This commit is contained in:
2021-01-19 19:35:40 +08:00
parent f56fe0c1b4
commit bc3b2160d4
+13 -3
View File
@@ -6,9 +6,11 @@ namespace Database;
use Annotation\IAnnotation; use Annotation\IAnnotation;
use Exception; use Exception;
use ReflectionException;
use Snowflake\Abstracts\Providers; use Snowflake\Abstracts\Providers;
use Snowflake\Application; use Snowflake\Application;
use Snowflake\Event; use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
@@ -33,11 +35,19 @@ class DatabasesProviders extends Providers
$event->on(Event::SERVER_WORKER_START, [$this, 'createPool']); $event->on(Event::SERVER_WORKER_START, [$this, 'createPool']);
$event->on(Event::SERVER_TASK_START, [$this, 'createPool']); $event->on(Event::SERVER_TASK_START, [$this, 'createPool']);
$event = Snowflake::app()->getEvent(); $event->on(Event::SERVER_BEFORE_START, [$this, 'scanModel']);
$event->on(Event::SERVER_BEFORE_START, function () { $event->on(Event::SERVER_WORKER_START, [$this, 'scanModel']);
}
/**
* @throws ReflectionException
* @throws ComponentException
*/
public function scanModel()
{
$attributes = Snowflake::app()->getAttributes(); $attributes = Snowflake::app()->getAttributes();
$attributes->readControllers(MODEL_PATH, 'App\Models', 'models'); $attributes->readControllers(MODEL_PATH, 'App\Models', 'models');
});
} }