Example #1
0
 public function test0_Validate()
 {
     $collection = new Collection(new Yaml());
     $collection->merge(static::$collection);
     $collection->thaw('part1');
     $this->assertFalse($collection->immutable('part1'));
     $collection->thaw('*');
     $this->assertFalse($collection->none());
     $this->assertTrue($collection->size() == 1);
     //$collection = new Collection(new Yaml);
     $collection->{'thing'}('boing');
     $this->assertEquals($collection['thing'], 'boing');
     $collection->freeze("*");
     $collection->freeze(['thing']);
 }
Example #2
0
 /** 
  * Match the current Route against incoming URI.
  *
  * @param Request request incoming request
  * @todo refactor.
  * @return bool
  */
 public function match(Request $request)
 {
     $parts = $request->getUriParts();
     // if we have more parameters passed, as expected.
     if (count($parts) > $this->components->size()) {
         return false;
     }
     // if / was requested, just skip this part.
     if (count($parts) != 0) {
         $it = $this->components->iterator();
         $this->merges = array();
         while ($it->hasNext()) {
             $component = $it->next();
             if (isset($parts[$it->key()])) {
                 if (!$component->isDynamic() && $component->getName() != $this->ignoreExtension($parts[$it->key()])) {
                     return false;
                 } elseif (isset($this->requirements[$component->getName()]) && !preg_match($this->requirements[$component->getName()], $parts[$it->key()])) {
                     return false;
                 } else {
                     // Registry::get('__logger')->debug( sprintf("Adding %s to merges", $component->getName()) );
                     if ($component->isDynamic()) {
                         $this->merges[$component->getName()] = $this->ignoreExtension($parts[$it->key()]);
                     }
                 }
             }
         }
     }
     // preparing to return true.
     $this->doMerge($request);
     $this->load($request);
     return true;
 }