本文整理匯總了PHP中IoC::bootstrap方法的典型用法代碼示例。如果您正苦於以下問題:PHP IoC::bootstrap方法的具體用法?PHP IoC::bootstrap怎麽用?PHP IoC::bootstrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IoC
的用法示例。
在下文中一共展示了IoC::bootstrap方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resolve
*
* // Pass an array of parameters to the resolver
* $mailer = IoC::resolve('mailer', array('test'));
* </code>
*
* @param string $name
* @param array $parameters
* @return mixed
*/
public static function resolve($name, $parameters = array())
{
if (array_key_exists($name, static::$singletons)) {
return static::$singletons[$name];
}
if (!static::registered($name)) {
throw new \OutOfBoundsException("Error resolving [{$name}]. No resolver has been registered.");
}
$object = call_user_func(static::$registry[$name]['resolver'], $parameters);
if (isset(static::$registry[$name]['singleton']) and static::$registry[$name]['singleton']) {
return static::$singletons[$name] = $object;
}
return $object;
}
}
/**
* We only bootstrap the IoC container once the class has been
* loaded since there isn't any reason to load the container
* configuration until the class is first requested.
*/
IoC::bootstrap();