@param Request $request
@param SettingsOwnerInterface|null $owner

@return \Symfony\Component\HttpFoundation\Response
517993
protected function manage(Request $request, SettingsOwnerInterface $owner = null)
    {
        $form = $this->createForm(SettingsType::class, $this->get('settings_manager')->all($owner));

        if ($request->isMethod('post')) {
            $form->handleRequest($request);

            if ($form->isValid()) {
                $this->get('settings_manager')->setMany($form->getData(), $owner);
                $this->get('session')->getFlashBag()->add(
                    'success',
                    $this->get('translator')->trans('settings_updated', array(), 'settings')
                );

                return $this->redirect($request->getUri());
            }
        }

        return $this->render(
            $this->container->getParameter('settings_manager.template'),
            array(
                'settings_form' => $form->createView(),
            )
        );
    }
201558
public function setRequest(Request $request)
    {
        $context = (new RequestContext())->fromRequest($request);

        $this->cachedRoot = null;
        $this->cachedSchema = null;
        return $this->setContext($context);
    }
826828
public function addSettingItem($owner, $code, array $definition)
    {
        $itemKey = $this->makeItemKey($owner, $code);

        if (isset($this->items[$itemKey])) {
            $definition = array_merge((array) $this->items[$itemKey], $definition);
        }

        $item = array_merge(self::$itemDefaults, array_merge($definition, [
            'code' => $code,
            'owner' => $owner
        ]));

        /*
         * Link to the generic settings page if a URL is not provided
         */
        if (isset($item['class']) && !isset($item['url'])) {
            $uri = [];

            if (strpos($owner, '.') !== null) {
                list($author, $plugin) = explode('.', $owner);
                $uri[] = strtolower($author);
                $uri[] = strtolower($plugin);
            }
            else {
                $uri[] = strtolower($owner);
            }

            $uri[] = strtolower($code);
            $uri =  implode('/', $uri);
            $item['url'] = Backend::url('system/settings/update/' . $uri);
        }

        $this->items[$itemKey] = (object) $item;
    }
1296242
public static function notAllowed(OwnableContract $ownable, CanBeOwnerContract $owner)
    {
        return new static(sprintf('Model `%s` not allows owner of type `%s`.', get_class($ownable), get_class($owner)));
    }
471141
public function patchSettingsAction(Request $request)
    {
        $settings = $request->request->all();

        try {
            $user = $this->tokenStorage->getToken()->getUser();

            foreach ($settings as $settingKey => $settingValue) {
                // get setting
                // TODO: move this logic into own service (UserSettingManager?)
                $setting = $this->userSettingRepository->findOneBy(['user' => $user, 'key' => $settingKey]);

                // or create new one
                if (!$setting) {
                    $setting = new UserSetting();
                    $setting->setKey($settingKey);
                    $setting->setUser($user);
                    $this->objectManager->persist($setting);
                }

                // persist setting
                $setting->setValue(json_encode($settingValue));
            }
            $this->objectManager->flush();

            //create view
            $view = View::create($settings, 200);
        } catch (RestException $exc) {
            $view = View::create($exc->toArray(), 400);
        }

        return $this->viewHandler->handle($view);
    }
827581
private function _createPreferenceEntity( $owner = null )
    {
        $prefClass = $this->_getFullClassname() . 'Preference';
        $pref = new $prefClass();

        if( $owner !== null )
        {
            $pref->{ 'set' . $this->_getShortClassname() }( $owner );
            $owner->{ 'add' . $this->_getPreferenceClassName() }( $pref );
        }

        return $pref;
    }
602034
public static function setContext($owner, $code)
    {
        $instance = self::instance();

        $instance->contextOwner = strtolower($owner);
        $instance->contextItemCode = strtolower($code);
    }
1097255
public function withOwner($owner, callable $callback, $args = [])
    {
        try {
            $this->setOwner($owner);
            return $callback(...$args);
        } finally {
            $this->clearOwner();
        }
    }
940869
public function store(Request $request)
    {
        $setting = new Setting();

        
        $setting->name = $request->name;

        
        $setting->description = $request->description;

        
        
        $setting->save();

        return redirect('setting');
    }
999298
private function filter(Collection $settings, string $section, string $key, ?string $owner)
    {
        return $settings->filter(
            function (SettingInterface $setting) use ($section, $key, $owner) {
                return $section === $setting->getSection()
                    && $key === $setting->getKey()
                    && $owner === $setting->getOwner();
            }
        );
    }
881018
public function newAuthorizeRequest($owner, $owner_id, $options)
  {
    return $this->getOAuth()->getAuthServer()
          ->getGrantType('authorization_code')
          ->newAuthoriseRequest($owner, $owner_id, $options);
  }
1056222
private function getSettingsFromRepository(SettingsOwnerInterface $owner = null)
    {
        $settings = array();

        foreach (array_keys($this->settingsConfiguration) as $name) {
            try {
                $this->validateSetting($name, $owner);
                $settings[$name] = null;
            } catch (WrongScopeException $e) {
                continue;
            }
        }

        /** @var Setting $setting */
        foreach ($this->repository->findBy(
            array('ownerId' => $owner === null ? null : $owner->getSettingIdentifier())
        ) as $setting) {
            if (array_key_exists($setting->getName(), $settings)) {
                $settings[$setting->getName()] = $this->serializer->unserialize($setting->getValue());
            }
        }

        return $settings;
    }
1052124
function touch($path, $owner = null)
    {
        touch($path);

        if ($owner) {
            $this->chown($path, $owner);
        }

        return $path;
    }
210532
public function historyAction(Request $request, $owner, $id)
    {
        $this->getDoctrine()->getManager()->getFilters()->disable('draft');

        /** @var Environment $environment */
        $environment = $this->get('opifer.content.block_environment');
        $environment->load($owner, $id);
        $environment->setBlockMode('manage');

        /** @var AbstractDesignSuite $suite */
        $suite = $this->get(sprintf('opifer.content.%s_design_suite', $owner));
        $suite->load($id);

        return $this->render($this->getParameter('opifer_content.content_history_view'), [
            'environment' => $environment,
            'suite' => $suite,
        ]);
    }
871401
public function getSetting($name, SettingsOwnerInterface $owner = null, $default = null)
    {
        return $this->settingsManager->get($name, $owner, $default);
    }
1354673
public function newAuthorizeRequest($owner, $owner_id, $options)
  {
    return $this->authServer->getGrantType('authorization_code')->newAuthoriseRequest($owner, $owner_id, $options);
  }
477195
public function setOwnerSide($ownerSide)
    {
        if (!is_bool($ownerSide)) {
            throw new \InvalidArgumentException('The attribute ownerSide on the class Attribute has to be boolean (' . gettype($ownerSide) . ('object' === gettype($ownerSide) ? ' ' . get_class($ownerSide) : '') . ' given).');
        }

        $this->ownerSide = $ownerSide;

        return $this;
    }