icingaweb2-module-businessp.../library/Businessprocess/Storage/Storage.php

108 lines
2.2 KiB
PHP
Raw Normal View History

<?php
2014-11-30 09:56:58 -05:00
namespace Icinga\Module\Businessprocess\Storage;
use Icinga\Application\Config;
use Icinga\Data\ConfigObject;
2017-01-11 08:04:45 -05:00
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\Metadata;
abstract class Storage
{
/**
* @var static
*/
protected static $instance;
2016-11-23 04:44:24 -05:00
/**
* @var ConfigObject
*/
protected $config;
2016-11-23 04:44:24 -05:00
/**
* Storage constructor.
* @param ConfigObject $config
*/
public function __construct(ConfigObject $config)
{
$this->config = $config;
$this->init();
}
protected function init()
{
}
public static function getInstance()
{
if (static::$instance === null) {
static::$instance = new static(Config::module('businessprocess')->getSection('global'));
}
return static::$instance;
}
/**
2017-01-11 05:57:10 -05:00
* All processes readable by the current user
*
* The returned array has the form <process name> => <nice title>, sorted
* by title
*
* @return array
*/
abstract public function listProcesses();
2017-01-11 05:57:10 -05:00
/**
* All process names readable by the current user
*
* The returned array has the form <process name> => <process name> and is
* sorted
*
* @return array
*/
2017-01-11 06:57:38 -05:00
abstract public function listProcessNames();
2017-01-11 05:57:10 -05:00
/**
* All available process names, regardless of eventual restrictions
*
* @return array
*/
abstract public function listAllProcessNames();
/**
* Whether a configuration with the given name exists
*
* @param $name
*
* @return bool
*/
abstract public function hasProcess($name);
/**
2016-11-23 04:44:24 -05:00
* @param $name
2017-01-11 08:04:45 -05:00
* @return BpConfig
*/
abstract public function loadProcess($name);
/**
2017-01-11 05:57:10 -05:00
* Store eventual changes applied to the given configuration
*
2017-01-11 08:04:45 -05:00
* @param BpConfig $config
2017-01-11 05:57:10 -05:00
*
2016-11-23 04:44:24 -05:00
* @return mixed
*/
2017-01-11 08:04:45 -05:00
abstract public function storeProcess(BpConfig $config);
2015-03-16 04:08:00 -04:00
2016-11-23 04:44:24 -05:00
/**
* @param $name
* @return bool Whether the process has been deleted
*/
2015-03-16 04:08:00 -04:00
abstract public function deleteProcess($name);
/**
* @param string $name
* @return Metadata
*/
abstract public function loadMetadata($name);
}