本文整理汇总了PHP中Zend\Mvc\Controller\PluginManager类的典型用法代码示例。如果您正苦于以下问题:PHP PluginManager类的具体用法?PHP PluginManager怎么用?PHP PluginManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PluginManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$plugins = new ControllerPluginManager();
$selector = $plugins->get('AcceptableViewModelSelector');
$this->listener = new AcceptListener($selector, array(
'controllers' => array(
'ZFTest\ContentNegotiation\TestAsset\ContentTypeController' => 'Json',
),
'selectors' => array(
'Json' => array(
'Zend\View\Model\JsonModel' => array(
'application/json',
'application/*+json',
),
),
),
));
$this->event = new MvcEvent();
$this->controller = new TestAsset\ContentTypeController();
$this->event->setTarget($this->controller);
$this->event->setRequest(new Request);
$this->event->setRouteMatch(new RouteMatch(array(
'controller' => __NAMESPACE__ . '\TestAsset\ContentTypeController',
)));
$this->controller->setEvent($this->event);
$this->controller->setRequest($this->event->getRequest());
$this->controller->setPluginManager($plugins);
}
示例2: testGetWithConstrutorAndOptions
public function testGetWithConstrutorAndOptions()
{
$pluginManager = new PluginManager();
$pluginManager->setInvokableClass('samplePlugin', 'ZendTest\\Mvc\\Controller\\Plugin\\TestAsset\\SamplePluginWithConstructor');
$plugin = $pluginManager->get('samplePlugin', 'foo');
$this->assertEquals($plugin->getBar(), 'foo');
}
示例3: __invoke
/**
* {@inheritdoc}
*
* @param PluginManager $pluginManager
*
* @return InitMetaTags
*/
public function __invoke(PluginManager $pluginManager)
{
/* @var \Zend\ServiceManager\ServiceManager */
$viewHelper = $pluginManager->getController()->getServiceLocator()->get('ViewHelperManager');
/*
* @var \Zend\View\Helper\Placeholder\Container
*/
$placeholderContainer = $viewHelper->get('placeholder')->getContainer('customHead');
/*
* @var \Zend\View\Helper\HeadMeta
*/
$headMeta = $viewHelper->get('HeadMeta');
/*
* @var \Zend\Http\PhpEnvironment\Request
*/
$request = $pluginManager->getController()->getRequest();
/*
* @var \SD\Application\Controller\Plugin\SystemSettings
*/
$systemSettings = $pluginManager->get('systemsettings');
/*
* @var InitMetaTags
*/
$plugin = new InitMetaTags($placeholderContainer, $headMeta, $request, $systemSettings);
return $plugin;
}
示例4: __invoke
/**
* {@inheritdoc}
*
* @param PluginManager $pluginManager
*
* @return Translate
*/
public function __invoke(PluginManager $pluginManager)
{
/* @var \Zend\ServiceManager\ServiceManager */
$translator = $pluginManager->getController()->getServiceLocator()->get('translator')->getTranslator();
$plugin = new Translate($translator);
return $plugin;
}
示例5: __invoke
/**
* {@inheritdoc}
*/
public function __invoke(PluginManager $pluginManager)
{
/* @var Zend\ServiceManager\ServiceManager */
$serviceLocator = $pluginManager->getController()->getServiceLocator();
$plugin = new GetTableModel($serviceLocator);
return $plugin;
}
示例6: url
/**
* Retourne le plugin url.
*
* @var \Zend\Mvc\Controller\PluginManager
*/
public function url()
{
if (!$this->_url) {
$this->_url = $this->_pluginManager->get('url');
}
return $this->_url;
}
示例7: 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);
}
示例8: 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);
}
示例9: __invoke
/**
* {@inheritdoc}
*/
public function __invoke(PluginManager $pluginManager)
{
$controller = $pluginManager->getController();
$layout = $controller->layout();
$response = $controller->getResponse();
$plugin = new ErrorCodes($layout, $response);
return $plugin;
}
示例10: testCreateService
public function testCreateService()
{
$pm = new ControllerPluginManager();
$sm = new ServiceManager();
$sm->setService('AcMailer\\Service\\MailService', new MailServiceMock());
$pm->setServiceLocator($sm);
$this->assertInstanceOf('AcMailer\\Controller\\Plugin\\SendMailPlugin', $this->factory->createService($pm));
}
示例11: testCanCreateByFactoryWithConstrutor
public function testCanCreateByFactoryWithConstrutor()
{
$pluginManager = new PluginManager();
$pluginManager->setFactory('samplePlugin', 'ZendTest\\Mvc\\Controller\\Plugin\\TestAsset\\SamplePluginWithConstructorFactory');
$plugin = $pluginManager->get('samplePlugin', 'foo');
$this->assertInstanceOf('\\ZendTest\\Mvc\\Controller\\Plugin\\TestAsset\\SamplePluginWithConstructor', $plugin);
$this->assertEquals($plugin->getBar(), 'foo');
}
示例12: createControllerManager
protected function createControllerManager($config = [])
{
$pm = new ControllerPluginManager();
$sm = new ServiceManager();
$sm->setService('Config', $config);
$pm->setServiceLocator($sm);
return $pm;
}
示例13: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
$this->serviceManager = Bootstrap::getServiceManager();
$this->entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default');
$this->createMergedDocument = new CreateMergedDocument();
$pluginManager = new PluginManager();
$pluginManager->setServiceLocator($this->serviceManager);
$this->createMergedDocument->setServiceLocator($pluginManager);
}
示例14: 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);
}
示例15: __invoke
/**
* {@inheritdoc}
*
* @param PluginManager $pluginManager
*
* @return GetUrlParams
*/
public function __invoke(PluginManager $pluginManager)
{
/*
* @var \Zend\Mvc\Controller\Plugin\Params
*/
$params = $pluginManager->get('params');
$plugin = new GetUrlParams($params);
return $plugin;
}