Inheritance: implements SplSubject, use trait Struct
コード例 #1
0
ファイル: AcmeHost.php プロジェクト: kelunik/aerys-acme
 public function boot(Server $server, Logger $logger)
 {
     $this->logger = $logger;
     if ($this->showActionWarning) {
         $logger->warning("No actions registered for \$host yet, be sure to add them before injecting Host to AcmeHost for best performance.");
     }
     $server->attach(new StartEvent($this->onBoot));
 }
コード例 #2
0
ファイル: Ticker.php プロジェクト: amphp/aerys
 public function update(Server $server) : Promise
 {
     switch ($server->state()) {
         case Server::STARTED:
             $this->watcherId = \Amp\repeat([$this, "updateTime"], 1000);
             $this->updateTime();
             break;
         case Server::STOPPED:
             \Amp\cancel($this->watcherId);
             $this->watcherId = null;
             break;
     }
     return new Success();
 }
コード例 #3
0
ファイル: StartEvent.php プロジェクト: kelunik/aerys-acme
 public function update(Server $server) : Promise
 {
     if ($server->state() === Server::STARTED) {
         if ($this->callable) {
             $callable = $this->callable;
             $return = $callable($server);
             if ($return instanceof Promise) {
                 return $return;
             } else {
                 return new Success();
             }
         }
     }
     return new Success();
 }
コード例 #4
0
ファイル: Root.php プロジェクト: vlakarados/aerys
 /**
  * Receive notifications from the server when it starts/stops
  *
  * @param Server $server
  * @return \Amp\Promise
  */
 public function update(Server $server) : amp\Promise
 {
     switch ($server->state()) {
         case Server::STARTING:
             $this->loadMimeFileTypes(__DIR__ . "/../etc/mime");
             break;
         case Server::STARTED:
             $this->debug = $server->getOption("debug");
             amp\enable($this->cacheWatcher);
             break;
         case Server::STOPPED:
             amp\disable($this->cacheWatcher);
             $this->cache = [];
             $this->cacheTimeouts = [];
             $this->cacheEntryCount = 0;
             $this->bufferedFileCount = 0;
             break;
     }
     return new amp\Success();
 }
コード例 #5
0
ファイル: Router.php プロジェクト: amphp/aerys
 private function buildRouter(RouteCollector $rc, Server $server)
 {
     $allowedMethods = [];
     foreach ($this->routes as list($method, $uri, $actions)) {
         $allowedMethods[] = $method;
         list($app, $monitors) = $this->bootRouteTarget($actions);
         $rc->addRoute($method, $uri, $app);
         $this->monitors[$method][$uri] = $monitors;
     }
     $originalMethods = $server->getOption("allowedMethods");
     if ($server->getOption("normalizeMethodCase")) {
         $allowedMethods = array_map("strtoupper", $allowedMethods);
     }
     $allowedMethods = array_merge($allowedMethods, $originalMethods);
     $allowedMethods = array_unique($allowedMethods);
     $server->setOption("allowedMethods", $allowedMethods);
 }
コード例 #6
0
ファイル: Bootstrapper.php プロジェクト: amphp/aerys
 public function update(Server $server) : Promise
 {
     if ($server->state() === Server::STOPPING) {
         $this->isStopping = true;
     }
     return new Success();
 }