Skip to content

Commit

Permalink
Reverting c631bbb: use AdminPagePreBuild
Browse files Browse the repository at this point in the history
instead of InitaliseAdminPageHead. AdminPagePreBuild is called for all pages (including content pages) not only for Symphony's pages.

This commit also makes sure that the pageAlert won't make a fatal error if no page is found and will log the alert instead.
  • Loading branch information
nitriques committed Oct 9, 2015
1 parent c2bae7e commit f7f4da0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function install() {
try {
$this->meetDependencies();
} catch (Exception $e) {
Administration::instance()->Page->pageAlert($e->getMessage(), Alert::ERROR);
$this->showAlertIfPossible($e);
}

/* Configuration */
Expand All @@ -44,7 +44,7 @@ public function update($previousVersion = false) {
try {
$this->meetDependencies();
} catch (Exception $e) {
Administration::instance()->Page->pageAlert($e->getMessage(), Alert::ERROR);
$this->showAlertIfPossible($e);
}

if (version_compare($previousVersion, '1.4', '<')) {
Expand Down Expand Up @@ -91,8 +91,8 @@ public function getSubscribedDelegates() {
),
array(
'page' => '/backend/',
'delegate' => 'InitaliseAdminPageHead',
'callback' => 'dInitialiseAdminPageHead'
'delegate' => 'AdminPagePreBuild',
'callback' => 'dAdminPagePreBuild'
),
array(
'page' => '/system/preferences/',
Expand Down Expand Up @@ -143,11 +143,11 @@ public function dFrontendParamsPostResolve($context) {
/**
* Backend
*/
public function dInitialiseAdminPageHead() {
public function dAdminPagePreBuild() {
try {
$this->meetDependencies();
} catch (Exception $e) {
Administration::instance()->Page->pageAlert($e->getMessage(), Alert::ERROR);
$this->showAlertIfPossible($e);
}

$this->_initFLang();
Expand Down Expand Up @@ -384,4 +384,13 @@ public function meetDependencies($return_status = false) {

return true;
}

private function showAlertIfPossible($e) {
if (class_exists('Administration') && Administration::instance()->Page) {
Administration::instance()->Page->pageAlert($e->getMessage(), Alert::ERROR);
}
else {
Symphony::Log()->pushExceptionToLog($e, true);
}
}
}

0 comments on commit f7f4da0

Please sign in to comment.