@DI\Observe("crud_post_create_object_claroline_corebundle_entity_role")

@param CreateEvent $event
976070
public function postCreate(CreateEvent $event)
    {
        /** @var Role $role */
        $role = $event->getObject();

        if ($role->getWorkspace()) {
            $sql = "
              INSERT INTO claro_resource_rights (role_id, mask, resourceNode_id)
              SELECT {$role->getId()}, 1, resource.id FROM claro_resource_node resource
              WHERE resource.workspace_id = {$role->getWorkspace()->getId()}
            ";

            $stmt = $this->conn->prepare($sql);
            $stmt->execute();
        }
    }
37426
public function create(ProductSaleElementCreateEvent $event)
    {
        $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME);

        $con->beginTransaction();

        try {
            // Check if we have a PSE without combination, this is the "default" PSE. Attach the combination to this PSE
            $salesElement = ProductSaleElementsQuery::create()
                ->filterByProductId($event->getProduct()->getId())
                ->joinAttributeCombination(null, Criteria::LEFT_JOIN)
                ->add(AttributeCombinationTableMap::COL_PRODUCT_SALE_ELEMENTS_ID, null, Criteria::ISNULL)
                ->findOne($con);

            if ($salesElement == null) {
                // Create a new default product sale element
                $salesElement = $event->getProduct()->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), false);
            } else {
                // This (new) one is the default
                $salesElement->setIsDefault(true)->save($con);
            }

            // Attach combination, if defined.
            $combinationAttributes = $event->getAttributeAvList();

            if (\count($combinationAttributes) > 0) {
                foreach ($combinationAttributes as $attributeAvId) {
                    $attributeAv = AttributeAvQuery::create()->findPk($attributeAvId);

                    if ($attributeAv !== null) {
                        $attributeCombination = new AttributeCombination();

                        $attributeCombination
                            ->setAttributeAvId($attributeAvId)
                            ->setAttribute($attributeAv->getAttribute())
                            ->setProductSaleElements($salesElement)
                            ->save($con);
                    }
                }
            }

            $event->setProductSaleElement($salesElement);

            // Store all the stuff !
            $con->commit();
        } catch (\Exception $ex) {
            $con->rollback();

            throw $ex;
        }
    }
895078
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();

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

        $visitor = $event->getVisitor();

        $visitor->addData('shadowLocales', $this->documentInspector->getShadowLocales($document));
    }
667180
public function onPostDeserialize(ObjectEvent $event)
    {
        /** @var TargetGroupRuleInterface $targetGroupRule */
        $targetGroupRule = $event->getObject();

        if (!$targetGroupRule instanceof TargetGroupRuleInterface) {
            return;
        }

        if ($targetGroupRule->getConditions()) {
            foreach ($targetGroupRule->getConditions() as $condition) {
                $condition->setRule($targetGroupRule);
            }
        }
    }
835807
public static function course_created(\core\event\course_created $event) {
        global $CFG;

        $course = $event->get_record_snapshot('course', $event->objectid);
        $format = course_get_format($course);
        if ($format->supports_news() && !empty($course->newsitems)) {
            require_once($CFG->dirroot . '/mod/forum/lib.php');
            // Auto create the announcements forum.
            forum_get_course_forum($event->objectid, 'news');
        }
    }
1259240
public function preCreate(CreateEvent $event)
    {
        $publicFile = $event->getObject();
        $options = $event->getOptions();
        $tmpFile = $options['file'];

        $fileName = !method_exists($tmpFile, 'getClientOriginalName') || !$tmpFile->getClientOriginalName() ?
            $tmpFile->getFileName() :
            $tmpFile->getClientOriginalName();
        $directoryName = $this->fileUtils->getActiveDirectoryName();
        $size = filesize($tmpFile);
        $mimeType = !method_exists($tmpFile, 'getClientMimeType') || !$tmpFile->getClientMimeType() ?
            $tmpFile->getMimeType() :
            $tmpFile->getClientMimeType();
        $extension = !method_exists($tmpFile, 'getClientOriginalExtension') || !$tmpFile->getClientOriginalExtension() ?
            $tmpFile->guessExtension() :
            $tmpFile->getClientOriginalExtension();
        $hashName = Uuid::uuid4()->toString().'.'.$extension;
        $prefix = 'data'.DIRECTORY_SEPARATOR.$directoryName;
        $url = $prefix.DIRECTORY_SEPARATOR.$hashName;

        $publicFile->setDirectoryName($directoryName);
        $publicFile->setFilename($fileName);
        $publicFile->setSize($size);
        $publicFile->setMimeType($mimeType);
        $publicFile->setCreationDate(new \DateTime());
        $publicFile->setUrl($url);

        if ($this->tokenStorage->getToken() && $user = 'anon.' !== $this->tokenStorage->getToken()->getUser()) {
            $user = $this->tokenStorage->getToken()->getUser();
            $publicFile->setCreator($user);
        }

        $tmpFile->move($this->filesDir.DIRECTORY_SEPARATOR.$prefix, $hashName);
    }
779703
public function preCreate(CreateEvent $event)
    {
        /** @var ResourceNode $resourceNode */
        $resourceNode = $event->getObject();

        // set the creator of the resource
        $user = $this->tokenStorage->getToken()->getUser();
        if ($user instanceof User) {
            $resourceNode->setCreator($user);
        }

        return $resourceNode;
    }
513779
public function onDisplayTool(OpenAdministrationToolEvent $event)
    {
        $content = $this->templating->render(
            'ClarolineCoreBundle:administration:users.html.twig', [
                // todo : put it in the async load of form
                'parameters' => $this->parametersSerializer->serialize(),
                'profile' => $this->profileSerializer->serialize(),
                'platformRoles' => $this->finder->search('Claroline\CoreBundle\Entity\Role', [
                    'filters' => ['type' => Role::PLATFORM_ROLE],
                ]),
            ]
        );

        $event->setResponse(new Response($content));
        $event->stopPropagation();
    }
689948
public function onPreSerialize(ObjectEvent $event)
    {
        $configuredType = $event->getObject();

        if ($configuredType instanceof ConfiguredType) {
            try {
                $configurationArray = json_decode($configuredType->getConfiguration(), true);
                $extraFormType = $this->registry->getType($configurationArray['form_type']);
                $configuredType->setExtraFormType($extraFormType);
            } catch (\Exception $e) {
                return;
            }
        }
    }
438752
public function onCreateZone(ZoneEvent $event)
    {
        $zone = $event->getZone();
        if ($zone->getComponents()->isEmpty()) {
            return;
        }

        $this->save($zone);
    }
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();
    }
990791
public function createView(ViewEvent $event)
    {
        $admin = $event->getAdmin();
        $action = $admin->getAction();
        $menuEvent = new MenuEvent($admin->getAction()->getConfiguration()->getParameter('menus'));
        $this->eventDispatcher->dispatch(Events::MENU, $menuEvent);
        $formName = '';

        // The form name is different according to the current action
        if ('edit' === $action->getName()) {
            $formName = 'entity';
        } elseif ('create' === $action->getName()) {
            $formName = 'entity';
        } elseif ('delete' === $action->getName()) {
            $formName = 'delete';
        }

        if ($this->shouldRedirect($admin, $action, $formName, $event->getRequest(), $admin->getConfiguration())) {
            $url = $this->getRedirectionUrl(
                $admin,
                $action,
                $admin->getConfiguration(),
                $event->getRequest()
            );

            $view = new RedirectView(
                $action->getName(),
                $admin->getName(),
                $action->getConfiguration(),
                $admin->getConfiguration()
            );
            $view->setUrl($url);
        } else {
            $view = $this->viewFactory->create(
                $event->getRequest(),
                $action->getName(),
                $admin->getName(),
                $admin->getConfiguration(),
                $action->getConfiguration(),
                $admin->getEntities(),
                $admin->getForms()
            );
        }
        $event->setView($view);
    }
644417
public function handle(MemberCreated $event)
    {
        if (is_null($event->actor)) {
            return;
        }

        $data = [
            'ip' => request()->ip(),
            'ua' => request()->header('User-Agent'),
        ];

        $event->actor->log('member.create', $data);
    }
152836
public function onConsoleCommand(ConsoleCommandEvent $event)
    {
        if (!$this->processRepository->createSchemaIfNotExists()) {
            throw new Exception('Cannot create schema for ConsoleProcessManagerBundle');
        }

        $argv = $_SERVER['argv'];
        unset($argv[0]);
        $command = implode(' ', $argv);

        if (!$process = $this->processRepository->findOneByCommand($command)) {
            $commandName = $event->getCommand()->getName();
            $process = $this->processRepository->createProcess($commandName, $command);
        }

        $call = new Call();
        $call->setStatus(Call::STATUS_STARTED);
        $call->setConsolePid($this->getPid());

        $this->processRepository->addCallToProcess($process, $call);

        $process->setLastCall($call);
        $this->processRepository->update($process);

        $_REQUEST['call_id'] = $call->getId();
    }
969598
public function postCreate(CreateEvent $event)
    {
        $organization = $event->getObject();
        $key = $this->cryptoManager->generatePair();
        $key->setOrganization($organization);
        $this->om->persist($key);
        $this->om->flush();
    }
903812
public function onSiteWebmasterCreate(SiteEvent $event)
    {
        /* @var UserInterface $user */
        $user = $this->entityManager->getStorage('user')->load($event->getArgument('webmaster_id'));

        if ($user->status == 0) {
            $this->tokenManager->sendTokenMail($user, 'ucms_user', 'new-account-disabled');
        } else {
            $this->tokenManager->sendTokenMail($user, 'ucms_user', 'new-account-enabled');
        }
    }
1261232
public function createEvent() {
        $event = new Event($this->getContext(),null);
        $this->addChild($event);
        $qry = new CreateEntityQuery($event);
        $this->getContext()->addQuery($qry, $event);
        return $event;
    }