eee
This commit is contained in:
@@ -46,13 +46,21 @@ abstract class BaseApplication extends LocalService
|
||||
public function __construct(public EventProvider $provider, public ConfigProvider $config, public ContainerInterface $container)
|
||||
{
|
||||
$this->mapping($config);
|
||||
$this->parseStorage($config);
|
||||
$this->parseEvents($config);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
$this->parseStorage($this->config);
|
||||
$this->parseEvents($this->config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ConfigProvider $config
|
||||
* @return void
|
||||
|
||||
@@ -1,129 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: whwyy
|
||||
* Date: 2018/3/30 0030
|
||||
* Time: 14:28
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Kiri;
|
||||
use Kiri\Error\StdoutLogger;
|
||||
use Kiri\Events\EventDispatch;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class Component
|
||||
* @package Kiri\Base
|
||||
* @property ContainerInterface $container
|
||||
* @property EventDispatch $dispatch
|
||||
* @property EventProvider $provider
|
||||
*/
|
||||
class Component implements Configure
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* BaseAbstract constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
#[Pure] public static function className(): string
|
||||
{
|
||||
return static::class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return StdoutLogger
|
||||
* @throws
|
||||
*/
|
||||
public function getLogger(): StdoutLogger
|
||||
{
|
||||
return Kiri::getLogger();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
* @throws
|
||||
*/
|
||||
public function __get(string $name)
|
||||
{
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->{$method}();
|
||||
} else if (method_exists($this, $name)) {
|
||||
return $this->{$name};
|
||||
} else {
|
||||
throw new Exception('Unable getting property ' . get_called_class() . '::' . $name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param $value
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public function __set(string $name, $value): void
|
||||
{
|
||||
$method = 'set' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->{$method}($value);
|
||||
} else if (method_exists($this, $name)) {
|
||||
$this->{$name} = $value;
|
||||
} else {
|
||||
throw new Exception('Unable setting property ' . get_called_class() . '::' . $name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return EventDispatch
|
||||
*/
|
||||
public function getDispatch(): EventDispatch
|
||||
{
|
||||
return Kiri::getDi()->get(EventDispatch::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return EventProvider
|
||||
*/
|
||||
public function getProvider(): EventProvider
|
||||
{
|
||||
return Kiri::getDi()->get(EventProvider::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function getContainer(): ContainerInterface
|
||||
{
|
||||
return Kiri::getDi();
|
||||
}
|
||||
}
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Kiri;
|
||||
use Kiri\Error\StdoutLogger;
|
||||
use Kiri\Events\EventDispatch;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class Component
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
#[Pure] public static function className(): string
|
||||
{
|
||||
return static::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws
|
||||
*/
|
||||
public function getLogger(): StdoutLogger
|
||||
{
|
||||
return Kiri::getLogger();
|
||||
}
|
||||
|
||||
public function getDispatch(): EventDispatch
|
||||
{
|
||||
return Kiri::getDi()->get(EventDispatch::class);
|
||||
}
|
||||
|
||||
public function getProvider(): EventProvider
|
||||
{
|
||||
return Kiri::getDi()->get(EventProvider::class);
|
||||
}
|
||||
|
||||
public function getContainer(): ContainerInterface
|
||||
{
|
||||
return Kiri::getDi();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws
|
||||
*/
|
||||
public function __get(string $name)
|
||||
{
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->{$method}();
|
||||
}
|
||||
throw new Exception('Unable getting property ' . get_called_class() . '::' . $name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: whwyy
|
||||
* Date: 2018/3/30 0030
|
||||
* Time: 14:11
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
/**
|
||||
* Interface Configure
|
||||
* @package Kiri\Base
|
||||
*/
|
||||
interface Configure
|
||||
{
|
||||
|
||||
}
|
||||
@@ -7,9 +7,7 @@ use Kiri\Coordinator;
|
||||
class CoordinatorManager
|
||||
{
|
||||
|
||||
|
||||
|
||||
private static array $_waite = [];
|
||||
private static array $_items = [];
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,10 +16,10 @@ class CoordinatorManager
|
||||
*/
|
||||
public static function utility(string $category): Coordinator
|
||||
{
|
||||
if (!((static::$_waite[$category] ?? null) instanceof Coordinator)) {
|
||||
static::$_waite[$category] = new Coordinator();
|
||||
if (!((static::$_items[$category] ?? null) instanceof Coordinator)) {
|
||||
static::$_items[$category] = new Coordinator();
|
||||
}
|
||||
return static::$_waite[$category];
|
||||
return static::$_items[$category];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
interface Kernel
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCommands(): array;
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
interface Kernel
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCommands(): array;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
interface Provider
|
||||
{
|
||||
|
||||
public function onImport();
|
||||
|
||||
}
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
interface Provider
|
||||
{
|
||||
|
||||
public function onImport();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
/**
|
||||
* Class Providers
|
||||
* @package Kiri\Abstracts
|
||||
*/
|
||||
abstract class Providers extends Component implements Provider
|
||||
{
|
||||
|
||||
}
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
/**
|
||||
* Class Providers
|
||||
* @package Kiri\Abstracts
|
||||
*/
|
||||
abstract class Providers extends Component implements Provider
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user