/**
  * BeanstalkServer constructor.
  *
  * @param $identifier
  * @param $value array Server configuration
  *
  * @throws Exception
  */
 public function __construct($identifier, $value)
 {
     // check value
     $value = Collection::cast($value)->toArray() + ['port' => PheanstalkInterface::DEFAULT_PORT, 'timeout' => null, 'persistent' => false];
     $mandatory = ['host', 'tube'];
     $missing = array_diff($mandatory, array_keys($value));
     if ($missing) {
         throw new Exception(sprintf('Missing %s keys in beanstalk configuration', implode(', ', $missing)));
     }
     parent::__construct($identifier, $value);
 }
 /**
  * FastRoute constructor.
  * @param $identifier   string  Route name
  * @param $route        string  Actual route
  * @param null $action  string  Action Middleware class name
  * @param int $method
  */
 public function __construct($identifier, $route, $action = null, $method = self::GET)
 {
     if (is_null($action)) {
         throw new Exception(sprintf('Action cannot be null (route "%s")', $identifier));
     }
     if (is_int($method)) {
         $method = $this->extractMethods($method);
     }
     $value = ['id' => $identifier, 'route' => $route, 'method' => $method, 'handler' => $action];
     parent::__construct($identifier, $value);
 }
Example #3
0
 public function __construct($route, $path, $action = null)
 {
     if (!is_callable($path)) {
         $path = function (RequestInterface $request = null, $params = []) use($path) {
             // no request is passed, so forge matching URL
             if (is_null($request)) {
                 return $path;
             }
             // else try to match Url
             return $path == $request->getUri()->getPath();
         };
     }
     $this->setAction($action);
     $this->pathHelper = $path;
     parent::__construct($route, $this);
 }