/** * Refresh the bound request instance in the container. * * @param \Themosis\Core\Request $request * @return void */ protected function refreshRequest(Request $request) { $this->instance('request', $request); Facade::clearResolvedInstance('request'); }
/** * Bootstrap the core plugin. */ protected function bootstrap() { /* * Define core framework paths. * These are real paths, not URLs to the framework files. */ $paths['core'] = __DIR__ . DS; $paths['sys'] = __DIR__ . DS . 'src' . DS . 'Themosis' . DS; $paths['storage'] = THEMOSIS_STORAGE; themosis_set_paths($paths); /* * Instantiate the service container for the project. */ $this->container = new \Themosis\Foundation\Application(); /* * Create a new Request instance and register it. * By providing an instance, the instance is shared. */ $request = \Themosis\Foundation\Request::capture(); $this->container->instance('request', $request); /* * Setup the facade. */ \Themosis\Facades\Facade::setFacadeApplication($this->container); /* * Register into the container, the registered paths. * Normally at this stage, plugins should have * their paths registered into the $GLOBALS array. */ $this->container->registerAllPaths(themosis_path()); /* * Register core service providers. */ $this->registerProviders(); /* * Setup core. */ $this->setup(); /* * Project hooks. * Added in their called order. */ add_action('admin_enqueue_scripts', [$this, 'adminEnqueueScripts']); add_action('admin_head', [$this, 'adminHead']); add_action('template_redirect', 'redirect_canonical'); add_action('template_redirect', 'wp_redirect_admin_locations'); add_action('template_redirect', [$this, 'setRouter'], 20); }