Xpressengine\Config\ConfigEntity::getPure PHP Method

getPure() public method

get pure value
public getPure ( string $name, mixed $default = null ) : mixed
$name string variable name
$default mixed default value
return mixed
    public function getPure($name, $default = null)
    {
        $segments = explode('.', $name);
        $key = array_shift($segments);
        if ($this->vo->{$key} !== null) {
            $value = $this->vo->{$key};
            if (empty($segments) || !is_array($value)) {
                return $value;
            }
            return array_get($value, implode('.', $segments));
        }
        return $default;
    }

Usage Example

Beispiel #1
0
 /**
  * convey to descendants
  *
  * @param ConfigEntity $config config instance
  * @param callable     $filter filter function
  * @param array        $items  item key list
  * @return void
  */
 protected function convey(ConfigEntity $config, callable $filter = null, array $items = null)
 {
     $descendants = $this->repo->fetchChildren($config->siteKey, $config->name);
     /** @var ConfigEntity $descendant */
     foreach ($descendants as $descendant) {
         if ($filter === null || call_user_func($filter, $descendant) === true) {
             if ($items === null) {
                 $descendant->clear();
             } else {
                 foreach ($items as $item) {
                     $val = $config->getPure($item);
                     if ($val instanceof Closure) {
                         continue;
                     }
                     $descendant->set($item, $val);
                 }
             }
             $this->repo->save($descendant);
         }
     }
 }