rules['splashing-images'] = 'splashing-images/default/index'; $event->rules['splashing-images/'] = 'splashing-images/default/index'; $event->rules['splashing-images/find'] = 'splashing-images/default/find'; $event->rules['splashing-images/search'] = 'splashing-images/default/search'; $event->rules['splashing-images/search/'] = 'splashing-images/default/search'; } ); Event::on( Plugins::class, Plugins::EVENT_AFTER_INSTALL_PLUGIN, function(PluginEvent $event) { if ($event->plugin->id === $this->id) { // Redirect to plugin settings $request = Craft::$app->getRequest(); if ($request->isCpRequest) { Craft::$app->getResponse()->redirect(UrlHelper::cpUrl( 'settings/plugins/splashing-images' ))->send(); } } } ); } // Protected Methods // ========================================================================= /** * Creates and returns the model used to store the plugin’s settings. **/ protected function createSettingsModel(): Model { return new Settings(); } /** * @inheritdoc */ public function getCpNavItem(): array { $navItem = [ 'label' => $this->getSettings()->pluginLabel ? $this->getSettings()->pluginLabel : 'Unsplash Images', 'url' => $this->id, ]; if (($iconPath = $this->cpNavIconPath()) !== null) { $navItem['icon'] = $iconPath; } return $navItem; } /** * Returns the rendered settings HTML, which will be inserted into the content * block on the settings page. * * @return string The rendered settings HTML */ protected function settingsHtml(): string { $volumes = Craft::$app->getVolumes(); foreach ($volumes->getAllVolumes() as $source) { $destinationOptions[] = array('label' => $source->name, 'value' => $source->handle); } return Craft::$app->view->renderTemplate( 'splashing-images/settings', [ 'settings' => $this->getSettings(), 'volumes' => $destinationOptions ?? null, ] ); } }