public function search($name, array $args = array())
{
try {
// strip off the schema
$key = $this->stripSchema($name);
// throw an exception if we can't find a value
if ($this->hasAttribute($key) === false) {
throw new \Exception(sprintf('Requested value %s has not been bound to naming directory %s', $name, $this->getIdentifier()));
}
// try to load the value, which may also be NULL
if (($found = $this->getAttribute($key)) == null) {
return;
}
// load the binded value/args
list($value, $bindArgs) = $found;
// check if we've a callback method
if (is_callable($value)) {
// if yes, merge the params and invoke the callback
foreach ($args as $arg) {
$bindArgs[] = $arg;
}
// invoke the callback
return call_user_func_array($value, $bindArgs);
}
// simply return the value
return $value;
} catch (\Exception $e) {
throw new NamingException(sprintf('Cant\'t resolve %s in naming directory %s', $name, $this->getIdentifier()), null, $e);
}
}