Toggle Country visibility

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

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

        $event->setCountry($country);
    }
1368299
protected function dispatch($eventName, Event $event = null)
    {
        if ($event == null) {
            $event = new DefaultActionEvent();
        }

        $this->getDispatcher()->dispatch($eventName, $event);
    }
1105620
private function dispatchEvent($eventName, MessageEvent $event)
    {
        if ($this->eventDispatcher) {
            return $this->eventDispatcher->dispatch($eventName, $event);
        }

        return $event;
    }
848182
public function updateAccessoryPosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        return $this->genericUpdatePosition(AccessoryQuery::create(), $event, $dispatcher);
    }
84134
public function delete(AttributeAvDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== ($attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId()))) {
            $attribute
                ->setDispatcher($dispatcher)
                ->delete()
            ;

            $event->setAttributeAv($attribute);
        }
    }
214679
public function updateFeaturePosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $this->genericUpdatePosition(FeatureTemplateQuery::create(), $event, $dispatcher);
    }
322325
public function update(CurrencyUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
            $currency
                ->setDispatcher($dispatcher)

                ->setLocale($event->getLocale())
                ->setName($event->getCurrencyName())
                ->setSymbol($event->getSymbol())
                ->setFormat($event->getFormat())
                ->setRate($event->getRate())
                ->setCode(strtoupper($event->getCode()))

                ->save();

            $event->setCurrency($currency);
        }
    }
1362205
protected function dispatch($eventName, ActionEvent $event = null)
    {
        if ($event == null) {
            $event = new DefaultActionEvent();
        }

        $this->getDispatcher()->dispatch($eventName, $event);
    }
1250198
public function create(CouponCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $coupon = new CouponModel();

        $this->createOrUpdate($coupon, $event, $dispatcher);
    }
607398
public function getPostage(DeliveryPostageEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $module = $event->getModule();

        // dispatch event to target specific module
        $dispatcher->dispatch(
            TheliaEvents::getModuleEvent(
                TheliaEvents::MODULE_DELIVERY_GET_POSTAGE,
                $module->getCode()
            ),
            $event
        );

        if ($event->isPropagationStopped()) {
            return;
        }

        // call legacy module method
        $event->setValidModule($module->isValidDelivery($event->getCountry()));
        if ($event->isValidModule()) {
            $event->setPostage($module->getPostage($event->getCountry()));
        }
    }
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);
    }
972466
public function onSetStartTimeListenerQuery(
        QueueSetStartTimeEvent $event,
        $eventName,
        EventDispatcherInterface $dispatcher
    ) {
        $table          = $event->getQueueTable();
        $field          = $event->getField();
        $id             = $event->getId();
        $query          = "UPDATE $table SET $field = " . time() . " WHERE id = $id";
        $event->setQuery($query);
    }
68728
public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if ($event->getView() == 'folder') {
            $folder = FolderQuery::create()
                ->filterById($event->getViewId())
                ->filterByVisible(1)
                ->count();

            if ($folder == 0) {
                $dispatcher->dispatch(TheliaEvents::VIEW_FOLDER_ID_NOT_VISIBLE, $event);
            }
        }
    }
759133
public function delete(AttributeDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) {
            $attribute
                ->setDispatcher($dispatcher)
                ->delete()
            ;

            $event->setAttribute($attribute);
        }
    }
1157027
public function onSaveJobResultRun(
        QueueSaveJobResultEvent $event,
        $eventName,
        EventDispatcherInterface $dispatcher
    ) {
        $query = $event->getQuery();
        $this->database->execute($query);
    }
727670
public function toggleVisibility(CategoryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $category = $event->getCategory();

        $category
            ->setDispatcher($dispatcher)
            ->setVisible($category->getVisible() ? false : true)
            ->save()
            ;

        $event->setCategory($category);
    }
1318413
public function delete(ConfigDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
            if (!$config->getSecured()) {
                $config->setDispatcher($dispatcher)->delete();

                $event->setConfig($config);
            }
        }
    }