本文整理匯總了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";