コード例 #1
0
 /**
  * Test if the search for a subdirectory works.
  *
  * @return void
  */
 public function testSearchForASubdirectory()
 {
     // create a three level directory
     $level1 = $this->namingDirectory->createSubdirectory('level1');
     $level2 = $level1->createSubdirectory('level2');
     $level3 = $level2->createSubdirectory('level3');
     // search for the last created subdirectory
     $this->assertInstanceOf('TechDivision\\Naming\\NamingDirectoryInterface', $this->namingDirectory->search('php:level1/level2/level3'));
 }
コード例 #2
0
 /**
  * Create and return a new naming subdirectory with the attributes
  * of this one.
  *
  * @param string $name   The name of the new subdirectory
  * @param array  $filter Array with filters that will be applied when copy the attributes
  *
  * @return \TechDivision\Naming\NamingDirectory The new naming subdirectory
  */
 public function createSubdirectory($name, array $filter = array())
 {
     // create a new subdirectory instance
     $subdirectory = new NamingDirectory($name, $this);
     // copy the attributes specified by the filter
     if (sizeof($filter) > 0) {
         foreach ($this->getAllKeys() as $key => $value) {
             foreach ($filter as $pattern) {
                 if (fnmatch($pattern, $key)) {
                     $subdirectory->bind($key, $value);
                 }
             }
         }
     }
     // bind it the directory
     $this->bind($name, $subdirectory);
     // return the instance
     return $subdirectory;
 }