Files
kiri-core/system/Application.php
T
2020-09-02 11:38:47 +08:00

83 lines
1.2 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: whwyy
* Date: 2018/4/25 0025
* Time: 18:38
*/
namespace Snowflake;
use Exception;
use HttpServer\Server;
use Snowflake\Abstracts\BaseApplication;
/**
* Class Init
*
* @package Snowflake
*
* @property-read Config $config
*/
class Application extends BaseApplication
{
/**
* @var string
*/
public $id = 'uniqueId';
/**
* @throws Exception
*/
public function init()
{
/** @var Server $https */
$https = $this->make(Server::class, Server::class);
$https->initCore(Config::get('servers', true));
$process = Snowflake::get()->processes;
$process->initCore();
}
/**
* @param $name
* @param $service
* @return Application
* @throws
*/
public function import(string $name, string $service)
{
$class = $this->set($name, ['class' => $service]);
if (method_exists($class, 'onImport')) {
$class->onImport($this);
}
return $this;
}
/**
* @throws
*/
public function start()
{
$process = Snowflake::get()->processes;
$process->start();
}
/**
* @param $className
* @param null $abstracts
* @return mixed
* @throws Exception
*/
public function make($className, $abstracts = null)
{
return make($className, $abstracts);
}
}