diff --git a/src/Theme/Theme.php b/src/Theme/Theme.php index 1e437f1..884dc30 100644 --- a/src/Theme/Theme.php +++ b/src/Theme/Theme.php @@ -3,12 +3,13 @@ namespace WPEmergeTheme\Theme; use WPEmerge; +use WPEmerge\Application\Application; use WPEmerge\Exceptions\ConfigurationException; -use WPEmerge\Facades\Application; use WPEmergeTheme\Assets\AssetsServiceProvider; use WPEmergeTheme\Avatar\AvatarServiceProvider; use WPEmergeTheme\Config\ConfigServiceProvider; use WPEmergeTheme\Facades\Assets; +use WPEmergeTheme\Facades\Theme as ThemeFacade; use WPEmergeTheme\Image\ImageServiceProvider; use WPEmergeTheme\Sidebar\SidebarServiceProvider; @@ -16,6 +17,13 @@ * Main communication channel with the theme. */ class Theme { + /** + * Application instance. + * + * @var Application + */ + protected $app = null; + /** * Flag whether the theme has been bootstrapped. * @@ -36,6 +44,41 @@ class Theme { SidebarServiceProvider::class, ]; + /** + * Make a new theme instance. + * + * @return self + */ + public static function make() { + $app = Application::make(); + $theme = new self( $app ); + + $container = $app->getContainer(); + $container['wpemerge_theme'] = $theme; + + $app->alias( 'WPEmergeTheme', ThemeFacade::class ); + + return $theme; + } + + /** + * Constructor. + * + * @param Application $app + */ + public function __construct( $app ) { + $this->app = $app; + } + + /** + * Get application instance. + * + * @return Application + */ + public function getApplication() { + return $this->app; + } + /** * Get whether the theme has been bootstrapped. * @@ -61,7 +104,7 @@ protected function bootstrapApplication( $config ) { $this->service_providers ); - Application::bootstrap( $config ); + $this->getApplication()->bootstrap( $config ); } /** diff --git a/src/load.php b/src/load.php deleted file mode 100644 index e4075be..0000000 --- a/src/load.php +++ /dev/null @@ -1,17 +0,0 @@ -