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

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

Binds the passed instance with the name to the naming directory.
public bind ( string $name, mixed $value, array $args = [] ) : void
$name string The name to bind the value with
$value mixed The object instance to bind
$args array The array with the arguments
Результат void
    public function bind($name, $value, array $args = array())
    {
        try {
            // strip off the schema
            $key = $this->stripSchema($name);
            // bind the value, if possible
            if ($this->hasAttribute($key) === false) {
                $this->setAttribute($key, array($value, $args));
                return;
            }
            // throw an exeception if the name has already been bound
            throw new \Exception(sprintf('A value with name %s has already been bound to naming directory %s', $name, $this->getIdentifier()));
        } catch (\Exception $e) {
            throw new NamingException(sprintf('Cant\'t bind %s to naming directory %s', $name, $this->getIdentifier()), null, $e);
        }
    }

Usage Example

Пример #1
0
 /**
  * Test the descending recursive search on a directory tree
  * with a three level structure.
  *
  * @return void
  */
 public function testThreeLevelDescendingRecursiveSearch()
 {
     // create the three level tree
     $level1 = $this->namingDirectory->createSubdirectory('level1');
     $level2 = $level1->createSubdirectory('level2');
     $level3 = $level2->createSubdirectory('level3');
     // bind a value and search recursive
     $this->namingDirectory->bind($name = 'php:level1/level2/level3/test', $value = 'testValue');
     $this->assertSame($this->namingDirectory->search($name), $value);
 }
All Usage Examples Of AppserverIo\Appserver\Naming\NamingDirectory::bind