SlimCMS\Factory\AppFactory::getInstance PHP Method

getInstance() public static method

public static getInstance ( $name = false )
    public static function getInstance($name = false)
    {
        if (!$name) {
            return self::$app;
        }
        if (self::$app->getContainer()->offsetExists($name)) {
            return self::$app->getContainer()->get($name);
        }
    }

Usage Example

Example #1
0
 /**
  * @param bool $cache
  */
 public function __construct($cache)
 {
     $this->filesystem = new Filesystem();
     $this->moduleContainer = new Container();
     $this->cache = !$cache;
     $container = AppFactory::getInstance()->getContainer();
     $container['cache'] = function () {
         $cacheContainer = new Container();
         $cacheContainer->singleton('files', function () {
             return new Filesystem();
         });
         $cacheContainer->singleton('config', function () {
             return AppFactory::getInstance()->getContainer()->config['cache'];
         });
         return new CacheManager($cacheContainer);
     };
     $this->cacheManager = $container->get('cache');
 }
All Usage Examples Of SlimCMS\Factory\AppFactory::getInstance