本文整理汇总了PHP中Zend\Mvc\Controller\PluginManager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginManager::get方法的具体用法?PHP PluginManager::get怎么用?PHP PluginManager::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Controller\PluginManager
的用法示例。
在下文中一共展示了PluginManager::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: testLoginProxiesToZfcUserAndReturnsNonModelInterface
public function testLoginProxiesToZfcUserAndReturnsNonModelInterface()
{
/** @var $forwardPlugin \Mockery\MockInterface */
$forwardPlugin = $this->pm->get('forward');
$forwardPlugin->shouldReceive('dispatch')->with('zfcuser', array('action' => 'login'))->andReturn('zfc-user-login');
$result = $this->dispatch('login');
$this->assertEquals('zfc-user-login', $result);
}
示例3: __invoke
/**
* {@inheritdoc}
*
* @param PluginManager $pluginManager
*
* @return Mailing
*/
public function __invoke(PluginManager $pluginManager)
{
/* @var \Zend\Mvc\Controller\Plugin\FlashMessenger */
$flashmessenger = $pluginManager->get('flashmessenger');
/* @var \SD\Application\Controller\Plugin\SystemSettings */
$systemsettings = $pluginManager->get('systemsettings');
$plugin = new Mailing($flashmessenger, $systemsettings);
return $plugin;
}
示例4: testPlugin
public function testPlugin()
{
$config = (include __DIR__ . '/../../../../config/module.config.php');
$plugins = new PluginManager(new Config($config['controller_plugins']));
$plugin = $plugins->get('CsvExport');
$this->assertInstanceOf('RdnCsv\\Controller\\Plugin\\CsvExport', $plugin);
$anotherPlugin = $plugins->get('CsvExport');
$this->assertFalse($plugin === $anotherPlugin);
}
示例5: testPluginManagerInjectsControllerForExistingPlugin
public function testPluginManagerInjectsControllerForExistingPlugin()
{
$controller1 = new SampleController();
$pluginManager = new PluginManager();
$pluginManager->setInvokableClass('samplePlugin', 'ZendTest\\Mvc\\Controller\\Plugin\\TestAsset\\SamplePlugin');
$pluginManager->setController($controller1);
// Plugin manager registers now instance of SamplePlugin
$pluginManager->get('samplePlugin');
$controller2 = new SampleController();
$pluginManager->setController($controller2);
$plugin = $pluginManager->get('samplePlugin');
$this->assertEquals($controller2, $plugin->getController());
}
示例6: __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;
}
示例7: 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);
}
示例8: 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');
}
示例9: 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');
}
示例10: __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;
}
示例11: setUp
public function setUp()
{
$plugins = new ControllerPluginManager(new ServiceManager());
$selector = $plugins->get('AcceptableViewModelSelector');
$this->listener = new AcceptListener($selector, ['controllers' => ['ZFTest\\ContentNegotiation\\TestAsset\\ContentTypeController' => 'Json'], 'selectors' => ['Json' => ['Zend\\View\\Model\\JsonModel' => ['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($this->createRouteMatch(['controller' => __NAMESPACE__ . '\\TestAsset\\ContentTypeController']));
$this->controller->setEvent($this->event);
$this->controller->setRequest($this->event->getRequest());
$this->controller->setPluginManager($plugins);
}
示例12: buildGraph
/**
* @param $className
*
* @return object
* @throws \Exception
*/
private function buildGraph($className)
{
if ($this->enableObjectGraphDebug) {
echo 'Building an object from the class: ' . $className . "<br />";
}
try {
$reflection = new \ReflectionClass($className);
} catch (\Exception $e) {
if ($this->enableObjectGraphDebug) {
echo 'Could not build a reflection class for ' . $className . "<br />";
}
return false;
}
if (!$reflection->getConstructor()) {
if ($this->enableObjectGraphDebug) {
echo 'We have build an object for class ' . $className . "<br />";
}
return new $className();
}
$constructorParameters = $reflection->getConstructor()->getParameters();
$dependencies = [];
foreach ($constructorParameters as $param) {
try {
$paramClassName = $param->getClass();
} catch (\Exception $e) {
throw new \Exception('Could not create dependency class "' . $param->getName() . '" for the currently building class: ' . $className);
}
if (!$paramClassName) {
switch (true) {
case $this->controllerPluginManager->has($param->name, false):
if ($this->enableObjectGraphDebug) {
echo 'The parameter "' . $param->name . '" exists in Controller Manager' . "<br />";
}
$dependencies[] = $this->controllerPluginManager->get($param->name);
break;
case $this->serviceManager->has($param->name, false):
if ($this->enableObjectGraphDebug) {
echo 'The parameter "' . $param->name . '" exists in Service Manager' . "<br />";
}
$dependencies[] = $this->serviceManager->get($param->name);
break;
default:
if ($param->isOptional()) {
$dependencies[] = $param->getDefaultValue();
} else {
if ($this->enableObjectGraphDebug) {
echo 'The parameter "' . $param->name . '" does not exist in (any) Service Manager' . "<br />";
}
echo 'The parameter "' . $param->name . '" does not exist in the Service Manager' . "<br />";
die;
}
break;
}
} else {
if ($this->enableObjectGraphDebug) {
echo 'Does the SM have an object for ' . $param->getClass()->name . "<br />";
}
switch (true) {
case $this->controllerPluginManager->has($param->getClass()->name, false, false):
if ($this->enableObjectGraphDebug) {
echo 'It does in the Controller Plugin Manager' . "<br />";
}
$dependencies[] = $this->controllerPluginManager->get($param->getClass()->name);
break;
case $this->viewHelperManager->has($param->getClass()->name, false, false):
if ($this->enableObjectGraphDebug) {
echo 'It does in the View Helper Manager' . "<br />";
}
$dependencies[] = $this->viewHelperManager->get($param->getClass()->name);
break;
case $this->formElementManager->has($param->getClass()->name, false, false):
if ($this->enableObjectGraphDebug) {
echo 'It does in the Form Element Manager' . "<br />";
}
$dependencies[] = $this->formElementManager->get($param->getClass()->name);
break;
case $this->serviceManager->has($param->getClass()->name, false, false):
if ($this->enableObjectGraphDebug) {
echo 'It does in the Service Manager' . "<br />";
}
$name = $param->getClass()->name;
if ($this->serviceManager->hasAlias($name)) {
$config = $this->serviceManager->get('config')['service_manager'];
$name = $config['aliases'][$name];
}
$dependencies[] = $this->serviceManager->get($name);
break;
default:
if ($this->enableObjectGraphDebug) {
echo 'No it It does not have an object' . "<br />";
}
if ($param->getClass()->isInterface()) {
continue;
}
//.........这里部分代码省略.........
示例13: it_should_handle_valid_post_to_a_delete_action
/**
* @param \Zend\Http\PhpEnvironment\Request $request
* @param \Zend\Mvc\MvcEvent $mvcEvent
* @param \Phpro\SmartCrud\Service\DeleteService $smartService
* @param \Phpro\SmartCrud\Service\SmartServiceResult $smartResult
* @param \Zend\Mvc\Controller\PluginManager $pluginManager
* @param \Zend\Mvc\Controller\Plugin\Redirect $redirectPlugin
* @param \Zend\Mvc\Controller\Plugin\Params $params
*/
public function it_should_handle_valid_post_to_a_delete_action($request, $mvcEvent, $smartService, $smartResult, $pluginManager, $redirectPlugin, $params)
{
$postParameters = array('property' => 'value');
$action = 'delete';
$smartResult->isSuccessFull()->shouldBeCalled()->willReturn(true);
$smartService->run(Argument::any(), Argument::exact($postParameters))->shouldBeCalled()->willReturn($smartResult);
$pluginManager->get(Argument::exact('params'), null)->shouldBeCalled()->willReturn($params);
$params->__invoke()->willReturn($params);
$params->fromRoute(Argument::exact('id'), null)->shouldBeCalled()->willReturn(1);
$pluginManager->get(Argument::exact('redirect'), null)->shouldBeCalled()->willReturn($redirectPlugin);
$redirectPlugin->toRoute(Argument::exact(null), Argument::exact(array('action' => 'list')), true)->shouldBeCalled()->willReturn('mockRedirect');
$this->setSmartService($smartService);
$this->mockValidPost($request, $mvcEvent, $pluginManager, $params, $action, $postParameters);
}
示例14: plugin
/**
* Get plugin instance
*
* @param string $name Name of plugin to return
* @param null|array $options Options to pass to plugin constructor (if not already instantiated)
*
* @return mixed
*/
public function plugin($name, array $options = null)
{
return $this->pluginManager->get($name, $options);
}
示例15: getFlashMessenger
/**
* @return \Zend\Mvc\Plugin\FlashMessenger\FlashMessenger
*/
protected function getFlashMessenger()
{
return $this->controllerPluginManager->get('flashMessenger');
}