本文整理汇总了PHP中Horde_Injector::bindClosure方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Injector::bindClosure方法的具体用法?PHP Horde_Injector::bindClosure怎么用?PHP Horde_Injector::bindClosure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Injector
的用法示例。
在下文中一共展示了Horde_Injector::bindClosure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Demonstrates how to use the closure binder with Horde_Injector.
*
* PHP version 5.3+
*
* @category Horde
* @package Injector
* @author Chuck Hagenbuch <chuck@horde.org>
* @license http://www.horde.org/licenses/bsd BSD
* @link http://pear.horde.org/index.php?package=Injector
*/
require 'Horde/Autoloader.php';
class ClosureCreated
{
public function __construct($msg)
{
$this->msg = $msg;
}
public function __toString()
{
return 'Foo: ' . $this->msg;
}
}
$closure = function (Horde_Injector $i) {
return new ClosureCreated('created by closure');
};
$binder = new Horde_Injector_Binder_Closure($closure);
$a = new Horde_Injector(new Horde_Injector_TopLevel());
$a->bindClosure('CC', $closure);
$b = $a->getInstance('CC');
echo "{$b}\n";