Loading src/Controller/OpenSearchDescriptionController.php +50 −19 Changes for src/Controller/OpenSearchDescriptionController.php: 50 added lines, 19 removed lines. Original line number Diff line number Diff line Loading @@ -2,44 +2,75 @@ namespace Drupal\opensearchtab\Controller; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ImmutableConfig; use Drupal\Core\Controller\ControllerBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; /** * OpenSearchDescriptionController . */ class OpenSearchDescriptionController { class OpenSearchDescriptionController extends ControllerBase { /** * @var ImmutableConfig $system_config */ private $system_config; /** * @var ImmutableConfig $ost_config */ private $ost_config; /** * Class constructor. * * @param ConfigFactoryInterface $config_factory * The config factory service. */ public function __construct(ConfigFactoryInterface $config_factory) { $this->system_config = $config_factory->get('system.site'); $this->ost_config = $config_factory->get('opensearchtab.settings'); } public static function create(ContainerInterface $container) { return new static( $container->get('config.factory') ); } /** * {@inheritdoc} */ public function content() { // Prepare variables for the XML content. $config = \Drupal::config('system.site'); $ost_config = \Drupal::config('opensearchtab.settings'); $short_name = !empty($ost_config->get('shortname')) ? $ost_config->get('shortname') : (!empty($config->get('name')) ? $config->get('name') : 'Drupal site'); $description = !empty($ost_config->get('description')) ? $ost_config->get('description') : (!empty($config->get('slogan')) ? $config->get('slogan') : 'Search the site'); $search_form_path = !empty($ost_config->get('search-form-path')) ? $short_name = !empty($this->ost_config->get('shortname')) ? $this->ost_config->get('shortname') : (!empty($this->system_config->get('name')) ? $this->system_config->get('name') : 'Drupal site'); $description = !empty($this->ost_config->get('description')) ? $this->ost_config->get('description') : (!empty($this->system_config->get('slogan')) ? $this->system_config->get('slogan') : 'Search the site'); $search_form_path = !empty($this->ost_config->get('search-form-path')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('search-form-path') : $this->ost_config->get('search-form-path') : \Drupal::request()->getSchemeAndHttpHost() . '/search/node'; $search_path = !empty($ost_config->get('search-path')) ? $search_path = !empty($this->ost_config->get('search-path')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('search-path') : $this->ost_config->get('search-path') : \Drupal::request()->getSchemeAndHttpHost() . '/search/node?keys={searchTerms}'; $suggestions_path_json = !empty($ost_config->get('suggestions-path-json')) ? $suggestions_path_json = !empty($this->ost_config->get('suggestions-path-json')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('suggestions-path-json') : ''; $suggestions_path_xml = !empty($ost_config->get('suggestions-path-xml')) ? $this->ost_config->get('suggestions-path-json') : ''; $suggestions_path_xml = !empty($this->ost_config->get('suggestions-path-xml')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('suggestions-path-xml') : ''; $favicon_path = !empty($ost_config->get('favicon-path')) ? $this->ost_config->get('suggestions-path-xml') : ''; $favicon_path = !empty($this->ost_config->get('favicon-path')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('favicon-path') : ''; $this->ost_config->get('favicon-path') : ''; // Define the XML content. $openTag = new \SimpleXMLElement( Loading Loading
src/Controller/OpenSearchDescriptionController.php +50 −19 Changes for src/Controller/OpenSearchDescriptionController.php: 50 added lines, 19 removed lines. Original line number Diff line number Diff line Loading @@ -2,44 +2,75 @@ namespace Drupal\opensearchtab\Controller; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ImmutableConfig; use Drupal\Core\Controller\ControllerBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; /** * OpenSearchDescriptionController . */ class OpenSearchDescriptionController { class OpenSearchDescriptionController extends ControllerBase { /** * @var ImmutableConfig $system_config */ private $system_config; /** * @var ImmutableConfig $ost_config */ private $ost_config; /** * Class constructor. * * @param ConfigFactoryInterface $config_factory * The config factory service. */ public function __construct(ConfigFactoryInterface $config_factory) { $this->system_config = $config_factory->get('system.site'); $this->ost_config = $config_factory->get('opensearchtab.settings'); } public static function create(ContainerInterface $container) { return new static( $container->get('config.factory') ); } /** * {@inheritdoc} */ public function content() { // Prepare variables for the XML content. $config = \Drupal::config('system.site'); $ost_config = \Drupal::config('opensearchtab.settings'); $short_name = !empty($ost_config->get('shortname')) ? $ost_config->get('shortname') : (!empty($config->get('name')) ? $config->get('name') : 'Drupal site'); $description = !empty($ost_config->get('description')) ? $ost_config->get('description') : (!empty($config->get('slogan')) ? $config->get('slogan') : 'Search the site'); $search_form_path = !empty($ost_config->get('search-form-path')) ? $short_name = !empty($this->ost_config->get('shortname')) ? $this->ost_config->get('shortname') : (!empty($this->system_config->get('name')) ? $this->system_config->get('name') : 'Drupal site'); $description = !empty($this->ost_config->get('description')) ? $this->ost_config->get('description') : (!empty($this->system_config->get('slogan')) ? $this->system_config->get('slogan') : 'Search the site'); $search_form_path = !empty($this->ost_config->get('search-form-path')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('search-form-path') : $this->ost_config->get('search-form-path') : \Drupal::request()->getSchemeAndHttpHost() . '/search/node'; $search_path = !empty($ost_config->get('search-path')) ? $search_path = !empty($this->ost_config->get('search-path')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('search-path') : $this->ost_config->get('search-path') : \Drupal::request()->getSchemeAndHttpHost() . '/search/node?keys={searchTerms}'; $suggestions_path_json = !empty($ost_config->get('suggestions-path-json')) ? $suggestions_path_json = !empty($this->ost_config->get('suggestions-path-json')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('suggestions-path-json') : ''; $suggestions_path_xml = !empty($ost_config->get('suggestions-path-xml')) ? $this->ost_config->get('suggestions-path-json') : ''; $suggestions_path_xml = !empty($this->ost_config->get('suggestions-path-xml')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('suggestions-path-xml') : ''; $favicon_path = !empty($ost_config->get('favicon-path')) ? $this->ost_config->get('suggestions-path-xml') : ''; $favicon_path = !empty($this->ost_config->get('favicon-path')) ? \Drupal::request()->getSchemeAndHttpHost() . $ost_config->get('favicon-path') : ''; $this->ost_config->get('favicon-path') : ''; // Define the XML content. $openTag = new \SimpleXMLElement( Loading