Zend\Mvc\Application::__construct PHP Method

__construct() public method

Constructor
public __construct ( Zend\ServiceManager\ServiceManager $serviceManager, Zend\EventManager\EventManagerInterface $events = null, Zend\Stdlib\RequestInterface $request = null, Zend\Stdlib\ResponseInterface $response = null )
$serviceManager Zend\ServiceManager\ServiceManager
$events Zend\EventManager\EventManagerInterface
$request Zend\Stdlib\RequestInterface
$response Zend\Stdlib\ResponseInterface
    public function __construct(ServiceManager $serviceManager, EventManagerInterface $events = null, RequestInterface $request = null, ResponseInterface $response = null)
    {
        $this->serviceManager = $serviceManager;
        $this->setEventManager($events ?: $serviceManager->get('EventManager'));
        $this->request = $request ?: $serviceManager->get('Request');
        $this->response = $response ?: $serviceManager->get('Response');
    }

Usage Example

Example #1
0
 public function __construct($configuration, ServiceManager $serviceManager)
 {
     parent::__construct($configuration, $serviceManager);
     $this->baseXMSEventManager = new EventManager();
     // shortcut the control lookup
     $this->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, array($this, 'onDispatch'));
     //TODO: moving to a dedicated function
     $this->serviceManager->setFactory('log', 'BaseXMS\\Log\\Factory');
     $this->serviceManager->setService('user', new \BaseXMS\User());
 }