public function getResponsibleService(User $user, $deliveryId = null)
    {
        if (!isset($this->service))
        {
            /** @var DelegatedServiceHandler $handler */
            foreach ($this->getOption(self::SERVICE_HANDLERS) as $handler) {
                if (!is_a($handler, DelegatedServiceHandler::class)) {
                    throw new \common_exception_NoImplementation('Handler should be instance of DelegatorServiceHandler.');
                }
                $handler->setServiceLocator($this->getServiceLocator());
                if ($handler->isSuitable($user, $deliveryId)) {
                    $this->service = $handler;
                    break;
                }
            }
        }
        return $this->service;
    }
public function getResponsibleService(User $user, $deliveryId = null)
    {
        if (!isset($this->service))
        {
            /** @var DelegatedServiceHandler $handler */
            foreach ($this->getOption(self::SERVICE_HANDLERS) as $handler) {
                if (!is_a($handler, DelegatedServiceHandler::class)) {
                    throw new \common_exception_NoImplementation('Handler should be instance of DelegatorServiceHandler.');
                }
                $handler->setServiceLocator($this->getServiceLocator());
                if ($handler->isSuitable($user, $deliveryId)) {
                    $this->service = $handler;
                    break;
                }
            }
        }
        return $this->service;
    }
public function getResponsibleService ( User $ user , $ deliveryId = null ) { if ( ! isset ( $ this -> service ) ) { /** @var DelegatedServiceHandler $handler */ foreach ( $ this -> getOption ( self :: SERVICE_HANDLERS ) as $ handler ) { if ( ! is_a ( $ handler , DelegatedServiceHandler :: class ) ) { throw new \ common_exception_NoImplementation ( 'Handler should be instance of DelegatorServiceHandler.' ) ; } $ handler -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; if ( $ handler -> isSuitable ( $ user , $ deliveryId ) ) { $ this -> service = $ handler ; break ; } } } return $ this -> service ; }
Returns applicable service

@throws \common_exception_NoImplementation
@param $user
@param $deliveryId
@return DelegatedServiceHandler
Returns applicable service