* @git GetBible * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace TrueChristianChurch\Joomla\GetBible; use Joomla\DI\Container; use TrueChristianChurch\Joomla\GetBible\Service\Api; use TrueChristianChurch\Joomla\GetBible\Service\Utilities; use TrueChristianChurch\Joomla\GetBible\Service\Watcher; use TrueChristianChurch\Joomla\GetBible\Service\App; use TrueChristianChurch\Joomla\GetBible\Service\Model; use TrueChristianChurch\Joomla\GetBible\Service\Database; use TrueChristianChurch\Joomla\Interfaces\FactoryInterface; /** * GetBible Factory * * @since 2.0.1 */ abstract class Factory implements FactoryInterface { /** * Global Package Container * * @var Container * @since 2.0.1 **/ protected static $container = null; /** * Get any class from the package container * * @param string $key The container class key * * @return Mixed * @since 2.0.1 */ public static function _($key) { return self::getContainer()->get($key); } /** * Get the global package container * * @return Container * @since 2.0.1 */ public static function getContainer(): Container { if (!self::$container) { self::$container = self::createContainer(); } return self::$container; } /** * Create a container object * * @return Container * @since 2.0.1 */ protected static function createContainer(): Container { return (new Container()) ->registerServiceProvider(new Utilities()) ->registerServiceProvider(new Api()) ->registerServiceProvider(new Watcher()) ->registerServiceProvider(new App()) ->registerServiceProvider(new Model()) ->registerServiceProvider(new Database()); } }