本文整理汇总了PHP中Zend\View\HelperPluginManager::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP HelperPluginManager::__construct方法的具体用法?PHP HelperPluginManager::__construct怎么用?PHP HelperPluginManager::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\HelperPluginManager
的用法示例。
在下文中一共展示了HelperPluginManager::__construct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param null|ConfigInterface|ContainerInterface $configOrContainerInstance
* @param array $v3config If $configOrContainerInstance is a container, this
* value will be passed to the parent constructor.
*/
public function __construct($configOrContainerInstance = null, array $v3config = [])
{
$this->initializers[] = function ($first, $second) {
// v2 vs v3 argument order
if ($first instanceof ContainerInterface) {
// v3
$container = $first;
$instance = $second;
} else {
// v2
$container = $second;
$instance = $first;
}
if (!$instance instanceof AbstractHelper) {
return;
}
// This initializer was written with v2 functionality in mind; as such,
// we need to test and see if we're called in a v2 context, and, if so,
// set the service locator to the parent locator.
//
// Under v3, the parent locator is what is passed to the method already.
if (!method_exists($container, 'configure') && $container->getServiceLocator()) {
$container = $container->getServiceLocator();
}
$instance->setServiceLocator($container);
};
parent::__construct($configOrContainerInstance, $v3config);
}
示例2: __construct
/**
* @param null|ConfigInterface|ContainerInterface $configOrContainerInstance
* @param array $v3config If $configOrContainerInstance is a container, this
* value will be passed to the parent constructor.
*/
public function __construct($configOrContainerInstance = null, array $v3config = [])
{
$this->initializers[] = function ($container, $instance) {
if (!$instance instanceof AbstractHelper) {
return;
}
$instance->setServiceLocator($container);
};
parent::__construct($configOrContainerInstance, $v3config);
}