本文整理匯總了PHP中Zend\View\HelperPluginManager::has方法的典型用法代碼示例。如果您正苦於以下問題:PHP HelperPluginManager::has方法的具體用法?PHP HelperPluginManager::has怎麽用?PHP HelperPluginManager::has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\View\HelperPluginManager
的用法示例。
在下文中一共展示了HelperPluginManager::has方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: perform_do
public function perform_do($args)
{
$name = array_shift($args);
if (is_string($name) == false) {
return null;
}
if ($this->helpers->has($name) == false) {
return null;
}
call_user_func_array($this->helpers->get($name), $args);
}
示例2: setHelperPluginManager
/**
* Set helper plugin manager instance.
*
* Also ensures that the 'Hal' helper is present.
*
* @param HelperPluginManager $helpers
*/
public function setHelperPluginManager(HelperPluginManager $helpers)
{
if (!$helpers->has('Hal')) {
$this->injectHalHelper($helpers);
}
$this->helpers = $helpers;
}
示例3: 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;
}
//.........這裏部分代碼省略.........
示例4: testInjectsCustomHelpersIntoHelperManagerFromContainer
/**
* @depends testWillUseHelperManagerFromContainer
*/
public function testInjectsCustomHelpersIntoHelperManagerFromContainer(HelperPluginManager $helpers)
{
$this->assertTrue($helpers->has('url'));
$this->assertTrue($helpers->has('serverurl'));
$this->assertInstanceOf(ZendView\UrlHelper::class, $helpers->get('url'));
$this->assertInstanceOf(ZendView\ServerUrlHelper::class, $helpers->get('serverurl'));
}