public function save($settings, $namespace = null)
    {
        if ($namespace === null) {
            $namespace = $this->detectNamespace($settings);
        }

        $namespaceParameters = $this->settingsMapper->findByNamespace($namespace);
        $hydrator = $this->namespaceHydratorProvider->getHydrator($namespace);
        $arrayData = $hydrator->extract($settings);
        $eventParams = ['settings' => $settings, 'array_data' => $arrayData, 'namespace' => $namespace];
        $this->getEventManager()->trigger(__FUNCTION__, $this, $eventParams);
        foreach ($arrayData as $name => $value) {
            $parameter = $this->findParameter($namespace, $name, $namespaceParameters);
            if ($parameter !== null) {
                if ($parameter->getValue() != $value) {
                    $parameter->setValue($value);
                    $this->getEventManager()->trigger('updateParameter', $this, ['parameter' => $parameter]);
                    $this->settingsMapper->updateParameter($parameter);
                }
            } else {
                $parameterEntityClass = $this->options->getParameterEntityClass();
                $parameter = $parameterEntityClass::create($namespace, $name, $value);
                $this->getEventManager()->trigger('insertParameter', $this, ['parameter' => $parameter]);
                $this->settingsMapper->insertParameter($parameter);
            }

        }

        if ($this->options->getCacheOptions()->isEnabled()) {
            $this->getCacheManager()->delete($namespace);
            $this->getCacheManager()->create($namespace, $settings);
        }

        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, $eventParams);
    }
public function save($settings, $namespace = null)
    {
        if ($namespace === null) {
            $namespace = $this->detectNamespace($settings);
        }

        $namespaceParameters = $this->settingsMapper->findByNamespace($namespace);
        $hydrator = $this->namespaceHydratorProvider->getHydrator($namespace);
        $arrayData = $hydrator->extract($settings);
        $eventParams = ['settings' => $settings, 'array_data' => $arrayData, 'namespace' => $namespace];
        $this->getEventManager()->trigger(__FUNCTION__, $this, $eventParams);
        foreach ($arrayData as $name => $value) {
            $parameter = $this->findParameter($namespace, $name, $namespaceParameters);
            if ($parameter !== null) {
                if ($parameter->getValue() != $value) {
                    $parameter->setValue($value);
                    $this->getEventManager()->trigger('updateParameter', $this, ['parameter' => $parameter]);
                    $this->settingsMapper->updateParameter($parameter);
                }
            } else {
                $parameterEntityClass = $this->options->getParameterEntityClass();
                $parameter = $parameterEntityClass::create($namespace, $name, $value);
                $this->getEventManager()->trigger('insertParameter', $this, ['parameter' => $parameter]);
                $this->settingsMapper->insertParameter($parameter);
            }

        }

        if ($this->options->getCacheOptions()->isEnabled()) {
            $this->getCacheManager()->delete($namespace);
            $this->getCacheManager()->create($namespace, $settings);
        }

        $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, $eventParams);
    }
{@inheritDoc}