@DI\Observe("claroline_users_delete")

@param GenericDataEvent $event
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);
    }
1311442
public function onRetrieveTags(GenericDatasEvent $event)
    {
        $tags = array();
        $tagsName = array();
        $datas = $event->getDatas();

        if (is_array($datas)) {
            $user = isset($datas['user']) ? $datas['user'] : null;
            $search = isset($datas['search']) ? $datas['search'] : '';
            $withPlatform = isset($datas['with_platform']) && $datas['with_platform'];
            $orderedBy = isset($datas['ordered_by']) ? $datas['ordered_by'] : 'name';
            $order = isset($datas['order']) ? $datas['order'] : 'ASC';
            $withPager = isset($datas['with_pager']) && $datas['with_pager'];
            $page = isset($datas['page']) ? $datas['page'] : 1;
            $max = isset($datas['max']) ? $datas['max'] : 50;
            $strictSearch = isset($datas['strict']) ? $datas['strict'] : false;

            $tags = $this->tagManager->getTags(
                $user,
                $search,
                $withPlatform,
                $orderedBy,
                $order,
                $withPager,
                $page,
                $max,
                $strictSearch
            );
        } else {
            $tags = $this->tagManager->getPlatformTags();
        }

        foreach ($tags as $tag) {
            $tagsName[] = $tag->getName();
        }
        $event->setResponse($tagsName);
    }
433996
public function onDeleteUser(LogGenericEvent $event)
    {
        if ($event instanceof LogUserDeleteEvent) {
            $receiver = $event->getReceiver();
            if (null !== $receiver) {
                $this->externalSyncUserManager->deleteExternalUserByUserId($receiver->getId());
            }
        }
    }
1240037
public function onReflectSuccess(GenericEvent $event)
    {
        if (sha1(serialize($event['ast'])) !== $this->hashUserData) {
            // cache need to be refresh
            ++$this->stats[self::STATS_MISSES];
            $this->storage->cache($event);
        }
    }
1174007
public function delete(FeatureDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) {
            $feature
                ->setDispatcher($dispatcher)
                ->delete()
            ;

            $event->setFeature($feature);
        }
    }
896350
public function onDelete(DeleteResourceEvent $event)
    {
        /** @var Blog $blog */
        $blog = $event->getResource();
        $options = $blog->getOptions();
        @unlink($this->container->getParameter('icap.blog.banner_directory').DIRECTORY_SEPARATOR.$options->getBannerBackgroundImage());

        $event->stopPropagation();
    }
1293347
public function delete(CategoryDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
            $con = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
            $con->beginTransaction();

            try {
                $fileList = ['images' => [], 'documentList' => []];

                // Get category's files to delete after category deletion
                $fileList['images']['list'] = CategoryImageQuery::create()
                    ->findByCategoryId($event->getCategoryId());
                $fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;

                $fileList['documentList']['list'] = CategoryDocumentQuery::create()
                    ->findByCategoryId($event->getCategoryId());
                $fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;

                // Delete category
                $category
                    ->setDispatcher($dispatcher)
                    ->delete($con);

                $event->setCategory($category);

                // Dispatch delete category's files event
                foreach ($fileList as $fileTypeList) {
                    foreach ($fileTypeList['list'] as $fileToDelete) {
                        $fileDeleteEvent = new FileDeleteEvent($fileToDelete);
                        $dispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
                    }
                }

                $con->commit();
            } catch (\Exception $e) {
                $con->rollback();
                throw $e;
            }
        }
    }
1345350
public function delete(EventInterface $event) {
        $event->getManager()->trigger('db.metadata.delete');
        $event->getResponse()->setModel(new Model\Metadata());
    }
404082
public function onGenerateResourceTracking(GenericDataEvent $event)
    {
        $data = $event->getData();
        $node = $data['resourceNode'];
        $user = $data['user'];
        $startDate = $data['startDate'];

        $logs = $this->resourceEvalManager->getLogsForResourceTracking(
            $node,
            $user,
            ['resource-read'],
            $startDate
        );
        $nbLogs = count($logs);

        if ($nbLogs > 0) {
            $this->om->startFlushSuite();
            $tracking = $this->resourceEvalManager->getResourceUserEvaluation($node, $user);
            $tracking->setDate($logs[0]->getDateLog());
            $tracking->setStatus(AbstractResourceEvaluation::STATUS_OPENED);
            $tracking->setNbOpenings($nbLogs);
            $this->om->persist($tracking);
            $this->om->endFlushSuite();
        }
        $event->stopPropagation();
    }
676983
public function delete(TemplateDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== ($template = TemplateQuery::create()->findPk($event->getTemplateId()))) {
            // Check if template is used by a product
            $productCount = ProductQuery::create()->findByTemplateId($template->getId())->count();
            
            if ($productCount <= 0) {
                $con = Propel::getWriteConnection(TemplateTableMap::DATABASE_NAME);
                $con->beginTransaction();
                
                try {
                    $template
                        ->setDispatcher($dispatcher)
                        ->delete($con);
                    
                    // We have to also delete any reference of this template in category tables
                    // We can't use a FK here, as the DefaultTemplateId column may be NULL
                    // so let's take care of this.
                    CategoryQuery::create()
                        ->filterByDefaultTemplateId($event->getTemplateId())
                        ->update([ 'DefaultTemplateId' => null], $con);
                    
                    $con->commit();
                } catch (\Exception $ex) {
                    $con->rollback();
                    
                    throw $ex;
                }
            }
            
            $event->setTemplate($template);
            
            $event->setProductCount($productCount);
        }
    }
657857
public function onReflectError(GenericEvent $event)
    {
        $context = $event->getArguments();
        $this->logger->error('Parser has detected an error on file "{file}". {error}', $context);
    }
47976
public function onReflectProgress(GenericEvent $event)
    {
        static $start = false;

        if (!$start) {
            $this->stopwatch->start($event['source']);
            $start = true;
        }
        $this->stopwatch->start($event['file']->getPathname());
    }
970145
public static function create_delete_data_request(\core\event\user_deleted $event) {
        // Automatic creation of deletion requests must be enabled.
        if (get_config('tool_dataprivacy', 'automaticdeletionrequests')) {
            $requesttypes = [api::DATAREQUEST_TYPE_DELETE];
            $requeststatuses = [api::DATAREQUEST_STATUS_COMPLETE, api::DATAREQUEST_STATUS_DELETED];

            $hasongoingdeleterequests = api::has_ongoing_request($event->objectid, $requesttypes[0]);
            $hascompleteddeleterequest = (api::get_data_requests_count($event->objectid, $requeststatuses,
                    $requesttypes) > 0) ? true : false;

            if (!$hasongoingdeleterequests && !$hascompleteddeleterequest) {
                api::create_data_request($event->objectid, $requesttypes[0],
                        get_string('datarequestcreatedupondelete', 'tool_dataprivacy'),
                        data_request::DATAREQUEST_CREATION_AUTO);
            }
        }
    }
365980
public function onSniff(GenericEvent $event)
    {
        $context = $event->getArguments();

        $this->logger->debug('Visiting SNIFF, process {method} {sniff}', $context);
    }
232735
public function publicDelete($user, Event $event)
    {
        if ($event->creator->id == $user->id) {
            return User::findOrFail($user->id)->hasPermission('laralum::events.delete-public');
        }

        return false;
    }
783915
public function onStorageEventPreDelete(StorageEvent $event)
    {
        /** @var Entity\Users $userEntity */
        $userEntity = $event->getContent();
        if (!$userEntity instanceof Entity\Users) {
            return;
        }

        $this->deleteAuthtokens($userEntity);
        $this->deleteSessions($userEntity);
    }
1135768
public function onRetrieveUserWorkspacesByTag(GenericDataEvent $event)
    {
        $workspaces = [];
        $data = $event->getData();

        if (is_array($data) && isset($data['user']) && isset($data['tag'])) {
            $user = $data['user'];
            $tag = $data['tag'];
            $orderedBy = isset($data['ordered_by']) ? $data['ordered_by'] : 'id';
            $order = isset($data['order']) ? $data['order'] : 'ASC';
            $workspaces = $this->manager->getTaggedWorkspacesByRoles(
                $user,
                $tag,
                $orderedBy,
                $order
            );
        }
        $event->setResponse($workspaces);
    }