本文整理汇总了PHP中Windwalker\DI\Container::alias方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::alias方法的具体用法?PHP Container::alias怎么用?PHP Container::alias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windwalker\DI\Container
的用法示例。
在下文中一共展示了Container::alias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return Container Returns itself to support chaining.
*
* @since 1.0
*/
public function register(Container $container)
{
$ioClass = 'Phoenix\\IO\\IO';
$container->alias('io', $ioClass)->alias('Muse\\IO\\IO', $ioClass)->alias('Muse\\IO\\IOInterface', $ioClass)->share($ioClass, new IO($this->controller->getCommand()));
$container->alias('operator.copy', 'Phoenix\\Generaotr\\FileOperator\\CopyOperator')->createObject('Phoenix\\Generaotr\\FileOperator\\CopyOperator');
$closure = function (Container $container) {
return new OperatorFactory($container->get('io'), $this->controller->getTagVariables());
};
$container->share('operator.factory', $closure);
}
示例2: testAlias
/**
* Method to test alias().
*
* @return void
*
* @covers Windwalker\DI\Container::alias
*/
public function testAlias()
{
$this->instance->alias('foo', 'flower');
$this->assertEquals('sakura', $this->instance->get('foo'));
}