Handle export change position event

@param UpdatePositionEvent $updatePositionEvent
@param $eventName
@param EventDispatcherInterface $dispatcher
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);
        }
    }
1238464
public function toggleVisibility(StateToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $state = $event->getState();

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

        $event->setState($state);
    }
667012
public function onPrepareWorkspaceUploadMaintenancePage(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $host = $event->getWorkspace()->getHost();
        $connection = $this->ensureConnection($host);

        $directory = sprintf('%s/maintenance/%s', $host->getPath(), $this->documentRoot);
        $context = array('directory' => $directory, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);

        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Creating directory "{directory}".', $eventName, $this, $context));
        if ($connection->isDirectory($directory) === false) {
            if ($connection->createDirectory($directory, 0770, true)) {
                $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Created directory "{directory}".', $eventName, $this, $context));
            } else {
                $context['event.task.action'] = TaskInterface::ACTION_FAILED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed creating directory "{directory}".', $eventName, $this, $context));
            }
        } else {
            $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
            $context['output.resetLine'] = true;

            $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Directory "{directory}" exists.', $eventName, $this, $context));
        }

        if ($connection->isDirectory($directory)) {
            $files = array_diff(scandir($this->localMaintenanceDirectory), array('.', '..'));
            foreach ($files as $file) {
                $localFile = $this->localMaintenanceDirectory.'/'.$file;
                if (is_file($localFile)) {
                    $context = array('file' => $localFile, 'event.task.action' => TaskInterface::ACTION_COMPLETED);

                    $uploaded = $connection->putFile($localFile, $directory.'/'.$file);
                    if ($uploaded === true) {
                        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Uploaded file "{file}".', $eventName, $this, $context));
                    }
                }
            }
        }
    }
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));
        }
    }
774271
protected function afterDispatch(string $eventName, $event)
    {
        $this->postDispatch($eventName, $event instanceof Event ? $event : new LegacyEventProxy($event));
    }
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);
    }
452799
public function create(FeatureCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $feature = new FeatureModel();

        $feature
            ->setDispatcher($dispatcher)

            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())

            ->save()
        ;

        $event->setFeature($feature);

        // Add atribute to all product templates if required
        if ($event->getAddToAllTemplates() != 0) {
            $this->doAddToAllTemplates($feature);
        }
    }
164891
public function create(FeatureAvCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $feature = new FeatureAvModel();

        $feature
            ->setDispatcher($dispatcher)

            ->setFeatureId($event->getFeatureId())
            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())

            ->save()
        ;

        $event->setFeatureAv($feature);
    }
830338
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
	{
		$this->eventDispatcher = $eventDispatcher;
		$this->twig->setEventDispatcher($eventDispatcher);
	}
321954
public function postUpdate(UpdateEvent $event)
    {
        $announcement = $event->getObject();

        $this->eventDispatcher->dispatch(
            'log',
            'Claroline\\AnnouncementBundle\\Event\\Log\\LogAnnouncementEditEvent',
            [$announcement->getAggregate(), $announcement]
        );
    }
790305
public function update(BrandUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $brand = BrandQuery::create()->findPk($event->getBrandId())) {
            $brand->setDispatcher($dispatcher);

            $brand
                ->setVisible($event->getVisible())
                ->setLogoImageId(\intval($event->getLogoImageId()) == 0 ? null : $event->getLogoImageId())
                ->setLocale($event->getLocale())
                ->setTitle($event->getTitle())
                ->setDescription($event->getDescription())
                ->setChapo($event->getChapo())
                ->setPostscriptum($event->getPostscriptum())
                ->save()
            ;

            $event->setBrand($brand);
        }
    }
1213912
public function onAddToQueueListenerQuery(AddToQueueEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $query          = $event->getQuery();
        $eventToSave    = $event->getEvent();
        $eventToSave    = serialize($eventToSave);
        $eventToSave    = urlencode($eventToSave);  // Ohne urlencode speichert Contao das serialisierte Event nicht!
        $kind           = $event->getKind();
        $priotity       = $event->getPriority();
        $srcmodule      = $event->getSrcmodule();
        $srctable       = $event->getSrctable();
        $srcid          = $event->getSrcid();
        $interval       = $event->getIntervalkind();
        $query         .= "tstamp = " . time();
        $query         .= ", kind = '$kind'";
        $query         .= ", priority = $priotity";
        $query         .= ", data = '$eventToSave'";
        $query         .= ", srcmodule = '$srcmodule'";
        $query         .= ", srcid = $srcid";
        $query         .= ", srctable = '$srctable'";
        $query         .= ", intervalkind = '$interval'";
        $event->setQuery($query);
    }
845935
protected function genericUpdateDelegatePosition(ModelCriteria $query, UpdatePositionEvent $event, EventDispatcherInterface $dispatcher = null)
    {
        if (null !== $object = $query->findOne()) {
            if (!isset(class_uses($object)['Thelia\Model\Tools\PositionManagementTrait'])) {
                throw new \InvalidArgumentException("Your model does not implement the PositionManagementTrait trait");
            }

            //$object->setDispatcher($dispatcher !== null ? $dispatcher : $event->getDispatcher());

            $mode = $event->getMode();

            if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) {
                $object->changeAbsolutePosition($event->getPosition());
            } elseif ($mode == UpdatePositionEvent::POSITION_UP) {
                $object->movePositionUp();
            } elseif ($mode == UpdatePositionEvent::POSITION_DOWN) {
                $object->movePositionDown();
            }
        }
    }
318770
public function fireEvent($eventName, Event $event = null)
    {
        /** @var EventDispatcher $events */
        $events = $this['events'];

        return $events->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);
    }
832957
public function create(OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $session = $this->getSession();

        $order = $event->getOrder();
        $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId());

        $placedOrder = $this->createOrder(
            $dispatcher,
            $event->getOrder(),
            $session->getCurrency(),
            $session->getLang(),
            $session->getSessionCart($dispatcher),
            $this->securityContext->getCustomerUser()
        );

        $dispatcher->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder));

        /* but memorize placed order */
        $event->setOrder(new OrderModel());
        $event->setPlacedOrder($placedOrder);

        /* call pay method */
        $payEvent = new OrderPaymentEvent($placedOrder);

        $dispatcher->dispatch(TheliaEvents::MODULE_PAY, $payEvent);

        if ($payEvent->hasResponse()) {
            $event->setResponse($payEvent->getResponse());
        }
    }