@DI\Observe("crud_pre_create_object_claroline_agendabundle_entity_event")

@param CreateEvent $event
513289
public function preCreate(CreateEvent $event)
    {
        /** @var Group $role */
        $object = $event->getObject();
        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof User) {
            $object->setUser($user);
        } else {
            $object->setUser($this->userManager->getDefaultClarolineUser());
        }
    }
1055916
public function preCreate(CreateEvent $event)
    {
        $announcement = $event->getObject();
        $options = $event->getOptions();
        $announcement->setAggregate($options['announcement_aggregate']);

        if (!in_array(Options::NO_LOG, $options)) {
            $this->eventDispatcher->dispatch(
                'log',
                'Claroline\\AnnouncementBundle\\Event\\Log\\LogAnnouncementCreateEvent',
                [$announcement->getAggregate(), $announcement]
            );
        }
    }
97804
public function onSiteCreate(SiteEvent $event)
    {
        $site = $event->getSite();

        $this->service->getNotificationService()->subscribe('site', $site->getId(), $site->getOwnerUserId());
    }
618460
public function afterStore(Event $event) {
		$this->pathBuilder($event->getSubject()->pathBuilder());
		$this->subject = $event->getSubject();

		$this->autoProcessImageVersions($event->getData('entity'), 'create');
	}
436630
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();
        $context = $event->getContext();

        if (!$document instanceof StructureBehavior) {
            return;
        }

        $visitor = $event->getVisitor();
        $structureMetadata = $this->inspector->getStructureMetadata($document);

        if ($structureMetadata) {
            $visitor->addData('template', $document->getStructureType());
            $visitor->addData('originTemplate', $document->getStructureType());
            $visitor->addData('internal', false);
            $visitor->addData(
                'localizedTemplate',
                $structureMetadata->getTitle(
                    $this->inspector->getLocale($document)
                )
            );

            if (false !== array_search('defaultPage', $context->attributes->get('groups')->getOrElse([]))) {
                $this->addStructureProperties($structureMetadata, $document, $visitor);
            }

            // create bread crumbs
            if (false !== array_search('breadcrumbPage', $context->attributes->get('groups')->getOrElse([]))) {
                $this->addBreadcrumb($document, $visitor);
            }
        }
    }
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);
        }
    }
214343
public function create(ProductCreateEvent $event)
    {
        $defaultTaxRuleId = null;
        if (null !== $defaultTaxRule = TaxRuleQuery::create()->findOneByIsDefault(true)) {
            $defaultTaxRuleId = $defaultTaxRule->getId();
        }

        $product = new ProductModel();

        $product
            ->setDispatcher($this->eventDispatcher)

            ->setRef($event->getRef())
            ->setLocale($event->getLocale())
            ->setTitle($event->getTitle())
            ->setVisible($event->getVisible() ? 1 : 0)
            ->setVirtual($event->getVirtual() ? 1 : 0)
            ->setTemplateId($event->getTemplateId())

            ->create(
                $event->getDefaultCategory(),
                $event->getBasePrice(),
                $event->getCurrencyId(),
                // Set the default tax rule if not defined
                $event->getTaxRuleId() ?: $defaultTaxRuleId,
                $event->getBaseWeight(),
                $event->getBaseQuantity()
            )
        ;

        $event->setProduct($product);
    }
561483
public function onPostSerialize(ObjectEvent $event)
    {
        $object = $event->getObject();

        // FIXME This can be removed, as soon as we've got rid of all ApiEntities.
        if ($object instanceof ApiWrapper) {
            $object = $object->getEntity();
        }

        if (!$object instanceof AuditableInterface && !$object instanceof LocalizedAuditableBehavior) {
            return;
        }

        $visitor = $event->getVisitor();

        if (!$visitor instanceof GenericSerializationVisitor) {
            return;
        }

        $visitor->setData('_hash', $this->hasher->hash($object));
    }
1211859
public function onPostSerialize(ObjectEvent $event)
    {
        $teaser = $event->getObject();
        $visitor = $event->getVisitor();
        $context = $event->getContext();

        if (!($teaser instanceof Teaser)) {
            return;
        }

        $visitor->addData('teaserId', $context->accept(sprintf('%s;%s', $teaser->getType(), $teaser->getId())));
    }
372215
public function preCreate(CreateEvent $event)
    {
        /** @var Group $role */
        $group = $event->getObject();
        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof User) {
            $group->addOrganization($user->getMainOrganization());
        }
    }
308997
public function create(MarketingEvent &$marketingEvent)
    {
        $data = $marketingEvent->exportData();
        $endpoint = '/admin/marketing_events.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'marketing_event' => $data
            )
        );
        $marketingEvent->setData($response['marketing_event']);
    }
7458
public function preCreate(CreateEvent $event)
    {
        $message = $event->getObject();
        $forum = $this->getSubject($message)->getForum();

        //create user if not here
        $user = $this->om->getRepository(User::class)->findOneBy([
          'user' => $message->getCreator(),
          'forum' => $forum,
        ]);

        if (!$user) {
            $user = new User();
            $user->setForum($forum);
            $user->setUser($message->getCreator());
        }
        if (!$this->checkPermission('EDIT', $forum->getResourceNode())) {
            if (Forum::VALIDATE_PRIOR_ALL === $forum->getValidationMode()) {
                $message->setModerated(Forum::VALIDATE_PRIOR_ALL);
            }

            if (Forum::VALIDATE_PRIOR_ONCE === $forum->getValidationMode()) {
                $message->setModerated($user->getAccess() ? Forum::VALIDATE_NONE : Forum::VALIDATE_PRIOR_ONCE);
            }
        } else {
            $message->setModerated(Forum::VALIDATE_NONE);
        }

        return $message;
    }
1232031
public function createVersions(Event $Event) {
		if ($this->_checkEvent($Event)) {
			$table = $Event->getSubject();
			$record = $Event->getData('record');
			$this->_createVersions($table, $record, $Event->getData('operations'));
			$Event->stopPropagation();
		}
	}
357749
public function beforePrepare(Event $event)
	{
		$command = $event['command'];

		if ($command->getName() !== 'createEntity') return;
		if (!$command['_id']) return;

		$operation = $command->getOperation();
		$operation->setHttpMethod('PUT');
	}
984074
public function onCreate(CreateResourceEvent $event)
    {
        $form = $this->formFactory->create(new ActivityType(), new Activity());
        $form->handleRequest($this->request);

        if ($form->isValid()) {
            $published = $form->get('published')->getData();
            $event->setPublished($published);
            $activity = $form->getData();
            $activity->setName($activity->getTitle());
            $activityParameters = new ActivityParameters();
            $activityParameters->setActivity($activity);
            $activity->setParameters($activityParameters);
            $event->setResources(array($activity));
            $event->stopPropagation();

            return;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:Resource:createForm.html.twig',
            array(
                'form' => $form->createView(),
                'resourceType' => 'activity'
            )
        );

        $event->setErrorFormContent($content);
        $event->stopPropagation();
    }
1261232
public function createEvent() {
        $event = new Event($this->getContext(),null);
        $this->addChild($event);
        $qry = new CreateEntityQuery($event);
        $this->getContext()->addQuery($qry, $event);
        return $event;
    }
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;
    }