elFinder\elFinderVolumeDriver::attr PHP Method

attr() protected method

Check file attribute
Author: Dmitry (dio) Levashov
protected attr ( string $path, string $name, boolean $val = null ) : boolean
$path string file path
$name string attribute name (read|write|locked|hidden)
$val boolean attribute value returned by file system
return boolean
    protected function attr($path, $name, $val = null)
    {
        if (!isset($this->defaults[$name])) {
            return false;
        }
        $perm = null;
        if ($this->access) {
            if (is_array($this->access)) {
                $obj = $this->access[0];
                $method = $this->access[1];
                $perm = $obj->{$method}($name, $path, $this->options['accessControlData'], $this);
            } else {
                $func = $this->access;
                $perm = $func($name, $path, $this->options['accessControlData'], $this);
            }
            if ($perm !== null) {
                return !!$perm;
            }
        }
        if ($this->separator != '/') {
            $path = str_replace($this->separator, '/', $this->_relpath($path));
        } else {
            $path = $this->_relpath($path);
        }
        $path = '/' . $path;
        for ($i = 0, $c = count($this->attributes); $i < $c; $i++) {
            $attrs = $this->attributes[$i];
            if (isset($attrs[$name]) && isset($attrs['pattern']) && preg_match($attrs['pattern'], $path)) {
                $perm = $attrs[$name];
            }
        }
        return $perm === null ? is_null($val) ? $this->defaults[$name] : $val : !!$perm;
    }