PHPDaemon\Config\Parser::purgeScope PHP Method

purgeScope() protected method

Removes old config parts after updating.
protected purgeScope ( $scope ) : void
return void
    protected function purgeScope($scope)
    {
        foreach ($scope as $name => $obj) {
            if ($obj instanceof Generic) {
                if ($obj->source === 'config' && $obj->revision < $this->revision) {
                    if (!$obj->resetToDefault()) {
                        unset($scope->{$name});
                    }
                }
            } elseif ($obj instanceof Section) {
                if ($obj->source === 'config' && $obj->revision < $this->revision) {
                    if ($obj->count() === 0) {
                        unset($scope->{$name});
                    } elseif (isset($obj->enable)) {
                        $obj->enable->setValue(false);
                    }
                }
            }
        }
    }