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


PHP PluginManager::setService方法代码示例

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


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

示例1: testGetMethod

 public function testGetMethod()
 {
     $expected = array('test1' => 'Testing Var 1', 'test2' => 'Testing Var 2');
     $this->rcmIsSiteAdminPlugin->expects($this->any())->method('__invoke')->will($this->returnValue(true));
     $parmsMock = $this->getMockBuilder('\\Zend\\Mvc\\Controller\\Plugin\\Params')->disableOriginalConstructor()->getMock();
     $parmsMock->expects($this->any())->method('__invoke')->will($this->returnValue('someUserName'));
     $this->pluginManager->setService('params', $parmsMock);
     $this->mockApi->expects($this->once())->method('getEmbed')->with($this->equalTo('someUserName'), $this->equalTo(22))->will($this->returnValue($expected));
     $result = $this->controller->get(22);
     $this->assertInstanceOf('\\Zend\\View\\Model\\JsonModel', $result);
     $jsonResult = $result->serialize();
     $this->assertEquals(json_encode($expected), $jsonResult);
 }
开发者ID:reliv,项目名称:rcm-issuu,代码行数:13,代码来源:DocumentListControllerTest.php

示例2: setUp

 public function setUp()
 {
     $this->sm = new ServiceManager();
     $this->pm = new PluginManager();
     $this->event = new MvcEvent();
     $this->request = new Request();
     $this->controller = new UserController();
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->sm);
     $this->controller->setPluginManager($this->pm);
     $forwardPlugin = \Mockery::mock('Zend\\Mvc\\Controller\\Plugin\\Forward[dispatch]');
     $this->pm->setService('forward', $forwardPlugin);
 }
开发者ID:aapthi,项目名称:video-collections,代码行数:13,代码来源:UserControllerTest.php

示例3: setUp

 public function setUp()
 {
     $this->controller = $controller = new RestController();
     $this->router = $router = new SimpleRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch(array()));
     $controller->setEvent($event);
     $controller->setRoute('resource');
     $pluginManager = new PluginManager();
     $pluginManager->setService('bodyParams', new BodyParams());
     $controller->setPluginManager($pluginManager);
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $linksHelper = new HalHelper();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $pluginManager->setService('Hal', $linksHelper);
     $linksHelper->setController($controller);
     $this->resource = $resource = new Resource();
     $controller->setResource($resource);
 }
开发者ID:noc-med,项目名称:zf-rest,代码行数:27,代码来源:RestControllerTest.php

示例4: setupHelpers

    public function setupHelpers()
    {
        if (!$this->router) {
            $this->setupRouter();
        }

        $urlHelper = new UrlHelper();
        $urlHelper->setRouter($this->router);

        $serverUrlHelper = new ServerUrlHelper();
        $serverUrlHelper->setScheme('http');
        $serverUrlHelper->setHost('localhost.localdomain');

        $linksHelper = new HalHelper();
        $linksHelper->setUrlHelper($urlHelper);
        $linksHelper->setServerUrlHelper($serverUrlHelper);

        $this->helpers = $helpers = new HelperPluginManager();
        $helpers->setService('url', $urlHelper);
        $helpers->setService('serverUrl', $serverUrlHelper);
        $helpers->setService('hal', $linksHelper);

        $this->plugins = $plugins = new ControllerPluginManager();
        $plugins->setService('hal', $linksHelper);
    }
开发者ID:jbarentsen,项目名称:drb,代码行数:25,代码来源:ChildEntitiesIntegrationTest.php

示例5: setupMockFlashMessenger

 private function setupMockFlashMessenger($messageType)
 {
     $flashMessenger = $this->getMock('Zend\\Mvc\\Controller\\Plugin\\FlashMessenger');
     $flashMessenger->expects($this->any())->method('has' . $messageType . 'Messages')->will($this->returnValue(true));
     $flashMessenger->expects($this->any())->method('get' . $messageType . 'Messages')->will($this->returnValue($this->testMessages));
     $plugins = new PluginManager();
     $plugins->setService('FlashMessenger', $flashMessenger);
     $this->controller->setPluginManager($plugins);
 }
开发者ID:netsensia,项目名称:zf2-foundation,代码行数:9,代码来源:NetsensiaActionControllerTest.php

示例6: getTestTarget

 /**
  *
  * @return ViewController
  */
 private function getTestTarget()
 {
     $target = $this->getSimpleTarget();
     $params = $this->getMockBuilder(Params::class)->disableOriginalConstructor()->setMethods(['__invoke'])->getMock();
     $params->expects($this->once())->method('__invoke')->with('id')->willReturn(1234);
     $plugins = new PluginManager();
     $plugins->setService('params', $params);
     $target->setPluginManager($plugins);
     return $target;
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:14,代码来源:ViewControllerTest.php

示例7: setupHelpers

 public function setupHelpers()
 {
     if (!$this->router) {
         $this->setupRouter();
     }
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $propertiesHelper = new JsonLDHelper();
     $propertiesHelper->setUrlHelper($urlHelper);
     $propertiesHelper->setServerUrlHelper($serverUrlHelper);
     $propertyExtractor = new PropertyExtractor($serverUrlHelper, $urlHelper);
     $propertyCollectionExtractor = new PropertyCollectionExtractor($propertyExtractor);
     $propertiesHelper->setPropertyCollectionExtractor($propertyCollectionExtractor);
     $this->helpers = $helpers = new HelperPluginManager();
     $helpers->setService('url', $urlHelper);
     $helpers->setService('serverUrl', $serverUrlHelper);
     $helpers->setService('JsonLD', $propertiesHelper);
     $this->plugins = $plugins = new ControllerPluginManager();
     $plugins->setService('JsonLD', $propertiesHelper);
 }
开发者ID:vixriihi,项目名称:zf-jsonld,代码行数:23,代码来源:ChildEntitiesIntegrationTest.php

示例8: setUpContentNegotiation

 public function setUpContentNegotiation($controller)
 {
     $plugins = new ControllerPluginManager();
     $plugins->setService('Hal', $this->linksHelper);
     $controller->setPluginManager($plugins);
     $viewModelSelector = $plugins->get('AcceptableViewModelSelector');
     $acceptListener = new AcceptListener($viewModelSelector, ['controllers' => [], 'selectors' => ['HalJson' => ['ZF\\Hal\\View\\HalJsonModel' => ['application/json']]]]);
     $controller->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, $acceptListener, -10);
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:9,代码来源:CollectionIntegrationTest.php

示例9: getMockApplication

 /**
  * Create mock Application with ServiceManager, controller plugin
  * manager, mock redirect plugin, authentication service, and access 
  * service (optional)
  * 
  * @return \Zend\Mvc\Application|PHPUnit_Framework_MockObject_MockObject
  */
 protected function getMockApplication($authenticated = false, $access = null)
 {
     $services = new ServiceManager();
     $response = new Response();
     $response->setStatusCode(302);
     $redirect = $this->getMock('Zend\\Mvc\\Controller\\Plugin\\Redirect');
     $redirect->method('toUrl')->willReturn($response);
     $redirect->method('toRoute')->willReturn($response);
     $pluginManager = new PluginManager();
     $pluginManager->setService('redirect', $redirect);
     $services->setService('controllerPluginManager', $pluginManager);
     $auth = new AuthenticationService();
     if (true === $authenticated) {
         $auth->getStorage()->write(true);
     }
     $services->setService('auth', $auth);
     if (null !== $access) {
         $access->setServices($services);
         $access->setAuthenticationService($auth);
         $services->setService(ServiceFactory::SERVICE, $access);
     }
     $application = $this->getMockBuilder('Zend\\Mvc\\Application')->disableOriginalConstructor()->getMock();
     $application->method('getServiceManager')->willReturn($services);
     return $application;
 }
开发者ID:sporkcode,项目名称:sporktools,代码行数:32,代码来源:AccessListenerTest.php

示例10: setUpController

 public function setUpController()
 {
     $this->setUpRouter();
     $this->setUpListeners();
     $resource = new Resource();
     $events = $resource->getEventManager();
     $events->attach($this->listeners);
     $controller = $this->controller = new ResourceController('Api\\ResourceController');
     $controller->setResource($resource);
     $controller->setIdentifierName('id');
     $controller->setPageSize(3);
     $controller->setRoute('resource');
     $controller->setEvent($this->getEvent());
     $plugins = new ControllerPluginManager();
     $plugins->setService('HalLinks', $this->linksHelper);
     $controller->setPluginManager($plugins);
 }
开发者ID:davidbrabrand,项目名称:PhlyRestfully,代码行数:17,代码来源:CollectionIntegrationTest.php


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