AppserverIo\Appserver\Naming\NamingDirectory::createSubdirectory PHP Метод

createSubdirectory() публичный Метод

Create and return a new naming subdirectory with the attributes of this one.
public createSubdirectory ( string $name, array $filter = [] ) : NamingDirectory
$name string The name of the new subdirectory
$filter array Array with filters that will be applied when copy the attributes
Результат NamingDirectory The new naming subdirectory
    public function createSubdirectory($name, array $filter = array())
    {
        try {
            // query whether or not the passed directory is relative or absolute
            if ($this->containsScheme($name)) {
                $this->setAttribute($this->stripSchema($name), '.');
            } else {
                // if the directory is relative, append it
                if ($directory = $this->getDirectory()) {
                    $directory = $this->appendDirectory($name);
                } else {
                    $this->setDirectory($directory = $name);
                }
                // bind the default value
                $this->bind($directory, '.');
            }
            // return the instance itself
            return $this;
        } catch (\Exception $e) {
            throw new NamingException(sprintf('Can\'t create subdirectory %s', $name), null, $e);
        }
    }

Usage Example

Пример #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('AppserverIo\\Psr\\Naming\\NamingDirectoryInterface', $this->namingDirectory->search('php:level1/level2/level3'));
 }
All Usage Examples Of AppserverIo\Appserver\Naming\NamingDirectory::createSubdirectory