mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 14:45:15 +02:00
Replace Hook class with EventDispatcher in Page class
This commit is contained in:
parent
9073c14d51
commit
1636d0546e
1 changed files with 18 additions and 6 deletions
|
@ -14,7 +14,6 @@ use Friendica\App;
|
||||||
use Friendica\AppHelper;
|
use Friendica\AppHelper;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\Hook;
|
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
|
@ -22,12 +21,14 @@ use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session\Model\UserSession;
|
use Friendica\Core\Session\Model\UserSession;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
|
use Friendica\Event\DataFilterEvent;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use GuzzleHttp\Psr7\Utils;
|
use GuzzleHttp\Psr7\Utils;
|
||||||
|
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,6 +71,8 @@ class Page implements ArrayAccess
|
||||||
*/
|
*/
|
||||||
private $basePath;
|
private $basePath;
|
||||||
|
|
||||||
|
private EventDispatcherInterface $eventDispatcher;
|
||||||
|
|
||||||
private $timestamp = 0;
|
private $timestamp = 0;
|
||||||
private $method = '';
|
private $method = '';
|
||||||
private $module = '';
|
private $module = '';
|
||||||
|
@ -78,10 +81,11 @@ class Page implements ArrayAccess
|
||||||
/**
|
/**
|
||||||
* @param string $basepath The Page basepath
|
* @param string $basepath The Page basepath
|
||||||
*/
|
*/
|
||||||
public function __construct(string $basepath)
|
public function __construct(string $basepath, EventDispatcherInterface $eventDispatcher)
|
||||||
{
|
{
|
||||||
$this->timestamp = microtime(true);
|
$this->timestamp = microtime(true);
|
||||||
$this->basePath = $basepath;
|
$this->basePath = $basepath;
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLogging(string $method, string $module, string $command)
|
public function setLogging(string $method, string $module, string $command)
|
||||||
|
@ -229,7 +233,9 @@ class Page implements ArrayAccess
|
||||||
$touch_icon = 'images/friendica-192.png';
|
$touch_icon = 'images/friendica-192.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
Hook::callAll('head', $this->page['htmlhead']);
|
$this->page['htmlhead'] = $this->eventDispatcher->dispatch(
|
||||||
|
new DataFilterEvent('head', $this->page['htmlhead'])
|
||||||
|
)->getData();
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('head.tpl');
|
$tpl = Renderer::getMarkupTemplate('head.tpl');
|
||||||
/* put the head template at the beginning of page['htmlhead']
|
/* put the head template at the beginning of page['htmlhead']
|
||||||
|
@ -351,7 +357,9 @@ class Page implements ArrayAccess
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Hook::callAll('footer', $this->page['footer']);
|
$this->page['footer'] = $this->eventDispatcher->dispatch(
|
||||||
|
new DataFilterEvent('footer', $this->page['footer'])
|
||||||
|
)->getData();
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('footer.tpl');
|
$tpl = Renderer::getMarkupTemplate('footer.tpl');
|
||||||
$this->page['footer'] = Renderer::replaceMacros($tpl, [
|
$this->page['footer'] = Renderer::replaceMacros($tpl, [
|
||||||
|
@ -375,7 +383,9 @@ class Page implements ArrayAccess
|
||||||
{
|
{
|
||||||
// initialise content region
|
// initialise content region
|
||||||
if ($mode->isNormal()) {
|
if ($mode->isNormal()) {
|
||||||
Hook::callAll('page_content_top', $this->page['content']);
|
$this->page['content'] = $this->eventDispatcher->dispatch(
|
||||||
|
new DataFilterEvent('page_content_top', $this->page['content'])
|
||||||
|
)->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->page['content'] .= (string)$response->getBody();
|
$this->page['content'] .= (string)$response->getBody();
|
||||||
|
@ -473,7 +483,9 @@ class Page implements ArrayAccess
|
||||||
$profiler->set(microtime(true) - $timestamp, 'aftermath');
|
$profiler->set(microtime(true) - $timestamp, 'aftermath');
|
||||||
|
|
||||||
if (!$mode->isAjax()) {
|
if (!$mode->isAjax()) {
|
||||||
Hook::callAll('page_end', $this->page['content']);
|
$this->page['content'] = $this->eventDispatcher->dispatch(
|
||||||
|
new DataFilterEvent('page_end', $this->page['content'])
|
||||||
|
)->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the navigation (menu) template
|
// Add the navigation (menu) template
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue