> */ private array $providers = [ TranslationServiceProvider::class, CPTServiceProvider::class, TaxonomyServiceProvider::class, SettingServiceProvider::class, ControllerServiceProvider::class, FeedServiceProvider::class, PlayerServiceProvider::class, StatisticsServiceProvider::class, ]; /** * Service provider instances created during plugin boot. * * @var array */ private array $providerInstances = []; /** * Return an asset version that changes whenever the file does, so edits bust the browser cache. * * @param string $path Path relative to the plugin directory. * @return string */ public static function assetVersion(string $path): string { $mtime = @filemtime(self::DIR . $path); return $mtime !== false ? (string) $mtime : self::VERSION; } /** * Create the plugin application and boot its providers. */ public function __construct() { $this->init(); } /** * Initialize the plugin lifecycle. * * @return void */ public function init(): void { $this->registerProviders(); $this->bootProviders(); } /** * Register all configured service providers. * * @return void */ private function registerProviders(): void { foreach ($this->providers as $providerClass) { // Keep provider instances so boot() runs on the same objects. $provider = new $providerClass(); $provider->register(); $this->providerInstances[] = $provider; } } /** * Boot all registered service providers. * * @return void */ private function bootProviders(): void { foreach ($this->providerInstances as $provider) { // Allow providers to run logic after every provider is registered. $provider->boot(); } } }