@DI\Observe("crud_pre_update_object_claroline_corebundle_entity_user")

@param UpdateEvent $event
176814
public function preUpdate(UpdateEvent $event)
    {
        $oldData = $event->getOldData();
        $user = $event->getObject();

        if (!empty($oldData) && $oldData['username'] !== $user->getUsername()) {
            $userRole = $this->roleManager->getUserRole($oldData['username']);
            $this->roleManager->renameUserRole($userRole, $user->getUsername());
            // TODO : rename personal WS if user is renamed
        }
    }
632171
public static function updateLastVisit($event)
    {
        if ($event->isValid) {
            /**
             * @var User $user
             */
            $user = $event->identity;
            $user->last_visit_at = time();
            $user->updateAttributes(['last_visit_at']);
            return true;
        }
        return false;
    }
1362811
public function afterUserLogin(UserEvent $event)
    {
        $settings = DefaultDashboard::$plugin->getSettings();

        // For the moment, only check on CP requests
        if (!Craft::$app->getRequest()->isCpRequest) {
            DefaultDashboard::log("Not a CP request");
            return;
        }

        $currentUser = $event->identity;
        $defaultUser = Craft::$app->users->getUserById($settings->userDashboard);

        if (!$defaultUser) {
            DefaultDashboard::error("Default User not found for ID: $settings->userDashboard");
            return;
        }

        // Proceed if we've got a setting for the default user, and its not that user logging in
        if ($currentUser->id == $defaultUser->id) {
            DefaultDashboard::log("Skip setting dashboard - this is the default user");
            return;
        }

        $currentUserWidgets = $this->_getUserWidgets($currentUser->id);
        $defaultUserWidgets = $this->_getUserWidgets($defaultUser->id);

        DefaultDashboard::log("Current User ID: " . $currentUser->id);
        DefaultDashboard::log("Default User ID: " . $defaultUser->id);
        DefaultDashboard::log("Current User Widget: " . json_encode($this->_widgets($currentUserWidgets)));
        DefaultDashboard::log("Default User Widget: " . json_encode($this->_widgets($defaultUserWidgets)));

        // If this user has no widgets, create them and finish - or, if we're forcing override
        if (!$currentUserWidgets || $settings->override) {
            // To prevent massive re-creating of widgets each login, check if default vs current is different
            if ($this->_compareWidgets($currentUserWidgets, $defaultUserWidgets)) {
                DefaultDashboard::log("Users widgets are the same");
                return;
            }

            // Remove any existing widgets for the user
            $this->_deleteUserWidgets($currentUser->id);

            // Update the logged in users widgets
            $this->_setUserWidgets($currentUser, $defaultUserWidgets);

            // Update the user with their dashboard-set flag so the default widgets aren't added
            Craft::$app->getDb()->createCommand()
                ->update('{{%users}}', ['hasDashboard' => true], ['id' => $currentUser->id])
                ->execute();
        }
    }
852307
public function preUpdate(PreUpdateEventArgs $eventArgs): void
    {
        $object = $eventArgs->getObject();
        $this->gatherResourceAndItemTags($object, true);

        $changeSet = $eventArgs->getEntityChangeSet();
        $associationMappings = $eventArgs->getEntityManager()->getClassMetadata(ClassUtils::getClass($eventArgs->getObject()))->getAssociationMappings();

        foreach ($changeSet as $key => $value) {
            if (!isset($associationMappings[$key])) {
                continue;
            }

            $this->addTagsFor($value[0]);
            $this->addTagsFor($value[1]);
        }
    }
1292882
public function preUpdate(PreUpdateEventArgs $args)
    {
        $entity = $args->getObject();

        /** @var object $entity */
        if (true === in_array(EditableEntityTrait::class, class_uses($entity))) {
            $entity->setUpdated(new DateTime());
        }
    }
1270451
public function preUpdate(PreUpdateEventArgs $event)
    {
        $entity = $event->getEntity();
        if ($entity instanceof CategorizableInterface) {
            $this
                ->categoryIntegrityFixer
                ->fixCategoriesIntegrity($entity);
        }
    }
419644
protected function performAdditionalUpdateAction($updateEvent)
    {
        $attr_values = $this->getRequest()->get('attribute_values', null);

        if ($attr_values !== null) {
            foreach ($attr_values as $id => $value) {
                $event = new AttributeAvUpdateEvent($id);

                $event->setTitle($value);
                $event->setLocale($this->getCurrentEditionLocale());

                $this->dispatch(TheliaEvents::ATTRIBUTE_AV_UPDATE, $event);
            }
        }

        return null;
    }
833949
public function preUpdate(MenuInterface $menu, PreUpdateEventArgs $event)
    {
        if (null !== $page = $menu->getPage()) {
            $event->setNewValue('route', $page->getRoute());
        }
        if ($event->hasChangedField('name') && !preg_match(self::NAME_REGEX, $name = $event->getNewValue('name'))) {
            $event->setNewValue('name', Transliterator::urlize(strtolower($name), '_'));
        }
    }
1014612
public function postUpdate(UpdateEvent $event)
    {
        $workspace = $event->getObject();
        $root = $this->resourceManager->getWorkspaceRoot($workspace);
        $root->setName($workspace->getName());
        $this->om->persist($root);
        $this->om->flush();
    }
216222
public function handle(UpdatedEvent $event)
    {
        // Delete sessions for user on password update
        if ($this->config->get('session.driver') === 'laranix') {
            Session::where('user_id', $event->user->id)->delete();
        }

        $this->track(Settings::TYPEID_UPDATED, $event->user->id, 50);
    }
1224675
public function onNodePrepare(NodeEvent $event)
    {
        $node = $event->getNode();

        if (!empty($node->group_id)) {
            return; // Someone took care of this for us
        }

        $node->group_id = $this->findMostRelevantGroupId();
        $node->is_ghost = (int)$this->findMostRelevantGhostValue($node);
    }
999636
public static function updateCito(Event $event)
    {
        $options = static::getOptions($event);
        $configDir = $options['symfony-config-dir'];
        $templateDir = $options['symfony-template-dir'];
        $fs = new Filesystem();

        /*
         * Update config/packages/cito.yaml
         */
        $yaml = Yaml::parseFile($configDir . '/packages/cito.yaml');
        if (!array_key_exists('user_agent_enabled', $yaml['cito'])) {
            $yaml['cito']['user_agent_enabled'] = false;
        }
        if (!array_key_exists('default_user_agent', $yaml['cito'])) {
            $yaml['cito']['default_user_agent'] = 'new';
        }
        if (!array_key_exists('user_agent_routing', $yaml['cito'])) {
            $yaml['cito']['user_agent_routing'] = [
                'new' => 'ie 11, opera > 52',
                'old' => 'ie < 11, opera < 52'
            ];
        }
        if (!array_key_exists('translation_enabled', $yaml['cito'])) {
            $yaml['cito']['translation_enabled'] = false;
        }
        if (!array_key_exists('translation_support', $yaml['cito'])) {
            $yaml['cito']['translation_support'] = [
                'de' => 'Deutsch',
                'en' => 'Englisch'
            ];
        }

        $fs->remove($configDir . '/packages/cito.yaml');
        $fs->dumpFile($configDir . '/packages/cito.yaml', Yaml::dump($yaml, 99));
    }
752342
public function onLayoutBoxPreUpdate(EntityEvent $event)
    {
        $resource = $event->getEntity();
        if ($resource instanceof LayoutBox) {
            $request  = $this->getRequestHelper()->getCurrentRequest();
            $settings = $this->getBoxSettingsFromRequest($request);
            $settings = $this->mergeUnmodifiedSettings($resource->getSettings(), $settings);
            $resource->setSettings($settings);
        }
    }
58799
public function onMerge(MergeUsersEvent $event)
    {
        // Replace user of Event nodes
        $eventCount = $this->manager->replaceEventUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineAgendaBundle] updated Event count: $eventCount");

        // Replace user of EventInvitation nodes
        $eventInvitationCount = $this->manager->replaceEventInvitationUser($event->getRemoved(), $event->getKept());
        $event->addMessage("[ClarolineAgendaBundle] updated EventInvitation count: $eventInvitationCount");
    }
779410
public function onPostUpdate(UserEvent $event)
    {
        if (!$event->hasData('password')) {
            return;
        }

        /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
        $user = $event->getResource();

        if (0 < $this->mailer->sendNewPasswordEmailMessage($user, $event->getData('password'))) {
            $event->addMessage(new ResourceMessage('ekyna_user.user.event.credentials_sent'));
        }
    }
1253414
public function setEvent(Event $e) : void
    {
        if ( ! $e instanceof DoctrineEvent) {
            $eventParams = $e->getParams();
            $e = new DoctrineEvent();
            $e->setParams($eventParams);
            unset($eventParams);
        }
        $this->event = $e;
    }
451714
public function handle(Login $event)
    {
        $user = $event->user;
        if (method_exists($user, 'updateLoginTimestamp')) {
            $user->updateLoginTimestamp();
        }
    }