public function update($name, $data = [])
    {
        $setting = $this->get($name);

        if (!$setting) {
            throw new \LogicException(sprintf('Setting %s not exist.', $name));
        }

        $this->eventDispatcher->dispatch(Events::PRE_UPDATE, new SettingActionEvent($name, $data, $setting));

        #TODO Add populate function to document class
        foreach ($data as $key => $value) {
            $setting->{'set'.ucfirst($key)}($value);
        }

        $this->manager->persist($setting);
        $this->manager->commit();
        $this->cache->delete($name);

        if ($setting->getType() == 'experiment' || $setting->getName() == 'ongr_active_experiments') {
            $this->getActiveExperimentProfilesCookie()->setClear(true);
        }

        $this->eventDispatcher->dispatch(Events::PRE_UPDATE, new SettingActionEvent($name, $data, $setting));

        return $setting;
    }