Change a configuration entry value

@param \Thelia\Core\Event\Config\ConfigUpdateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
969383
public function setValue(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
            if ($event->getValue() !== $config->getValue()) {
                $config->setDispatcher($dispatcher)->setValue($event->getValue())->save();

                $event->setConfig($config);
            }
        }
    }
155027
public function onSubscriptionCancel(StripeSubscriptionCancelEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $localSubscription = $event->getLocalSubscription();

        $localSubscription->setCancelAtPeriodEnd(true);

        $result = $this->getStripeManager()->cancelSubscription($localSubscription, true);

        // Check if something went wrong
        if (false === $result) {
            // Stop progation
            $event->setStopReason($this->getStripeManager()->getError())->stopPropagation();

            // Dispatch a failed event
            $dispatcher->dispatch(StripeSubscriptionCancelEvent::FAILED, $event);

            // exit
            return;
        }

        $dispatcher->dispatch(StripeSubscriptionCancelEvent::CANCELED, $event);
    }
1092883
public function toggleVisibility(BrandToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $brand = $event->getBrand();

        $brand
            ->setDispatcher($dispatcher)
            ->setVisible(!$brand->getVisible())
            ->save();

        $event->setBrand($brand);
    }
101813
public function create(MessageCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $message = new MessageModel();

        $message
            ->setDispatcher($dispatcher)

            ->setName($event->getMessageName())
            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())
            ->setSecured($event->getSecured())

            ->save()
        ;

        $event->setMessage($message);
    }
545180
public function toggleVisibility(CountryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $country = $event->getCountry();

        $country
            ->setDispatcher($dispatcher)
            ->setVisible(!$country->getVisible())
            ->save();

        $event->setCountry($country);
    }
4337
public function exportChangePosition(UpdatePositionEvent $updatePositionEvent, $eventName, EventDispatcherInterface $dispatcher)
    {
        $this->handler->getExport($updatePositionEvent->getObjectId(), true);
        $this->genericUpdatePosition(new ExportQuery, $updatePositionEvent, $dispatcher);
    }
172150
public function dispatchEvent($eventName, Event $event = null)
    {
        if ($this->eventDispatcher instanceof EventDispatcherInterface) {
            $this->eventDispatcher->dispatch($eventName, $event);
        }
    }
318770
public function fireEvent($eventName, Event $event = null)
    {
        /** @var EventDispatcher $events */
        $events = $this['events'];

        return $events->dispatch($eventName, $event);
    }
469050
public function update(CategoryUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
            $category
                ->setDispatcher($dispatcher)
                ->setDefaultTemplateId($event->getDefaultTemplateId() == 0 ? null : $event->getDefaultTemplateId())
                ->setLocale($event->getLocale())
                ->setTitle($event->getTitle())
                ->setDescription($event->getDescription())
                ->setChapo($event->getChapo())
                ->setPostscriptum($event->getPostscriptum())

                ->setParent($event->getParent())
                ->setVisible($event->getVisible())

                ->save();

            $event->setCategory($category);
        }
    }
739629
public function onInstallReleaseCreateOrUpdateConfiguration(InstallReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $release = $event->getRelease();
        $this->gatherEnvironmentVariables($release);

        $connection = $this->ensureConnection($release->getWorkspace()->getHost());

        $configurationFile = $release->getPath().$this->configurationFile;
        $configurationDistributionFile = $configurationFile.'.dist';

        $context = array('action' => 'Creating', 'configurationFile' => $configurationFile, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);
        if ($connection->isFile($configurationFile)) {
            $context['action'] = 'Updating';
        }

        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, '{action} configuration file "{configurationFile}"...', $eventName, $this, $context));

        $yamlConfiguration = $this->getYamlConfiguration($connection, $release->getWorkspace()->getHost()->getStage(), $configurationFile, $configurationDistributionFile);
        if ($connection->putContents($configurationFile, $yamlConfiguration)) {
            $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
            if ($context['action'] === 'Creating') {
                $context['action'] = 'Created';
            } else {
                $context['action'] = 'Updated';
            }

            $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, '{action} configuration file "{configurationFile}".', $eventName, $this, $context));
        } else {
            $context['event.task.action'] = TaskInterface::ACTION_FAILED;
            $context['action'] = strtolower($context['action']);

            $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed {action} configuration file "{configurationFile}".', $eventName, $this, $context));
        }
    }
650236
public function setActionByDispatchName($dispatchName)
    {
        if (array_key_exists($dispatchName, $this->availableEvents)) {
            $this->action = $this->availableEvents[$dispatchName];
        } else {
            throw new \RuntimeException('Document Model event dispatch type not found: ' . $dispatchName);
        }
    }
1105620
private function dispatchEvent($eventName, MessageEvent $event)
    {
        if ($this->eventDispatcher) {
            return $this->eventDispatcher->dispatch($eventName, $event);
        }

        return $event;
    }
1157027
public function onSaveJobResultRun(
        QueueSaveJobResultEvent $event,
        $eventName,
        EventDispatcherInterface $dispatcher
    ) {
        $query = $event->getQuery();
        $this->database->execute($query);
    }
1195966
public function onQueueResponseListenerGenerate(
        QueueResponseEvent $event,
        $eventName,
        EventDispatcherInterface $dispatcher
    ) {
        $queueName          = $event->getQueueName();
        $kind               = $event->getKind();
        $content            = $event->getContent();
        $msgKey             = 'con4gis - QueueMessage';
        $msgType            = $queueName . '_' . $kind;
        $param              = $event->getParam();
        $param['queueName'] = $queueName;
        $param['kind']      = $kind;
        $param['content']   = $content;
        $param['msgKey']    = $msgKey;
        $param['msgType']   = $msgType;

        if (class_exists('Notification')) {
            $notifications = Notification::findByType($msgType);

            if ($notifications !== null) {
                while ($notifications->next()) {
                    $notifications->current()
                                  ->send($param);
                }
            }
        }
    }
1302231
public function triggerEvent($eventName, Event $event = null)
    {
        if (!$event) {
            $event = new Event;
        }

        $event->setTarget($this);

        return $this->eventDispatcher->dispatch($eventName, $event);
    }
210805
public function onSubscriptionCreate(StripeSubscriptionCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $localSubscription = $event->getLocalSubscription();

        $result = $this->getStripeManager()->createSubscription($localSubscription);

        // Check if something went wrong
        if (false === $result) {
            // Stop progation
            $event->setStopReason($this->getStripeManager()->getError())->stopPropagation();

            // Dispatch a failed event
            $dispatcher->dispatch(StripeSubscriptionCreateEvent::FAILED, $event);

            // exit
            return;
        }

        $dispatcher->dispatch(StripeSubscriptionCreateEvent::CREATED, $event);
    }
1313724
public function doDispatch(DispatchEvent $event)
    {
        $controller = $event->getContext();
        $action     = $event->getParam('action') . 'Action';

        $server   = $this->getServer();
        $request  = $server->getRequest()->withAddedAttributes($event->getParams());
        $response = $server->getResponse();

        $result = call_user_func_array([$controller, $action], [$request, $response]);
        $event->setResult($result);
    }