當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PluginManager::setInvokableClass方法代碼示例

本文整理匯總了PHP中Zend\Mvc\Controller\PluginManager::setInvokableClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP PluginManager::setInvokableClass方法的具體用法?PHP PluginManager::setInvokableClass怎麽用?PHP PluginManager::setInvokableClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Mvc\Controller\PluginManager的用法示例。


在下文中一共展示了PluginManager::setInvokableClass方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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');
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:7,代碼來源:PluginManagerTest.php

示例2: 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());
 }
開發者ID:haoyanfei,項目名稱:zf2,代碼行數:13,代碼來源:PluginManagerTest.php

示例3: testProcessPutRequest

 public function testProcessPutRequest()
 {
     $currentDir = getcwd();
     $tmpDir = sys_get_temp_dir() . "/" . uniqid(__NAMESPACE__ . '_');
     mkdir($tmpDir);
     mkdir("{$tmpDir}/module/Foo", 0775, true);
     mkdir("{$tmpDir}/config");
     file_put_contents("{$tmpDir}/config/application.config.php", '<' . '?php return array(\'modules\'=>array(\'Foo\'));');
     file_put_contents("{$tmpDir}/module/Foo/Module.php", "<" . "?php\n\nnamespace Foo;\n\nclass Module\n{\n}");
     chdir($tmpDir);
     require 'module/Foo/Module.php';
     $moduleManager = $this->getMockBuilder('Zend\\ModuleManager\\ModuleManager')->disableOriginalConstructor()->getMock();
     $moduleManager->expects($this->any())->method('getLoadedModules')->will($this->returnValue(['Foo' => new \Foo\Module()]));
     $moduleResource = new ModuleModel($moduleManager, [], []);
     $controller = new ModuleCreationController($moduleResource);
     $request = new Request();
     $request->setMethod('put');
     $request->getHeaders()->addHeaderLine('Accept', 'application/json');
     $request->getHeaders()->addHeaderLine('Content-Type', 'application/json');
     $parameters = new ParameterDataContainer();
     $parameters->setBodyParam('module', 'Foo');
     $event = new MvcEvent();
     $event->setParam('ZFContentNegotiationParameterData', $parameters);
     $plugins = new PluginManager();
     $plugins->setInvokableClass('bodyParam', 'ZF\\ContentNegotiation\\ControllerPlugin\\BodyParam');
     $controller->setRequest($request);
     $controller->setEvent($event);
     $controller->setPluginManager($plugins);
     $result = $controller->apiEnableAction();
     $this->assertInstanceOf('ZF\\ContentNegotiation\\ViewModel', $result);
     $payload = $result->getVariable('payload');
     $entity = method_exists($payload, 'getEntity') ? $payload->getEntity() : $payload->entity;
     $this->assertInstanceOf('ZF\\Hal\\Entity', $payload);
     $this->assertInstanceOf('ZF\\Apigility\\Admin\\Model\\ModuleEntity', $entity);
     $this->assertEquals('Foo', $entity->getName());
     $this->removeDir($tmpDir);
     chdir($currentDir);
 }
開發者ID:antarus,項目名稱:mystra-pve,代碼行數:38,代碼來源:ModuleCreationControllerTest.php

示例4: testAddInputFilter

 public function testAddInputFilter()
 {
     $inputFilter = [['name' => 'bar', 'validators' => [['name' => 'NotEmpty', 'options' => ['type' => 127]], ['name' => 'Digits']]]];
     $request = new Request();
     $request->setMethod('put');
     $request->setContent(json_encode($inputFilter));
     $request->getHeaders()->addHeaderLine('Accept', 'application/json');
     $request->getHeaders()->addHeaderLine('Content-Type', 'application/json');
     $module = 'InputFilter';
     $controller = 'InputFilter\\V1\\Rest\\Foo\\Controller';
     $params = ['name' => $module, 'controller_service_name' => $controller];
     $routeMatch = new RouteMatch($params);
     $routeMatch->setMatchedRouteName('zf-apigility-admin/api/module/rest-service/rest_input_filter');
     $event = new MvcEvent();
     $event->setRouteMatch($routeMatch);
     $parameters = new ParameterDataContainer();
     $parameters->setBodyParams($inputFilter);
     $event->setParam('ZFContentNegotiationParameterData', $parameters);
     $plugins = new PluginManager();
     $plugins->setInvokableClass('bodyParams', 'ZF\\ContentNegotiation\\ControllerPlugin\\BodyParams');
     $this->controller->setRequest($request);
     $this->controller->setEvent($event);
     $this->controller->setPluginManager($plugins);
     $result = $this->controller->indexAction();
     $this->assertInstanceOf('ZF\\ContentNegotiation\\ViewModel', $result);
     $payload = $result->payload;
     $this->assertInstanceOf('ZF\\Hal\\Entity', $payload);
     $entity = $payload->entity;
     $this->assertInstanceOf('ZF\\Apigility\\Admin\\Model\\InputFilterEntity', $entity);
     $config = (include $this->basePath . '/module.config.php');
     $validator = $config['zf-content-validation'][$controller]['input_filter'];
     $expected = $config['input_filter_specs'][$validator];
     $expected['input_filter_name'] = $validator;
     $this->assertEquals($expected, $entity->getArrayCopy());
 }
開發者ID:erik-maas,項目名稱:zf-apigility-admin,代碼行數:35,代碼來源:InputFilterControllerTest.php

示例5: generatePluginManager

 private function generatePluginManager()
 {
     $pluginManager = new ControllerPluginManager();
     $pluginManager->setInvokableClass('params', 'Acelaya\\QrCode\\Test\\Controller\\Plugin\\ParamsMock');
     return $pluginManager;
 }
開發者ID:acelaya,項目名稱:zf2-acqrcode,代碼行數:6,代碼來源:QrCodeControllerTest.php


注:本文中的Zend\Mvc\Controller\PluginManager::setInvokableClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。