diff --git a/plugins/system/sef/src/Extension/Sef.php b/plugins/system/sef/src/Extension/Sef.php index d431f6b18e2e..927eeffa8133 100644 --- a/plugins/system/sef/src/Extension/Sef.php +++ b/plugins/system/sef/src/Extension/Sef.php @@ -29,14 +29,6 @@ */ final class Sef extends CMSPlugin implements SubscriberInterface { - /** - * Application object. - * - * @var \Joomla\CMS\Application\CMSApplication - * @since __DEPLOY_VERSION__ - */ - protected $app; - /** * Returns an array of CMS events this plugin will listen to and the respective handlers. * @@ -69,7 +61,7 @@ public function onAfterInitialiseRouter(AfterInitialiseRouterEvent $event) { if ( is_a($event->getRouter(), SiteRouter::class) - && $this->app->get('sef_rewrite') + && $this->getApplication()->get('sef_rewrite') && $this->params->get('indexphp') ) { // Enforce removing index.php with a redirect @@ -78,8 +70,8 @@ public function onAfterInitialiseRouter(AfterInitialiseRouterEvent $event) if ( is_a($event->getRouter(), SiteRouter::class) - && $this->app->get('sef') - && !$this->app->get('sef_suffix') + && $this->getApplication()->get('sef') + && !$this->getApplication()->get('sef_suffix') && $this->params->get('trailingslash') ) { if ($this->params->get('trailingslash') == 1) { @@ -270,7 +262,7 @@ function ($match) use ($base, $protocols) { public function removeIndexphp(&$router, &$uri) { // We only want to redirect on GET requests - if ($this->app->getInput()->getMethod() !== 'GET') { + if ($this->getApplication()->getInput()->getMethod() !== 'GET') { return; } @@ -279,13 +271,13 @@ public function removeIndexphp(&$router, &$uri) if (substr($origUri->getPath(), -9) === 'index.php') { // Remove trailing index.php $origUri->setPath(substr($origUri->getPath(), 0, -9)); - $this->app->redirect($origUri->toString(), 301); + $this->getApplication()->redirect($origUri->toString(), 301); } if (substr($origUri->getPath(), \strlen(Uri::base(true)), 11) === '/index.php/') { // Remove leading index.php $origUri->setPath(Uri::base(true) . substr($origUri->getPath(), \strlen(Uri::base(true)) + 10)); - $this->app->redirect($origUri->toString(), 301); + $this->getApplication()->redirect($origUri->toString(), 301); } } @@ -340,7 +332,7 @@ public function addTrailingSlash(&$router, &$uri) public function enforceTrailingSlash(&$router, &$uri) { // We only want to redirect on GET requests - if ($this->app->getInput()->getMethod() != 'GET') { + if ($this->getApplication()->getInput()->getMethod() != 'GET') { return; } @@ -349,11 +341,11 @@ public function enforceTrailingSlash(&$router, &$uri) if ($this->params->get('trailingslash') == 1 && substr($originalUri->getPath(), -1) == '/' && $originalUri->toString() != Uri::root()) { // Remove trailingslash $originalUri->setPath(substr($originalUri->getPath(), 0, -1)); - $this->app->redirect($originalUri->toString(), 301); + $this->getApplication()->redirect($originalUri->toString(), 301); } elseif ($this->params->get('trailingslash') == 2 && substr($originalUri->getPath(), -1) != '/') { // Add trailingslash $originalUri->setPath($originalUri->getPath() . '/'); - $this->app->redirect($originalUri->toString(), 301); + $this->getApplication()->redirect($originalUri->toString(), 301); } }