Update question

@param GenericEvent $event
504784
public function update(GenericEvent $event)
    {
        $originalAnswers = new ArrayCollection();

        foreach ($event->getSubject()->getAnswers()->getSnapshot() as $answer) {
            $originalAnswers->add($answer);
        }

        /** @var ArrayCollection $answers */
        $answers = $event->getSubject()->getAnswers();

        foreach ($originalAnswers as $answer) {
            if ($answers->contains($answer) == false) {
                $answers->removeElement($answer);

                $this->manager->persist($answer);
                $this->manager->remove($answer);
            }
        }
    }
85211
public function setEvent($event)
  {
    if ($event === '?' || $event === '') {
      $this->event = null;
    } else {
      $event = Util::foreignLettersToEnglishLetters($event);
      $event = Util::titleCaseIfCurrentlyAllCaps($event);
      $this->event = $event === '?' ? null : $event;
    }
  }
202975
public function onUpdate(EventInterface $event)
    {
        $values = $event->getParam('values');

        $now = new DateTime();
        $values['last_updated_at'] = $now->format('Y-m-d h:i:s');

        $event->setParam('values', $values);
    }
194313
protected function dispatchEvent(\Erebot\Interfaces\Event\Base\Generic $event)
    {
        $logger = \Plop\Plop::getInstance();
        $logger->debug(
            $this->bot->gettext('Dispatching "%(type)s" event.'),
            array('type' => get_class($event))
        );
        try {
            foreach ($this->events as $handler) {
                if ($handler->handleEvent($event) === false) {
                    break;
                }
            }
        } catch (\Erebot\ErrorReportingException $e) {
            // This should help make the code a little more "bug-free" (TM).
            $logger->exception($this->bot->gettext('Code is not clean!'), $e);
            $this->disconnect($e->getMessage());
        }
    }
701943
public function onWorkspacesDelete(GenericDatasEvent $event)
    {
        $workspaces = $event->getDatas();
        $ids = array();

        foreach ($workspaces as $workspace) {
            $ids[] = $workspace->getId();
        }
        $this->tagManager->removeTaggedObjectsByClassAndIds(
            'Claroline\CoreBundle\Entity\Workspace\Workspace',
            $ids
        );
    }
1364123
public function onReflectComplete(GenericEvent $event)
    {
        $context = $event->getArguments();
        unset($context['extra']);
        $this->logger->notice('Parsing data source "{source}" completed.', $context);
    }
772312
public function onDelete(GenericDataEvent $event)
    {
        /** @var UserEntity[] $users */
        $users = $event->getData();

        $ids = [];
        foreach ($users as $user) {
            $ids[] = $user->getId();
        }

        $this->manager->removeTaggedObjectsByClassAndIds(UserEntity::class, $ids);
    }
962268
public function update($event, $value)
    {
        if (null === $value) {
            return;
        }

        $event->setOptions($value);
        $event->stopPropagation();
    }
163770
public function onRetrieveObjectsByTag(GenericDatasEvent $event)
    {
        $taggedObjects = array();
        $datas = $event->getDatas();

        if (is_array($datas) && isset($datas['tag']) && !empty($datas['tag'])) {
            $search = $datas['tag'];
            $user = isset($datas['user']) ? $datas['user'] : null;
            $withPlatform = isset($datas['with_platform']) && $datas['with_platform'];
            $strictSearch = isset($datas['strict']) ? $datas['strict'] : false;
            $class = isset($datas['class']) ? $datas['class'] : null;
            $objectResponse = isset($datas['object_response']) && $datas['object_response'];
            $orderedBy = isset($datas['ordered_by']) ? $datas['ordered_by'] : 'id';
            $order = isset($datas['order']) ? $datas['order'] : 'ASC';

            $objects = $this->tagManager->getTaggedObjects(
                $user,
                $withPlatform,
                $class,
                $search,
                $strictSearch
            );

            if (!is_null($class) && $objectResponse) {
                $ids = array();

                foreach ($objects as $object) {
                    $ids[] = $object->getObjectId();
                }
                $taggedObjects = $this->tagManager->getObjectsByClassAndIds(
                    $class,
                    $ids,
                    $orderedBy,
                    $order
                );
            } else {

                foreach ($objects as $object) {
                    $datas = array();
                    $datas['class'] = $object->getObjectClass();
                    $datas['id'] = $object->getObjectId();
                    $datas['name'] = $object->getObjectName();
                    $taggedObjects[] = $datas;
                }
            }
        }
        $event->setResponse($taggedObjects);
    }
1161509
private function mutate($event)
    {
        $method = 'on' . (string) new EventName($event);

        if (method_exists($this, $method)) {
            $this->$method($event);
        } else {
            throw new \RuntimeException(sprintf('Method %s does not exist on aggregate %s', $method, get_class($this)));
        }
    }
47976
public function onReflectProgress(GenericEvent $event)
    {
        static $start = false;

        if (!$start) {
            $this->stopwatch->start($event['source']);
            $start = true;
        }
        $this->stopwatch->start($event['file']->getPathname());
    }
572588
public function update($event, $value)
    {
        if (null === $value) {
            return;
        }

        $event->setAdditional($value);
        $event->stopPropagation();
    }
221340
public function onRetrieveUsedTagsByClassAndIds(GenericDataEvent $event)
    {
        $tags = [];
        $data = $event->getData();

        if (is_array($data) && isset($data['class']) && !empty($data['ids'])) {
            /** @var TaggedObject[] $taggedObjects */
            $taggedObjects = $this->manager->getTaggedObjects($data['class'], $data['ids']);

            if (isset($data['frequency']) && $data['frequency']) {
                //array [tagName => frequency]
                foreach ($taggedObjects as $taggedObject) {
                    $tag = $taggedObject->getTag();
                    if (!array_key_exists($tag->getName(), $tags)) {
                        $tags[$tag->getName()] = 0;
                    }
                    ++$tags[$tag->getName()];
                }
            } else {
                //array [tagName]
                foreach ($taggedObjects as $taggedObject) {
                    $tag = $taggedObject->getTag();
                    $tags[$tag->getId()] = $taggedObject->getTag()->getName();
                }
                $tags = array_values($tags);
            }
        }
        $event->setResponse($tags);
    }
396808
public function onPreRequest(ehough_tickertape_GenericEvent $event)
    {
        $request = $event->getSubject();

        $this->_isDebugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG);

        $this->_setDefaultHeadersBasic($request);
        $this->_setDefaultHeadersCompression($request);
        $this->_setDefaultHeadersContent($request);
    }
1321177
public function updateIndexedNode(NodeEvent $event)
    {
        $node = $event->getNode();
        if (true === $node->getStatus()->isPublishedState()
        ) {
            $this->nodeIndexor->index($node);
        } elseif (true === $event->getPreviousStatus()->isPublishedState()) {
            $this->nodeIndexor->delete($node);
        }
    }
1252659
public static function postUpdate( \Composer\Script\Event $event )
    {
        $_composer = $event->getComposer();
        $_package = $_composer->getPackage();
        // do stuff
    }
1359679
public function updateContentPosition(UpdatePositionEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        return $this->genericUpdatePosition(ProductAssociatedContentQuery::create(), $event, $dispatcher);
    }