Fix: Simplify TopBar hook

refs #5597
This commit is contained in:
Marius Hein 2014-02-12 09:58:59 +01:00
parent ddafae6271
commit 1a6d1a20fb
6 changed files with 13 additions and 24 deletions

View File

@ -33,7 +33,7 @@ class LayoutController extends ActionController
/** @var Hook\Layout\TopBar $hook */
$hook = null;
foreach (Hook::all(Hook::TARGET_LAYOUT_TOPBAR) as $hook) {
foreach (Hook::all('TopBar') as $hook) {
$topbarHtmlParts[] = $hook->getHtml($this->getRequest(), $this->view);
}

View File

@ -573,9 +573,14 @@ class Module
*
* @return self
*/
protected function registerHook($name, $key, $class)
protected function registerHook($name, $class, $key = null)
{
if ($key === null) {
$key = $this->name;
}
Hook::register($name, $key, $class);
return $this;
}
}

View File

@ -45,11 +45,6 @@ use \Icinga\Exception\ProgrammingError;
*/
class Hook
{
/**
* Hook name
*/
const TARGET_LAYOUT_TOPBAR = 'Layout\\TopBar';
/**
* Our hook name registry
*

View File

@ -27,7 +27,7 @@
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Hook\Layout;
namespace Icinga\Web\Hook;
use \Icinga\Web\Request;
use \Zend_View;

View File

@ -29,7 +29,7 @@
namespace Icinga\Module\Monitoring\Web\Hook;
use Icinga\Web\Hook\Layout\TopBar as IcingaTopBar;
use Icinga\Web\Hook\TopBar as IcingaTopBar;
use Icinga\Module\Monitoring\DataView\StatusSummary as StatusSummaryView;
use Icinga\Web\Request;
use Zend_View;

View File

@ -6,18 +6,7 @@
*
*/
use Icinga\Application\Icinga;
use Icinga\Authentication\Manager as AuthManager;
use Icinga\Web\Hook;
if (Icinga::app()->isCli()) {
return;
}
if (AuthManager::getInstance()->isAuthenticated()) {
Hook::register(
Hook::TARGET_LAYOUT_TOPBAR,
'monitoring-topbar',
'Icinga\\Module\\Monitoring\\Web\\Hook\\TopBar'
);
}
$this->registerHook(
'TopBar',
'Icinga\\Module\\Monitoring\\Web\\Hook\\TopBar'
);