createSubdirectory() public method

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
return NamingDirectory The new naming subdirectory
Ejemplo n.º 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'));
 }
Ejemplo n.º 2
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');
     $level2->createSubdirectory('level3');
     // search for the last created subdirectory
     $this->assertSame('.', $this->namingDirectory->search('php:level1/level2/level3'));
 }
Ejemplo n.º 3
0
    $bootstrapFilename = sprintf('%s/etc/appserver/conf.d/bootstrap-commands.xml', APPSERVER_BP);
} elseif (array_key_exists($watch, $arguments) && file_exists(sprintf('%s/etc/appserver/conf.d/bootstrap-watcher.xml', APPSERVER_BP))) {
    // set the default watcher boostrap file
    $bootstrapFilename = sprintf('%s/etc/appserver/conf.d/bootstrap-watcher.xml', APPSERVER_BP);
} elseif (file_exists(sprintf('%s/etc/appserver/conf.d/bootstrap.xml', APPSERVER_BP))) {
    // try to load the default bootstrap file
    $bootstrapFilename = sprintf('%s/etc/appserver/conf.d/bootstrap.xml', APPSERVER_BP);
} else {
    // throw an exception if we don't have a bootstrap file
    throw new \Exception('Can\'t find a bootstrap file');
}
// create and initialize the naming directory
$namingDirectory = new NamingDirectory();
$namingDirectory->setScheme('php');
// create a directory for the services
$namingDirectory->createSubdirectory('php:env');
$namingDirectory->createSubdirectory('php:env/args');
$namingDirectory->createSubdirectory('php:global');
$namingDirectory->createSubdirectory('php:global/log');
$namingDirectory->createSubdirectory('php:services');
// create the default subdirectories
foreach (array_keys(ApplicationServer::$runlevels) as $runlevel) {
    $namingDirectory->createSubdirectory(sprintf('php:services/%s', $runlevel));
}
// bind the command line arguments to the naming directory
foreach ($arguments as $name => $value) {
    $namingDirectory->bind(sprintf('php:env/args/%s', $name), empty($value) ? true : $value);
}
// bind the current user to the naming directory
$namingDirectory->bind('php:env/currentUser', isset($_SERVER['SUDO_USER']) ? $_SERVER['SUDO_USER'] : get_current_user());
// bind the path to the default configuration and bootstrap filenames