改名
This commit is contained in:
@@ -28,10 +28,10 @@ use Server\ServerProviders;
|
||||
use stdClass;
|
||||
use Swoole\Process;
|
||||
use Swoole\Timer;
|
||||
use Symfony\Component\Console\Application as ConsoleApplication;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Application as ConsoleApplication;
|
||||
|
||||
/**
|
||||
* Class Init
|
||||
@@ -68,7 +68,7 @@ class Application extends BaseApplication
|
||||
|
||||
|
||||
/**
|
||||
* @throws NotFindClassException
|
||||
* @throws
|
||||
*/
|
||||
public function withDatabase()
|
||||
{
|
||||
@@ -77,7 +77,7 @@ class Application extends BaseApplication
|
||||
|
||||
|
||||
/**
|
||||
* @throws NotFindClassException
|
||||
* @throws
|
||||
*/
|
||||
public function withCrontab()
|
||||
{
|
||||
@@ -118,9 +118,7 @@ class Application extends BaseApplication
|
||||
|
||||
|
||||
/**
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
* @throws
|
||||
*/
|
||||
public function withFileChangeListen()
|
||||
{
|
||||
@@ -163,7 +161,7 @@ class Application extends BaseApplication
|
||||
public function import(string $service): static
|
||||
{
|
||||
if (!class_exists($service)) {
|
||||
throw new NotFindClassException($service);
|
||||
return $this;
|
||||
}
|
||||
$class = Kiri::getDi()->get($service);
|
||||
if (method_exists($class, 'onImport')) {
|
||||
|
||||
@@ -63,6 +63,15 @@ class Router extends HttpService implements RouterInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
*/
|
||||
public function setNamespace(string $namespace): void
|
||||
{
|
||||
$this->dir = $namespace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ConfigException
|
||||
* @throws Exception
|
||||
|
||||
@@ -10,7 +10,6 @@ use Kiri\Abstracts\Config;
|
||||
use Kiri\Di\NoteManager;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Kiri;
|
||||
use Kiri\Runtime;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use ReflectionException;
|
||||
use Server\ServerManager;
|
||||
@@ -44,7 +43,6 @@ class OnWorkerStart implements EventDispatcherInterface
|
||||
{
|
||||
$isWorker = $event->workerId < $event->server->setting['worker_num'];
|
||||
|
||||
$this->annotation->read(APP_PATH . 'app', 'App');
|
||||
$this->interpretDirectory();
|
||||
if ($isWorker) {
|
||||
ServerManager::setEnv('environmental', Kiri::WORKER);
|
||||
@@ -86,9 +84,9 @@ class OnWorkerStart implements EventDispatcherInterface
|
||||
*/
|
||||
private function interpretDirectory()
|
||||
{
|
||||
$fileLists = $this->annotation->runtime(APP_PATH . 'app');
|
||||
$di = Kiri::getDi();
|
||||
foreach ($fileLists as $class) {
|
||||
$fileLists = $this->annotation->read(APP_PATH . 'app');
|
||||
foreach ($fileLists->runtime(APP_PATH . 'app') as $class) {
|
||||
foreach (NoteManager::getTargetNote($class) as $value) {
|
||||
$value->execute($class);
|
||||
}
|
||||
|
||||
+3
-2
@@ -61,12 +61,13 @@ class Annotation extends Component
|
||||
* @param string $path
|
||||
* @param string $namespace
|
||||
* @param array $exclude
|
||||
* @return void
|
||||
* @return static
|
||||
* @throws Exception
|
||||
*/
|
||||
public function read(string $path, string $namespace = 'App', array $exclude = []): void
|
||||
public function read(string $path, string $namespace = 'App', array $exclude = []): static
|
||||
{
|
||||
$this->_loader->_scanDir(new DirectoryIterator($path), $namespace, $exclude);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user