/** * Checks environment and build defaults * */ protected function __construct() { // Instantiate Feature Manager FeatureManager::getInstance(); // Instantiate Context Manager ContextManager::getInstance(); // Instantiate URLs Manager UrlManager::getInstance(); // Instantiate Paths Manager & set Bebop root directory PathManager::getInstance()->set('bebop', __DIR__); // Set default Media Mvc Model modifications on the Bebop HTTP API Media::onContext('api', function ($media) { $media->cacheAllImageSizes(); }); // Set default views directory View::setViewsDir(PathManager::getInstance()->get('theme', 'views')); // Instantiate CSS Manager CSS::getInstance(); // Instantiate JS Manager JS::getInstance(); // Instantiate UI UI::getInstance(); // Instantiate Api self::Api(); // Instantiate Config Config::getInstance(); // Shortcode support for in editor use add_shortcode('Bebop', array($this, '__bebopShortcodes')); }
/** * Registers script * * @param object $hook_name JS Hook instance * @return object Current object */ protected function handleAction($hook_name, $action) { if ($hook = CSS::getInstance()->getHook($hook_name)) { if ($action == 'register') { // Get dependencies $deps = $this->config->get('deps') ?: []; // Enqueue dependencies if ($deps) { foreach ($deps as $dep_handle) { // Publish event $this->getEventEmitter()->publish("cms.config.styles.{$dep_handle}", ['action' => 'enqueue_as_dependency', 'hooks' => [$hook_name]]); } } // Register script $hook->register($this->config->get('handle'), $this->config->get('src'), $deps, $this->config->get('version') ?: null, $this->config->get('in_footer') ?: null); } else { $hook->{$action}($this->config->get('handle')); } } return $this; }