Ejemplo n.º 1
0
 /**
  * Construct an abstract sampler.
  *
  * @param   array  $parameters    Parameters.
  * @return  void
  */
 public function __construct(array $parameters = [])
 {
     $this->_parameters = new Core\Parameter(__CLASS__, [], ['integer.min' => -16, 'integer.max' => 15, 'float.min' => -128.0, 'float.max' => 127.0]);
     $this->_parameters->setParameters($parameters);
     if (null === $this->_parameters->getParameter('integer.min')) {
         $this->_parameters->setParameter('integer.min', PHP_INT_MIN);
     }
     if (null === $this->_parameters->getParameter('integer.max')) {
         $this->_parameters->setParameter('integer.max', PHP_INT_MAX);
     }
     if (null === $this->_parameters->getParameter('float.min')) {
         $this->_parameters->setParameter('float.min', PHP_INT_MIN);
     }
     if (null === $this->_parameters->getParameter('float.max')) {
         $this->_parameters->setParameter('float.max', PHP_INT_MAX);
     }
     $this->construct();
     return;
 }
Ejemplo n.º 2
0
 /**
  * Dispatch a router rule.
  *
  * @param   \Hoa\Router         $router    Router.
  * @param   \Hoa\View\Viewable  $view      View.
  * @return  mixed
  * @throws  \Hoa\Controller\Exception
  */
 public function dispatch(Router $router, View\Viewable $view = null)
 {
     $rule = $router->getTheRule();
     if (null === $rule) {
         $router->route();
         $rule = $router->getTheRule();
     }
     if (null === $view) {
         $view = $this->_currentView;
     } else {
         $this->_currentView = $view;
     }
     $parameters = $this->_parameters;
     $this->_parameters = clone $this->_parameters;
     foreach ($rule[Router::RULE_VARIABLES] as $key => $value) {
         $this->_parameters->setParameter('variables.' . $key, $value);
     }
     $out = $this->resolve($rule, $router, $view);
     unset($this->_parameters);
     $this->_parameters = $parameters;
     return $out;
 }