Skip to content

Commit

Permalink
#856 - Move remaining parts to Joomla extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed Dec 16, 2021
1 parent 1303be4 commit f337440
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
24 changes: 2 additions & 22 deletions code/dispatcher/behavior/decoratable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,12 @@ protected function _beforeSend(KDispatcherContextInterface $context)

if(!$response->isDownloadable() && !$response->isRedirect() && $request->getFormat() == 'html')
{
$decorator = $this->getDecorator();

//Set metadata in Joomla document
if($decorator == 'joomla')
{
//Set the title
if($title = $this->getController()->getView()->getTitle()) {
JFactory::getDocument()->setTitle($title);
}

//Set the direction
if($direction = $this->getController()->getView()->getDirection()) {
JFactory::getDocument()->setDirection($direction);
}

//Set the language
if($language = $this->getController()->getView()->getLanguage()) {
JFactory::getDocument()->setLanguage($language);
}
}

$controller = $this->getObject('com:koowa.controller.page', array('response' => $response));

//Configure the page view
$controller->getView()
->setDecorator($decorator)
->setDecorator($this->getDecorator())
->setDecorator($this->getDecorator())
->setLayout($this->getLayout());

//Set the result in the response
Expand Down
26 changes: 25 additions & 1 deletion contrib/extensions/joomla/event/subscriber/dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public function onAfterApplicationInitialise(KEventInterface $event)
}
}


public function onAfterApplicationRoute(KEventInterface $event)
{
$dispatcher = $this->getDispatcher();
Expand Down Expand Up @@ -231,6 +230,29 @@ public function onBeforeDispatcherDispatch(KEventInterface $event)
}
}

public function onBeforeKoowaPageControllerRender(KEventInterface $event)
{
$dispatcher = $this->getDispatcher();

if($dispatcher->getDecorator() == 'joomla')
{
//Set the title
if($title = $dispatcher->getController()->getView()->getTitle()) {
JFactory::getDocument()->setTitle($title);
}

//Set the direction
if($direction = $dispatcher->getController()->getView()->getDirection()) {
JFactory::getDocument()->setDirection($direction);
}

//Set the language
if($language = $dispatcher->getController()->getView()->getLanguage()) {
JFactory::getDocument()->setLanguage($language);
}
}
}

public function onAfterApplicationDispatch(KEventInterface $event)
{
if($this->isDispatchable())
Expand Down Expand Up @@ -274,6 +296,8 @@ public function onAfterApplicationDispatch(KEventInterface $event)
}
}



public function onAfterApplicationRender(KEventInterface $event)
{
if(!headers_sent())
Expand Down

0 comments on commit f337440

Please sign in to comment.