本文整理汇总了PHP中Zend\Mvc\Controller\PluginManager::has方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginManager::has方法的具体用法?PHP PluginManager::has怎么用?PHP PluginManager::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Controller\PluginManager
的用法示例。
在下文中一共展示了PluginManager::has方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDefinesFactoryForIdentityPlugin
public function testDefinesFactoryForIdentityPlugin()
{
$pluginManager = new PluginManager();
$this->assertTrue($pluginManager->has('identity'));
}
示例2: 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;
}
//.........这里部分代码省略.........