当前位置: 首页>>代码示例>>PHP>>正文


PHP ControllerManager::has方法代码示例

本文整理汇总了PHP中Zend\Mvc\Controller\ControllerManager::has方法的典型用法代码示例。如果您正苦于以下问题:PHP ControllerManager::has方法的具体用法?PHP ControllerManager::has怎么用?PHP ControllerManager::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Mvc\Controller\ControllerManager的用法示例。


在下文中一共展示了ControllerManager::has方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mockConfiguration

 /**
  * @param \Zend\Mvc\Controller\ControllerManager       $controllerManager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @param array                                        $routeParams
  */
 protected function mockConfiguration($controllerManager, $serviceLocator, $routeParams = array('action' => 'list'))
 {
     $prophet = new Prophet();
     $controllerKey = 'Phpro\\SmartCrud\\Controller\\CrudController';
     $serviceKey = 'Phpro\\SmartCrud\\Service\\AbstractSmartService';
     $viewBuilderKey = 'Phpro\\SmartCrud\\View\\Model\\ViewModelBuilder';
     $controllerManager->getServiceLocator()->willReturn($serviceLocator);
     // Mock config
     $serviceLocator->has('Config')->willReturn(true);
     $serviceLocator->get('Config')->willReturn(array(AbstractCrudControllerFactory::FACTORY_NAMESPACE => array('custom-controller' => array(AbstractCrudControllerFactory::CONFIG_CONTROLLER => $controllerKey, AbstractCrudControllerFactory::CONFIG_IDENTIFIER => 'id', AbstractCrudControllerFactory::CONFIG_SMART_SERVICE => $serviceKey), 'fault-controller' => array(AbstractCrudControllerFactory::CONFIG_CONTROLLER => 'invalid-controller'), 'fault-service' => array(AbstractCrudControllerFactory::CONFIG_SMART_SERVICE => 'invalid-service'))));
     // Mock controller
     $controller = $prophet->prophesize('\\Phpro\\SmartCrud\\Controller\\CrudController');
     $controllerManager->has($controllerKey)->willReturn(true);
     $controllerManager->get($controllerKey)->willReturn($controller);
     $controllerManager->has('invalid-controller')->willReturn(false);
     // Mock route
     $this->mockRouteMatch($serviceLocator, $routeParams);
     // Mock service
     $serviceKey = $serviceKey . '::' . $routeParams['action'];
     $service = $prophet->prophesize('\\Phpro\\SmartCrud\\Service\\AbstractSmartService');
     $serviceLocator->has($serviceKey)->willReturn(true);
     $serviceLocator->get($serviceKey)->willReturn($service);
     $serviceLocator->has('invalid-service::' . $routeParams['action'])->willReturn(false);
     $viewBuilder = $prophet->prophesize('\\Phpro\\SmartCrud\\View\\Model\\ViewModelBuilder');
     $serviceLocator->has($viewBuilderKey)->willReturn(true);
     $serviceLocator->get($viewBuilderKey)->willReturn($viewBuilder);
     $this->setServiceLocator($serviceLocator);
 }
开发者ID:phpro,项目名称:zf-smartcrud,代码行数:33,代码来源:AbstractCrudControllerFactorySpec.php

示例2: toUrl

 /**
  * Redirect with Handling against url.
  *
  * @param string $url
  *
  * @return Response
  */
 public function toUrl($url)
 {
     $allow_not_routed_url = isset($this->config['allow_not_routed_url']) ? $this->config['allow_not_routed_url'] : false;
     $exclude_urls = isset($this->config['options']['exclude_urls']) ? $this->config['options']['exclude_urls'] : [];
     $exclude_hosts = isset($this->config['options']['exclude_hosts']) ? $this->config['options']['exclude_hosts'] : [];
     $uriTargetHost = (new Uri($url))->getHost();
     if (true === $allow_not_routed_url || in_array($url, $exclude_urls) || in_array($uriTargetHost, $exclude_hosts)) {
         return parent::toUrl($url);
     }
     $controller = $this->getController();
     $request = $controller->getRequest();
     $current_uri = $request->getRequestUri();
     $request->setUri($url);
     $uriTarget = (new Uri($url))->__toString();
     if ($current_uri === $uriTarget) {
         $this->getEventManager()->trigger('redirect-same-url');
         return;
     }
     $mvcEvent = $this->getEvent();
     $routeMatch = $mvcEvent->getRouteMatch();
     $currentRouteMatchName = $routeMatch->getMatchedRouteName();
     $router = $mvcEvent->getRouter();
     $uriCurrentHost = (new Uri($router->getRequestUri()))->getHost();
     if (($routeToBeMatched = $router->match($request)) && ($uriTargetHost === null || $uriCurrentHost === $uriTargetHost) && (($routeToBeMatchedRouteName = $routeToBeMatched->getMatchedRouteName()) !== $currentRouteMatchName && ($this->manager->has($routeToBeMatched->getParam('controller')) || $routeToBeMatched->getParam('middleware') !== false) || $routeToBeMatched->getParam('action') != $routeMatch->getParam('action') || $routeToBeMatchedRouteName === $currentRouteMatchName)) {
         return parent::toUrl($url);
     }
     $default_url = isset($this->config['default_url']) ? $this->config['default_url'] : '/';
     return parent::toUrl($default_url);
 }
开发者ID:samsonasik,项目名称:RedirectHandlerModule,代码行数:36,代码来源:Redirect.php

示例3: testWillInstantiateControllersFromDiAbstractFactoryWhenWhitelisted

 public function testWillInstantiateControllersFromDiAbstractFactoryWhenWhitelisted()
 {
     $config = new ArrayObject(array('di' => array('instance' => array('alias' => array('my-controller' => 'stdClass')), 'allowed_controllers' => array('my-controller'))));
     $this->services->setAllowOverride(true);
     $this->services->setService('Config', $config);
     $this->loader = $this->services->get('ControllerLoader');
     $this->assertTrue($this->loader->has('my-controller'));
     // invalid controller exception (because we're getting an \stdClass after all)
     $this->setExpectedException('Zend\\Mvc\\Exception\\InvalidControllerException');
     $this->loader->get('my-controller');
 }
开发者ID:nieldm,项目名称:zf2,代码行数:11,代码来源:ControllerLoaderFactoryTest.php

示例4: testCreation

 public function testCreation()
 {
     $moduleManagerMock = $this->getMockBuilder('Zend\\ModuleManager\\ModuleManager')->disableOriginalConstructor()->getMock();
     $this->serviceManager->setService('ModuleManager', $moduleManagerMock);
     $this->assertTrue($this->controllerManager->has('Modules\\Controller\\Console\\List'));
     $controller = $this->controllerManager->get('Modules\\Controller\\Console\\List');
     $this->assertInstanceOf('Modules\\Controller\\Console\\ListController', $controller);
     $this->assertAttributeInstanceOf('ComposerLockParser\\ComposerInfo', 'composerInfo', $controller);
     $this->assertAttributeEquals($moduleManagerMock, 'moduleManager', $controller);
     $this->assertAttributeInstanceOf('Zend\\View\\Renderer\\PhpRenderer', 'renderer', $controller);
     $this->assertAttributeInstanceOf('Modules\\ViewModel\\Console\\ListViewModel', 'viewModel', $controller);
 }
开发者ID:t4web,项目名称:Modules,代码行数:12,代码来源:ListControllerTest.php

示例5: injectControllerClass

 /**
  * Inject the class name of the controller, if it can be resolved.
  *
  * @param RpcServiceEntity $service
  */
 protected function injectControllerClass(RpcServiceEntity $service)
 {
     $controllerServiceName = $service->controllerServiceName;
     if (!$this->controllerManager->has($controllerServiceName)) {
         return;
     }
     $controller = $this->controllerManager->get($controllerServiceName);
     $service->exchangeArray(['controller_class' => get_class($controller)]);
 }
开发者ID:zfcampus,项目名称:zf-apigility-admin,代码行数:14,代码来源:RpcServiceResource.php

示例6: has

 /**
  * Override: do not use peering service managers
  *
  * @param  string|array $name
  * @param  bool         $checkAbstractFactories
  * @param  bool         $usePeeringServiceManagers
  * @return bool
  * @SuppressWarnings(PHPMD.LongVariable)
  */
 public function has($name, $checkAbstractFactories = true, $usePeeringServiceManagers = false)
 {
     if (is_string($name) && $this->container->has($name)) {
         return true;
     } elseif (parent::has($name, $checkAbstractFactories, $usePeeringServiceManagers)) {
         return true;
     }
     return false;
 }
开发者ID:mnapoli,项目名称:php-di-zf2,代码行数:18,代码来源:ControllerManager.php

示例7: injectControllerClass

 /**
  * Inject the class name of the controller, if it can be resolved.
  *
  * @param DoctrineRpcServiceEntity $service
  */
 protected function injectControllerClass(DoctrineRpcServiceEntity $service)
 {
     $controllerServiceName = $service->controllerServiceName;
     if (!$this->controllerManager->has($controllerServiceName)) {
         // @codeCoverageIgnoreStart
         return;
         // @codeCoverageIgnoreEnd
     }
     $controller = $this->controllerManager->get($controllerServiceName);
     $service->exchangeArray(array('controller_class' => get_class($controller)));
 }
开发者ID:API-Skeletons,项目名称:zf-apigility-doctrine,代码行数:16,代码来源:DoctrineRpcServiceResource.php


注:本文中的Zend\Mvc\Controller\ControllerManager::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。