Esempio n. 1
0
 protected static function callInstance(IService $instance, $method, array $exceptionMappings = [])
 {
     try {
         $result = json_encode(["result" => $instance->{$method}((new Input())->getData())]);
         header("Content-Length: " . strlen($result));
         echo $result;
     } catch (\Exception $exception) {
         $exceptionClass = get_class($exception);
         $httpCode = isset($exceptionMappings[$exceptionClass]) ? $exceptionMappings[$exceptionClass] : 500;
         $instance->fail($httpCode, $exception->getMessage());
     }
 }
Esempio n. 2
0
	/**
	 * @param IService
	 * @return Container
	 */
	public function setService(IService $service)
	{
		$this->updating();
		$this->services[$service->getEntityClass()] = $service;
		return $this;
	}