More Related Content
Similar to Dependency Injection in Zend Framework and Symfony explained
Similar to Dependency Injection in Zend Framework and Symfony explained (20)
Dependency Injection in Zend Framework and Symfony explained
- 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