search/src/01a89ba8-f8bb-435c-93de-0a8.../code.power

52 lines
1010 B
Plaintext

/**
* Global Search Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the search container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _(string $key)
{
return self::getContainer()->get($key);
}
/**
* Get the global search container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Search())
->registerServiceProvider(new Model())
->registerServiceProvider(new Database())
->registerServiceProvider(new Agent());
}