icingaweb2-module-director/library/Director/Hook/JobHook.php

60 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace Icinga\Module\Director\Hook;
2016-04-21 13:24:48 +02:00
use Icinga\Module\Director\Db;
2016-04-22 09:31:52 +02:00
use Icinga\Module\Director\Web\Form\QuickForm;
2016-04-21 13:24:48 +02:00
abstract class JobHook
{
2016-04-21 13:24:48 +02:00
private $db;
2016-04-22 09:31:52 +02:00
public static function getDescription(QuickForm $form)
{
return false;
}
abstract public function run();
abstract public function isPending();
public function getName()
{
$parts = explode('\\', get_class($this));
$class = preg_replace('/Job$/', '', array_pop($parts));
if (array_shift($parts) === 'Icinga' && array_shift($parts) === 'Module') {
$module = array_shift($parts);
if ($module !== 'Director') {
return sprintf('%s (%s)', $class, $module);
}
}
return $class;
}
2016-04-22 09:31:52 +02:00
/**
* Override this method if you want to extend the settings form
*
* @param QuickForm $form QuickForm that should be extended
* @return QuickForm
*/
public static function addSettingsFormFields(QuickForm $form)
{
return $form;
}
2016-04-21 13:24:48 +02:00
public function setDb(Db $db)
{
$this->db = $db;
return $this;
}
protected function db()
{
return $this->db;
}
}