Update oids after commit
@param $event
197715
public function afterCommit(TransactionEvent $event) {
    if ($event->getPhase() == TransactionEvent::AFTER_COMMIT) {
      $response = $this->getResponse();

      // return the saved nodes
      $changedOids = array_flip($event->getInsertedOids());
      foreach ($this->nodeArray as $requestOidStr => $node) {
        $newOidStr = $node->getOID()->__toString();
        $oldOidStr = $changedOids[$newOidStr];
        $response->clearValue($oldOidStr);
        $response->setValue($newOidStr, $node);
      }

      // return oid of the lastly created node
      if ($this->lastInsertOid && !$response->hasErrors()) {
        $response->setValue('oid', $this->nodeArray[$this->lastInsertOid]->getOID());
        $response->setStatus(201);
      }
    }
  }
34460
public static function postInstall(Event $event)
    {
        require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';

        static::clearCompiled();
        static::artisanOptimize();
        static::artisanLangJS();
    }
308005
public static function onUpdate(Event $event)
    {
        $content = $event->getTarget();
        if (!($content instanceof AbstractClassContent)) {
            throw new BBException(
                'Enable to update object',
                BBException::INVALID_ARGUMENT,
                new \InvalidArgumentException(sprintf(
                    'Only BackBee\ClassContent\AbstractClassContent can be commit, `%s` received',
                    get_class($content)
                ))
            );
        }

        $dispatcher = $event->getDispatcher();
        if (null === $application = $dispatcher->getApplication()) {
            throw new BBException(
                'Enable to update object',
                BBException::MISSING_APPLICATION,
                new \RuntimeException('BackBee application has to be initialized')
            );
        }

        if (null === $token = $application->getBBUserToken()) {
            throw new SecurityException('Enable to update : unauthorized user', SecurityException::UNAUTHORIZED_USER);
        }

        $em = $dispatcher->getApplication()->getEntityManager();
        if (null === $revision = $content->getDraft()) {
            if (null === $revision = $em->getRepository('BackBee\ClassContent\Revision')->getDraft($content, $token)) {
                throw new ClassContentException('Enable to get draft', ClassContentException::REVISION_MISSING);
            }
            $content->setDraft($revision);
        }

        $content->releaseDraft();
        if (0 == $revision->getRevision() || $revision->getRevision() == $content->getRevision) {
            throw new ClassContentException('Content is up to date', ClassContentException::REVISION_UPTODATE);
        }

        $lastCommitted = $em->getRepository('BackBee\ClassContent\Revision')->findBy([
            '_content'  => $content,
            '_revision' => $content->getRevision(),
            '_state'    => Revision::STATE_COMMITTED,
        ]);
        if (null === $lastCommitted) {
            throw new ClassContentException(
                'Enable to get last committed revision',
                ClassContentException::REVISION_MISSING
            );
        }

        $content->updateDraft($lastCommitted);
    }
186697
public function afterUpdate($event)
    {
        $oldCondition = [];
        $currentCondition = [];
        /** @var ActiveRecord $owner */
        $owner = $this->owner;
        foreach ((array)$this->conditionAttributes as $attribute) {
            if (!$owner->hasAttribute($attribute)) {
                continue;
            }
            $oldCondition[$attribute] = $currentCondition[$attribute] = $owner->getAttribute($attribute);
            if (array_key_exists($attribute, $event->changedAttributes)) {
                $oldCondition[$attribute] = $event->changedAttributes[$attribute];
            }
        }
        if (array_diff($currentCondition, $oldCondition) != []) {
            // condition was changed
            /** @var ActiveRecord $changedModel */
            $changedModel = Yii::createObject($owner->className());
            $changedModel->setAttributes($oldCondition, false);
            // recalculate old model range
            $changedModel->recalculateSort();
            // move model to top in new model range
            $owner->updateAttributes([
                $this->sortAttribute => $owner->find()->andWhere($this->getCondition())->count() - 1
            ]);
        }
    }
335527
protected function update(IEvent $event)
    {
        $statement = $this->connection->prepare(
            'UPDATE ' . $this->table . ' SET response = :response, SET latency = :latency WHERE id = :id'
        );

        $statement->execute(
            [
                ':id' => $event->getId(),
                ':response' => $event->getResponse(),
                ':latency' => $event->getLatency(),
            ]
        );

        return $statement->columnCount() === 1;
    }
401912
public function update($event, $value)
    {
        $groupingInformation = ViewHelpers::getGroupingMode($event->getEnvironment());
        if (isset($groupingInformation['mode'])
            && ($groupingInformation['mode'] === GroupAndSortingInformationInterface::GROUP_NONE)
        ) {
            if (!\is_array($value)) {
                return;
            }

            $this->updateTableMode($event, $value);
        }

        if (!\is_string($value)) {
            return;
        }

        $this->updateNonTableMode($event, $value);
    }
877239
public function onPostSerialize(ObjectEvent $event)
    {
        $visitor = $event->getVisitor();
        $document = $event->getObject();

        if (!$document instanceof PathBehavior || !$this->documentRegistry->hasDocument($document)) {
            return;
        }

        $visitor->addData('path', $this->documentInspector->getContentPath($document));
    }
969598
public function postCreate(CreateEvent $event)
    {
        $organization = $event->getObject();
        $key = $this->cryptoManager->generatePair();
        $key->setOrganization($organization);
        $this->om->persist($key);
        $this->om->flush();
    }
1290323
public function afterFind($event)
    {
        $this->_dbAttributes = $this->owner->getAttributes();
        parent::afterFind($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
        }
    }
727557
public function beforeInsert($event)
    {
        foreach ($this->insert as $field) {
            $event->sender->$field = time();
        }
    }
268391
public static function onPostLoad(Event $event)
    {
        $revision = $event->getTarget();
        $dispatcher = $event->getDispatcher();
        $application = $dispatcher->getApplication();

        if (null !== $application) {
            $em = $application->getEntityManager();
            $revision
                ->setEntityManager($em)
                ->setToken($application->getBBUserToken())
            ;

            if (null === $revision->getContent()) {
                $db = $em->getConnection();
                $stmt = $db->executeQuery(
                    'SELECT `content_uid`, `classname` FROM `revision` WHERE `uid` = ?',
                    [$revision->getUid()]
                );

                $items = $stmt->fetchAll();
                if ($items) {
                    foreach ($items as $item) {
                        $content = $em->find(Revision::getFullClassname($item['classname']), $item['content_uid']);
                        if ($content) {
                            $revision->setContent($content);
                        }
                    }
                }
            }
        }

        $revision->postLoad();
    }
422595
public function update($event, $value)
    {
        if (null === $value) {
            return;
        }

        $event->setValue($value);
        $event->stopPropagation();
    }
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();
    }
1148441
public function afterFind($event)
    {
        foreach ($this->attributes as $attribute) {
            $this->owner->{$attribute} = $this->htmlEncode($this->owner->{$attribute});
        }
    }
792035
public function afterSave(Save $event)
    {
        /** @var Entity $entity */
        $entity = $event->getTarget();
        $entity->loadRelations = false;
        $prop = $this->getPropertyName();
        $relPrk = Entity\Manager::getInstance()->get($this->getRelatedEntity())
            ->getEntity()->getPrimaryKey();
        $entPrk = $entity->getPrimaryKey();
        
        if (isset($entity->$prop) && is_array($entity->$prop)) {
            $this->beforeDelete(new Delete(['primaryKey' => $entity->$entPrk]));
            foreach ($entity->$prop as $object) {
                $relVal = $object;
                if ($object instanceof Entity) {
                    $relVal = $object->$relPrk;
                }

                Sql::createSql($entity->getAdapter())
                    ->insert($this->getRelationTable())
                    ->set(
                        [
                            $this->getForeignKey() => $entity->$entPrk,
                            $this->getRelatedForeignKey() => $relVal
                        ]
                    )
                    ->execute();
            }
        }
        $entity->loadRelations = true;
    }
240035
public function beforeDelete($event)
    {
        $oldId = $this->owner->{$this->savedAttribute};
        if (($oldModel = FileModel::findOne($oldId)) !== null) {
            $event->isValid = $event->isValid && $oldModel->delete();
        }
    }