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/dashboard/Manager/DashboardManager.php
DashboardManager.getWorkspaceUsersIds
private function getWorkspaceUsersIds(Workspace $workspace) { // Select all user(s) belonging to the target workspace (manager and collaborators)... $selectUsersIds = 'SELECT DISTINCT cur.user_id FROM claro_user_role cur JOIN claro_role cr ON cr.id = cur.role_id WHERE cr.workspace_id = :wid'; $idStmt = $this->em->getConnection()->prepare($selectUsersIds); $idStmt->bindValue('wid', $workspace->getId()); $idStmt->execute(); $idResults = $idStmt->fetchAll(); foreach ($idResults as $result) { $ids[] = $result['user_id']; } return $ids; }
php
private function getWorkspaceUsersIds(Workspace $workspace) { // Select all user(s) belonging to the target workspace (manager and collaborators)... $selectUsersIds = 'SELECT DISTINCT cur.user_id FROM claro_user_role cur JOIN claro_role cr ON cr.id = cur.role_id WHERE cr.workspace_id = :wid'; $idStmt = $this->em->getConnection()->prepare($selectUsersIds); $idStmt->bindValue('wid', $workspace->getId()); $idStmt->execute(); $idResults = $idStmt->fetchAll(); foreach ($idResults as $result) { $ids[] = $result['user_id']; } return $ids; }
[ "private", "function", "getWorkspaceUsersIds", "(", "Workspace", "$", "workspace", ")", "{", "// Select all user(s) belonging to the target workspace (manager and collaborators)...", "$", "selectUsersIds", "=", "'SELECT DISTINCT cur.user_id FROM claro_user_role cur JOIN claro_role cr ON cr...
Get all ids from users related to a given workspace.
[ "Get", "all", "ids", "from", "users", "related", "to", "a", "given", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L145-L158
train
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.computeTimeForUserAndWorkspace
private function computeTimeForUserAndWorkspace($startDate, $userId, $workspaceId, $time) { // select first "out of this workspace event" (ie "workspace enter" on another workspace) $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $startDate); $stmt->execute(); $action = $stmt->fetch(); // if there is an action we can compute time if ($action['date_log']) { $t1 = strtotime($startDate); $t2 = strtotime($action['date_log']); $seconds = $t2 - $t1; // add time only if bewteen 30s and 2 hours <= totally arbitrary ! if ($seconds > 5 && ($seconds / 60) <= 120) { $time += $seconds; } // get next "enter the requested workspace enter event" $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog AND workspace_id = :wid ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $action['date_log']); $stmt->bindValue('wid', $workspaceId); $stmt->execute(); $nextEnterEvent = $stmt->fetch(); // if there is an "enter-workspace" action after the current one recall the method if ($nextEnterEvent['date_log']) { return $this->computeTimeForUserAndWorkspace($nextEnterEvent['date_log'], $userId, $workspaceId, $time); } else { return $time; } } return $time; }
php
private function computeTimeForUserAndWorkspace($startDate, $userId, $workspaceId, $time) { // select first "out of this workspace event" (ie "workspace enter" on another workspace) $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $startDate); $stmt->execute(); $action = $stmt->fetch(); // if there is an action we can compute time if ($action['date_log']) { $t1 = strtotime($startDate); $t2 = strtotime($action['date_log']); $seconds = $t2 - $t1; // add time only if bewteen 30s and 2 hours <= totally arbitrary ! if ($seconds > 5 && ($seconds / 60) <= 120) { $time += $seconds; } // get next "enter the requested workspace enter event" $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog AND workspace_id = :wid ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $action['date_log']); $stmt->bindValue('wid', $workspaceId); $stmt->execute(); $nextEnterEvent = $stmt->fetch(); // if there is an "enter-workspace" action after the current one recall the method if ($nextEnterEvent['date_log']) { return $this->computeTimeForUserAndWorkspace($nextEnterEvent['date_log'], $userId, $workspaceId, $time); } else { return $time; } } return $time; }
[ "private", "function", "computeTimeForUserAndWorkspace", "(", "$", "startDate", ",", "$", "userId", ",", "$", "workspaceId", ",", "$", "time", ")", "{", "// select first \"out of this workspace event\" (ie \"workspace enter\" on another workspace)", "$", "sql", "=", "\"SELE...
Search for out and in events on a given wokspace, for a given user and relativly to a date.
[ "Search", "for", "out", "and", "in", "events", "on", "a", "given", "wokspace", "for", "a", "given", "user", "and", "relativly", "to", "a", "date", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L163-L200
train
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.exportDashboard
public function exportDashboard(Dashboard $dashboard) { return [ 'id' => $dashboard->getId(), 'creatorId' => $dashboard->getCreator()->getId(), 'name' => $dashboard->getName(), 'workspace' => $this->workspaceManager->exportWorkspace($dashboard->getWorkspace()), ]; }
php
public function exportDashboard(Dashboard $dashboard) { return [ 'id' => $dashboard->getId(), 'creatorId' => $dashboard->getCreator()->getId(), 'name' => $dashboard->getName(), 'workspace' => $this->workspaceManager->exportWorkspace($dashboard->getWorkspace()), ]; }
[ "public", "function", "exportDashboard", "(", "Dashboard", "$", "dashboard", ")", "{", "return", "[", "'id'", "=>", "$", "dashboard", "->", "getId", "(", ")", ",", "'creatorId'", "=>", "$", "dashboard", "->", "getCreator", "(", ")", "->", "getId", "(", "...
Export dashboard as array.
[ "Export", "dashboard", "as", "array", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L205-L213
train
claroline/Distribution
plugin/tag/Listener/TagListener.php
TagListener.onRetrieveUsedTagsByClassAndIds
public function onRetrieveUsedTagsByClassAndIds(GenericDataEvent $event) { $tags = []; $data = $event->getData(); if (is_array($data) && isset($data['class']) && !empty($data['ids'])) { /** @var TaggedObject[] $taggedObjects */ $taggedObjects = $this->manager->getTaggedObjects($data['class'], $data['ids']); if (isset($data['frequency']) && $data['frequency']) { //array [tagName => frequency] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); if (!array_key_exists($tag->getName(), $tags)) { $tags[$tag->getName()] = 0; } ++$tags[$tag->getName()]; } } else { //array [tagName] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); $tags[$tag->getId()] = $taggedObject->getTag()->getName(); } $tags = array_values($tags); } } $event->setResponse($tags); }
php
public function onRetrieveUsedTagsByClassAndIds(GenericDataEvent $event) { $tags = []; $data = $event->getData(); if (is_array($data) && isset($data['class']) && !empty($data['ids'])) { /** @var TaggedObject[] $taggedObjects */ $taggedObjects = $this->manager->getTaggedObjects($data['class'], $data['ids']); if (isset($data['frequency']) && $data['frequency']) { //array [tagName => frequency] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); if (!array_key_exists($tag->getName(), $tags)) { $tags[$tag->getName()] = 0; } ++$tags[$tag->getName()]; } } else { //array [tagName] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); $tags[$tag->getId()] = $taggedObject->getTag()->getName(); } $tags = array_values($tags); } } $event->setResponse($tags); }
[ "public", "function", "onRetrieveUsedTagsByClassAndIds", "(", "GenericDataEvent", "$", "event", ")", "{", "$", "tags", "=", "[", "]", ";", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "is_array", "(", "$", "data", ")", "&&...
Used by serializers to retrieves tags. @DI\Observe("claroline_retrieve_used_tags_by_class_and_ids") @param GenericDataEvent $event
[ "Used", "by", "serializers", "to", "retrieves", "tags", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Listener/TagListener.php#L155-L183
train
claroline/Distribution
main/app/JVal/Walker.php
Walker.parseSchema
public function parseSchema(\stdClass $schema, Context $context) { if ($this->isProcessed($schema, $this->parsedSchemas)) { return $schema; } $version = $this->getVersion($schema); $constraints = $this->registry->getConstraints($version); $constraints = $this->filterConstraintsForSchema($constraints, $schema); foreach ($constraints as $constraint) { $constraint->normalize($schema, $context, $this); } return $schema; }
php
public function parseSchema(\stdClass $schema, Context $context) { if ($this->isProcessed($schema, $this->parsedSchemas)) { return $schema; } $version = $this->getVersion($schema); $constraints = $this->registry->getConstraints($version); $constraints = $this->filterConstraintsForSchema($constraints, $schema); foreach ($constraints as $constraint) { $constraint->normalize($schema, $context, $this); } return $schema; }
[ "public", "function", "parseSchema", "(", "\\", "stdClass", "$", "schema", ",", "Context", "$", "context", ")", "{", "if", "(", "$", "this", "->", "isProcessed", "(", "$", "schema", ",", "$", "this", "->", "parsedSchemas", ")", ")", "{", "return", "$",...
Recursively normalizes a given schema and validates its syntax. @param stdClass $schema @param Context $context @return stdClass
[ "Recursively", "normalizes", "a", "given", "schema", "and", "validates", "its", "syntax", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/JVal/Walker.php#L143-L158
train
claroline/Distribution
main/app/JVal/Walker.php
Walker.getVersion
private function getVersion(stdClass $schema) { return property_exists($schema, '$schema') && is_string($schema->{'$schema'}) ? $schema->{'$schema'} : Registry::VERSION_CURRENT; }
php
private function getVersion(stdClass $schema) { return property_exists($schema, '$schema') && is_string($schema->{'$schema'}) ? $schema->{'$schema'} : Registry::VERSION_CURRENT; }
[ "private", "function", "getVersion", "(", "stdClass", "$", "schema", ")", "{", "return", "property_exists", "(", "$", "schema", ",", "'$schema'", ")", "&&", "is_string", "(", "$", "schema", "->", "{", "'$schema'", "}", ")", "?", "$", "schema", "->", "{",...
Returns the version of a schema. @param stdClass $schema @return string
[ "Returns", "the", "version", "of", "a", "schema", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/JVal/Walker.php#L212-L217
train
claroline/Distribution
plugin/website/Controller/Controller.php
Controller.getLoggedUser
protected function getLoggedUser() { $user = $this->get('security.token_storage')->getToken()->getUser(); if (is_string($user)) { $user = null; } return $user; }
php
protected function getLoggedUser() { $user = $this->get('security.token_storage')->getToken()->getUser(); if (is_string($user)) { $user = null; } return $user; }
[ "protected", "function", "getLoggedUser", "(", ")", "{", "$", "user", "=", "$", "this", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "is_string", "(", "$", "user", ")", ")", ...
Retrieve logged user. If anonymous return null. @return user
[ "Retrieve", "logged", "user", ".", "If", "anonymous", "return", "null", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/website/Controller/Controller.php#L88-L96
train
claroline/Distribution
main/core/Listener/Administration/HomeListener.php
HomeListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $tabs = $this->finder->search( HomeTab::class, ['filters' => ['type' => HomeTab::TYPE_ADMIN_DESKTOP]] ); $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $roles = $this->finder->search('Claroline\CoreBundle\Entity\Role', ['filters' => ['type' => Role::PLATFORM_ROLE]] ); $content = $this->templating->render( 'ClarolineCoreBundle:administration:home.html.twig', [ 'editable' => true, 'administration' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, 'data' => [ 'roles' => $roles['data'], ], ], 'tabs' => array_values($orderedTabs), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $tabs = $this->finder->search( HomeTab::class, ['filters' => ['type' => HomeTab::TYPE_ADMIN_DESKTOP]] ); $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $roles = $this->finder->search('Claroline\CoreBundle\Entity\Role', ['filters' => ['type' => Role::PLATFORM_ROLE]] ); $content = $this->templating->render( 'ClarolineCoreBundle:administration:home.html.twig', [ 'editable' => true, 'administration' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, 'data' => [ 'roles' => $roles['data'], ], ], 'tabs' => array_values($orderedTabs), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "tabs", "=", "$", "this", "->", "finder", "->", "search", "(", "HomeTab", "::", "class", ",", "[", "'filters'", "=>", "[", "'type'", "=>", "HomeTab", ":...
Displays analytics administration tool. @DI\Observe("administration_tool_desktop_and_home") @param OpenAdministrationToolEvent $event
[ "Displays", "analytics", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/HomeListener.php#L51-L86
train
claroline/Distribution
plugin/open-badge/Serializer/EvidenceSerializer.php
EvidenceSerializer.deserialize
public function deserialize(array $data, Evidence $evidence = null, array $options = []) { $this->sipe('narrative', 'setNarrative', $data, $evidence); $this->sipe('name', 'setName', $data, $evidence); if (isset($data['resources'])) { $resources = []; foreach ($data['resources'] as $resource) { $node = $this->_om->getObject($resource, ResourceNode::class); $resources[] = $this->resourceNodeSerializer->deserialize($resource, $node); } $evidence->setResourceEvidences($resources); } }
php
public function deserialize(array $data, Evidence $evidence = null, array $options = []) { $this->sipe('narrative', 'setNarrative', $data, $evidence); $this->sipe('name', 'setName', $data, $evidence); if (isset($data['resources'])) { $resources = []; foreach ($data['resources'] as $resource) { $node = $this->_om->getObject($resource, ResourceNode::class); $resources[] = $this->resourceNodeSerializer->deserialize($resource, $node); } $evidence->setResourceEvidences($resources); } }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Evidence", "$", "evidence", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "sipe", "(", "'narrative'", ",", "'setNarrative'", ",", "$", "data"...
Serializes a Evidence entity. @param array $data @param Evidence $evidence @param array $options @return array
[ "Serializes", "a", "Evidence", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/open-badge/Serializer/EvidenceSerializer.php#L72-L85
train
claroline/Distribution
plugin/exo/Entity/Misc/GridItem.php
GridItem.getCoords
public function getCoords() { return (is_int($this->coordsX) || is_int($this->coordsY)) ? [$this->coordsX, $this->coordsY] : null; }
php
public function getCoords() { return (is_int($this->coordsX) || is_int($this->coordsY)) ? [$this->coordsX, $this->coordsY] : null; }
[ "public", "function", "getCoords", "(", ")", "{", "return", "(", "is_int", "(", "$", "this", "->", "coordsX", ")", "||", "is_int", "(", "$", "this", "->", "coordsY", ")", ")", "?", "[", "$", "this", "->", "coordsX", ",", "$", "this", "->", "coordsY...
Get coordinates. @return array
[ "Get", "coordinates", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/GridItem.php#L113-L117
train
claroline/Distribution
plugin/scorm/Manager/ScormManager.php
ScormManager.retrieveIntervalFromSeconds
private function retrieveIntervalFromSeconds($seconds) { $result = ''; $remainingTime = (int) $seconds; if (empty($remainingTime)) { $result .= 'PT0S'; } else { $nbDays = (int) ($remainingTime / 86400); $remainingTime %= 86400; $nbHours = (int) ($remainingTime / 3600); $remainingTime %= 3600; $nbMinutes = (int) ($remainingTime / 60); $nbSeconds = $remainingTime % 60; $result .= 'P'.$nbDays.'DT'.$nbHours.'H'.$nbMinutes.'M'.$nbSeconds.'S'; } return $result; }
php
private function retrieveIntervalFromSeconds($seconds) { $result = ''; $remainingTime = (int) $seconds; if (empty($remainingTime)) { $result .= 'PT0S'; } else { $nbDays = (int) ($remainingTime / 86400); $remainingTime %= 86400; $nbHours = (int) ($remainingTime / 3600); $remainingTime %= 3600; $nbMinutes = (int) ($remainingTime / 60); $nbSeconds = $remainingTime % 60; $result .= 'P'.$nbDays.'DT'.$nbHours.'H'.$nbMinutes.'M'.$nbSeconds.'S'; } return $result; }
[ "private", "function", "retrieveIntervalFromSeconds", "(", "$", "seconds", ")", "{", "$", "result", "=", "''", ";", "$", "remainingTime", "=", "(", "int", ")", "$", "seconds", ";", "if", "(", "empty", "(", "$", "remainingTime", ")", ")", "{", "$", "res...
Converts a time in seconds to a DateInterval string. @param int $seconds @return string
[ "Converts", "a", "time", "in", "seconds", "to", "a", "DateInterval", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ScormManager.php#L992-L1010
train
claroline/Distribution
plugin/exo/Serializer/UserSerializer.php
UserSerializer.serialize
public function serialize(User $user, array $options = []) { $serialized = [ 'id' => $user->getUuid(), 'name' => trim($user->getFirstName().' '.$user->getLastName()), 'picture' => $this->serializePicture($user), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'username' => $user->getUsername(), 'publicUrl' => $user->getPublicUrl(), ]; if (!in_array(Transfer::MINIMAL, $options)) { $serialized['email'] = $user->getEmail(); } return $serialized; }
php
public function serialize(User $user, array $options = []) { $serialized = [ 'id' => $user->getUuid(), 'name' => trim($user->getFirstName().' '.$user->getLastName()), 'picture' => $this->serializePicture($user), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'username' => $user->getUsername(), 'publicUrl' => $user->getPublicUrl(), ]; if (!in_array(Transfer::MINIMAL, $options)) { $serialized['email'] = $user->getEmail(); } return $serialized; }
[ "public", "function", "serialize", "(", "User", "$", "user", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "user", "->", "getUuid", "(", ")", ",", "'name'", "=>", "trim", "(", "$", "user", ...
Converts a User into a JSON-encodable structure. @param User $user @param array $options @return array
[ "Converts", "a", "User", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/UserSerializer.php#L56-L73
train
claroline/Distribution
plugin/exo/Serializer/UserSerializer.php
UserSerializer.deserialize
public function deserialize($data, User $user = null, array $options = []) { if (empty($user)) { /** @var User $user */ $user = $this->om->getRepository(User::class)->findOneBy(['uuid' => $data['id']]); } return $user; }
php
public function deserialize($data, User $user = null, array $options = []) { if (empty($user)) { /** @var User $user */ $user = $this->om->getRepository(User::class)->findOneBy(['uuid' => $data['id']]); } return $user; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "User", "$", "user", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "user", ")", ")", "{", "/** @var User $user */", "$", "user", "=", "$...
Converts raw data into a User entity. Note : we don't allow to update users here, so this method only returns the untouched entity instance. @param \array $data @param User $user @param array $options @return User
[ "Converts", "raw", "data", "into", "a", "User", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/UserSerializer.php#L86-L94
train
claroline/Distribution
plugin/exo/Serializer/UserSerializer.php
UserSerializer.serializePicture
private function serializePicture(User $user) { if (!empty($user->getPicture())) { /** @var PublicFile $file */ $file = $this->om ->getRepository(PublicFile::class) ->findOneBy(['url' => $user->getPicture()]); if ($file) { return $this->fileSerializer->serialize($file); } } return null; }
php
private function serializePicture(User $user) { if (!empty($user->getPicture())) { /** @var PublicFile $file */ $file = $this->om ->getRepository(PublicFile::class) ->findOneBy(['url' => $user->getPicture()]); if ($file) { return $this->fileSerializer->serialize($file); } } return null; }
[ "private", "function", "serializePicture", "(", "User", "$", "user", ")", "{", "if", "(", "!", "empty", "(", "$", "user", "->", "getPicture", "(", ")", ")", ")", "{", "/** @var PublicFile $file */", "$", "file", "=", "$", "this", "->", "om", "->", "get...
Serialize the user picture. @param User $user @return array|null
[ "Serialize", "the", "user", "picture", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/UserSerializer.php#L103-L117
train
claroline/Distribution
main/core/Entity/Facet/Facet.php
Facet.resetPanelFacets
public function resetPanelFacets() { foreach ($this->panelFacets as $panelFacet) { $panelFacet->setFacet(null); } $this->panelFacets = new ArrayCollection(); }
php
public function resetPanelFacets() { foreach ($this->panelFacets as $panelFacet) { $panelFacet->setFacet(null); } $this->panelFacets = new ArrayCollection(); }
[ "public", "function", "resetPanelFacets", "(", ")", "{", "foreach", "(", "$", "this", "->", "panelFacets", "as", "$", "panelFacet", ")", "{", "$", "panelFacet", "->", "setFacet", "(", "null", ")", ";", "}", "$", "this", "->", "panelFacets", "=", "new", ...
Removes all PanelFacet.
[ "Removes", "all", "PanelFacet", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Facet/Facet.php#L132-L139
train
claroline/Distribution
main/core/Controller/FileController.php
FileController.uploadTinyMceAction
public function uploadTinyMceAction(Request $request, User $user) { // grab and validate user submission $content = $this->decodeRequest($request); if (empty($content) || empty($content['file']) || empty($content['parent'])) { $errors = []; if (empty($content['parent'])) { $errors[] = [ 'path' => 'parent', 'message' => 'This value should not be blank.', ]; } if (empty($content['file'])) { $errors[] = [ 'path' => 'file', 'message' => 'This value should not be blank.', ]; } throw new InvalidDataException('Invalid data.', $errors); } // check user rights $parent = $this->om->getRepository(ResourceNode::class)->findOneBy(['uuid' => $content['parent']]); $this->checkPermission('CREATE', new ResourceCollection([$parent], ['type' => 'file'])); // create the new file resource $file = new File(); $file->setSize($content['file']['size']); $file->setName($content['file']['filename']); $file->setHashName($content['file']['url']); $file->setMimeType($content['file']['mimeType']); $rights = []; if (!$parent->getWorkspace()) { $rights = [ 'ROLE_ANONYMOUS' => [ 'open' => true, 'export' => true, 'create' => [], 'role' => $this->roleManager->getRoleByName('ROLE_ANONYMOUS'), ], ]; } $file = $this->resourceManager->create( $file, $this->resourceManager->getResourceTypeByName('file'), $user, $parent->getWorkspace(), $parent, null, $rights, true ); return new JsonResponse($this->serializer->serialize($file->getResourceNode(), [Options::SERIALIZE_MINIMAL]), 201); }
php
public function uploadTinyMceAction(Request $request, User $user) { // grab and validate user submission $content = $this->decodeRequest($request); if (empty($content) || empty($content['file']) || empty($content['parent'])) { $errors = []; if (empty($content['parent'])) { $errors[] = [ 'path' => 'parent', 'message' => 'This value should not be blank.', ]; } if (empty($content['file'])) { $errors[] = [ 'path' => 'file', 'message' => 'This value should not be blank.', ]; } throw new InvalidDataException('Invalid data.', $errors); } // check user rights $parent = $this->om->getRepository(ResourceNode::class)->findOneBy(['uuid' => $content['parent']]); $this->checkPermission('CREATE', new ResourceCollection([$parent], ['type' => 'file'])); // create the new file resource $file = new File(); $file->setSize($content['file']['size']); $file->setName($content['file']['filename']); $file->setHashName($content['file']['url']); $file->setMimeType($content['file']['mimeType']); $rights = []; if (!$parent->getWorkspace()) { $rights = [ 'ROLE_ANONYMOUS' => [ 'open' => true, 'export' => true, 'create' => [], 'role' => $this->roleManager->getRoleByName('ROLE_ANONYMOUS'), ], ]; } $file = $this->resourceManager->create( $file, $this->resourceManager->getResourceTypeByName('file'), $user, $parent->getWorkspace(), $parent, null, $rights, true ); return new JsonResponse($this->serializer->serialize($file->getResourceNode(), [Options::SERIALIZE_MINIMAL]), 201); }
[ "public", "function", "uploadTinyMceAction", "(", "Request", "$", "request", ",", "User", "$", "user", ")", "{", "// grab and validate user submission", "$", "content", "=", "$", "this", "->", "decodeRequest", "(", "$", "request", ")", ";", "if", "(", "empty",...
Creates a resource from uploaded file. @EXT\Route("/tinymce/upload", name="claro_tinymce_file_upload") @EXT\ParamConverter("user", options={"authenticatedUser" = true}) @EXT\Method("POST") @param Request $request @param User $user @throws \Exception @return Response
[ "Creates", "a", "resource", "from", "uploaded", "file", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/FileController.php#L178-L234
train
claroline/Distribution
main/core/Controller/FileController.php
FileController.stream
private function stream(ResourceNode $resourceNode) { //temporary because otherwise injected resource must have the "open" right $this->checkPermission('OPEN', $resourceNode, [], true); // free the session as soon as possible // see https://github.com/claroline/CoreBundle/commit/7cee6de85bbc9448f86eb98af2abb1cb072c7b6b $this->session->save(); /** @var File $file */ $file = $this->resourceManager->getResourceFromNode($resourceNode); $path = $this->fileDir.DIRECTORY_SEPARATOR.$file->getHashName(); if (!file_exists($path)) { return new JsonResponse(['File not found'], 500); } $response = new BinaryFileResponse($path); $response->headers->set('Content-Type', $resourceNode->getMimeType()); return $response; }
php
private function stream(ResourceNode $resourceNode) { //temporary because otherwise injected resource must have the "open" right $this->checkPermission('OPEN', $resourceNode, [], true); // free the session as soon as possible // see https://github.com/claroline/CoreBundle/commit/7cee6de85bbc9448f86eb98af2abb1cb072c7b6b $this->session->save(); /** @var File $file */ $file = $this->resourceManager->getResourceFromNode($resourceNode); $path = $this->fileDir.DIRECTORY_SEPARATOR.$file->getHashName(); if (!file_exists($path)) { return new JsonResponse(['File not found'], 500); } $response = new BinaryFileResponse($path); $response->headers->set('Content-Type', $resourceNode->getMimeType()); return $response; }
[ "private", "function", "stream", "(", "ResourceNode", "$", "resourceNode", ")", "{", "//temporary because otherwise injected resource must have the \"open\" right", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "resourceNode", ",", "[", "]", ",", "true"...
Streams a resource file to the user browser. @param ResourceNode $resourceNode @return BinaryFileResponse
[ "Streams", "a", "resource", "file", "to", "the", "user", "browser", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/FileController.php#L279-L300
train
claroline/Distribution
main/core/Controller/LayoutController.php
LayoutController.footerAction
public function footerAction() { // TODO: find the lightest way to get that information $version = $this->get('claroline.manager.version_manager')->getDistributionVersion(); $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $selfRegistration = $this->configHandler->getParameter('allow_self_registration') && $this->roleManager->validateRoleInsert(new User(), $roleUser); return $this->render('ClarolineCoreBundle:layout:footer.html.twig', [ 'footerMessage' => $this->configHandler->getParameter('footer'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), 'coreVersion' => $version, 'selfRegistration' => $selfRegistration, ]); }
php
public function footerAction() { // TODO: find the lightest way to get that information $version = $this->get('claroline.manager.version_manager')->getDistributionVersion(); $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $selfRegistration = $this->configHandler->getParameter('allow_self_registration') && $this->roleManager->validateRoleInsert(new User(), $roleUser); return $this->render('ClarolineCoreBundle:layout:footer.html.twig', [ 'footerMessage' => $this->configHandler->getParameter('footer'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), 'coreVersion' => $version, 'selfRegistration' => $selfRegistration, ]); }
[ "public", "function", "footerAction", "(", ")", "{", "// TODO: find the lightest way to get that information", "$", "version", "=", "$", "this", "->", "get", "(", "'claroline.manager.version_manager'", ")", "->", "getDistributionVersion", "(", ")", ";", "$", "roleUser",...
Renders the platform footer. @return Response
[ "Renders", "the", "platform", "footer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/LayoutController.php#L265-L282
train
claroline/Distribution
main/core/Controller/LayoutController.php
LayoutController.renderWarningImpersonationAction
public function renderWarningImpersonationAction() { $token = $this->tokenStorage->getToken(); $roles = $this->utils->getRoles($token); $impersonatedRole = null; $isRoleImpersonated = false; $workspaceName = ''; $roleName = ''; foreach ($roles as $role) { if (strstr($role, 'ROLE_USURPATE_WORKSPACE_ROLE')) { $isRoleImpersonated = true; } } if ($isRoleImpersonated) { foreach ($roles as $role) { if (strstr($role, 'ROLE_WS')) { $impersonatedRole = $role; } } if (null === $impersonatedRole) { $roleName = 'ROLE_ANONYMOUS'; } else { $guid = substr($impersonatedRole, strripos($impersonatedRole, '_') + 1); $workspace = $this->workspaceManager->getOneByGuid($guid); $roleEntity = $this->roleManager->getRoleByName($impersonatedRole); $roleName = $roleEntity->getTranslationKey(); if ($workspace) { $workspaceName = $workspace->getName(); } } } return $this->render('ClarolineCoreBundle:layout:render_warning_impersonation.html.twig', [ 'isImpersonated' => $this->isImpersonated(), 'workspace' => $workspaceName, 'role' => $roleName, ]); }
php
public function renderWarningImpersonationAction() { $token = $this->tokenStorage->getToken(); $roles = $this->utils->getRoles($token); $impersonatedRole = null; $isRoleImpersonated = false; $workspaceName = ''; $roleName = ''; foreach ($roles as $role) { if (strstr($role, 'ROLE_USURPATE_WORKSPACE_ROLE')) { $isRoleImpersonated = true; } } if ($isRoleImpersonated) { foreach ($roles as $role) { if (strstr($role, 'ROLE_WS')) { $impersonatedRole = $role; } } if (null === $impersonatedRole) { $roleName = 'ROLE_ANONYMOUS'; } else { $guid = substr($impersonatedRole, strripos($impersonatedRole, '_') + 1); $workspace = $this->workspaceManager->getOneByGuid($guid); $roleEntity = $this->roleManager->getRoleByName($impersonatedRole); $roleName = $roleEntity->getTranslationKey(); if ($workspace) { $workspaceName = $workspace->getName(); } } } return $this->render('ClarolineCoreBundle:layout:render_warning_impersonation.html.twig', [ 'isImpersonated' => $this->isImpersonated(), 'workspace' => $workspaceName, 'role' => $roleName, ]); }
[ "public", "function", "renderWarningImpersonationAction", "(", ")", "{", "$", "token", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ";", "$", "roles", "=", "$", "this", "->", "utils", "->", "getRoles", "(", "$", "token", ")", ";", ...
Renders the warning bar when a workspace role is impersonated. @return Response
[ "Renders", "the", "warning", "bar", "when", "a", "workspace", "role", "is", "impersonated", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/LayoutController.php#L289-L329
train
claroline/Distribution
plugin/exo/Entity/Misc/Cell.php
Cell.setChoices
public function setChoices(array $choices) { // Removes old choices $oldChoices = array_filter($this->choices->toArray(), function (CellChoice $choice) use ($choices) { return !in_array($choice, $choices); }); array_walk($oldChoices, function (CellChoice $choice) { $this->removeChoice($choice); }); // Adds new ones array_walk($choices, function (CellChoice $choice) { $this->addChoice($choice); }); }
php
public function setChoices(array $choices) { // Removes old choices $oldChoices = array_filter($this->choices->toArray(), function (CellChoice $choice) use ($choices) { return !in_array($choice, $choices); }); array_walk($oldChoices, function (CellChoice $choice) { $this->removeChoice($choice); }); // Adds new ones array_walk($choices, function (CellChoice $choice) { $this->addChoice($choice); }); }
[ "public", "function", "setChoices", "(", "array", "$", "choices", ")", "{", "// Removes old choices", "$", "oldChoices", "=", "array_filter", "(", "$", "this", "->", "choices", "->", "toArray", "(", ")", ",", "function", "(", "CellChoice", "$", "choice", ")"...
Sets choices collection. @param array $choices
[ "Sets", "choices", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/Cell.php#L300-L314
train
claroline/Distribution
plugin/exo/Entity/Misc/Cell.php
Cell.getChoice
public function getChoice($text) { $found = null; $text = trim($text); $iText = strtoupper(TextNormalizer::stripDiacritics($text)); foreach ($this->choices as $choice) { /** @var CellChoice $choice */ $tmpText = trim($choice->getText()); if ($tmpText === $text || ( !$choice->isCaseSensitive() && strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText) ) { $found = $choice; break; } } return $found; }
php
public function getChoice($text) { $found = null; $text = trim($text); $iText = strtoupper(TextNormalizer::stripDiacritics($text)); foreach ($this->choices as $choice) { /** @var CellChoice $choice */ $tmpText = trim($choice->getText()); if ($tmpText === $text || ( !$choice->isCaseSensitive() && strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText) ) { $found = $choice; break; } } return $found; }
[ "public", "function", "getChoice", "(", "$", "text", ")", "{", "$", "found", "=", "null", ";", "$", "text", "=", "trim", "(", "$", "text", ")", ";", "$", "iText", "=", "strtoupper", "(", "TextNormalizer", "::", "stripDiacritics", "(", "$", "text", ")...
Get a cell choice by text. @param string $text @return Cell|null
[ "Get", "a", "cell", "choice", "by", "text", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/Cell.php#L344-L363
train
claroline/Distribution
plugin/exo/Manager/Attempt/ScoreManager.php
ScoreManager.applyPenalties
public function applyPenalties($score, CorrectedAnswer $correctedAnswer) { $penalties = $correctedAnswer->getPenalties(); foreach ($penalties as $penalty) { $score -= $penalty->getPenalty(); } return $score; }
php
public function applyPenalties($score, CorrectedAnswer $correctedAnswer) { $penalties = $correctedAnswer->getPenalties(); foreach ($penalties as $penalty) { $score -= $penalty->getPenalty(); } return $score; }
[ "public", "function", "applyPenalties", "(", "$", "score", ",", "CorrectedAnswer", "$", "correctedAnswer", ")", "{", "$", "penalties", "=", "$", "correctedAnswer", "->", "getPenalties", "(", ")", ";", "foreach", "(", "$", "penalties", "as", "$", "penalty", "...
Applies hint penalties to a score. @param float $score @param CorrectedAnswer $correctedAnswer @return float
[ "Applies", "hint", "penalties", "to", "a", "score", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/ScoreManager.php#L214-L222
train
claroline/Distribution
main/core/Repository/RevisionRepository.php
RevisionRepository.getLastRevision
public function getLastRevision(Text $text) { $dql = " SELECT r FROM Claroline\CoreBundle\Entity\Resource\Revision r JOIN r.text t2 WHERE r.version = (SELECT MAX(r2.version) FROM Claroline\CoreBundle\Entity\Resource\Revision r2 JOIN r2.text t WHERE t.id = {$text->getId()}) and t2.id = {$text->getId()} "; $query = $this->_em->createQuery($dql); return $query->getSingleResult(); }
php
public function getLastRevision(Text $text) { $dql = " SELECT r FROM Claroline\CoreBundle\Entity\Resource\Revision r JOIN r.text t2 WHERE r.version = (SELECT MAX(r2.version) FROM Claroline\CoreBundle\Entity\Resource\Revision r2 JOIN r2.text t WHERE t.id = {$text->getId()}) and t2.id = {$text->getId()} "; $query = $this->_em->createQuery($dql); return $query->getSingleResult(); }
[ "public", "function", "getLastRevision", "(", "Text", "$", "text", ")", "{", "$", "dql", "=", "\"\n SELECT r FROM Claroline\\CoreBundle\\Entity\\Resource\\Revision r\n JOIN r.text t2\n WHERE r.version = (SELECT MAX(r2.version) FROM Claroline\\CoreBundle\\Enti...
Returns the last revision of a text. @param Text $text @return Revision
[ "Returns", "the", "last", "revision", "of", "a", "text", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/RevisionRepository.php#L26-L38
train
claroline/Distribution
main/core/Manager/Resource/MaskManager.php
MaskManager.removeMask
public function removeMask(ResourceType $resourceType, $name) { $toRemove = $this->getDecoder($resourceType, $name); if (!empty($toRemove)) { $this->om->remove($toRemove); } }
php
public function removeMask(ResourceType $resourceType, $name) { $toRemove = $this->getDecoder($resourceType, $name); if (!empty($toRemove)) { $this->om->remove($toRemove); } }
[ "public", "function", "removeMask", "(", "ResourceType", "$", "resourceType", ",", "$", "name", ")", "{", "$", "toRemove", "=", "$", "this", "->", "getDecoder", "(", "$", "resourceType", ",", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", ...
Retrieves and removes a mask decoder. @param ResourceType $resourceType @param string $name
[ "Retrieves", "and", "removes", "a", "mask", "decoder", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/MaskManager.php#L165-L171
train
claroline/Distribution
main/core/Manager/Resource/MaskManager.php
MaskManager.renameMask
public function renameMask(ResourceType $resourceType, $currentName, $newName) { $toRename = $this->getDecoder($resourceType, $currentName); if (!empty($toRename)) { $toRename->setName($newName); $this->om->persist($toRename); } }
php
public function renameMask(ResourceType $resourceType, $currentName, $newName) { $toRename = $this->getDecoder($resourceType, $currentName); if (!empty($toRename)) { $toRename->setName($newName); $this->om->persist($toRename); } }
[ "public", "function", "renameMask", "(", "ResourceType", "$", "resourceType", ",", "$", "currentName", ",", "$", "newName", ")", "{", "$", "toRename", "=", "$", "this", "->", "getDecoder", "(", "$", "resourceType", ",", "$", "currentName", ")", ";", "if", ...
Retrieves and renames a mask decoder. @param ResourceType $resourceType @param string $currentName @param string $newName
[ "Retrieves", "and", "renames", "a", "mask", "decoder", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/MaskManager.php#L180-L187
train
claroline/Distribution
main/core/Manager/Resource/MaskManager.php
MaskManager.getPermissionMap
public function getPermissionMap(ResourceType $type) { /** @var MaskDecoder[] $decoders */ $decoders = $this->maskRepo->findBy(['resourceType' => $type]); $permsMap = []; foreach ($decoders as $decoder) { $permsMap[$decoder->getValue()] = $decoder->getName(); } return $permsMap; }
php
public function getPermissionMap(ResourceType $type) { /** @var MaskDecoder[] $decoders */ $decoders = $this->maskRepo->findBy(['resourceType' => $type]); $permsMap = []; foreach ($decoders as $decoder) { $permsMap[$decoder->getValue()] = $decoder->getName(); } return $permsMap; }
[ "public", "function", "getPermissionMap", "(", "ResourceType", "$", "type", ")", "{", "/** @var MaskDecoder[] $decoders */", "$", "decoders", "=", "$", "this", "->", "maskRepo", "->", "findBy", "(", "[", "'resourceType'", "=>", "$", "type", "]", ")", ";", "$",...
Returns an array containing the possible permission for a resource type. @param ResourceType $type @return array
[ "Returns", "an", "array", "containing", "the", "possible", "permission", "for", "a", "resource", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/MaskManager.php#L196-L207
train
claroline/Distribution
plugin/team/Serializer/WorkspaceTeamParametersSerializer.php
WorkspaceTeamParametersSerializer.serialize
public function serialize(WorkspaceTeamParameters $parameters) { $serialized = [ 'id' => $parameters->getUuid(), 'selfRegistration' => $parameters->isSelfRegistration(), 'selfUnregistration' => $parameters->isSelfUnregistration(), 'publicDirectory' => $parameters->isPublic(), 'deletableDirectory' => $parameters->isDirDeletable(), 'allowedTeams' => $parameters->getMaxTeams(), 'workspace' => [ 'uuid' => $parameters->getWorkspace()->getUuid(), ], ]; return $serialized; }
php
public function serialize(WorkspaceTeamParameters $parameters) { $serialized = [ 'id' => $parameters->getUuid(), 'selfRegistration' => $parameters->isSelfRegistration(), 'selfUnregistration' => $parameters->isSelfUnregistration(), 'publicDirectory' => $parameters->isPublic(), 'deletableDirectory' => $parameters->isDirDeletable(), 'allowedTeams' => $parameters->getMaxTeams(), 'workspace' => [ 'uuid' => $parameters->getWorkspace()->getUuid(), ], ]; return $serialized; }
[ "public", "function", "serialize", "(", "WorkspaceTeamParameters", "$", "parameters", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "parameters", "->", "getUuid", "(", ")", ",", "'selfRegistration'", "=>", "$", "parameters", "->", "isSelfRegistration...
Serializes a WorkspaceTeamParameters entity for the JSON api. @param WorkspaceTeamParameters $parameters @return array - the serialized representation of the WorkspaceTeamParameters entity
[ "Serializes", "a", "WorkspaceTeamParameters", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Serializer/WorkspaceTeamParametersSerializer.php#L45-L60
train
claroline/Distribution
main/installation/Manager/InstallationManager.php
InstallationManager.end
public function end(InstallableInterface $bundle, $currentVersion = null, $targetVersion = null) { $additionalInstaller = $this->getAdditionalInstaller($bundle); if ($additionalInstaller) { $additionalInstaller->end($currentVersion, $targetVersion); } }
php
public function end(InstallableInterface $bundle, $currentVersion = null, $targetVersion = null) { $additionalInstaller = $this->getAdditionalInstaller($bundle); if ($additionalInstaller) { $additionalInstaller->end($currentVersion, $targetVersion); } }
[ "public", "function", "end", "(", "InstallableInterface", "$", "bundle", ",", "$", "currentVersion", "=", "null", ",", "$", "targetVersion", "=", "null", ")", "{", "$", "additionalInstaller", "=", "$", "this", "->", "getAdditionalInstaller", "(", "$", "bundle"...
It allows us to override some stuff and it's just easier that way.
[ "It", "allows", "us", "to", "override", "some", "stuff", "and", "it", "s", "just", "easier", "that", "way", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/installation/Manager/InstallationManager.php#L140-L147
train
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.retrieveTag
protected function retrieveTag($name) { $tag = $this->objectManager->getRepository('IcapBlogBundle:Tag')->findOneByName($name); if (!$tag) { //let's look if it's scheduled for an Insert... $tag = $this->getTagFromIdentityMapOrScheduledForInsert($name); if (!$tag) { $tag = new Tag(); $tag->setName($name); $this->objectManager->persist($tag); } } return $tag; }
php
protected function retrieveTag($name) { $tag = $this->objectManager->getRepository('IcapBlogBundle:Tag')->findOneByName($name); if (!$tag) { //let's look if it's scheduled for an Insert... $tag = $this->getTagFromIdentityMapOrScheduledForInsert($name); if (!$tag) { $tag = new Tag(); $tag->setName($name); $this->objectManager->persist($tag); } } return $tag; }
[ "protected", "function", "retrieveTag", "(", "$", "name", ")", "{", "$", "tag", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'IcapBlogBundle:Tag'", ")", "->", "findOneByName", "(", "$", "name", ")", ";", "if", "(", "!", "$", "tag...
This method is used by the workspace import function. @param string $name @return Tag
[ "This", "method", "is", "used", "by", "the", "workspace", "import", "function", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L315-L331
train
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.getBlogByIdOrUuid
public function getBlogByIdOrUuid($id) { if (preg_match('/^\d+$/', $id)) { $blog = $this->repo->findOneBy([ 'id' => $id, ]); } else { $blog = $this->repo->findOneBy([ 'uuid' => $id, ]); } return $blog; }
php
public function getBlogByIdOrUuid($id) { if (preg_match('/^\d+$/', $id)) { $blog = $this->repo->findOneBy([ 'id' => $id, ]); } else { $blog = $this->repo->findOneBy([ 'uuid' => $id, ]); } return $blog; }
[ "public", "function", "getBlogByIdOrUuid", "(", "$", "id", ")", "{", "if", "(", "preg_match", "(", "'/^\\d+$/'", ",", "$", "id", ")", ")", "{", "$", "blog", "=", "$", "this", "->", "repo", "->", "findOneBy", "(", "[", "'id'", "=>", "$", "id", ",", ...
Get blog by its ID or UUID. @param string $id @return Blog
[ "Get", "blog", "by", "its", "ID", "or", "UUID", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L455-L468
train
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.getTags
public function getTags($blog, array $postData = []) { $postUuids = array_column($postData, 'id'); $event = new GenericDataEvent([ 'class' => 'Icap\BlogBundle\Entity\Post', 'ids' => $postUuids, 'frequency' => true, ]); $this->eventDispatcher->dispatch( 'claroline_retrieve_used_tags_by_class_and_ids', $event ); $tags = $event->getResponse(); //only keep max tag number, if defined if ($blog->getOptions()->isTagTopMode() && $blog->getOptions()->getMaxTag() > 0) { arsort($tags); $tags = array_slice($tags, 0, $blog->getOptions()->getMaxTag()); } return (object) $tags; }
php
public function getTags($blog, array $postData = []) { $postUuids = array_column($postData, 'id'); $event = new GenericDataEvent([ 'class' => 'Icap\BlogBundle\Entity\Post', 'ids' => $postUuids, 'frequency' => true, ]); $this->eventDispatcher->dispatch( 'claroline_retrieve_used_tags_by_class_and_ids', $event ); $tags = $event->getResponse(); //only keep max tag number, if defined if ($blog->getOptions()->isTagTopMode() && $blog->getOptions()->getMaxTag() > 0) { arsort($tags); $tags = array_slice($tags, 0, $blog->getOptions()->getMaxTag()); } return (object) $tags; }
[ "public", "function", "getTags", "(", "$", "blog", ",", "array", "$", "postData", "=", "[", "]", ")", "{", "$", "postUuids", "=", "array_column", "(", "$", "postData", ",", "'id'", ")", ";", "$", "event", "=", "new", "GenericDataEvent", "(", "[", "'c...
Get tags used in the blog. @param Blog $blog @param array $posts @return array
[ "Get", "tags", "used", "in", "the", "blog", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L478-L501
train
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.replaceMemberAuthor
public function replaceMemberAuthor(User $from, User $to) { $fromIsMember = false; $froms = $this->memberRepo->findByUser($from); if (count($froms) > 0) { $fromIsMember = true; } $toIsMember = false; $tos = $this->memberRepo->findByUser($to); if (count($tos) > 0) { $toIsMember = true; } if ($toIsMember && $fromIsMember) { //user kept already have its member entry, delete the old one foreach ($froms as $member) { $this->objectManager->remove($member); } $this->objectManager->flush(); } elseif (!$toIsMember && $fromIsMember) { //update entry for kept user foreach ($froms as $member) { $member->setUser($to); } $this->objectManager->flush(); } }
php
public function replaceMemberAuthor(User $from, User $to) { $fromIsMember = false; $froms = $this->memberRepo->findByUser($from); if (count($froms) > 0) { $fromIsMember = true; } $toIsMember = false; $tos = $this->memberRepo->findByUser($to); if (count($tos) > 0) { $toIsMember = true; } if ($toIsMember && $fromIsMember) { //user kept already have its member entry, delete the old one foreach ($froms as $member) { $this->objectManager->remove($member); } $this->objectManager->flush(); } elseif (!$toIsMember && $fromIsMember) { //update entry for kept user foreach ($froms as $member) { $member->setUser($to); } $this->objectManager->flush(); } }
[ "public", "function", "replaceMemberAuthor", "(", "User", "$", "from", ",", "User", "$", "to", ")", "{", "$", "fromIsMember", "=", "false", ";", "$", "froms", "=", "$", "this", "->", "memberRepo", "->", "findByUser", "(", "$", "from", ")", ";", "if", ...
Find all member for a given user and the replace him by another. @param User $from @param User $to
[ "Find", "all", "member", "for", "a", "given", "user", "and", "the", "replace", "him", "by", "another", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L509-L536
train
claroline/Distribution
plugin/website/Manager/WebsiteManager.php
WebsiteManager.copyWebsite
public function copyWebsite(Website $orgWebsite, Website $newWebsite) { $orgRoot = $orgWebsite->getRoot(); $orgOptions = $orgWebsite->getOptions(); $websitePages = $this->websitePageRepository->children($orgRoot); array_unshift($websitePages, $orgRoot); $newWebsitePagesMap = []; foreach ($websitePages as $websitePage) { $newWebsitePage = new WebsitePage(); $newWebsitePage->setWebsite($newWebsite); $newWebsitePage->importFromArray($websitePage->exportToArray()); if ($websitePage->isRoot()) { $newWebsite->setRoot($newWebsitePage); $this->om->persist($newWebsite); } else { $newWebsitePageParent = $newWebsitePagesMap[$websitePage->getParent()->getId()]; $newWebsitePage->setParent($newWebsitePageParent); $this->websitePageRepository->persistAsLastChildOf($newWebsitePage, $newWebsitePageParent); } if ($websitePage->getIsHomepage()) { $newWebsite->setHomePage($newWebsitePage); } $newWebsitePagesMap[$websitePage->getId()] = $newWebsitePage; } $this->om->flush(); $newWebsite->getOptions()->importFromArray( $this->webDir, $orgOptions->exportToArray($this->webDir), $this->webDir.DIRECTORY_SEPARATOR.$orgOptions->getUploadDir() ); return $newWebsite; }
php
public function copyWebsite(Website $orgWebsite, Website $newWebsite) { $orgRoot = $orgWebsite->getRoot(); $orgOptions = $orgWebsite->getOptions(); $websitePages = $this->websitePageRepository->children($orgRoot); array_unshift($websitePages, $orgRoot); $newWebsitePagesMap = []; foreach ($websitePages as $websitePage) { $newWebsitePage = new WebsitePage(); $newWebsitePage->setWebsite($newWebsite); $newWebsitePage->importFromArray($websitePage->exportToArray()); if ($websitePage->isRoot()) { $newWebsite->setRoot($newWebsitePage); $this->om->persist($newWebsite); } else { $newWebsitePageParent = $newWebsitePagesMap[$websitePage->getParent()->getId()]; $newWebsitePage->setParent($newWebsitePageParent); $this->websitePageRepository->persistAsLastChildOf($newWebsitePage, $newWebsitePageParent); } if ($websitePage->getIsHomepage()) { $newWebsite->setHomePage($newWebsitePage); } $newWebsitePagesMap[$websitePage->getId()] = $newWebsitePage; } $this->om->flush(); $newWebsite->getOptions()->importFromArray( $this->webDir, $orgOptions->exportToArray($this->webDir), $this->webDir.DIRECTORY_SEPARATOR.$orgOptions->getUploadDir() ); return $newWebsite; }
[ "public", "function", "copyWebsite", "(", "Website", "$", "orgWebsite", ",", "Website", "$", "newWebsite", ")", "{", "$", "orgRoot", "=", "$", "orgWebsite", "->", "getRoot", "(", ")", ";", "$", "orgOptions", "=", "$", "orgWebsite", "->", "getOptions", "(",...
Copies website to a location. @param Website $orgWebsite @return Website
[ "Copies", "website", "to", "a", "location", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/website/Manager/WebsiteManager.php#L79-L113
train
claroline/Distribution
main/core/API/Serializer/User/OrganizationSerializer.php
OrganizationSerializer.serialize
public function serialize(Organization $organization, array $options = []) { $data = [ 'id' => $organization->getUuid(), 'name' => $organization->getName(), 'code' => $organization->getCode(), 'email' => $organization->getEmail(), 'type' => $organization->getType(), 'parent' => !empty($organization->getParent()) ? [ 'id' => $organization->getParent()->getUuid(), 'name' => $organization->getParent()->getName(), ] : null, 'meta' => [ 'default' => $organization->getDefault(), 'position' => $organization->getPosition(), ], 'managers' => array_map(function (User $administrator) { return [ 'id' => $administrator->getId(), 'username' => $administrator->getUsername(), ]; }, $organization->getAdministrators()->toArray()), 'locations' => array_map(function (Location $location) { return [ 'id' => $location->getId(), 'name' => $location->getName(), ]; }, $organization->getLocations()->toArray()), ]; if (in_array(Options::IS_RECURSIVE, $options)) { $data['children'] = array_map(function (Organization $child) use ($options) { return $this->serialize($child, $options); }, $organization->getChildren()->toArray()); } return $data; }
php
public function serialize(Organization $organization, array $options = []) { $data = [ 'id' => $organization->getUuid(), 'name' => $organization->getName(), 'code' => $organization->getCode(), 'email' => $organization->getEmail(), 'type' => $organization->getType(), 'parent' => !empty($organization->getParent()) ? [ 'id' => $organization->getParent()->getUuid(), 'name' => $organization->getParent()->getName(), ] : null, 'meta' => [ 'default' => $organization->getDefault(), 'position' => $organization->getPosition(), ], 'managers' => array_map(function (User $administrator) { return [ 'id' => $administrator->getId(), 'username' => $administrator->getUsername(), ]; }, $organization->getAdministrators()->toArray()), 'locations' => array_map(function (Location $location) { return [ 'id' => $location->getId(), 'name' => $location->getName(), ]; }, $organization->getLocations()->toArray()), ]; if (in_array(Options::IS_RECURSIVE, $options)) { $data['children'] = array_map(function (Organization $child) use ($options) { return $this->serialize($child, $options); }, $organization->getChildren()->toArray()); } return $data; }
[ "public", "function", "serialize", "(", "Organization", "$", "organization", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'id'", "=>", "$", "organization", "->", "getUuid", "(", ")", ",", "'name'", "=>", "$", "organiza...
Serializes an Organization entity for the JSON api. @param Organization $organization - the organization to serialize @param array $options @return array - the serialized representation of the workspace
[ "Serializes", "an", "Organization", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/User/OrganizationSerializer.php#L46-L83
train
claroline/Distribution
plugin/wiki/Entity/Section.php
Section.setNewActiveContributionToSection
public function setNewActiveContributionToSection(User $user = null) { $oldActiveContribution = $this->getActiveContribution(); $newActiveContribution = new Contribution(); $newActiveContribution->setSection($this); if (null === $oldActiveContribution) { if (null === $user) { $user = $this->getAuthor(); } } else { if (null === $user) { $user = $oldActiveContribution->getContributor(); } if (null === $user) { $user = $this->getAuthor(); } $newActiveContribution->setTitle($oldActiveContribution->getTitle()); $newActiveContribution->setText($oldActiveContribution->getText()); } $newActiveContribution->setContributor($user); $this->setActiveContribution($newActiveContribution); }
php
public function setNewActiveContributionToSection(User $user = null) { $oldActiveContribution = $this->getActiveContribution(); $newActiveContribution = new Contribution(); $newActiveContribution->setSection($this); if (null === $oldActiveContribution) { if (null === $user) { $user = $this->getAuthor(); } } else { if (null === $user) { $user = $oldActiveContribution->getContributor(); } if (null === $user) { $user = $this->getAuthor(); } $newActiveContribution->setTitle($oldActiveContribution->getTitle()); $newActiveContribution->setText($oldActiveContribution->getText()); } $newActiveContribution->setContributor($user); $this->setActiveContribution($newActiveContribution); }
[ "public", "function", "setNewActiveContributionToSection", "(", "User", "$", "user", "=", "null", ")", "{", "$", "oldActiveContribution", "=", "$", "this", "->", "getActiveContribution", "(", ")", ";", "$", "newActiveContribution", "=", "new", "Contribution", "(",...
Creates a new non persisted contribution and sets it as section's active contribution. @param \Claroline\CoreBundle\Entity\User $user
[ "Creates", "a", "new", "non", "persisted", "contribution", "and", "sets", "it", "as", "section", "s", "active", "contribution", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/wiki/Entity/Section.php#L453-L474
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.serialize
public function serialize(ClozeQuestion $clozeQuestion, array $options = []) { $serialized = [ 'text' => $clozeQuestion->getText(), 'holes' => $this->serializeHoles($clozeQuestion), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($clozeQuestion, $options); } return $serialized; }
php
public function serialize(ClozeQuestion $clozeQuestion, array $options = []) { $serialized = [ 'text' => $clozeQuestion->getText(), 'holes' => $this->serializeHoles($clozeQuestion), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($clozeQuestion, $options); } return $serialized; }
[ "public", "function", "serialize", "(", "ClozeQuestion", "$", "clozeQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'text'", "=>", "$", "clozeQuestion", "->", "getText", "(", ")", ",", "'holes'", "=>", "$",...
Converts a Cloze question into a JSON-encodable structure. @param ClozeQuestion $clozeQuestion @param array $options @return array
[ "Converts", "a", "Cloze", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L48-L60
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.deserialize
public function deserialize($data, ClozeQuestion $clozeQuestion = null, array $options = []) { if (empty($clozeQuestion)) { $clozeQuestion = new ClozeQuestion(); } $this->sipe('text', 'setText', $data, $clozeQuestion); $this->deserializeHoles($clozeQuestion, $data['holes'], $data['solutions'], $options); return $clozeQuestion; }
php
public function deserialize($data, ClozeQuestion $clozeQuestion = null, array $options = []) { if (empty($clozeQuestion)) { $clozeQuestion = new ClozeQuestion(); } $this->sipe('text', 'setText', $data, $clozeQuestion); $this->deserializeHoles($clozeQuestion, $data['holes'], $data['solutions'], $options); return $clozeQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "ClozeQuestion", "$", "clozeQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "clozeQuestion", ")", ")", "{", "$", "clozeQuestion", "...
Converts raw data into a Cloze question entity. @param array $data @param ClozeQuestion $clozeQuestion @param array $options @return ClozeQuestion
[ "Converts", "raw", "data", "into", "a", "Cloze", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L71-L81
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.deserializeHoles
private function deserializeHoles(ClozeQuestion $clozeQuestion, array $holes, array $solutions, array $options = []) { $holeEntities = $clozeQuestion->getHoles()->toArray(); foreach ($holes as $holeData) { $hole = null; // Searches for an existing hole entity. foreach ($holeEntities as $entityIndex => $entityHole) { /** @var Hole $entityHole */ if ($entityHole->getUuid() === $holeData['id']) { $hole = $entityHole; unset($holeEntities[$entityIndex]); break; } } $hole = $hole ?: new Hole(); $hole->setUuid($holeData['id']); if (!empty($holeData['size'])) { $hole->setSize($holeData['size']); } if (!empty($holeData['choices'])) { $hole->setSelector(true); } else { $hole->setSelector(false); } foreach ($solutions as $solution) { if ($solution['holeId'] === $holeData['id']) { $this->deserializeHoleKeywords($hole, $solution['answers'], $options); break; } } $clozeQuestion->addHole($hole); } // Remaining holes are no longer in the Question foreach ($holeEntities as $holeToRemove) { $clozeQuestion->removeHole($holeToRemove); } }
php
private function deserializeHoles(ClozeQuestion $clozeQuestion, array $holes, array $solutions, array $options = []) { $holeEntities = $clozeQuestion->getHoles()->toArray(); foreach ($holes as $holeData) { $hole = null; // Searches for an existing hole entity. foreach ($holeEntities as $entityIndex => $entityHole) { /** @var Hole $entityHole */ if ($entityHole->getUuid() === $holeData['id']) { $hole = $entityHole; unset($holeEntities[$entityIndex]); break; } } $hole = $hole ?: new Hole(); $hole->setUuid($holeData['id']); if (!empty($holeData['size'])) { $hole->setSize($holeData['size']); } if (!empty($holeData['choices'])) { $hole->setSelector(true); } else { $hole->setSelector(false); } foreach ($solutions as $solution) { if ($solution['holeId'] === $holeData['id']) { $this->deserializeHoleKeywords($hole, $solution['answers'], $options); break; } } $clozeQuestion->addHole($hole); } // Remaining holes are no longer in the Question foreach ($holeEntities as $holeToRemove) { $clozeQuestion->removeHole($holeToRemove); } }
[ "private", "function", "deserializeHoles", "(", "ClozeQuestion", "$", "clozeQuestion", ",", "array", "$", "holes", ",", "array", "$", "solutions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "holeEntities", "=", "$", "clozeQuestion", "->", ...
Deserializes Question holes. @param ClozeQuestion $clozeQuestion @param array $holes @param array $solutions @param array $options
[ "Deserializes", "Question", "holes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L122-L167
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.deserializeHoleKeywords
private function deserializeHoleKeywords(Hole $hole, array $keywords, array $options = []) { $updatedKeywords = $this->keywordSerializer->deserializeCollection($keywords, $hole->getKeywords()->toArray(), $options); $hole->setKeywords($updatedKeywords); }
php
private function deserializeHoleKeywords(Hole $hole, array $keywords, array $options = []) { $updatedKeywords = $this->keywordSerializer->deserializeCollection($keywords, $hole->getKeywords()->toArray(), $options); $hole->setKeywords($updatedKeywords); }
[ "private", "function", "deserializeHoleKeywords", "(", "Hole", "$", "hole", ",", "array", "$", "keywords", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "updatedKeywords", "=", "$", "this", "->", "keywordSerializer", "->", "deserializeCollection"...
Deserializes the keywords of a Hole. @param Hole $hole @param array $keywords @param array $options
[ "Deserializes", "the", "keywords", "of", "a", "Hole", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L176-L180
train
claroline/Distribution
plugin/exo/Library/Item/Definition/GraphicDefinition.php
GraphicDefinition.refreshIdentifiers
public function refreshIdentifiers(AbstractItem $item) { // generate image id $item->getImage()->refreshUuid(); /** @var Area $area */ foreach ($item->getAreas() as $area) { $area->refreshUuid(); } }
php
public function refreshIdentifiers(AbstractItem $item) { // generate image id $item->getImage()->refreshUuid(); /** @var Area $area */ foreach ($item->getAreas() as $area) { $area->refreshUuid(); } }
[ "public", "function", "refreshIdentifiers", "(", "AbstractItem", "$", "item", ")", "{", "// generate image id", "$", "item", "->", "getImage", "(", ")", "->", "refreshUuid", "(", ")", ";", "/** @var Area $area */", "foreach", "(", "$", "item", "->", "getAreas", ...
Refreshes image and areas UUIDs. @param GraphicQuestion $item
[ "Refreshes", "image", "and", "areas", "UUIDs", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/GraphicDefinition.php#L191-L200
train
claroline/Distribution
main/core/Controller/APINew/Resource/LogController.php
LogController.getResourceNodeFilteredQuery
private function getResourceNodeFilteredQuery(Request $request, ResourceNode $node) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['resourceNode' => $node]); return $query; }
php
private function getResourceNodeFilteredQuery(Request $request, ResourceNode $node) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['resourceNode' => $node]); return $query; }
[ "private", "function", "getResourceNodeFilteredQuery", "(", "Request", "$", "request", ",", "ResourceNode", "$", "node", ")", "{", "$", "query", "=", "$", "request", "->", "query", "->", "all", "(", ")", ";", "$", "hiddenFilters", "=", "isset", "(", "$", ...
Add resource node filter to request. @param Request $request @param ResourceNode $node @return array
[ "Add", "resource", "node", "filter", "to", "request", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Resource/LogController.php#L236-L243
train
claroline/Distribution
main/core/Form/DataTransformer/DateRangeToTextTransformer.php
DateRangeToTextTransformer.reverseTransform
public function reverseTransform($string) { $startDate = time(); $endDate = time(); $separator = $this->translator->trans('date_range.separator', array(), 'platform'); if ($string != null) { $array = explode(' '.$separator.' ', $string); if (array_key_exists(0, $array)) { $dateFormat = $this->translator->trans('date_range.format', array(), 'platform'); $startDate = $endDate = \DateTime::createFromFormat($dateFormat, $array[0])->getTimestamp(); if (array_key_exists(1, $array)) { $endDate = \DateTime::createFromFormat($dateFormat, $array[1])->getTimestamp(); } } return array($startDate, $endDate); } }
php
public function reverseTransform($string) { $startDate = time(); $endDate = time(); $separator = $this->translator->trans('date_range.separator', array(), 'platform'); if ($string != null) { $array = explode(' '.$separator.' ', $string); if (array_key_exists(0, $array)) { $dateFormat = $this->translator->trans('date_range.format', array(), 'platform'); $startDate = $endDate = \DateTime::createFromFormat($dateFormat, $array[0])->getTimestamp(); if (array_key_exists(1, $array)) { $endDate = \DateTime::createFromFormat($dateFormat, $array[1])->getTimestamp(); } } return array($startDate, $endDate); } }
[ "public", "function", "reverseTransform", "(", "$", "string", ")", "{", "$", "startDate", "=", "time", "(", ")", ";", "$", "endDate", "=", "time", "(", ")", ";", "$", "separator", "=", "$", "this", "->", "translator", "->", "trans", "(", "'date_range.s...
Transforms a string to an array of 2 dates. @param string $string @return array of strings (names for tags)
[ "Transforms", "a", "string", "to", "an", "array", "of", "2", "dates", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Form/DataTransformer/DateRangeToTextTransformer.php#L62-L82
train
claroline/Distribution
main/core/Controller/LocaleController.php
LocaleController.changeAction
public function changeAction(Request $request, $locale) { if (($token = $this->tokenStorage->getToken()) && 'anon.' !== $token->getUser()) { $this->localeManager->setUserLocale($locale); } $request->setLocale($locale); $request->getSession()->set('_locale', $locale); return new RedirectResponse( $request->headers->get('referer') ); }
php
public function changeAction(Request $request, $locale) { if (($token = $this->tokenStorage->getToken()) && 'anon.' !== $token->getUser()) { $this->localeManager->setUserLocale($locale); } $request->setLocale($locale); $request->getSession()->set('_locale', $locale); return new RedirectResponse( $request->headers->get('referer') ); }
[ "public", "function", "changeAction", "(", "Request", "$", "request", ",", "$", "locale", ")", "{", "if", "(", "(", "$", "token", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ")", "&&", "'anon.'", "!==", "$", "token", "->", "ge...
Change locale. @EXT\Route("/change/{locale}", name="claroline_locale_change") @param Request $request @param string $locale @return RedirectResponse
[ "Change", "locale", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/LocaleController.php#L75-L87
train
claroline/Distribution
main/app/API/Transfer/Adapter/Explain/Csv/ExplanationBuilder.php
ExplanationBuilder.explainOneOf
private function explainOneOf($data, $explanation, $currentPath, $isArray = false) { $explanation->addOneOf(array_map(function ($oneOf) use ($currentPath, $isArray) { return $this->explainSchema($oneOf, null, $currentPath, $isArray); }, $data->oneOf), 'an auto generated descr', true); }
php
private function explainOneOf($data, $explanation, $currentPath, $isArray = false) { $explanation->addOneOf(array_map(function ($oneOf) use ($currentPath, $isArray) { return $this->explainSchema($oneOf, null, $currentPath, $isArray); }, $data->oneOf), 'an auto generated descr', true); }
[ "private", "function", "explainOneOf", "(", "$", "data", ",", "$", "explanation", ",", "$", "currentPath", ",", "$", "isArray", "=", "false", ")", "{", "$", "explanation", "->", "addOneOf", "(", "array_map", "(", "function", "(", "$", "oneOf", ")", "use"...
A oneOf is simply an other schema that needs to be explained.
[ "A", "oneOf", "is", "simply", "an", "other", "schema", "that", "needs", "to", "be", "explained", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Transfer/Adapter/Explain/Csv/ExplanationBuilder.php#L54-L59
train
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.createRights
public function createRights(ResourceNode $node, array $rights = [], $withDefault = true) { foreach ($rights as $data) { $resourceTypes = $this->checkResourceTypes($data['create']); $this->rightsManager->create($data, $data['role'], $node, false, $resourceTypes); } if ($withDefault) { if (!array_key_exists('ROLE_ANONYMOUS', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_ANONYMOUS']), $node, false, [] ); } if (!array_key_exists('ROLE_USER', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_USER']), $node, false, [] ); } } }
php
public function createRights(ResourceNode $node, array $rights = [], $withDefault = true) { foreach ($rights as $data) { $resourceTypes = $this->checkResourceTypes($data['create']); $this->rightsManager->create($data, $data['role'], $node, false, $resourceTypes); } if ($withDefault) { if (!array_key_exists('ROLE_ANONYMOUS', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_ANONYMOUS']), $node, false, [] ); } if (!array_key_exists('ROLE_USER', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_USER']), $node, false, [] ); } } }
[ "public", "function", "createRights", "(", "ResourceNode", "$", "node", ",", "array", "$", "rights", "=", "[", "]", ",", "$", "withDefault", "=", "true", ")", "{", "foreach", "(", "$", "rights", "as", "$", "data", ")", "{", "$", "resourceTypes", "=", ...
Create the rights for a node. array $rights should be defined that way: array('ROLE_WS_XXX' => array('open' => true, 'edit' => false, ... 'create' => array('directory', ...), 'role' => $entity)) @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node @param array $rights @param bool $withDefault
[ "Create", "the", "rights", "for", "a", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L352-L378
train
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.setPublishedStatus
public function setPublishedStatus(array $nodes, $arePublished, $isRecursive = false) { $this->om->startFlushSuite(); foreach ($nodes as $node) { $node->setPublished($arePublished); $this->om->persist($node); //do it on every children aswell if ($isRecursive) { $descendants = $this->resourceNodeRepo->findDescendants($node, true); $this->setPublishedStatus($descendants, $arePublished, false); } //only warn for the roots $this->dispatcher->dispatch( "publication_change_{$node->getResourceType()->getName()}", 'Resource\PublicationChange', [$this->getResourceFromNode($node)] ); $usersToNotify = $node->getWorkspace() && !$node->getWorkspace()->isDisabledNotifications() ? $this->container->get('claroline.manager.user_manager')->getUsersByWorkspaces([$node->getWorkspace()], null, null, false) : []; $this->dispatcher->dispatch('log', 'Log\LogResourcePublish', [$node, $usersToNotify]); } $this->om->endFlushSuite(); return $nodes; }
php
public function setPublishedStatus(array $nodes, $arePublished, $isRecursive = false) { $this->om->startFlushSuite(); foreach ($nodes as $node) { $node->setPublished($arePublished); $this->om->persist($node); //do it on every children aswell if ($isRecursive) { $descendants = $this->resourceNodeRepo->findDescendants($node, true); $this->setPublishedStatus($descendants, $arePublished, false); } //only warn for the roots $this->dispatcher->dispatch( "publication_change_{$node->getResourceType()->getName()}", 'Resource\PublicationChange', [$this->getResourceFromNode($node)] ); $usersToNotify = $node->getWorkspace() && !$node->getWorkspace()->isDisabledNotifications() ? $this->container->get('claroline.manager.user_manager')->getUsersByWorkspaces([$node->getWorkspace()], null, null, false) : []; $this->dispatcher->dispatch('log', 'Log\LogResourcePublish', [$node, $usersToNotify]); } $this->om->endFlushSuite(); return $nodes; }
[ "public", "function", "setPublishedStatus", "(", "array", "$", "nodes", ",", "$", "arePublished", ",", "$", "isRecursive", "=", "false", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", ...
Sets the publication flag of a collection of nodes. @param ResourceNode[] $nodes @param bool $arePublished @param bool $isRecursive @return ResourceNode[]
[ "Sets", "the", "publication", "flag", "of", "a", "collection", "of", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L599-L629
train
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.rename
public function rename(ResourceNode $node, $name, $noFlush = false) { $node->setName($name); $name = $this->getUniqueName($node, $node->getParent()); $node->setName($name); $this->om->persist($node); $this->logChangeSet($node); if (!$noFlush) { $this->om->flush(); } return $node; }
php
public function rename(ResourceNode $node, $name, $noFlush = false) { $node->setName($name); $name = $this->getUniqueName($node, $node->getParent()); $node->setName($name); $this->om->persist($node); $this->logChangeSet($node); if (!$noFlush) { $this->om->flush(); } return $node; }
[ "public", "function", "rename", "(", "ResourceNode", "$", "node", ",", "$", "name", ",", "$", "noFlush", "=", "false", ")", "{", "$", "node", "->", "setName", "(", "$", "name", ")", ";", "$", "name", "=", "$", "this", "->", "getUniqueName", "(", "$...
Renames a node. @param ResourceNode $node @param string $name @param bool $noFlush @return ResourceNode @deprecated
[ "Renames", "a", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L958-L971
train
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.addPublicFileDirectory
public function addPublicFileDirectory(Workspace $workspace) { $directory = new Directory(); $dirName = $this->translator->trans('my_public_documents', [], 'platform'); $directory->setName($dirName); $directory->setUploadDestination(true); $parent = $this->getNodeScheduledForInsert($workspace, $workspace->getName()); if (!$parent) { $parent = $this->resourceNodeRepo->findOneBy(['workspace' => $workspace->getId(), 'parent' => $parent]); } $role = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); /** @var Directory $publicDir */ $publicDir = $this->create( $directory, $this->getResourceTypeByName('directory'), $workspace->getCreator(), $workspace, $parent, null, ['ROLE_ANONYMOUS' => ['open' => true, 'export' => true, 'create' => [], 'role' => $role]], true ); return $publicDir; }
php
public function addPublicFileDirectory(Workspace $workspace) { $directory = new Directory(); $dirName = $this->translator->trans('my_public_documents', [], 'platform'); $directory->setName($dirName); $directory->setUploadDestination(true); $parent = $this->getNodeScheduledForInsert($workspace, $workspace->getName()); if (!$parent) { $parent = $this->resourceNodeRepo->findOneBy(['workspace' => $workspace->getId(), 'parent' => $parent]); } $role = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); /** @var Directory $publicDir */ $publicDir = $this->create( $directory, $this->getResourceTypeByName('directory'), $workspace->getCreator(), $workspace, $parent, null, ['ROLE_ANONYMOUS' => ['open' => true, 'export' => true, 'create' => [], 'role' => $role]], true ); return $publicDir; }
[ "public", "function", "addPublicFileDirectory", "(", "Workspace", "$", "workspace", ")", "{", "$", "directory", "=", "new", "Directory", "(", ")", ";", "$", "dirName", "=", "$", "this", "->", "translator", "->", "trans", "(", "'my_public_documents'", ",", "[...
Adds the public file directory in a workspace. @todo move in workspace manager @param Workspace $workspace @return Directory
[ "Adds", "the", "public", "file", "directory", "in", "a", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L1296-L1321
train
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.restore
public function restore(ResourceNode $resourceNode) { $this->setActive($resourceNode); $workspace = $resourceNode->getWorkspace(); if ($workspace) { $root = $this->getWorkspaceRoot($workspace); $resourceNode->setParent($root); } $name = substr($resourceNode->getName(), 0, strrpos($resourceNode->getName(), '_')); $resourceNode->setName($name); $resourceNode->setName($this->getUniqueName($resourceNode)); $this->om->persist($resourceNode); $this->om->flush(); }
php
public function restore(ResourceNode $resourceNode) { $this->setActive($resourceNode); $workspace = $resourceNode->getWorkspace(); if ($workspace) { $root = $this->getWorkspaceRoot($workspace); $resourceNode->setParent($root); } $name = substr($resourceNode->getName(), 0, strrpos($resourceNode->getName(), '_')); $resourceNode->setName($name); $resourceNode->setName($this->getUniqueName($resourceNode)); $this->om->persist($resourceNode); $this->om->flush(); }
[ "public", "function", "restore", "(", "ResourceNode", "$", "resourceNode", ")", "{", "$", "this", "->", "setActive", "(", "$", "resourceNode", ")", ";", "$", "workspace", "=", "$", "resourceNode", "->", "getWorkspace", "(", ")", ";", "if", "(", "$", "wor...
Restores a soft deleted resource node. @param ResourceNode $resourceNode
[ "Restores", "a", "soft", "deleted", "resource", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L1459-L1472
train
claroline/Distribution
plugin/competency/Repository/CompetencyAbilityRepository.php
CompetencyAbilityRepository.countByAbility
public function countByAbility(Ability $ability) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.ability = :ability') ->setParameter(':ability', $ability) ->getQuery() ->getSingleScalarResult(); }
php
public function countByAbility(Ability $ability) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.ability = :ability') ->setParameter(':ability', $ability) ->getQuery() ->getSingleScalarResult(); }
[ "public", "function", "countByAbility", "(", "Ability", "$", "ability", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'ca'", ")", "->", "select", "(", "'COUNT(ca)'", ")", "->", "where", "(", "'ca.ability = :ability'", ")", "->", "setParame...
Returns the number of existing associations between competencies and a given ability. @param Ability $ability @return int
[ "Returns", "the", "number", "of", "existing", "associations", "between", "competencies", "and", "a", "given", "ability", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyAbilityRepository.php#L19-L27
train
claroline/Distribution
plugin/competency/Repository/CompetencyAbilityRepository.php
CompetencyAbilityRepository.countByCompetency
public function countByCompetency(Competency $competency) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.competency = :competency') ->setParameter(':competency', $competency) ->getQuery() ->getSingleScalarResult(); }
php
public function countByCompetency(Competency $competency) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.competency = :competency') ->setParameter(':competency', $competency) ->getQuery() ->getSingleScalarResult(); }
[ "public", "function", "countByCompetency", "(", "Competency", "$", "competency", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'ca'", ")", "->", "select", "(", "'COUNT(ca)'", ")", "->", "where", "(", "'ca.competency = :competency'", ")", "->...
Returns the number of abilities associated with a given competency. @param Competency $competency @return mixed
[ "Returns", "the", "number", "of", "abilities", "associated", "with", "a", "given", "competency", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyAbilityRepository.php#L36-L44
train
claroline/Distribution
plugin/competency/Repository/CompetencyAbilityRepository.php
CompetencyAbilityRepository.findOneByTerms
public function findOneByTerms(Competency $parent, Ability $ability) { $link = $this->findOneBy(['competency' => $parent, 'ability' => $ability]); if (!$link) { throw new \RuntimeException( "Competency {$parent->getId()} is not linked to ability {$ability->getId()}" ); } return $link; }
php
public function findOneByTerms(Competency $parent, Ability $ability) { $link = $this->findOneBy(['competency' => $parent, 'ability' => $ability]); if (!$link) { throw new \RuntimeException( "Competency {$parent->getId()} is not linked to ability {$ability->getId()}" ); } return $link; }
[ "public", "function", "findOneByTerms", "(", "Competency", "$", "parent", ",", "Ability", "$", "ability", ")", "{", "$", "link", "=", "$", "this", "->", "findOneBy", "(", "[", "'competency'", "=>", "$", "parent", ",", "'ability'", "=>", "$", "ability", "...
Returns the association between a competency and an ability. @param Competency $parent @param Ability $ability @return null|object @throws \Exception if the ability is not linked to the competency
[ "Returns", "the", "association", "between", "a", "competency", "and", "an", "ability", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyAbilityRepository.php#L56-L67
train
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.handleEvaluation
public function handleEvaluation(ResourceUserEvaluation $evaluation) { $this->clearCache(); $this->om->startFlushSuite(); $resource = $evaluation->getResourceNode(); $abilities = $this->abilityRepo->findByResource($resource); $user = $evaluation->getUser(); foreach ($abilities as $ability) { $this->setCompetencyProgressResourceId($ability, $user, $resource->getId()); $progress = $this->getAbilityProgress($ability, $user); if ($evaluation->isSuccessful()) { $progress->addPassedResource($resource); if (AbilityProgress::STATUS_ACQUIRED !== $progress->getStatus()) { if ($progress->getPassedResourceCount() >= $ability->getMinResourceCount()) { $progress->setStatus(AbilityProgress::STATUS_ACQUIRED); $this->om->forceFlush(); } else { $progress->setStatus(AbilityProgress::STATUS_PENDING); } } $this->computeCompetencyProgress($ability, $user); } else { $progress->addFailedResource($resource); } } $this->om->endFlushSuite(); }
php
public function handleEvaluation(ResourceUserEvaluation $evaluation) { $this->clearCache(); $this->om->startFlushSuite(); $resource = $evaluation->getResourceNode(); $abilities = $this->abilityRepo->findByResource($resource); $user = $evaluation->getUser(); foreach ($abilities as $ability) { $this->setCompetencyProgressResourceId($ability, $user, $resource->getId()); $progress = $this->getAbilityProgress($ability, $user); if ($evaluation->isSuccessful()) { $progress->addPassedResource($resource); if (AbilityProgress::STATUS_ACQUIRED !== $progress->getStatus()) { if ($progress->getPassedResourceCount() >= $ability->getMinResourceCount()) { $progress->setStatus(AbilityProgress::STATUS_ACQUIRED); $this->om->forceFlush(); } else { $progress->setStatus(AbilityProgress::STATUS_PENDING); } } $this->computeCompetencyProgress($ability, $user); } else { $progress->addFailedResource($resource); } } $this->om->endFlushSuite(); }
[ "public", "function", "handleEvaluation", "(", "ResourceUserEvaluation", "$", "evaluation", ")", "{", "$", "this", "->", "clearCache", "(", ")", ";", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "resource", "=", "$", "evaluation", ...
Computes and logs the progression of a user. @param ResourceUserEvaluation $evaluation
[ "Computes", "and", "logs", "the", "progression", "of", "a", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L62-L94
train
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.recomputeUserProgress
public function recomputeUserProgress($subject) { $this->clearCache(); $percentage = null; if ($subject instanceof User) { $percentage = $this->computeUserProgress($subject); } elseif ($subject instanceof Group) { foreach ($subject->getUsers() as $user) { $this->computeUserProgress($user); } } else { throw new \InvalidArgumentException( 'Subject must be an instance of User or Group' ); } $this->om->flush(); return $percentage; }
php
public function recomputeUserProgress($subject) { $this->clearCache(); $percentage = null; if ($subject instanceof User) { $percentage = $this->computeUserProgress($subject); } elseif ($subject instanceof Group) { foreach ($subject->getUsers() as $user) { $this->computeUserProgress($user); } } else { throw new \InvalidArgumentException( 'Subject must be an instance of User or Group' ); } $this->om->flush(); return $percentage; }
[ "public", "function", "recomputeUserProgress", "(", "$", "subject", ")", "{", "$", "this", "->", "clearCache", "(", ")", ";", "$", "percentage", "=", "null", ";", "if", "(", "$", "subject", "instanceof", "User", ")", "{", "$", "percentage", "=", "$", "...
Recomputes the progression of a user or a group of users. In case the subject is a user, returns the computed percentage, otherwise returns null. Note: this method recomputes only the percentage of reached objectives. @param User|Group $subject @return null|int
[ "Recomputes", "the", "progression", "of", "a", "user", "or", "a", "group", "of", "users", ".", "In", "case", "the", "subject", "is", "a", "user", "returns", "the", "computed", "percentage", "otherwise", "returns", "null", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L107-L127
train
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.recomputeObjectiveProgress
public function recomputeObjectiveProgress(Objective $objective) { $this->clearCache(); $users = $this->objectiveRepo->findUsersWithObjective($objective); foreach ($users as $user) { $this->computeUserObjective($objective, $user); $this->computeUserProgress($user); } $this->om->flush(); }
php
public function recomputeObjectiveProgress(Objective $objective) { $this->clearCache(); $users = $this->objectiveRepo->findUsersWithObjective($objective); foreach ($users as $user) { $this->computeUserObjective($objective, $user); $this->computeUserProgress($user); } $this->om->flush(); }
[ "public", "function", "recomputeObjectiveProgress", "(", "Objective", "$", "objective", ")", "{", "$", "this", "->", "clearCache", "(", ")", ";", "$", "users", "=", "$", "this", "->", "objectiveRepo", "->", "findUsersWithObjective", "(", "$", "objective", ")",...
Recomputes an objective progress for all the users and groups of users to which that objective is assigned. Note: this method doesn't compute competency progress. @param Objective $objective
[ "Recomputes", "an", "objective", "progress", "for", "all", "the", "users", "and", "groups", "of", "users", "to", "which", "that", "objective", "is", "assigned", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L137-L148
train
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.listLeafCompetencyLogs
public function listLeafCompetencyLogs(Competency $competency, User $user) { return $this->abilityRepo->findEvaluationsByCompetency($competency, $user); }
php
public function listLeafCompetencyLogs(Competency $competency, User $user) { return $this->abilityRepo->findEvaluationsByCompetency($competency, $user); }
[ "public", "function", "listLeafCompetencyLogs", "(", "Competency", "$", "competency", ",", "User", "$", "user", ")", "{", "return", "$", "this", "->", "abilityRepo", "->", "findEvaluationsByCompetency", "(", "$", "competency", ",", "$", "user", ")", ";", "}" ]
Returns user evaluation data for a given leaf competency. @param Competency $competency @param User $user @return mixed
[ "Returns", "user", "evaluation", "data", "for", "a", "given", "leaf", "competency", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L158-L161
train
claroline/Distribution
plugin/bibliography/Serializer/BookReferenceConfigurationSerializer.php
BookReferenceConfigurationSerializer.deserialize
public function deserialize($data, BookReferenceConfiguration $bookReferenceConfiguration = null, array $options = []) { if (empty($bookReferenceConfiguration)) { $bookReferenceConfiguration = new BookReferenceConfiguration(); } $this->sipe('apiKey', 'setApiKey', $data, $bookReferenceConfiguration); return $bookReferenceConfiguration; }
php
public function deserialize($data, BookReferenceConfiguration $bookReferenceConfiguration = null, array $options = []) { if (empty($bookReferenceConfiguration)) { $bookReferenceConfiguration = new BookReferenceConfiguration(); } $this->sipe('apiKey', 'setApiKey', $data, $bookReferenceConfiguration); return $bookReferenceConfiguration; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "BookReferenceConfiguration", "$", "bookReferenceConfiguration", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "bookReferenceConfiguration", ")", ")...
De-serializes a book reference configuration. @param $data @param BookReferenceConfiguration|null $bookReferenceConfiguration @param array $options @return BookReferenceConfiguration
[ "De", "-", "serializes", "a", "book", "reference", "configuration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/bibliography/Serializer/BookReferenceConfigurationSerializer.php#L47-L56
train
claroline/Distribution
plugin/wiki/Listener/Resource/WikiListener.php
WikiListener.load
public function load(LoadResourceEvent $event) { $resourceNode = $event->getResourceNode(); /** @var Wiki $wiki */ $wiki = $event->getResource(); $sectionTree = $this->sectionManager->getSerializedSectionTree( $wiki, $this->tokenStorage->getToken()->getUser() instanceof User ? $this->tokenStorage->getToken()->getUser() : null, $this->checkPermission('EDIT', $resourceNode) ); $event->setData([ 'wiki' => $this->serializer->serialize($wiki), 'sections' => $sectionTree, ]); $event->stopPropagation(); }
php
public function load(LoadResourceEvent $event) { $resourceNode = $event->getResourceNode(); /** @var Wiki $wiki */ $wiki = $event->getResource(); $sectionTree = $this->sectionManager->getSerializedSectionTree( $wiki, $this->tokenStorage->getToken()->getUser() instanceof User ? $this->tokenStorage->getToken()->getUser() : null, $this->checkPermission('EDIT', $resourceNode) ); $event->setData([ 'wiki' => $this->serializer->serialize($wiki), 'sections' => $sectionTree, ]); $event->stopPropagation(); }
[ "public", "function", "load", "(", "LoadResourceEvent", "$", "event", ")", "{", "$", "resourceNode", "=", "$", "event", "->", "getResourceNode", "(", ")", ";", "/** @var Wiki $wiki */", "$", "wiki", "=", "$", "event", "->", "getResource", "(", ")", ";", "$...
Loads a Wiki resource. @DI\Observe("resource.icap_wiki.load") @param LoadResourceEvent $event
[ "Loads", "a", "Wiki", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/wiki/Listener/Resource/WikiListener.php#L96-L114
train
claroline/Distribution
main/core/Event/Log/LogRoleSubscribeEvent.php
LogRoleSubscribeEvent.getExcludeUserIds
public function getExcludeUserIds() { $userIds = array(); $currentGroupId = -1; //First of all we need to test if subject is group or user //In case of group we need to exclude all these users that already exist in role if ($this->receiverGroup !== null) { $currentGroupId = $this->receiverGroup->getId(); $roleUsers = $this->role->getUsers(); foreach ($roleUsers as $user) { array_push($userIds, $user->getId()); } } //For both cases (user or group) we need to exclude all users already enrolled in other groups $roleGroups = $this->role->getGroups(); if ($roleGroups) { foreach ($roleGroups as $group) { if ($group->getId() != $currentGroupId) { $userIds = array_merge($userIds, $group->getUserIds()); } } } $userIds = array_unique($userIds); return $userIds; }
php
public function getExcludeUserIds() { $userIds = array(); $currentGroupId = -1; //First of all we need to test if subject is group or user //In case of group we need to exclude all these users that already exist in role if ($this->receiverGroup !== null) { $currentGroupId = $this->receiverGroup->getId(); $roleUsers = $this->role->getUsers(); foreach ($roleUsers as $user) { array_push($userIds, $user->getId()); } } //For both cases (user or group) we need to exclude all users already enrolled in other groups $roleGroups = $this->role->getGroups(); if ($roleGroups) { foreach ($roleGroups as $group) { if ($group->getId() != $currentGroupId) { $userIds = array_merge($userIds, $group->getUserIds()); } } } $userIds = array_unique($userIds); return $userIds; }
[ "public", "function", "getExcludeUserIds", "(", ")", "{", "$", "userIds", "=", "array", "(", ")", ";", "$", "currentGroupId", "=", "-", "1", ";", "//First of all we need to test if subject is group or user", "//In case of group we need to exclude all these users that already ...
Get excludeUsers array of user ids. @return array
[ "Get", "excludeUsers", "array", "of", "user", "ids", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/Log/LogRoleSubscribeEvent.php#L123-L150
train
claroline/Distribution
main/core/Event/Log/LogRoleSubscribeEvent.php
LogRoleSubscribeEvent.getActionKey
public function getActionKey() { if ($this->receiver !== null) { if ($this->role->getWorkspace() === null) { return $this::ACTION_USER; } else { return $this::ACTION_WORKSPACE_USER; } } else { if ($this->role->getWorkspace() === null) { return $this::ACTION_GROUP; } else { return $this::ACTION_WORKSPACE_GROUP; } } }
php
public function getActionKey() { if ($this->receiver !== null) { if ($this->role->getWorkspace() === null) { return $this::ACTION_USER; } else { return $this::ACTION_WORKSPACE_USER; } } else { if ($this->role->getWorkspace() === null) { return $this::ACTION_GROUP; } else { return $this::ACTION_WORKSPACE_GROUP; } } }
[ "public", "function", "getActionKey", "(", ")", "{", "if", "(", "$", "this", "->", "receiver", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "role", "->", "getWorkspace", "(", ")", "===", "null", ")", "{", "return", "$", "this", "::", "ACT...
Get actionKey string. @return string
[ "Get", "actionKey", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/Log/LogRoleSubscribeEvent.php#L157-L172
train
claroline/Distribution
main/core/API/Serializer/Resource/ResourceUserEvaluationSerializer.php
ResourceUserEvaluationSerializer.serialize
public function serialize(ResourceUserEvaluation $resourceUserEvaluation) { $serialized = [ 'id' => $resourceUserEvaluation->getId(), 'date' => $resourceUserEvaluation->getDate() ? $resourceUserEvaluation->getDate()->format('Y-m-d H:i') : null, 'status' => $resourceUserEvaluation->getStatus(), 'duration' => $resourceUserEvaluation->getDuration(), 'score' => $resourceUserEvaluation->getScore(), 'scoreMin' => $resourceUserEvaluation->getScoreMin(), 'scoreMax' => $resourceUserEvaluation->getScoreMax(), 'customScore' => $resourceUserEvaluation->getCustomScore(), 'progression' => $resourceUserEvaluation->getProgression(), 'resourceNode' => $this->resourceNodeSerializer->serialize($resourceUserEvaluation->getResourceNode()), 'user' => $this->userSerializer->serialize($resourceUserEvaluation->getUser()), 'userName' => $resourceUserEvaluation->getUserName(), 'nbAttempts' => $resourceUserEvaluation->getNbAttempts(), 'nbOpenings' => $resourceUserEvaluation->getNbOpenings(), ]; return $serialized; }
php
public function serialize(ResourceUserEvaluation $resourceUserEvaluation) { $serialized = [ 'id' => $resourceUserEvaluation->getId(), 'date' => $resourceUserEvaluation->getDate() ? $resourceUserEvaluation->getDate()->format('Y-m-d H:i') : null, 'status' => $resourceUserEvaluation->getStatus(), 'duration' => $resourceUserEvaluation->getDuration(), 'score' => $resourceUserEvaluation->getScore(), 'scoreMin' => $resourceUserEvaluation->getScoreMin(), 'scoreMax' => $resourceUserEvaluation->getScoreMax(), 'customScore' => $resourceUserEvaluation->getCustomScore(), 'progression' => $resourceUserEvaluation->getProgression(), 'resourceNode' => $this->resourceNodeSerializer->serialize($resourceUserEvaluation->getResourceNode()), 'user' => $this->userSerializer->serialize($resourceUserEvaluation->getUser()), 'userName' => $resourceUserEvaluation->getUserName(), 'nbAttempts' => $resourceUserEvaluation->getNbAttempts(), 'nbOpenings' => $resourceUserEvaluation->getNbOpenings(), ]; return $serialized; }
[ "public", "function", "serialize", "(", "ResourceUserEvaluation", "$", "resourceUserEvaluation", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "resourceUserEvaluation", "->", "getId", "(", ")", ",", "'date'", "=>", "$", "resourceUserEvaluation", "->", ...
Serializes a ResourceUserEvaluation entity for the JSON api. @param ResourceUserEvaluation $resourceUserEvaluation @return array - the serialized representation of the resource evaluation
[ "Serializes", "a", "ResourceUserEvaluation", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceUserEvaluationSerializer.php#L42-L62
train
claroline/Distribution
plugin/social-media/Listener/ApiListener.php
ApiListener.onSerialize
public function onSerialize(DecorateResourceNodeEvent $event) { $count = $this->om->getRepository('IcapSocialmediaBundle:LikeAction')->countLikes([ 'resource' => $event->getResourceNode()->getId(), ]); $event->add('social', [ 'likes' => $count, ]); }
php
public function onSerialize(DecorateResourceNodeEvent $event) { $count = $this->om->getRepository('IcapSocialmediaBundle:LikeAction')->countLikes([ 'resource' => $event->getResourceNode()->getId(), ]); $event->add('social', [ 'likes' => $count, ]); }
[ "public", "function", "onSerialize", "(", "DecorateResourceNodeEvent", "$", "event", ")", "{", "$", "count", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'IcapSocialmediaBundle:LikeAction'", ")", "->", "countLikes", "(", "[", "'resource'", "=>", "$...
Add like count to serialized resource node when requested through API. @DI\Observe("serialize_resource_node") @param DecorateResourceNodeEvent $event
[ "Add", "like", "count", "to", "serialized", "resource", "node", "when", "requested", "through", "API", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/social-media/Listener/ApiListener.php#L40-L49
train
claroline/Distribution
main/core/Entity/Widget/WidgetContainer.php
WidgetContainer.addInstance
public function addInstance(WidgetInstance $instance) { if (!$this->instances->contains($instance)) { $this->instances->add($instance); $instance->setContainer($this); } }
php
public function addInstance(WidgetInstance $instance) { if (!$this->instances->contains($instance)) { $this->instances->add($instance); $instance->setContainer($this); } }
[ "public", "function", "addInstance", "(", "WidgetInstance", "$", "instance", ")", "{", "if", "(", "!", "$", "this", "->", "instances", "->", "contains", "(", "$", "instance", ")", ")", "{", "$", "this", "->", "instances", "->", "add", "(", "$", "instan...
Add a WidgetInstance into the container. @param WidgetInstance $instance
[ "Add", "a", "WidgetInstance", "into", "the", "container", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Widget/WidgetContainer.php#L82-L88
train
claroline/Distribution
main/core/Entity/Widget/WidgetContainer.php
WidgetContainer.removeInstance
public function removeInstance(WidgetInstance $instance) { if ($this->instances->contains($instance)) { $this->instances->removeElement($instance); } }
php
public function removeInstance(WidgetInstance $instance) { if ($this->instances->contains($instance)) { $this->instances->removeElement($instance); } }
[ "public", "function", "removeInstance", "(", "WidgetInstance", "$", "instance", ")", "{", "if", "(", "$", "this", "->", "instances", "->", "contains", "(", "$", "instance", ")", ")", "{", "$", "this", "->", "instances", "->", "removeElement", "(", "$", "...
Remove a WidgetInstance from the container. @param WidgetInstance $instance
[ "Remove", "a", "WidgetInstance", "from", "the", "container", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Widget/WidgetContainer.php#L95-L100
train
claroline/Distribution
main/core/Controller/APINew/Model/HasOrganizationsTrait.php
HasOrganizationsTrait.addOrganizationsAction
public function addOrganizationsAction($id, $class, Request $request) { $object = $this->find($class, $id); $organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization'); $this->crud->patch($object, 'organization', Crud::COLLECTION_ADD, $organizations); return new JsonResponse( $this->serializer->serialize($object) ); }
php
public function addOrganizationsAction($id, $class, Request $request) { $object = $this->find($class, $id); $organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization'); $this->crud->patch($object, 'organization', Crud::COLLECTION_ADD, $organizations); return new JsonResponse( $this->serializer->serialize($object) ); }
[ "public", "function", "addOrganizationsAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "organizations", "=", "$", ...
Adds organizations to the collection. @EXT\Route("/{id}/organization") @EXT\Method("PATCH") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Adds", "organizations", "to", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasOrganizationsTrait.php#L49-L58
train
claroline/Distribution
main/core/Controller/APINew/Model/HasOrganizationsTrait.php
HasOrganizationsTrait.removeOrganizationsAction
public function removeOrganizationsAction($id, $class, Request $request) { $object = $this->find($class, $id); $organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization'); $this->crud->patch($object, 'organization', Crud::COLLECTION_REMOVE, $organizations); return new JsonResponse( $this->serializer->serialize($object) ); }
php
public function removeOrganizationsAction($id, $class, Request $request) { $object = $this->find($class, $id); $organizations = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Organization\Organization'); $this->crud->patch($object, 'organization', Crud::COLLECTION_REMOVE, $organizations); return new JsonResponse( $this->serializer->serialize($object) ); }
[ "public", "function", "removeOrganizationsAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "organizations", "=", "$"...
Removes organizations from the collection. @EXT\Route("/{id}/organization") @EXT\Method("DELETE") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Removes", "organizations", "from", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasOrganizationsTrait.php#L72-L81
train
claroline/Distribution
plugin/exo/Library/Model/AttemptParametersTrait.php
AttemptParametersTrait.setMaxAttemptsPerDay
public function setMaxAttemptsPerDay($maxAttemptsPerDay) { if ($maxAttemptsPerDay > $this->maxAttempts) { //we can't try more times per day than the maximum allowed attempts defined $this->maxAttemptsPerDay = $this->maxAttempts; } $this->maxAttemptsPerDay = $maxAttemptsPerDay; }
php
public function setMaxAttemptsPerDay($maxAttemptsPerDay) { if ($maxAttemptsPerDay > $this->maxAttempts) { //we can't try more times per day than the maximum allowed attempts defined $this->maxAttemptsPerDay = $this->maxAttempts; } $this->maxAttemptsPerDay = $maxAttemptsPerDay; }
[ "public", "function", "setMaxAttemptsPerDay", "(", "$", "maxAttemptsPerDay", ")", "{", "if", "(", "$", "maxAttemptsPerDay", ">", "$", "this", "->", "maxAttempts", ")", "{", "//we can't try more times per day than the maximum allowed attempts defined", "$", "this", "->", ...
Sets max attempts. @param int $maxAttemptsPerDay
[ "Sets", "max", "attempts", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Model/AttemptParametersTrait.php#L179-L187
train
claroline/Distribution
plugin/tag/Controller/TagController.php
TagController.listObjectsAction
public function listObjectsAction(Tag $tag, Request $request) { return new JsonResponse( $this->finder->search(TaggedObject::class, array_merge( $request->query->all(), ['hiddenFilters' => [$this->getName() => $tag->getUuid()]] )) ); }
php
public function listObjectsAction(Tag $tag, Request $request) { return new JsonResponse( $this->finder->search(TaggedObject::class, array_merge( $request->query->all(), ['hiddenFilters' => [$this->getName() => $tag->getUuid()]] )) ); }
[ "public", "function", "listObjectsAction", "(", "Tag", "$", "tag", ",", "Request", "$", "request", ")", "{", "return", "new", "JsonResponse", "(", "$", "this", "->", "finder", "->", "search", "(", "TaggedObject", "::", "class", ",", "array_merge", "(", "$"...
List all objects linked to a Tag. @EXT\Route("/{id}/object", name="apiv2_tag_list_objects") @EXT\ParamConverter("tag", class="ClarolineTagBundle:Tag", options={"mapping": {"id": "uuid"}}) @EXT\Method("GET") @param Tag $tag @param Request $request @return JsonResponse
[ "List", "all", "objects", "linked", "to", "a", "Tag", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Controller/TagController.php#L69-L77
train
claroline/Distribution
plugin/tag/Controller/TagController.php
TagController.addObjectsAction
public function addObjectsAction($tag, User $user, Request $request) { $taggedObjects = $this->manager->tagData([$tag], $this->decodeRequest($request), $user); return new JsonResponse( !empty($taggedObjects) ? $this->serializer->serialize($taggedObjects[0]->getTag()) : null ); }
php
public function addObjectsAction($tag, User $user, Request $request) { $taggedObjects = $this->manager->tagData([$tag], $this->decodeRequest($request), $user); return new JsonResponse( !empty($taggedObjects) ? $this->serializer->serialize($taggedObjects[0]->getTag()) : null ); }
[ "public", "function", "addObjectsAction", "(", "$", "tag", ",", "User", "$", "user", ",", "Request", "$", "request", ")", "{", "$", "taggedObjects", "=", "$", "this", "->", "manager", "->", "tagData", "(", "[", "$", "tag", "]", ",", "$", "this", "->"...
Adds a tag to a collection of taggable objects. NB. If the tag does not exist, it will be created. @EXT\Route("/{tag}/object", name="apiv2_tag_add_objects") @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @EXT\Method("POST") @param string $tag @param User $user @param Request $request @return JsonResponse
[ "Adds", "a", "tag", "to", "a", "collection", "of", "taggable", "objects", ".", "NB", ".", "If", "the", "tag", "does", "not", "exist", "it", "will", "be", "created", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Controller/TagController.php#L93-L100
train
claroline/Distribution
main/app/Manager/CacheManager.php
CacheManager.getParameter
public function getParameter($parameter) { $isRefreshed = false; if (!$this->cacheExists()) { $this->refresh(); $isRefreshed = true; } $values = parse_ini_file($this->cachePath); $return = null; if (isset($values[$parameter])) { $return = $values[$parameter]; } else { if (!$isRefreshed) { $this->refresh(); $values = parse_ini_file($this->cachePath); if (isset($values[$parameter])) { $return = $values[$parameter]; } } } return $return ? $return : false; }
php
public function getParameter($parameter) { $isRefreshed = false; if (!$this->cacheExists()) { $this->refresh(); $isRefreshed = true; } $values = parse_ini_file($this->cachePath); $return = null; if (isset($values[$parameter])) { $return = $values[$parameter]; } else { if (!$isRefreshed) { $this->refresh(); $values = parse_ini_file($this->cachePath); if (isset($values[$parameter])) { $return = $values[$parameter]; } } } return $return ? $return : false; }
[ "public", "function", "getParameter", "(", "$", "parameter", ")", "{", "$", "isRefreshed", "=", "false", ";", "if", "(", "!", "$", "this", "->", "cacheExists", "(", ")", ")", "{", "$", "this", "->", "refresh", "(", ")", ";", "$", "isRefreshed", "=", ...
Read a value from the claroline cache. @param $parameter @throws \Exception @return mixed
[ "Read", "a", "value", "from", "the", "claroline", "cache", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/Manager/CacheManager.php#L59-L85
train
claroline/Distribution
main/app/Manager/CacheManager.php
CacheManager.refresh
public function refresh() { $this->removeCache(); /** @var RefreshCacheEvent $event */ $event = $this->eventDispatcher->dispatch('refresh_cache', RefreshCacheEvent::class); $this->writeCache($event->getParameters()); }
php
public function refresh() { $this->removeCache(); /** @var RefreshCacheEvent $event */ $event = $this->eventDispatcher->dispatch('refresh_cache', RefreshCacheEvent::class); $this->writeCache($event->getParameters()); }
[ "public", "function", "refresh", "(", ")", "{", "$", "this", "->", "removeCache", "(", ")", ";", "/** @var RefreshCacheEvent $event */", "$", "event", "=", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'refresh_cache'", ",", "RefreshCacheEvent", ...
Refresh the claroline cache.
[ "Refresh", "the", "claroline", "cache", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/Manager/CacheManager.php#L102-L110
train
claroline/Distribution
plugin/reservation/Serializer/ResourceRightsSerializer.php
ResourceRightsSerializer.deserialize
public function deserialize($data, ResourceRights $resourceRights = null) { if (empty($resourceRights)) { $resourceRights = new ResourceRights(); } if (isset($data['mask'])) { $resourceRights->setMask($data['mask']); } if (isset($data['resource'])) { $resource = $this->resourceRepo->findOneBy(['uuid' => $data['resource']['id']]); $resourceRights->setResource($resource); } if (isset($data['role'])) { $role = $this->roleRepo->findOneBy(['uuid' => $data['role']['id']]); $resourceRights->setRole($role); } return $resourceRights; }
php
public function deserialize($data, ResourceRights $resourceRights = null) { if (empty($resourceRights)) { $resourceRights = new ResourceRights(); } if (isset($data['mask'])) { $resourceRights->setMask($data['mask']); } if (isset($data['resource'])) { $resource = $this->resourceRepo->findOneBy(['uuid' => $data['resource']['id']]); $resourceRights->setResource($resource); } if (isset($data['role'])) { $role = $this->roleRepo->findOneBy(['uuid' => $data['role']['id']]); $resourceRights->setRole($role); } return $resourceRights; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "ResourceRights", "$", "resourceRights", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "resourceRights", ")", ")", "{", "$", "resourceRights", "=", "new", "ResourceRights", "(", ")", ";", ...
Deserializes data into a ResourceRights entity. @param \stdClass $data @param ResourceRights $resourceRights @return ResourceRights
[ "Deserializes", "data", "into", "a", "ResourceRights", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Serializer/ResourceRightsSerializer.php#L67-L85
train
claroline/Distribution
main/core/Listener/AuthenticationSuccessListener.php
AuthenticationSuccessListener.checkTermOfServices
public function checkTermOfServices(GetResponseEvent $event) { if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) { $user = !empty($this->tokenStorage->getToken()) ? $this->tokenStorage->getToken()->getUser() : null; if ($user instanceof User && $this->configurationHandler->getParameter('terms_of_service')) { $this->showTermOfServices($event); } } }
php
public function checkTermOfServices(GetResponseEvent $event) { if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) { $user = !empty($this->tokenStorage->getToken()) ? $this->tokenStorage->getToken()->getUser() : null; if ($user instanceof User && $this->configurationHandler->getParameter('terms_of_service')) { $this->showTermOfServices($event); } } }
[ "public", "function", "checkTermOfServices", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "'prod'", "===", "$", "this", "->", "kernel", "->", "getEnvironment", "(", ")", "&&", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "$", ...
Checks the current user has accepted term of services if any before displaying platform. @DI\Observe("kernel.request") @param GetResponseEvent $event
[ "Checks", "the", "current", "user", "has", "accepted", "term", "of", "services", "if", "any", "before", "displaying", "platform", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/AuthenticationSuccessListener.php#L229-L237
train
claroline/Distribution
main/core/Listener/AuthenticationSuccessListener.php
AuthenticationSuccessListener.getUser
private function getUser(Request $request) { if ($this->configurationHandler->getParameter('terms_of_service') && 'claroline_locale_change' !== $request->get('_route') && 'claroline_locale_select' !== $request->get('_route') && 'bazinga_exposetranslation_js' !== $request->get('_route') && ($token = $this->tokenStorage->getToken()) && ($user = $token->getUser()) && $user instanceof User ) { return $user; } return null; }
php
private function getUser(Request $request) { if ($this->configurationHandler->getParameter('terms_of_service') && 'claroline_locale_change' !== $request->get('_route') && 'claroline_locale_select' !== $request->get('_route') && 'bazinga_exposetranslation_js' !== $request->get('_route') && ($token = $this->tokenStorage->getToken()) && ($user = $token->getUser()) && $user instanceof User ) { return $user; } return null; }
[ "private", "function", "getUser", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "this", "->", "configurationHandler", "->", "getParameter", "(", "'terms_of_service'", ")", "&&", "'claroline_locale_change'", "!==", "$", "request", "->", "get", "(", ...
Return a user if need to accept the terms of service. @param \Symfony\Component\HttpFoundation\Request $request @return User
[ "Return", "a", "user", "if", "need", "to", "accept", "the", "terms", "of", "service", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/AuthenticationSuccessListener.php#L309-L323
train
fastdlabs/http
src/Response.php
Response.withExpires
public function withExpires(DateTime $date) { $timezone = new DateTimeZone("PRC"); $this->withoutHeader('Expires'); $date->setTimezone($timezone); $this->withHeader('Expires', $date->format('D, d M Y H:i:s') . ' GMT'); $maxAge = $date->getTimestamp() - (new DateTime('now', $timezone))->getTimestamp(); $this->withMaxAge($maxAge); return $this; }
php
public function withExpires(DateTime $date) { $timezone = new DateTimeZone("PRC"); $this->withoutHeader('Expires'); $date->setTimezone($timezone); $this->withHeader('Expires', $date->format('D, d M Y H:i:s') . ' GMT'); $maxAge = $date->getTimestamp() - (new DateTime('now', $timezone))->getTimestamp(); $this->withMaxAge($maxAge); return $this; }
[ "public", "function", "withExpires", "(", "DateTime", "$", "date", ")", "{", "$", "timezone", "=", "new", "DateTimeZone", "(", "\"PRC\"", ")", ";", "$", "this", "->", "withoutHeader", "(", "'Expires'", ")", ";", "$", "date", "->", "setTimezone", "(", "$"...
Sets the Expires HTTP header with a DateTime instance. Passing null as value will remove the header. @param DateTime|null $date A \DateTime instance or null to remove the header @return $this
[ "Sets", "the", "Expires", "HTTP", "header", "with", "a", "DateTime", "instance", "." ]
9ac973b4eaefb9b7f28ff7550077643f4128ef99
https://github.com/fastdlabs/http/blob/9ac973b4eaefb9b7f28ff7550077643f4128ef99/src/Response.php#L448-L460
train
fastdlabs/http
src/Response.php
Response.withNotModified
public function withNotModified() { $this->withStatus(static::HTTP_NOT_MODIFIED); $this->getBody()->write(''); // remove headers that MUST NOT be included with 304 Not Modified responses foreach ([ 'Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified'] as $header) { $this->withoutHeader($header); } return $this; }
php
public function withNotModified() { $this->withStatus(static::HTTP_NOT_MODIFIED); $this->getBody()->write(''); // remove headers that MUST NOT be included with 304 Not Modified responses foreach ([ 'Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified'] as $header) { $this->withoutHeader($header); } return $this; }
[ "public", "function", "withNotModified", "(", ")", "{", "$", "this", "->", "withStatus", "(", "static", "::", "HTTP_NOT_MODIFIED", ")", ";", "$", "this", "->", "getBody", "(", ")", "->", "write", "(", "''", ")", ";", "// remove headers that MUST NOT be include...
Modifies the response so that it conforms to the rules defined for a 304 status code. This sets the status, removes the body, and discards any headers that MUST NOT be included in 304 responses. @return Response @see http://tools.ietf.org/html/rfc2616#section-10.3.5
[ "Modifies", "the", "response", "so", "that", "it", "conforms", "to", "the", "rules", "defined", "for", "a", "304", "status", "code", "." ]
9ac973b4eaefb9b7f28ff7550077643f4128ef99
https://github.com/fastdlabs/http/blob/9ac973b4eaefb9b7f28ff7550077643f4128ef99/src/Response.php#L550-L568
train
krizalys/onedrive-php-sdk
src/Folder.php
Folder.fetchDriveItems
public function fetchDriveItems() { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::children' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); return array_map(function (DriveItemProxy $item) use ($client) { $options = $client->buildOptions($item, ['parent_id' => $this->_id]); return $client->isFolder($item) ? new self($client, $item->id, $options) : new File($client, $item->id, $options); }, $item->children); }
php
public function fetchDriveItems() { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::children' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); return array_map(function (DriveItemProxy $item) use ($client) { $options = $client->buildOptions($item, ['parent_id' => $this->_id]); return $client->isFolder($item) ? new self($client, $item->id, $options) : new File($client, $item->id, $options); }, $item->children); }
[ "public", "function", "fetchDriveItems", "(", ")", "{", "$", "client", "=", "$", "this", "->", "_client", ";", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in version 3;'", ".", "' use Krizalys\\Onedrive\\Proxy\\DriveItemProxy::children'", ...
Gets the drive items in the OneDrive folder referenced by this Folder instance. @return array The drive items in the OneDrive folder referenced by this Folder instance, as DriveItem instances. @deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::children instead.
[ "Gets", "the", "drive", "items", "in", "the", "OneDrive", "folder", "referenced", "by", "this", "Folder", "instance", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Folder.php#L53-L75
train
krizalys/onedrive-php-sdk
src/Folder.php
Folder.createFolder
public function createFolder($name, $description = null) { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); $options = []; if ($description !== null) { $options += [ 'description' => (string) $description, ]; } $item = $item->createFolder($name, $options); $options = $client->buildOptions($item, ['parent_id' => $parentId]); return new self($client, $item->id, $options); }
php
public function createFolder($name, $description = null) { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); $options = []; if ($description !== null) { $options += [ 'description' => (string) $description, ]; } $item = $item->createFolder($name, $options); $options = $client->buildOptions($item, ['parent_id' => $parentId]); return new self($client, $item->id, $options); }
[ "public", "function", "createFolder", "(", "$", "name", ",", "$", "description", "=", "null", ")", "{", "$", "client", "=", "$", "this", "->", "_client", ";", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in version 3;'", ".", "...
Creates a folder in the OneDrive folder referenced by this Folder instance. @param string $name The name of the OneDrive folder to be created. @param null|string $description The description of the OneDrive folder to be created, or null to create it without a description. Default: null. @return Folder The folder created, as a Folder instance. @deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder() instead.
[ "Creates", "a", "folder", "in", "the", "OneDrive", "folder", "referenced", "by", "this", "Folder", "instance", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Folder.php#L127-L153
train
krizalys/onedrive-php-sdk
src/Folder.php
Folder.createFile
public function createFile($name, $content = '', array $options = []) { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); $options = []; if ($description !== null) { $options += [ 'description' => (string) $description, ]; } $item = $item->upload($name, $content, $options); $options = $client->buildOptions($item, ['parent_id' => $parentId]); return new File($client, $item->id, $options); }
php
public function createFile($name, $content = '', array $options = []) { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); $options = []; if ($description !== null) { $options += [ 'description' => (string) $description, ]; } $item = $item->upload($name, $content, $options); $options = $client->buildOptions($item, ['parent_id' => $parentId]); return new File($client, $item->id, $options); }
[ "public", "function", "createFile", "(", "$", "name", ",", "$", "content", "=", "''", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "client", "=", "$", "this", "->", "_client", ";", "$", "message", "=", "sprintf", "(", "'%s() is depreca...
Creates a file in the OneDrive folder referenced by this Folder instance. @param string $name The name of the OneDrive file to be created. @param string|resource $content The content of the OneDrive file to be created, as a string or handle to an already opened file. In the latter case, the responsibility to close the handle is is left to the calling function. Default: ''. @param array $options The options. @return File The file created, as a File instance. @throws Exception Thrown on I/O errors. @deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::upload() instead.
[ "Creates", "a", "file", "in", "the", "OneDrive", "folder", "referenced", "by", "this", "Folder", "instance", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Folder.php#L176-L202
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.getChildren
public function getChildren() { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator/children"; $response = $this ->graph ->createCollectionRequest('GET', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status"); } $driveItems = $response->getResponseAsObject(DriveItem::class); if (!is_array($driveItems)) { return []; } return array_map(function (DriveItem $driveItem) { return new self($this->graph, $driveItem); }, $driveItems); }
php
public function getChildren() { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator/children"; $response = $this ->graph ->createCollectionRequest('GET', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status"); } $driveItems = $response->getResponseAsObject(DriveItem::class); if (!is_array($driveItems)) { return []; } return array_map(function (DriveItem $driveItem) { return new self($this->graph, $driveItem); }, $driveItems); }
[ "public", "function", "getChildren", "(", ")", "{", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->driveId}\"", ";", "$", "itemLocator", "=", "\"/items/{$this->id}\"", ";", "$", "endpoint", "=", "\"$driveLocator$itemLocator/children\"", ";", "$", "response"...
Gets this folder drive item's children. @return array The child drive items. @todo Support pagination using a native iterator.
[ "Gets", "this", "folder", "drive", "item", "s", "children", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L211-L237
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.delete
public function delete() { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator"; $response = $this ->graph ->createRequest('DELETE', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 204) { throw new \Exception("Unexpected status code produced by 'DELETE $endpoint': $status"); } }
php
public function delete() { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator"; $response = $this ->graph ->createRequest('DELETE', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 204) { throw new \Exception("Unexpected status code produced by 'DELETE $endpoint': $status"); } }
[ "public", "function", "delete", "(", ")", "{", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->driveId}\"", ";", "$", "itemLocator", "=", "\"/items/{$this->id}\"", ";", "$", "endpoint", "=", "\"$driveLocator$itemLocator\"", ";", "$", "response", "=", "$"...
Deletes this drive item.
[ "Deletes", "this", "drive", "item", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L242-L258
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.upload
public function upload($name, $content, array $options = []) { $name = rawurlencode($name); $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator:/$name:/content"; $body = $content instanceof Stream ? $content : Psr7\stream_for($content); $response = $this ->graph ->createRequest('PUT', $endpoint) ->addHeaders($options) ->attachBody($body) ->execute(); $status = $response->getStatus(); if ($status != 200 && $status != 201) { throw new \Exception("Unexpected status code produced by 'PUT $endpoint': $status"); } $driveItem = $response->getResponseAsObject(DriveItem::class); return new self($this->graph, $driveItem); }
php
public function upload($name, $content, array $options = []) { $name = rawurlencode($name); $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator:/$name:/content"; $body = $content instanceof Stream ? $content : Psr7\stream_for($content); $response = $this ->graph ->createRequest('PUT', $endpoint) ->addHeaders($options) ->attachBody($body) ->execute(); $status = $response->getStatus(); if ($status != 200 && $status != 201) { throw new \Exception("Unexpected status code produced by 'PUT $endpoint': $status"); } $driveItem = $response->getResponseAsObject(DriveItem::class); return new self($this->graph, $driveItem); }
[ "public", "function", "upload", "(", "$", "name", ",", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "name", "=", "rawurlencode", "(", "$", "name", ")", ";", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->driveI...
Uploads a file under this folder drive item. @param string $name The name. @param string|resource|\GuzzleHttp\Psr7\Stream $content The content. @param array $options The options. @return DriveItemProxy The drive item created. @todo Support name conflict behavior. @todo Support content type in options.
[ "Uploads", "a", "file", "under", "this", "folder", "drive", "item", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L276-L303
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.startUpload
public function startUpload($name, $content, array $options = []) { $name = rawurlencode($name); $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator:/$name:/createUploadSession"; $response = $this ->graph ->createRequest('POST', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status"); } $uploadSession = $response->getResponseAsObject(UploadSession::class); return new UploadSessionProxy($this->graph, $uploadSession, $content, $options); }
php
public function startUpload($name, $content, array $options = []) { $name = rawurlencode($name); $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator:/$name:/createUploadSession"; $response = $this ->graph ->createRequest('POST', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status"); } $uploadSession = $response->getResponseAsObject(UploadSession::class); return new UploadSessionProxy($this->graph, $uploadSession, $content, $options); }
[ "public", "function", "startUpload", "(", "$", "name", ",", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "name", "=", "rawurlencode", "(", "$", "name", ")", ";", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->d...
Creates an upload session to upload a large file in multiple ranges under this folder drive item. @param string $name The name. @param string|resource|\GuzzleHttp\Psr7\Stream $content The content. @param array $options The options. @return UploadSessionProxy The upload session created. @todo Support name conflict behavior. @todo Support content type in options.
[ "Creates", "an", "upload", "session", "to", "upload", "a", "large", "file", "in", "multiple", "ranges", "under", "this", "folder", "drive", "item", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L322-L343
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.download
public function download() { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator/content"; $response = $this ->graph ->createRequest('GET', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status"); } return $response->getResponseAsObject(Stream::class); }
php
public function download() { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator/content"; $response = $this ->graph ->createRequest('GET', $endpoint) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'GET $endpoint': $status"); } return $response->getResponseAsObject(Stream::class); }
[ "public", "function", "download", "(", ")", "{", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->driveId}\"", ";", "$", "itemLocator", "=", "\"/items/{$this->id}\"", ";", "$", "endpoint", "=", "\"$driveLocator$itemLocator/content\"", ";", "$", "response", ...
Downloads this file drive item. @return GuzzleHttp\Psr7\Stream The content.
[ "Downloads", "this", "file", "drive", "item", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L351-L369
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.rename
public function rename($name, array $options = []) { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator"; $body = [ 'name' => (string) $name, ]; $response = $this ->graph ->createRequest('PATCH', $endpoint) ->attachBody($body + $options) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status"); } $driveItem = $response->getResponseAsObject(DriveItem::class); return new self($this->graph, $driveItem); }
php
public function rename($name, array $options = []) { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator"; $body = [ 'name' => (string) $name, ]; $response = $this ->graph ->createRequest('PATCH', $endpoint) ->attachBody($body + $options) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status"); } $driveItem = $response->getResponseAsObject(DriveItem::class); return new self($this->graph, $driveItem); }
[ "public", "function", "rename", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->driveId}\"", ";", "$", "itemLocator", "=", "\"/items/{$this->id}\"", ";", "$", "endpoint", "=",...
Renames this file item. @param string $name The name. @param array $options The options. @return DriveItemProxy The drive item renamed.
[ "Renames", "this", "file", "item", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L382-L407
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.move
public function move(self $destinationItem, array $options = []) { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator"; $body = [ 'parentReference' => [ 'id' => $destinationItem->id, ], ]; $response = $this ->graph ->createRequest('PATCH', $endpoint) ->attachBody($body + $options) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status"); } $driveItem = $response->getResponseAsObject(DriveItem::class); return new self($this->graph, $driveItem); }
php
public function move(self $destinationItem, array $options = []) { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator"; $body = [ 'parentReference' => [ 'id' => $destinationItem->id, ], ]; $response = $this ->graph ->createRequest('PATCH', $endpoint) ->attachBody($body + $options) ->execute(); $status = $response->getStatus(); if ($status != 200) { throw new \Exception("Unexpected status code produced by 'PATCH $endpoint': $status"); } $driveItem = $response->getResponseAsObject(DriveItem::class); return new self($this->graph, $driveItem); }
[ "public", "function", "move", "(", "self", "$", "destinationItem", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->driveId}\"", ";", "$", "itemLocator", "=", "\"/items/{$this->id}\"", ";", "$", ...
Moves this drive item. @param DriveItemProxy $destinationItem The destination item. @param array $options The options. @return DriveItemProxy The drive item.
[ "Moves", "this", "drive", "item", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L420-L447
train
krizalys/onedrive-php-sdk
src/Proxy/DriveItemProxy.php
DriveItemProxy.copy
public function copy(self $destinationItem, array $options = []) { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator/copy"; $body = [ 'parentReference' => [ 'id' => $destinationItem->id, ], ]; $response = $this ->graph ->createRequest('POST', $endpoint) ->attachBody($body + $options) ->execute(); $status = $response->getStatus(); if ($status != 202) { throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status"); } $headers = $response->getHeaders(); return $headers['Location'][0]; }
php
public function copy(self $destinationItem, array $options = []) { $driveLocator = "/drives/{$this->parentReference->driveId}"; $itemLocator = "/items/{$this->id}"; $endpoint = "$driveLocator$itemLocator/copy"; $body = [ 'parentReference' => [ 'id' => $destinationItem->id, ], ]; $response = $this ->graph ->createRequest('POST', $endpoint) ->attachBody($body + $options) ->execute(); $status = $response->getStatus(); if ($status != 202) { throw new \Exception("Unexpected status code produced by 'POST $endpoint': $status"); } $headers = $response->getHeaders(); return $headers['Location'][0]; }
[ "public", "function", "copy", "(", "self", "$", "destinationItem", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "driveLocator", "=", "\"/drives/{$this->parentReference->driveId}\"", ";", "$", "itemLocator", "=", "\"/items/{$this->id}\"", ";", "$", ...
Copies this drive item. @param DriveItemProxy $destinationItem The destination item. @param array $options The options. @return string The progress URI. @todo Support asynchronous Graph operation.
[ "Copies", "this", "drive", "item", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/DriveItemProxy.php#L462-L489
train
krizalys/onedrive-php-sdk
src/DriveItem.php
DriveItem.fetchProperties
public function fetchProperties() { $result = $this->_client->fetchProperties($this->_id); $this->_parentId = '' != $result->parent_id ? (string) $result->parent_id : null; $this->_name = $result->name; $this->_description = '' != $result->description ? (string) $result->description : null; $this->_size = (int) $result->size; /** @todo Handle volatile existence (eg. present only for files). */ $this->_source = (string) $result->source; $this->_createdTime = strtotime($result->created_time); $this->_updatedTime = strtotime($result->updated_time); return $result; }
php
public function fetchProperties() { $result = $this->_client->fetchProperties($this->_id); $this->_parentId = '' != $result->parent_id ? (string) $result->parent_id : null; $this->_name = $result->name; $this->_description = '' != $result->description ? (string) $result->description : null; $this->_size = (int) $result->size; /** @todo Handle volatile existence (eg. present only for files). */ $this->_source = (string) $result->source; $this->_createdTime = strtotime($result->created_time); $this->_updatedTime = strtotime($result->updated_time); return $result; }
[ "public", "function", "fetchProperties", "(", ")", "{", "$", "result", "=", "$", "this", "->", "_client", "->", "fetchProperties", "(", "$", "this", "->", "_id", ")", ";", "$", "this", "->", "_parentId", "=", "''", "!=", "$", "result", "->", "parent_id...
Fetches the properties of the OneDrive drive item referenced by this DriveItem instance. Some properties are cached for faster subsequent access. @return array The properties of the OneDrive drive item referenced by this DriveItem instance.
[ "Fetches", "the", "properties", "of", "the", "OneDrive", "drive", "item", "referenced", "by", "this", "DriveItem", "instance", ".", "Some", "properties", "are", "cached", "for", "faster", "subsequent", "access", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/DriveItem.php#L151-L172
train
krizalys/onedrive-php-sdk
src/DriveItem.php
DriveItem.move
public function move($destinationId = null) { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::move()' . ' instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); $destinationItem = $client->getDriveItemById($drive->id, $destinationId); return $item->move($destinationItem); }
php
public function move($destinationId = null) { $client = $this->_client; $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::move()' . ' instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $client->getMyDrive(); $item = $client->getDriveItemById($drive->id, $this->_id); $destinationItem = $client->getDriveItemById($drive->id, $destinationId); return $item->move($destinationItem); }
[ "public", "function", "move", "(", "$", "destinationId", "=", "null", ")", "{", "$", "client", "=", "$", "this", "->", "_client", ";", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in version 3;'", ".", "' use Krizalys\\Onedrive\\Prox...
Moves the OneDrive drive item referenced by this DriveItem instance into another OneDrive folder. @param null|string $destinationId The unique ID of the OneDrive folder into which to move the OneDrive drive item referenced by this DriveItem instance, or null to move it to the OneDrive root folder. Default: null. @deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::move() instead.
[ "Moves", "the", "OneDrive", "drive", "item", "referenced", "by", "this", "DriveItem", "instance", "into", "another", "OneDrive", "folder", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/DriveItem.php#L317-L334
train
krizalys/onedrive-php-sdk
src/Proxy/UploadSessionProxy.php
UploadSessionProxy.complete
public function complete() { $stream = $this->content instanceof Stream ? $this->content : Psr7\stream_for($this->content); if ($this->rangeSize !== null) { $rangeSize = $this->rangeSize; $rangeSize = $rangeSize - $rangeSize % self::RANGE_SIZE_MULTIPLE; $rangeSize = min($rangeSize, self::MAX_RANGE_SIZE); $rangeSize = max($rangeSize, self::MIN_RANGE_SIZE); } else { $rangeSize = self::RANGE_SIZE_MULTIPLE; } $size = $stream->getSize(); $offset = 0; while (!$stream->eof()) { $rangeStream = new LimitStream($stream, $rangeSize, $offset); $rangeSize = $rangeStream->getSize(); $body = $rangeStream->getContents(); $rangeFirst = $offset; $offset += $rangeSize; $rangeLast = $offset - 1; $headers = [ 'Content-Length' => $rangeSize, 'Content-Range' => "bytes $rangeFirst-$rangeLast/$size", ]; if ($this->type !== null) { $headers['Content-Type'] = $this->type; } $response = $this ->graph ->createRequest('PUT', $this->uploadUrl) ->addHeaders($headers) ->attachBody($body) ->execute(); $status = $response->getStatus(); if ($status == 200 || $status == 201) { $driveItem = $response->getResponseAsObject(DriveItem::class); return new DriveItemProxy($this->graph, $driveItem); } if ($status != 202) { throw new \Exception("Unexpected status code produced by 'PUT {$this->uploadUrl}': $status"); } } throw new \Exception('OneDrive did not create a drive item for the uploaded file'); }
php
public function complete() { $stream = $this->content instanceof Stream ? $this->content : Psr7\stream_for($this->content); if ($this->rangeSize !== null) { $rangeSize = $this->rangeSize; $rangeSize = $rangeSize - $rangeSize % self::RANGE_SIZE_MULTIPLE; $rangeSize = min($rangeSize, self::MAX_RANGE_SIZE); $rangeSize = max($rangeSize, self::MIN_RANGE_SIZE); } else { $rangeSize = self::RANGE_SIZE_MULTIPLE; } $size = $stream->getSize(); $offset = 0; while (!$stream->eof()) { $rangeStream = new LimitStream($stream, $rangeSize, $offset); $rangeSize = $rangeStream->getSize(); $body = $rangeStream->getContents(); $rangeFirst = $offset; $offset += $rangeSize; $rangeLast = $offset - 1; $headers = [ 'Content-Length' => $rangeSize, 'Content-Range' => "bytes $rangeFirst-$rangeLast/$size", ]; if ($this->type !== null) { $headers['Content-Type'] = $this->type; } $response = $this ->graph ->createRequest('PUT', $this->uploadUrl) ->addHeaders($headers) ->attachBody($body) ->execute(); $status = $response->getStatus(); if ($status == 200 || $status == 201) { $driveItem = $response->getResponseAsObject(DriveItem::class); return new DriveItemProxy($this->graph, $driveItem); } if ($status != 202) { throw new \Exception("Unexpected status code produced by 'PUT {$this->uploadUrl}': $status"); } } throw new \Exception('OneDrive did not create a drive item for the uploaded file'); }
[ "public", "function", "complete", "(", ")", "{", "$", "stream", "=", "$", "this", "->", "content", "instanceof", "Stream", "?", "$", "this", "->", "content", ":", "Psr7", "\\", "stream_for", "(", "$", "this", "->", "content", ")", ";", "if", "(", "$"...
Uploads the content in multiple ranges and completes this session. @return DriveItemProxy The drive item created. @todo Support retries on errors.
[ "Uploads", "the", "content", "in", "multiple", "ranges", "and", "completes", "this", "session", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Proxy/UploadSessionProxy.php#L110-L166
train
krizalys/onedrive-php-sdk
src/Client.php
Client.getLogInUrl
public function getLogInUrl(array $scopes, $redirectUri) { $redirectUri = (string) $redirectUri; $this->_state->redirect_uri = $redirectUri; $values = [ 'client_id' => $this->clientId, 'response_type' => 'code', 'redirect_uri' => $redirectUri, 'scope' => implode(' ', $scopes), 'response_mode' => 'query', ]; $query = http_build_query($values, '', '&', PHP_QUERY_RFC3986); // When visiting this URL and authenticating successfully, the agent is // redirected to the redirect URI, with a code passed in the query // string (the name of the variable is "code"). This is suitable for // PHP. return self::AUTH_URL . "?$query"; }
php
public function getLogInUrl(array $scopes, $redirectUri) { $redirectUri = (string) $redirectUri; $this->_state->redirect_uri = $redirectUri; $values = [ 'client_id' => $this->clientId, 'response_type' => 'code', 'redirect_uri' => $redirectUri, 'scope' => implode(' ', $scopes), 'response_mode' => 'query', ]; $query = http_build_query($values, '', '&', PHP_QUERY_RFC3986); // When visiting this URL and authenticating successfully, the agent is // redirected to the redirect URI, with a code passed in the query // string (the name of the variable is "code"). This is suitable for // PHP. return self::AUTH_URL . "?$query"; }
[ "public", "function", "getLogInUrl", "(", "array", "$", "scopes", ",", "$", "redirectUri", ")", "{", "$", "redirectUri", "=", "(", "string", ")", "$", "redirectUri", ";", "$", "this", "->", "_state", "->", "redirect_uri", "=", "$", "redirectUri", ";", "$...
Gets the URL of the log in form. After login, the browser is redirected to the redirect URI, and a code is passed as a query string parameter to this URI. The browser is also redirected to the redirect URI if the user is already logged in. @param array $scopes The OneDrive scopes requested by the application. Supported values: - 'offline_access' - 'files.read' - 'files.read.all' - 'files.readwrite' - 'files.readwrite.all' @param string $redirectUri The URI to which to redirect to upon successful log in. @return string The log in URL.
[ "Gets", "the", "URL", "of", "the", "log", "in", "form", ".", "After", "login", "the", "browser", "is", "redirected", "to", "the", "redirect", "URI", "and", "a", "code", "is", "passed", "as", "a", "query", "string", "parameter", "to", "this", "URI", "."...
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L153-L173
train
krizalys/onedrive-php-sdk
src/Client.php
Client.getTokenExpire
public function getTokenExpire() { return $this->_state->token->obtained + $this->_state->token->data->expires_in - time(); }
php
public function getTokenExpire() { return $this->_state->token->obtained + $this->_state->token->data->expires_in - time(); }
[ "public", "function", "getTokenExpire", "(", ")", "{", "return", "$", "this", "->", "_state", "->", "token", "->", "obtained", "+", "$", "this", "->", "_state", "->", "token", "->", "data", "->", "expires_in", "-", "time", "(", ")", ";", "}" ]
Gets the access token expiration delay. @return int The token expiration delay, in seconds.
[ "Gets", "the", "access", "token", "expiration", "delay", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L181-L185
train
krizalys/onedrive-php-sdk
src/Client.php
Client.getAccessTokenStatus
public function getAccessTokenStatus() { if (null === $this->_state->token) { return 0; } $remaining = $this->getTokenExpire(); if (0 >= $remaining) { return -2; } if (60 >= $remaining) { return -1; } return 1; }
php
public function getAccessTokenStatus() { if (null === $this->_state->token) { return 0; } $remaining = $this->getTokenExpire(); if (0 >= $remaining) { return -2; } if (60 >= $remaining) { return -1; } return 1; }
[ "public", "function", "getAccessTokenStatus", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_state", "->", "token", ")", "{", "return", "0", ";", "}", "$", "remaining", "=", "$", "this", "->", "getTokenExpire", "(", ")", ";", "if", "("...
Gets the status of the current access token. @return int The status of the current access token: - 0 No access token. - -1 Access token will expire soon (1 minute or less). - -2 Access token is expired. - 1 Access token is valid.
[ "Gets", "the", "status", "of", "the", "current", "access", "token", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L197-L214
train
krizalys/onedrive-php-sdk
src/Client.php
Client.obtainAccessToken
public function obtainAccessToken($clientSecret, $code) { if (null === $this->_state->redirect_uri) { throw new \Exception( 'The state\'s redirect URI must be set to call' . ' obtainAccessToken()' ); } $values = [ 'client_id' => $this->clientId, 'redirect_uri' => $this->_state->redirect_uri, 'client_secret' => (string) $clientSecret, 'code' => (string) $code, 'grant_type' => 'authorization_code', ]; $response = $this->httpClient->post( self::TOKEN_URL, ['form_params' => $values] ); $body = $response->getBody(); $data = json_decode($body); if ($data === null) { throw new \Exception('json_decode() failed'); } $this->_state->redirect_uri = null; $this->_state->token = (object) [ 'obtained' => time(), 'data' => $data, ]; $this->graph->setAccessToken($this->_state->token->data->access_token); }
php
public function obtainAccessToken($clientSecret, $code) { if (null === $this->_state->redirect_uri) { throw new \Exception( 'The state\'s redirect URI must be set to call' . ' obtainAccessToken()' ); } $values = [ 'client_id' => $this->clientId, 'redirect_uri' => $this->_state->redirect_uri, 'client_secret' => (string) $clientSecret, 'code' => (string) $code, 'grant_type' => 'authorization_code', ]; $response = $this->httpClient->post( self::TOKEN_URL, ['form_params' => $values] ); $body = $response->getBody(); $data = json_decode($body); if ($data === null) { throw new \Exception('json_decode() failed'); } $this->_state->redirect_uri = null; $this->_state->token = (object) [ 'obtained' => time(), 'data' => $data, ]; $this->graph->setAccessToken($this->_state->token->data->access_token); }
[ "public", "function", "obtainAccessToken", "(", "$", "clientSecret", ",", "$", "code", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_state", "->", "redirect_uri", ")", "{", "throw", "new", "\\", "Exception", "(", "'The state\\'s redirect URI must be...
Obtains a new access token from OAuth. This token is valid for one hour. @param string $clientSecret The OneDrive client secret. @param string $code The code returned by OneDrive after successful log in. @throws Exception Thrown if the redirect URI of this Client instance's state is not set. @throws Exception Thrown if the HTTP response body cannot be JSON-decoded.
[ "Obtains", "a", "new", "access", "token", "from", "OAuth", ".", "This", "token", "is", "valid", "for", "one", "hour", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L230-L267
train
krizalys/onedrive-php-sdk
src/Client.php
Client.renewAccessToken
public function renewAccessToken($clientSecret) { if (null === $this->_state->token->data->refresh_token) { throw new \Exception( 'The refresh token is not set or no permission for' . ' \'wl.offline_access\' was given to renew the token' ); } $values = [ 'client_id' => $this->clientId, 'client_secret' => $clientSecret, 'grant_type' => 'refresh_token', 'refresh_token' => $this->_state->token->data->refresh_token, ]; $response = $this->httpClient->post( self::TOKEN_URL, ['form_params' => $values] ); $body = $response->getBody(); $data = json_decode($body); if ($data === null) { throw new \Exception('json_decode() failed'); } $this->_state->token = (object) [ 'obtained' => time(), 'data' => $data, ]; }
php
public function renewAccessToken($clientSecret) { if (null === $this->_state->token->data->refresh_token) { throw new \Exception( 'The refresh token is not set or no permission for' . ' \'wl.offline_access\' was given to renew the token' ); } $values = [ 'client_id' => $this->clientId, 'client_secret' => $clientSecret, 'grant_type' => 'refresh_token', 'refresh_token' => $this->_state->token->data->refresh_token, ]; $response = $this->httpClient->post( self::TOKEN_URL, ['form_params' => $values] ); $body = $response->getBody(); $data = json_decode($body); if ($data === null) { throw new \Exception('json_decode() failed'); } $this->_state->token = (object) [ 'obtained' => time(), 'data' => $data, ]; }
[ "public", "function", "renewAccessToken", "(", "$", "clientSecret", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_state", "->", "token", "->", "data", "->", "refresh_token", ")", "{", "throw", "new", "\\", "Exception", "(", "'The refresh token is ...
Renews the access token from OAuth. This token is valid for one hour. @param string $clientSecret The client secret.
[ "Renews", "the", "access", "token", "from", "OAuth", ".", "This", "token", "is", "valid", "for", "one", "hour", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L275-L307
train
krizalys/onedrive-php-sdk
src/Client.php
Client.createFolder
public function createFolder($name, $parentId = null, $description = null) { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $this->getMyDrive(); $item = $parentId !== null ? $this->getDriveItemById($drive->id, $parentId) : $drive->getRoot(); $options = []; if ($description !== null) { $options += [ 'description' => (string) $description, ]; } $item = $item->createFolder($name, $options); $options = $this->buildOptions($item, ['parent_id' => $parentId]); return new Folder($this, $item->id, $options); }
php
public function createFolder($name, $parentId = null, $description = null) { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $this->getMyDrive(); $item = $parentId !== null ? $this->getDriveItemById($drive->id, $parentId) : $drive->getRoot(); $options = []; if ($description !== null) { $options += [ 'description' => (string) $description, ]; } $item = $item->createFolder($name, $options); $options = $this->buildOptions($item, ['parent_id' => $parentId]); return new Folder($this, $item->id, $options); }
[ "public", "function", "createFolder", "(", "$", "name", ",", "$", "parentId", "=", "null", ",", "$", "description", "=", "null", ")", "{", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in version 3;'", ".", "' use Krizalys\\Onedrive\\...
Creates a folder in the current OneDrive account. @param string $name The name of the OneDrive folder to be created. @param null|string $parentId The ID of the OneDrive folder into which to create the OneDrive folder, or null to create it in the OneDrive root folder. Default: null. @param null|string $description The description of the OneDrive folder to be created, or null to create it without a description. Default: null. @return Folder The folder created, as a Folder instance referencing to the OneDrive folder created. @deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::createFolder() instead.
[ "Creates", "a", "folder", "in", "the", "current", "OneDrive", "account", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L655-L683
train
krizalys/onedrive-php-sdk
src/Client.php
Client.createFile
public function createFile( $name, $parentId = null, $content = '', array $options = [] ) { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $this->getMyDrive(); $item = $parentId !== null ? $this->getDriveItemById($drive->id, $parentId) : $drive->getRoot(); $item = $item->upload($name, $content); $options = $this->buildOptions($item, ['parent_id' => $parentId]); return new File($this, $item->id, $options); }
php
public function createFile( $name, $parentId = null, $content = '', array $options = [] ) { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Proxy\DriveItemProxy::upload()' . ' instead', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $this->getMyDrive(); $item = $parentId !== null ? $this->getDriveItemById($drive->id, $parentId) : $drive->getRoot(); $item = $item->upload($name, $content); $options = $this->buildOptions($item, ['parent_id' => $parentId]); return new File($this, $item->id, $options); }
[ "public", "function", "createFile", "(", "$", "name", ",", "$", "parentId", "=", "null", ",", "$", "content", "=", "''", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in...
Creates a file in the current OneDrive account. @param string $name The name of the OneDrive file to be created. @param null|string $parentId The ID of the OneDrive folder into which to create the OneDrive file, or null to create it in the OneDrive root folder. Default: null. @param string|resource|\GuzzleHttp\Psr7\Stream $content The content of the OneDrive file to be created, as a string or as a resource to an already opened file. Default: ''. @param array $options The options. @return File The file created, as File instance referencing to the OneDrive file created. @throws Exception Thrown on I/O errors. @deprecated Use Krizalys\Onedrive\Proxy\DriveItemProxy::upload() instead. @todo Support name conflict behavior. @todo Support content type in options.
[ "Creates", "a", "file", "in", "the", "current", "OneDrive", "account", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L712-L736
train
krizalys/onedrive-php-sdk
src/Client.php
Client.fetchDriveItem
public function fetchDriveItem($driveItemId = null) { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Client::getDriveItemById() instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $this->getMyDrive(); $item = $driveItemId !== null ? $this->getDriveItemById($drive->id, $driveItemId) : $drive->getRoot(); $options = $this->buildOptions($item, ['parent_id' => $driveItemId]); return $this->isFolder($item) ? new Folder($this, $item->id, $options) : new File($this, $item->id, $options); }
php
public function fetchDriveItem($driveItemId = null) { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Client::getDriveItemById() instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $drive = $this->getMyDrive(); $item = $driveItemId !== null ? $this->getDriveItemById($drive->id, $driveItemId) : $drive->getRoot(); $options = $this->buildOptions($item, ['parent_id' => $driveItemId]); return $this->isFolder($item) ? new Folder($this, $item->id, $options) : new File($this, $item->id, $options); }
[ "public", "function", "fetchDriveItem", "(", "$", "driveItemId", "=", "null", ")", "{", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in version 3;'", ".", "' use Krizalys\\Onedrive\\Client::getDriveItemById() instead.'", ",", "__METHOD__", ")"...
Fetches a drive item from the current OneDrive account. @param null|string $driveItemId The unique ID of the OneDrive drive item to fetch, or null to fetch the OneDrive root folder. Default: null. @return object The drive item fetched, as a DriveItem instance referencing to the OneDrive drive item fetched. @deprecated Use Krizalys\Onedrive\Client::getDriveItemById() instead.
[ "Fetches", "a", "drive", "item", "from", "the", "current", "OneDrive", "account", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L751-L771
train
krizalys/onedrive-php-sdk
src/Client.php
Client.fetchRoot
public function fetchRoot() { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Client::getRoot() instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $item = $this->getRoot(); $options = $this->buildOptions($item); return new Folder($this, $item->id, $options); }
php
public function fetchRoot() { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Client::getRoot() instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $item = $this->getRoot(); $options = $this->buildOptions($item); return new Folder($this, $item->id, $options); }
[ "public", "function", "fetchRoot", "(", ")", "{", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in version 3;'", ".", "' use Krizalys\\Onedrive\\Client::getRoot() instead.'", ",", "__METHOD__", ")", ";", "@", "trigger_error", "(", "$", "mes...
Fetches the root folder from the current OneDrive account. @return Folder The root folder, as a Folder instance referencing to the OneDrive root folder. @deprecated Use Krizalys\Onedrive\Client::getRoot() instead.
[ "Fetches", "the", "root", "folder", "from", "the", "current", "OneDrive", "account", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L782-L795
train
krizalys/onedrive-php-sdk
src/Client.php
Client.fetchPics
public function fetchPics() { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Client::getSpecialFolder() instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $item = $this->getSpecialFolder('photos'); $options = $this->buildOptions($item); return new Folder($this, $item->id, $options); }
php
public function fetchPics() { $message = sprintf( '%s() is deprecated and will be removed in version 3;' . ' use Krizalys\Onedrive\Client::getSpecialFolder() instead.', __METHOD__ ); @trigger_error($message, E_USER_DEPRECATED); $item = $this->getSpecialFolder('photos'); $options = $this->buildOptions($item); return new Folder($this, $item->id, $options); }
[ "public", "function", "fetchPics", "(", ")", "{", "$", "message", "=", "sprintf", "(", "'%s() is deprecated and will be removed in version 3;'", ".", "' use Krizalys\\Onedrive\\Client::getSpecialFolder() instead.'", ",", "__METHOD__", ")", ";", "@", "trigger_error", "(", "$...
Fetches the "Pictures" folder from the current OneDrive account. @return Folder The "Pictures" folder, as a Folder instance referencing to the OneDrive "Pictures" folder. @deprecated Use Krizalys\Onedrive\Client::getSpecialFolder() instead.
[ "Fetches", "the", "Pictures", "folder", "from", "the", "current", "OneDrive", "account", "." ]
80fd1be8e149190e44dd5a055bad09bafda2c330
https://github.com/krizalys/onedrive-php-sdk/blob/80fd1be8e149190e44dd5a055bad09bafda2c330/src/Client.php#L854-L867
train