modify plugin name

This commit is contained in:
2022-03-03 18:30:59 +08:00
parent 9cd44aad3d
commit 4af173deff
5 changed files with 38 additions and 67 deletions
+6 -6
View File
@@ -20,6 +20,7 @@ use Kiri\Server\{Server};
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Kiri\Events\EventProvider;
/**
* Class BaseApplication
@@ -42,7 +43,7 @@ abstract class BaseApplication extends Component
*
* @throws
*/
public function __construct(public ContainerInterface $container)
public function __construct(public ContainerInterface $container, public EventProvider $eventProvider)
{
Kiri::init($this);
$config = sweep(APP_PATH . '/config');
@@ -183,22 +184,21 @@ abstract class BaseApplication extends Component
*/
private function addEvent($key, $value): void
{
$provider = $this->getEventProvider();
if ($value instanceof \Closure || is_object($value)) {
$provider->on($key, $value, 0);
$this->eventProvider->on($key, $value, 0);
return;
}
if (is_array($value)) {
if (is_object($value[0]) && !($value[0] instanceof \Closure)) {
$provider->on($key, $value, 0);
$this->eventProvider->on($key, $value, 0);
return;
}
if (is_string($value[0])) {
$value[0] = Kiri::createObject($value[0]);
$provider->on($key, $value, 0);
$this->eventProvider->on($key, $value, 0);
return;
}
@@ -207,7 +207,7 @@ abstract class BaseApplication extends Component
if (!is_callable($item, true)) {
throw new InitException("Class does not hav callback.");
}
$provider->on($key, $item, 0);
$this->eventProvider->on($key, $item, 0);
}
}
-37
View File
@@ -13,13 +13,7 @@ namespace Kiri\Abstracts;
use Exception;
use JetBrains\PhpStorm\Pure;
use Kiri;
use Kiri\Di\Container;
use Kiri\Error\StdoutLoggerInterface;
use Kiri\Events\EventDispatch;
use Kiri\Events\EventProvider;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class Component
@@ -65,37 +59,6 @@ class Component implements Configure
}
/**
* @return Container|ContainerInterface
*/
#[Pure] public function getContainer(): ContainerInterface|Container
{
return Kiri::getDi();
}
/**
* @return EventProvider
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getEventProvider(): EventProvider
{
return $this->getContainer()->get(EventProvider::class);
}
/**
* @return EventDispatch
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getEventDispatch(): EventDispatch
{
return $this->getContainer()->get(EventDispatch::class);
}
/**
* @param string $name
* @return mixed