SimpleSAML_Configuration::getPathValue PHP Метод

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

The function will always return an absolute path unless the option is not set. It will then return the default value. It checks if the value starts with a slash, and prefixes it with the value from getBaseDir if it doesn't.
public getPathValue ( string $name, string | null $default = null ) : string | null
$name string Name of the configuration option.
$default string | null Default value of the configuration option. This parameter will default to null if not specified.
Результат string | null The path configuration option with name $name, or $default if the option was not found.
    public function getPathValue($name, $default = null)
    {
        // return the default value if the option is unset
        if (!array_key_exists($name, $this->configuration)) {
            $path = $default;
        } else {
            $path = $this->configuration[$name];
        }
        if ($path === null) {
            return null;
        }
        return $this->resolvePath($path) . '/';
    }

Usage Example

Пример #1
0
 /**
  * Initialize the output.
  *
  * @param SimpleSAML_Configuration $config  The configuration for this output.
  */
 public function __construct(SimpleSAML_Configuration $config)
 {
     $this->logDir = $config->getPathValue('directory');
     if ($this->logDir === NULL) {
         throw new Exception('Missing "directory" option for core:File');
     }
     if (!is_dir($this->logDir)) {
         throw new Exception('Could not find log directory: ' . var_export($this->logDir, TRUE));
     }
 }
All Usage Examples Of SimpleSAML_Configuration::getPathValue