本文整理汇总了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');
}
示例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());
}
示例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);
}
示例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());
}
示例5: generatePluginManager
private function generatePluginManager()
{
$pluginManager = new ControllerPluginManager();
$pluginManager->setInvokableClass('params', 'Acelaya\\QrCode\\Test\\Controller\\Plugin\\ParamsMock');
return $pluginManager;
}