repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
claroline/Distribution
plugin/link/Serializer/ShortcutSerializer.php
ShortcutSerializer.serialize
public function serialize(Shortcut $shortcut, array $options = []) { return [ 'target' => $this->resourceNodeSerializer->serialize($shortcut->getTarget(), array_merge($options, [Options::SERIALIZE_MINIMAL])), ]; }
php
public function serialize(Shortcut $shortcut, array $options = []) { return [ 'target' => $this->resourceNodeSerializer->serialize($shortcut->getTarget(), array_merge($options, [Options::SERIALIZE_MINIMAL])), ]; }
[ "public", "function", "serialize", "(", "Shortcut", "$", "shortcut", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "[", "'target'", "=>", "$", "this", "->", "resourceNodeSerializer", "->", "serialize", "(", "$", "shortcut", "->", "getTar...
Serializes a Shortcut resource entity for the JSON api. @param Shortcut $shortcut @param array $options @return array
[ "Serializes", "a", "Shortcut", "resource", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Serializer/ShortcutSerializer.php#L59-L64
train
claroline/Distribution
plugin/link/Serializer/ShortcutSerializer.php
ShortcutSerializer.deserialize
public function deserialize(array $data, Shortcut $shortcut) { if (!empty($data['target']) && !empty($data['target']['id']) && (!$shortcut->getTarget() || $data['target']['id'] !== $shortcut->getTarget()->getUuid()) ) { // the target is specified and as changed /** @var ResourceNode $target */ $target = $this->om ->getRepository('ClarolineCoreBundle:Resource\ResourceNode') ->findOneBy(['uuid' => $data['target']['id']]); $shortcut->setTarget($target); } }
php
public function deserialize(array $data, Shortcut $shortcut) { if (!empty($data['target']) && !empty($data['target']['id']) && (!$shortcut->getTarget() || $data['target']['id'] !== $shortcut->getTarget()->getUuid()) ) { // the target is specified and as changed /** @var ResourceNode $target */ $target = $this->om ->getRepository('ClarolineCoreBundle:Resource\ResourceNode') ->findOneBy(['uuid' => $data['target']['id']]); $shortcut->setTarget($target); } }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Shortcut", "$", "shortcut", ")", "{", "if", "(", "!", "empty", "(", "$", "data", "[", "'target'", "]", ")", "&&", "!", "empty", "(", "$", "data", "[", "'target'", "]", "[", "'id'...
Deserializes shortcut data into an Entity. @param array $data @param Shortcut $shortcut @return Shortcut
[ "Deserializes", "shortcut", "data", "into", "an", "Entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Serializer/ShortcutSerializer.php#L74-L88
train
claroline/Distribution
plugin/exo/Validator/JsonSchema/Item/ItemValidator.php
ItemValidator.validateAfterSchema
public function validateAfterSchema($question, array $options = []) { $errors = []; if (empty($question['content'])) { // No blank content $errors[] = [ 'path' => '/content', 'message' => 'Question content can not be empty', ]; } if (!isset($question['score'])) { // No question with no score // this is not in the schema because this will become optional when exercise without scores will be implemented $errors[] = [ 'path' => '/score', 'message' => 'Question score is required', ]; } if (in_array(Validation::REQUIRE_SOLUTIONS, $options) && !isset($question['solutions'])) { // No question without solutions $errors[] = [ 'path' => '/solutions', 'message' => 'Question requires a "solutions" property', ]; } if (!$this->itemDefinitions->has($question['type'])) { $errors[] = [ 'path' => '/type', 'message' => 'Unknown question type "'.$question['type'].'"', ]; } // Validate hints if (isset($question['hints'])) { array_map(function ($hint) use (&$errors, $options) { $errors = array_merge($errors, $this->hintValidator->validateAfterSchema($hint, $options)); }, $question['hints']); } // Validate objects if (isset($question['objects'])) { array_map(function ($object) use (&$errors, $options) { $errors = array_merge($errors, $this->contentValidator->validateAfterSchema($object, $options)); }, $question['objects']); } // Validates specific data of the question type if (empty($errors)) { // Forward to the correct definition $definition = $this->itemDefinitions->get($question['type']); $errors = array_merge( $errors, $definition->validateQuestion($question, array_merge($options, [Validation::NO_SCHEMA])) ); } return $errors; }
php
public function validateAfterSchema($question, array $options = []) { $errors = []; if (empty($question['content'])) { // No blank content $errors[] = [ 'path' => '/content', 'message' => 'Question content can not be empty', ]; } if (!isset($question['score'])) { // No question with no score // this is not in the schema because this will become optional when exercise without scores will be implemented $errors[] = [ 'path' => '/score', 'message' => 'Question score is required', ]; } if (in_array(Validation::REQUIRE_SOLUTIONS, $options) && !isset($question['solutions'])) { // No question without solutions $errors[] = [ 'path' => '/solutions', 'message' => 'Question requires a "solutions" property', ]; } if (!$this->itemDefinitions->has($question['type'])) { $errors[] = [ 'path' => '/type', 'message' => 'Unknown question type "'.$question['type'].'"', ]; } // Validate hints if (isset($question['hints'])) { array_map(function ($hint) use (&$errors, $options) { $errors = array_merge($errors, $this->hintValidator->validateAfterSchema($hint, $options)); }, $question['hints']); } // Validate objects if (isset($question['objects'])) { array_map(function ($object) use (&$errors, $options) { $errors = array_merge($errors, $this->contentValidator->validateAfterSchema($object, $options)); }, $question['objects']); } // Validates specific data of the question type if (empty($errors)) { // Forward to the correct definition $definition = $this->itemDefinitions->get($question['type']); $errors = array_merge( $errors, $definition->validateQuestion($question, array_merge($options, [Validation::NO_SCHEMA])) ); } return $errors; }
[ "public", "function", "validateAfterSchema", "(", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "errors", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "question", "[", "'content'", "]", ")", ")", "{", "// No blank ...
Delegates the validation to the correct question type handler. @param array $question @param array $options @return array
[ "Delegates", "the", "validation", "to", "the", "correct", "question", "type", "handler", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Validator/JsonSchema/Item/ItemValidator.php#L67-L129
train
claroline/Distribution
main/core/Listener/CliListener.php
CliListener.setDefaultUser
public function setDefaultUser(ConsoleCommandEvent $event) { $command = $event->getCommand(); if ($command instanceof AdminCliCommand) { $user = $this->userManager->getDefaultClarolineAdmin(); $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $this->tokenStorage->setToken($token); } }
php
public function setDefaultUser(ConsoleCommandEvent $event) { $command = $event->getCommand(); if ($command instanceof AdminCliCommand) { $user = $this->userManager->getDefaultClarolineAdmin(); $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $this->tokenStorage->setToken($token); } }
[ "public", "function", "setDefaultUser", "(", "ConsoleCommandEvent", "$", "event", ")", "{", "$", "command", "=", "$", "event", "->", "getCommand", "(", ")", ";", "if", "(", "$", "command", "instanceof", "AdminCliCommand", ")", "{", "$", "user", "=", "$", ...
Sets claroline default admin for cli because it's very annoying otherwise to do it manually everytime. @DI\Observe("console.command", priority = 17) @param GetResponseEvent $event
[ "Sets", "claroline", "default", "admin", "for", "cli", "because", "it", "s", "very", "annoying", "otherwise", "to", "do", "it", "manually", "everytime", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/CliListener.php#L55-L64
train
claroline/Distribution
plugin/collecticiel/Entity/ReturnReceiptType.php
ReturnReceiptType.addReturnreceipt
public function addReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts[] = $returnreceipt; return $this; }
php
public function addReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts[] = $returnreceipt; return $this; }
[ "public", "function", "addReturnreceipt", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ReturnReceipt", "$", "returnreceipt", ")", "{", "$", "this", "->", "returnreceipts", "[", "]", "=", "$", "returnreceipt", ";", "return", "$", "thi...
Add returnreceipt. @param \Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt @return ReturnReceiptType
[ "Add", "returnreceipt", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/ReturnReceiptType.php#L90-L95
train
claroline/Distribution
plugin/collecticiel/Entity/ReturnReceiptType.php
ReturnReceiptType.removeReturnreceipt
public function removeReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts->removeElement($returnreceipt); }
php
public function removeReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts->removeElement($returnreceipt); }
[ "public", "function", "removeReturnreceipt", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ReturnReceipt", "$", "returnreceipt", ")", "{", "$", "this", "->", "returnreceipts", "->", "removeElement", "(", "$", "returnreceipt", ")", ";", ...
Remove returnreceipt. @param \Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt
[ "Remove", "returnreceipt", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/ReturnReceiptType.php#L102-L105
train
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.getTranslatedContent
public function getTranslatedContent(array $filter) { $content = $this->getContent($filter); if ($content instanceof Content) { return $this->translations->findTranslations($content); } }
php
public function getTranslatedContent(array $filter) { $content = $this->getContent($filter); if ($content instanceof Content) { return $this->translations->findTranslations($content); } }
[ "public", "function", "getTranslatedContent", "(", "array", "$", "filter", ")", "{", "$", "content", "=", "$", "this", "->", "getContent", "(", "$", "filter", ")", ";", "if", "(", "$", "content", "instanceof", "Content", ")", "{", "return", "$", "this", ...
Get translated Content. Example: $contentManager->getTranslatedContent(array('id' => $id)); @param array $filter @return array
[ "Get", "translated", "Content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L93-L100
train
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.deleteTranslation
public function deleteTranslation($locale, $id) { if ('en' === $locale) { $content = $this->content->findOneBy(['id' => $id]); } else { $content = $this->translations->findOneBy(['foreignKey' => $id, 'locale' => $locale]); } if ($content instanceof ContentTranslation || $content instanceof Content) { $this->manager->remove($content); $this->manager->flush(); } }
php
public function deleteTranslation($locale, $id) { if ('en' === $locale) { $content = $this->content->findOneBy(['id' => $id]); } else { $content = $this->translations->findOneBy(['foreignKey' => $id, 'locale' => $locale]); } if ($content instanceof ContentTranslation || $content instanceof Content) { $this->manager->remove($content); $this->manager->flush(); } }
[ "public", "function", "deleteTranslation", "(", "$", "locale", ",", "$", "id", ")", "{", "if", "(", "'en'", "===", "$", "locale", ")", "{", "$", "content", "=", "$", "this", "->", "content", "->", "findOneBy", "(", "[", "'id'", "=>", "$", "id", "]"...
Delete a translation of content. @param string $locale @param $id
[ "Delete", "a", "translation", "of", "content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L148-L160
train
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.resetContent
private function resetContent(Content $content, array $translatedContents) { foreach ($translatedContents as $lang => $translatedContent) { $this->updateTranslation($content, $translatedContent, $lang, true); } $this->updateTranslation($content, $translatedContents['en']); return $content; }
php
private function resetContent(Content $content, array $translatedContents) { foreach ($translatedContents as $lang => $translatedContent) { $this->updateTranslation($content, $translatedContent, $lang, true); } $this->updateTranslation($content, $translatedContents['en']); return $content; }
[ "private", "function", "resetContent", "(", "Content", "$", "content", ",", "array", "$", "translatedContents", ")", "{", "foreach", "(", "$", "translatedContents", "as", "$", "lang", "=>", "$", "translatedContent", ")", "{", "$", "this", "->", "updateTranslat...
Reset translated values of a content. @param Content $content A content entity @param array $translatedContents array('en' => array('content' => 'foo', 'title' => 'foo')) @return \Claroline\CoreBundle\Entity\Content
[ "Reset", "translated", "values", "of", "a", "content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L170-L179
train
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.updateTranslation
private function updateTranslation(Content $content, $translation, $locale = 'en', $reset = false) { if (isset($translation['title'])) { $content->setTitle(($reset ? null : $translation['title'])); } if (isset($translation['content'])) { $content->setContent(($reset ? null : $translation['content'])); } $content->setTranslatableLocale($locale); $content->setModified(); $this->manager->persist($content); $this->manager->flush(); }
php
private function updateTranslation(Content $content, $translation, $locale = 'en', $reset = false) { if (isset($translation['title'])) { $content->setTitle(($reset ? null : $translation['title'])); } if (isset($translation['content'])) { $content->setContent(($reset ? null : $translation['content'])); } $content->setTranslatableLocale($locale); $content->setModified(); $this->manager->persist($content); $this->manager->flush(); }
[ "private", "function", "updateTranslation", "(", "Content", "$", "content", ",", "$", "translation", ",", "$", "locale", "=", "'en'", ",", "$", "reset", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "translation", "[", "'title'", "]", ")", ")",...
Update a content translation. @param Content $content A content entity @param array $translation array('content' => 'foo', 'title' => 'foo') @param string $locale A string with a locale value as 'en' or 'fr' @param bool $reset A boolean in case of you whant to reset the values of the translation
[ "Update", "a", "content", "translation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L189-L202
train
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.setDefault
private function setDefault(array $translatedContent, $field, $locale) { if ('en' !== $locale) { if (isset($translatedContent['en'][$field]) && !strlen($translatedContent['en'][$field]) && isset($translatedContent[$locale][$field]) && strlen($translatedContent[$locale][$field])) { $translatedContent['en'][$field] = $translatedContent[$locale][$field]; } } return $translatedContent; }
php
private function setDefault(array $translatedContent, $field, $locale) { if ('en' !== $locale) { if (isset($translatedContent['en'][$field]) && !strlen($translatedContent['en'][$field]) && isset($translatedContent[$locale][$field]) && strlen($translatedContent[$locale][$field])) { $translatedContent['en'][$field] = $translatedContent[$locale][$field]; } } return $translatedContent; }
[ "private", "function", "setDefault", "(", "array", "$", "translatedContent", ",", "$", "field", ",", "$", "locale", ")", "{", "if", "(", "'en'", "!==", "$", "locale", ")", "{", "if", "(", "isset", "(", "$", "translatedContent", "[", "'en'", "]", "[", ...
create_content in another language not longer create this content in the default language, so this function is used for this purpose. @param array $translatedContent array('en' => array('content' => 'foo', 'title' => 'foo')) @param string $field The name of a field as 'title' or 'content' @param string $locale A string with a locale value as 'en' or 'fr' @return array('en' => array('content' => 'foo', 'title' => 'foo'))
[ "create_content", "in", "another", "language", "not", "longer", "create", "this", "content", "in", "the", "default", "language", "so", "this", "function", "is", "used", "for", "this", "purpose", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L214-L224
train
claroline/Distribution
main/core/Controller/AdministrationController.php
AdministrationController.openToolAction
public function openToolAction($toolName) { $tool = $this->toolManager->getAdminToolByName($toolName); if (!$this->authorization->isGranted('OPEN', $tool)) { throw new AccessDeniedException(); } /** @var OpenAdministrationToolEvent $event */ $event = $this->eventDispatcher->dispatch( 'administration_tool_'.$toolName, 'OpenAdministrationTool', ['toolName' => $toolName] ); $this->eventDispatcher->dispatch( 'log', 'Log\LogAdminToolRead', ['toolName' => $toolName] ); return $event->getResponse(); }
php
public function openToolAction($toolName) { $tool = $this->toolManager->getAdminToolByName($toolName); if (!$this->authorization->isGranted('OPEN', $tool)) { throw new AccessDeniedException(); } /** @var OpenAdministrationToolEvent $event */ $event = $this->eventDispatcher->dispatch( 'administration_tool_'.$toolName, 'OpenAdministrationTool', ['toolName' => $toolName] ); $this->eventDispatcher->dispatch( 'log', 'Log\LogAdminToolRead', ['toolName' => $toolName] ); return $event->getResponse(); }
[ "public", "function", "openToolAction", "(", "$", "toolName", ")", "{", "$", "tool", "=", "$", "this", "->", "toolManager", "->", "getAdminToolByName", "(", "$", "toolName", ")", ";", "if", "(", "!", "$", "this", "->", "authorization", "->", "isGranted", ...
Opens an administration tool. @EXT\Route("/open/{toolName}", name="claro_admin_open_tool") @param $toolName @throws AccessDeniedException @return Response
[ "Opens", "an", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/AdministrationController.php#L103-L124
train
claroline/Distribution
plugin/favourite/Manager/FavouriteManager.php
FavouriteManager.createFavourite
public function createFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (empty($favourite)) { $favourite = new Favourite(); $favourite->setUser($user); $favourite->setResourceNode($resourceNode); $this->om->persist($favourite); $this->om->flush(); } }
php
public function createFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (empty($favourite)) { $favourite = new Favourite(); $favourite->setUser($user); $favourite->setResourceNode($resourceNode); $this->om->persist($favourite); $this->om->flush(); } }
[ "public", "function", "createFavourite", "(", "User", "$", "user", ",", "ResourceNode", "$", "resourceNode", ")", "{", "$", "favourite", "=", "$", "this", "->", "repo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "user", ",", "'resourceNode'", "=>", ...
Creates a favourite for given user and resource. @param User $user @param ResourceNode $resourceNode
[ "Creates", "a", "favourite", "for", "given", "user", "and", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/favourite/Manager/FavouriteManager.php#L95-L106
train
claroline/Distribution
plugin/favourite/Manager/FavouriteManager.php
FavouriteManager.deleteFavourite
public function deleteFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (!empty($favourite)) { $this->om->remove($favourite); $this->om->flush(); } }
php
public function deleteFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (!empty($favourite)) { $this->om->remove($favourite); $this->om->flush(); } }
[ "public", "function", "deleteFavourite", "(", "User", "$", "user", ",", "ResourceNode", "$", "resourceNode", ")", "{", "$", "favourite", "=", "$", "this", "->", "repo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "user", ",", "'resourceNode'", "=>", ...
Deletes favourite for given user and resource. @param User $user @param ResourceNode $resourceNode
[ "Deletes", "favourite", "for", "given", "user", "and", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/favourite/Manager/FavouriteManager.php#L114-L122
train
claroline/Distribution
plugin/announcement/Manager/AnnouncementManager.php
AnnouncementManager.sendMessage
public function sendMessage(Announcement $announcement, array $users = []) { $message = $this->getMessage($announcement, $users); $announcementSend = new AnnouncementSend(); $data = $message; $data['receivers'] = array_map(function (User $receiver) { return $receiver->getUsername(); }, $message['receivers']); $data['sender'] = $message['sender']->getUsername(); $announcementSend->setAnnouncement($announcement); $announcementSend->setData($data); $this->om->persist($announcementSend); $this->om->flush(); $this->eventDispatcher->dispatch( 'claroline_message_sending_to_users', 'SendMessage', [ $message['sender'], $message['content'], $message['object'], null, $message['receivers'], ] ); }
php
public function sendMessage(Announcement $announcement, array $users = []) { $message = $this->getMessage($announcement, $users); $announcementSend = new AnnouncementSend(); $data = $message; $data['receivers'] = array_map(function (User $receiver) { return $receiver->getUsername(); }, $message['receivers']); $data['sender'] = $message['sender']->getUsername(); $announcementSend->setAnnouncement($announcement); $announcementSend->setData($data); $this->om->persist($announcementSend); $this->om->flush(); $this->eventDispatcher->dispatch( 'claroline_message_sending_to_users', 'SendMessage', [ $message['sender'], $message['content'], $message['object'], null, $message['receivers'], ] ); }
[ "public", "function", "sendMessage", "(", "Announcement", "$", "announcement", ",", "array", "$", "users", "=", "[", "]", ")", "{", "$", "message", "=", "$", "this", "->", "getMessage", "(", "$", "announcement", ",", "$", "users", ")", ";", "$", "annou...
Sends an Announcement by message to Users that can access it. @param Announcement $announcement @param array $users
[ "Sends", "an", "Announcement", "by", "message", "to", "Users", "that", "can", "access", "it", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/announcement/Manager/AnnouncementManager.php#L145-L171
train
claroline/Distribution
plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php
AbstractScormManifest.dump
public function dump() { // Create a new XML document $document = new \DOMDocument('1.0', 'utf-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $document->loadXML($this->xml->asXML()); return $document->saveXML(); }
php
public function dump() { // Create a new XML document $document = new \DOMDocument('1.0', 'utf-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $document->loadXML($this->xml->asXML()); return $document->saveXML(); }
[ "public", "function", "dump", "(", ")", "{", "// Create a new XML document", "$", "document", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "document", "->", "preserveWhiteSpace", "=", "false", ";", "$", "document", "->", "for...
Dump manifest structure into a XML string. @return string
[ "Dump", "manifest", "structure", "into", "a", "XML", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php#L56-L65
train
claroline/Distribution
plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php
AbstractScormManifest.addMetadata
protected function addMetadata() { $metadata = $this->xml->addChild('metadata'); $metadata->addChild('schema', 'ADL SCORM'); $metadata->addChild('schemaversion', $this->getSchemaVersion()); return $metadata; }
php
protected function addMetadata() { $metadata = $this->xml->addChild('metadata'); $metadata->addChild('schema', 'ADL SCORM'); $metadata->addChild('schemaversion', $this->getSchemaVersion()); return $metadata; }
[ "protected", "function", "addMetadata", "(", ")", "{", "$", "metadata", "=", "$", "this", "->", "xml", "->", "addChild", "(", "'metadata'", ")", ";", "$", "metadata", "->", "addChild", "(", "'schema'", ",", "'ADL SCORM'", ")", ";", "$", "metadata", "->",...
Add metadata node to the manifest. @return \SimpleXMLElement
[ "Add", "metadata", "node", "to", "the", "manifest", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php#L72-L79
train
claroline/Distribution
plugin/video-player/Serializer/TrackSerializer.php
TrackSerializer.deserialize
public function deserialize($data, Track $track) { if (empty($track)) { $track = new Track(); } $track->setUuid($data['id']); $video = $this->fileRepo->findOneBy(['id' => $data['video']['id']]); $track->setVideo($video); $this->sipe('meta.label', 'setLabel', $data, $track); $this->sipe('meta.lang', 'setLang', $data, $track); $this->sipe('meta.kind', 'setKind', $data, $track); $this->sipe('meta.default', 'setIsDefault', $data, $track); if (isset($data['file'])) { $trackFile = $this->fileManager->create( new File(), $data['file'], $data['file']->getClientOriginalName(), $data['file']->getMimeType(), $video->getResourceNode()->getWorkspace() ); $this->om->persist($trackFile); $track->setTrackFile($trackFile); } return $track; }
php
public function deserialize($data, Track $track) { if (empty($track)) { $track = new Track(); } $track->setUuid($data['id']); $video = $this->fileRepo->findOneBy(['id' => $data['video']['id']]); $track->setVideo($video); $this->sipe('meta.label', 'setLabel', $data, $track); $this->sipe('meta.lang', 'setLang', $data, $track); $this->sipe('meta.kind', 'setKind', $data, $track); $this->sipe('meta.default', 'setIsDefault', $data, $track); if (isset($data['file'])) { $trackFile = $this->fileManager->create( new File(), $data['file'], $data['file']->getClientOriginalName(), $data['file']->getMimeType(), $video->getResourceNode()->getWorkspace() ); $this->om->persist($trackFile); $track->setTrackFile($trackFile); } return $track; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "Track", "$", "track", ")", "{", "if", "(", "empty", "(", "$", "track", ")", ")", "{", "$", "track", "=", "new", "Track", "(", ")", ";", "}", "$", "track", "->", "setUuid", "(", "$", "...
Deserializes data into a Track entity. @param \stdClass $data @param Track $track @return Track
[ "Deserializes", "data", "into", "a", "Track", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/video-player/Serializer/TrackSerializer.php#L95-L121
train
claroline/Distribution
main/core/Twig/HomeExtension.php
HomeExtension.autoLink
public function autoLink($text) { $rexProtocol = '(https?://)?'; $rexDomain = '((?:[-a-zA-Z0-9]{1,63}\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})'; $rexPort = '(:[0-9]{1,5})?'; $rexPath = '(/[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]*?)?'; $rexQuery = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $text = preg_replace_callback( "&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&", function ($match) { // Prepend http:// if no protocol specified $completeUrl = $match[1] ? $match[0] : "http://{$match[0]}"; return '<a href="'.$completeUrl.'" target="_blank">' .$match[2].$match[3].$match[4].'</a>'; }, htmlspecialchars($text) ); return $text; }
php
public function autoLink($text) { $rexProtocol = '(https?://)?'; $rexDomain = '((?:[-a-zA-Z0-9]{1,63}\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})'; $rexPort = '(:[0-9]{1,5})?'; $rexPath = '(/[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]*?)?'; $rexQuery = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $text = preg_replace_callback( "&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&", function ($match) { // Prepend http:// if no protocol specified $completeUrl = $match[1] ? $match[0] : "http://{$match[0]}"; return '<a href="'.$completeUrl.'" target="_blank">' .$match[2].$match[3].$match[4].'</a>'; }, htmlspecialchars($text) ); return $text; }
[ "public", "function", "autoLink", "(", "$", "text", ")", "{", "$", "rexProtocol", "=", "'(https?://)?'", ";", "$", "rexDomain", "=", "'((?:[-a-zA-Z0-9]{1,63}\\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\\.){3}[0-9]{1,3})'", ";", "$", "rexPort", "=", "'(:[0-9]{1,5})?'", ";", "$"...
Find links in a text and made it clickable.
[ "Find", "links", "in", "a", "text", "and", "made", "it", "clickable", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Twig/HomeExtension.php#L201-L223
train
claroline/Distribution
main/app/JVal/Context.php
Context.getCurrentPath
public function getCurrentPath() { $this->pathSegments = array_slice($this->pathSegments, 0, $this->pathLength); return $this->pathLength ? '/'.implode('/', $this->pathSegments) : ''; }
php
public function getCurrentPath() { $this->pathSegments = array_slice($this->pathSegments, 0, $this->pathLength); return $this->pathLength ? '/'.implode('/', $this->pathSegments) : ''; }
[ "public", "function", "getCurrentPath", "(", ")", "{", "$", "this", "->", "pathSegments", "=", "array_slice", "(", "$", "this", "->", "pathSegments", ",", "0", ",", "$", "this", "->", "pathLength", ")", ";", "return", "$", "this", "->", "pathLength", "?"...
Returns the path of the current node. @return string
[ "Returns", "the", "path", "of", "the", "current", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/JVal/Context.php#L75-L80
train
claroline/Distribution
plugin/dropzone/Repository/DropRepository.php
DropRepository.isUnlockedDrop
public function isUnlockedDrop($dropzoneId, $userId) { $qb = $this->createQueryBuilder('drop') ->select('drop.unlockedUser') ->andWhere('drop.dropzone = :dropzone') ->andWhere('drop.user = :user') ->setParameter('dropzone', $dropzoneId) ->setParameter('user', $userId); $isUnlockedDrop = $qb->getQuery()->getOneOrNullResult(); return $isUnlockedDrop; }
php
public function isUnlockedDrop($dropzoneId, $userId) { $qb = $this->createQueryBuilder('drop') ->select('drop.unlockedUser') ->andWhere('drop.dropzone = :dropzone') ->andWhere('drop.user = :user') ->setParameter('dropzone', $dropzoneId) ->setParameter('user', $userId); $isUnlockedDrop = $qb->getQuery()->getOneOrNullResult(); return $isUnlockedDrop; }
[ "public", "function", "isUnlockedDrop", "(", "$", "dropzoneId", ",", "$", "userId", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'drop'", ")", "->", "select", "(", "'drop.unlockedUser'", ")", "->", "andWhere", "(", "'drop.dropzone...
Return if user was unlocked ( no need to make the required corrections todo Why not in a user super class ? @param $dropzoneId @param $userId @return array
[ "Return", "if", "user", "was", "unlocked", "(", "no", "need", "to", "make", "the", "required", "corrections", "todo", "Why", "not", "in", "a", "user", "super", "class", "?" ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Repository/DropRepository.php#L82-L93
train
claroline/Distribution
plugin/dropzone/Repository/DropRepository.php
DropRepository.closeUnTerminatedDropsByDropzone
public function closeUnTerminatedDropsByDropzone($dropzoneId) { $qb = $this->createQueryBuilder('drop') ->update('Icap\\DropzoneBundle\\Entity\\Drop', 'd') ->set('d.autoClosedDrop', 1) ->set('d.finished', 1) ->andWhere('d.dropzone = :dropzoneId') ->andWhere('d.finished = 0') ->setParameter('dropzoneId', $dropzoneId); $qb->getQuery()->execute(); }
php
public function closeUnTerminatedDropsByDropzone($dropzoneId) { $qb = $this->createQueryBuilder('drop') ->update('Icap\\DropzoneBundle\\Entity\\Drop', 'd') ->set('d.autoClosedDrop', 1) ->set('d.finished', 1) ->andWhere('d.dropzone = :dropzoneId') ->andWhere('d.finished = 0') ->setParameter('dropzoneId', $dropzoneId); $qb->getQuery()->execute(); }
[ "public", "function", "closeUnTerminatedDropsByDropzone", "(", "$", "dropzoneId", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'drop'", ")", "->", "update", "(", "'Icap\\\\DropzoneBundle\\\\Entity\\\\Drop'", ",", "'d'", ")", "->", "set"...
Close unclosed drops in a dropzone. @param $dropzoneId
[ "Close", "unclosed", "drops", "in", "a", "dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Repository/DropRepository.php#L417-L427
train
claroline/Distribution
plugin/exo/Controller/Api/Item/ShareController.php
ShareController.shareAction
public function shareAction(Request $request, User $user) { $errors = []; $data = $this->decodeRequestData($request); if (empty($data)) { $errors[] = [ 'path' => '', 'message' => 'Invalid JSON data.', ]; } else { try { $this->shareManager->share($data, $user); } catch (InvalidDataException $e) { $errors = $e->getErrors(); } } if (!empty($errors)) { return new JsonResponse($errors, 422); } else { return new JsonResponse(null, 201); } }
php
public function shareAction(Request $request, User $user) { $errors = []; $data = $this->decodeRequestData($request); if (empty($data)) { $errors[] = [ 'path' => '', 'message' => 'Invalid JSON data.', ]; } else { try { $this->shareManager->share($data, $user); } catch (InvalidDataException $e) { $errors = $e->getErrors(); } } if (!empty($errors)) { return new JsonResponse($errors, 422); } else { return new JsonResponse(null, 201); } }
[ "public", "function", "shareAction", "(", "Request", "$", "request", ",", "User", "$", "user", ")", "{", "$", "errors", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "decodeRequestData", "(", "$", "request", ")", ";", "if", "(", "empty", ...
Shares a list of questions to users. @EXT\Route("", name="questions_share") @EXT\Method("POST") @EXT\ParamConverter("user", converter="current_user") @param Request $request @param User $user @return JsonResponse
[ "Shares", "a", "list", "of", "questions", "to", "users", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/Item/ShareController.php#L74-L97
train
claroline/Distribution
plugin/exo/Controller/Api/Item/ShareController.php
ShareController.searchUsers
public function searchUsers($search) { $users = $this->userRepository->findByName($search); return new JsonResponse(array_map(function (User $user) { return $this->userSerializer->serialize($user); }, $users)); }
php
public function searchUsers($search) { $users = $this->userRepository->findByName($search); return new JsonResponse(array_map(function (User $user) { return $this->userSerializer->serialize($user); }, $users)); }
[ "public", "function", "searchUsers", "(", "$", "search", ")", "{", "$", "users", "=", "$", "this", "->", "userRepository", "->", "findByName", "(", "$", "search", ")", ";", "return", "new", "JsonResponse", "(", "array_map", "(", "function", "(", "User", ...
Searches users by username, first or last name. @EXT\Route("/{search}", name="questions_share_users") @EXT\Method("GET") @param string $search @return JsonResponse
[ "Searches", "users", "by", "username", "first", "or", "last", "name", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/Item/ShareController.php#L133-L140
train
claroline/Distribution
plugin/web-resource/Installation/Updater/Updater120000.php
Updater120000.updateWebResourceFilePath
private function updateWebResourceFilePath() { $this->log('Update resourceWeb file path ...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $resourceType = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceType')->findOneBy(['name' => 'claroline_web_resource']); $resourceNodes = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceNode')->findBy(['resourceType' => $resourceType]); $resourceManager = $this->container->get('claroline.manager.resource_manager'); $fs = $this->container->get('filesystem'); foreach ($resourceNodes as $resourceNode) { $file = $resourceManager->getResourceFromNode($resourceNode); $workspace = $resourceNode->getWorkspace(); if (!empty($file)) { $hash = $file->getHashName(); $uploadDir = $this->container->getParameter('claroline.param.uploads_directory'); $filesDir = $this->container->getParameter('claroline.param.files_directory'); if ($fs->exists($filesDir.DIRECTORY_SEPARATOR.$hash)) { $fs->copy($filesDir.DIRECTORY_SEPARATOR.$hash, $filesDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($filesDir.DIRECTORY_SEPARATOR.$hash); } if ($fs->exists($uploadDir.DIRECTORY_SEPARATOR.$hash)) { $fs->mirror($uploadDir.DIRECTORY_SEPARATOR.$hash, $uploadDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($uploadDir.DIRECTORY_SEPARATOR.$hash); } } } }
php
private function updateWebResourceFilePath() { $this->log('Update resourceWeb file path ...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $resourceType = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceType')->findOneBy(['name' => 'claroline_web_resource']); $resourceNodes = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceNode')->findBy(['resourceType' => $resourceType]); $resourceManager = $this->container->get('claroline.manager.resource_manager'); $fs = $this->container->get('filesystem'); foreach ($resourceNodes as $resourceNode) { $file = $resourceManager->getResourceFromNode($resourceNode); $workspace = $resourceNode->getWorkspace(); if (!empty($file)) { $hash = $file->getHashName(); $uploadDir = $this->container->getParameter('claroline.param.uploads_directory'); $filesDir = $this->container->getParameter('claroline.param.files_directory'); if ($fs->exists($filesDir.DIRECTORY_SEPARATOR.$hash)) { $fs->copy($filesDir.DIRECTORY_SEPARATOR.$hash, $filesDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($filesDir.DIRECTORY_SEPARATOR.$hash); } if ($fs->exists($uploadDir.DIRECTORY_SEPARATOR.$hash)) { $fs->mirror($uploadDir.DIRECTORY_SEPARATOR.$hash, $uploadDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($uploadDir.DIRECTORY_SEPARATOR.$hash); } } } }
[ "private", "function", "updateWebResourceFilePath", "(", ")", "{", "$", "this", "->", "log", "(", "'Update resourceWeb file path ...'", ")", ";", "/** @var ObjectManager $om */", "$", "om", "=", "$", "this", "->", "container", "->", "get", "(", "'claroline.persisten...
Update file path.
[ "Update", "file", "path", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/web-resource/Installation/Updater/Updater120000.php#L27-L58
train
claroline/Distribution
main/core/Controller/APINew/Tool/Workspace/LogController.php
LogController.getWorkspaceFilteredQuery
private function getWorkspaceFilteredQuery(Request $request, Workspace $workspace) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['workspace' => $workspace]); return $query; }
php
private function getWorkspaceFilteredQuery(Request $request, Workspace $workspace) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['workspace' => $workspace]); return $query; }
[ "private", "function", "getWorkspaceFilteredQuery", "(", "Request", "$", "request", ",", "Workspace", "$", "workspace", ")", "{", "$", "query", "=", "$", "request", "->", "query", "->", "all", "(", ")", ";", "$", "hiddenFilters", "=", "isset", "(", "$", ...
Add workspace filter to request. @param Request $request @param Workspace $workspace @return array
[ "Add", "workspace", "filter", "to", "request", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Tool/Workspace/LogController.php#L237-L244
train
claroline/Distribution
plugin/exo/Entity/ItemType/GraphicQuestion.php
GraphicQuestion.addArea
public function addArea(Area $area) { if (!$this->areas->contains($area)) { $this->areas->add($area); $area->setInteractionGraphic($this); } }
php
public function addArea(Area $area) { if (!$this->areas->contains($area)) { $this->areas->add($area); $area->setInteractionGraphic($this); } }
[ "public", "function", "addArea", "(", "Area", "$", "area", ")", "{", "if", "(", "!", "$", "this", "->", "areas", "->", "contains", "(", "$", "area", ")", ")", "{", "$", "this", "->", "areas", "->", "add", "(", "$", "area", ")", ";", "$", "area"...
Adds an area. @param Area $area
[ "Adds", "an", "area", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/GraphicQuestion.php#L88-L94
train
claroline/Distribution
plugin/exo/Entity/ItemType/GraphicQuestion.php
GraphicQuestion.removeArea
public function removeArea(Area $area) { if ($this->areas->contains($area)) { $this->areas->removeElement($area); } }
php
public function removeArea(Area $area) { if ($this->areas->contains($area)) { $this->areas->removeElement($area); } }
[ "public", "function", "removeArea", "(", "Area", "$", "area", ")", "{", "if", "(", "$", "this", "->", "areas", "->", "contains", "(", "$", "area", ")", ")", "{", "$", "this", "->", "areas", "->", "removeElement", "(", "$", "area", ")", ";", "}", ...
Removes an area. @param Area $area
[ "Removes", "an", "area", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/GraphicQuestion.php#L101-L106
train
claroline/Distribution
plugin/claco-form/Serializer/FieldValueSerializer.php
FieldValueSerializer.serialize
public function serialize(FieldValue $fieldValue, array $options = []) { $serialized = [ 'id' => $fieldValue->getUuid(), ]; if (in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'field' => [ 'id' => $fieldValue->getField()->getUuid(), ], 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } else { $serialized = array_merge($serialized, [ 'field' => $this->fieldSerializer->serialize($fieldValue->getField(), [Options::SERIALIZE_MINIMAL]), 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } return $serialized; }
php
public function serialize(FieldValue $fieldValue, array $options = []) { $serialized = [ 'id' => $fieldValue->getUuid(), ]; if (in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'field' => [ 'id' => $fieldValue->getField()->getUuid(), ], 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } else { $serialized = array_merge($serialized, [ 'field' => $this->fieldSerializer->serialize($fieldValue->getField(), [Options::SERIALIZE_MINIMAL]), 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } return $serialized; }
[ "public", "function", "serialize", "(", "FieldValue", "$", "fieldValue", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "fieldValue", "->", "getUuid", "(", ")", ",", "]", ";", "if", "(", "in_arr...
Serializes a FieldValue entity for the JSON api. @param FieldValue $fieldValue - the field value to serialize @param array $options - a list of serialization options @return array - the serialized representation of the field value
[ "Serializes", "a", "FieldValue", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Serializer/FieldValueSerializer.php#L49-L70
train
claroline/Distribution
main/core/Controller/APINew/Model/HasGroupsTrait.php
HasGroupsTrait.addGroupsAction
public function addGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_ADD, $groups); return new JsonResponse( $this->serializer->serialize($object) ); }
php
public function addGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_ADD, $groups); return new JsonResponse( $this->serializer->serialize($object) ); }
[ "public", "function", "addGroupsAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "groups", "=", "$", "this", "->...
Adds groups to the collection. @EXT\Route("/{id}/group") @EXT\Method("PATCH") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Adds", "groups", "to", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasGroupsTrait.php#L49-L58
train
claroline/Distribution
main/core/Controller/APINew/Model/HasGroupsTrait.php
HasGroupsTrait.removeGroupsAction
public function removeGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_REMOVE, $groups); return new JsonResponse($this->serializer->serialize($object)); }
php
public function removeGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_REMOVE, $groups); return new JsonResponse($this->serializer->serialize($object)); }
[ "public", "function", "removeGroupsAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "groups", "=", "$", "this", ...
Removes groups from the collection. @EXT\Route("/{id}/group") @EXT\Method("DELETE") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Removes", "groups", "from", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasGroupsTrait.php#L72-L79
train
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.addDocument
public function addDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents[] = $documents; return $this; }
php
public function addDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents[] = $documents; return $this; }
[ "public", "function", "addDocument", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Document", "$", "documents", ")", "{", "$", "this", "->", "documents", "[", "]", "=", "$", "documents", ";", "return", "$", "this", ";", "}" ]
Add documents. @param \Innova\CollecticielBundle\Entity\Document $documents @return Drop
[ "Add", "documents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L434-L439
train
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.removeDocument
public function removeDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents->removeElement($documents); }
php
public function removeDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents->removeElement($documents); }
[ "public", "function", "removeDocument", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Document", "$", "documents", ")", "{", "$", "this", "->", "documents", "->", "removeElement", "(", "$", "documents", ")", ";", "}" ]
Remove documents. @param \Innova\CollecticielBundle\Entity\Document $documents
[ "Remove", "documents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L446-L449
train
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.addCorrection
public function addCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections[] = $corrections; return $this; }
php
public function addCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections[] = $corrections; return $this; }
[ "public", "function", "addCorrection", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Correction", "$", "corrections", ")", "{", "$", "this", "->", "corrections", "[", "]", "=", "$", "corrections", ";", "return", "$", "this", ";", ...
Add corrections. @param \Innova\CollecticielBundle\Entity\Correction $corrections @return Drop
[ "Add", "corrections", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L458-L463
train
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.removeCorrection
public function removeCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections->removeElement($corrections); }
php
public function removeCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections->removeElement($corrections); }
[ "public", "function", "removeCorrection", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Correction", "$", "corrections", ")", "{", "$", "this", "->", "corrections", "->", "removeElement", "(", "$", "corrections", ")", ";", "}" ]
Remove corrections. @param \Innova\CollecticielBundle\Entity\Correction $corrections
[ "Remove", "corrections", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L470-L473
train
claroline/Distribution
plugin/path/Installation/Updater/Updater120000.php
Updater120000.initializeResourceEvaluationProgression
private function initializeResourceEvaluationProgression() { $this->log('Initializing progression of path evaluations...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $paths = $om->getRepository('Innova\PathBundle\Entity\Path\Path')->findAll(); $om->startFlushSuite(); $i = 0; foreach ($paths as $path) { $node = $path->getResourceNode(); $userEvals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceUserEvaluation') ->findBy(['resourceNode' => $node]); foreach ($userEvals as $userEval) { $userEvalScore = $userEval->getScore(); $userEvalScoreMax = $userEval->getScoreMax(); if (is_null($userEval->getProgression()) && !is_null($userEvalScore) && !empty($userEvalScoreMax)) { $progression = intval(($userEvalScore / $userEvalScoreMax) * 100); $userEval->setProgression($progression); $om->persist($userEval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } $evals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceEvaluation') ->findBy(['resourceUserEvaluation' => $userEval]); foreach ($evals as $eval) { $evalScore = $eval->getScore(); $evalScoreMax = $eval->getScoreMax(); if (is_null($eval->getProgression()) && !is_null($evalScore) && !empty($evalScoreMax)) { $progression = intval(($evalScore / $evalScoreMax) * 100); $eval->setProgression($progression); $om->persist($eval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } } } } $om->endFlushSuite(); }
php
private function initializeResourceEvaluationProgression() { $this->log('Initializing progression of path evaluations...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $paths = $om->getRepository('Innova\PathBundle\Entity\Path\Path')->findAll(); $om->startFlushSuite(); $i = 0; foreach ($paths as $path) { $node = $path->getResourceNode(); $userEvals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceUserEvaluation') ->findBy(['resourceNode' => $node]); foreach ($userEvals as $userEval) { $userEvalScore = $userEval->getScore(); $userEvalScoreMax = $userEval->getScoreMax(); if (is_null($userEval->getProgression()) && !is_null($userEvalScore) && !empty($userEvalScoreMax)) { $progression = intval(($userEvalScore / $userEvalScoreMax) * 100); $userEval->setProgression($progression); $om->persist($userEval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } $evals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceEvaluation') ->findBy(['resourceUserEvaluation' => $userEval]); foreach ($evals as $eval) { $evalScore = $eval->getScore(); $evalScoreMax = $eval->getScoreMax(); if (is_null($eval->getProgression()) && !is_null($evalScore) && !empty($evalScoreMax)) { $progression = intval(($evalScore / $evalScoreMax) * 100); $eval->setProgression($progression); $om->persist($eval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } } } } $om->endFlushSuite(); }
[ "private", "function", "initializeResourceEvaluationProgression", "(", ")", "{", "$", "this", "->", "log", "(", "'Initializing progression of path evaluations...'", ")", ";", "/** @var ObjectManager $om */", "$", "om", "=", "$", "this", "->", "container", "->", "get", ...
Initializes progression of path evaluation.
[ "Initializes", "progression", "of", "path", "evaluation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Installation/Updater/Updater120000.php#L33-L85
train
claroline/Distribution
main/core/Form/Handler/FormHandler.php
FormHandler.isValid
public function isValid($formReference, Request $request, $data = null, array $options = []) { $form = $this->getForm($formReference, $data, $options); $form->handleRequest($request); return $form->isValid(); }
php
public function isValid($formReference, Request $request, $data = null, array $options = []) { $form = $this->getForm($formReference, $data, $options); $form->handleRequest($request); return $form->isValid(); }
[ "public", "function", "isValid", "(", "$", "formReference", ",", "Request", "$", "request", ",", "$", "data", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "form", "=", "$", "this", "->", "getForm", "(", "$", "formReference...
Returns whether a form is valid and stores it internally for future use. @param string $formReference The form type name @param Request $request The request to be bound @param mixed $data An entity or array to be bound @param array $options The options to be passed to the form builder @return bool
[ "Returns", "whether", "a", "form", "is", "valid", "and", "stores", "it", "internally", "for", "future", "use", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Form/Handler/FormHandler.php#L42-L48
train
claroline/Distribution
main/core/Form/Handler/FormHandler.php
FormHandler.getView
public function getView($formReference = null, $data = null, array $options = []) { if ($formReference) { $this->getForm($formReference, $data, $options); } return $this->getCurrentForm()->createView(); }
php
public function getView($formReference = null, $data = null, array $options = []) { if ($formReference) { $this->getForm($formReference, $data, $options); } return $this->getCurrentForm()->createView(); }
[ "public", "function", "getView", "(", "$", "formReference", "=", "null", ",", "$", "data", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "formReference", ")", "{", "$", "this", "->", "getForm", "(", "$", "formR...
Creates and returns a form view either from the current form or from a new form type reference passed as argument. @param string $formReference The form type name @param mixed $data An entity or array to be bound @param array $options The options to be passed to the form builder @return mixed @throws \LogicException if no reference is passed and no form has been handled yet
[ "Creates", "and", "returns", "a", "form", "view", "either", "from", "the", "current", "form", "or", "from", "a", "new", "form", "type", "reference", "passed", "as", "argument", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Form/Handler/FormHandler.php#L75-L82
train
claroline/Distribution
plugin/forum/Listener/Resource/ForumListener.php
ForumListener.onOpen
public function onOpen(LoadResourceEvent $event) { $forum = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isValidatedUser = false; if ('anon.' !== $user) { $validationUser = $this->manager->getValidationUser($user, $forum); $isValidatedUser = $validationUser->getAccess(); } $event->setData([ 'forum' => $this->serializer->serialize($forum), 'isValidatedUser' => $isValidatedUser, ]); $event->stopPropagation(); }
php
public function onOpen(LoadResourceEvent $event) { $forum = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isValidatedUser = false; if ('anon.' !== $user) { $validationUser = $this->manager->getValidationUser($user, $forum); $isValidatedUser = $validationUser->getAccess(); } $event->setData([ 'forum' => $this->serializer->serialize($forum), 'isValidatedUser' => $isValidatedUser, ]); $event->stopPropagation(); }
[ "public", "function", "onOpen", "(", "LoadResourceEvent", "$", "event", ")", "{", "$", "forum", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "("...
Loads a Forum resource. @DI\Observe("resource.claroline_forum.load") @param LoadResourceEvent $event
[ "Loads", "a", "Forum", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/forum/Listener/Resource/ForumListener.php#L95-L112
train
claroline/Distribution
main/authentication/Listener/Cas/ApiListener.php
ApiListener.onSerialize
public function onSerialize(DecorateUserEvent $event) { $casUserId = $this->casManager->getCasUserIdByUserId($event->getUser()->getId()); $event->add('cas_data', [ 'id' => $casUserId, ]); }
php
public function onSerialize(DecorateUserEvent $event) { $casUserId = $this->casManager->getCasUserIdByUserId($event->getUser()->getId()); $event->add('cas_data', [ 'id' => $casUserId, ]); }
[ "public", "function", "onSerialize", "(", "DecorateUserEvent", "$", "event", ")", "{", "$", "casUserId", "=", "$", "this", "->", "casManager", "->", "getCasUserIdByUserId", "(", "$", "event", "->", "getUser", "(", ")", "->", "getId", "(", ")", ")", ";", ...
Add CAS ID to serialized user. @param DecorateUserEvent $event @DI\Observe("serialize_user")
[ "Add", "CAS", "ID", "to", "serialized", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/authentication/Listener/Cas/ApiListener.php#L39-L46
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.showAction
public function showAction($id, User $currentUser = null) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // TODO : not pretty, but might want on some case to download files instead ? // TODO : find a way to do it in the link plugin if ('shortcut' === $resourceNode->getResourceType()->getName()) { $shortcut = $this->manager->getResourceFromNode($resourceNode); $resourceNode = $shortcut->getTarget(); } // do a minimal security check to redirect user which are not authenticated if needed. if (empty($currentUser) && 0 >= $this->rightsRepo->findMaximumRights([], $resourceNode)) { // user is not authenticated and the current node is not opened to anonymous throw new AccessDeniedException(); } return [ 'resourceNode' => $resourceNode, ]; }
php
public function showAction($id, User $currentUser = null) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // TODO : not pretty, but might want on some case to download files instead ? // TODO : find a way to do it in the link plugin if ('shortcut' === $resourceNode->getResourceType()->getName()) { $shortcut = $this->manager->getResourceFromNode($resourceNode); $resourceNode = $shortcut->getTarget(); } // do a minimal security check to redirect user which are not authenticated if needed. if (empty($currentUser) && 0 >= $this->rightsRepo->findMaximumRights([], $resourceNode)) { // user is not authenticated and the current node is not opened to anonymous throw new AccessDeniedException(); } return [ 'resourceNode' => $resourceNode, ]; }
[ "public", "function", "showAction", "(", "$", "id", ",", "User", "$", "currentUser", "=", "null", ")", "{", "/** @var ResourceNode $resourceNode */", "$", "resourceNode", "=", "$", "this", "->", "om", "->", "find", "(", "ResourceNode", "::", "class", ",", "$...
Renders a resource application. @EXT\Route("/show/{id}", name="claro_resource_show_short") @EXT\Route("/show/{type}/{id}", name="claro_resource_show") @EXT\Method("GET") @EXT\ParamConverter("currentUser", converter="current_user", options={"allowAnonymous"=true}) @EXT\Template() @param int|string $id - the id of the target node (we don't use ParamConverter to support ID and UUID) @param User $currentUser @return array @throws ResourceNotFoundException
[ "Renders", "a", "resource", "application", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L142-L166
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.embedAction
public function embedAction(ResourceNode $resourceNode) { $mimeType = explode('/', $resourceNode->getMimeType()); $view = 'default'; if ($mimeType[0] && in_array($mimeType[0], ['video', 'audio', 'image'])) { $view = $mimeType[0]; } return new Response( $this->templating->render("ClarolineCoreBundle:resource:embed/{$view}.html.twig", [ 'resource' => $this->manager->getResourceFromNode($resourceNode), ]) ); }
php
public function embedAction(ResourceNode $resourceNode) { $mimeType = explode('/', $resourceNode->getMimeType()); $view = 'default'; if ($mimeType[0] && in_array($mimeType[0], ['video', 'audio', 'image'])) { $view = $mimeType[0]; } return new Response( $this->templating->render("ClarolineCoreBundle:resource:embed/{$view}.html.twig", [ 'resource' => $this->manager->getResourceFromNode($resourceNode), ]) ); }
[ "public", "function", "embedAction", "(", "ResourceNode", "$", "resourceNode", ")", "{", "$", "mimeType", "=", "explode", "(", "'/'", ",", "$", "resourceNode", "->", "getMimeType", "(", ")", ")", ";", "$", "view", "=", "'default'", ";", "if", "(", "$", ...
Embeds a resource inside a rich text content. @EXT\Route("/embed/{id}", name="claro_resource_embed_short") @EXT\Route("/embed/{type}/{id}", name="claro_resource_embed") @param ResourceNode $resourceNode @return Response
[ "Embeds", "a", "resource", "inside", "a", "rich", "text", "content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L178-L192
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.downloadAction
public function downloadAction($forceArchive = false, Request $request) { $ids = $request->query->get('ids'); $nodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $collection = new ResourceCollection($nodes); if (!$this->authorization->isGranted('EXPORT', $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } $data = $this->manager->download($nodes, $forceArchive); $file = $data['file'] ?: tempnam('tmp', 'tmp'); $fileName = $data['name']; if (!file_exists($file)) { return new JsonResponse(['file_not_found'], 500); } $fileName = null === $fileName ? $response->getFile()->getFilename() : $fileName; $fileName = str_replace('/', '_', $fileName); $fileName = str_replace('\\', '_', $fileName); $response = new BinaryFileResponse($file, 200, ['Content-Disposition' => "attachment; filename={$fileName}"]); return $response; }
php
public function downloadAction($forceArchive = false, Request $request) { $ids = $request->query->get('ids'); $nodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $collection = new ResourceCollection($nodes); if (!$this->authorization->isGranted('EXPORT', $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } $data = $this->manager->download($nodes, $forceArchive); $file = $data['file'] ?: tempnam('tmp', 'tmp'); $fileName = $data['name']; if (!file_exists($file)) { return new JsonResponse(['file_not_found'], 500); } $fileName = null === $fileName ? $response->getFile()->getFilename() : $fileName; $fileName = str_replace('/', '_', $fileName); $fileName = str_replace('\\', '_', $fileName); $response = new BinaryFileResponse($file, 200, ['Content-Disposition' => "attachment; filename={$fileName}"]); return $response; }
[ "public", "function", "downloadAction", "(", "$", "forceArchive", "=", "false", ",", "Request", "$", "request", ")", "{", "$", "ids", "=", "$", "request", "->", "query", "->", "get", "(", "'ids'", ")", ";", "$", "nodes", "=", "$", "this", "->", "om",...
Downloads a list of Resources. @EXT\Route( "/download", name="claro_resource_download", defaults ={"forceArchive"=false} ) @EXT\Route( "/download/{forceArchive}", name="claro_resource_download", requirements={"forceArchive" = "^(true|false|0|1)$"}, ) @param bool $forceArchive @param Request $request @return Response
[ "Downloads", "a", "list", "of", "Resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L213-L240
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.unlockAction
public function unlockAction(ResourceNode $resourceNode, Request $request) { $this->restrictionsManager->unlock($resourceNode, json_decode($request->getContent(), true)['code']); return new JsonResponse(null, 204); }
php
public function unlockAction(ResourceNode $resourceNode, Request $request) { $this->restrictionsManager->unlock($resourceNode, json_decode($request->getContent(), true)['code']); return new JsonResponse(null, 204); }
[ "public", "function", "unlockAction", "(", "ResourceNode", "$", "resourceNode", ",", "Request", "$", "request", ")", "{", "$", "this", "->", "restrictionsManager", "->", "unlock", "(", "$", "resourceNode", ",", "json_decode", "(", "$", "request", "->", "getCon...
Submit access code. @EXT\Route("/unlock/{id}", name="claro_resource_unlock") @EXT\Method("POST") @EXT\ParamConverter("resourceNode", class="ClarolineCoreBundle:Resource\ResourceNode", options={"mapping": {"id": "uuid"}}) @param ResourceNode $resourceNode @param Request $request @return JsonResponse
[ "Submit", "access", "code", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L254-L259
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.executeCollectionAction
public function executeCollectionAction($action, Request $request) { $ids = $request->query->get('ids'); /** @var ResourceNode[] $resourceNodes */ $resourceNodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $responses = []; // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); $this->om->startFlushSuite(); foreach ($resourceNodes as $resourceNode) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // dispatch action event $responses[] = $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); } $this->om->endFlushSuite(); return new JsonResponse(array_map(function (Response $response) { return json_decode($response->getContent(), true); }, $responses)); }
php
public function executeCollectionAction($action, Request $request) { $ids = $request->query->get('ids'); /** @var ResourceNode[] $resourceNodes */ $resourceNodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $responses = []; // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); $this->om->startFlushSuite(); foreach ($resourceNodes as $resourceNode) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // dispatch action event $responses[] = $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); } $this->om->endFlushSuite(); return new JsonResponse(array_map(function (Response $response) { return json_decode($response->getContent(), true); }, $responses)); }
[ "public", "function", "executeCollectionAction", "(", "$", "action", ",", "Request", "$", "request", ")", "{", "$", "ids", "=", "$", "request", "->", "query", "->", "get", "(", "'ids'", ")", ";", "/** @var ResourceNode[] $resourceNodes */", "$", "resourceNodes",...
Executes an action on a collection of resources. @EXT\Route("/collection/{action}", name="claro_resource_collection_action") @param string $action @param Request $request @return JsonResponse @throws NotFoundHttpException
[ "Executes", "an", "action", "on", "a", "collection", "of", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L273-L313
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.getAction
public function getAction($id, $embedded = 0) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // gets the current user roles to check access restrictions $userRoles = $this->security->getRoles($this->tokenStorage->getToken()); $accessErrors = $this->restrictionsManager->getErrors($resourceNode, $userRoles); if (empty($accessErrors) || $this->manager->isManager($resourceNode)) { try { $loaded = $this->manager->load($resourceNode, intval($embedded) ? true : false); } catch (ResourceNotFoundException $e) { return new JsonResponse(['resource_not_found'], 500); } return new JsonResponse( array_merge([ // append access restrictions to the loaded node // if any to let know the manager that other user can not enter the resource 'accessErrors' => $accessErrors, ], $loaded) ); } return new JsonResponse($accessErrors, 403); }
php
public function getAction($id, $embedded = 0) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // gets the current user roles to check access restrictions $userRoles = $this->security->getRoles($this->tokenStorage->getToken()); $accessErrors = $this->restrictionsManager->getErrors($resourceNode, $userRoles); if (empty($accessErrors) || $this->manager->isManager($resourceNode)) { try { $loaded = $this->manager->load($resourceNode, intval($embedded) ? true : false); } catch (ResourceNotFoundException $e) { return new JsonResponse(['resource_not_found'], 500); } return new JsonResponse( array_merge([ // append access restrictions to the loaded node // if any to let know the manager that other user can not enter the resource 'accessErrors' => $accessErrors, ], $loaded) ); } return new JsonResponse($accessErrors, 403); }
[ "public", "function", "getAction", "(", "$", "id", ",", "$", "embedded", "=", "0", ")", "{", "/** @var ResourceNode $resourceNode */", "$", "resourceNode", "=", "$", "this", "->", "om", "->", "find", "(", "ResourceNode", "::", "class", ",", "$", "id", ")",...
Gets a resource. @EXT\Route("/{id}", name="claro_resource_load_short") @EXT\Route("/{type}/{id}", name="claro_resource_load") @EXT\Route("/{type}/{id}/embedded/{embedded}", name="claro_resource_load_embedded") @EXT\Method("GET") @param int|string $id - the id of the target node (we don't use ParamConverter to support ID and UUID) @param int $embedded @return JsonResponse @throws ResourceNotFoundException
[ "Gets", "a", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L330-L359
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.executeAction
public function executeAction($action, ResourceNode $resourceNode, Request $request) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); // dispatch action event return $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); }
php
public function executeAction($action, ResourceNode $resourceNode, Request $request) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); // dispatch action event return $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); }
[ "public", "function", "executeAction", "(", "$", "action", ",", "ResourceNode", "$", "resourceNode", ",", "Request", "$", "request", ")", "{", "// check the requested action exists", "if", "(", "!", "$", "this", "->", "actionManager", "->", "support", "(", "$", ...
Executes an action on one resource. @EXT\Route("/{action}/{id}", name="claro_resource_action_short") @EXT\Route("/{type}/{action}/{id}", name="claro_resource_action") @param string $action @param ResourceNode $resourceNode @param Request $request @return Response @throws NotFoundHttpException
[ "Executes", "an", "action", "on", "one", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L375-L400
train
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.checkAccess
private function checkAccess(MenuAction $action, array $resourceNodes, array $attributes = []) { $collection = new ResourceCollection($resourceNodes); $collection->setAttributes($attributes); if (!$this->actionManager->hasPermission($action, $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } }
php
private function checkAccess(MenuAction $action, array $resourceNodes, array $attributes = []) { $collection = new ResourceCollection($resourceNodes); $collection->setAttributes($attributes); if (!$this->actionManager->hasPermission($action, $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } }
[ "private", "function", "checkAccess", "(", "MenuAction", "$", "action", ",", "array", "$", "resourceNodes", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "collection", "=", "new", "ResourceCollection", "(", "$", "resourceNodes", ")", ";", ...
Checks the current user can execute the action on the requested nodes. @param MenuAction $action @param array $resourceNodes @param array $attributes
[ "Checks", "the", "current", "user", "can", "execute", "the", "action", "on", "the", "requested", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L409-L417
train
claroline/Distribution
plugin/link/Listener/Resource/Types/ShortcutListener.php
ShortcutListener.load
public function load(LoadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->load($shortcut->getTarget()); }
php
public function load(LoadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->load($shortcut->getTarget()); }
[ "public", "function", "load", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var Shortcut $shortcut */", "$", "shortcut", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "this", "->", "resourceLifecycle", "->", "load", "(", "$", "shortcut"...
Loads a shortcut. It forwards the event to the target of the shortcut. @DI\Observe("resource.shortcut.load") @param LoadResourceEvent $event
[ "Loads", "a", "shortcut", ".", "It", "forwards", "the", "event", "to", "the", "target", "of", "the", "shortcut", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Listener/Resource/Types/ShortcutListener.php#L55-L61
train
claroline/Distribution
plugin/link/Listener/Resource/Types/ShortcutListener.php
ShortcutListener.open
public function open(OpenResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->open($shortcut->getTarget()); }
php
public function open(OpenResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->open($shortcut->getTarget()); }
[ "public", "function", "open", "(", "OpenResourceEvent", "$", "event", ")", "{", "/** @var Shortcut $shortcut */", "$", "shortcut", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "this", "->", "resourceLifecycle", "->", "open", "(", "$", "shortcut"...
Opens a shortcut. It forwards the event to the target of the shortcut. @DI\Observe("resource.shortcut.open") @param OpenResourceEvent $event
[ "Opens", "a", "shortcut", ".", "It", "forwards", "the", "event", "to", "the", "target", "of", "the", "shortcut", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Listener/Resource/Types/ShortcutListener.php#L71-L77
train
claroline/Distribution
plugin/link/Listener/Resource/Types/ShortcutListener.php
ShortcutListener.export
public function export(DownloadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->export($shortcut->getTarget()); }
php
public function export(DownloadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->export($shortcut->getTarget()); }
[ "public", "function", "export", "(", "DownloadResourceEvent", "$", "event", ")", "{", "/** @var Shortcut $shortcut */", "$", "shortcut", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "this", "->", "resourceLifecycle", "->", "export", "(", "$", "s...
Exports a shortcut. It forwards the event to the target of the shortcut. @DI\Observe("resource.shortcut.export") @param DownloadResourceEvent $event
[ "Exports", "a", "shortcut", ".", "It", "forwards", "the", "event", "to", "the", "target", "of", "the", "shortcut", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Listener/Resource/Types/ShortcutListener.php#L87-L93
train
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.addAssociation
public function addAssociation(Association $association) { if (!$this->associations->contains($association)) { $this->associations->add($association); $association->setQuestion($this); } }
php
public function addAssociation(Association $association) { if (!$this->associations->contains($association)) { $this->associations->add($association); $association->setQuestion($this); } }
[ "public", "function", "addAssociation", "(", "Association", "$", "association", ")", "{", "if", "(", "!", "$", "this", "->", "associations", "->", "contains", "(", "$", "association", ")", ")", "{", "$", "this", "->", "associations", "->", "add", "(", "$...
Adds an association. @param Association $association
[ "Adds", "an", "association", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L91-L97
train
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.removeAssociation
public function removeAssociation(Association $association) { if ($this->associations->contains($association)) { $this->associations->removeElement($association); } }
php
public function removeAssociation(Association $association) { if ($this->associations->contains($association)) { $this->associations->removeElement($association); } }
[ "public", "function", "removeAssociation", "(", "Association", "$", "association", ")", "{", "if", "(", "$", "this", "->", "associations", "->", "contains", "(", "$", "association", ")", ")", "{", "$", "this", "->", "associations", "->", "removeElement", "("...
Removes an association. @param Association $association
[ "Removes", "an", "association", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L104-L109
train
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.addLabel
public function addLabel(Label $label) { if (!$this->labels->contains($label)) { $this->labels->add($label); $label->setInteractionMatching($this); } }
php
public function addLabel(Label $label) { if (!$this->labels->contains($label)) { $this->labels->add($label); $label->setInteractionMatching($this); } }
[ "public", "function", "addLabel", "(", "Label", "$", "label", ")", "{", "if", "(", "!", "$", "this", "->", "labels", "->", "contains", "(", "$", "label", ")", ")", "{", "$", "this", "->", "labels", "->", "add", "(", "$", "label", ")", ";", "$", ...
Adds a label. @param Label $label
[ "Adds", "a", "label", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L126-L132
train
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.removeLabel
public function removeLabel(Label $label) { if ($this->labels->contains($label)) { $this->labels->removeElement($label); } }
php
public function removeLabel(Label $label) { if ($this->labels->contains($label)) { $this->labels->removeElement($label); } }
[ "public", "function", "removeLabel", "(", "Label", "$", "label", ")", "{", "if", "(", "$", "this", "->", "labels", "->", "contains", "(", "$", "label", ")", ")", "{", "$", "this", "->", "labels", "->", "removeElement", "(", "$", "label", ")", ";", ...
Removes a label. @param Label $label
[ "Removes", "a", "label", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L139-L144
train
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.addProposal
public function addProposal(Proposal $proposal) { if (!$this->proposals->contains($proposal)) { $this->proposals->add($proposal); $proposal->setInteractionMatching($this); } }
php
public function addProposal(Proposal $proposal) { if (!$this->proposals->contains($proposal)) { $this->proposals->add($proposal); $proposal->setInteractionMatching($this); } }
[ "public", "function", "addProposal", "(", "Proposal", "$", "proposal", ")", "{", "if", "(", "!", "$", "this", "->", "proposals", "->", "contains", "(", "$", "proposal", ")", ")", "{", "$", "this", "->", "proposals", "->", "add", "(", "$", "proposal", ...
Adds a proposal. @param Proposal $proposal
[ "Adds", "a", "proposal", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L161-L167
train
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.removeProposal
public function removeProposal(Proposal $proposal) { if ($this->proposals->contains($proposal)) { $this->proposals->removeElement($proposal); } }
php
public function removeProposal(Proposal $proposal) { if ($this->proposals->contains($proposal)) { $this->proposals->removeElement($proposal); } }
[ "public", "function", "removeProposal", "(", "Proposal", "$", "proposal", ")", "{", "if", "(", "$", "this", "->", "proposals", "->", "contains", "(", "$", "proposal", ")", ")", "{", "$", "this", "->", "proposals", "->", "removeElement", "(", "$", "propos...
Removes a proposal. @param Proposal $proposal
[ "Removes", "a", "proposal", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L174-L179
train
claroline/Distribution
main/core/Library/Normalizer/DateRangeNormalizer.php
DateRangeNormalizer.normalize
public static function normalize(\DateTime $startDate = null, \DateTime $endDate = null) { if (!empty($startDate) || !empty($endDate)) { return [ DateNormalizer::normalize($startDate), DateNormalizer::normalize($endDate), ]; } return []; }
php
public static function normalize(\DateTime $startDate = null, \DateTime $endDate = null) { if (!empty($startDate) || !empty($endDate)) { return [ DateNormalizer::normalize($startDate), DateNormalizer::normalize($endDate), ]; } return []; }
[ "public", "static", "function", "normalize", "(", "\\", "DateTime", "$", "startDate", "=", "null", ",", "\\", "DateTime", "$", "endDate", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "startDate", ")", "||", "!", "empty", "(", "$", "endDa...
Normalizes two DateTimes to an array of date strings. @param \DateTime|null $startDate @param \DateTime|null $endDate @return array
[ "Normalizes", "two", "DateTimes", "to", "an", "array", "of", "date", "strings", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Normalizer/DateRangeNormalizer.php#L23-L33
train
claroline/Distribution
main/core/Library/Normalizer/DateRangeNormalizer.php
DateRangeNormalizer.denormalize
public static function denormalize($dateRange = []) { if (!empty($dateRange)) { return [ DateNormalizer::denormalize($dateRange[0]), DateNormalizer::denormalize($dateRange[1]), ]; } return [null, null]; }
php
public static function denormalize($dateRange = []) { if (!empty($dateRange)) { return [ DateNormalizer::denormalize($dateRange[0]), DateNormalizer::denormalize($dateRange[1]), ]; } return [null, null]; }
[ "public", "static", "function", "denormalize", "(", "$", "dateRange", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "dateRange", ")", ")", "{", "return", "[", "DateNormalizer", "::", "denormalize", "(", "$", "dateRange", "[", "0", "]", ...
Denormalizes an array of date strings into DateTime objects. @param array $dateRange @return array
[ "Denormalizes", "an", "array", "of", "date", "strings", "into", "DateTime", "objects", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Normalizer/DateRangeNormalizer.php#L42-L52
train
claroline/Distribution
plugin/collecticiel/Entity/CommentRead.php
CommentRead.setComment
public function setComment(\Innova\CollecticielBundle\Entity\Comment $comment) { $this->comment = $comment; return $this; }
php
public function setComment(\Innova\CollecticielBundle\Entity\Comment $comment) { $this->comment = $comment; return $this; }
[ "public", "function", "setComment", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Comment", "$", "comment", ")", "{", "$", "this", "->", "comment", "=", "$", "comment", ";", "return", "$", "this", ";", "}" ]
Set comment. @param \Innova\CollecticielBundle\Entity\Comment $comment @return CommentRead
[ "Set", "comment", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/CommentRead.php#L168-L173
train
claroline/Distribution
main/core/Entity/Home/Content2Type.php
Content2Type.detach
public function detach() { if ($this->getBack()) { $this->getBack()->setNext($this->getNext()); } if ($this->getNext()) { $this->getNext()->setBack($this->getBack()); } }
php
public function detach() { if ($this->getBack()) { $this->getBack()->setNext($this->getNext()); } if ($this->getNext()) { $this->getNext()->setBack($this->getBack()); } }
[ "public", "function", "detach", "(", ")", "{", "if", "(", "$", "this", "->", "getBack", "(", ")", ")", "{", "$", "this", "->", "getBack", "(", ")", "->", "setNext", "(", "$", "this", "->", "getNext", "(", ")", ")", ";", "}", "if", "(", "$", "...
Detach a content from a type, this function can be used for reorder or delete contents.
[ "Detach", "a", "content", "from", "a", "type", "this", "function", "can", "be", "used", "for", "reorder", "or", "delete", "contents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Home/Content2Type.php#L239-L248
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.serialize
public function serialize(Paper $paper, array $options = []) { // Adds user score if available and the method options do not already request it if (!in_array(Transfer::INCLUDE_USER_SCORE, $options) && $this->isScoreAvailable($paper->getExercise(), $paper)) { $options[] = Transfer::INCLUDE_USER_SCORE; } return $this->serializer->serialize($paper, $options); }
php
public function serialize(Paper $paper, array $options = []) { // Adds user score if available and the method options do not already request it if (!in_array(Transfer::INCLUDE_USER_SCORE, $options) && $this->isScoreAvailable($paper->getExercise(), $paper)) { $options[] = Transfer::INCLUDE_USER_SCORE; } return $this->serializer->serialize($paper, $options); }
[ "public", "function", "serialize", "(", "Paper", "$", "paper", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// Adds user score if available and the method options do not already request it", "if", "(", "!", "in_array", "(", "Transfer", "::", "INCLUDE_USER_S...
Serializes a user paper. @param Paper $paper @param array $options @return array
[ "Serializes", "a", "user", "paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L92-L101
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.checkPaperEvaluated
public function checkPaperEvaluated(Paper $paper) { $fullyEvaluated = $this->repository->isFullyEvaluated($paper); if ($fullyEvaluated) { $event = new LogExerciseEvaluatedEvent($paper->getExercise(), [ 'result' => $paper->getScore(), 'resultMax' => $this->calculateTotal($paper), ]); $this->eventDispatcher->dispatch('log', $event); } return $fullyEvaluated; }
php
public function checkPaperEvaluated(Paper $paper) { $fullyEvaluated = $this->repository->isFullyEvaluated($paper); if ($fullyEvaluated) { $event = new LogExerciseEvaluatedEvent($paper->getExercise(), [ 'result' => $paper->getScore(), 'resultMax' => $this->calculateTotal($paper), ]); $this->eventDispatcher->dispatch('log', $event); } return $fullyEvaluated; }
[ "public", "function", "checkPaperEvaluated", "(", "Paper", "$", "paper", ")", "{", "$", "fullyEvaluated", "=", "$", "this", "->", "repository", "->", "isFullyEvaluated", "(", "$", "paper", ")", ";", "if", "(", "$", "fullyEvaluated", ")", "{", "$", "event",...
Check if a Paper is full evaluated and dispatch a Log event if yes. @param Paper $paper @return bool
[ "Check", "if", "a", "Paper", "is", "full", "evaluated", "and", "dispatch", "a", "Log", "event", "if", "yes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L110-L123
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.calculateScore
public function calculateScore(Paper $paper, $base = null) { $score = $this->repository->findScore($paper); if (!empty($base) && $base > 0) { $scoreTotal = $this->calculateTotal($paper); if ($scoreTotal && $scoreTotal !== $base) { $score = ($score / $scoreTotal) * $base; } } return $score; }
php
public function calculateScore(Paper $paper, $base = null) { $score = $this->repository->findScore($paper); if (!empty($base) && $base > 0) { $scoreTotal = $this->calculateTotal($paper); if ($scoreTotal && $scoreTotal !== $base) { $score = ($score / $scoreTotal) * $base; } } return $score; }
[ "public", "function", "calculateScore", "(", "Paper", "$", "paper", ",", "$", "base", "=", "null", ")", "{", "$", "score", "=", "$", "this", "->", "repository", "->", "findScore", "(", "$", "paper", ")", ";", "if", "(", "!", "empty", "(", "$", "bas...
Calculates the score of a Paper. @param Paper $paper @param float $base @return float
[ "Calculates", "the", "score", "of", "a", "Paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L133-L144
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.calculateTotal
public function calculateTotal(Paper $paper) { $total = 0; $structure = json_decode($paper->getStructure(), true); foreach ($structure['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { $total += $this->itemManager->calculateTotal($item); } } } return $total; }
php
public function calculateTotal(Paper $paper) { $total = 0; $structure = json_decode($paper->getStructure(), true); foreach ($structure['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { $total += $this->itemManager->calculateTotal($item); } } } return $total; }
[ "public", "function", "calculateTotal", "(", "Paper", "$", "paper", ")", "{", "$", "total", "=", "0", ";", "$", "structure", "=", "json_decode", "(", "$", "paper", "->", "getStructure", "(", ")", ",", "true", ")", ";", "foreach", "(", "$", "structure",...
Calculates the total score of a Paper. @param Paper $paper @return float
[ "Calculates", "the", "total", "score", "of", "a", "Paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L153-L168
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.serializeExercisePapers
public function serializeExercisePapers(Exercise $exercise, User $user = null) { if (!empty($user)) { // Load papers for of a single user $papers = $this->repository->findBy([ 'exercise' => $exercise, 'user' => $user, ]); } else { // Load all papers submitted for the exercise $papers = $this->repository->findBy([ 'exercise' => $exercise, ]); } return array_map(function (Paper $paper) { return $this->serialize($paper); }, $papers); }
php
public function serializeExercisePapers(Exercise $exercise, User $user = null) { if (!empty($user)) { // Load papers for of a single user $papers = $this->repository->findBy([ 'exercise' => $exercise, 'user' => $user, ]); } else { // Load all papers submitted for the exercise $papers = $this->repository->findBy([ 'exercise' => $exercise, ]); } return array_map(function (Paper $paper) { return $this->serialize($paper); }, $papers); }
[ "public", "function", "serializeExercisePapers", "(", "Exercise", "$", "exercise", ",", "User", "$", "user", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "user", ")", ")", "{", "// Load papers for of a single user", "$", "papers", "=", "$", "t...
Returns the papers for a given exercise, in a JSON format. @param Exercise $exercise @param User $user @return array
[ "Returns", "the", "papers", "for", "a", "given", "exercise", "in", "a", "JSON", "format", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L178-L196
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.delete
public function delete(Paper $paper) { $this->om->remove($paper); $this->om->flush(); }
php
public function delete(Paper $paper) { $this->om->remove($paper); $this->om->flush(); }
[ "public", "function", "delete", "(", "Paper", "$", "paper", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "paper", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Deletes a paper. @param Paper $paper
[ "Deletes", "a", "paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L221-L225
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.countUserFinishedPapers
public function countUserFinishedPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedPapers($exercise, $user); }
php
public function countUserFinishedPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedPapers($exercise, $user); }
[ "public", "function", "countUserFinishedPapers", "(", "Exercise", "$", "exercise", ",", "User", "$", "user", ")", "{", "return", "$", "this", "->", "repository", "->", "countUserFinishedPapers", "(", "$", "exercise", ",", "$", "user", ")", ";", "}" ]
Returns the number of finished papers already done by the user for a given exercise. @param Exercise $exercise @param User $user @return array
[ "Returns", "the", "number", "of", "finished", "papers", "already", "done", "by", "the", "user", "for", "a", "given", "exercise", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L235-L238
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.countUserFinishedDayPapers
public function countUserFinishedDayPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedDayPapers($exercise, $user); }
php
public function countUserFinishedDayPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedDayPapers($exercise, $user); }
[ "public", "function", "countUserFinishedDayPapers", "(", "Exercise", "$", "exercise", ",", "User", "$", "user", ")", "{", "return", "$", "this", "->", "repository", "->", "countUserFinishedDayPapers", "(", "$", "exercise", ",", "$", "user", ")", ";", "}" ]
Returns the number of finished papers already done by the user for a given exercise for the current day. @param Exercise $exercise @param User $user @return array
[ "Returns", "the", "number", "of", "finished", "papers", "already", "done", "by", "the", "user", "for", "a", "given", "exercise", "for", "the", "current", "day", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L248-L251
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.isSolutionAvailable
public function isSolutionAvailable(Exercise $exercise, Paper $paper) { $correctionMode = $exercise->getCorrectionMode(); switch ($correctionMode) { case ShowCorrectionAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowCorrectionAt::AFTER_LAST_ATTEMPT: $available = 0 === $exercise->getMaxAttempts() || $paper->getNumber() === $exercise->getMaxAttempts(); break; case ShowCorrectionAt::AFTER_DATE: $now = new \DateTime(); $available = empty($exercise->getDateCorrection()) || $now >= $exercise->getDateCorrection(); break; case ShowCorrectionAt::NEVER: default: $available = false; break; } return $available; }
php
public function isSolutionAvailable(Exercise $exercise, Paper $paper) { $correctionMode = $exercise->getCorrectionMode(); switch ($correctionMode) { case ShowCorrectionAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowCorrectionAt::AFTER_LAST_ATTEMPT: $available = 0 === $exercise->getMaxAttempts() || $paper->getNumber() === $exercise->getMaxAttempts(); break; case ShowCorrectionAt::AFTER_DATE: $now = new \DateTime(); $available = empty($exercise->getDateCorrection()) || $now >= $exercise->getDateCorrection(); break; case ShowCorrectionAt::NEVER: default: $available = false; break; } return $available; }
[ "public", "function", "isSolutionAvailable", "(", "Exercise", "$", "exercise", ",", "Paper", "$", "paper", ")", "{", "$", "correctionMode", "=", "$", "exercise", "->", "getCorrectionMode", "(", ")", ";", "switch", "(", "$", "correctionMode", ")", "{", "case"...
Check if the solution of the Paper is available to User. @param Exercise $exercise @param Paper $paper @return bool
[ "Check", "if", "the", "solution", "of", "the", "Paper", "is", "available", "to", "User", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L297-L321
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.isScoreAvailable
public function isScoreAvailable(Exercise $exercise, Paper $paper) { $markMode = $exercise->getMarkMode(); switch ($markMode) { case ShowScoreAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowScoreAt::NEVER: $available = false; break; case ShowScoreAt::WITH_CORRECTION: default: $available = $this->isSolutionAvailable($exercise, $paper); break; } return $available; }
php
public function isScoreAvailable(Exercise $exercise, Paper $paper) { $markMode = $exercise->getMarkMode(); switch ($markMode) { case ShowScoreAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowScoreAt::NEVER: $available = false; break; case ShowScoreAt::WITH_CORRECTION: default: $available = $this->isSolutionAvailable($exercise, $paper); break; } return $available; }
[ "public", "function", "isScoreAvailable", "(", "Exercise", "$", "exercise", ",", "Paper", "$", "paper", ")", "{", "$", "markMode", "=", "$", "exercise", "->", "getMarkMode", "(", ")", ";", "switch", "(", "$", "markMode", ")", "{", "case", "ShowScoreAt", ...
Check if the score of the Paper is available to User. @param Exercise $exercise @param Paper $paper @return bool
[ "Check", "if", "the", "score", "of", "the", "Paper", "is", "available", "to", "User", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L331-L348
train
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.generateResourceEvaluation
public function generateResourceEvaluation(Paper $paper, $finished) { $totalScoreOn = $paper->getExercise()->getTotalScoreOn(); $total = $totalScoreOn ? $totalScoreOn : $this->calculateTotal($paper); $score = $this->calculateScore($paper, $total); $successScore = $paper->getExercise()->getSuccessScore(); $data = [ 'paper' => [ 'id' => $paper->getId(), 'uuid' => $paper->getUuid(), ], ]; if ($finished) { if (is_null($successScore)) { $status = AbstractResourceEvaluation::STATUS_COMPLETED; } else { $percentScore = 100 === $totalScoreOn ? $score : $this->calculateScore($paper, 100); $status = $percentScore >= $successScore ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; } } else { $status = AbstractResourceEvaluation::STATUS_INCOMPLETE; } $nbQuestions = 0; $structure = json_decode($paper->getStructure(), true); if (isset($structure['steps'])) { foreach ($structure['steps'] as $step) { $nbQuestions += count($step['items']); // TODO : remove content items } } $nbAnswers = 0; foreach ($paper->getAnswers() as $answer) { if (!is_null($answer->getData())) { ++$nbAnswers; } } return $this->resourceEvalManager->createResourceEvaluation( $paper->getExercise()->getResourceNode(), $paper->getUser(), null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $total, 'progression' => $nbQuestions > 0 ? floor(($nbAnswers / $nbQuestions) * 100) : null, 'data' => $data, ] ); }
php
public function generateResourceEvaluation(Paper $paper, $finished) { $totalScoreOn = $paper->getExercise()->getTotalScoreOn(); $total = $totalScoreOn ? $totalScoreOn : $this->calculateTotal($paper); $score = $this->calculateScore($paper, $total); $successScore = $paper->getExercise()->getSuccessScore(); $data = [ 'paper' => [ 'id' => $paper->getId(), 'uuid' => $paper->getUuid(), ], ]; if ($finished) { if (is_null($successScore)) { $status = AbstractResourceEvaluation::STATUS_COMPLETED; } else { $percentScore = 100 === $totalScoreOn ? $score : $this->calculateScore($paper, 100); $status = $percentScore >= $successScore ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; } } else { $status = AbstractResourceEvaluation::STATUS_INCOMPLETE; } $nbQuestions = 0; $structure = json_decode($paper->getStructure(), true); if (isset($structure['steps'])) { foreach ($structure['steps'] as $step) { $nbQuestions += count($step['items']); // TODO : remove content items } } $nbAnswers = 0; foreach ($paper->getAnswers() as $answer) { if (!is_null($answer->getData())) { ++$nbAnswers; } } return $this->resourceEvalManager->createResourceEvaluation( $paper->getExercise()->getResourceNode(), $paper->getUser(), null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $total, 'progression' => $nbQuestions > 0 ? floor(($nbAnswers / $nbQuestions) * 100) : null, 'data' => $data, ] ); }
[ "public", "function", "generateResourceEvaluation", "(", "Paper", "$", "paper", ",", "$", "finished", ")", "{", "$", "totalScoreOn", "=", "$", "paper", "->", "getExercise", "(", ")", "->", "getTotalScoreOn", "(", ")", ";", "$", "total", "=", "$", "totalSco...
Creates a ResourceEvaluation for the attempt. @param Paper $paper @param bool $finished @return ResourceEvaluation
[ "Creates", "a", "ResourceEvaluation", "for", "the", "attempt", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L358-L411
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php
ChoiceQuestionSerializer.serialize
public function serialize(ChoiceQuestion $choiceQuestion, array $options = []) { $serialized = [ 'random' => $choiceQuestion->getShuffle(), 'multiple' => $choiceQuestion->isMultiple(), 'numbering' => $choiceQuestion->getNumbering(), 'direction' => $choiceQuestion->getDirection(), ]; // Serializes choices $choices = $this->serializeChoices($choiceQuestion, $options); if ($choiceQuestion->getShuffle() && in_array(Transfer::SHUFFLE_ANSWERS, $options)) { shuffle($choices); } $serialized['choices'] = $choices; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($choiceQuestion); } return $serialized; }
php
public function serialize(ChoiceQuestion $choiceQuestion, array $options = []) { $serialized = [ 'random' => $choiceQuestion->getShuffle(), 'multiple' => $choiceQuestion->isMultiple(), 'numbering' => $choiceQuestion->getNumbering(), 'direction' => $choiceQuestion->getDirection(), ]; // Serializes choices $choices = $this->serializeChoices($choiceQuestion, $options); if ($choiceQuestion->getShuffle() && in_array(Transfer::SHUFFLE_ANSWERS, $options)) { shuffle($choices); } $serialized['choices'] = $choices; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($choiceQuestion); } return $serialized; }
[ "public", "function", "serialize", "(", "ChoiceQuestion", "$", "choiceQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'random'", "=>", "$", "choiceQuestion", "->", "getShuffle", "(", ")", ",", "'multiple'", "...
Converts a Choice question into a JSON-encodable structure. @param ChoiceQuestion $choiceQuestion @param array $options @return array
[ "Converts", "a", "Choice", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php#L47-L70
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php
ChoiceQuestionSerializer.deserialize
public function deserialize($data, ChoiceQuestion $choiceQuestion = null, array $options = []) { if (empty($choiceQuestion)) { $choiceQuestion = new ChoiceQuestion(); } $this->sipe('multiple', 'setMultiple', $data, $choiceQuestion); $this->sipe('random', 'setShuffle', $data, $choiceQuestion); $this->sipe('numbering', 'setNumbering', $data, $choiceQuestion); $this->deserializeChoices($choiceQuestion, $data['choices'], $data['solutions'], $options); return $choiceQuestion; }
php
public function deserialize($data, ChoiceQuestion $choiceQuestion = null, array $options = []) { if (empty($choiceQuestion)) { $choiceQuestion = new ChoiceQuestion(); } $this->sipe('multiple', 'setMultiple', $data, $choiceQuestion); $this->sipe('random', 'setShuffle', $data, $choiceQuestion); $this->sipe('numbering', 'setNumbering', $data, $choiceQuestion); $this->deserializeChoices($choiceQuestion, $data['choices'], $data['solutions'], $options); return $choiceQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "ChoiceQuestion", "$", "choiceQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "choiceQuestion", ")", ")", "{", "$", "choiceQuestion",...
Converts raw data into a Choice question entity. @param array $data @param ChoiceQuestion $choiceQuestion @param array $options @return ChoiceQuestion
[ "Converts", "raw", "data", "into", "a", "Choice", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php#L81-L94
train
claroline/Distribution
main/core/Repository/ResourceNodeRepository.php
ResourceNodeRepository.findDescendants
public function findDescendants( ResourceNode $resource, $includeStartNode = false, $filterResourceType = null ) { $this->builder->selectAsEntity(true) ->wherePathLike($resource->getPath(), $includeStartNode); if ($filterResourceType) { $this->builder->whereTypeIn([$filterResourceType]); } $query = $this->_em->createQuery($this->builder->getDql()); $query->setParameters($this->builder->getParameters()); return $this->executeQuery($query, null, null, false); }
php
public function findDescendants( ResourceNode $resource, $includeStartNode = false, $filterResourceType = null ) { $this->builder->selectAsEntity(true) ->wherePathLike($resource->getPath(), $includeStartNode); if ($filterResourceType) { $this->builder->whereTypeIn([$filterResourceType]); } $query = $this->_em->createQuery($this->builder->getDql()); $query->setParameters($this->builder->getParameters()); return $this->executeQuery($query, null, null, false); }
[ "public", "function", "findDescendants", "(", "ResourceNode", "$", "resource", ",", "$", "includeStartNode", "=", "false", ",", "$", "filterResourceType", "=", "null", ")", "{", "$", "this", "->", "builder", "->", "selectAsEntity", "(", "true", ")", "->", "w...
Returns the descendants of a resource. @param ResourceNode $resource The resource node to start with @param bool $includeStartNode Whether the given resource should be included in the result @param string $filterResourceType A resource type to filter the results @return array[ResourceNode]
[ "Returns", "the", "descendants", "of", "a", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceNodeRepository.php#L89-L105
train
claroline/Distribution
main/core/Repository/ResourceNodeRepository.php
ResourceNodeRepository.executeQuery
private function executeQuery($query, $offset = null, $numrows = null, $asArray = true) { $query->setFirstResult($offset); $query->setMaxResults($numrows); if ($asArray) { $resources = $query->getArrayResult(); $return = $resources; // Add a field "pathfordisplay" in each entity (as array) of the given array. foreach ($resources as $key => $resource) { if (isset($resource['path'])) { $return[$key]['path_for_display'] = ResourceNode::convertPathForDisplay($resource['path']); } } return $return; } return $query->getResult(); }
php
private function executeQuery($query, $offset = null, $numrows = null, $asArray = true) { $query->setFirstResult($offset); $query->setMaxResults($numrows); if ($asArray) { $resources = $query->getArrayResult(); $return = $resources; // Add a field "pathfordisplay" in each entity (as array) of the given array. foreach ($resources as $key => $resource) { if (isset($resource['path'])) { $return[$key]['path_for_display'] = ResourceNode::convertPathForDisplay($resource['path']); } } return $return; } return $query->getResult(); }
[ "private", "function", "executeQuery", "(", "$", "query", ",", "$", "offset", "=", "null", ",", "$", "numrows", "=", "null", ",", "$", "asArray", "=", "true", ")", "{", "$", "query", "->", "setFirstResult", "(", "$", "offset", ")", ";", "$", "query",...
Executes a DQL query and returns resources as entities or arrays. If it returns arrays, it add a "pathfordisplay" field to each item. @param Query $query The query to execute @param int $offset First row to start with @param int $numrows Maximum number of rows to return @param bool $asArray Whether the resources must be returned as arrays or as objects @return array[AbstractResource|array]
[ "Executes", "a", "DQL", "query", "and", "returns", "resources", "as", "entities", "or", "arrays", ".", "If", "it", "returns", "arrays", "it", "add", "a", "pathfordisplay", "field", "to", "each", "item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceNodeRepository.php#L306-L325
train
claroline/Distribution
main/core/API/Serializer/Resource/Types/DirectorySerializer.php
DirectorySerializer.serialize
public function serialize(Directory $directory): array { return [ 'id' => $directory->getId(), 'uploadDestination' => $directory->isUploadDestination(), 'display' => [ 'showSummary' => $directory->getShowSummary(), 'openSummary' => $directory->getOpenSummary(), ], // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer 'list' => [ 'actions' => $directory->hasActions(), 'count' => $directory->hasCount(), // display feature 'display' => $directory->getDisplay(), 'availableDisplays' => $directory->getAvailableDisplays(), // sort feature 'sorting' => $directory->getSortBy(), 'availableSort' => $directory->getAvailableSort(), // filter feature 'searchMode' => $directory->getSearchMode(), 'filters' => $directory->getFilters(), 'availableFilters' => $directory->getAvailableFilters(), // pagination feature 'paginated' => $directory->isPaginated(), 'pageSize' => $directory->getPageSize(), 'availablePageSizes' => $directory->getAvailablePageSizes(), // table config 'columns' => $directory->getDisplayedColumns(), 'availableColumns' => $directory->getAvailableColumns(), // grid config 'card' => [ 'display' => $directory->getCard(), 'mapping' => [], // TODO ], ], ]; }
php
public function serialize(Directory $directory): array { return [ 'id' => $directory->getId(), 'uploadDestination' => $directory->isUploadDestination(), 'display' => [ 'showSummary' => $directory->getShowSummary(), 'openSummary' => $directory->getOpenSummary(), ], // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer 'list' => [ 'actions' => $directory->hasActions(), 'count' => $directory->hasCount(), // display feature 'display' => $directory->getDisplay(), 'availableDisplays' => $directory->getAvailableDisplays(), // sort feature 'sorting' => $directory->getSortBy(), 'availableSort' => $directory->getAvailableSort(), // filter feature 'searchMode' => $directory->getSearchMode(), 'filters' => $directory->getFilters(), 'availableFilters' => $directory->getAvailableFilters(), // pagination feature 'paginated' => $directory->isPaginated(), 'pageSize' => $directory->getPageSize(), 'availablePageSizes' => $directory->getAvailablePageSizes(), // table config 'columns' => $directory->getDisplayedColumns(), 'availableColumns' => $directory->getAvailableColumns(), // grid config 'card' => [ 'display' => $directory->getCard(), 'mapping' => [], // TODO ], ], ]; }
[ "public", "function", "serialize", "(", "Directory", "$", "directory", ")", ":", "array", "{", "return", "[", "'id'", "=>", "$", "directory", "->", "getId", "(", ")", ",", "'uploadDestination'", "=>", "$", "directory", "->", "isUploadDestination", "(", ")", ...
Serializes a Directory entity for the JSON api. @param Directory $directory @return array
[ "Serializes", "a", "Directory", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/Types/DirectorySerializer.php#L24-L68
train
claroline/Distribution
main/core/API/Serializer/Resource/Types/DirectorySerializer.php
DirectorySerializer.deserialize
public function deserialize(array $data, Directory $directory): Directory { $this->sipe('uploadDestination', 'setUploadDestination', $data, $directory); $this->sipe('display.showSummary', 'setShowSummary', $data, $directory); $this->sipe('display.openSummary', 'setOpenSummary', $data, $directory); // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer $this->sipe('list.count', 'setCount', $data, $directory); $this->sipe('list.actions', 'setActions', $data, $directory); // display feature $this->sipe('list.display', 'setDisplay', $data, $directory); $this->sipe('list.availableDisplays', 'setAvailableDisplays', $data, $directory); // sort feature $this->sipe('list.sorting', 'setSortBy', $data, $directory); $this->sipe('list.availableSort', 'setAvailableSort', $data, $directory); // filter feature $this->sipe('list.searchMode', 'setSearchMode', $data, $directory); $this->sipe('list.filters', 'setFilters', $data, $directory); $this->sipe('list.availableFilters', 'setAvailableFilters', $data, $directory); // pagination feature $this->sipe('list.paginated', 'setPaginated', $data, $directory); $this->sipe('list.pageSize', 'setPageSize', $data, $directory); $this->sipe('list.availablePageSizes', 'setAvailablePageSizes', $data, $directory); // table config $this->sipe('list.columns', 'setDisplayedColumns', $data, $directory); $this->sipe('list.availableColumns', 'setAvailableColumns', $data, $directory); // grid config $this->sipe('list.card.display', 'setCard', $data, $directory); return $directory; }
php
public function deserialize(array $data, Directory $directory): Directory { $this->sipe('uploadDestination', 'setUploadDestination', $data, $directory); $this->sipe('display.showSummary', 'setShowSummary', $data, $directory); $this->sipe('display.openSummary', 'setOpenSummary', $data, $directory); // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer $this->sipe('list.count', 'setCount', $data, $directory); $this->sipe('list.actions', 'setActions', $data, $directory); // display feature $this->sipe('list.display', 'setDisplay', $data, $directory); $this->sipe('list.availableDisplays', 'setAvailableDisplays', $data, $directory); // sort feature $this->sipe('list.sorting', 'setSortBy', $data, $directory); $this->sipe('list.availableSort', 'setAvailableSort', $data, $directory); // filter feature $this->sipe('list.searchMode', 'setSearchMode', $data, $directory); $this->sipe('list.filters', 'setFilters', $data, $directory); $this->sipe('list.availableFilters', 'setAvailableFilters', $data, $directory); // pagination feature $this->sipe('list.paginated', 'setPaginated', $data, $directory); $this->sipe('list.pageSize', 'setPageSize', $data, $directory); $this->sipe('list.availablePageSizes', 'setAvailablePageSizes', $data, $directory); // table config $this->sipe('list.columns', 'setDisplayedColumns', $data, $directory); $this->sipe('list.availableColumns', 'setAvailableColumns', $data, $directory); // grid config $this->sipe('list.card.display', 'setCard', $data, $directory); return $directory; }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Directory", "$", "directory", ")", ":", "Directory", "{", "$", "this", "->", "sipe", "(", "'uploadDestination'", ",", "'setUploadDestination'", ",", "$", "data", ",", "$", "directory", ")"...
Deserializes directory data into an Entity. @param array $data @param Directory $directory @return Directory
[ "Deserializes", "directory", "data", "into", "an", "Entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/Types/DirectorySerializer.php#L78-L116
train
claroline/Distribution
main/core/Listener/PlatformListener.php
PlatformListener.setLocale
public function setLocale(GetResponseEvent $event) { if ($event->isMasterRequest()) { $request = $event->getRequest(); $locale = $this->localeManager->getUserLocale($request); $request->setLocale($locale); } }
php
public function setLocale(GetResponseEvent $event) { if ($event->isMasterRequest()) { $request = $event->getRequest(); $locale = $this->localeManager->getUserLocale($request); $request->setLocale($locale); } }
[ "public", "function", "setLocale", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "$", "locale", "=", "$", "...
Sets the platform language. @DI\Observe("kernel.request", priority = 17) @param GetResponseEvent $event
[ "Sets", "the", "platform", "language", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/PlatformListener.php#L95-L103
train
claroline/Distribution
main/core/Listener/PlatformListener.php
PlatformListener.checkAvailability
public function checkAvailability(GetResponseEvent $event) { if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) { $isAdmin = false; $token = $this->tokenStorage->getToken(); if ($token) { foreach ($token->getRoles() as $role) { if ('ROLE_ADMIN' === $role->getRole()) { $isAdmin = true; break; } } } $now = time(); if (is_int($this->config->getParameter('platform_init_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_init_date')); } else { $minDate = new \DateTime($this->config->getParameter('platform_init_date')); } if (is_int($this->config->getParameter('platform_limit_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_limit_date')); } else { $expirationDate = new \DateTime($this->config->getParameter('platform_limit_date')); } if (!$isAdmin && !in_array($event->getRequest()->get('_route'), static::PUBLIC_ROUTES) && ($minDate->getTimeStamp() > $now || $now > $expirationDate->getTimeStamp()) ) { throw new HttpException(503, 'Platform is not available.'); } } }
php
public function checkAvailability(GetResponseEvent $event) { if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) { $isAdmin = false; $token = $this->tokenStorage->getToken(); if ($token) { foreach ($token->getRoles() as $role) { if ('ROLE_ADMIN' === $role->getRole()) { $isAdmin = true; break; } } } $now = time(); if (is_int($this->config->getParameter('platform_init_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_init_date')); } else { $minDate = new \DateTime($this->config->getParameter('platform_init_date')); } if (is_int($this->config->getParameter('platform_limit_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_limit_date')); } else { $expirationDate = new \DateTime($this->config->getParameter('platform_limit_date')); } if (!$isAdmin && !in_array($event->getRequest()->get('_route'), static::PUBLIC_ROUTES) && ($minDate->getTimeStamp() > $now || $now > $expirationDate->getTimeStamp()) ) { throw new HttpException(503, 'Platform is not available.'); } } }
[ "public", "function", "checkAvailability", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "'prod'", "===", "$", "this", "->", "kernel", "->", "getEnvironment", "(", ")", "&&", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "$", "...
Checks the app availability before displaying the platform. - Checks are enabled only on productions. - Administrators are always granted. - Public routes are still accessible. @DI\Observe("kernel.request") @param GetResponseEvent $event
[ "Checks", "the", "app", "availability", "before", "displaying", "the", "platform", ".", "-", "Checks", "are", "enabled", "only", "on", "productions", ".", "-", "Administrators", "are", "always", "granted", ".", "-", "Public", "routes", "are", "still", "accessi...
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/PlatformListener.php#L115-L152
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php
OpenQuestionSerializer.serialize
public function serialize(OpenQuestion $openQuestion, array $options = []) { $serialized = [ 'contentType' => 'text', 'maxLength' => $openQuestion->getAnswerMaxLength(), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = []; } return $serialized; }
php
public function serialize(OpenQuestion $openQuestion, array $options = []) { $serialized = [ 'contentType' => 'text', 'maxLength' => $openQuestion->getAnswerMaxLength(), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = []; } return $serialized; }
[ "public", "function", "serialize", "(", "OpenQuestion", "$", "openQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'contentType'", "=>", "'text'", ",", "'maxLength'", "=>", "$", "openQuestion", "->", "getAnswerM...
Converts a Open question into a JSON-encodable structure. @param OpenQuestion $openQuestion @param array $options @return array
[ "Converts", "a", "Open", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php#L26-L38
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php
OpenQuestionSerializer.deserialize
public function deserialize($data, OpenQuestion $openQuestion = null, array $options = []) { if (empty($openQuestion)) { $openQuestion = new OpenQuestion(); } $this->sipe('maxLength', 'setAnswerMaxLength', $data, $openQuestion); return $openQuestion; }
php
public function deserialize($data, OpenQuestion $openQuestion = null, array $options = []) { if (empty($openQuestion)) { $openQuestion = new OpenQuestion(); } $this->sipe('maxLength', 'setAnswerMaxLength', $data, $openQuestion); return $openQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "OpenQuestion", "$", "openQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "openQuestion", ")", ")", "{", "$", "openQuestion", "=", ...
Converts raw data into an Open question entity. @param array $data @param OpenQuestion $openQuestion @param array $options @return OpenQuestion
[ "Converts", "raw", "data", "into", "an", "Open", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php#L49-L57
train
claroline/Distribution
main/core/Listener/Administration/AppearanceListener.php
AppearanceListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $iconSets = $this->iconSetManager->listIconSetsByType(IconSetTypeEnum::RESOURCE_ICON_SET); // TODO : do it front side $iconSetChoices = []; foreach ($iconSets as $set) { $iconSetChoices[$set->getName()] = $set->getName(); } $content = $this->templating->render( 'ClarolineCoreBundle:administration:appearance.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'iconSetChoices' => $iconSetChoices, ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $iconSets = $this->iconSetManager->listIconSetsByType(IconSetTypeEnum::RESOURCE_ICON_SET); // TODO : do it front side $iconSetChoices = []; foreach ($iconSets as $set) { $iconSetChoices[$set->getName()] = $set->getName(); } $content = $this->templating->render( 'ClarolineCoreBundle:administration:appearance.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'iconSetChoices' => $iconSetChoices, ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "iconSets", "=", "$", "this", "->", "iconSetManager", "->", "listIconSetsByType", "(", "IconSetTypeEnum", "::", "RESOURCE_ICON_SET", ")", ";", "// TODO : do it fron...
Displays appearance administration tool. @DI\Observe("administration_tool_appearance_settings") @param OpenAdministrationToolEvent $event
[ "Displays", "appearance", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/AppearanceListener.php#L74-L96
train
claroline/Distribution
main/core/Event/User/DecorateUserEvent.php
DecorateUserEvent.add
public function add($key, $data) { $this->validate($key, $data); $this->injectedData[$key] = $data; }
php
public function add($key, $data) { $this->validate($key, $data); $this->injectedData[$key] = $data; }
[ "public", "function", "add", "(", "$", "key", ",", "$", "data", ")", "{", "$", "this", "->", "validate", "(", "$", "key", ",", "$", "data", ")", ";", "$", "this", "->", "injectedData", "[", "$", "key", "]", "=", "$", "data", ";", "}" ]
Adds custom data to the resource node. @param string $key @param mixed $data
[ "Adds", "custom", "data", "to", "the", "resource", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/User/DecorateUserEvent.php#L87-L92
train
claroline/Distribution
main/core/Event/User/DecorateUserEvent.php
DecorateUserEvent.validate
private function validate($key, $data) { // validates key if (in_array($key, $this->unauthorizedKeys)) { throw new \RuntimeException( 'Injected key `'.$key.'` is not authorized. (Unauthorized keys: '.implode(', ', $this->unauthorizedKeys).')' ); } if (in_array($key, array_keys($this->injectedData))) { throw new \RuntimeException( 'Injected key `'.$key.'` is already used.' ); } // validates data (must be serializable) if (false !== $data && false === json_encode($data)) { throw new \RuntimeException( 'Injected data is not serializable.' ); } }
php
private function validate($key, $data) { // validates key if (in_array($key, $this->unauthorizedKeys)) { throw new \RuntimeException( 'Injected key `'.$key.'` is not authorized. (Unauthorized keys: '.implode(', ', $this->unauthorizedKeys).')' ); } if (in_array($key, array_keys($this->injectedData))) { throw new \RuntimeException( 'Injected key `'.$key.'` is already used.' ); } // validates data (must be serializable) if (false !== $data && false === json_encode($data)) { throw new \RuntimeException( 'Injected data is not serializable.' ); } }
[ "private", "function", "validate", "(", "$", "key", ",", "$", "data", ")", "{", "// validates key", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "unauthorizedKeys", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Inject...
Validates injected data. @param string $key @param mixed $data
[ "Validates", "injected", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/User/DecorateUserEvent.php#L100-L121
train
claroline/Distribution
main/migration/Twig/SqlFormatterExtension.php
SqlFormatterExtension.formatSql
public function formatSql($sql, $tabOffset = 3) { $tab = Formatter::$tab; $indent = ''; for ($i = 0; $i < $tabOffset; ++$i) { $indent .= $tab; } $sql = explode("\n", Formatter::format($sql, false)); $indentedLines = array(); foreach ($sql as $line) { $indentedLines[] = $indent.str_replace('"', '\"', $line); } return implode("\n", $indentedLines); }
php
public function formatSql($sql, $tabOffset = 3) { $tab = Formatter::$tab; $indent = ''; for ($i = 0; $i < $tabOffset; ++$i) { $indent .= $tab; } $sql = explode("\n", Formatter::format($sql, false)); $indentedLines = array(); foreach ($sql as $line) { $indentedLines[] = $indent.str_replace('"', '\"', $line); } return implode("\n", $indentedLines); }
[ "public", "function", "formatSql", "(", "$", "sql", ",", "$", "tabOffset", "=", "3", ")", "{", "$", "tab", "=", "Formatter", "::", "$", "tab", ";", "$", "indent", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "tabOf...
Formats an SQL query using the SqlFormatter library. @param string $sql @param int $tabOffset @return string
[ "Formats", "an", "SQL", "query", "using", "the", "SqlFormatter", "library", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/migration/Twig/SqlFormatterExtension.php#L66-L83
train
claroline/Distribution
plugin/exo/Manager/Attempt/AnswerManager.php
AnswerManager.update
public function update(Item $question, Answer $answer, array $answerData, $noFlush = false) { $errors = $this->validator->validate($answerData, [Validation::QUESTION => $question->getInteraction()]); if (count($errors) > 0) { throw new InvalidDataException('Answer is not valid', $errors); } // Update Answer with new data $this->serializer->deserialize($answerData, $answer); // Save to DB $this->om->persist($answer); if (!$noFlush) { $this->om->flush(); } return $answer; }
php
public function update(Item $question, Answer $answer, array $answerData, $noFlush = false) { $errors = $this->validator->validate($answerData, [Validation::QUESTION => $question->getInteraction()]); if (count($errors) > 0) { throw new InvalidDataException('Answer is not valid', $errors); } // Update Answer with new data $this->serializer->deserialize($answerData, $answer); // Save to DB $this->om->persist($answer); if (!$noFlush) { $this->om->flush(); } return $answer; }
[ "public", "function", "update", "(", "Item", "$", "question", ",", "Answer", "$", "answer", ",", "array", "$", "answerData", ",", "$", "noFlush", "=", "false", ")", "{", "$", "errors", "=", "$", "this", "->", "validator", "->", "validate", "(", "$", ...
Validates and updates an Answer entity with raw data. @param Item $question @param Answer $answer @param array $answerData @param bool $noFlush @return Answer @throws InvalidDataException
[ "Validates", "and", "updates", "an", "Answer", "entity", "with", "raw", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/AnswerManager.php#L86-L104
train
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findMaximumRights
public function findMaximumRights(array $roles, ResourceNode $resource) { //add the role anonymous for everyone ! if (!in_array('ROLE_ANONYMOUS', $roles)) { $roles[] = 'ROLE_ANONYMOUS'; } $dql = ' SELECT rrw.mask FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rrw JOIN rrw.role role JOIN rrw.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = {$resource->getId()} AND role.name = :role{$key}"; ++$index; } $query = $this->_em->createQuery($dql); foreach ($roles as $key => $role) { $query->setParameter("role{$key}", $role); } $results = $query->getResult(); $mask = 0; foreach ($results as $result) { $mask |= $result['mask']; } return $mask; }
php
public function findMaximumRights(array $roles, ResourceNode $resource) { //add the role anonymous for everyone ! if (!in_array('ROLE_ANONYMOUS', $roles)) { $roles[] = 'ROLE_ANONYMOUS'; } $dql = ' SELECT rrw.mask FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rrw JOIN rrw.role role JOIN rrw.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = {$resource->getId()} AND role.name = :role{$key}"; ++$index; } $query = $this->_em->createQuery($dql); foreach ($roles as $key => $role) { $query->setParameter("role{$key}", $role); } $results = $query->getResult(); $mask = 0; foreach ($results as $result) { $mask |= $result['mask']; } return $mask; }
[ "public", "function", "findMaximumRights", "(", "array", "$", "roles", ",", "ResourceNode", "$", "resource", ")", "{", "//add the role anonymous for everyone !", "if", "(", "!", "in_array", "(", "'ROLE_ANONYMOUS'", ",", "$", "roles", ")", ")", "{", "$", "roles",...
Returns the maximum rights on a given resource for a set of roles. Used by the ResourceVoter. @param array[string] $rights @param ResourceNode $resource @return array
[ "Returns", "the", "maximum", "rights", "on", "a", "given", "resource", "for", "a", "set", "of", "roles", ".", "Used", "by", "the", "ResourceVoter", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L30-L66
train
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findCreationRights
public function findCreationRights(array $roles, ResourceNode $node) { if (0 === count($roles)) { throw new \RuntimeException('Roles cannot be empty'); } $dql = ' SELECT DISTINCT rType.name FROM Claroline\CoreBundle\Entity\Resource\ResourceType AS rType JOIN rType.rights right JOIN right.role role JOIN right.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = :nodeId AND role.name = :role_{$key}"; ++$index; } $query = $this->_em->createQuery($dql); $query->setParameter('nodeId', $node->getId()); foreach ($roles as $key => $role) { $query->setParameter('role_'.$key, $role); } return $query->getArrayResult(); }
php
public function findCreationRights(array $roles, ResourceNode $node) { if (0 === count($roles)) { throw new \RuntimeException('Roles cannot be empty'); } $dql = ' SELECT DISTINCT rType.name FROM Claroline\CoreBundle\Entity\Resource\ResourceType AS rType JOIN rType.rights right JOIN right.role role JOIN right.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = :nodeId AND role.name = :role_{$key}"; ++$index; } $query = $this->_em->createQuery($dql); $query->setParameter('nodeId', $node->getId()); foreach ($roles as $key => $role) { $query->setParameter('role_'.$key, $role); } return $query->getArrayResult(); }
[ "public", "function", "findCreationRights", "(", "array", "$", "roles", ",", "ResourceNode", "$", "node", ")", "{", "if", "(", "0", "===", "count", "(", "$", "roles", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Roles cannot be empty'", ...
Returns the resource types a set of roles is allowed to create in a given directory. @param array $roles @param ResourceNode $node @return array
[ "Returns", "the", "resource", "types", "a", "set", "of", "roles", "is", "allowed", "to", "create", "in", "a", "given", "directory", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L77-L107
train
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findRecursiveByResource
public function findRecursiveByResource(ResourceNode $resource) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); return $query->getResult(); }
php
public function findRecursiveByResource(ResourceNode $resource) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); return $query->getResult(); }
[ "public", "function", "findRecursiveByResource", "(", "ResourceNode", "$", "resource", ")", "{", "$", "dql", "=", "\"\n SELECT rights, role, resource\n FROM Claroline\\CoreBundle\\Entity\\Resource\\ResourceRights rights\n JOIN rights.resourceNode resource\n ...
Returns all the resource rights of a resource and its descendants. @param ResourceNode $resource @return array[ResourceRights]
[ "Returns", "all", "the", "resource", "rights", "of", "a", "resource", "and", "its", "descendants", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L145-L159
train
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findRecursiveByResourceAndRole
public function findRecursiveByResourceAndRole(ResourceNode $resource, Role $role) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path AND role.name = :roleName "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); $query->setParameter('roleName', $role->getName()); return $query->getResult(); }
php
public function findRecursiveByResourceAndRole(ResourceNode $resource, Role $role) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path AND role.name = :roleName "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); $query->setParameter('roleName', $role->getName()); return $query->getResult(); }
[ "public", "function", "findRecursiveByResourceAndRole", "(", "ResourceNode", "$", "resource", ",", "Role", "$", "role", ")", "{", "$", "dql", "=", "\"\n SELECT rights, role, resource\n FROM Claroline\\CoreBundle\\Entity\\Resource\\ResourceRights rights\n ...
Find ResourceRights for each descendant of a resource for a role. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $resource @param \Claroline\CoreBundle\Entity\Role $role @return array
[ "Find", "ResourceRights", "for", "each", "descendant", "of", "a", "resource", "for", "a", "role", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L169-L184
train
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.addRow
public function addRow(GridRow $row) { if (!$this->rows->contains($row)) { $this->rows->add($row); $row->setQuestion($this); } }
php
public function addRow(GridRow $row) { if (!$this->rows->contains($row)) { $this->rows->add($row); $row->setQuestion($this); } }
[ "public", "function", "addRow", "(", "GridRow", "$", "row", ")", "{", "if", "(", "!", "$", "this", "->", "rows", "->", "contains", "(", "$", "row", ")", ")", "{", "$", "this", "->", "rows", "->", "add", "(", "$", "row", ")", ";", "$", "row", ...
Add row. @param GridRow $row
[ "Add", "row", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L145-L151
train
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.removeRow
public function removeRow(GridRow $row) { if ($this->rows->contains($row)) { $this->rows->removeElement($row); } }
php
public function removeRow(GridRow $row) { if ($this->rows->contains($row)) { $this->rows->removeElement($row); } }
[ "public", "function", "removeRow", "(", "GridRow", "$", "row", ")", "{", "if", "(", "$", "this", "->", "rows", "->", "contains", "(", "$", "row", ")", ")", "{", "$", "this", "->", "rows", "->", "removeElement", "(", "$", "row", ")", ";", "}", "}"...
Remove row. @param GridRow $row
[ "Remove", "row", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L158-L163
train
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.getOddItem
public function getOddItem($uuid) { $found = null; foreach ($this->oddItems as $oddItem) { if ($oddItem->getItem()->getUuid() === $uuid) { $found = $oddItem; break; } } return $found; }
php
public function getOddItem($uuid) { $found = null; foreach ($this->oddItems as $oddItem) { if ($oddItem->getItem()->getUuid() === $uuid) { $found = $oddItem; break; } } return $found; }
[ "public", "function", "getOddItem", "(", "$", "uuid", ")", "{", "$", "found", "=", "null", ";", "foreach", "(", "$", "this", "->", "oddItems", "as", "$", "oddItem", ")", "{", "if", "(", "$", "oddItem", "->", "getItem", "(", ")", "->", "getUuid", "(...
Get an odd item by its uuid. @param $uuid @return GridOdd|null
[ "Get", "an", "odd", "item", "by", "its", "uuid", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L182-L193
train
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.addOddItem
public function addOddItem(GridOdd $gridOdd) { if (!$this->oddItems->contains($gridOdd)) { $this->oddItems->add($gridOdd); $gridOdd->setQuestion($this); } }
php
public function addOddItem(GridOdd $gridOdd) { if (!$this->oddItems->contains($gridOdd)) { $this->oddItems->add($gridOdd); $gridOdd->setQuestion($this); } }
[ "public", "function", "addOddItem", "(", "GridOdd", "$", "gridOdd", ")", "{", "if", "(", "!", "$", "this", "->", "oddItems", "->", "contains", "(", "$", "gridOdd", ")", ")", "{", "$", "this", "->", "oddItems", "->", "add", "(", "$", "gridOdd", ")", ...
Add odd item. @param GridOdd $gridOdd
[ "Add", "odd", "item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L200-L206
train
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.removeOddItem
public function removeOddItem(GridOdd $gridOdd) { if ($this->oddItems->contains($gridOdd)) { $this->oddItems->removeElement($gridOdd); } }
php
public function removeOddItem(GridOdd $gridOdd) { if ($this->oddItems->contains($gridOdd)) { $this->oddItems->removeElement($gridOdd); } }
[ "public", "function", "removeOddItem", "(", "GridOdd", "$", "gridOdd", ")", "{", "if", "(", "$", "this", "->", "oddItems", "->", "contains", "(", "$", "gridOdd", ")", ")", "{", "$", "this", "->", "oddItems", "->", "removeElement", "(", "$", "gridOdd", ...
Remove odd item. @param GridOdd $gridOdd
[ "Remove", "odd", "item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L213-L218
train
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.getAll
public function getAll(User $user) { return array_map(function ($dashboard) { return $this->exportDashboard($dashboard); }, $this->getRepository()->findBy(['creator' => $user])); }
php
public function getAll(User $user) { return array_map(function ($dashboard) { return $this->exportDashboard($dashboard); }, $this->getRepository()->findBy(['creator' => $user])); }
[ "public", "function", "getAll", "(", "User", "$", "user", ")", "{", "return", "array_map", "(", "function", "(", "$", "dashboard", ")", "{", "return", "$", "this", "->", "exportDashboard", "(", "$", "dashboard", ")", ";", "}", ",", "$", "this", "->", ...
get all dashboards for a given user.
[ "get", "all", "dashboards", "for", "a", "given", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L49-L54
train
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.create
public function create(User $user, $data) { $dashboard = new Dashboard(); $dashboard->setCreator($user); $dashboard->setName($data['name']); $wId = $data['workspace']['id']; $dashboard->setWorkspace($this->workspaceManager->getWorkspaceById($wId)); $this->em->persist($dashboard); $this->em->flush(); return $this->exportDashboard($dashboard); }
php
public function create(User $user, $data) { $dashboard = new Dashboard(); $dashboard->setCreator($user); $dashboard->setName($data['name']); $wId = $data['workspace']['id']; $dashboard->setWorkspace($this->workspaceManager->getWorkspaceById($wId)); $this->em->persist($dashboard); $this->em->flush(); return $this->exportDashboard($dashboard); }
[ "public", "function", "create", "(", "User", "$", "user", ",", "$", "data", ")", "{", "$", "dashboard", "=", "new", "Dashboard", "(", ")", ";", "$", "dashboard", "->", "setCreator", "(", "$", "user", ")", ";", "$", "dashboard", "->", "setName", "(", ...
create a dashboard.
[ "create", "a", "dashboard", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L59-L70
train
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.delete
public function delete(Dashboard $dashboard) { $this->em->remove($dashboard); $this->em->flush(); }
php
public function delete(Dashboard $dashboard) { $this->em->remove($dashboard); $this->em->flush(); }
[ "public", "function", "delete", "(", "Dashboard", "$", "dashboard", ")", "{", "$", "this", "->", "em", "->", "remove", "(", "$", "dashboard", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}" ]
delete a dashboard.
[ "delete", "a", "dashboard", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L86-L90
train
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.getDashboardWorkspaceSpentTimes
public function getDashboardWorkspaceSpentTimes(Workspace $workspace, User $user, $all = false) { $datas = []; // user(s) concerned by the query if ($all) { // get all users involved in the workspace $ids = $this->getWorkspaceUsersIds($workspace); } else { // only the current user $ids[] = $user->getId(); } // for each user (ie user ids) -> get first 'workspace-enter' event for the given workspace foreach ($ids as $uid) { $userSqlSelect = 'SELECT first_name, last_name FROM claro_user WHERE id = :uid'; $userSqlSelectStmt = $this->em->getConnection()->prepare($userSqlSelect); $userSqlSelectStmt->bindValue('uid', $uid); $userSqlSelectStmt->execute(); $userData = $userSqlSelectStmt->fetch(); // select first "workspace-enter" actions for the given user and workspace $selectEnterEventOnThisWorkspace = "SELECT DISTINCT date_log FROM claro_log WHERE workspace_id = :wid AND action = 'workspace-enter' AND doer_id = :uid ORDER BY date_log ASC LIMIT 1"; $selectEnterEventOnThisWorkspaceStmt = $this->em->getConnection()->prepare($selectEnterEventOnThisWorkspace); $selectEnterEventOnThisWorkspaceStmt->bindValue('uid', $uid); $selectEnterEventOnThisWorkspaceStmt->bindValue('wid', $workspace->getId()); $selectEnterEventOnThisWorkspaceStmt->execute(); $enterOnThisWorksapceDateResult = $selectEnterEventOnThisWorkspaceStmt->fetch(); $refDate = $enterOnThisWorksapceDateResult['date_log']; $total = 0; if ($refDate) { $total = $this->computeTimeForUserAndWorkspace($refDate, $uid, $workspace->getId(), 0); } $datas[] = [ 'user' => [ 'id' => $uid, 'firstName' => $userData['first_name'], 'lastName' => $userData['last_name'], ], 'time' => $total, ]; } return $datas; }
php
public function getDashboardWorkspaceSpentTimes(Workspace $workspace, User $user, $all = false) { $datas = []; // user(s) concerned by the query if ($all) { // get all users involved in the workspace $ids = $this->getWorkspaceUsersIds($workspace); } else { // only the current user $ids[] = $user->getId(); } // for each user (ie user ids) -> get first 'workspace-enter' event for the given workspace foreach ($ids as $uid) { $userSqlSelect = 'SELECT first_name, last_name FROM claro_user WHERE id = :uid'; $userSqlSelectStmt = $this->em->getConnection()->prepare($userSqlSelect); $userSqlSelectStmt->bindValue('uid', $uid); $userSqlSelectStmt->execute(); $userData = $userSqlSelectStmt->fetch(); // select first "workspace-enter" actions for the given user and workspace $selectEnterEventOnThisWorkspace = "SELECT DISTINCT date_log FROM claro_log WHERE workspace_id = :wid AND action = 'workspace-enter' AND doer_id = :uid ORDER BY date_log ASC LIMIT 1"; $selectEnterEventOnThisWorkspaceStmt = $this->em->getConnection()->prepare($selectEnterEventOnThisWorkspace); $selectEnterEventOnThisWorkspaceStmt->bindValue('uid', $uid); $selectEnterEventOnThisWorkspaceStmt->bindValue('wid', $workspace->getId()); $selectEnterEventOnThisWorkspaceStmt->execute(); $enterOnThisWorksapceDateResult = $selectEnterEventOnThisWorkspaceStmt->fetch(); $refDate = $enterOnThisWorksapceDateResult['date_log']; $total = 0; if ($refDate) { $total = $this->computeTimeForUserAndWorkspace($refDate, $uid, $workspace->getId(), 0); } $datas[] = [ 'user' => [ 'id' => $uid, 'firstName' => $userData['first_name'], 'lastName' => $userData['last_name'], ], 'time' => $total, ]; } return $datas; }
[ "public", "function", "getDashboardWorkspaceSpentTimes", "(", "Workspace", "$", "workspace", ",", "User", "$", "user", ",", "$", "all", "=", "false", ")", "{", "$", "datas", "=", "[", "]", ";", "// user(s) concerned by the query", "if", "(", "$", "all", ")",...
Compute spent time for each user in a given workspace.
[ "Compute", "spent", "time", "for", "each", "user", "in", "a", "given", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L95-L140
train