本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}