More Related Content
Similar to ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency Injection)
Similar to ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency Injection) (20)
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency Injection)
- 18. //[..................] /** * Inject properties on Pre-Dispatch */ public function preDispatch() { $actionController = $this ->getActionController(); $class = new Zend_Reflection_Class( $actionController ); $properties = $class ->getProperties(); /* @var $property Zend_Reflection_Property */ foreach ( $properties as $property ) { if ( $property ->getDocComment()->hasTag( 'Inject' )) { $injectTag = $property ->getDocComment()->getTag( 'Inject' ); $serviceName = $injectTag ->getDescription(); if ( empty ( $serviceName )) { $serviceName = $this ->_formatServiceName( $property ->getName()); } if ( isset ( $this ->_сontainer-> $serviceName )) { $this ->_injectProperty( $property , $this ->_container-> $serviceName ); } } } }
Editor's Notes
- * Instead of your program running the system, the system runs your program * Controller