id
int32
0
241k
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
222,000
claroline/CoreBundle
Controller/ResourcePropertiesController.php
ResourcePropertiesController.checkAccess
private function checkAccess($permission, $collection) { if (!$this->authorization->isGranted($permission, $collection)) { throw new AccessDeniedException(print_r($collection->getErrorsForDisplay(), true)); } }
php
private function checkAccess($permission, $collection) { if (!$this->authorization->isGranted($permission, $collection)) { throw new AccessDeniedException(print_r($collection->getErrorsForDisplay(), true)); } }
[ "private", "function", "checkAccess", "(", "$", "permission", ",", "$", "collection", ")", "{", "if", "(", "!", "$", "this", "->", "authorization", "->", "isGranted", "(", "$", "permission", ",", "$", "collection", ")", ")", "{", "throw", "new", "AccessDeniedException", "(", "print_r", "(", "$", "collection", "->", "getErrorsForDisplay", "(", ")", ",", "true", ")", ")", ";", "}", "}" ]
Checks if the current user has the right to do an action on a ResourceCollection. Be carrefull, ResourceCollection may need some aditionnal parameters. - for CREATE: $collection->setAttributes(array('type' => $resourceType)) where $resourceType is the name of the resource type. - for MOVE / COPY $collection->setAttributes(array('parent' => $parent)) where $parent is the new parent entity. @param string $permission @param ResourceCollection $collection @throws AccessDeniedException
[ "Checks", "if", "the", "current", "user", "has", "the", "right", "to", "do", "an", "action", "on", "a", "ResourceCollection", ".", "Be", "carrefull", "ResourceCollection", "may", "need", "some", "aditionnal", "parameters", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/ResourcePropertiesController.php#L327-L332
222,001
claroline/CoreBundle
Manager/WidgetManager.php
WidgetManager.createInstance
public function createInstance( Widget $widget, $isAdmin, $isDesktop, User $user = null, Workspace $ws = null ) { if (!$widget->isDisplayableInDesktop()) { if ($isDesktop || $user) { throw new \Exception("This widget doesn't support the desktop"); } } if (!$widget->isDisplayableInWorkspace()) { if (!$isDesktop || $ws) { throw new \Exception("This widget doesn't support the workspace"); } } $instance = new WidgetInstance($widget); $instance->setName($this->translator->trans($widget->getName(), array(), 'widget')); $instance->setIsAdmin($isAdmin); $instance->setIsDesktop($isDesktop); $instance->setWidget($widget); $instance->setUser($user); $instance->setWorkspace($ws); $this->om->persist($instance); $this->om->flush(); return $instance; }
php
public function createInstance( Widget $widget, $isAdmin, $isDesktop, User $user = null, Workspace $ws = null ) { if (!$widget->isDisplayableInDesktop()) { if ($isDesktop || $user) { throw new \Exception("This widget doesn't support the desktop"); } } if (!$widget->isDisplayableInWorkspace()) { if (!$isDesktop || $ws) { throw new \Exception("This widget doesn't support the workspace"); } } $instance = new WidgetInstance($widget); $instance->setName($this->translator->trans($widget->getName(), array(), 'widget')); $instance->setIsAdmin($isAdmin); $instance->setIsDesktop($isDesktop); $instance->setWidget($widget); $instance->setUser($user); $instance->setWorkspace($ws); $this->om->persist($instance); $this->om->flush(); return $instance; }
[ "public", "function", "createInstance", "(", "Widget", "$", "widget", ",", "$", "isAdmin", ",", "$", "isDesktop", ",", "User", "$", "user", "=", "null", ",", "Workspace", "$", "ws", "=", "null", ")", "{", "if", "(", "!", "$", "widget", "->", "isDisplayableInDesktop", "(", ")", ")", "{", "if", "(", "$", "isDesktop", "||", "$", "user", ")", "{", "throw", "new", "\\", "Exception", "(", "\"This widget doesn't support the desktop\"", ")", ";", "}", "}", "if", "(", "!", "$", "widget", "->", "isDisplayableInWorkspace", "(", ")", ")", "{", "if", "(", "!", "$", "isDesktop", "||", "$", "ws", ")", "{", "throw", "new", "\\", "Exception", "(", "\"This widget doesn't support the workspace\"", ")", ";", "}", "}", "$", "instance", "=", "new", "WidgetInstance", "(", "$", "widget", ")", ";", "$", "instance", "->", "setName", "(", "$", "this", "->", "translator", "->", "trans", "(", "$", "widget", "->", "getName", "(", ")", ",", "array", "(", ")", ",", "'widget'", ")", ")", ";", "$", "instance", "->", "setIsAdmin", "(", "$", "isAdmin", ")", ";", "$", "instance", "->", "setIsDesktop", "(", "$", "isDesktop", ")", ";", "$", "instance", "->", "setWidget", "(", "$", "widget", ")", ";", "$", "instance", "->", "setUser", "(", "$", "user", ")", ";", "$", "instance", "->", "setWorkspace", "(", "$", "ws", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "instance", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "return", "$", "instance", ";", "}" ]
Creates a widget instance. @param \Claroline\CoreBundle\Entity\Widget\Widget $widget @param boolean $isAdmin @param boolean $isDesktop @param \Claroline\CoreBundle\Entity\User $user @param \Claroline\CoreBundle\Entity\Workspace\Workspace $ws @return \Claroline\CoreBundle\Entity\Widget\WidgetInstance @throws \Exception
[ "Creates", "a", "widget", "instance", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/WidgetManager.php#L69-L100
222,002
claroline/CoreBundle
Manager/WorkspaceManager.php
WorkspaceManager.rename
public function rename(Workspace $workspace, $name) { $workspace->setName($name); $root = $this->resourceManager->getWorkspaceRoot($workspace); $root->setName($name); $this->om->persist($workspace); $this->om->persist($root); $this->om->flush(); }
php
public function rename(Workspace $workspace, $name) { $workspace->setName($name); $root = $this->resourceManager->getWorkspaceRoot($workspace); $root->setName($name); $this->om->persist($workspace); $this->om->persist($root); $this->om->flush(); }
[ "public", "function", "rename", "(", "Workspace", "$", "workspace", ",", "$", "name", ")", "{", "$", "workspace", "->", "setName", "(", "$", "name", ")", ";", "$", "root", "=", "$", "this", "->", "resourceManager", "->", "getWorkspaceRoot", "(", "$", "workspace", ")", ";", "$", "root", "->", "setName", "(", "$", "name", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "workspace", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "root", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Rename a workspace. @param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace @param string $name
[ "Rename", "a", "workspace", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/WorkspaceManager.php#L153-L161
222,003
claroline/CoreBundle
Manager/WorkspaceManager.php
WorkspaceManager.create
public function create(Configuration $configuration, User $manager) { $transfertManager = $this->container->get('claroline.manager.transfert_manager'); if ($this->logger) $transfertManager->setLogger($this->logger); $workspace = $transfertManager->createWorkspace($configuration, $manager); return $workspace; }
php
public function create(Configuration $configuration, User $manager) { $transfertManager = $this->container->get('claroline.manager.transfert_manager'); if ($this->logger) $transfertManager->setLogger($this->logger); $workspace = $transfertManager->createWorkspace($configuration, $manager); return $workspace; }
[ "public", "function", "create", "(", "Configuration", "$", "configuration", ",", "User", "$", "manager", ")", "{", "$", "transfertManager", "=", "$", "this", "->", "container", "->", "get", "(", "'claroline.manager.transfert_manager'", ")", ";", "if", "(", "$", "this", "->", "logger", ")", "$", "transfertManager", "->", "setLogger", "(", "$", "this", "->", "logger", ")", ";", "$", "workspace", "=", "$", "transfertManager", "->", "createWorkspace", "(", "$", "configuration", ",", "$", "manager", ")", ";", "return", "$", "workspace", ";", "}" ]
Creates a workspace. @param \Claroline\CoreBundle\Library\Workspace\Configuration $configuration @param \Claroline\CoreBundle\Entity\User $manager @param bool $createUsers @param bool $importUsers @return \Claroline\CoreBundle\Entity\Workspace\AbstractWorkspace
[ "Creates", "a", "workspace", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/WorkspaceManager.php#L173-L180
222,004
claroline/CoreBundle
Manager/WorkspaceManager.php
WorkspaceManager.importInExistingWorkspace
public function importInExistingWorkspace(Configuration $configuration, Workspace $workspace) { $root = $this->resourceManager->getResourceFromNode($this->resourceManager->getWorkspaceRoot($workspace)); $wsRoles = $this->roleManager->getRolesByWorkspace($workspace); $entityRoles = []; foreach ($wsRoles as $wsRole) { $entityRoles[$this->roleManager->getWorkspaceRoleBaseName($wsRole)] = $wsRole; } $workspace = $this->container->get('claroline.manager.transfert_manager')->importResources( $configuration, $workspace->getCreator(), $root->getResourceNode() ); $this->importRichText(); return $workspace; }
php
public function importInExistingWorkspace(Configuration $configuration, Workspace $workspace) { $root = $this->resourceManager->getResourceFromNode($this->resourceManager->getWorkspaceRoot($workspace)); $wsRoles = $this->roleManager->getRolesByWorkspace($workspace); $entityRoles = []; foreach ($wsRoles as $wsRole) { $entityRoles[$this->roleManager->getWorkspaceRoleBaseName($wsRole)] = $wsRole; } $workspace = $this->container->get('claroline.manager.transfert_manager')->importResources( $configuration, $workspace->getCreator(), $root->getResourceNode() ); $this->importRichText(); return $workspace; }
[ "public", "function", "importInExistingWorkspace", "(", "Configuration", "$", "configuration", ",", "Workspace", "$", "workspace", ")", "{", "$", "root", "=", "$", "this", "->", "resourceManager", "->", "getResourceFromNode", "(", "$", "this", "->", "resourceManager", "->", "getWorkspaceRoot", "(", "$", "workspace", ")", ")", ";", "$", "wsRoles", "=", "$", "this", "->", "roleManager", "->", "getRolesByWorkspace", "(", "$", "workspace", ")", ";", "$", "entityRoles", "=", "[", "]", ";", "foreach", "(", "$", "wsRoles", "as", "$", "wsRole", ")", "{", "$", "entityRoles", "[", "$", "this", "->", "roleManager", "->", "getWorkspaceRoleBaseName", "(", "$", "wsRole", ")", "]", "=", "$", "wsRole", ";", "}", "$", "workspace", "=", "$", "this", "->", "container", "->", "get", "(", "'claroline.manager.transfert_manager'", ")", "->", "importResources", "(", "$", "configuration", ",", "$", "workspace", "->", "getCreator", "(", ")", ",", "$", "root", "->", "getResourceNode", "(", ")", ")", ";", "$", "this", "->", "importRichText", "(", ")", ";", "return", "$", "workspace", ";", "}" ]
Import the content of an archive in a workspace. @param Configuration $configuration @param Workspace $workspace @return Workspace
[ "Import", "the", "content", "of", "an", "archive", "in", "a", "workspace", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/WorkspaceManager.php#L861-L880
222,005
claroline/CoreBundle
Manager/WorkspaceManager.php
WorkspaceManager.countResources
public function countResources(Workspace $workspace) { //@todo count directory from dql $root = $this->resourceManager->getWorkspaceRoot($workspace); if (!$root) return 0; $descendants = $this->resourceManager->getDescendants($root); return count($descendants); }
php
public function countResources(Workspace $workspace) { //@todo count directory from dql $root = $this->resourceManager->getWorkspaceRoot($workspace); if (!$root) return 0; $descendants = $this->resourceManager->getDescendants($root); return count($descendants); }
[ "public", "function", "countResources", "(", "Workspace", "$", "workspace", ")", "{", "//@todo count directory from dql", "$", "root", "=", "$", "this", "->", "resourceManager", "->", "getWorkspaceRoot", "(", "$", "workspace", ")", ";", "if", "(", "!", "$", "root", ")", "return", "0", ";", "$", "descendants", "=", "$", "this", "->", "resourceManager", "->", "getDescendants", "(", "$", "root", ")", ";", "return", "count", "(", "$", "descendants", ")", ";", "}" ]
Count the number of resources in a workspace @param Workspace $workspace @return integer
[ "Count", "the", "number", "of", "resources", "in", "a", "workspace" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/WorkspaceManager.php#L1036-L1044
222,006
claroline/CoreBundle
Listener/Tool/ResourceManagerListener.php
ResourceManagerListener.resourceWorkspace
public function resourceWorkspace($workspaceId) { if (!$this->request) { throw new NoHttpRequestException(); } $breadcrumbsIds = $this->request->query->get('_breadcrumbs'); if ($breadcrumbsIds != null) { $ancestors = $this->manager->getByIds($breadcrumbsIds); if (!$this->manager->isPathValid($ancestors)) { throw new \Exception('Breadcrumbs invalid'); }; } else { $ancestors = array(); } $path = array(); foreach ($ancestors as $ancestor) { $path[] = $this->manager->toArray($ancestor, $this->tokenStorage->getToken()); } $jsonPath = json_encode($path); $workspace = $this->workspaceManager->getWorkspaceById($workspaceId); $directoryId = $this->resourceManager->getWorkspaceRoot($workspace)->getId(); $resourceTypes = $this->em->getRepository('ClarolineCoreBundle:Resource\ResourceType') ->findAll(); $resourceActions = $this->em->getRepository('ClarolineCoreBundle:Resource\MenuAction') ->findByResourceType(null); return $this->templating->render( 'ClarolineCoreBundle:Tool\workspace\resource_manager:resources.html.twig', array( 'workspace' => $workspace, 'directoryId' => $directoryId, 'resourceTypes' => $resourceTypes, 'resourceActions' => $resourceActions, 'jsonPath' => $jsonPath, 'maxPostSize' => ini_get('post_max_size'), 'resourceZoom' => $this->getZoom() ) ); }
php
public function resourceWorkspace($workspaceId) { if (!$this->request) { throw new NoHttpRequestException(); } $breadcrumbsIds = $this->request->query->get('_breadcrumbs'); if ($breadcrumbsIds != null) { $ancestors = $this->manager->getByIds($breadcrumbsIds); if (!$this->manager->isPathValid($ancestors)) { throw new \Exception('Breadcrumbs invalid'); }; } else { $ancestors = array(); } $path = array(); foreach ($ancestors as $ancestor) { $path[] = $this->manager->toArray($ancestor, $this->tokenStorage->getToken()); } $jsonPath = json_encode($path); $workspace = $this->workspaceManager->getWorkspaceById($workspaceId); $directoryId = $this->resourceManager->getWorkspaceRoot($workspace)->getId(); $resourceTypes = $this->em->getRepository('ClarolineCoreBundle:Resource\ResourceType') ->findAll(); $resourceActions = $this->em->getRepository('ClarolineCoreBundle:Resource\MenuAction') ->findByResourceType(null); return $this->templating->render( 'ClarolineCoreBundle:Tool\workspace\resource_manager:resources.html.twig', array( 'workspace' => $workspace, 'directoryId' => $directoryId, 'resourceTypes' => $resourceTypes, 'resourceActions' => $resourceActions, 'jsonPath' => $jsonPath, 'maxPostSize' => ini_get('post_max_size'), 'resourceZoom' => $this->getZoom() ) ); }
[ "public", "function", "resourceWorkspace", "(", "$", "workspaceId", ")", "{", "if", "(", "!", "$", "this", "->", "request", ")", "{", "throw", "new", "NoHttpRequestException", "(", ")", ";", "}", "$", "breadcrumbsIds", "=", "$", "this", "->", "request", "->", "query", "->", "get", "(", "'_breadcrumbs'", ")", ";", "if", "(", "$", "breadcrumbsIds", "!=", "null", ")", "{", "$", "ancestors", "=", "$", "this", "->", "manager", "->", "getByIds", "(", "$", "breadcrumbsIds", ")", ";", "if", "(", "!", "$", "this", "->", "manager", "->", "isPathValid", "(", "$", "ancestors", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Breadcrumbs invalid'", ")", ";", "}", ";", "}", "else", "{", "$", "ancestors", "=", "array", "(", ")", ";", "}", "$", "path", "=", "array", "(", ")", ";", "foreach", "(", "$", "ancestors", "as", "$", "ancestor", ")", "{", "$", "path", "[", "]", "=", "$", "this", "->", "manager", "->", "toArray", "(", "$", "ancestor", ",", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ")", ";", "}", "$", "jsonPath", "=", "json_encode", "(", "$", "path", ")", ";", "$", "workspace", "=", "$", "this", "->", "workspaceManager", "->", "getWorkspaceById", "(", "$", "workspaceId", ")", ";", "$", "directoryId", "=", "$", "this", "->", "resourceManager", "->", "getWorkspaceRoot", "(", "$", "workspace", ")", "->", "getId", "(", ")", ";", "$", "resourceTypes", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'ClarolineCoreBundle:Resource\\ResourceType'", ")", "->", "findAll", "(", ")", ";", "$", "resourceActions", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'ClarolineCoreBundle:Resource\\MenuAction'", ")", "->", "findByResourceType", "(", "null", ")", ";", "return", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:Tool\\workspace\\resource_manager:resources.html.twig'", ",", "array", "(", "'workspace'", "=>", "$", "workspace", ",", "'directoryId'", "=>", "$", "directoryId", ",", "'resourceTypes'", "=>", "$", "resourceTypes", ",", "'resourceActions'", "=>", "$", "resourceActions", ",", "'jsonPath'", "=>", "$", "jsonPath", ",", "'maxPostSize'", "=>", "ini_get", "(", "'post_max_size'", ")", ",", "'resourceZoom'", "=>", "$", "this", "->", "getZoom", "(", ")", ")", ")", ";", "}" ]
Renders the resources page with its layout. @param integer $workspaceId @throws \Claroline\CoreBundle\Listener\NoHttpRequestException @throws \Exception @return string
[ "Renders", "the", "resources", "page", "with", "its", "layout", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Listener/Tool/ResourceManagerListener.php#L136-L179
222,007
claroline/CoreBundle
Listener/Tool/ResourceManagerListener.php
ResourceManagerListener.resourceDesktop
public function resourceDesktop() { $resourceTypes = $this->em->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll(); $resourceActions = $this->em->getRepository('ClarolineCoreBundle:Resource\MenuAction') ->findByResourceType(null); return $this->templating->render( 'ClarolineCoreBundle:Tool\desktop\resource_manager:resources.html.twig', array( 'resourceTypes' => $resourceTypes, 'resourceActions' => $resourceActions, 'maxPostSize' => ini_get('post_max_size'), 'resourceZoom' => $this->getZoom() ) ); }
php
public function resourceDesktop() { $resourceTypes = $this->em->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll(); $resourceActions = $this->em->getRepository('ClarolineCoreBundle:Resource\MenuAction') ->findByResourceType(null); return $this->templating->render( 'ClarolineCoreBundle:Tool\desktop\resource_manager:resources.html.twig', array( 'resourceTypes' => $resourceTypes, 'resourceActions' => $resourceActions, 'maxPostSize' => ini_get('post_max_size'), 'resourceZoom' => $this->getZoom() ) ); }
[ "public", "function", "resourceDesktop", "(", ")", "{", "$", "resourceTypes", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'ClarolineCoreBundle:Resource\\ResourceType'", ")", "->", "findAll", "(", ")", ";", "$", "resourceActions", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'ClarolineCoreBundle:Resource\\MenuAction'", ")", "->", "findByResourceType", "(", "null", ")", ";", "return", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:Tool\\desktop\\resource_manager:resources.html.twig'", ",", "array", "(", "'resourceTypes'", "=>", "$", "resourceTypes", ",", "'resourceActions'", "=>", "$", "resourceActions", ",", "'maxPostSize'", "=>", "ini_get", "(", "'post_max_size'", ")", ",", "'resourceZoom'", "=>", "$", "this", "->", "getZoom", "(", ")", ")", ")", ";", "}" ]
Displays the resource manager. @return string
[ "Displays", "the", "resource", "manager", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Listener/Tool/ResourceManagerListener.php#L186-L201
222,008
claroline/CoreBundle
Library/Utilities/ZipArchive.php
ZipArchive.extractTo
public function extractTo($extractPath, $files = null) { $fs = new FileSystem(); $ds = DIRECTORY_SEPARATOR; for ($i = 0; $i < $this->numFiles; $i++) { $oldName = parent::getNameIndex($i); $newName = mb_convert_encoding( $this->getNameIndex($i), 'ISO-8859-1', 'CP850,UTF-8' ); //we cheat a little because we can't tell wich name the extracted part should have //so we put it a directory wich share it's name $tmpDir = $extractPath . $ds . '__claro_zip_hack_' . $oldName; parent::extractTo($tmpDir, parent::getNameIndex($i)); //now we move the content of the directory and we put the good name on it. foreach ($iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) { if ($item->isFile()) { $fs->mkdir(dirname($extractPath . $ds . $oldName)); $fs->rename($item->getPathname(), $extractPath . $ds . $oldName); } } } //we remove our 'trash here' $iterator = new \DirectoryIterator($extractPath); foreach ($iterator as $item) { if (strpos($item->getFilename(), '_claro_zip_hack')) { $fs->rmdir($item->getRealPath(), true); } } }
php
public function extractTo($extractPath, $files = null) { $fs = new FileSystem(); $ds = DIRECTORY_SEPARATOR; for ($i = 0; $i < $this->numFiles; $i++) { $oldName = parent::getNameIndex($i); $newName = mb_convert_encoding( $this->getNameIndex($i), 'ISO-8859-1', 'CP850,UTF-8' ); //we cheat a little because we can't tell wich name the extracted part should have //so we put it a directory wich share it's name $tmpDir = $extractPath . $ds . '__claro_zip_hack_' . $oldName; parent::extractTo($tmpDir, parent::getNameIndex($i)); //now we move the content of the directory and we put the good name on it. foreach ($iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) { if ($item->isFile()) { $fs->mkdir(dirname($extractPath . $ds . $oldName)); $fs->rename($item->getPathname(), $extractPath . $ds . $oldName); } } } //we remove our 'trash here' $iterator = new \DirectoryIterator($extractPath); foreach ($iterator as $item) { if (strpos($item->getFilename(), '_claro_zip_hack')) { $fs->rmdir($item->getRealPath(), true); } } }
[ "public", "function", "extractTo", "(", "$", "extractPath", ",", "$", "files", "=", "null", ")", "{", "$", "fs", "=", "new", "FileSystem", "(", ")", ";", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "numFiles", ";", "$", "i", "++", ")", "{", "$", "oldName", "=", "parent", "::", "getNameIndex", "(", "$", "i", ")", ";", "$", "newName", "=", "mb_convert_encoding", "(", "$", "this", "->", "getNameIndex", "(", "$", "i", ")", ",", "'ISO-8859-1'", ",", "'CP850,UTF-8'", ")", ";", "//we cheat a little because we can't tell wich name the extracted part should have", "//so we put it a directory wich share it's name", "$", "tmpDir", "=", "$", "extractPath", ".", "$", "ds", ".", "'__claro_zip_hack_'", ".", "$", "oldName", ";", "parent", "::", "extractTo", "(", "$", "tmpDir", ",", "parent", "::", "getNameIndex", "(", "$", "i", ")", ")", ";", "//now we move the content of the directory and we put the good name on it.", "foreach", "(", "$", "iterator", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "tmpDir", ",", "\\", "RecursiveDirectoryIterator", "::", "SKIP_DOTS", ")", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "isFile", "(", ")", ")", "{", "$", "fs", "->", "mkdir", "(", "dirname", "(", "$", "extractPath", ".", "$", "ds", ".", "$", "oldName", ")", ")", ";", "$", "fs", "->", "rename", "(", "$", "item", "->", "getPathname", "(", ")", ",", "$", "extractPath", ".", "$", "ds", ".", "$", "oldName", ")", ";", "}", "}", "}", "//we remove our 'trash here'", "$", "iterator", "=", "new", "\\", "DirectoryIterator", "(", "$", "extractPath", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "item", ")", "{", "if", "(", "strpos", "(", "$", "item", "->", "getFilename", "(", ")", ",", "'_claro_zip_hack'", ")", ")", "{", "$", "fs", "->", "rmdir", "(", "$", "item", "->", "getRealPath", "(", ")", ",", "true", ")", ";", "}", "}", "}" ]
It actually works but in this code lies madness.
[ "It", "actually", "works", "but", "in", "this", "code", "lies", "madness", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Utilities/ZipArchive.php#L19-L57
222,009
claroline/CoreBundle
Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereInUserWorkspace
public function whereInUserWorkspace(User $user) { $eol = PHP_EOL; $clause = "node.workspace IN{$eol}" . "({$eol}" . " SELECT aw FROM Claroline\CoreBundle\Entity\Workspace\Workspace aw{$eol}" . " JOIN aw.roles r{$eol}" . " WHERE r IN (SELECT r2 FROM Claroline\CoreBundle\Entity\Role r2 {$eol}". " LEFT JOIN r2.users u {$eol}" . " LEFT JOIN r2.groups g {$eol}" . " LEFT JOIN g.users u2 {$eol}" . " WHERE u.id = :user_id OR u2.id = :user_id {$eol}" . " ) {$eol}" . ") {$eol}"; $this->addWhereClause($clause); $this->parameters[':user_id'] = $user->getId(); return $this; }
php
public function whereInUserWorkspace(User $user) { $eol = PHP_EOL; $clause = "node.workspace IN{$eol}" . "({$eol}" . " SELECT aw FROM Claroline\CoreBundle\Entity\Workspace\Workspace aw{$eol}" . " JOIN aw.roles r{$eol}" . " WHERE r IN (SELECT r2 FROM Claroline\CoreBundle\Entity\Role r2 {$eol}". " LEFT JOIN r2.users u {$eol}" . " LEFT JOIN r2.groups g {$eol}" . " LEFT JOIN g.users u2 {$eol}" . " WHERE u.id = :user_id OR u2.id = :user_id {$eol}" . " ) {$eol}" . ") {$eol}"; $this->addWhereClause($clause); $this->parameters[':user_id'] = $user->getId(); return $this; }
[ "public", "function", "whereInUserWorkspace", "(", "User", "$", "user", ")", "{", "$", "eol", "=", "PHP_EOL", ";", "$", "clause", "=", "\"node.workspace IN{$eol}\"", ".", "\"({$eol}\"", ".", "\" SELECT aw FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace aw{$eol}\"", ".", "\" JOIN aw.roles r{$eol}\"", ".", "\" WHERE r IN (SELECT r2 FROM Claroline\\CoreBundle\\Entity\\Role r2 {$eol}\"", ".", "\" LEFT JOIN r2.users u {$eol}\"", ".", "\" LEFT JOIN r2.groups g {$eol}\"", ".", "\" LEFT JOIN g.users u2 {$eol}\"", ".", "\" WHERE u.id = :user_id OR u2.id = :user_id {$eol}\"", ".", "\" ) {$eol}\"", ".", "\") {$eol}\"", ";", "$", "this", "->", "addWhereClause", "(", "$", "clause", ")", ";", "$", "this", "->", "parameters", "[", "':user_id'", "]", "=", "$", "user", "->", "getId", "(", ")", ";", "return", "$", "this", ";", "}" ]
Filters nodes belonging to any of the workspaces a given user has access to. @param User $user @return ResourceQueryBuilder
[ "Filters", "nodes", "belonging", "to", "any", "of", "the", "workspaces", "a", "given", "user", "has", "access", "to", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceQueryBuilder.php#L228-L247
222,010
claroline/CoreBundle
Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereTypeIn
public function whereTypeIn(array $types) { if (count($types) > 0) { $this->joinSingleRelatives = true; $clause = ''; for ($i = 0, $count = count($types); $i < $count; $i++) { $clause .= $i === 0 ? "resourceType.name = :type_{$i}" : "OR resourceType.name = :type_{$i}"; $clause .= $i < $count - 1 ? PHP_EOL : ''; $this->parameters[":type_{$i}"] = $types[$i]; } $this->addWhereClause($clause); } return $this; }
php
public function whereTypeIn(array $types) { if (count($types) > 0) { $this->joinSingleRelatives = true; $clause = ''; for ($i = 0, $count = count($types); $i < $count; $i++) { $clause .= $i === 0 ? "resourceType.name = :type_{$i}" : "OR resourceType.name = :type_{$i}"; $clause .= $i < $count - 1 ? PHP_EOL : ''; $this->parameters[":type_{$i}"] = $types[$i]; } $this->addWhereClause($clause); } return $this; }
[ "public", "function", "whereTypeIn", "(", "array", "$", "types", ")", "{", "if", "(", "count", "(", "$", "types", ")", ">", "0", ")", "{", "$", "this", "->", "joinSingleRelatives", "=", "true", ";", "$", "clause", "=", "''", ";", "for", "(", "$", "i", "=", "0", ",", "$", "count", "=", "count", "(", "$", "types", ")", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "clause", ".=", "$", "i", "===", "0", "?", "\"resourceType.name = :type_{$i}\"", ":", "\"OR resourceType.name = :type_{$i}\"", ";", "$", "clause", ".=", "$", "i", "<", "$", "count", "-", "1", "?", "PHP_EOL", ":", "''", ";", "$", "this", "->", "parameters", "[", "\":type_{$i}\"", "]", "=", "$", "types", "[", "$", "i", "]", ";", "}", "$", "this", "->", "addWhereClause", "(", "$", "clause", ")", ";", "}", "return", "$", "this", ";", "}" ]
Filters nodes of any of the given types. @param array[string] $types @return ResourceQueryBuilder
[ "Filters", "nodes", "of", "any", "of", "the", "given", "types", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceQueryBuilder.php#L256-L274
222,011
claroline/CoreBundle
Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereRootIn
public function whereRootIn(array $roots) { if (0 !== $count = count($roots)) { $eol = PHP_EOL; $clause = "{$eol}({$eol}"; for ($i = 0; $i < $count; $i++) { $clause .= $i > 0 ? ' OR ' : ' '; $clause .= "node.path LIKE :root_{$i}{$eol}"; $this->parameters[":root_{$i}"] = "{$roots[$i]}_%"; } $this->addWhereClause($clause . ')'); } return $this; }
php
public function whereRootIn(array $roots) { if (0 !== $count = count($roots)) { $eol = PHP_EOL; $clause = "{$eol}({$eol}"; for ($i = 0; $i < $count; $i++) { $clause .= $i > 0 ? ' OR ' : ' '; $clause .= "node.path LIKE :root_{$i}{$eol}"; $this->parameters[":root_{$i}"] = "{$roots[$i]}_%"; } $this->addWhereClause($clause . ')'); } return $this; }
[ "public", "function", "whereRootIn", "(", "array", "$", "roots", ")", "{", "if", "(", "0", "!==", "$", "count", "=", "count", "(", "$", "roots", ")", ")", "{", "$", "eol", "=", "PHP_EOL", ";", "$", "clause", "=", "\"{$eol}({$eol}\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "clause", ".=", "$", "i", ">", "0", "?", "' OR '", ":", "' '", ";", "$", "clause", ".=", "\"node.path LIKE :root_{$i}{$eol}\"", ";", "$", "this", "->", "parameters", "[", "\":root_{$i}\"", "]", "=", "\"{$roots[$i]}_%\"", ";", "}", "$", "this", "->", "addWhereClause", "(", "$", "clause", ".", "')'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Filters nodes that are the descendants of any of the given root directory paths. @param array[string] $roots @return ResourceQueryBuilder
[ "Filters", "nodes", "that", "are", "the", "descendants", "of", "any", "of", "the", "given", "root", "directory", "paths", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceQueryBuilder.php#L283-L299
222,012
claroline/CoreBundle
Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereIsShortcut
public function whereIsShortcut() { $eol = PHP_EOL; $this->joinRelativesClause = "JOIN rs.resourceNode node{$eol}" . $this->joinRelativesClause; $this->joinRelativesClause = "JOIN rs.target target{$eol}" . $this->joinRelativesClause; $this->fromClause = "FROM Claroline\CoreBundle\Entity\Resource\ResourceShortcut rs{$eol}"; $this->selectClause .= ", target.id as target_id{$eol}"; $this->selectClause .= ", target.path as target_path{$eol}"; return $this; }
php
public function whereIsShortcut() { $eol = PHP_EOL; $this->joinRelativesClause = "JOIN rs.resourceNode node{$eol}" . $this->joinRelativesClause; $this->joinRelativesClause = "JOIN rs.target target{$eol}" . $this->joinRelativesClause; $this->fromClause = "FROM Claroline\CoreBundle\Entity\Resource\ResourceShortcut rs{$eol}"; $this->selectClause .= ", target.id as target_id{$eol}"; $this->selectClause .= ", target.path as target_path{$eol}"; return $this; }
[ "public", "function", "whereIsShortcut", "(", ")", "{", "$", "eol", "=", "PHP_EOL", ";", "$", "this", "->", "joinRelativesClause", "=", "\"JOIN rs.resourceNode node{$eol}\"", ".", "$", "this", "->", "joinRelativesClause", ";", "$", "this", "->", "joinRelativesClause", "=", "\"JOIN rs.target target{$eol}\"", ".", "$", "this", "->", "joinRelativesClause", ";", "$", "this", "->", "fromClause", "=", "\"FROM Claroline\\CoreBundle\\Entity\\Resource\\ResourceShortcut rs{$eol}\"", ";", "$", "this", "->", "selectClause", ".=", "\", target.id as target_id{$eol}\"", ";", "$", "this", "->", "selectClause", ".=", "\", target.path as target_path{$eol}\"", ";", "return", "$", "this", ";", "}" ]
Filters nodes that are shortcuts and selects their target. @return ResourceQueryBuilder
[ "Filters", "nodes", "that", "are", "shortcuts", "and", "selects", "their", "target", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceQueryBuilder.php#L367-L377
222,013
claroline/CoreBundle
Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereIsAccessible
public function whereIsAccessible($user) { $currentDate = new \DateTime(); $clause = '( creator.id = :creatorId OR ( node.published = true AND (node.accessibleFrom IS NULL OR node.accessibleFrom <= :currentdate) AND (node.accessibleUntil IS NULL OR node.accessibleUntil >= :currentdate) ) )'; $this->addWhereClause($clause); $this->parameters[':creatorId'] = ($user === 'anon.') ? -1 : $user->getId(); $this->parameters[':currentdate'] = $currentDate->format('Y-m-d H:i:s'); return $this; }
php
public function whereIsAccessible($user) { $currentDate = new \DateTime(); $clause = '( creator.id = :creatorId OR ( node.published = true AND (node.accessibleFrom IS NULL OR node.accessibleFrom <= :currentdate) AND (node.accessibleUntil IS NULL OR node.accessibleUntil >= :currentdate) ) )'; $this->addWhereClause($clause); $this->parameters[':creatorId'] = ($user === 'anon.') ? -1 : $user->getId(); $this->parameters[':currentdate'] = $currentDate->format('Y-m-d H:i:s'); return $this; }
[ "public", "function", "whereIsAccessible", "(", "$", "user", ")", "{", "$", "currentDate", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "clause", "=", "'(\n creator.id = :creatorId\n OR (\n node.published = true\n AND (node.accessibleFrom IS NULL OR node.accessibleFrom <= :currentdate)\n AND (node.accessibleUntil IS NULL OR node.accessibleUntil >= :currentdate)\n )\n )'", ";", "$", "this", "->", "addWhereClause", "(", "$", "clause", ")", ";", "$", "this", "->", "parameters", "[", "':creatorId'", "]", "=", "(", "$", "user", "===", "'anon.'", ")", "?", "-", "1", ":", "$", "user", "->", "getId", "(", ")", ";", "$", "this", "->", "parameters", "[", "':currentdate'", "]", "=", "$", "currentDate", "->", "format", "(", "'Y-m-d H:i:s'", ")", ";", "return", "$", "this", ";", "}" ]
Filters nodes that are published. @param $user (not typing because we don't want anon. to crash everything) @return ResourceQueryBuilder
[ "Filters", "nodes", "that", "are", "published", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceQueryBuilder.php#L405-L421
222,014
claroline/CoreBundle
Controller/Administration/UsersController.php
UsersController.executeGroupAdminAction
public function executeGroupAdminAction(Group $group, AdditionalAction $action) { $event = $this->eventDispatcher->dispatch($action->getType() . '_' . $action->getAction(), 'AdminGroupAction', array('group' => $group)); return $event->getResponse(); }
php
public function executeGroupAdminAction(Group $group, AdditionalAction $action) { $event = $this->eventDispatcher->dispatch($action->getType() . '_' . $action->getAction(), 'AdminGroupAction', array('group' => $group)); return $event->getResponse(); }
[ "public", "function", "executeGroupAdminAction", "(", "Group", "$", "group", ",", "AdditionalAction", "$", "action", ")", "{", "$", "event", "=", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "$", "action", "->", "getType", "(", ")", ".", "'_'", ".", "$", "action", "->", "getAction", "(", ")", ",", "'AdminGroupAction'", ",", "array", "(", "'group'", "=>", "$", "group", ")", ")", ";", "return", "$", "event", "->", "getResponse", "(", ")", ";", "}" ]
This method should be moved @EXT\Route( "/{group}/admin/action/{action}", name="admin_group_action", options={"expose"=true} )
[ "This", "method", "should", "be", "moved" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/Administration/UsersController.php#L622-L627
222,015
claroline/CoreBundle
Manager/CacheManager.php
CacheManager.refresh
public function refresh() { $this->removeCache(); $event = $this->eventManager->dispatch('refresh_cache', 'RefreshCache'); $this->writeCache($event->getParameters()); }
php
public function refresh() { $this->removeCache(); $event = $this->eventManager->dispatch('refresh_cache', 'RefreshCache'); $this->writeCache($event->getParameters()); }
[ "public", "function", "refresh", "(", ")", "{", "$", "this", "->", "removeCache", "(", ")", ";", "$", "event", "=", "$", "this", "->", "eventManager", "->", "dispatch", "(", "'refresh_cache'", ",", "'RefreshCache'", ")", ";", "$", "this", "->", "writeCache", "(", "$", "event", "->", "getParameters", "(", ")", ")", ";", "}" ]
Refresh the claroline cache
[ "Refresh", "the", "claroline", "cache" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/CacheManager.php#L93-L98
222,016
claroline/CoreBundle
Persistence/ObjectManager.php
ObjectManager.endFlushSuite
public function endFlushSuite() { if ($this->flushSuiteLevel === 0) { throw new NoFlushSuiteStartedException('No flush suite has been started'); } --$this->flushSuiteLevel; $this->flush(); if ($this->activateLog && $this->showFlushLevel) $this->logFlushLevel(); }
php
public function endFlushSuite() { if ($this->flushSuiteLevel === 0) { throw new NoFlushSuiteStartedException('No flush suite has been started'); } --$this->flushSuiteLevel; $this->flush(); if ($this->activateLog && $this->showFlushLevel) $this->logFlushLevel(); }
[ "public", "function", "endFlushSuite", "(", ")", "{", "if", "(", "$", "this", "->", "flushSuiteLevel", "===", "0", ")", "{", "throw", "new", "NoFlushSuiteStartedException", "(", "'No flush suite has been started'", ")", ";", "}", "--", "$", "this", "->", "flushSuiteLevel", ";", "$", "this", "->", "flush", "(", ")", ";", "if", "(", "$", "this", "->", "activateLog", "&&", "$", "this", "->", "showFlushLevel", ")", "$", "this", "->", "logFlushLevel", "(", ")", ";", "}" ]
Ends a previously opened flush suite. If there is no other active suite, a flush is performed. @throws NoFlushSuiteStartedException if no flush suite has been started
[ "Ends", "a", "previously", "opened", "flush", "suite", ".", "If", "there", "is", "no", "other", "active", "suite", "a", "flush", "is", "performed", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Persistence/ObjectManager.php#L117-L126
222,017
claroline/CoreBundle
Persistence/ObjectManager.php
ObjectManager.forceFlush
public function forceFlush() { if ($this->allowForceFlush) { if ($this->activateLog) $this->log('Flush was forced for level ' . $this->flushSuiteLevel. '.'); parent::flush(); } }
php
public function forceFlush() { if ($this->allowForceFlush) { if ($this->activateLog) $this->log('Flush was forced for level ' . $this->flushSuiteLevel. '.'); parent::flush(); } }
[ "public", "function", "forceFlush", "(", ")", "{", "if", "(", "$", "this", "->", "allowForceFlush", ")", "{", "if", "(", "$", "this", "->", "activateLog", ")", "$", "this", "->", "log", "(", "'Flush was forced for level '", ".", "$", "this", "->", "flushSuiteLevel", ".", "'.'", ")", ";", "parent", "::", "flush", "(", ")", ";", "}", "}" ]
Forces a flush.
[ "Forces", "a", "flush", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Persistence/ObjectManager.php#L131-L137
222,018
claroline/CoreBundle
Persistence/ObjectManager.php
ObjectManager.findByIds
public function findByIds($class, array $ids) { if (count($ids) === 0) { return array(); } $dql = "SELECT object FROM {$class} object WHERE object.id IN (:ids)"; $query = $this->wrapped->createQuery($dql); $query->setParameter('ids', $ids); $objects = $query->getResult(); if (($entityCount = count($objects)) !== ($idCount = count($ids))) { throw new MissingObjectException( "{$entityCount} out of {$idCount} ids don't match any existing object" ); } return $objects; }
php
public function findByIds($class, array $ids) { if (count($ids) === 0) { return array(); } $dql = "SELECT object FROM {$class} object WHERE object.id IN (:ids)"; $query = $this->wrapped->createQuery($dql); $query->setParameter('ids', $ids); $objects = $query->getResult(); if (($entityCount = count($objects)) !== ($idCount = count($ids))) { throw new MissingObjectException( "{$entityCount} out of {$idCount} ids don't match any existing object" ); } return $objects; }
[ "public", "function", "findByIds", "(", "$", "class", ",", "array", "$", "ids", ")", "{", "if", "(", "count", "(", "$", "ids", ")", "===", "0", ")", "{", "return", "array", "(", ")", ";", "}", "$", "dql", "=", "\"SELECT object FROM {$class} object WHERE object.id IN (:ids)\"", ";", "$", "query", "=", "$", "this", "->", "wrapped", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setParameter", "(", "'ids'", ",", "$", "ids", ")", ";", "$", "objects", "=", "$", "query", "->", "getResult", "(", ")", ";", "if", "(", "(", "$", "entityCount", "=", "count", "(", "$", "objects", ")", ")", "!==", "(", "$", "idCount", "=", "count", "(", "$", "ids", ")", ")", ")", "{", "throw", "new", "MissingObjectException", "(", "\"{$entityCount} out of {$idCount} ids don't match any existing object\"", ")", ";", "}", "return", "$", "objects", ";", "}" ]
Finds a set of objects by their ids. @param string $objectClass @param array $ids @return array[object] @throws MissingObjectException if any of the requested objects cannot be found @todo make this method compatible with odm implementations
[ "Finds", "a", "set", "of", "objects", "by", "their", "ids", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Persistence/ObjectManager.php#L237-L255
222,019
claroline/CoreBundle
Twig/BaseUriExtension.php
BaseUriExtension.getAssetPath
public function getAssetPath() { $path = $this->assetsHelper->getUrl(''); if ($path[strlen($path) - 1] === '/') { $path = rtrim($path, '/'); } return $path; }
php
public function getAssetPath() { $path = $this->assetsHelper->getUrl(''); if ($path[strlen($path) - 1] === '/') { $path = rtrim($path, '/'); } return $path; }
[ "public", "function", "getAssetPath", "(", ")", "{", "$", "path", "=", "$", "this", "->", "assetsHelper", "->", "getUrl", "(", "''", ")", ";", "if", "(", "$", "path", "[", "strlen", "(", "$", "path", ")", "-", "1", "]", "===", "'/'", ")", "{", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "}", "return", "$", "path", ";", "}" ]
Returns the URI under which assets are served, without any trailing slash. @return string
[ "Returns", "the", "URI", "under", "which", "assets", "are", "served", "without", "any", "trailing", "slash", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Twig/BaseUriExtension.php#L50-L59
222,020
claroline/CoreBundle
Twig/UrlAutoDetectorTwigExtension.php
UrlAutoDetectorTwigExtension.callbackReplace
public function callbackReplace($matches) { if ($matches[1] !== '') { return $matches[0]; // don't modify existing <a href="">links</a> and <img src=""> } $url = $matches[2]; $urlWithPrefix = $matches[2]; if (strpos($url, '@') !== false) { $urlWithPrefix = 'mailto:'.$url; } elseif (strpos($url, 'https://') === 0) { $urlWithPrefix = $url; } elseif (strpos($url, 'http://') !== 0) { $urlWithPrefix = 'http://'.$url; } return '<a href="'.$urlWithPrefix.'">'.$url.'</a>'; }
php
public function callbackReplace($matches) { if ($matches[1] !== '') { return $matches[0]; // don't modify existing <a href="">links</a> and <img src=""> } $url = $matches[2]; $urlWithPrefix = $matches[2]; if (strpos($url, '@') !== false) { $urlWithPrefix = 'mailto:'.$url; } elseif (strpos($url, 'https://') === 0) { $urlWithPrefix = $url; } elseif (strpos($url, 'http://') !== 0) { $urlWithPrefix = 'http://'.$url; } return '<a href="'.$urlWithPrefix.'">'.$url.'</a>'; }
[ "public", "function", "callbackReplace", "(", "$", "matches", ")", "{", "if", "(", "$", "matches", "[", "1", "]", "!==", "''", ")", "{", "return", "$", "matches", "[", "0", "]", ";", "// don't modify existing <a href=\"\">links</a> and <img src=\"\">", "}", "$", "url", "=", "$", "matches", "[", "2", "]", ";", "$", "urlWithPrefix", "=", "$", "matches", "[", "2", "]", ";", "if", "(", "strpos", "(", "$", "url", ",", "'@'", ")", "!==", "false", ")", "{", "$", "urlWithPrefix", "=", "'mailto:'", ".", "$", "url", ";", "}", "elseif", "(", "strpos", "(", "$", "url", ",", "'https://'", ")", "===", "0", ")", "{", "$", "urlWithPrefix", "=", "$", "url", ";", "}", "elseif", "(", "strpos", "(", "$", "url", ",", "'http://'", ")", "!==", "0", ")", "{", "$", "urlWithPrefix", "=", "'http://'", ".", "$", "url", ";", "}", "return", "'<a href=\"'", ".", "$", "urlWithPrefix", ".", "'\">'", ".", "$", "url", ".", "'</a>'", ";", "}" ]
For every url match in string encapsulate if needed and return string. @param array $matches @return string
[ "For", "every", "url", "match", "in", "string", "encapsulate", "if", "needed", "and", "return", "string", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Twig/UrlAutoDetectorTwigExtension.php#L70-L86
222,021
symlex/input-validation
src/Form/Validator.php
Validator.validateRequired
public function validateRequired(string $key, array $def, $value) { if (isset($def['required']) && ($def['required'] === true) && ($value === null || $value === '' || $value === false)) { $this->addError($key, 'form.value_must_not_be_empty'); } }
php
public function validateRequired(string $key, array $def, $value) { if (isset($def['required']) && ($def['required'] === true) && ($value === null || $value === '' || $value === false)) { $this->addError($key, 'form.value_must_not_be_empty'); } }
[ "public", "function", "validateRequired", "(", "string", "$", "key", ",", "array", "$", "def", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "def", "[", "'required'", "]", ")", "&&", "(", "$", "def", "[", "'required'", "]", "===", "true", ")", "&&", "(", "$", "value", "===", "null", "||", "$", "value", "===", "''", "||", "$", "value", "===", "false", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_must_not_be_empty'", ")", ";", "}", "}" ]
Validator for the "required" form field property
[ "Validator", "for", "the", "required", "form", "field", "property" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Validator.php#L100-L105
222,022
symlex/input-validation
src/Form/Validator.php
Validator.validateMatches
public function validateMatches(string $key, array $def, $value) { if (isset($def['matches'])) { if ($def['matches'][0] == '!') { $fieldName = substr($def['matches'], 1); if ($value == $this->getForm()->$fieldName) { $this->addError($key, 'form.value_must_not_be_the_same', array('%other_field%' => $this->getFieldCaption($fieldName))); } } else { if ($value != $this->getForm()->{$def['matches']}) { $this->addError($key, 'form.value_must_be_the_same', array('%other_field%' => $this->getFieldCaption($def['matches']))); } } } }
php
public function validateMatches(string $key, array $def, $value) { if (isset($def['matches'])) { if ($def['matches'][0] == '!') { $fieldName = substr($def['matches'], 1); if ($value == $this->getForm()->$fieldName) { $this->addError($key, 'form.value_must_not_be_the_same', array('%other_field%' => $this->getFieldCaption($fieldName))); } } else { if ($value != $this->getForm()->{$def['matches']}) { $this->addError($key, 'form.value_must_be_the_same', array('%other_field%' => $this->getFieldCaption($def['matches']))); } } } }
[ "public", "function", "validateMatches", "(", "string", "$", "key", ",", "array", "$", "def", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "def", "[", "'matches'", "]", ")", ")", "{", "if", "(", "$", "def", "[", "'matches'", "]", "[", "0", "]", "==", "'!'", ")", "{", "$", "fieldName", "=", "substr", "(", "$", "def", "[", "'matches'", "]", ",", "1", ")", ";", "if", "(", "$", "value", "==", "$", "this", "->", "getForm", "(", ")", "->", "$", "fieldName", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_must_not_be_the_same'", ",", "array", "(", "'%other_field%'", "=>", "$", "this", "->", "getFieldCaption", "(", "$", "fieldName", ")", ")", ")", ";", "}", "}", "else", "{", "if", "(", "$", "value", "!=", "$", "this", "->", "getForm", "(", ")", "->", "{", "$", "def", "[", "'matches'", "]", "}", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_must_be_the_same'", ",", "array", "(", "'%other_field%'", "=>", "$", "this", "->", "getFieldCaption", "(", "$", "def", "[", "'matches'", "]", ")", ")", ")", ";", "}", "}", "}", "}" ]
Validator for the "matches" form field property
[ "Validator", "for", "the", "matches", "form", "field", "property" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Validator.php#L110-L124
222,023
symlex/input-validation
src/Form/Validator.php
Validator.validateMin
public function validateMin(string $key, array $def, $value) { if (!isset($def['options']) && isset($def['min']) && $value != '') { if (isset($def['type']) && ($def['type'] == 'int' || $def['type'] == 'numeric' || $def['type'] == 'float')) { if ($value < $def['min']) { $this->addError($key, 'form.value_is_too_small', array('%limit%' => $def['min'])); } } elseif (isset($def['type']) && ($def['type'] == 'date' || $def['type'] == 'datetime')) { if ($value instanceof DateTime) { if (is_int($def['min'])) { $limit = new DateTime(); $limit->sub(new DateInterval('P' . $def['min'] . 'D')); } else { $limit = new DateTime($def['min']); } if ($value < $limit) { $format = $this->translate('form.' . $def['type']); $this->addError($key, 'form.value_is_too_far_in_the_past', array('%limit%' => $limit->format($format))); } } } elseif (isset($def['type']) && $def['type'] == 'list') { if (count($value) < $def['min']) { $this->addError($key, 'form.value_min_options_selected', array('%limit%' => $def['min'])); } } elseif (is_scalar($value) && (strlen($value) < $def['min'])) { $this->addError($key, 'form.value_is_too_short_chars', array('%limit%' => $def['min'])); } } }
php
public function validateMin(string $key, array $def, $value) { if (!isset($def['options']) && isset($def['min']) && $value != '') { if (isset($def['type']) && ($def['type'] == 'int' || $def['type'] == 'numeric' || $def['type'] == 'float')) { if ($value < $def['min']) { $this->addError($key, 'form.value_is_too_small', array('%limit%' => $def['min'])); } } elseif (isset($def['type']) && ($def['type'] == 'date' || $def['type'] == 'datetime')) { if ($value instanceof DateTime) { if (is_int($def['min'])) { $limit = new DateTime(); $limit->sub(new DateInterval('P' . $def['min'] . 'D')); } else { $limit = new DateTime($def['min']); } if ($value < $limit) { $format = $this->translate('form.' . $def['type']); $this->addError($key, 'form.value_is_too_far_in_the_past', array('%limit%' => $limit->format($format))); } } } elseif (isset($def['type']) && $def['type'] == 'list') { if (count($value) < $def['min']) { $this->addError($key, 'form.value_min_options_selected', array('%limit%' => $def['min'])); } } elseif (is_scalar($value) && (strlen($value) < $def['min'])) { $this->addError($key, 'form.value_is_too_short_chars', array('%limit%' => $def['min'])); } } }
[ "public", "function", "validateMin", "(", "string", "$", "key", ",", "array", "$", "def", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "def", "[", "'options'", "]", ")", "&&", "isset", "(", "$", "def", "[", "'min'", "]", ")", "&&", "$", "value", "!=", "''", ")", "{", "if", "(", "isset", "(", "$", "def", "[", "'type'", "]", ")", "&&", "(", "$", "def", "[", "'type'", "]", "==", "'int'", "||", "$", "def", "[", "'type'", "]", "==", "'numeric'", "||", "$", "def", "[", "'type'", "]", "==", "'float'", ")", ")", "{", "if", "(", "$", "value", "<", "$", "def", "[", "'min'", "]", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_is_too_small'", ",", "array", "(", "'%limit%'", "=>", "$", "def", "[", "'min'", "]", ")", ")", ";", "}", "}", "elseif", "(", "isset", "(", "$", "def", "[", "'type'", "]", ")", "&&", "(", "$", "def", "[", "'type'", "]", "==", "'date'", "||", "$", "def", "[", "'type'", "]", "==", "'datetime'", ")", ")", "{", "if", "(", "$", "value", "instanceof", "DateTime", ")", "{", "if", "(", "is_int", "(", "$", "def", "[", "'min'", "]", ")", ")", "{", "$", "limit", "=", "new", "DateTime", "(", ")", ";", "$", "limit", "->", "sub", "(", "new", "DateInterval", "(", "'P'", ".", "$", "def", "[", "'min'", "]", ".", "'D'", ")", ")", ";", "}", "else", "{", "$", "limit", "=", "new", "DateTime", "(", "$", "def", "[", "'min'", "]", ")", ";", "}", "if", "(", "$", "value", "<", "$", "limit", ")", "{", "$", "format", "=", "$", "this", "->", "translate", "(", "'form.'", ".", "$", "def", "[", "'type'", "]", ")", ";", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_is_too_far_in_the_past'", ",", "array", "(", "'%limit%'", "=>", "$", "limit", "->", "format", "(", "$", "format", ")", ")", ")", ";", "}", "}", "}", "elseif", "(", "isset", "(", "$", "def", "[", "'type'", "]", ")", "&&", "$", "def", "[", "'type'", "]", "==", "'list'", ")", "{", "if", "(", "count", "(", "$", "value", ")", "<", "$", "def", "[", "'min'", "]", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_min_options_selected'", ",", "array", "(", "'%limit%'", "=>", "$", "def", "[", "'min'", "]", ")", ")", ";", "}", "}", "elseif", "(", "is_scalar", "(", "$", "value", ")", "&&", "(", "strlen", "(", "$", "value", ")", "<", "$", "def", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_is_too_short_chars'", ",", "array", "(", "'%limit%'", "=>", "$", "def", "[", "'min'", "]", ")", ")", ";", "}", "}", "}" ]
Validator for the "min" form field property
[ "Validator", "for", "the", "min", "form", "field", "property" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Validator.php#L129-L159
222,024
symlex/input-validation
src/Form/Validator.php
Validator.validateDepends
public function validateDepends(string $key, array $def, $value) { if (isset($def['depends'])) { if ($this->getForm()->{$def['depends']} != '' && $value == '' && !isset($def['depends_value_empty'])) { if (isset($def['depends_first_option']) && $this->getDefinition($def['depends'], 'options')) { $options = $this->getDefinition($def['depends'], 'options'); reset($options); if ($this->getForm()->{$def['depends']} == key($options)) { $this->addError($key, 'form.value_empty_depends', array( '%other_field%' => $this->getFieldCaption($def['depends']), '%value%' => current($options) ) ); } } elseif (isset($def['depends_last_option']) && $this->getDefinition($def['depends'], 'options')) { $options = $this->getDefinition($def['depends'], 'options'); end($options); if ($this->getForm()->{$def['depends']} == key($options)) { $this->addError($key, 'form.value_empty_depends', array( '%other_field%' => $this->getFieldCaption($def['depends']), '%value%' => current($options) ) ); } } elseif (!isset($def['depends_value']) || $this->getForm()->{$def['depends']} == $def['depends_value']) { $this->addError($key, 'form.value_empty'); } } elseif ($this->getForm()->{$def['depends']} == '' && $value == '' && isset($def['depends_value_empty'])) { $this->addError($key, 'form.value_empty', array( '%other_field%' => $this->getFieldCaption($def['depends']) ) ); } } }
php
public function validateDepends(string $key, array $def, $value) { if (isset($def['depends'])) { if ($this->getForm()->{$def['depends']} != '' && $value == '' && !isset($def['depends_value_empty'])) { if (isset($def['depends_first_option']) && $this->getDefinition($def['depends'], 'options')) { $options = $this->getDefinition($def['depends'], 'options'); reset($options); if ($this->getForm()->{$def['depends']} == key($options)) { $this->addError($key, 'form.value_empty_depends', array( '%other_field%' => $this->getFieldCaption($def['depends']), '%value%' => current($options) ) ); } } elseif (isset($def['depends_last_option']) && $this->getDefinition($def['depends'], 'options')) { $options = $this->getDefinition($def['depends'], 'options'); end($options); if ($this->getForm()->{$def['depends']} == key($options)) { $this->addError($key, 'form.value_empty_depends', array( '%other_field%' => $this->getFieldCaption($def['depends']), '%value%' => current($options) ) ); } } elseif (!isset($def['depends_value']) || $this->getForm()->{$def['depends']} == $def['depends_value']) { $this->addError($key, 'form.value_empty'); } } elseif ($this->getForm()->{$def['depends']} == '' && $value == '' && isset($def['depends_value_empty'])) { $this->addError($key, 'form.value_empty', array( '%other_field%' => $this->getFieldCaption($def['depends']) ) ); } } }
[ "public", "function", "validateDepends", "(", "string", "$", "key", ",", "array", "$", "def", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "def", "[", "'depends'", "]", ")", ")", "{", "if", "(", "$", "this", "->", "getForm", "(", ")", "->", "{", "$", "def", "[", "'depends'", "]", "}", "!=", "''", "&&", "$", "value", "==", "''", "&&", "!", "isset", "(", "$", "def", "[", "'depends_value_empty'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "def", "[", "'depends_first_option'", "]", ")", "&&", "$", "this", "->", "getDefinition", "(", "$", "def", "[", "'depends'", "]", ",", "'options'", ")", ")", "{", "$", "options", "=", "$", "this", "->", "getDefinition", "(", "$", "def", "[", "'depends'", "]", ",", "'options'", ")", ";", "reset", "(", "$", "options", ")", ";", "if", "(", "$", "this", "->", "getForm", "(", ")", "->", "{", "$", "def", "[", "'depends'", "]", "}", "==", "key", "(", "$", "options", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_empty_depends'", ",", "array", "(", "'%other_field%'", "=>", "$", "this", "->", "getFieldCaption", "(", "$", "def", "[", "'depends'", "]", ")", ",", "'%value%'", "=>", "current", "(", "$", "options", ")", ")", ")", ";", "}", "}", "elseif", "(", "isset", "(", "$", "def", "[", "'depends_last_option'", "]", ")", "&&", "$", "this", "->", "getDefinition", "(", "$", "def", "[", "'depends'", "]", ",", "'options'", ")", ")", "{", "$", "options", "=", "$", "this", "->", "getDefinition", "(", "$", "def", "[", "'depends'", "]", ",", "'options'", ")", ";", "end", "(", "$", "options", ")", ";", "if", "(", "$", "this", "->", "getForm", "(", ")", "->", "{", "$", "def", "[", "'depends'", "]", "}", "==", "key", "(", "$", "options", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_empty_depends'", ",", "array", "(", "'%other_field%'", "=>", "$", "this", "->", "getFieldCaption", "(", "$", "def", "[", "'depends'", "]", ")", ",", "'%value%'", "=>", "current", "(", "$", "options", ")", ")", ")", ";", "}", "}", "elseif", "(", "!", "isset", "(", "$", "def", "[", "'depends_value'", "]", ")", "||", "$", "this", "->", "getForm", "(", ")", "->", "{", "$", "def", "[", "'depends'", "]", "}", "==", "$", "def", "[", "'depends_value'", "]", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_empty'", ")", ";", "}", "}", "elseif", "(", "$", "this", "->", "getForm", "(", ")", "->", "{", "$", "def", "[", "'depends'", "]", "}", "==", "''", "&&", "$", "value", "==", "''", "&&", "isset", "(", "$", "def", "[", "'depends_value_empty'", "]", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_empty'", ",", "array", "(", "'%other_field%'", "=>", "$", "this", "->", "getFieldCaption", "(", "$", "def", "[", "'depends'", "]", ")", ")", ")", ";", "}", "}", "}" ]
Validator for the "depends" form field property
[ "Validator", "for", "the", "depends", "form", "field", "property" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Validator.php#L198-L239
222,025
symlex/input-validation
src/Form/Validator.php
Validator.validateRegex
public function validateRegex(string $key, array $def, $value) { if (is_scalar($value) && isset($def['regex']) && !empty($value) && !preg_match($def['regex'], $value)) { $this->addError($key, 'form.value_not_valid_regex'); } }
php
public function validateRegex(string $key, array $def, $value) { if (is_scalar($value) && isset($def['regex']) && !empty($value) && !preg_match($def['regex'], $value)) { $this->addError($key, 'form.value_not_valid_regex'); } }
[ "public", "function", "validateRegex", "(", "string", "$", "key", ",", "array", "$", "def", ",", "$", "value", ")", "{", "if", "(", "is_scalar", "(", "$", "value", ")", "&&", "isset", "(", "$", "def", "[", "'regex'", "]", ")", "&&", "!", "empty", "(", "$", "value", ")", "&&", "!", "preg_match", "(", "$", "def", "[", "'regex'", "]", ",", "$", "value", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_not_valid_regex'", ")", ";", "}", "}" ]
Validator for the "regex" form field property
[ "Validator", "for", "the", "regex", "form", "field", "property" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Validator.php#L244-L249
222,026
symlex/input-validation
src/Form/Validator.php
Validator.validateOptions
public function validateOptions(string $key, array $def, $value) { if (isset($def['options']) && $value != '') { if (isset($def['min']) || isset($def['max'])) { if (!is_array($value)) { $this->addError($key, 'form.value_must_be_list'); } else { if (isset($def['min']) && count($value) < $def['min']) { $this->addError($key, 'form.value_min_options_selected', array('%limit%' => $def['min'])); } if (isset($def['max']) && count($value) > $def['max']) { $this->addError($key, 'form.value_max_options_selected', array('%limit%' => $def['max'])); } } } if (is_array($value)) { foreach ($value as $option => $order) { if (is_int($option)) { if (!isset($def['options'][$order])) { $this->addError($key, 'form.value_invalid_option', array('%option%' => $order)); } } else { if (!isset($def['options'][$option])) { $this->addError($key, 'form.value_invalid_option', array('%option%' => $option)); } } } } else { if (!isset($def['options'][$value])) { $this->addError($key, 'form.value_invalid_option', array('%option%' => $value)); } } } }
php
public function validateOptions(string $key, array $def, $value) { if (isset($def['options']) && $value != '') { if (isset($def['min']) || isset($def['max'])) { if (!is_array($value)) { $this->addError($key, 'form.value_must_be_list'); } else { if (isset($def['min']) && count($value) < $def['min']) { $this->addError($key, 'form.value_min_options_selected', array('%limit%' => $def['min'])); } if (isset($def['max']) && count($value) > $def['max']) { $this->addError($key, 'form.value_max_options_selected', array('%limit%' => $def['max'])); } } } if (is_array($value)) { foreach ($value as $option => $order) { if (is_int($option)) { if (!isset($def['options'][$order])) { $this->addError($key, 'form.value_invalid_option', array('%option%' => $order)); } } else { if (!isset($def['options'][$option])) { $this->addError($key, 'form.value_invalid_option', array('%option%' => $option)); } } } } else { if (!isset($def['options'][$value])) { $this->addError($key, 'form.value_invalid_option', array('%option%' => $value)); } } } }
[ "public", "function", "validateOptions", "(", "string", "$", "key", ",", "array", "$", "def", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "def", "[", "'options'", "]", ")", "&&", "$", "value", "!=", "''", ")", "{", "if", "(", "isset", "(", "$", "def", "[", "'min'", "]", ")", "||", "isset", "(", "$", "def", "[", "'max'", "]", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_must_be_list'", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "def", "[", "'min'", "]", ")", "&&", "count", "(", "$", "value", ")", "<", "$", "def", "[", "'min'", "]", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_min_options_selected'", ",", "array", "(", "'%limit%'", "=>", "$", "def", "[", "'min'", "]", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "def", "[", "'max'", "]", ")", "&&", "count", "(", "$", "value", ")", ">", "$", "def", "[", "'max'", "]", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_max_options_selected'", ",", "array", "(", "'%limit%'", "=>", "$", "def", "[", "'max'", "]", ")", ")", ";", "}", "}", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "option", "=>", "$", "order", ")", "{", "if", "(", "is_int", "(", "$", "option", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "def", "[", "'options'", "]", "[", "$", "order", "]", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_invalid_option'", ",", "array", "(", "'%option%'", "=>", "$", "order", ")", ")", ";", "}", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "def", "[", "'options'", "]", "[", "$", "option", "]", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_invalid_option'", ",", "array", "(", "'%option%'", "=>", "$", "option", ")", ")", ";", "}", "}", "}", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "def", "[", "'options'", "]", "[", "$", "value", "]", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "key", ",", "'form.value_invalid_option'", ",", "array", "(", "'%option%'", "=>", "$", "value", ")", ")", ";", "}", "}", "}", "}" ]
Validator for the "options" form field property
[ "Validator", "for", "the", "options", "form", "field", "property" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Validator.php#L254-L289
222,027
symlex/input-validation
src/Form/Validator.php
Validator.validateField
public function validateField(string $key, array $def, $value) { $this->validateRequired($key, $def, $value); $this->validateMin($key, $def, $value); $this->validateMax($key, $def, $value); $this->validateMatches($key, $def, $value); $this->validateDepends($key, $def, $value); $this->validateRegex($key, $def, $value); $this->validateOptions($key, $def, $value); $this->validateType($key, $def, $value); }
php
public function validateField(string $key, array $def, $value) { $this->validateRequired($key, $def, $value); $this->validateMin($key, $def, $value); $this->validateMax($key, $def, $value); $this->validateMatches($key, $def, $value); $this->validateDepends($key, $def, $value); $this->validateRegex($key, $def, $value); $this->validateOptions($key, $def, $value); $this->validateType($key, $def, $value); }
[ "public", "function", "validateField", "(", "string", "$", "key", ",", "array", "$", "def", ",", "$", "value", ")", "{", "$", "this", "->", "validateRequired", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "$", "this", "->", "validateMin", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "$", "this", "->", "validateMax", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "$", "this", "->", "validateMatches", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "$", "this", "->", "validateDepends", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "$", "this", "->", "validateRegex", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "$", "this", "->", "validateOptions", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "$", "this", "->", "validateType", "(", "$", "key", ",", "$", "def", ",", "$", "value", ")", ";", "}" ]
Applies the validators to a form field. Can be extended by inherited classes. @param string $key The field name @param array $def The field definition @param mixed $value The field value
[ "Applies", "the", "validators", "to", "a", "form", "field", ".", "Can", "be", "extended", "by", "inherited", "classes", "." ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Validator.php#L382-L392
222,028
idimensionz/sendgrid-webapi-v3-php
lib/iDimensionz/SendGridWebApiV3/Api/Templates/TemplateVersionDto.php
TemplateVersionDto.validateArray
private function validateArray($templateVersionData) { $isValid = true; $isValid = $isValid && is_array($templateVersionData); if ($isValid) { $keys = array_keys($templateVersionData); $isValid = $isValid && in_array('id', $keys) && in_array('template_id', $keys) && in_array('active', $keys) && in_array('name', $keys) && in_array('updated_at', $keys); } if (!$isValid) { throw new \InvalidArgumentException('Template Version data must be an array and contain valid keys'); } }
php
private function validateArray($templateVersionData) { $isValid = true; $isValid = $isValid && is_array($templateVersionData); if ($isValid) { $keys = array_keys($templateVersionData); $isValid = $isValid && in_array('id', $keys) && in_array('template_id', $keys) && in_array('active', $keys) && in_array('name', $keys) && in_array('updated_at', $keys); } if (!$isValid) { throw new \InvalidArgumentException('Template Version data must be an array and contain valid keys'); } }
[ "private", "function", "validateArray", "(", "$", "templateVersionData", ")", "{", "$", "isValid", "=", "true", ";", "$", "isValid", "=", "$", "isValid", "&&", "is_array", "(", "$", "templateVersionData", ")", ";", "if", "(", "$", "isValid", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "templateVersionData", ")", ";", "$", "isValid", "=", "$", "isValid", "&&", "in_array", "(", "'id'", ",", "$", "keys", ")", "&&", "in_array", "(", "'template_id'", ",", "$", "keys", ")", "&&", "in_array", "(", "'active'", ",", "$", "keys", ")", "&&", "in_array", "(", "'name'", ",", "$", "keys", ")", "&&", "in_array", "(", "'updated_at'", ",", "$", "keys", ")", ";", "}", "if", "(", "!", "$", "isValid", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Template Version data must be an array and contain valid keys'", ")", ";", "}", "}" ]
Validates template version data is an array with all the expected keys @param array $templateVersionData
[ "Validates", "template", "version", "data", "is", "an", "array", "with", "all", "the", "expected", "keys" ]
f9ae04939c7c21de1486ad4b310bc950ec0d8163
https://github.com/idimensionz/sendgrid-webapi-v3-php/blob/f9ae04939c7c21de1486ad4b310bc950ec0d8163/lib/iDimensionz/SendGridWebApiV3/Api/Templates/TemplateVersionDto.php#L268-L285
222,029
claroline/CoreBundle
Twig/HomeExtension.php
HomeExtension.getFilters
public function getFilters() { return array( 'timeAgo' => new \Twig_Filter_Method($this, 'timeAgo'), 'homeLink' => new \Twig_Filter_Method($this, 'homeLink'), 'activeLink' => new \Twig_Filter_Method($this, 'activeLink'), 'activeRoute' => new \Twig_Filter_Method($this, 'activeRoute'), 'compareRoute' => new \Twig_Filter_Method($this, 'compareRoute'), 'autoLink' => new \Twig_Filter_Method($this, 'autoLink') ); }
php
public function getFilters() { return array( 'timeAgo' => new \Twig_Filter_Method($this, 'timeAgo'), 'homeLink' => new \Twig_Filter_Method($this, 'homeLink'), 'activeLink' => new \Twig_Filter_Method($this, 'activeLink'), 'activeRoute' => new \Twig_Filter_Method($this, 'activeRoute'), 'compareRoute' => new \Twig_Filter_Method($this, 'compareRoute'), 'autoLink' => new \Twig_Filter_Method($this, 'autoLink') ); }
[ "public", "function", "getFilters", "(", ")", "{", "return", "array", "(", "'timeAgo'", "=>", "new", "\\", "Twig_Filter_Method", "(", "$", "this", ",", "'timeAgo'", ")", ",", "'homeLink'", "=>", "new", "\\", "Twig_Filter_Method", "(", "$", "this", ",", "'homeLink'", ")", ",", "'activeLink'", "=>", "new", "\\", "Twig_Filter_Method", "(", "$", "this", ",", "'activeLink'", ")", ",", "'activeRoute'", "=>", "new", "\\", "Twig_Filter_Method", "(", "$", "this", ",", "'activeRoute'", ")", ",", "'compareRoute'", "=>", "new", "\\", "Twig_Filter_Method", "(", "$", "this", ",", "'compareRoute'", ")", ",", "'autoLink'", "=>", "new", "\\", "Twig_Filter_Method", "(", "$", "this", ",", "'autoLink'", ")", ")", ";", "}" ]
Get filters of the service @return \Twig_Filter_Method
[ "Get", "filters", "of", "the", "service" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Twig/HomeExtension.php#L45-L55
222,030
claroline/CoreBundle
Twig/HomeExtension.php
HomeExtension.homeLink
public function homeLink($link) { if (!(strpos($link, "http://") === 0 or strpos($link, "https://") === 0 or strpos($link, "ftp://") === 0 or strpos($link, "www.") === 0) ) { $home = $this->container->get("router")->generate('claro_index').$link; $home = str_replace("//", "/", $home); return $home; } return $link; }
php
public function homeLink($link) { if (!(strpos($link, "http://") === 0 or strpos($link, "https://") === 0 or strpos($link, "ftp://") === 0 or strpos($link, "www.") === 0) ) { $home = $this->container->get("router")->generate('claro_index').$link; $home = str_replace("//", "/", $home); return $home; } return $link; }
[ "public", "function", "homeLink", "(", "$", "link", ")", "{", "if", "(", "!", "(", "strpos", "(", "$", "link", ",", "\"http://\"", ")", "===", "0", "or", "strpos", "(", "$", "link", ",", "\"https://\"", ")", "===", "0", "or", "strpos", "(", "$", "link", ",", "\"ftp://\"", ")", "===", "0", "or", "strpos", "(", "$", "link", ",", "\"www.\"", ")", "===", "0", ")", ")", "{", "$", "home", "=", "$", "this", "->", "container", "->", "get", "(", "\"router\"", ")", "->", "generate", "(", "'claro_index'", ")", ".", "$", "link", ";", "$", "home", "=", "str_replace", "(", "\"//\"", ",", "\"/\"", ",", "$", "home", ")", ";", "return", "$", "home", ";", "}", "return", "$", "link", ";", "}" ]
Check if a link is local or external
[ "Check", "if", "a", "link", "is", "local", "or", "external" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Twig/HomeExtension.php#L131-L146
222,031
claroline/CoreBundle
Twig/HomeExtension.php
HomeExtension.activeLink
public function activeLink($link) { $pathinfo = $this->getPathInfo(); if (($pathinfo and '/' . $pathinfo === $link) or (!$pathinfo and $link === '/')) { return ' active'; //the white space is nedded } return ''; }
php
public function activeLink($link) { $pathinfo = $this->getPathInfo(); if (($pathinfo and '/' . $pathinfo === $link) or (!$pathinfo and $link === '/')) { return ' active'; //the white space is nedded } return ''; }
[ "public", "function", "activeLink", "(", "$", "link", ")", "{", "$", "pathinfo", "=", "$", "this", "->", "getPathInfo", "(", ")", ";", "if", "(", "(", "$", "pathinfo", "and", "'/'", ".", "$", "pathinfo", "===", "$", "link", ")", "or", "(", "!", "$", "pathinfo", "and", "$", "link", "===", "'/'", ")", ")", "{", "return", "' active'", ";", "//the white space is nedded", "}", "return", "''", ";", "}" ]
Return active if a given link match to the path info
[ "Return", "active", "if", "a", "given", "link", "match", "to", "the", "path", "info" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Twig/HomeExtension.php#L151-L159
222,032
claroline/CoreBundle
Library/Security/Voter/FacetVoter.php
FacetVoter.vote
public function vote(TokenInterface $token, $object, array $attributes) { if ($object instanceof FieldFacet) { return $this->fieldFacetVote($object, $token, $attributes[0]); } return VoterInterface::ACCESS_ABSTAIN; }
php
public function vote(TokenInterface $token, $object, array $attributes) { if ($object instanceof FieldFacet) { return $this->fieldFacetVote($object, $token, $attributes[0]); } return VoterInterface::ACCESS_ABSTAIN; }
[ "public", "function", "vote", "(", "TokenInterface", "$", "token", ",", "$", "object", ",", "array", "$", "attributes", ")", "{", "if", "(", "$", "object", "instanceof", "FieldFacet", ")", "{", "return", "$", "this", "->", "fieldFacetVote", "(", "$", "object", ",", "$", "token", ",", "$", "attributes", "[", "0", "]", ")", ";", "}", "return", "VoterInterface", "::", "ACCESS_ABSTAIN", ";", "}" ]
Attributes can either be "open" or "edit" @param TokenInterface $token @param $object @param array $attributes
[ "Attributes", "can", "either", "be", "open", "or", "edit" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Security/Voter/FacetVoter.php#L52-L59
222,033
sam002/yii2-otp
src/behaviors/OtpBehavior.php
OtpBehavior.initSecret
public function initSecret() { $secret = $this->owner->{$this->secretAttribute}; if (!empty($secret)) { $this->otp->setSecret($secret); } }
php
public function initSecret() { $secret = $this->owner->{$this->secretAttribute}; if (!empty($secret)) { $this->otp->setSecret($secret); } }
[ "public", "function", "initSecret", "(", ")", "{", "$", "secret", "=", "$", "this", "->", "owner", "->", "{", "$", "this", "->", "secretAttribute", "}", ";", "if", "(", "!", "empty", "(", "$", "secret", ")", ")", "{", "$", "this", "->", "otp", "->", "setSecret", "(", "$", "secret", ")", ";", "}", "}" ]
Init secret attribute
[ "Init", "secret", "attribute" ]
d98b7398eb64c8ce25560c82c85f7116128c913f
https://github.com/sam002/yii2-otp/blob/d98b7398eb64c8ce25560c82c85f7116128c913f/src/behaviors/OtpBehavior.php#L75-L81
222,034
sam002/yii2-otp
src/behaviors/OtpBehavior.php
OtpBehavior.confirmSecret
public function confirmSecret() { $secret = $this->owner->{$this->secretAttribute}; if (empty($secret)) { $this->owner->addError($this->codeAttribute, Yii::t('yii', 'The secret is empty.')); } else { $this->otp->setSecret($secret); if (!$this->secretConfirmed()) { $this->owner->addError($this->codeAttribute, Yii::t('yii', 'The code is incorrect.')); } } }
php
public function confirmSecret() { $secret = $this->owner->{$this->secretAttribute}; if (empty($secret)) { $this->owner->addError($this->codeAttribute, Yii::t('yii', 'The secret is empty.')); } else { $this->otp->setSecret($secret); if (!$this->secretConfirmed()) { $this->owner->addError($this->codeAttribute, Yii::t('yii', 'The code is incorrect.')); } } }
[ "public", "function", "confirmSecret", "(", ")", "{", "$", "secret", "=", "$", "this", "->", "owner", "->", "{", "$", "this", "->", "secretAttribute", "}", ";", "if", "(", "empty", "(", "$", "secret", ")", ")", "{", "$", "this", "->", "owner", "->", "addError", "(", "$", "this", "->", "codeAttribute", ",", "Yii", "::", "t", "(", "'yii'", ",", "'The secret is empty.'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "otp", "->", "setSecret", "(", "$", "secret", ")", ";", "if", "(", "!", "$", "this", "->", "secretConfirmed", "(", ")", ")", "{", "$", "this", "->", "owner", "->", "addError", "(", "$", "this", "->", "codeAttribute", ",", "Yii", "::", "t", "(", "'yii'", ",", "'The code is incorrect.'", ")", ")", ";", "}", "}", "}" ]
Confirm secret by code
[ "Confirm", "secret", "by", "code" ]
d98b7398eb64c8ce25560c82c85f7116128c913f
https://github.com/sam002/yii2-otp/blob/d98b7398eb64c8ce25560c82c85f7116128c913f/src/behaviors/OtpBehavior.php#L86-L97
222,035
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.decreaseSide
public function decreaseSide($side, $size) { $x = $y = 1; $x2 = $this->width; $y2 = $this->height; switch ($side) { case 'top': $y = $size; break; case 'right': $x2 -= $size; break; case 'bottom': $y2 -= $size; break; case 'left': $x = $size; break; } $this->crop($x, $y, $x2, $y2); return $this; }
php
public function decreaseSide($side, $size) { $x = $y = 1; $x2 = $this->width; $y2 = $this->height; switch ($side) { case 'top': $y = $size; break; case 'right': $x2 -= $size; break; case 'bottom': $y2 -= $size; break; case 'left': $x = $size; break; } $this->crop($x, $y, $x2, $y2); return $this; }
[ "public", "function", "decreaseSide", "(", "$", "side", ",", "$", "size", ")", "{", "$", "x", "=", "$", "y", "=", "1", ";", "$", "x2", "=", "$", "this", "->", "width", ";", "$", "y2", "=", "$", "this", "->", "height", ";", "switch", "(", "$", "side", ")", "{", "case", "'top'", ":", "$", "y", "=", "$", "size", ";", "break", ";", "case", "'right'", ":", "$", "x2", "-=", "$", "size", ";", "break", ";", "case", "'bottom'", ":", "$", "y2", "-=", "$", "size", ";", "break", ";", "case", "'left'", ":", "$", "x", "=", "$", "size", ";", "break", ";", "}", "$", "this", "->", "crop", "(", "$", "x", ",", "$", "y", ",", "$", "x2", ",", "$", "y2", ")", ";", "return", "$", "this", ";", "}" ]
Deletes a piece of image from specific side. For example, if side=top and size=100, 100px from top will be deleted. @param string $side Side to cut @param int $size Pixels @return ImageEditor this object
[ "Deletes", "a", "piece", "of", "image", "from", "specific", "side", ".", "For", "example", "if", "side", "=", "top", "and", "size", "=", "100", "100px", "from", "top", "will", "be", "deleted", "." ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L109-L129
222,036
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.zoomWidthTo
public function zoomWidthTo($size) { $ratio = round($this->width / $size, 3); $this->resize($size, $this->height / $ratio); return $this; }
php
public function zoomWidthTo($size) { $ratio = round($this->width / $size, 3); $this->resize($size, $this->height / $ratio); return $this; }
[ "public", "function", "zoomWidthTo", "(", "$", "size", ")", "{", "$", "ratio", "=", "round", "(", "$", "this", "->", "width", "/", "$", "size", ",", "3", ")", ";", "$", "this", "->", "resize", "(", "$", "size", ",", "$", "this", "->", "height", "/", "$", "ratio", ")", ";", "return", "$", "this", ";", "}" ]
Changes proportionally image width to new size @param int $size New value of width @return ImageEditor this object
[ "Changes", "proportionally", "image", "width", "to", "new", "size" ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L150-L154
222,037
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.zoomHeightTo
public function zoomHeightTo($size) { $ratio = round($this->height / $size, 3); $this->resize($this->width / $ratio, $size); return $this; }
php
public function zoomHeightTo($size) { $ratio = round($this->height / $size, 3); $this->resize($this->width / $ratio, $size); return $this; }
[ "public", "function", "zoomHeightTo", "(", "$", "size", ")", "{", "$", "ratio", "=", "round", "(", "$", "this", "->", "height", "/", "$", "size", ",", "3", ")", ";", "$", "this", "->", "resize", "(", "$", "this", "->", "width", "/", "$", "ratio", ",", "$", "size", ")", ";", "return", "$", "this", ";", "}" ]
Changes proportionally image height to new size @param int $size New value of height @return ImageEditor this object
[ "Changes", "proportionally", "image", "height", "to", "new", "size" ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L161-L165
222,038
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.decreaseTo
public function decreaseTo($size) { $currentSize = max($this->height, $this->width); if ($currentSize <= $size) return; $ratio = round($currentSize / $size, 3); $this->resize($this->width / $ratio, $this->height / $ratio); return $this; }
php
public function decreaseTo($size) { $currentSize = max($this->height, $this->width); if ($currentSize <= $size) return; $ratio = round($currentSize / $size, 3); $this->resize($this->width / $ratio, $this->height / $ratio); return $this; }
[ "public", "function", "decreaseTo", "(", "$", "size", ")", "{", "$", "currentSize", "=", "max", "(", "$", "this", "->", "height", ",", "$", "this", "->", "width", ")", ";", "if", "(", "$", "currentSize", "<=", "$", "size", ")", "return", ";", "$", "ratio", "=", "round", "(", "$", "currentSize", "/", "$", "size", ",", "3", ")", ";", "$", "this", "->", "resize", "(", "$", "this", "->", "width", "/", "$", "ratio", ",", "$", "this", "->", "height", "/", "$", "ratio", ")", ";", "return", "$", "this", ";", "}" ]
Decreases proportionally larger side to new size, if needed @param int $size New max value of sides @return ImageEditor this object
[ "Decreases", "proportionally", "larger", "side", "to", "new", "size", "if", "needed" ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L196-L203
222,039
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.placeImageAt
public function placeImageAt($x, $y, ImageEditor $image) { imagecopy($this->_image, $image->resource, $x, $y, 0, 0, $image->width, $image->height); return $this; }
php
public function placeImageAt($x, $y, ImageEditor $image) { imagecopy($this->_image, $image->resource, $x, $y, 0, 0, $image->width, $image->height); return $this; }
[ "public", "function", "placeImageAt", "(", "$", "x", ",", "$", "y", ",", "ImageEditor", "$", "image", ")", "{", "imagecopy", "(", "$", "this", "->", "_image", ",", "$", "image", "->", "resource", ",", "$", "x", ",", "$", "y", ",", "0", ",", "0", ",", "$", "image", "->", "width", ",", "$", "image", "->", "height", ")", ";", "return", "$", "this", ";", "}" ]
Places another image atop current image @param int $x X-position @param int $y Y-position @param ImageEditor $image Image to place @return ImageEditor this object
[ "Places", "another", "image", "atop", "current", "image" ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L273-L276
222,040
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.rotate
public function rotate($angle, $bgColor = 0) { if ($angle === true) $angle = 90; elseif ($angle === false) $angle = -90; $this->_image = imagerotate($this->_image, 360 - $angle, $bgColor); return $this; }
php
public function rotate($angle, $bgColor = 0) { if ($angle === true) $angle = 90; elseif ($angle === false) $angle = -90; $this->_image = imagerotate($this->_image, 360 - $angle, $bgColor); return $this; }
[ "public", "function", "rotate", "(", "$", "angle", ",", "$", "bgColor", "=", "0", ")", "{", "if", "(", "$", "angle", "===", "true", ")", "$", "angle", "=", "90", ";", "elseif", "(", "$", "angle", "===", "false", ")", "$", "angle", "=", "-", "90", ";", "$", "this", "->", "_image", "=", "imagerotate", "(", "$", "this", "->", "_image", ",", "360", "-", "$", "angle", ",", "$", "bgColor", ")", ";", "return", "$", "this", ";", "}" ]
Rotates an image @param mixed $angle An angle to rotate in degrees. Also you can pass true or false to rotate 90 degress and -90 degrees. @param int $bgColor Color of uncovered zone {@see http://www.php.net/manual/en/function.imagerotate.php} @return ImageEditor this object
[ "Rotates", "an", "image" ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L296-L303
222,041
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.verticalFlip
public function verticalFlip() { if (function_exists('imageflip')) { imageflip($this->_image, IMG_FLIP_VERTICAL); } else { $image = imagecreatetruecolor($this->width, $this->height); $dst_x = 0; $src_x = 0; $coordinate = ($this->height - 1); foreach (range($this->height, 0) as $range) { $src_y = $range; $dst_y = $coordinate - $range; imagecopy($image, $this->_image, $dst_x, $dst_y, $src_x, $src_y, $this->width, 1); } imagedestroy($this->_image); $this->_image = $image; } return $this; }
php
public function verticalFlip() { if (function_exists('imageflip')) { imageflip($this->_image, IMG_FLIP_VERTICAL); } else { $image = imagecreatetruecolor($this->width, $this->height); $dst_x = 0; $src_x = 0; $coordinate = ($this->height - 1); foreach (range($this->height, 0) as $range) { $src_y = $range; $dst_y = $coordinate - $range; imagecopy($image, $this->_image, $dst_x, $dst_y, $src_x, $src_y, $this->width, 1); } imagedestroy($this->_image); $this->_image = $image; } return $this; }
[ "public", "function", "verticalFlip", "(", ")", "{", "if", "(", "function_exists", "(", "'imageflip'", ")", ")", "{", "imageflip", "(", "$", "this", "->", "_image", ",", "IMG_FLIP_VERTICAL", ")", ";", "}", "else", "{", "$", "image", "=", "imagecreatetruecolor", "(", "$", "this", "->", "width", ",", "$", "this", "->", "height", ")", ";", "$", "dst_x", "=", "0", ";", "$", "src_x", "=", "0", ";", "$", "coordinate", "=", "(", "$", "this", "->", "height", "-", "1", ")", ";", "foreach", "(", "range", "(", "$", "this", "->", "height", ",", "0", ")", "as", "$", "range", ")", "{", "$", "src_y", "=", "$", "range", ";", "$", "dst_y", "=", "$", "coordinate", "-", "$", "range", ";", "imagecopy", "(", "$", "image", ",", "$", "this", "->", "_image", ",", "$", "dst_x", ",", "$", "dst_y", ",", "$", "src_x", ",", "$", "src_y", ",", "$", "this", "->", "width", ",", "1", ")", ";", "}", "imagedestroy", "(", "$", "this", "->", "_image", ")", ";", "$", "this", "->", "_image", "=", "$", "image", ";", "}", "return", "$", "this", ";", "}" ]
Flips an image vertically. @return ImageEditor this object
[ "Flips", "an", "image", "vertically", "." ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L389-L406
222,042
wapmorgan/ImageEditor
ImageEditor.php
ImageEditor.createFromResource
static public function createFromResource($resource) { if (!is_resource($resource)) throw new Exception('Invalid (resource) parameter! This is not a resource!'); if (get_resource_type($resource) != 'gd') throw new Exception('Invalid (resource) parameter! Resource is not a gd resource!'); return new self($resource); }
php
static public function createFromResource($resource) { if (!is_resource($resource)) throw new Exception('Invalid (resource) parameter! This is not a resource!'); if (get_resource_type($resource) != 'gd') throw new Exception('Invalid (resource) parameter! Resource is not a gd resource!'); return new self($resource); }
[ "static", "public", "function", "createFromResource", "(", "$", "resource", ")", "{", "if", "(", "!", "is_resource", "(", "$", "resource", ")", ")", "throw", "new", "Exception", "(", "'Invalid (resource) parameter! This is not a resource!'", ")", ";", "if", "(", "get_resource_type", "(", "$", "resource", ")", "!=", "'gd'", ")", "throw", "new", "Exception", "(", "'Invalid (resource) parameter! Resource is not a gd resource!'", ")", ";", "return", "new", "self", "(", "$", "resource", ")", ";", "}" ]
Creates an instace from gd-resource @param resource $resource Image resource
[ "Creates", "an", "instace", "from", "gd", "-", "resource" ]
ff93050ff55754d5c30debdfac37a1b44c3c9ff2
https://github.com/wapmorgan/ImageEditor/blob/ff93050ff55754d5c30debdfac37a1b44c3c9ff2/ImageEditor.php#L479-L485
222,043
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.getRegionContents
public function getRegionContents() { $array = array(); $regions = $this->region->findAll(); foreach ($regions as $region) { $first = $this->contentRegion->findOneBy(array('back' => null, 'region' => $region)); while ($first != null) { $contentType = $this->contentType->findOneBy(array('content' => $first->getContent())); if ($contentType) { $type = $contentType->getType()->getName(); } else { $type = 'default'; } $array[$region->getName()][] = array( 'content' => $first->getContent(), 'size' => $first->getSize(), 'menu' => '', 'type' => $type, 'region' => $region->getName() ); $first = $first->getNext(); } } return $array; }
php
public function getRegionContents() { $array = array(); $regions = $this->region->findAll(); foreach ($regions as $region) { $first = $this->contentRegion->findOneBy(array('back' => null, 'region' => $region)); while ($first != null) { $contentType = $this->contentType->findOneBy(array('content' => $first->getContent())); if ($contentType) { $type = $contentType->getType()->getName(); } else { $type = 'default'; } $array[$region->getName()][] = array( 'content' => $first->getContent(), 'size' => $first->getSize(), 'menu' => '', 'type' => $type, 'region' => $region->getName() ); $first = $first->getNext(); } } return $array; }
[ "public", "function", "getRegionContents", "(", ")", "{", "$", "array", "=", "array", "(", ")", ";", "$", "regions", "=", "$", "this", "->", "region", "->", "findAll", "(", ")", ";", "foreach", "(", "$", "regions", "as", "$", "region", ")", "{", "$", "first", "=", "$", "this", "->", "contentRegion", "->", "findOneBy", "(", "array", "(", "'back'", "=>", "null", ",", "'region'", "=>", "$", "region", ")", ")", ";", "while", "(", "$", "first", "!=", "null", ")", "{", "$", "contentType", "=", "$", "this", "->", "contentType", "->", "findOneBy", "(", "array", "(", "'content'", "=>", "$", "first", "->", "getContent", "(", ")", ")", ")", ";", "if", "(", "$", "contentType", ")", "{", "$", "type", "=", "$", "contentType", "->", "getType", "(", ")", "->", "getName", "(", ")", ";", "}", "else", "{", "$", "type", "=", "'default'", ";", "}", "$", "array", "[", "$", "region", "->", "getName", "(", ")", "]", "[", "]", "=", "array", "(", "'content'", "=>", "$", "first", "->", "getContent", "(", ")", ",", "'size'", "=>", "$", "first", "->", "getSize", "(", ")", ",", "'menu'", "=>", "''", ",", "'type'", "=>", "$", "type", ",", "'region'", "=>", "$", "region", "->", "getName", "(", ")", ")", ";", "$", "first", "=", "$", "first", "->", "getNext", "(", ")", ";", "}", "}", "return", "$", "array", ";", "}" ]
Get the content of the regions of the front page. @return array The content of regions.
[ "Get", "the", "content", "of", "the", "regions", "of", "the", "front", "page", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L184-L214
222,044
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.getRegion
public function getRegion($content) { $region = $this->contentRegion->findOneBy(array('content' => $content)); if ($region) { return $region->getRegion()->getName(); } }
php
public function getRegion($content) { $region = $this->contentRegion->findOneBy(array('content' => $content)); if ($region) { return $region->getRegion()->getName(); } }
[ "public", "function", "getRegion", "(", "$", "content", ")", "{", "$", "region", "=", "$", "this", "->", "contentRegion", "->", "findOneBy", "(", "array", "(", "'content'", "=>", "$", "content", ")", ")", ";", "if", "(", "$", "region", ")", "{", "return", "$", "region", "->", "getRegion", "(", ")", "->", "getName", "(", ")", ";", "}", "}" ]
Determine in what region a content is.
[ "Determine", "in", "what", "region", "a", "content", "is", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L219-L226
222,045
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.moveContent
public function moveContent($content, $type, $page) { $contenType = $this->contentType->findOneBy(array('type' => $type, 'content' => $content)); $contenType->detach(); $contenType->setType($page); $contenType->setFirst($this->contentType->findOneBy(array('type' => $page, 'back' => null))); $this->manager->persist($contenType); $this->manager->flush(); }
php
public function moveContent($content, $type, $page) { $contenType = $this->contentType->findOneBy(array('type' => $type, 'content' => $content)); $contenType->detach(); $contenType->setType($page); $contenType->setFirst($this->contentType->findOneBy(array('type' => $page, 'back' => null))); $this->manager->persist($contenType); $this->manager->flush(); }
[ "public", "function", "moveContent", "(", "$", "content", ",", "$", "type", ",", "$", "page", ")", "{", "$", "contenType", "=", "$", "this", "->", "contentType", "->", "findOneBy", "(", "array", "(", "'type'", "=>", "$", "type", ",", "'content'", "=>", "$", "content", ")", ")", ";", "$", "contenType", "->", "detach", "(", ")", ";", "$", "contenType", "->", "setType", "(", "$", "page", ")", ";", "$", "contenType", "->", "setFirst", "(", "$", "this", "->", "contentType", "->", "findOneBy", "(", "array", "(", "'type'", "=>", "$", "page", ",", "'back'", "=>", "null", ")", ")", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "contenType", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "}" ]
Move a content from a type to another @param content The content to move @param page The page type where move the content @return This function doesn't return anything.
[ "Move", "a", "content", "from", "a", "type", "to", "another" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L364-L374
222,046
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.deleteContent
public function deleteContent($content) { $this->deleNodeEntity($this->contentType, array('content' => $content)); $this->deleNodeEntity( $this->subContent, array('father' => $content), function ($entity) { $this->deleteContent($entity->getChild()); } ); $this->deleNodeEntity($this->subContent, array('child' => $content)); $this->deleNodeEntity($this->contentRegion, array('content' => $content)); $this->manager->remove($content); $this->manager->flush(); }
php
public function deleteContent($content) { $this->deleNodeEntity($this->contentType, array('content' => $content)); $this->deleNodeEntity( $this->subContent, array('father' => $content), function ($entity) { $this->deleteContent($entity->getChild()); } ); $this->deleNodeEntity($this->subContent, array('child' => $content)); $this->deleNodeEntity($this->contentRegion, array('content' => $content)); $this->manager->remove($content); $this->manager->flush(); }
[ "public", "function", "deleteContent", "(", "$", "content", ")", "{", "$", "this", "->", "deleNodeEntity", "(", "$", "this", "->", "contentType", ",", "array", "(", "'content'", "=>", "$", "content", ")", ")", ";", "$", "this", "->", "deleNodeEntity", "(", "$", "this", "->", "subContent", ",", "array", "(", "'father'", "=>", "$", "content", ")", ",", "function", "(", "$", "entity", ")", "{", "$", "this", "->", "deleteContent", "(", "$", "entity", "->", "getChild", "(", ")", ")", ";", "}", ")", ";", "$", "this", "->", "deleNodeEntity", "(", "$", "this", "->", "subContent", ",", "array", "(", "'child'", "=>", "$", "content", ")", ")", ";", "$", "this", "->", "deleNodeEntity", "(", "$", "this", "->", "contentRegion", ",", "array", "(", "'content'", "=>", "$", "content", ")", ")", ";", "$", "this", "->", "manager", "->", "remove", "(", "$", "content", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "}" ]
Delete a content and his childs. @return This function doesn't return anything.
[ "Delete", "a", "content", "and", "his", "childs", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L381-L394
222,047
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.deleteType
public function deleteType($type) { $contents = $this->contentType->findBy(array('type' => $type)); foreach ($contents as $content) { $this->deleteContent($content->getContent()); } $this->manager->remove($type); $this->manager->flush(); }
php
public function deleteType($type) { $contents = $this->contentType->findBy(array('type' => $type)); foreach ($contents as $content) { $this->deleteContent($content->getContent()); } $this->manager->remove($type); $this->manager->flush(); }
[ "public", "function", "deleteType", "(", "$", "type", ")", "{", "$", "contents", "=", "$", "this", "->", "contentType", "->", "findBy", "(", "array", "(", "'type'", "=>", "$", "type", ")", ")", ";", "foreach", "(", "$", "contents", "as", "$", "content", ")", "{", "$", "this", "->", "deleteContent", "(", "$", "content", "->", "getContent", "(", ")", ")", ";", "}", "$", "this", "->", "manager", "->", "remove", "(", "$", "type", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "}" ]
Delete a type and his childs. @return This function doesn't return anything.
[ "Delete", "a", "type", "and", "his", "childs", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L449-L459
222,048
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.publishType
public function publishType($type) { $publish = true; if ($type instanceof Type and $type->getName() !== 'home' and $type->getName() !== 'menu') { if ($type->isPublish()) { $publish = false; } $type->setPublish($publish); $this->manager->persist($type); $this->manager->flush(); } return $publish; }
php
public function publishType($type) { $publish = true; if ($type instanceof Type and $type->getName() !== 'home' and $type->getName() !== 'menu') { if ($type->isPublish()) { $publish = false; } $type->setPublish($publish); $this->manager->persist($type); $this->manager->flush(); } return $publish; }
[ "public", "function", "publishType", "(", "$", "type", ")", "{", "$", "publish", "=", "true", ";", "if", "(", "$", "type", "instanceof", "Type", "and", "$", "type", "->", "getName", "(", ")", "!==", "'home'", "and", "$", "type", "->", "getName", "(", ")", "!==", "'menu'", ")", "{", "if", "(", "$", "type", "->", "isPublish", "(", ")", ")", "{", "$", "publish", "=", "false", ";", "}", "$", "type", "->", "setPublish", "(", "$", "publish", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "type", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "}", "return", "$", "publish", ";", "}" ]
Publish content type page @param $type a content type @return boolean
[ "Publish", "content", "type", "page" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L468-L483
222,049
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.contentToRegion
public function contentToRegion($region, $content) { $regions = $this->contentRegion->findBy(array('content' => $content)); if (count($regions) === 1 and $regions[0]->getRegion()->getName() === $region->getName()) { $this->deleteRegions($content, $regions); } else { $this->deleteRegions($content, $regions); $first = $this->contentRegion->findOneBy(array('back' => null, 'region' => $region)); $contentRegion = new Content2Region($first); $contentRegion->setRegion($region); $contentRegion->setContent($content); $this->manager->persist($contentRegion); $this->manager->flush(); } }
php
public function contentToRegion($region, $content) { $regions = $this->contentRegion->findBy(array('content' => $content)); if (count($regions) === 1 and $regions[0]->getRegion()->getName() === $region->getName()) { $this->deleteRegions($content, $regions); } else { $this->deleteRegions($content, $regions); $first = $this->contentRegion->findOneBy(array('back' => null, 'region' => $region)); $contentRegion = new Content2Region($first); $contentRegion->setRegion($region); $contentRegion->setContent($content); $this->manager->persist($contentRegion); $this->manager->flush(); } }
[ "public", "function", "contentToRegion", "(", "$", "region", ",", "$", "content", ")", "{", "$", "regions", "=", "$", "this", "->", "contentRegion", "->", "findBy", "(", "array", "(", "'content'", "=>", "$", "content", ")", ")", ";", "if", "(", "count", "(", "$", "regions", ")", "===", "1", "and", "$", "regions", "[", "0", "]", "->", "getRegion", "(", ")", "->", "getName", "(", ")", "===", "$", "region", "->", "getName", "(", ")", ")", "{", "$", "this", "->", "deleteRegions", "(", "$", "content", ",", "$", "regions", ")", ";", "}", "else", "{", "$", "this", "->", "deleteRegions", "(", "$", "content", ",", "$", "regions", ")", ";", "$", "first", "=", "$", "this", "->", "contentRegion", "->", "findOneBy", "(", "array", "(", "'back'", "=>", "null", ",", "'region'", "=>", "$", "region", ")", ")", ";", "$", "contentRegion", "=", "new", "Content2Region", "(", "$", "first", ")", ";", "$", "contentRegion", "->", "setRegion", "(", "$", "region", ")", ";", "$", "contentRegion", "->", "setContent", "(", "$", "content", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "contentRegion", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "}", "}" ]
Put a content in a region of home page as left, right, footer or header, this is useful for menus. @return string The word "true" useful in ajax.
[ "Put", "a", "content", "in", "a", "region", "of", "home", "page", "as", "left", "right", "footer", "or", "header", "this", "is", "useful", "for", "menus", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L512-L528
222,050
claroline/CoreBundle
Manager/HomeManager.php
HomeManager.collapse
public function collapse($content, $type) { $contentType = $this->contentType->findOneBy(array('content' => $content, 'type' => $type)); $contentType->setCollapse(!$contentType->isCollapse()); $this->manager->persist($contentType); $this->manager->flush(); }
php
public function collapse($content, $type) { $contentType = $this->contentType->findOneBy(array('content' => $content, 'type' => $type)); $contentType->setCollapse(!$contentType->isCollapse()); $this->manager->persist($contentType); $this->manager->flush(); }
[ "public", "function", "collapse", "(", "$", "content", ",", "$", "type", ")", "{", "$", "contentType", "=", "$", "this", "->", "contentType", "->", "findOneBy", "(", "array", "(", "'content'", "=>", "$", "content", ",", "'type'", "=>", "$", "type", ")", ")", ";", "$", "contentType", "->", "setCollapse", "(", "!", "$", "contentType", "->", "isCollapse", "(", ")", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "contentType", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "}" ]
Update the collapse attribute of a content.
[ "Update", "the", "collapse", "attribute", "of", "a", "content", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/HomeManager.php#L622-L629
222,051
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.createFacet
public function createFacet($name, $forceCreationForm = false) { $this->om->startFlushSuite(); $facet = new Facet(); $facet->setName($name); $facet->setForceCreationForm($forceCreationForm); $facet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\Facet')); $this->initFacetPermissions($facet); $this->om->persist($facet); $this->om->endFlushSuite(); return $facet; }
php
public function createFacet($name, $forceCreationForm = false) { $this->om->startFlushSuite(); $facet = new Facet(); $facet->setName($name); $facet->setForceCreationForm($forceCreationForm); $facet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\Facet')); $this->initFacetPermissions($facet); $this->om->persist($facet); $this->om->endFlushSuite(); return $facet; }
[ "public", "function", "createFacet", "(", "$", "name", ",", "$", "forceCreationForm", "=", "false", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "facet", "=", "new", "Facet", "(", ")", ";", "$", "facet", "->", "setName", "(", "$", "name", ")", ";", "$", "facet", "->", "setForceCreationForm", "(", "$", "forceCreationForm", ")", ";", "$", "facet", "->", "setPosition", "(", "$", "this", "->", "om", "->", "count", "(", "'Claroline\\CoreBundle\\Entity\\Facet\\Facet'", ")", ")", ";", "$", "this", "->", "initFacetPermissions", "(", "$", "facet", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "facet", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "return", "$", "facet", ";", "}" ]
Creates a new facet. @param $name
[ "Creates", "a", "new", "facet", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L73-L85
222,052
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.removeFacet
public function removeFacet(Facet $facet) { $this->om->remove($facet); $this->om->flush(); $this->reorderFacets(); }
php
public function removeFacet(Facet $facet) { $this->om->remove($facet); $this->om->flush(); $this->reorderFacets(); }
[ "public", "function", "removeFacet", "(", "Facet", "$", "facet", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "facet", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "$", "this", "->", "reorderFacets", "(", ")", ";", "}" ]
Removes an existing facet. @param Facet $facet
[ "Removes", "an", "existing", "facet", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L92-L97
222,053
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.reorderFacets
public function reorderFacets() { $facets = $this->getFacets(); $order = 0; foreach ($facets as $facet) { $facet->setPosition($order); $order++; $this->om->persist($facet); } $this->om->flush(); }
php
public function reorderFacets() { $facets = $this->getFacets(); $order = 0; foreach ($facets as $facet) { $facet->setPosition($order); $order++; $this->om->persist($facet); } $this->om->flush(); }
[ "public", "function", "reorderFacets", "(", ")", "{", "$", "facets", "=", "$", "this", "->", "getFacets", "(", ")", ";", "$", "order", "=", "0", ";", "foreach", "(", "$", "facets", "as", "$", "facet", ")", "{", "$", "facet", "->", "setPosition", "(", "$", "order", ")", ";", "$", "order", "++", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "facet", ")", ";", "}", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Fixes gaps beteween facet orders
[ "Fixes", "gaps", "beteween", "facet", "orders" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L112-L124
222,054
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.reorderFields
public function reorderFields(PanelFacet $panelFacet) { $fields = $panelFacet->getFieldsFacet(); $order = 0; foreach ($fields as $field) { $field->setPosition($order); $order++; $this->om->persist($field); } $this->om->flush(); }
php
public function reorderFields(PanelFacet $panelFacet) { $fields = $panelFacet->getFieldsFacet(); $order = 0; foreach ($fields as $field) { $field->setPosition($order); $order++; $this->om->persist($field); } $this->om->flush(); }
[ "public", "function", "reorderFields", "(", "PanelFacet", "$", "panelFacet", ")", "{", "$", "fields", "=", "$", "panelFacet", "->", "getFieldsFacet", "(", ")", ";", "$", "order", "=", "0", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "field", "->", "setPosition", "(", "$", "order", ")", ";", "$", "order", "++", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "field", ")", ";", "}", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Fixes gaps beteween fields orders
[ "Fixes", "gaps", "beteween", "fields", "orders" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L129-L141
222,055
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.addField
public function addField(PanelFacet $panelFacet, $name, $type) { $this->om->startFlushSuite(); $fieldFacet = new FieldFacet(); $fieldFacet->setPanelFacet($panelFacet); $fieldFacet->setName($name); $fieldFacet->setType($type); $fieldFacet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\FieldFacet')); $this->initFieldPermissions($fieldFacet); $this->om->persist($fieldFacet); $this->om->endFlushSuite(); return $fieldFacet; }
php
public function addField(PanelFacet $panelFacet, $name, $type) { $this->om->startFlushSuite(); $fieldFacet = new FieldFacet(); $fieldFacet->setPanelFacet($panelFacet); $fieldFacet->setName($name); $fieldFacet->setType($type); $fieldFacet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\FieldFacet')); $this->initFieldPermissions($fieldFacet); $this->om->persist($fieldFacet); $this->om->endFlushSuite(); return $fieldFacet; }
[ "public", "function", "addField", "(", "PanelFacet", "$", "panelFacet", ",", "$", "name", ",", "$", "type", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "fieldFacet", "=", "new", "FieldFacet", "(", ")", ";", "$", "fieldFacet", "->", "setPanelFacet", "(", "$", "panelFacet", ")", ";", "$", "fieldFacet", "->", "setName", "(", "$", "name", ")", ";", "$", "fieldFacet", "->", "setType", "(", "$", "type", ")", ";", "$", "fieldFacet", "->", "setPosition", "(", "$", "this", "->", "om", "->", "count", "(", "'Claroline\\CoreBundle\\Entity\\Facet\\FieldFacet'", ")", ")", ";", "$", "this", "->", "initFieldPermissions", "(", "$", "fieldFacet", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "fieldFacet", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "return", "$", "fieldFacet", ";", "}" ]
Creates a new field for a facet @param PanelFacet $facet @param string $name @param integer $type
[ "Creates", "a", "new", "field", "for", "a", "facet" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L150-L163
222,056
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.editPanel
public function editPanel(PanelFacet $panel) { $this->om->persist($panel); $this->om->flush(); return $panel; }
php
public function editPanel(PanelFacet $panel) { $this->om->persist($panel); $this->om->flush(); return $panel; }
[ "public", "function", "editPanel", "(", "PanelFacet", "$", "panel", ")", "{", "$", "this", "->", "om", "->", "persist", "(", "$", "panel", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "return", "$", "panel", ";", "}" ]
Persists and flush a panel. @param FacetPanel $panel @return FacetPanel
[ "Persists", "and", "flush", "a", "panel", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L193-L199
222,057
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.removePanel
public function removePanel(PanelFacet $panel) { //some reordering have to happen here... $panels = $this->panelRepo->findPanelsAfter($panel); foreach ($panels as $afterPanel) { $afterPanel->setPosition($afterPanel->getPosition() - 1); $this->om->persist($afterPanel); } $this->om->remove($panel); $this->om->flush(); //reorder the fields for the still standing panels $panels = $this->panelRepo->findAll(); foreach ($panels as $panel) { $this->reorderFields($panel); } }
php
public function removePanel(PanelFacet $panel) { //some reordering have to happen here... $panels = $this->panelRepo->findPanelsAfter($panel); foreach ($panels as $afterPanel) { $afterPanel->setPosition($afterPanel->getPosition() - 1); $this->om->persist($afterPanel); } $this->om->remove($panel); $this->om->flush(); //reorder the fields for the still standing panels $panels = $this->panelRepo->findAll(); foreach ($panels as $panel) { $this->reorderFields($panel); } }
[ "public", "function", "removePanel", "(", "PanelFacet", "$", "panel", ")", "{", "//some reordering have to happen here...", "$", "panels", "=", "$", "this", "->", "panelRepo", "->", "findPanelsAfter", "(", "$", "panel", ")", ";", "foreach", "(", "$", "panels", "as", "$", "afterPanel", ")", "{", "$", "afterPanel", "->", "setPosition", "(", "$", "afterPanel", "->", "getPosition", "(", ")", "-", "1", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "afterPanel", ")", ";", "}", "$", "this", "->", "om", "->", "remove", "(", "$", "panel", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "//reorder the fields for the still standing panels", "$", "panels", "=", "$", "this", "->", "panelRepo", "->", "findAll", "(", ")", ";", "foreach", "(", "$", "panels", "as", "$", "panel", ")", "{", "$", "this", "->", "reorderFields", "(", "$", "panel", ")", ";", "}", "}" ]
Removes a panel. @param FacetPanel $panel
[ "Removes", "a", "panel", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L206-L224
222,058
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.removeField
public function removeField(FieldFacet $field) { $panel = $field->getPanelFacet(); $this->om->remove($field); $this->om->flush(); $this->reorderFields($panel); }
php
public function removeField(FieldFacet $field) { $panel = $field->getPanelFacet(); $this->om->remove($field); $this->om->flush(); $this->reorderFields($panel); }
[ "public", "function", "removeField", "(", "FieldFacet", "$", "field", ")", "{", "$", "panel", "=", "$", "field", "->", "getPanelFacet", "(", ")", ";", "$", "this", "->", "om", "->", "remove", "(", "$", "field", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "$", "this", "->", "reorderFields", "(", "$", "panel", ")", ";", "}" ]
Removes a field from a facet @param FieldFacet $field
[ "Removes", "a", "field", "from", "a", "facet" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L231-L237
222,059
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.setFieldValue
public function setFieldValue(User $user, FieldFacet $field, $value, $force = false) { if (!$this->authorization->isGranted('edit', $field) && !$force) { throw new AccessDeniedException(); } $fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue') ->findOneBy(array('user' => $user, 'fieldFacet' => $field)); if ($fieldFacetValue === null) { $fieldFacetValue = new FieldFacetValue(); $fieldFacetValue->setUser($user); $fieldFacetValue->setFieldFacet($field); } switch ($field->getType()) { case FieldFacet::DATE_TYPE: $date = is_string($value) ? \DateTime::createFromFormat( $this->translator->trans('date_form_datepicker_php', array(), 'platform'), $value ): $value; $fieldFacetValue->setDateValue($date); break; case FieldFacet::FLOAT_TYPE: $fieldFacetValue->setFloatValue($value); break; case FieldFacet::STRING_TYPE: $fieldFacetValue->setStringValue($value); break; default: throw new \Exception('The facet type ' . $field->getType() . ' is unknown.'); } $this->om->persist($fieldFacetValue); $this->om->flush(); }
php
public function setFieldValue(User $user, FieldFacet $field, $value, $force = false) { if (!$this->authorization->isGranted('edit', $field) && !$force) { throw new AccessDeniedException(); } $fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue') ->findOneBy(array('user' => $user, 'fieldFacet' => $field)); if ($fieldFacetValue === null) { $fieldFacetValue = new FieldFacetValue(); $fieldFacetValue->setUser($user); $fieldFacetValue->setFieldFacet($field); } switch ($field->getType()) { case FieldFacet::DATE_TYPE: $date = is_string($value) ? \DateTime::createFromFormat( $this->translator->trans('date_form_datepicker_php', array(), 'platform'), $value ): $value; $fieldFacetValue->setDateValue($date); break; case FieldFacet::FLOAT_TYPE: $fieldFacetValue->setFloatValue($value); break; case FieldFacet::STRING_TYPE: $fieldFacetValue->setStringValue($value); break; default: throw new \Exception('The facet type ' . $field->getType() . ' is unknown.'); } $this->om->persist($fieldFacetValue); $this->om->flush(); }
[ "public", "function", "setFieldValue", "(", "User", "$", "user", ",", "FieldFacet", "$", "field", ",", "$", "value", ",", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "authorization", "->", "isGranted", "(", "'edit'", ",", "$", "field", ")", "&&", "!", "$", "force", ")", "{", "throw", "new", "AccessDeniedException", "(", ")", ";", "}", "$", "fieldFacetValue", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineCoreBundle:Facet\\FieldFacetValue'", ")", "->", "findOneBy", "(", "array", "(", "'user'", "=>", "$", "user", ",", "'fieldFacet'", "=>", "$", "field", ")", ")", ";", "if", "(", "$", "fieldFacetValue", "===", "null", ")", "{", "$", "fieldFacetValue", "=", "new", "FieldFacetValue", "(", ")", ";", "$", "fieldFacetValue", "->", "setUser", "(", "$", "user", ")", ";", "$", "fieldFacetValue", "->", "setFieldFacet", "(", "$", "field", ")", ";", "}", "switch", "(", "$", "field", "->", "getType", "(", ")", ")", "{", "case", "FieldFacet", "::", "DATE_TYPE", ":", "$", "date", "=", "is_string", "(", "$", "value", ")", "?", "\\", "DateTime", "::", "createFromFormat", "(", "$", "this", "->", "translator", "->", "trans", "(", "'date_form_datepicker_php'", ",", "array", "(", ")", ",", "'platform'", ")", ",", "$", "value", ")", ":", "$", "value", ";", "$", "fieldFacetValue", "->", "setDateValue", "(", "$", "date", ")", ";", "break", ";", "case", "FieldFacet", "::", "FLOAT_TYPE", ":", "$", "fieldFacetValue", "->", "setFloatValue", "(", "$", "value", ")", ";", "break", ";", "case", "FieldFacet", "::", "STRING_TYPE", ":", "$", "fieldFacetValue", "->", "setStringValue", "(", "$", "value", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "'The facet type '", ".", "$", "field", "->", "getType", "(", ")", ".", "' is unknown.'", ")", ";", "}", "$", "this", "->", "om", "->", "persist", "(", "$", "fieldFacetValue", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Set the value of a field for a user @param User $user @param FieldFacet $field @param mixed $value @throws \Exception
[ "Set", "the", "value", "of", "a", "field", "for", "a", "user" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L248-L285
222,060
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.moveFacetUp
public function moveFacetUp(Facet $facet) { $currentPosition = $facet->getPosition(); if ($currentPosition < $this->om->count('Claroline\CoreBundle\Entity\Facet\Facet') - 1) { $nextPosition = $currentPosition + 1; $nextFacet = $this->om ->getRepository('ClarolineCoreBundle:Facet\Facet') ->findOneBy(array('position' => $nextPosition)); $nextFacet->setPosition($currentPosition); $facet->setPosition($nextPosition); $this->om->persist($nextFacet); $this->om->persist($facet); $this->om->flush(); } }
php
public function moveFacetUp(Facet $facet) { $currentPosition = $facet->getPosition(); if ($currentPosition < $this->om->count('Claroline\CoreBundle\Entity\Facet\Facet') - 1) { $nextPosition = $currentPosition + 1; $nextFacet = $this->om ->getRepository('ClarolineCoreBundle:Facet\Facet') ->findOneBy(array('position' => $nextPosition)); $nextFacet->setPosition($currentPosition); $facet->setPosition($nextPosition); $this->om->persist($nextFacet); $this->om->persist($facet); $this->om->flush(); } }
[ "public", "function", "moveFacetUp", "(", "Facet", "$", "facet", ")", "{", "$", "currentPosition", "=", "$", "facet", "->", "getPosition", "(", ")", ";", "if", "(", "$", "currentPosition", "<", "$", "this", "->", "om", "->", "count", "(", "'Claroline\\CoreBundle\\Entity\\Facet\\Facet'", ")", "-", "1", ")", "{", "$", "nextPosition", "=", "$", "currentPosition", "+", "1", ";", "$", "nextFacet", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineCoreBundle:Facet\\Facet'", ")", "->", "findOneBy", "(", "array", "(", "'position'", "=>", "$", "nextPosition", ")", ")", ";", "$", "nextFacet", "->", "setPosition", "(", "$", "currentPosition", ")", ";", "$", "facet", "->", "setPosition", "(", "$", "nextPosition", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "nextFacet", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "facet", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}", "}" ]
Moves a facet up @param Facet $facet
[ "Moves", "a", "facet", "up" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L298-L313
222,061
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.moveFacetDown
public function moveFacetDown(Facet $facet) { $currentPosition = $facet->getPosition(); if ($currentPosition > 0) { $prevPosition = $currentPosition - 1; $prevFacet = $this->om ->getRepository('ClarolineCoreBundle:Facet\Facet') ->findOneBy(array('position' => $prevPosition)); $prevFacet->setPosition($currentPosition); $facet->setPosition($prevPosition); $this->om->persist($prevFacet); $this->om->persist($facet); $this->om->flush(); } }
php
public function moveFacetDown(Facet $facet) { $currentPosition = $facet->getPosition(); if ($currentPosition > 0) { $prevPosition = $currentPosition - 1; $prevFacet = $this->om ->getRepository('ClarolineCoreBundle:Facet\Facet') ->findOneBy(array('position' => $prevPosition)); $prevFacet->setPosition($currentPosition); $facet->setPosition($prevPosition); $this->om->persist($prevFacet); $this->om->persist($facet); $this->om->flush(); } }
[ "public", "function", "moveFacetDown", "(", "Facet", "$", "facet", ")", "{", "$", "currentPosition", "=", "$", "facet", "->", "getPosition", "(", ")", ";", "if", "(", "$", "currentPosition", ">", "0", ")", "{", "$", "prevPosition", "=", "$", "currentPosition", "-", "1", ";", "$", "prevFacet", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineCoreBundle:Facet\\Facet'", ")", "->", "findOneBy", "(", "array", "(", "'position'", "=>", "$", "prevPosition", ")", ")", ";", "$", "prevFacet", "->", "setPosition", "(", "$", "currentPosition", ")", ";", "$", "facet", "->", "setPosition", "(", "$", "prevPosition", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "prevFacet", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "facet", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}", "}" ]
Moves a facet down @param Facet $facet
[ "Moves", "a", "facet", "down" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L320-L335
222,062
claroline/CoreBundle
Manager/FacetManager.php
FacetManager.setFieldBoolProperty
public function setFieldBoolProperty(FieldFacet $fieldFacet, array $roles, $property) { //find each fields sharing the same role as $fieldFacet $fieldFacetsRole = $fieldFacet->getFieldFacetsRole(); //get the correct setter $setterFunc = 'set' . ucfirst($property); //initialize an array of roles wich are not linked to the field $unknownRoles = array(); //initialize an array of fieldFacetRoles wich are going to have their property to true $fieldFacetRolesToChange = array(); //initialize each of field facets property to false foreach ($fieldFacetsRole as $fieldFacetRole) { $fieldFacetRole->$setterFunc(false); } //find roles wich are not linked to a field foreach ($roles as $role) { $found = false; foreach ($fieldFacetsRole as $fieldFacetRole) { if ($fieldFacetRole->getRole()->getId() === $role->getId()) { $found = true; $fieldFacetRolesToChange[] = $fieldFacetRole; } } if (!$found) { $unknownRoles[] = $role; } } //create a new FieldFacetRole for each missing role foreach ($unknownRoles as $unknownRole) { $ffr = new FieldFacetRole(); $ffr->setRole($unknownRole); $ffr->setFieldFacet($fieldFacet); //add the new fieldFacetRole to the list of retrieved fieldFacetRoles at the beginning $fieldFacetRolesToChange[] = $ffr; } //set the property correctly foreach ($fieldFacetRolesToChange as $ffr) { $ffr->$setterFunc(true); $this->om->persist($ffr); } $this->om->flush(); }
php
public function setFieldBoolProperty(FieldFacet $fieldFacet, array $roles, $property) { //find each fields sharing the same role as $fieldFacet $fieldFacetsRole = $fieldFacet->getFieldFacetsRole(); //get the correct setter $setterFunc = 'set' . ucfirst($property); //initialize an array of roles wich are not linked to the field $unknownRoles = array(); //initialize an array of fieldFacetRoles wich are going to have their property to true $fieldFacetRolesToChange = array(); //initialize each of field facets property to false foreach ($fieldFacetsRole as $fieldFacetRole) { $fieldFacetRole->$setterFunc(false); } //find roles wich are not linked to a field foreach ($roles as $role) { $found = false; foreach ($fieldFacetsRole as $fieldFacetRole) { if ($fieldFacetRole->getRole()->getId() === $role->getId()) { $found = true; $fieldFacetRolesToChange[] = $fieldFacetRole; } } if (!$found) { $unknownRoles[] = $role; } } //create a new FieldFacetRole for each missing role foreach ($unknownRoles as $unknownRole) { $ffr = new FieldFacetRole(); $ffr->setRole($unknownRole); $ffr->setFieldFacet($fieldFacet); //add the new fieldFacetRole to the list of retrieved fieldFacetRoles at the beginning $fieldFacetRolesToChange[] = $ffr; } //set the property correctly foreach ($fieldFacetRolesToChange as $ffr) { $ffr->$setterFunc(true); $this->om->persist($ffr); } $this->om->flush(); }
[ "public", "function", "setFieldBoolProperty", "(", "FieldFacet", "$", "fieldFacet", ",", "array", "$", "roles", ",", "$", "property", ")", "{", "//find each fields sharing the same role as $fieldFacet", "$", "fieldFacetsRole", "=", "$", "fieldFacet", "->", "getFieldFacetsRole", "(", ")", ";", "//get the correct setter", "$", "setterFunc", "=", "'set'", ".", "ucfirst", "(", "$", "property", ")", ";", "//initialize an array of roles wich are not linked to the field", "$", "unknownRoles", "=", "array", "(", ")", ";", "//initialize an array of fieldFacetRoles wich are going to have their property to true", "$", "fieldFacetRolesToChange", "=", "array", "(", ")", ";", "//initialize each of field facets property to false", "foreach", "(", "$", "fieldFacetsRole", "as", "$", "fieldFacetRole", ")", "{", "$", "fieldFacetRole", "->", "$", "setterFunc", "(", "false", ")", ";", "}", "//find roles wich are not linked to a field", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "$", "fieldFacetsRole", "as", "$", "fieldFacetRole", ")", "{", "if", "(", "$", "fieldFacetRole", "->", "getRole", "(", ")", "->", "getId", "(", ")", "===", "$", "role", "->", "getId", "(", ")", ")", "{", "$", "found", "=", "true", ";", "$", "fieldFacetRolesToChange", "[", "]", "=", "$", "fieldFacetRole", ";", "}", "}", "if", "(", "!", "$", "found", ")", "{", "$", "unknownRoles", "[", "]", "=", "$", "role", ";", "}", "}", "//create a new FieldFacetRole for each missing role", "foreach", "(", "$", "unknownRoles", "as", "$", "unknownRole", ")", "{", "$", "ffr", "=", "new", "FieldFacetRole", "(", ")", ";", "$", "ffr", "->", "setRole", "(", "$", "unknownRole", ")", ";", "$", "ffr", "->", "setFieldFacet", "(", "$", "fieldFacet", ")", ";", "//add the new fieldFacetRole to the list of retrieved fieldFacetRoles at the beginning", "$", "fieldFacetRolesToChange", "[", "]", "=", "$", "ffr", ";", "}", "//set the property correctly", "foreach", "(", "$", "fieldFacetRolesToChange", "as", "$", "ffr", ")", "{", "$", "ffr", "->", "$", "setterFunc", "(", "true", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "ffr", ")", ";", "}", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
This function will allow to set on of the boolean property of FieldFacetRole for a fieldFacet and an array of roles. @param FieldFacet $fieldFacet @param array $roles @param $property (canOpen | canEdit)
[ "This", "function", "will", "allow", "to", "set", "on", "of", "the", "boolean", "property", "of", "FieldFacetRole", "for", "a", "fieldFacet", "and", "an", "array", "of", "roles", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/FacetManager.php#L458-L510
222,063
claroline/CoreBundle
Manager/RightsManager.php
RightsManager.create
public function create( $permissions, Role $role, ResourceNode $node, $isRecursive, array $creations = array() ) { $rights = $this->rightsRepo->findBy(array('role' => $role, 'resourceNode' => $node)); if (count($rights) === 0) { $isRecursive ? $this->recursiveCreation($permissions, $role, $node, $creations) : $this->nonRecursiveCreation($permissions, $role, $node, $creations); } else { $this->editPerms($permissions, $role, $node, $isRecursive, $creations); } }
php
public function create( $permissions, Role $role, ResourceNode $node, $isRecursive, array $creations = array() ) { $rights = $this->rightsRepo->findBy(array('role' => $role, 'resourceNode' => $node)); if (count($rights) === 0) { $isRecursive ? $this->recursiveCreation($permissions, $role, $node, $creations) : $this->nonRecursiveCreation($permissions, $role, $node, $creations); } else { $this->editPerms($permissions, $role, $node, $isRecursive, $creations); } }
[ "public", "function", "create", "(", "$", "permissions", ",", "Role", "$", "role", ",", "ResourceNode", "$", "node", ",", "$", "isRecursive", ",", "array", "$", "creations", "=", "array", "(", ")", ")", "{", "$", "rights", "=", "$", "this", "->", "rightsRepo", "->", "findBy", "(", "array", "(", "'role'", "=>", "$", "role", ",", "'resourceNode'", "=>", "$", "node", ")", ")", ";", "if", "(", "count", "(", "$", "rights", ")", "===", "0", ")", "{", "$", "isRecursive", "?", "$", "this", "->", "recursiveCreation", "(", "$", "permissions", ",", "$", "role", ",", "$", "node", ",", "$", "creations", ")", ":", "$", "this", "->", "nonRecursiveCreation", "(", "$", "permissions", ",", "$", "role", ",", "$", "node", ",", "$", "creations", ")", ";", "}", "else", "{", "$", "this", "->", "editPerms", "(", "$", "permissions", ",", "$", "role", ",", "$", "node", ",", "$", "isRecursive", ",", "$", "creations", ")", ";", "}", "}" ]
Create a new ResourceRight. If the ResourceRight already exists, it's edited instead. @param array|integer $permissions @param \Claroline\CoreBundle\Entity\Role $role @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node @param boolean $isRecursive @param array $creations
[ "Create", "a", "new", "ResourceRight", ".", "If", "the", "ResourceRight", "already", "exists", "it", "s", "edited", "instead", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/RightsManager.php#L107-L124
222,064
claroline/CoreBundle
Manager/RightsManager.php
RightsManager.copy
public function copy(ResourceNode $original, ResourceNode $node) { $originalRights = $this->rightsRepo->findBy(array('resourceNode' => $original)); $this->om->startFlushSuite(); foreach ($originalRights as $originalRight) { $new = $this->om->factory('Claroline\CoreBundle\Entity\Resource\ResourceRights'); $new->setRole($originalRight->getRole()); $new->setResourceNode($node); $new->setMask($originalRight->getMask()); $new->setCreatableResourceTypes($originalRight->getCreatableResourceTypes()->toArray()); $this->om->persist($new); $node->addRight($new); } $this->om->endFlushSuite(); return $node; }
php
public function copy(ResourceNode $original, ResourceNode $node) { $originalRights = $this->rightsRepo->findBy(array('resourceNode' => $original)); $this->om->startFlushSuite(); foreach ($originalRights as $originalRight) { $new = $this->om->factory('Claroline\CoreBundle\Entity\Resource\ResourceRights'); $new->setRole($originalRight->getRole()); $new->setResourceNode($node); $new->setMask($originalRight->getMask()); $new->setCreatableResourceTypes($originalRight->getCreatableResourceTypes()->toArray()); $this->om->persist($new); $node->addRight($new); } $this->om->endFlushSuite(); return $node; }
[ "public", "function", "copy", "(", "ResourceNode", "$", "original", ",", "ResourceNode", "$", "node", ")", "{", "$", "originalRights", "=", "$", "this", "->", "rightsRepo", "->", "findBy", "(", "array", "(", "'resourceNode'", "=>", "$", "original", ")", ")", ";", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "originalRights", "as", "$", "originalRight", ")", "{", "$", "new", "=", "$", "this", "->", "om", "->", "factory", "(", "'Claroline\\CoreBundle\\Entity\\Resource\\ResourceRights'", ")", ";", "$", "new", "->", "setRole", "(", "$", "originalRight", "->", "getRole", "(", ")", ")", ";", "$", "new", "->", "setResourceNode", "(", "$", "node", ")", ";", "$", "new", "->", "setMask", "(", "$", "originalRight", "->", "getMask", "(", ")", ")", ";", "$", "new", "->", "setCreatableResourceTypes", "(", "$", "originalRight", "->", "getCreatableResourceTypes", "(", ")", "->", "toArray", "(", ")", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "new", ")", ";", "$", "node", "->", "addRight", "(", "$", "new", ")", ";", "}", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "return", "$", "node", ";", "}" ]
Copy the rights from the parent to its children. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $original @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node
[ "Copy", "the", "rights", "from", "the", "parent", "to", "its", "children", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/RightsManager.php#L238-L256
222,065
claroline/CoreBundle
Manager/RightsManager.php
RightsManager.canEditPwsPerm
public function canEditPwsPerm(TokenInterface $token) { if ($this->container->get('security.context')->isGranted('ROLE_ADMIN')) return true; $roles = $this->roleManager->getStringRolesFromToken($token); $accesses = $this->om ->getRepository('ClarolineCoreBundle:Resource\PwsRightsManagementAccess') ->findByRoles($roles); foreach ($accesses as $access) { if ($access->isAccessible()) return true; } return false; }
php
public function canEditPwsPerm(TokenInterface $token) { if ($this->container->get('security.context')->isGranted('ROLE_ADMIN')) return true; $roles = $this->roleManager->getStringRolesFromToken($token); $accesses = $this->om ->getRepository('ClarolineCoreBundle:Resource\PwsRightsManagementAccess') ->findByRoles($roles); foreach ($accesses as $access) { if ($access->isAccessible()) return true; } return false; }
[ "public", "function", "canEditPwsPerm", "(", "TokenInterface", "$", "token", ")", "{", "if", "(", "$", "this", "->", "container", "->", "get", "(", "'security.context'", ")", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "return", "true", ";", "$", "roles", "=", "$", "this", "->", "roleManager", "->", "getStringRolesFromToken", "(", "$", "token", ")", ";", "$", "accesses", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineCoreBundle:Resource\\PwsRightsManagementAccess'", ")", "->", "findByRoles", "(", "$", "roles", ")", ";", "foreach", "(", "$", "accesses", "as", "$", "access", ")", "{", "if", "(", "$", "access", "->", "isAccessible", "(", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if the permissions can be edited for a resource. This may change in the future because it's quite heavy !
[ "Check", "if", "the", "permissions", "can", "be", "edited", "for", "a", "resource", ".", "This", "may", "change", "in", "the", "future", "because", "it", "s", "quite", "heavy", "!" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/RightsManager.php#L670-L684
222,066
claroline/CoreBundle
Library/Utilities/ClaroUtilities.php
ClaroUtilities.getRealFileSize
public function getRealFileSize($fileSize) { //B goes at the end because it's always matched otherwise $validUnits = array('KB', 'MB', 'GB', 'TB'); $value = str_replace(' ', '', $fileSize); $replacements = array(''); $pattern = '/(\d+)/'; $data = preg_grep($pattern, array($value)); foreach ($validUnits as $unit) { if (strpos($fileSize, $unit)) { switch($unit) { case 'B': return $data[0] * pow(1024, 0); case 'KB': return $data[0] * pow(1024, 1); case 'MB': return $data[0] * pow(1024, 2); case 'GB': return $data[0] * pow(1024, 3); case 'TB': return $data[0] * pow(1024, 4); } } } return $fileSize; }
php
public function getRealFileSize($fileSize) { //B goes at the end because it's always matched otherwise $validUnits = array('KB', 'MB', 'GB', 'TB'); $value = str_replace(' ', '', $fileSize); $replacements = array(''); $pattern = '/(\d+)/'; $data = preg_grep($pattern, array($value)); foreach ($validUnits as $unit) { if (strpos($fileSize, $unit)) { switch($unit) { case 'B': return $data[0] * pow(1024, 0); case 'KB': return $data[0] * pow(1024, 1); case 'MB': return $data[0] * pow(1024, 2); case 'GB': return $data[0] * pow(1024, 3); case 'TB': return $data[0] * pow(1024, 4); } } } return $fileSize; }
[ "public", "function", "getRealFileSize", "(", "$", "fileSize", ")", "{", "//B goes at the end because it's always matched otherwise", "$", "validUnits", "=", "array", "(", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ")", ";", "$", "value", "=", "str_replace", "(", "' '", ",", "''", ",", "$", "fileSize", ")", ";", "$", "replacements", "=", "array", "(", "''", ")", ";", "$", "pattern", "=", "'/(\\d+)/'", ";", "$", "data", "=", "preg_grep", "(", "$", "pattern", ",", "array", "(", "$", "value", ")", ")", ";", "foreach", "(", "$", "validUnits", "as", "$", "unit", ")", "{", "if", "(", "strpos", "(", "$", "fileSize", ",", "$", "unit", ")", ")", "{", "switch", "(", "$", "unit", ")", "{", "case", "'B'", ":", "return", "$", "data", "[", "0", "]", "*", "pow", "(", "1024", ",", "0", ")", ";", "case", "'KB'", ":", "return", "$", "data", "[", "0", "]", "*", "pow", "(", "1024", ",", "1", ")", ";", "case", "'MB'", ":", "return", "$", "data", "[", "0", "]", "*", "pow", "(", "1024", ",", "2", ")", ";", "case", "'GB'", ":", "return", "$", "data", "[", "0", "]", "*", "pow", "(", "1024", ",", "3", ")", ";", "case", "'TB'", ":", "return", "$", "data", "[", "0", "]", "*", "pow", "(", "1024", ",", "4", ")", ";", "}", "}", "}", "return", "$", "fileSize", ";", "}" ]
Take a formatted file size and returns the number of bytes
[ "Take", "a", "formatted", "file", "size", "and", "returns", "the", "number", "of", "bytes" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Utilities/ClaroUtilities.php#L220-L248
222,067
claroline/CoreBundle
DataFixtures/Required/Data/LoadHomeTabData.php
LoadHomeTabData.load
public function load(ObjectManager $manager) { $translator = $this->container->get('translator'); $infoName = $translator->trans('informations', array(), 'platform'); $desktopHomeTab = new HomeTab(); $desktopHomeTab->setType('admin_desktop'); $desktopHomeTab->setName($infoName); $manager->persist($desktopHomeTab); $desktopHomeTabConfig = new HomeTabConfig(); $desktopHomeTabConfig->setHomeTab($desktopHomeTab); $desktopHomeTabConfig->setType('admin_desktop'); $desktopHomeTabConfig->setVisible(true); $desktopHomeTabConfig->setLocked(false); $desktopHomeTabConfig->setTabOrder(1); $manager->persist($desktopHomeTabConfig); $workspaceHomeTab = new HomeTab(); $workspaceHomeTab->setType('admin_workspace'); $workspaceHomeTab->setName($infoName); $manager->persist($workspaceHomeTab); $workspaceHomeTabConfig = new HomeTabConfig(); $workspaceHomeTabConfig->setHomeTab($workspaceHomeTab); $workspaceHomeTabConfig->setType('admin_workspace'); $workspaceHomeTabConfig->setVisible(true); $workspaceHomeTabConfig->setLocked(false); $workspaceHomeTabConfig->setTabOrder(1); $manager->persist($workspaceHomeTabConfig); }
php
public function load(ObjectManager $manager) { $translator = $this->container->get('translator'); $infoName = $translator->trans('informations', array(), 'platform'); $desktopHomeTab = new HomeTab(); $desktopHomeTab->setType('admin_desktop'); $desktopHomeTab->setName($infoName); $manager->persist($desktopHomeTab); $desktopHomeTabConfig = new HomeTabConfig(); $desktopHomeTabConfig->setHomeTab($desktopHomeTab); $desktopHomeTabConfig->setType('admin_desktop'); $desktopHomeTabConfig->setVisible(true); $desktopHomeTabConfig->setLocked(false); $desktopHomeTabConfig->setTabOrder(1); $manager->persist($desktopHomeTabConfig); $workspaceHomeTab = new HomeTab(); $workspaceHomeTab->setType('admin_workspace'); $workspaceHomeTab->setName($infoName); $manager->persist($workspaceHomeTab); $workspaceHomeTabConfig = new HomeTabConfig(); $workspaceHomeTabConfig->setHomeTab($workspaceHomeTab); $workspaceHomeTabConfig->setType('admin_workspace'); $workspaceHomeTabConfig->setVisible(true); $workspaceHomeTabConfig->setLocked(false); $workspaceHomeTabConfig->setTabOrder(1); $manager->persist($workspaceHomeTabConfig); }
[ "public", "function", "load", "(", "ObjectManager", "$", "manager", ")", "{", "$", "translator", "=", "$", "this", "->", "container", "->", "get", "(", "'translator'", ")", ";", "$", "infoName", "=", "$", "translator", "->", "trans", "(", "'informations'", ",", "array", "(", ")", ",", "'platform'", ")", ";", "$", "desktopHomeTab", "=", "new", "HomeTab", "(", ")", ";", "$", "desktopHomeTab", "->", "setType", "(", "'admin_desktop'", ")", ";", "$", "desktopHomeTab", "->", "setName", "(", "$", "infoName", ")", ";", "$", "manager", "->", "persist", "(", "$", "desktopHomeTab", ")", ";", "$", "desktopHomeTabConfig", "=", "new", "HomeTabConfig", "(", ")", ";", "$", "desktopHomeTabConfig", "->", "setHomeTab", "(", "$", "desktopHomeTab", ")", ";", "$", "desktopHomeTabConfig", "->", "setType", "(", "'admin_desktop'", ")", ";", "$", "desktopHomeTabConfig", "->", "setVisible", "(", "true", ")", ";", "$", "desktopHomeTabConfig", "->", "setLocked", "(", "false", ")", ";", "$", "desktopHomeTabConfig", "->", "setTabOrder", "(", "1", ")", ";", "$", "manager", "->", "persist", "(", "$", "desktopHomeTabConfig", ")", ";", "$", "workspaceHomeTab", "=", "new", "HomeTab", "(", ")", ";", "$", "workspaceHomeTab", "->", "setType", "(", "'admin_workspace'", ")", ";", "$", "workspaceHomeTab", "->", "setName", "(", "$", "infoName", ")", ";", "$", "manager", "->", "persist", "(", "$", "workspaceHomeTab", ")", ";", "$", "workspaceHomeTabConfig", "=", "new", "HomeTabConfig", "(", ")", ";", "$", "workspaceHomeTabConfig", "->", "setHomeTab", "(", "$", "workspaceHomeTab", ")", ";", "$", "workspaceHomeTabConfig", "->", "setType", "(", "'admin_workspace'", ")", ";", "$", "workspaceHomeTabConfig", "->", "setVisible", "(", "true", ")", ";", "$", "workspaceHomeTabConfig", "->", "setLocked", "(", "false", ")", ";", "$", "workspaceHomeTabConfig", "->", "setTabOrder", "(", "1", ")", ";", "$", "manager", "->", "persist", "(", "$", "workspaceHomeTabConfig", ")", ";", "}" ]
Loads the core Home Tabs. @param ObjectManager $manager
[ "Loads", "the", "core", "Home", "Tabs", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/DataFixtures/Required/Data/LoadHomeTabData.php#L29-L59
222,068
claroline/CoreBundle
Repository/ResourceNodeRepository.php
ResourceNodeRepository.findWorkspaceRoot
public function findWorkspaceRoot(Workspace $workspace) { $builder = new ResourceQueryBuilder(); $builder->selectAsEntity() ->whereInWorkspace($workspace) ->whereParentIsNull(); $query = $this->_em->createQuery($builder->getDql()); $query->setParameters($builder->getParameters()); return $query->getOneOrNullResult(); }
php
public function findWorkspaceRoot(Workspace $workspace) { $builder = new ResourceQueryBuilder(); $builder->selectAsEntity() ->whereInWorkspace($workspace) ->whereParentIsNull(); $query = $this->_em->createQuery($builder->getDql()); $query->setParameters($builder->getParameters()); return $query->getOneOrNullResult(); }
[ "public", "function", "findWorkspaceRoot", "(", "Workspace", "$", "workspace", ")", "{", "$", "builder", "=", "new", "ResourceQueryBuilder", "(", ")", ";", "$", "builder", "->", "selectAsEntity", "(", ")", "->", "whereInWorkspace", "(", "$", "workspace", ")", "->", "whereParentIsNull", "(", ")", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "builder", "->", "getDql", "(", ")", ")", ";", "$", "query", "->", "setParameters", "(", "$", "builder", "->", "getParameters", "(", ")", ")", ";", "return", "$", "query", "->", "getOneOrNullResult", "(", ")", ";", "}" ]
Returns the root directory of a workspace. @param Workspace $workspace @return ResourceNode
[ "Returns", "the", "root", "directory", "of", "a", "workspace", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceNodeRepository.php#L48-L58
222,069
claroline/CoreBundle
Repository/ResourceNodeRepository.php
ResourceNodeRepository.findWorkspaceRootsByUser
public function findWorkspaceRootsByUser(User $user) { $builder = new ResourceQueryBuilder(); $dql = $builder->selectAsArray() ->whereParentIsNull() ->whereInUserWorkspace($user) ->orderByPath() ->getDql(); $query = $this->_em->createQuery($dql); $query->setParameters($builder->getParameters()); return $this->executeQuery($query); }
php
public function findWorkspaceRootsByUser(User $user) { $builder = new ResourceQueryBuilder(); $dql = $builder->selectAsArray() ->whereParentIsNull() ->whereInUserWorkspace($user) ->orderByPath() ->getDql(); $query = $this->_em->createQuery($dql); $query->setParameters($builder->getParameters()); return $this->executeQuery($query); }
[ "public", "function", "findWorkspaceRootsByUser", "(", "User", "$", "user", ")", "{", "$", "builder", "=", "new", "ResourceQueryBuilder", "(", ")", ";", "$", "dql", "=", "$", "builder", "->", "selectAsArray", "(", ")", "->", "whereParentIsNull", "(", ")", "->", "whereInUserWorkspace", "(", "$", "user", ")", "->", "orderByPath", "(", ")", "->", "getDql", "(", ")", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setParameters", "(", "$", "builder", "->", "getParameters", "(", ")", ")", ";", "return", "$", "this", "->", "executeQuery", "(", "$", "query", ")", ";", "}" ]
Returns the root directories of workspaces a user is registered to. @param User $user @return array[array] An array of resources represented as arrays
[ "Returns", "the", "root", "directories", "of", "workspaces", "a", "user", "is", "registered", "to", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceNodeRepository.php#L200-L212
222,070
claroline/CoreBundle
Repository/ResourceNodeRepository.php
ResourceNodeRepository.findWorkspaceRootsByRoles
public function findWorkspaceRootsByRoles(array $roles) { $builder = new ResourceQueryBuilder(); $dql = $builder->selectAsArray() ->whereParentIsNull() ->whereHasRoleIn($roles) ->orderByName() ->getDql(); $query = $this->_em->createQuery($dql); $query->setParameters($builder->getParameters()); return $this->executeQuery($query); }
php
public function findWorkspaceRootsByRoles(array $roles) { $builder = new ResourceQueryBuilder(); $dql = $builder->selectAsArray() ->whereParentIsNull() ->whereHasRoleIn($roles) ->orderByName() ->getDql(); $query = $this->_em->createQuery($dql); $query->setParameters($builder->getParameters()); return $this->executeQuery($query); }
[ "public", "function", "findWorkspaceRootsByRoles", "(", "array", "$", "roles", ")", "{", "$", "builder", "=", "new", "ResourceQueryBuilder", "(", ")", ";", "$", "dql", "=", "$", "builder", "->", "selectAsArray", "(", ")", "->", "whereParentIsNull", "(", ")", "->", "whereHasRoleIn", "(", "$", "roles", ")", "->", "orderByName", "(", ")", "->", "getDql", "(", ")", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setParameters", "(", "$", "builder", "->", "getParameters", "(", ")", ")", ";", "return", "$", "this", "->", "executeQuery", "(", "$", "query", ")", ";", "}" ]
Returns the roots directories a user is granted access @param array $roles @return array[array] An array of resources represented as arrays
[ "Returns", "the", "roots", "directories", "a", "user", "is", "granted", "access" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceNodeRepository.php#L221-L234
222,071
claroline/CoreBundle
Repository/ResourceNodeRepository.php
ResourceNodeRepository.findAncestors
public function findAncestors(ResourceNode $resource) { // No need to access DB to get ancestors as they are given by the materialized path. $regex = '/-(\d+)' . ResourceNode::PATH_SEPARATOR . '/'; $parts = preg_split($regex, $resource->getPath(), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $ancestors = array(); $currentPath = ''; for ($i = 0, $count = count($parts); $i < $count; $i += 2) { $ancestor = array(); $currentPath = $currentPath . $parts[$i] . '-' . $parts[$i + 1] . '`'; $ancestor['path'] = $currentPath; $ancestor['name'] = $parts[$i]; $ancestor['id'] = (int) $parts[$i + 1]; $ancestors[] = $ancestor; } return $ancestors; }
php
public function findAncestors(ResourceNode $resource) { // No need to access DB to get ancestors as they are given by the materialized path. $regex = '/-(\d+)' . ResourceNode::PATH_SEPARATOR . '/'; $parts = preg_split($regex, $resource->getPath(), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $ancestors = array(); $currentPath = ''; for ($i = 0, $count = count($parts); $i < $count; $i += 2) { $ancestor = array(); $currentPath = $currentPath . $parts[$i] . '-' . $parts[$i + 1] . '`'; $ancestor['path'] = $currentPath; $ancestor['name'] = $parts[$i]; $ancestor['id'] = (int) $parts[$i + 1]; $ancestors[] = $ancestor; } return $ancestors; }
[ "public", "function", "findAncestors", "(", "ResourceNode", "$", "resource", ")", "{", "// No need to access DB to get ancestors as they are given by the materialized path.", "$", "regex", "=", "'/-(\\d+)'", ".", "ResourceNode", "::", "PATH_SEPARATOR", ".", "'/'", ";", "$", "parts", "=", "preg_split", "(", "$", "regex", ",", "$", "resource", "->", "getPath", "(", ")", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", "|", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "ancestors", "=", "array", "(", ")", ";", "$", "currentPath", "=", "''", ";", "for", "(", "$", "i", "=", "0", ",", "$", "count", "=", "count", "(", "$", "parts", ")", ";", "$", "i", "<", "$", "count", ";", "$", "i", "+=", "2", ")", "{", "$", "ancestor", "=", "array", "(", ")", ";", "$", "currentPath", "=", "$", "currentPath", ".", "$", "parts", "[", "$", "i", "]", ".", "'-'", ".", "$", "parts", "[", "$", "i", "+", "1", "]", ".", "'`'", ";", "$", "ancestor", "[", "'path'", "]", "=", "$", "currentPath", ";", "$", "ancestor", "[", "'name'", "]", "=", "$", "parts", "[", "$", "i", "]", ";", "$", "ancestor", "[", "'id'", "]", "=", "(", "int", ")", "$", "parts", "[", "$", "i", "+", "1", "]", ";", "$", "ancestors", "[", "]", "=", "$", "ancestor", ";", "}", "return", "$", "ancestors", ";", "}" ]
Returns the ancestors of a resource, including the resource itself. @param ResourceNode $resource @return array[array] An array of resources represented as arrays
[ "Returns", "the", "ancestors", "of", "a", "resource", "including", "the", "resource", "itself", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceNodeRepository.php#L243-L261
222,072
claroline/CoreBundle
Repository/ResourceNodeRepository.php
ResourceNodeRepository.findWorkspaceInfoByIds
public function findWorkspaceInfoByIds(array $nodesIds) { if (count($nodesIds) === 0) { throw new \InvalidArgumentException('Resource ids array cannot be empty'); } $dql = ' SELECT r.id AS id, w.code AS code, w.name AS name FROM Claroline\CoreBundle\Entity\Resource\ResourceNode r JOIN r.workspace w WHERE r.id IN (:nodeIds) ORDER BY w.name ASC '; $query = $this->_em->createQuery($dql); $query->setParameter('nodeIds', $nodesIds); return $query->getResult(); }
php
public function findWorkspaceInfoByIds(array $nodesIds) { if (count($nodesIds) === 0) { throw new \InvalidArgumentException('Resource ids array cannot be empty'); } $dql = ' SELECT r.id AS id, w.code AS code, w.name AS name FROM Claroline\CoreBundle\Entity\Resource\ResourceNode r JOIN r.workspace w WHERE r.id IN (:nodeIds) ORDER BY w.name ASC '; $query = $this->_em->createQuery($dql); $query->setParameter('nodeIds', $nodesIds); return $query->getResult(); }
[ "public", "function", "findWorkspaceInfoByIds", "(", "array", "$", "nodesIds", ")", "{", "if", "(", "count", "(", "$", "nodesIds", ")", "===", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Resource ids array cannot be empty'", ")", ";", "}", "$", "dql", "=", "'\n SELECT r.id AS id, w.code AS code, w.name AS name\n FROM Claroline\\CoreBundle\\Entity\\Resource\\ResourceNode r\n JOIN r.workspace w\n WHERE r.id IN (:nodeIds)\n ORDER BY w.name ASC\n '", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setParameter", "(", "'nodeIds'", ",", "$", "nodesIds", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Returns the workspace name and code of the resources whose ids are passed as argument. @param array $resourceIds @return array @throws \InvalidArgumentException if the resource ids array is empty
[ "Returns", "the", "workspace", "name", "and", "code", "of", "the", "resources", "whose", "ids", "are", "passed", "as", "argument", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ResourceNodeRepository.php#L349-L366
222,073
claroline/CoreBundle
Manager/ToolManager.php
ToolManager.getDesktopToolsConfigurationArrayForAdmin
public function getDesktopToolsConfigurationArrayForAdmin($type = 0) { $orderedToolList = array(); $desktopTools = $this->orderedToolRepo ->findDisplayableDesktopOrderedToolsByTypeForAdmin($type); foreach ($desktopTools as $desktopTool) { //this field isn't mapped $desktopTool->getTool()->setVisible($desktopTool->isVisibleInDesktop()); $orderedToolList[$desktopTool->getOrder()] = $desktopTool->getTool(); } $undisplayedTools = $this->toolRepo->findDesktopUndisplayedToolsByTypeForAdmin($type); foreach ($undisplayedTools as $tool) { //this field isn't mapped $tool->setVisible(false); } $this->addMissingDesktopToolsForAdmin( $undisplayedTools, count($desktopTools) + 1, $type ); return $this->utilities->arrayFill($orderedToolList, $undisplayedTools); }
php
public function getDesktopToolsConfigurationArrayForAdmin($type = 0) { $orderedToolList = array(); $desktopTools = $this->orderedToolRepo ->findDisplayableDesktopOrderedToolsByTypeForAdmin($type); foreach ($desktopTools as $desktopTool) { //this field isn't mapped $desktopTool->getTool()->setVisible($desktopTool->isVisibleInDesktop()); $orderedToolList[$desktopTool->getOrder()] = $desktopTool->getTool(); } $undisplayedTools = $this->toolRepo->findDesktopUndisplayedToolsByTypeForAdmin($type); foreach ($undisplayedTools as $tool) { //this field isn't mapped $tool->setVisible(false); } $this->addMissingDesktopToolsForAdmin( $undisplayedTools, count($desktopTools) + 1, $type ); return $this->utilities->arrayFill($orderedToolList, $undisplayedTools); }
[ "public", "function", "getDesktopToolsConfigurationArrayForAdmin", "(", "$", "type", "=", "0", ")", "{", "$", "orderedToolList", "=", "array", "(", ")", ";", "$", "desktopTools", "=", "$", "this", "->", "orderedToolRepo", "->", "findDisplayableDesktopOrderedToolsByTypeForAdmin", "(", "$", "type", ")", ";", "foreach", "(", "$", "desktopTools", "as", "$", "desktopTool", ")", "{", "//this field isn't mapped", "$", "desktopTool", "->", "getTool", "(", ")", "->", "setVisible", "(", "$", "desktopTool", "->", "isVisibleInDesktop", "(", ")", ")", ";", "$", "orderedToolList", "[", "$", "desktopTool", "->", "getOrder", "(", ")", "]", "=", "$", "desktopTool", "->", "getTool", "(", ")", ";", "}", "$", "undisplayedTools", "=", "$", "this", "->", "toolRepo", "->", "findDesktopUndisplayedToolsByTypeForAdmin", "(", "$", "type", ")", ";", "foreach", "(", "$", "undisplayedTools", "as", "$", "tool", ")", "{", "//this field isn't mapped", "$", "tool", "->", "setVisible", "(", "false", ")", ";", "}", "$", "this", "->", "addMissingDesktopToolsForAdmin", "(", "$", "undisplayedTools", ",", "count", "(", "$", "desktopTools", ")", "+", "1", ",", "$", "type", ")", ";", "return", "$", "this", "->", "utilities", "->", "arrayFill", "(", "$", "orderedToolList", ",", "$", "undisplayedTools", ")", ";", "}" ]
Returns the sorted list of OrderedTools for configuration in admin. @return \Claroline\CoreBundle\Entity\Tool\OrderedTool
[ "Returns", "the", "sorted", "list", "of", "OrderedTools", "for", "configuration", "in", "admin", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ToolManager.php#L235-L261
222,074
claroline/CoreBundle
Manager/ToolManager.php
ToolManager.extractFiles
public function extractFiles($archpath, $confTools) { $extractPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('claro_ws_tmp_', true); $archive = $this->om->factory('ZipArchive'); $archive->open($archpath); $archive->extractTo($extractPath); $realPaths = array(); if (isset($confTools['files'])) { foreach ($confTools['files'] as $path) { $realPaths[] = $extractPath . DIRECTORY_SEPARATOR . $path; } } return $realPaths; }
php
public function extractFiles($archpath, $confTools) { $extractPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('claro_ws_tmp_', true); $archive = $this->om->factory('ZipArchive'); $archive->open($archpath); $archive->extractTo($extractPath); $realPaths = array(); if (isset($confTools['files'])) { foreach ($confTools['files'] as $path) { $realPaths[] = $extractPath . DIRECTORY_SEPARATOR . $path; } } return $realPaths; }
[ "public", "function", "extractFiles", "(", "$", "archpath", ",", "$", "confTools", ")", "{", "$", "extractPath", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "uniqid", "(", "'claro_ws_tmp_'", ",", "true", ")", ";", "$", "archive", "=", "$", "this", "->", "om", "->", "factory", "(", "'ZipArchive'", ")", ";", "$", "archive", "->", "open", "(", "$", "archpath", ")", ";", "$", "archive", "->", "extractTo", "(", "$", "extractPath", ")", ";", "$", "realPaths", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "confTools", "[", "'files'", "]", ")", ")", "{", "foreach", "(", "$", "confTools", "[", "'files'", "]", "as", "$", "path", ")", "{", "$", "realPaths", "[", "]", "=", "$", "extractPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "path", ";", "}", "}", "return", "$", "realPaths", ";", "}" ]
Extract the files from a the template configuration array @param string $archpath @param array $confTools @return array
[ "Extract", "the", "files", "from", "a", "the", "template", "configuration", "array" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ToolManager.php#L692-L707
222,075
claroline/CoreBundle
Repository/RoleRepository.php
RoleRepository.findWorkspaceRolesForUser
public function findWorkspaceRolesForUser(User $user, Workspace $workspace) { $dql = " SELECT r FROM Claroline\CoreBundle\Entity\Role r JOIN r.workspace ws JOIN r.users user WHERE ws.guid = '{$workspace->getGuid()}' AND r.name != 'ROLE_ADMIN' AND user.id = {$user->getId()} "; $query = $this->_em->createQuery($dql); return $query->getResult(); }
php
public function findWorkspaceRolesForUser(User $user, Workspace $workspace) { $dql = " SELECT r FROM Claroline\CoreBundle\Entity\Role r JOIN r.workspace ws JOIN r.users user WHERE ws.guid = '{$workspace->getGuid()}' AND r.name != 'ROLE_ADMIN' AND user.id = {$user->getId()} "; $query = $this->_em->createQuery($dql); return $query->getResult(); }
[ "public", "function", "findWorkspaceRolesForUser", "(", "User", "$", "user", ",", "Workspace", "$", "workspace", ")", "{", "$", "dql", "=", "\"\n SELECT r FROM Claroline\\CoreBundle\\Entity\\Role r\n JOIN r.workspace ws\n JOIN r.users user\n WHERE ws.guid = '{$workspace->getGuid()}'\n AND r.name != 'ROLE_ADMIN'\n AND user.id = {$user->getId()}\n \"", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Returns the roles of a user in a workspace. @param User $user The subject of the role @param Workspace $workspace The workspace the role should be bound to @return null|Role
[ "Returns", "the", "roles", "of", "a", "user", "in", "a", "workspace", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/RoleRepository.php#L187-L201
222,076
claroline/CoreBundle
Form/Field/ResourcePickerType.php
ResourcePickerType.getResourceNode
private function getResourceNode(FormInterface $form) { if ($form->getData() instanceof ResourceNode) { return $form->getData(); } else if ($form->getData() and $form->getData() != '') { return $this->resourceManager->getById($form->getData()); } }
php
private function getResourceNode(FormInterface $form) { if ($form->getData() instanceof ResourceNode) { return $form->getData(); } else if ($form->getData() and $form->getData() != '') { return $this->resourceManager->getById($form->getData()); } }
[ "private", "function", "getResourceNode", "(", "FormInterface", "$", "form", ")", "{", "if", "(", "$", "form", "->", "getData", "(", ")", "instanceof", "ResourceNode", ")", "{", "return", "$", "form", "->", "getData", "(", ")", ";", "}", "else", "if", "(", "$", "form", "->", "getData", "(", ")", "and", "$", "form", "->", "getData", "(", ")", "!=", "''", ")", "{", "return", "$", "this", "->", "resourceManager", "->", "getById", "(", "$", "form", "->", "getData", "(", ")", ")", ";", "}", "}" ]
Get resource node
[ "Get", "resource", "node" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Form/Field/ResourcePickerType.php#L101-L108
222,077
claroline/CoreBundle
Controller/Administration/FacetController.php
FacetController.fieldFormAction
public function fieldFormAction(PanelFacet $panelFacet) { $form = $this->formFactory->create(new FieldFacetType(), new FieldFacet()); return array('form' => $form->createView(), 'panelFacet' => $panelFacet); }
php
public function fieldFormAction(PanelFacet $panelFacet) { $form = $this->formFactory->create(new FieldFacetType(), new FieldFacet()); return array('form' => $form->createView(), 'panelFacet' => $panelFacet); }
[ "public", "function", "fieldFormAction", "(", "PanelFacet", "$", "panelFacet", ")", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", "new", "FieldFacetType", "(", ")", ",", "new", "FieldFacet", "(", ")", ")", ";", "return", "array", "(", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'panelFacet'", "=>", "$", "panelFacet", ")", ";", "}" ]
Returns the facet field creation form in a modal @EXT\Route("/panel/{panelFacet}/field/form", name="claro_admin_facet_field_form", options = {"expose"=true} ) @EXT\Template
[ "Returns", "the", "facet", "field", "creation", "form", "in", "a", "modal" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/Administration/FacetController.php#L168-L173
222,078
claroline/CoreBundle
Controller/Administration/FacetController.php
FacetController.moveFieldFacetsAction
public function moveFieldFacetsAction(PanelFacet $panel) { $params = $this->request->query->all(); $ids = []; foreach ($params['ids'] as $value) { $ids[] = (int) str_replace('field-', '', $value); } $this->facetManager->orderFields($ids, $panel); return new Response('success'); }
php
public function moveFieldFacetsAction(PanelFacet $panel) { $params = $this->request->query->all(); $ids = []; foreach ($params['ids'] as $value) { $ids[] = (int) str_replace('field-', '', $value); } $this->facetManager->orderFields($ids, $panel); return new Response('success'); }
[ "public", "function", "moveFieldFacetsAction", "(", "PanelFacet", "$", "panel", ")", "{", "$", "params", "=", "$", "this", "->", "request", "->", "query", "->", "all", "(", ")", ";", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "params", "[", "'ids'", "]", "as", "$", "value", ")", "{", "$", "ids", "[", "]", "=", "(", "int", ")", "str_replace", "(", "'field-'", ",", "''", ",", "$", "value", ")", ";", "}", "$", "this", "->", "facetManager", "->", "orderFields", "(", "$", "ids", ",", "$", "panel", ")", ";", "return", "new", "Response", "(", "'success'", ")", ";", "}" ]
Ajax method for ordering fields @EXT\Route("/{panel}/fields/order", name="claro_admin_field_facet_order", options = {"expose"=true} )
[ "Ajax", "method", "for", "ordering", "fields" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/Administration/FacetController.php#L397-L409
222,079
claroline/CoreBundle
Controller/Administration/FacetController.php
FacetController.facetRolesFormAction
public function facetRolesFormAction(Facet $facet) { $roles = $facet->getRoles(); $platformRoles = $this->roleManager->getPlatformNonAdminRoles(true); return array('roles' => $roles, 'facet' => $facet, 'platformRoles' => $platformRoles); }
php
public function facetRolesFormAction(Facet $facet) { $roles = $facet->getRoles(); $platformRoles = $this->roleManager->getPlatformNonAdminRoles(true); return array('roles' => $roles, 'facet' => $facet, 'platformRoles' => $platformRoles); }
[ "public", "function", "facetRolesFormAction", "(", "Facet", "$", "facet", ")", "{", "$", "roles", "=", "$", "facet", "->", "getRoles", "(", ")", ";", "$", "platformRoles", "=", "$", "this", "->", "roleManager", "->", "getPlatformNonAdminRoles", "(", "true", ")", ";", "return", "array", "(", "'roles'", "=>", "$", "roles", ",", "'facet'", "=>", "$", "facet", ",", "'platformRoles'", "=>", "$", "platformRoles", ")", ";", "}" ]
Returns the facet role edition in a modal @EXT\Route("/{facet}/roles/form", name="claro_admin_facet_role_form", options = {"expose"=true} ) @EXT\Template()
[ "Returns", "the", "facet", "role", "edition", "in", "a", "modal" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/Administration/FacetController.php#L421-L427
222,080
claroline/CoreBundle
Controller/Administration/FacetController.php
FacetController.fieldRolesFormAction
public function fieldRolesFormAction(FieldFacet $field) { $fieldFacetsRole = $field->getFieldFacetsRole(); $platformRoles = $this->roleManager->getPlatformNonAdminRoles(true); return array('fieldFacetsRole' => $fieldFacetsRole, 'field' => $field, 'platformRoles' => $platformRoles); }
php
public function fieldRolesFormAction(FieldFacet $field) { $fieldFacetsRole = $field->getFieldFacetsRole(); $platformRoles = $this->roleManager->getPlatformNonAdminRoles(true); return array('fieldFacetsRole' => $fieldFacetsRole, 'field' => $field, 'platformRoles' => $platformRoles); }
[ "public", "function", "fieldRolesFormAction", "(", "FieldFacet", "$", "field", ")", "{", "$", "fieldFacetsRole", "=", "$", "field", "->", "getFieldFacetsRole", "(", ")", ";", "$", "platformRoles", "=", "$", "this", "->", "roleManager", "->", "getPlatformNonAdminRoles", "(", "true", ")", ";", "return", "array", "(", "'fieldFacetsRole'", "=>", "$", "fieldFacetsRole", ",", "'field'", "=>", "$", "field", ",", "'platformRoles'", "=>", "$", "platformRoles", ")", ";", "}" ]
Returns the field role edition in a modal @EXT\Route("/field/{field}/roles/form", name="claro_admin_field_role_form", options = {"expose"=true} ) @EXT\Template()
[ "Returns", "the", "field", "role", "edition", "in", "a", "modal" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/Administration/FacetController.php#L453-L459
222,081
claroline/CoreBundle
Controller/Administration/FacetController.php
FacetController.orderPanels
public function orderPanels(Facet $facet) { $params = $this->request->query->all(); $ids = []; foreach ($params['ids'] as $value) { $ids[] = (int) str_replace('panel-', '', $value); } $this->facetManager->orderPanels($ids, $facet); return new Response('success'); }
php
public function orderPanels(Facet $facet) { $params = $this->request->query->all(); $ids = []; foreach ($params['ids'] as $value) { $ids[] = (int) str_replace('panel-', '', $value); } $this->facetManager->orderPanels($ids, $facet); return new Response('success'); }
[ "public", "function", "orderPanels", "(", "Facet", "$", "facet", ")", "{", "$", "params", "=", "$", "this", "->", "request", "->", "query", "->", "all", "(", ")", ";", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "params", "[", "'ids'", "]", "as", "$", "value", ")", "{", "$", "ids", "[", "]", "=", "(", "int", ")", "str_replace", "(", "'panel-'", ",", "''", ",", "$", "value", ")", ";", "}", "$", "this", "->", "facetManager", "->", "orderPanels", "(", "$", "ids", ",", "$", "facet", ")", ";", "return", "new", "Response", "(", "'success'", ")", ";", "}" ]
Reorder panels. @EXT\Route("/order/panels/facet/{facet}", name="claro_admin_panel_facet_order", options = {"expose" = true} )
[ "Reorder", "panels", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/Administration/FacetController.php#L630-L642
222,082
usmanhalalit/strana
src/Strana/ConfigHelper.php
ConfigHelper.setDefaults
protected function setDefaults() { $get = $_GET; $page = isset($get['page']) ? (int) $get['page'] : 1; $defaults = array( 'perPage' => 20, 'page' => $page, 'maximumPages' => 5, 'infiniteScroll' => false, ); $this->config = array_merge($defaults, $this->config); }
php
protected function setDefaults() { $get = $_GET; $page = isset($get['page']) ? (int) $get['page'] : 1; $defaults = array( 'perPage' => 20, 'page' => $page, 'maximumPages' => 5, 'infiniteScroll' => false, ); $this->config = array_merge($defaults, $this->config); }
[ "protected", "function", "setDefaults", "(", ")", "{", "$", "get", "=", "$", "_GET", ";", "$", "page", "=", "isset", "(", "$", "get", "[", "'page'", "]", ")", "?", "(", "int", ")", "$", "get", "[", "'page'", "]", ":", "1", ";", "$", "defaults", "=", "array", "(", "'perPage'", "=>", "20", ",", "'page'", "=>", "$", "page", ",", "'maximumPages'", "=>", "5", ",", "'infiniteScroll'", "=>", "false", ",", ")", ";", "$", "this", "->", "config", "=", "array_merge", "(", "$", "defaults", ",", "$", "this", "->", "config", ")", ";", "}" ]
Set default config values
[ "Set", "default", "config", "values" ]
8b4f7221df222ab79e1d0d54ddea29519c8c481b
https://github.com/usmanhalalit/strana/blob/8b4f7221df222ab79e1d0d54ddea29519c8c481b/src/Strana/ConfigHelper.php#L21-L33
222,083
symlex/input-validation
src/Form.php
Form.getParam
protected function getParam(string $name) { if (!array_key_exists($name, $this->_params)) { throw new Exception ('Required parameter "' . $name . '" was not set'); } return $this->_params[$name]; }
php
protected function getParam(string $name) { if (!array_key_exists($name, $this->_params)) { throw new Exception ('Required parameter "' . $name . '" was not set'); } return $this->_params[$name]; }
[ "protected", "function", "getParam", "(", "string", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_params", ")", ")", "{", "throw", "new", "Exception", "(", "'Required parameter \"'", ".", "$", "name", ".", "'\" was not set'", ")", ";", "}", "return", "$", "this", "->", "_params", "[", "$", "name", "]", ";", "}" ]
Returns optional config parameter or throws Exception, if parameter does not exist @param string $name @throws Exception @return mixed
[ "Returns", "optional", "config", "parameter", "or", "throws", "Exception", "if", "parameter", "does", "not", "exist" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L154-L161
222,084
symlex/input-validation
src/Form.php
Form.optionsWithDefault
public function optionsWithDefault(string $listName, string $defaultLabel = ''): array { $result = $this->getDefaultOption($defaultLabel) + $this->options($listName); return $result; }
php
public function optionsWithDefault(string $listName, string $defaultLabel = ''): array { $result = $this->getDefaultOption($defaultLabel) + $this->options($listName); return $result; }
[ "public", "function", "optionsWithDefault", "(", "string", "$", "listName", ",", "string", "$", "defaultLabel", "=", "''", ")", ":", "array", "{", "$", "result", "=", "$", "this", "->", "getDefaultOption", "(", "$", "defaultLabel", ")", "+", "$", "this", "->", "options", "(", "$", "listName", ")", ";", "return", "$", "result", ";", "}" ]
Returns a list of options with default label for no selection 'country' => array( 'type' => 'string', 'required' => true, 'options' => $this->form->optionsWithDefault('countries') ) @param string $listName Optional name of options list (shortcut) @param string $defaultLabel The field label translation token @return array
[ "Returns", "a", "list", "of", "options", "with", "default", "label", "for", "no", "selection" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L229-L234
222,085
symlex/input-validation
src/Form.php
Form.getDefaultOption
protected function getDefaultOption(string $label = ''): array { if ($label == '') { $label = $this->getDefaultOptionLabel(); } return array('' => $this->translate($label)); }
php
protected function getDefaultOption(string $label = ''): array { if ($label == '') { $label = $this->getDefaultOptionLabel(); } return array('' => $this->translate($label)); }
[ "protected", "function", "getDefaultOption", "(", "string", "$", "label", "=", "''", ")", ":", "array", "{", "if", "(", "$", "label", "==", "''", ")", "{", "$", "label", "=", "$", "this", "->", "getDefaultOptionLabel", "(", ")", ";", "}", "return", "array", "(", "''", "=>", "$", "this", "->", "translate", "(", "$", "label", ")", ")", ";", "}" ]
Helper function to return default option string like "Please select" @param string $label The field label token @return array
[ "Helper", "function", "to", "return", "default", "option", "string", "like", "Please", "select" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L265-L272
222,086
symlex/input-validation
src/Form.php
Form.addDefinition
public function addDefinition(string $name, array $definition) { if (isset($this->_definition[$name])) { throw new Exception('Definition for "' . $name . '" already exists'); } $this->_definition[$name] = $definition; return $this; }
php
public function addDefinition(string $name, array $definition) { if (isset($this->_definition[$name])) { throw new Exception('Definition for "' . $name . '" already exists'); } $this->_definition[$name] = $definition; return $this; }
[ "public", "function", "addDefinition", "(", "string", "$", "name", ",", "array", "$", "definition", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_definition", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Definition for \"'", ".", "$", "name", ".", "'\" already exists'", ")", ";", "}", "$", "this", "->", "_definition", "[", "$", "name", "]", "=", "$", "definition", ";", "return", "$", "this", ";", "}" ]
Adds a single form field definition @param string $name Field name @param array $definition Field definition array @throws Exception @return $this
[ "Adds", "a", "single", "form", "field", "definition" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L444-L453
222,087
symlex/input-validation
src/Form.php
Form.changeDefinition
public function changeDefinition(string $name, array $changes) { if (!isset($this->_definition[$name])) { throw new Exception('Definition for "' . $name . '" does not exist'); } foreach ($changes as $prop => $val) { if ($val === null) { unset($this->_definition[$name][$prop]); } else { $this->_definition[$name][$prop] = $val; } } return $this; }
php
public function changeDefinition(string $name, array $changes) { if (!isset($this->_definition[$name])) { throw new Exception('Definition for "' . $name . '" does not exist'); } foreach ($changes as $prop => $val) { if ($val === null) { unset($this->_definition[$name][$prop]); } else { $this->_definition[$name][$prop] = $val; } } return $this; }
[ "public", "function", "changeDefinition", "(", "string", "$", "name", ",", "array", "$", "changes", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_definition", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Definition for \"'", ".", "$", "name", ".", "'\" does not exist'", ")", ";", "}", "foreach", "(", "$", "changes", "as", "$", "prop", "=>", "$", "val", ")", "{", "if", "(", "$", "val", "===", "null", ")", "{", "unset", "(", "$", "this", "->", "_definition", "[", "$", "name", "]", "[", "$", "prop", "]", ")", ";", "}", "else", "{", "$", "this", "->", "_definition", "[", "$", "name", "]", "[", "$", "prop", "]", "=", "$", "val", ";", "}", "}", "return", "$", "this", ";", "}" ]
Changes a single form field definition @param string $name Field name @param array $changes Field definition array @throws Exception @return $this
[ "Changes", "a", "single", "form", "field", "definition" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L463-L478
222,088
symlex/input-validation
src/Form.php
Form.getFieldAsArray
public function getFieldAsArray(string $name): array { $result = $this->getFieldDefinition($name); $result['name'] = $name; if (empty($result['caption'])) { $result['caption'] = $this->_($result['name']); } $value = $this->$name; $type = @$result['type']; if (($type == 'date' || $type == 'datetime' || $type == 'time') && is_object($value)) { $value = $value->format($this->translate('form.' . $type)); } $result['value'] = $value; $result['uid'] = 'id' . uniqid(); if (isset($result['options']) && is_array($result['options'])) { $options = array(); foreach ($result['options'] as $option => $label) { $options[] = array('option' => $option, 'label' => $label); } $result['options'] = $options; } return $result; }
php
public function getFieldAsArray(string $name): array { $result = $this->getFieldDefinition($name); $result['name'] = $name; if (empty($result['caption'])) { $result['caption'] = $this->_($result['name']); } $value = $this->$name; $type = @$result['type']; if (($type == 'date' || $type == 'datetime' || $type == 'time') && is_object($value)) { $value = $value->format($this->translate('form.' . $type)); } $result['value'] = $value; $result['uid'] = 'id' . uniqid(); if (isset($result['options']) && is_array($result['options'])) { $options = array(); foreach ($result['options'] as $option => $label) { $options[] = array('option' => $option, 'label' => $label); } $result['options'] = $options; } return $result; }
[ "public", "function", "getFieldAsArray", "(", "string", "$", "name", ")", ":", "array", "{", "$", "result", "=", "$", "this", "->", "getFieldDefinition", "(", "$", "name", ")", ";", "$", "result", "[", "'name'", "]", "=", "$", "name", ";", "if", "(", "empty", "(", "$", "result", "[", "'caption'", "]", ")", ")", "{", "$", "result", "[", "'caption'", "]", "=", "$", "this", "->", "_", "(", "$", "result", "[", "'name'", "]", ")", ";", "}", "$", "value", "=", "$", "this", "->", "$", "name", ";", "$", "type", "=", "@", "$", "result", "[", "'type'", "]", ";", "if", "(", "(", "$", "type", "==", "'date'", "||", "$", "type", "==", "'datetime'", "||", "$", "type", "==", "'time'", ")", "&&", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "value", "->", "format", "(", "$", "this", "->", "translate", "(", "'form.'", ".", "$", "type", ")", ")", ";", "}", "$", "result", "[", "'value'", "]", "=", "$", "value", ";", "$", "result", "[", "'uid'", "]", "=", "'id'", ".", "uniqid", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "[", "'options'", "]", ")", "&&", "is_array", "(", "$", "result", "[", "'options'", "]", ")", ")", "{", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "result", "[", "'options'", "]", "as", "$", "option", "=>", "$", "label", ")", "{", "$", "options", "[", "]", "=", "array", "(", "'option'", "=>", "$", "option", ",", "'label'", "=>", "$", "label", ")", ";", "}", "$", "result", "[", "'options'", "]", "=", "$", "options", ";", "}", "return", "$", "result", ";", "}" ]
Returns field definition and value as JSON compatible array @param string $name @return array
[ "Returns", "field", "definition", "and", "value", "as", "JSON", "compatible", "array" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L486-L517
222,089
symlex/input-validation
src/Form.php
Form.isOptional
protected function isOptional(string $name): bool { return ($this->getFieldProperty($name, 'checkbox') == true) || ($this->getFieldProperty($name, 'optional') == true); }
php
protected function isOptional(string $name): bool { return ($this->getFieldProperty($name, 'checkbox') == true) || ($this->getFieldProperty($name, 'optional') == true); }
[ "protected", "function", "isOptional", "(", "string", "$", "name", ")", ":", "bool", "{", "return", "(", "$", "this", "->", "getFieldProperty", "(", "$", "name", ",", "'checkbox'", ")", "==", "true", ")", "||", "(", "$", "this", "->", "getFieldProperty", "(", "$", "name", ",", "'optional'", ")", "==", "true", ")", ";", "}" ]
Returns true, if the field is optional This is a workaround for Web form elements, that do not get submitted, if empty. In general, this applies to non-checked checkboxes or to empty form elements submitted by certain JavaScript frameworks (e.g. AngularJS). @param string $name @return bool
[ "Returns", "true", "if", "the", "field", "is", "optional" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L583-L586
222,090
symlex/input-validation
src/Form.php
Form.setOptionalValueInArray
protected function setOptionalValueInArray(string $name, &$values) { if ($this->isOptional($name) && !array_key_exists($name, $values)) { $default = $this->getFieldProperty($name, 'default'); if (is_null($default)) { $type = $this->getFieldProperty($name, 'type'); switch ($type) { case 'list': $default = array(); break; case 'bool': $default = false; break; } } $values[$name] = $default; } return $this; }
php
protected function setOptionalValueInArray(string $name, &$values) { if ($this->isOptional($name) && !array_key_exists($name, $values)) { $default = $this->getFieldProperty($name, 'default'); if (is_null($default)) { $type = $this->getFieldProperty($name, 'type'); switch ($type) { case 'list': $default = array(); break; case 'bool': $default = false; break; } } $values[$name] = $default; } return $this; }
[ "protected", "function", "setOptionalValueInArray", "(", "string", "$", "name", ",", "&", "$", "values", ")", "{", "if", "(", "$", "this", "->", "isOptional", "(", "$", "name", ")", "&&", "!", "array_key_exists", "(", "$", "name", ",", "$", "values", ")", ")", "{", "$", "default", "=", "$", "this", "->", "getFieldProperty", "(", "$", "name", ",", "'default'", ")", ";", "if", "(", "is_null", "(", "$", "default", ")", ")", "{", "$", "type", "=", "$", "this", "->", "getFieldProperty", "(", "$", "name", ",", "'type'", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'list'", ":", "$", "default", "=", "array", "(", ")", ";", "break", ";", "case", "'bool'", ":", "$", "default", "=", "false", ";", "break", ";", "}", "}", "$", "values", "[", "$", "name", "]", "=", "$", "default", ";", "}", "return", "$", "this", ";", "}" ]
Sets the default types for values of form fields marked as optional @param string $name The field name @param array $values Reference to the array containing all form values @return $this
[ "Sets", "the", "default", "types", "for", "values", "of", "form", "fields", "marked", "as", "optional" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L595-L617
222,091
symlex/input-validation
src/Form.php
Form.setDefinedValues
public function setDefinedValues(array $values) { foreach ($this->_definition as $key => $value) { $this->setOptionalValueInArray($key, $values); if (!array_key_exists($key, $values)) { throw new Exception ('Value is missing for "' . $key . '"'); } $this->$key = $values[$key]; } return $this; }
php
public function setDefinedValues(array $values) { foreach ($this->_definition as $key => $value) { $this->setOptionalValueInArray($key, $values); if (!array_key_exists($key, $values)) { throw new Exception ('Value is missing for "' . $key . '"'); } $this->$key = $values[$key]; } return $this; }
[ "public", "function", "setDefinedValues", "(", "array", "$", "values", ")", "{", "foreach", "(", "$", "this", "->", "_definition", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "setOptionalValueInArray", "(", "$", "key", ",", "$", "values", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "values", ")", ")", "{", "throw", "new", "Exception", "(", "'Value is missing for \"'", ".", "$", "key", ".", "'\"'", ")", ";", "}", "$", "this", "->", "$", "key", "=", "$", "values", "[", "$", "key", "]", ";", "}", "return", "$", "this", ";", "}" ]
Iterates through the form definition and sets the values for fields, that are present in the form definition @param array $values The values (key must be the field name) @throws Exception @return $this
[ "Iterates", "through", "the", "form", "definition", "and", "sets", "the", "values", "for", "fields", "that", "are", "present", "in", "the", "form", "definition" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L642-L655
222,092
symlex/input-validation
src/Form.php
Form.setWritableValues
public function setWritableValues(array $values) { foreach ($values as $key => $value) { if ($this->isWritable($key)) { $this->$key = $value; } } return $this; }
php
public function setWritableValues(array $values) { foreach ($values as $key => $value) { if ($this->isWritable($key)) { $this->$key = $value; } } return $this; }
[ "public", "function", "setWritableValues", "(", "array", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isWritable", "(", "$", "key", ")", ")", "{", "$", "this", "->", "$", "key", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Iterates through the passed value array and sets the values for fields, that are writable by the user @param array $values The values (key must be the field name) @return $this
[ "Iterates", "through", "the", "passed", "value", "array", "and", "sets", "the", "values", "for", "fields", "that", "are", "writable", "by", "the", "user" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L663-L672
222,093
symlex/input-validation
src/Form.php
Form.getValuesByPage
public function getValuesByPage(): array { $result = array(); foreach ($this->_definition as $key => $value) { $page = $this->getFieldProperty($key, 'page'); if ($page) { $result[$page][$key] = $this->$key; } } return $result; }
php
public function getValuesByPage(): array { $result = array(); foreach ($this->_definition as $key => $value) { $page = $this->getFieldProperty($key, 'page'); if ($page) { $result[$page][$key] = $this->$key; } } return $result; }
[ "public", "function", "getValuesByPage", "(", ")", ":", "array", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_definition", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "page", "=", "$", "this", "->", "getFieldProperty", "(", "$", "key", ",", "'page'", ")", ";", "if", "(", "$", "page", ")", "{", "$", "result", "[", "$", "page", "]", "[", "$", "key", "]", "=", "$", "this", "->", "$", "key", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns the form values for all elements grouped by page @return array
[ "Returns", "the", "form", "values", "for", "all", "elements", "grouped", "by", "page" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L731-L744
222,094
symlex/input-validation
src/Form.php
Form.getValuesByTag
public function getValuesByTag(string $tag): array { $result = array(); foreach ($this->_definition as $key => $value) { $tags = $this->getFieldProperty($key, 'tags'); if (is_array($tags) && in_array($tag, $tags)) { $result[$key] = $this->$key; } } return $result; }
php
public function getValuesByTag(string $tag): array { $result = array(); foreach ($this->_definition as $key => $value) { $tags = $this->getFieldProperty($key, 'tags'); if (is_array($tags) && in_array($tag, $tags)) { $result[$key] = $this->$key; } } return $result; }
[ "public", "function", "getValuesByTag", "(", "string", "$", "tag", ")", ":", "array", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_definition", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "tags", "=", "$", "this", "->", "getFieldProperty", "(", "$", "key", ",", "'tags'", ")", ";", "if", "(", "is_array", "(", "$", "tags", ")", "&&", "in_array", "(", "$", "tag", ",", "$", "tags", ")", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "this", "->", "$", "key", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns the form values for all elements by tag @return array
[ "Returns", "the", "form", "values", "for", "all", "elements", "by", "tag" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L751-L764
222,095
symlex/input-validation
src/Form.php
Form.getValues
public function getValues(): array { $result = array(); foreach ($this->_definition as $key => $value) { $result[$key] = $this->$key; } return $result; }
php
public function getValues(): array { $result = array(); foreach ($this->_definition as $key => $value) { $result[$key] = $this->$key; } return $result; }
[ "public", "function", "getValues", "(", ")", ":", "array", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_definition", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "this", "->", "$", "key", ";", "}", "return", "$", "result", ";", "}" ]
Returns all form field values @return array
[ "Returns", "all", "form", "field", "values" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L771-L780
222,096
symlex/input-validation
src/Form.php
Form.getWritableValues
public function getWritableValues(): array { $result = array(); foreach ($this->_definition as $key => $value) { if ($this->isWritable($key)) { $result[$key] = $this->$key; } } return $result; }
php
public function getWritableValues(): array { $result = array(); foreach ($this->_definition as $key => $value) { if ($this->isWritable($key)) { $result[$key] = $this->$key; } } return $result; }
[ "public", "function", "getWritableValues", "(", ")", ":", "array", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_definition", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isWritable", "(", "$", "key", ")", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "this", "->", "$", "key", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns all writable form field values @return array
[ "Returns", "all", "writable", "form", "field", "values" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L787-L798
222,097
symlex/input-validation
src/Form.php
Form.getFieldCaption
public function getFieldCaption(string $name): string { $caption = $this->getFieldProperty($name, 'caption'); if ($caption) { return $this->translate($caption); } return $name; }
php
public function getFieldCaption(string $name): string { $caption = $this->getFieldProperty($name, 'caption'); if ($caption) { return $this->translate($caption); } return $name; }
[ "public", "function", "getFieldCaption", "(", "string", "$", "name", ")", ":", "string", "{", "$", "caption", "=", "$", "this", "->", "getFieldProperty", "(", "$", "name", ",", "'caption'", ")", ";", "if", "(", "$", "caption", ")", "{", "return", "$", "this", "->", "translate", "(", "$", "caption", ")", ";", "}", "return", "$", "name", ";", "}" ]
Returns a translated field caption @param string $name The field name @return string
[ "Returns", "a", "translated", "field", "caption" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L935-L944
222,098
symlex/input-validation
src/Form.php
Form.getFirstError
public function getFirstError(): string { $result = ''; $errors = $this->getErrors(); $firstField = reset($errors); if ($firstField && isset($firstField[0])) { $result = $firstField[0]; } return $result; }
php
public function getFirstError(): string { $result = ''; $errors = $this->getErrors(); $firstField = reset($errors); if ($firstField && isset($firstField[0])) { $result = $firstField[0]; } return $result; }
[ "public", "function", "getFirstError", "(", ")", ":", "string", "{", "$", "result", "=", "''", ";", "$", "errors", "=", "$", "this", "->", "getErrors", "(", ")", ";", "$", "firstField", "=", "reset", "(", "$", "errors", ")", ";", "if", "(", "$", "firstField", "&&", "isset", "(", "$", "firstField", "[", "0", "]", ")", ")", "{", "$", "result", "=", "$", "firstField", "[", "0", "]", ";", "}", "return", "$", "result", ";", "}" ]
Returns the first error as string @return string
[ "Returns", "the", "first", "error", "as", "string" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L1031-L1042
222,099
symlex/input-validation
src/Form.php
Form.getErrorsAsText
public function getErrorsAsText(): string { $result = ''; $fieldCounter = 0; $fields = $this->getErrors(); foreach ($fields as $fieldName => $fieldErrors) { $fieldCounter++; $result .= "$fieldCounter) $fieldName\n"; foreach ($fieldErrors as $error) { $result .= " - $error\n"; } } return $result; }
php
public function getErrorsAsText(): string { $result = ''; $fieldCounter = 0; $fields = $this->getErrors(); foreach ($fields as $fieldName => $fieldErrors) { $fieldCounter++; $result .= "$fieldCounter) $fieldName\n"; foreach ($fieldErrors as $error) { $result .= " - $error\n"; } } return $result; }
[ "public", "function", "getErrorsAsText", "(", ")", ":", "string", "{", "$", "result", "=", "''", ";", "$", "fieldCounter", "=", "0", ";", "$", "fields", "=", "$", "this", "->", "getErrors", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", "=>", "$", "fieldErrors", ")", "{", "$", "fieldCounter", "++", ";", "$", "result", ".=", "\"$fieldCounter) $fieldName\\n\"", ";", "foreach", "(", "$", "fieldErrors", "as", "$", "error", ")", "{", "$", "result", ".=", "\" - $error\\n\"", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns all errors as indented text @return string
[ "Returns", "all", "errors", "as", "indented", "text" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L1049-L1065