Exemple #1
0
 public function __construct($namespace)
 {
     $this->namespace = $namespace;
     if (empty($_SESSION[$namespace])) {
         $input = array();
     } else {
         $input = $_SESSION[$namespace];
     }
     parent::__construct($input);
 }
Exemple #2
0
 /**
  * @param array $parts
  * @param array $routes
  */
 private function resolve(array $parts, $routes = [])
 {
     if (count($parts)) {
         $part = array_shift($parts);
         if (isset($routes[$part])) {
             $matchPart = $part;
         } elseif (isset($routes)) {
             foreach (array_keys($routes) as $rout) {
                 if (strpos($rout, ':') === 0) {
                     $matchPart = $rout;
                     $param = mb_strcut($matchPart, 1);
                     $this->params[$param] = $part;
                     break;
                 }
             }
         }
         if (isset($matchPart)) {
             $match = $routes[$matchPart];
             $url = '/' . $matchPart;
             if (isset($match['name'])) {
                 $this->getBreadcrumbs()->append(['url' => $url, 'name' => $match['name'], 'title' => $match['name']]);
             }
             if (isset($match['module'])) {
                 $this->moduleName = $match['module'];
             }
             if (isset($match['controller'])) {
                 $this->controller = $match['controller'];
             }
             if (isset($match['action'])) {
                 $this->action = $match['action'];
             }
         } else {
             if (count($parts)) {
                 $value = array_shift($parts);
                 $this->params->offsetSet($part, $value);
             } else {
                 $this->notFound();
             }
             $match = [];
         }
         $this->resolve($parts, isset($match['children']) ? $match['children'] : []);
     }
 }
Exemple #3
0
 /**
  * @param $index
  * @return bool
  */
 public function has($index)
 {
     return $this->elements->offsetExists($index);
 }
Exemple #4
0
 /**
  * @return Collection
  */
 public function getValues()
 {
     $dataObject = new Common\Collection([]);
     foreach ($this->getElements() as $name => $element) {
         if ($element instanceof ElementInterface) {
             $dataObject->set($name, $element->getValue());
         }
     }
     return $dataObject;
 }