Maslosoft Sitcom API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
<?php
/**
* This software package is licensed under AGPL, Commercial license.
*
* @package maslosoft/sitcom
* @licence AGPL, Commercial
* @copyright Copyright (c) Piotr Masełkowski <pmaselkowski@gmail.com>
* @copyright Copyright (c) Maslosoft
* @link http://maslosoft.com/sitcom/
*/
namespace Maslosoft\Sitcom;
use Maslosoft\Cli\Shared\ConfigReader;
use Maslosoft\Signals\Signal;
use Maslosoft\Sitcom\Helpers\CommandWrapper;
use Symfony\Component\Console\Application;
class Sitcom
{
/**
* Config file name
*/
const ConfigName = "sitcom";
/**
* Version number holder
* @var string
*/
private static $_version = null;
public function __construct($configName = self::ConfigName)
{
$config = new ConfigReader($configName);
$cfg = (object) $config->toArray();
if (!empty($cfg->require))
{
$cwd = getcwd();
foreach ($cfg->require as $require)
{
require_once(sprintf('%s/%s', $cwd, $require));
}
}
}
public function addCommands(Application $app)
{
$signal = new Signal();
$signal->init();
$signal->emit(new Command(new CommandWrapper($app)));
}
public function __get($name)
{
return $this->{'get' . ucfirst($name)}();
}
public function __set($name, $value)
{
$this->{'set' . ucfirst($name)}($value);
}
/**
* Get version number
* @return string
*/
public function getVersion()
{
if (null === self::$_version)
{
self::$_version = require __DIR__ . '/version.php';
}
return self::$_version;
}
}
API documentation generated by ApiGen