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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
romm/configuration_object
Classes/Service/Items/Parents/ParentsTrait.php
ParentsTrait.getFirstParent
public function getFirstParent($parentClassName) { $foundParent = null; $this->alongParents(function ($parent) use ($parentClassName, &$foundParent) { if ($parent instanceof $parentClassName) { $foundParent = $parent; return false; } return true; }); if (null === $foundParent) { throw new EntryNotFoundException( 'The parent "' . $parentClassName . '" was not found in this object (class "' . get_class($this) . '"). Use the function "hasParent()" before your call to this function!', 1471379635 ); } return $foundParent; }
php
public function getFirstParent($parentClassName) { $foundParent = null; $this->alongParents(function ($parent) use ($parentClassName, &$foundParent) { if ($parent instanceof $parentClassName) { $foundParent = $parent; return false; } return true; }); if (null === $foundParent) { throw new EntryNotFoundException( 'The parent "' . $parentClassName . '" was not found in this object (class "' . get_class($this) . '"). Use the function "hasParent()" before your call to this function!', 1471379635 ); } return $foundParent; }
[ "public", "function", "getFirstParent", "(", "$", "parentClassName", ")", "{", "$", "foundParent", "=", "null", ";", "$", "this", "->", "alongParents", "(", "function", "(", "$", "parent", ")", "use", "(", "$", "parentClassName", ",", "&", "$", "foundParent", ")", "{", "if", "(", "$", "parent", "instanceof", "$", "parentClassName", ")", "{", "$", "foundParent", "=", "$", "parent", ";", "return", "false", ";", "}", "return", "true", ";", "}", ")", ";", "if", "(", "null", "===", "$", "foundParent", ")", "{", "throw", "new", "EntryNotFoundException", "(", "'The parent \"'", ".", "$", "parentClassName", ".", "'\" was not found in this object (class \"'", ".", "get_class", "(", "$", "this", ")", ".", "'\"). Use the function \"hasParent()\" before your call to this function!'", ",", "1471379635", ")", ";", "}", "return", "$", "foundParent", ";", "}" ]
Returns the first found instance of the desired parent. An exception is thrown if the parent is not found. It is advised to use the function `hasParent()` before using this function. @param string $parentClassName Name of the parent class. @return object @throws EntryNotFoundException
[ "Returns", "the", "first", "found", "instance", "of", "the", "desired", "parent", "." ]
d3a40903386c2e0766bd8279337fe6da45cf5ce3
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/Items/Parents/ParentsTrait.php#L178-L200
train
zewadesign/framework
Zewa/View.php
View.setView
public function setView($viewName) { $view = $this->pathToView . DIRECTORY_SEPARATOR . strtolower($viewName) . '.php'; if (!file_exists($view)) { throw new Exception\LookupException('View: "' . $view . '" could not be found.'); } $this->viewQueue[$viewName] = $view; }
php
public function setView($viewName) { $view = $this->pathToView . DIRECTORY_SEPARATOR . strtolower($viewName) . '.php'; if (!file_exists($view)) { throw new Exception\LookupException('View: "' . $view . '" could not be found.'); } $this->viewQueue[$viewName] = $view; }
[ "public", "function", "setView", "(", "$", "viewName", ")", "{", "$", "view", "=", "$", "this", "->", "pathToView", ".", "DIRECTORY_SEPARATOR", ".", "strtolower", "(", "$", "viewName", ")", ".", "'.php'", ";", "if", "(", "!", "file_exists", "(", "$", "view", ")", ")", "{", "throw", "new", "Exception", "\\", "LookupException", "(", "'View: \"'", ".", "$", "view", ".", "'\" could not be found.'", ")", ";", "}", "$", "this", "->", "viewQueue", "[", "$", "viewName", "]", "=", "$", "view", ";", "}" ]
formats and prepares view for inclusion @param $viewName @return string @throws Exception\LookupException
[ "formats", "and", "prepares", "view", "for", "inclusion" ]
be74e41c674ac2c2ef924752ed310cfbaafe33b8
https://github.com/zewadesign/framework/blob/be74e41c674ac2c2ef924752ed310cfbaafe33b8/Zewa/View.php#L125-L134
train
zewadesign/framework
Zewa/View.php
View.fetchCSS
public function fetchCSS() { $string = ""; if (empty($this->queuedCSS)) { return $string; } foreach ($this->queuedCSS as $sheet) { $string .= '<link rel="stylesheet" href="' . $sheet .'">' . "\r\n"; } return $string; }
php
public function fetchCSS() { $string = ""; if (empty($this->queuedCSS)) { return $string; } foreach ($this->queuedCSS as $sheet) { $string .= '<link rel="stylesheet" href="' . $sheet .'">' . "\r\n"; } return $string; }
[ "public", "function", "fetchCSS", "(", ")", "{", "$", "string", "=", "\"\"", ";", "if", "(", "empty", "(", "$", "this", "->", "queuedCSS", ")", ")", "{", "return", "$", "string", ";", "}", "foreach", "(", "$", "this", "->", "queuedCSS", "as", "$", "sheet", ")", "{", "$", "string", ".=", "'<link rel=\"stylesheet\" href=\"'", ".", "$", "sheet", ".", "'\">'", ".", "\"\\r\\n\"", ";", "}", "return", "$", "string", ";", "}" ]
Helper method for grabbing aggregated css files @access protected @return string css includes
[ "Helper", "method", "for", "grabbing", "aggregated", "css", "files" ]
be74e41c674ac2c2ef924752ed310cfbaafe33b8
https://github.com/zewadesign/framework/blob/be74e41c674ac2c2ef924752ed310cfbaafe33b8/Zewa/View.php#L249-L262
train
zewadesign/framework
Zewa/View.php
View.fetchJS
public function fetchJS() { $string = "<script>baseURL = '" . $this->router->baseURL() . "/'</script>\r\n"; if (empty($this->queuedJS)) { return $string; } foreach ($this->queuedJS as $script) { $string .= '<script src="' . $script . '"></script>' . "\r\n"; } return $string; }
php
public function fetchJS() { $string = "<script>baseURL = '" . $this->router->baseURL() . "/'</script>\r\n"; if (empty($this->queuedJS)) { return $string; } foreach ($this->queuedJS as $script) { $string .= '<script src="' . $script . '"></script>' . "\r\n"; } return $string; }
[ "public", "function", "fetchJS", "(", ")", "{", "$", "string", "=", "\"<script>baseURL = '\"", ".", "$", "this", "->", "router", "->", "baseURL", "(", ")", ".", "\"/'</script>\\r\\n\"", ";", "if", "(", "empty", "(", "$", "this", "->", "queuedJS", ")", ")", "{", "return", "$", "string", ";", "}", "foreach", "(", "$", "this", "->", "queuedJS", "as", "$", "script", ")", "{", "$", "string", ".=", "'<script src=\"'", ".", "$", "script", ".", "'\"></script>'", ".", "\"\\r\\n\"", ";", "}", "return", "$", "string", ";", "}" ]
Helper method for grabbing aggregated JS files @access protected @return string JS includes
[ "Helper", "method", "for", "grabbing", "aggregated", "JS", "files" ]
be74e41c674ac2c2ef924752ed310cfbaafe33b8
https://github.com/zewadesign/framework/blob/be74e41c674ac2c2ef924752ed310cfbaafe33b8/Zewa/View.php#L270-L283
train
phpguard/listen
src/PhpGuard/Listen/Resource/FileResource.php
FileResource.isExists
public function isExists() { clearstatcache(true,(string)$this->resource); return is_file((string)$this->resource); }
php
public function isExists() { clearstatcache(true,(string)$this->resource); return is_file((string)$this->resource); }
[ "public", "function", "isExists", "(", ")", "{", "clearstatcache", "(", "true", ",", "(", "string", ")", "$", "this", "->", "resource", ")", ";", "return", "is_file", "(", "(", "string", ")", "$", "this", "->", "resource", ")", ";", "}" ]
Returns true if the resource exists in the filesystem. @return Boolean
[ "Returns", "true", "if", "the", "resource", "exists", "in", "the", "filesystem", "." ]
cd0cda150858d6d85deb025a72996873d2af3532
https://github.com/phpguard/listen/blob/cd0cda150858d6d85deb025a72996873d2af3532/src/PhpGuard/Listen/Resource/FileResource.php#L52-L56
train
Mandarin-Medien/MMCmfContentBundle
Controller/ContentNodeController.php
ContentNodeController.saveAction
public function saveAction(Request $request) { $json_nodes = $request->get('nodes'); if ($json_nodes) { $this->em = $this->getDoctrine()->getManager(); foreach ($json_nodes as $id => $obj) { $contentNode = $this->em->find(ContentNode::class, $id); if ($contentNode) { $className = $obj['class']; unset($obj['class']); $metaData = $this->getClassMetaData($className); foreach ($obj as $key => $value) { $method = 'set' . ucfirst($key); if (method_exists($contentNode, $method)) { if (!empty($metaData->associationMappings[$key])) { $fieldMetaData = $metaData->associationMappings[$key]; $repo = $this->em->getRepository($fieldMetaData['targetEntity']); //check if its just a standard relation if ( in_array( $fieldMetaData['type'], array( ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY ) ) ) $value = $repo->findById($value); else $value = $repo->findOneById($value); } $contentNode->$method($value); } } $this->em->persist($contentNode); } } $this->em->flush(); return new JsonResponse(array('status' => 'saved')); } else { return new JsonResponse(array('status' => 'failed', 'msg' => 'Nothing to update.')); } }
php
public function saveAction(Request $request) { $json_nodes = $request->get('nodes'); if ($json_nodes) { $this->em = $this->getDoctrine()->getManager(); foreach ($json_nodes as $id => $obj) { $contentNode = $this->em->find(ContentNode::class, $id); if ($contentNode) { $className = $obj['class']; unset($obj['class']); $metaData = $this->getClassMetaData($className); foreach ($obj as $key => $value) { $method = 'set' . ucfirst($key); if (method_exists($contentNode, $method)) { if (!empty($metaData->associationMappings[$key])) { $fieldMetaData = $metaData->associationMappings[$key]; $repo = $this->em->getRepository($fieldMetaData['targetEntity']); //check if its just a standard relation if ( in_array( $fieldMetaData['type'], array( ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY ) ) ) $value = $repo->findById($value); else $value = $repo->findOneById($value); } $contentNode->$method($value); } } $this->em->persist($contentNode); } } $this->em->flush(); return new JsonResponse(array('status' => 'saved')); } else { return new JsonResponse(array('status' => 'failed', 'msg' => 'Nothing to update.')); } }
[ "public", "function", "saveAction", "(", "Request", "$", "request", ")", "{", "$", "json_nodes", "=", "$", "request", "->", "get", "(", "'nodes'", ")", ";", "if", "(", "$", "json_nodes", ")", "{", "$", "this", "->", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "foreach", "(", "$", "json_nodes", "as", "$", "id", "=>", "$", "obj", ")", "{", "$", "contentNode", "=", "$", "this", "->", "em", "->", "find", "(", "ContentNode", "::", "class", ",", "$", "id", ")", ";", "if", "(", "$", "contentNode", ")", "{", "$", "className", "=", "$", "obj", "[", "'class'", "]", ";", "unset", "(", "$", "obj", "[", "'class'", "]", ")", ";", "$", "metaData", "=", "$", "this", "->", "getClassMetaData", "(", "$", "className", ")", ";", "foreach", "(", "$", "obj", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "method", "=", "'set'", ".", "ucfirst", "(", "$", "key", ")", ";", "if", "(", "method_exists", "(", "$", "contentNode", ",", "$", "method", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "metaData", "->", "associationMappings", "[", "$", "key", "]", ")", ")", "{", "$", "fieldMetaData", "=", "$", "metaData", "->", "associationMappings", "[", "$", "key", "]", ";", "$", "repo", "=", "$", "this", "->", "em", "->", "getRepository", "(", "$", "fieldMetaData", "[", "'targetEntity'", "]", ")", ";", "//check if its just a standard relation", "if", "(", "in_array", "(", "$", "fieldMetaData", "[", "'type'", "]", ",", "array", "(", "ClassMetadataInfo", "::", "ONE_TO_MANY", ",", "ClassMetadataInfo", "::", "MANY_TO_MANY", ")", ")", ")", "$", "value", "=", "$", "repo", "->", "findById", "(", "$", "value", ")", ";", "else", "$", "value", "=", "$", "repo", "->", "findOneById", "(", "$", "value", ")", ";", "}", "$", "contentNode", "->", "$", "method", "(", "$", "value", ")", ";", "}", "}", "$", "this", "->", "em", "->", "persist", "(", "$", "contentNode", ")", ";", "}", "}", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'saved'", ")", ")", ";", "}", "else", "{", "return", "new", "JsonResponse", "(", "array", "(", "'status'", "=>", "'failed'", ",", "'msg'", "=>", "'Nothing to update.'", ")", ")", ";", "}", "}" ]
AJAX save endpoint, not related to the CRUD @param Request $request @return JsonResponse
[ "AJAX", "save", "endpoint", "not", "related", "to", "the", "CRUD" ]
503ab31cef3ce068f767de5b72f833526355b726
https://github.com/Mandarin-Medien/MMCmfContentBundle/blob/503ab31cef3ce068f767de5b72f833526355b726/Controller/ContentNodeController.php#L35-L96
train
Mandarin-Medien/MMCmfContentBundle
Controller/ContentNodeController.php
ContentNodeController.simpleUpdateAction
public function simpleUpdateAction(Request $request, ContentNode $contentNode) { return $this->updateAction($request, $contentNode, true); }
php
public function simpleUpdateAction(Request $request, ContentNode $contentNode) { return $this->updateAction($request, $contentNode, true); }
[ "public", "function", "simpleUpdateAction", "(", "Request", "$", "request", ",", "ContentNode", "$", "contentNode", ")", "{", "return", "$", "this", "->", "updateAction", "(", "$", "request", ",", "$", "contentNode", ",", "true", ")", ";", "}" ]
validates the simple ContentNode Form @param Request $request @param ContentNode $contentNode @return JsonResponse
[ "validates", "the", "simple", "ContentNode", "Form" ]
503ab31cef3ce068f767de5b72f833526355b726
https://github.com/Mandarin-Medien/MMCmfContentBundle/blob/503ab31cef3ce068f767de5b72f833526355b726/Controller/ContentNodeController.php#L191-L194
train
Mandarin-Medien/MMCmfContentBundle
Controller/ContentNodeController.php
ContentNodeController.updateAction
public function updateAction(Request $request, ContentNode $contentNode, $isSimpleForm = false) { $em = $this->getDoctrine()->getManager(); $repository = $this->getDoctrine()->getRepository('MMCmfNodeBundle:Node'); $rootNode = null; if ((int)$request->get('root_node')) { $rootNode = $repository->find((int)$request->get('root_node')); } //check if node need "simple" validation if ($isSimpleForm) $editForm = $this->createSimpleEditForm($contentNode, $rootNode); else $editForm = $this->createEditForm($contentNode, $rootNode); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); $markup = $this->get('mm_cmf_content.mm_cmf_parse_twig_extension')->cmfParse( $this->get('twig'), $contentNode ); return new JsonResponse(array( 'success' => true, 'data' => array( 'id' => $contentNode->getId(), 'markup' => $markup )) ); } return new JsonResponse(array('success' => false)); }
php
public function updateAction(Request $request, ContentNode $contentNode, $isSimpleForm = false) { $em = $this->getDoctrine()->getManager(); $repository = $this->getDoctrine()->getRepository('MMCmfNodeBundle:Node'); $rootNode = null; if ((int)$request->get('root_node')) { $rootNode = $repository->find((int)$request->get('root_node')); } //check if node need "simple" validation if ($isSimpleForm) $editForm = $this->createSimpleEditForm($contentNode, $rootNode); else $editForm = $this->createEditForm($contentNode, $rootNode); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); $markup = $this->get('mm_cmf_content.mm_cmf_parse_twig_extension')->cmfParse( $this->get('twig'), $contentNode ); return new JsonResponse(array( 'success' => true, 'data' => array( 'id' => $contentNode->getId(), 'markup' => $markup )) ); } return new JsonResponse(array('success' => false)); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ",", "ContentNode", "$", "contentNode", ",", "$", "isSimpleForm", "=", "false", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "repository", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'MMCmfNodeBundle:Node'", ")", ";", "$", "rootNode", "=", "null", ";", "if", "(", "(", "int", ")", "$", "request", "->", "get", "(", "'root_node'", ")", ")", "{", "$", "rootNode", "=", "$", "repository", "->", "find", "(", "(", "int", ")", "$", "request", "->", "get", "(", "'root_node'", ")", ")", ";", "}", "//check if node need \"simple\" validation", "if", "(", "$", "isSimpleForm", ")", "$", "editForm", "=", "$", "this", "->", "createSimpleEditForm", "(", "$", "contentNode", ",", "$", "rootNode", ")", ";", "else", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "contentNode", ",", "$", "rootNode", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "flush", "(", ")", ";", "$", "markup", "=", "$", "this", "->", "get", "(", "'mm_cmf_content.mm_cmf_parse_twig_extension'", ")", "->", "cmfParse", "(", "$", "this", "->", "get", "(", "'twig'", ")", ",", "$", "contentNode", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'success'", "=>", "true", ",", "'data'", "=>", "array", "(", "'id'", "=>", "$", "contentNode", "->", "getId", "(", ")", ",", "'markup'", "=>", "$", "markup", ")", ")", ")", ";", "}", "return", "new", "JsonResponse", "(", "array", "(", "'success'", "=>", "false", ")", ")", ";", "}" ]
validates the general ContentNode Form @param Request $request @param ContentNode $contentNode @param bool $isSimpleForm @return JsonResponse
[ "validates", "the", "general", "ContentNode", "Form" ]
503ab31cef3ce068f767de5b72f833526355b726
https://github.com/Mandarin-Medien/MMCmfContentBundle/blob/503ab31cef3ce068f767de5b72f833526355b726/Controller/ContentNodeController.php#L362-L398
train
Mandarin-Medien/MMCmfContentBundle
Controller/ContentNodeController.php
ContentNodeController.createSimpleEditForm
public function createSimpleEditForm(ContentNode $contentNode, Node $rootNode = null) { $contentNodeClassName = get_class($contentNode); $contentNodeParser = $this->get('mm_cmf_content.content_parser'); $simpleFormData = $contentNodeParser->getSimpleForm($contentNodeClassName); //set FormType if (isset($simpleFormData['type']) && class_exists($simpleFormData['type'])) { $simpleFormType = $simpleFormData['type']; } else $simpleFormType = ContentNodeType::class; //get fields to hide $hiddenFields = $contentNodeParser->getHiddenFields($contentNodeClassName); $templateVars = array( 'hiddenFields' => $hiddenFields, 'action' => $this->get('router')->generate('mm_cmf_content_node_simple_update', array( 'id' => $contentNode->getId() )) ); if ($rootNode) $templateVars['root_node'] = $rootNode; return $this->createForm( $simpleFormType, $contentNode, $templateVars ); }
php
public function createSimpleEditForm(ContentNode $contentNode, Node $rootNode = null) { $contentNodeClassName = get_class($contentNode); $contentNodeParser = $this->get('mm_cmf_content.content_parser'); $simpleFormData = $contentNodeParser->getSimpleForm($contentNodeClassName); //set FormType if (isset($simpleFormData['type']) && class_exists($simpleFormData['type'])) { $simpleFormType = $simpleFormData['type']; } else $simpleFormType = ContentNodeType::class; //get fields to hide $hiddenFields = $contentNodeParser->getHiddenFields($contentNodeClassName); $templateVars = array( 'hiddenFields' => $hiddenFields, 'action' => $this->get('router')->generate('mm_cmf_content_node_simple_update', array( 'id' => $contentNode->getId() )) ); if ($rootNode) $templateVars['root_node'] = $rootNode; return $this->createForm( $simpleFormType, $contentNode, $templateVars ); }
[ "public", "function", "createSimpleEditForm", "(", "ContentNode", "$", "contentNode", ",", "Node", "$", "rootNode", "=", "null", ")", "{", "$", "contentNodeClassName", "=", "get_class", "(", "$", "contentNode", ")", ";", "$", "contentNodeParser", "=", "$", "this", "->", "get", "(", "'mm_cmf_content.content_parser'", ")", ";", "$", "simpleFormData", "=", "$", "contentNodeParser", "->", "getSimpleForm", "(", "$", "contentNodeClassName", ")", ";", "//set FormType", "if", "(", "isset", "(", "$", "simpleFormData", "[", "'type'", "]", ")", "&&", "class_exists", "(", "$", "simpleFormData", "[", "'type'", "]", ")", ")", "{", "$", "simpleFormType", "=", "$", "simpleFormData", "[", "'type'", "]", ";", "}", "else", "$", "simpleFormType", "=", "ContentNodeType", "::", "class", ";", "//get fields to hide", "$", "hiddenFields", "=", "$", "contentNodeParser", "->", "getHiddenFields", "(", "$", "contentNodeClassName", ")", ";", "$", "templateVars", "=", "array", "(", "'hiddenFields'", "=>", "$", "hiddenFields", ",", "'action'", "=>", "$", "this", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'mm_cmf_content_node_simple_update'", ",", "array", "(", "'id'", "=>", "$", "contentNode", "->", "getId", "(", ")", ")", ")", ")", ";", "if", "(", "$", "rootNode", ")", "$", "templateVars", "[", "'root_node'", "]", "=", "$", "rootNode", ";", "return", "$", "this", "->", "createForm", "(", "$", "simpleFormType", ",", "$", "contentNode", ",", "$", "templateVars", ")", ";", "}" ]
Returns the configured Simple Form for Frontend Editing purpose @param ContentNode $contentNode @param Node|null $rootNode @return \Symfony\Component\Form\Form
[ "Returns", "the", "configured", "Simple", "Form", "for", "Frontend", "Editing", "purpose" ]
503ab31cef3ce068f767de5b72f833526355b726
https://github.com/Mandarin-Medien/MMCmfContentBundle/blob/503ab31cef3ce068f767de5b72f833526355b726/Controller/ContentNodeController.php#L407-L439
train
LpFactory/NestedSetRoutingBundle
Factory/PageRouteFactory.php
PageRouteFactory.createFromId
public function createFromId(AbstractPageRouteConfiguration $routeConfiguration, $pageId) { $page = $this->repository->find($pageId); return $this->create($routeConfiguration, $page); }
php
public function createFromId(AbstractPageRouteConfiguration $routeConfiguration, $pageId) { $page = $this->repository->find($pageId); return $this->create($routeConfiguration, $page); }
[ "public", "function", "createFromId", "(", "AbstractPageRouteConfiguration", "$", "routeConfiguration", ",", "$", "pageId", ")", "{", "$", "page", "=", "$", "this", "->", "repository", "->", "find", "(", "$", "pageId", ")", ";", "return", "$", "this", "->", "create", "(", "$", "routeConfiguration", ",", "$", "page", ")", ";", "}" ]
Create a new route instance from a page id @param AbstractPageRouteConfiguration $routeConfiguration @param int $pageId @return \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route
[ "Create", "a", "new", "route", "instance", "from", "a", "page", "id" ]
dc07227a6764e657b7b321827a18127ec18ba214
https://github.com/LpFactory/NestedSetRoutingBundle/blob/dc07227a6764e657b7b321827a18127ec18ba214/Factory/PageRouteFactory.php#L80-L85
train
LpFactory/NestedSetRoutingBundle
Factory/PageRouteFactory.php
PageRouteFactory.buildUrlFromPath
protected function buildUrlFromPath(array $path) { // Remove root level (homepage) array_shift($path); // Homepage if (count($path) === 0 && $this->treeStrategy->isHomeTreeRoot()) { return '/'; } // Build uri from tree path return array_reduce($path, function ($carry, NestedSetRoutingPageInterface $item) { $carry .= '/' . $item->getSlug(); return $carry; }); }
php
protected function buildUrlFromPath(array $path) { // Remove root level (homepage) array_shift($path); // Homepage if (count($path) === 0 && $this->treeStrategy->isHomeTreeRoot()) { return '/'; } // Build uri from tree path return array_reduce($path, function ($carry, NestedSetRoutingPageInterface $item) { $carry .= '/' . $item->getSlug(); return $carry; }); }
[ "protected", "function", "buildUrlFromPath", "(", "array", "$", "path", ")", "{", "// Remove root level (homepage)", "array_shift", "(", "$", "path", ")", ";", "// Homepage", "if", "(", "count", "(", "$", "path", ")", "===", "0", "&&", "$", "this", "->", "treeStrategy", "->", "isHomeTreeRoot", "(", ")", ")", "{", "return", "'/'", ";", "}", "// Build uri from tree path", "return", "array_reduce", "(", "$", "path", ",", "function", "(", "$", "carry", ",", "NestedSetRoutingPageInterface", "$", "item", ")", "{", "$", "carry", ".=", "'/'", ".", "$", "item", "->", "getSlug", "(", ")", ";", "return", "$", "carry", ";", "}", ")", ";", "}" ]
Build an url from a path @param array $path @return string
[ "Build", "an", "url", "from", "a", "path" ]
dc07227a6764e657b7b321827a18127ec18ba214
https://github.com/LpFactory/NestedSetRoutingBundle/blob/dc07227a6764e657b7b321827a18127ec18ba214/Factory/PageRouteFactory.php#L94-L109
train
intrip/laravel-library
src/Jacopo/Library/Form/FormModel.php
FormModel.process
public function process(array $input) { if($this->v->validate($input)) { Event::fire("form.processing", array($input)); return $this->callRepository($input); } else { $this->errors = $this->v->getErrors(); throw new ValidationException; } }
php
public function process(array $input) { if($this->v->validate($input)) { Event::fire("form.processing", array($input)); return $this->callRepository($input); } else { $this->errors = $this->v->getErrors(); throw new ValidationException; } }
[ "public", "function", "process", "(", "array", "$", "input", ")", "{", "if", "(", "$", "this", "->", "v", "->", "validate", "(", "$", "input", ")", ")", "{", "Event", "::", "fire", "(", "\"form.processing\"", ",", "array", "(", "$", "input", ")", ")", ";", "return", "$", "this", "->", "callRepository", "(", "$", "input", ")", ";", "}", "else", "{", "$", "this", "->", "errors", "=", "$", "this", "->", "v", "->", "getErrors", "(", ")", ";", "throw", "new", "ValidationException", ";", "}", "}" ]
Process the input and calls the repository @param array $input @throws \Jacopo\Library\Exceptions\JacopoExceptionsInterface
[ "Process", "the", "input", "and", "calls", "the", "repository" ]
9ea7d5cd9d84c70893238af6300b24c7dd4b8ca3
https://github.com/intrip/laravel-library/blob/9ea7d5cd9d84c70893238af6300b24c7dd4b8ca3/src/Jacopo/Library/Form/FormModel.php#L51-L63
train
intrip/laravel-library
src/Jacopo/Library/Form/FormModel.php
FormModel.isUpdate
protected function isUpdate($input) { return (isset($input[$this->id_field_name]) && ! empty($input[$this->id_field_name]) ); }
php
protected function isUpdate($input) { return (isset($input[$this->id_field_name]) && ! empty($input[$this->id_field_name]) ); }
[ "protected", "function", "isUpdate", "(", "$", "input", ")", "{", "return", "(", "isset", "(", "$", "input", "[", "$", "this", "->", "id_field_name", "]", ")", "&&", "!", "empty", "(", "$", "input", "[", "$", "this", "->", "id_field_name", "]", ")", ")", ";", "}" ]
Check if the operation is update or create @param $input @return booelan $update update=true create=false
[ "Check", "if", "the", "operation", "is", "update", "or", "create" ]
9ea7d5cd9d84c70893238af6300b24c7dd4b8ca3
https://github.com/intrip/laravel-library/blob/9ea7d5cd9d84c70893238af6300b24c7dd4b8ca3/src/Jacopo/Library/Form/FormModel.php#L110-L113
train
intrip/laravel-library
src/Jacopo/Library/Form/FormModel.php
FormModel.delete
public function delete(array $input) { if(isset($input[$this->id_field_name]) && ! empty($input[$this->id_field_name])) { try { $this->r->delete($input[$this->id_field_name]); } catch(ModelNotFoundException $e) { $this->errors = new MessageBag(array("model" => "Element does not exists.")); throw new NotFoundException(); } catch(PermissionException $e) { $this->errors = new MessageBag(array("model" => "Cannot delete this item, please check that the item is not already associated to any other element, in that case remove the association first.")); throw new PermissionException(); } } else { $this->errors = new MessageBag(array("model" => "Id not given")); throw new NotFoundException(); } }
php
public function delete(array $input) { if(isset($input[$this->id_field_name]) && ! empty($input[$this->id_field_name])) { try { $this->r->delete($input[$this->id_field_name]); } catch(ModelNotFoundException $e) { $this->errors = new MessageBag(array("model" => "Element does not exists.")); throw new NotFoundException(); } catch(PermissionException $e) { $this->errors = new MessageBag(array("model" => "Cannot delete this item, please check that the item is not already associated to any other element, in that case remove the association first.")); throw new PermissionException(); } } else { $this->errors = new MessageBag(array("model" => "Id not given")); throw new NotFoundException(); } }
[ "public", "function", "delete", "(", "array", "$", "input", ")", "{", "if", "(", "isset", "(", "$", "input", "[", "$", "this", "->", "id_field_name", "]", ")", "&&", "!", "empty", "(", "$", "input", "[", "$", "this", "->", "id_field_name", "]", ")", ")", "{", "try", "{", "$", "this", "->", "r", "->", "delete", "(", "$", "input", "[", "$", "this", "->", "id_field_name", "]", ")", ";", "}", "catch", "(", "ModelNotFoundException", "$", "e", ")", "{", "$", "this", "->", "errors", "=", "new", "MessageBag", "(", "array", "(", "\"model\"", "=>", "\"Element does not exists.\"", ")", ")", ";", "throw", "new", "NotFoundException", "(", ")", ";", "}", "catch", "(", "PermissionException", "$", "e", ")", "{", "$", "this", "->", "errors", "=", "new", "MessageBag", "(", "array", "(", "\"model\"", "=>", "\"Cannot delete this item, please check that the item is not already associated to any other element, in that case remove the association first.\"", ")", ")", ";", "throw", "new", "PermissionException", "(", ")", ";", "}", "}", "else", "{", "$", "this", "->", "errors", "=", "new", "MessageBag", "(", "array", "(", "\"model\"", "=>", "\"Id not given\"", ")", ")", ";", "throw", "new", "NotFoundException", "(", ")", ";", "}", "}" ]
Run delete on the repository @param $input @throws \Jacopo\Library\Exceptions\NotFoundException @todo test with exceptions
[ "Run", "delete", "on", "the", "repository" ]
9ea7d5cd9d84c70893238af6300b24c7dd4b8ca3
https://github.com/intrip/laravel-library/blob/9ea7d5cd9d84c70893238af6300b24c7dd4b8ca3/src/Jacopo/Library/Form/FormModel.php#L121-L145
train
bseddon/XPath20
AST/ForNode.php
ForNode.getQNVarName
public function getQNVarName() { return \lyquidity\xml\qname( $this->_varName->ToString(), $this->getContext()->NamespaceManager->getNamespaces(), true ); }
php
public function getQNVarName() { return \lyquidity\xml\qname( $this->_varName->ToString(), $this->getContext()->NamespaceManager->getNamespaces(), true ); }
[ "public", "function", "getQNVarName", "(", ")", "{", "return", "\\", "lyquidity", "\\", "xml", "\\", "qname", "(", "$", "this", "->", "_varName", "->", "ToString", "(", ")", ",", "$", "this", "->", "getContext", "(", ")", "->", "NamespaceManager", "->", "getNamespaces", "(", ")", ",", "true", ")", ";", "}" ]
Get the VarName as a QName
[ "Get", "the", "VarName", "as", "a", "QName" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/AST/ForNode.php#L89-L92
train
Vectrex/vxPHP
src/Http/JsonResponse.php
JsonResponse.setCallback
public function setCallback($callback = NULL) { if (NULL !== $callback) { // taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/ $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u'; foreach (explode('.', $callback) as $part) { if (!preg_match($pattern, $part)) { throw new \InvalidArgumentException(sprintf("The callback name '%s' is not valid.", $part)); } } } $this->callback = $callback; return $this->update(); }
php
public function setCallback($callback = NULL) { if (NULL !== $callback) { // taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/ $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u'; foreach (explode('.', $callback) as $part) { if (!preg_match($pattern, $part)) { throw new \InvalidArgumentException(sprintf("The callback name '%s' is not valid.", $part)); } } } $this->callback = $callback; return $this->update(); }
[ "public", "function", "setCallback", "(", "$", "callback", "=", "NULL", ")", "{", "if", "(", "NULL", "!==", "$", "callback", ")", "{", "// taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/", "$", "pattern", "=", "'/^[$_\\p{L}][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*+$/u'", ";", "foreach", "(", "explode", "(", "'.'", ",", "$", "callback", ")", "as", "$", "part", ")", "{", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "part", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"The callback name '%s' is not valid.\"", ",", "$", "part", ")", ")", ";", "}", "}", "}", "$", "this", "->", "callback", "=", "$", "callback", ";", "return", "$", "this", "->", "update", "(", ")", ";", "}" ]
set the JSONP callback pass NULL for not using a callback @param string|null $callback @return JsonResponse @throws \InvalidArgumentException when callback name is not valid
[ "set", "the", "JSONP", "callback", "pass", "NULL", "for", "not", "using", "a", "callback" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/JsonResponse.php#L72-L90
train
Vectrex/vxPHP
src/Http/JsonResponse.php
JsonResponse.setEncodingOptions
public function setEncodingOptions($encodingOptions) { $this->encodingOptions = (int) $encodingOptions; return $this->setPayload(json_decode($this->data)); }
php
public function setEncodingOptions($encodingOptions) { $this->encodingOptions = (int) $encodingOptions; return $this->setPayload(json_decode($this->data)); }
[ "public", "function", "setEncodingOptions", "(", "$", "encodingOptions", ")", "{", "$", "this", "->", "encodingOptions", "=", "(", "int", ")", "$", "encodingOptions", ";", "return", "$", "this", "->", "setPayload", "(", "json_decode", "(", "$", "this", "->", "data", ")", ")", ";", "}" ]
set options used while encoding data to JSON re-encodes payload with new encoding setting @param int $encodingOptions @return JsonResponse @throws \Exception
[ "set", "options", "used", "while", "encoding", "data", "to", "JSON", "re", "-", "encodes", "payload", "with", "new", "encoding", "setting" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/JsonResponse.php#L144-L150
train
Vectrex/vxPHP
src/Http/JsonResponse.php
JsonResponse.update
protected function update() { if(!is_null($this->callback)) { // Not using application/javascript for compatibility reasons with older browsers. $this->headers->set('Content-Type', 'text/javascript'); return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data)); } // set header only when there is none or when it equals 'text/javascript' (from a previous update with callback) // in order to not overwrite a custom definition if(!$this->headers->has('Content-Type') || $this->headers->get('Content-Type') === 'text/javascript') { $this->headers->set('Content-Type', 'application/json'); } return $this->setContent($this->data); }
php
protected function update() { if(!is_null($this->callback)) { // Not using application/javascript for compatibility reasons with older browsers. $this->headers->set('Content-Type', 'text/javascript'); return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data)); } // set header only when there is none or when it equals 'text/javascript' (from a previous update with callback) // in order to not overwrite a custom definition if(!$this->headers->has('Content-Type') || $this->headers->get('Content-Type') === 'text/javascript') { $this->headers->set('Content-Type', 'application/json'); } return $this->setContent($this->data); }
[ "protected", "function", "update", "(", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "callback", ")", ")", "{", "// Not using application/javascript for compatibility reasons with older browsers.", "$", "this", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'text/javascript'", ")", ";", "return", "$", "this", "->", "setContent", "(", "sprintf", "(", "'/**/%s(%s);'", ",", "$", "this", "->", "callback", ",", "$", "this", "->", "data", ")", ")", ";", "}", "// set header only when there is none or when it equals 'text/javascript' (from a previous update with callback)", "// in order to not overwrite a custom definition", "if", "(", "!", "$", "this", "->", "headers", "->", "has", "(", "'Content-Type'", ")", "||", "$", "this", "->", "headers", "->", "get", "(", "'Content-Type'", ")", "===", "'text/javascript'", ")", "{", "$", "this", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "}", "return", "$", "this", "->", "setContent", "(", "$", "this", "->", "data", ")", ";", "}" ]
update content and headers according to the JSON data and a set callback @return JsonResponse
[ "update", "content", "and", "headers", "according", "to", "the", "JSON", "data", "and", "a", "set", "callback" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/JsonResponse.php#L157-L177
train
anime-db/catalog-bundle
src/Plugin/Fill/Refiller/Chain.php
Chain.getPluginsThatCanFillItem
public function getPluginsThatCanFillItem(Item $item, $field) { $plugins = []; /* @var $plugin Refiller */ foreach ($this->plugins as $plugin) { if ($plugin->isCanRefill($item, $field) || $plugin->isCanSearch($item, $field)) { $plugins[] = $plugin; } } return $plugins; }
php
public function getPluginsThatCanFillItem(Item $item, $field) { $plugins = []; /* @var $plugin Refiller */ foreach ($this->plugins as $plugin) { if ($plugin->isCanRefill($item, $field) || $plugin->isCanSearch($item, $field)) { $plugins[] = $plugin; } } return $plugins; }
[ "public", "function", "getPluginsThatCanFillItem", "(", "Item", "$", "item", ",", "$", "field", ")", "{", "$", "plugins", "=", "[", "]", ";", "/* @var $plugin Refiller */", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "$", "plugin", "->", "isCanRefill", "(", "$", "item", ",", "$", "field", ")", "||", "$", "plugin", "->", "isCanSearch", "(", "$", "item", ",", "$", "field", ")", ")", "{", "$", "plugins", "[", "]", "=", "$", "plugin", ";", "}", "}", "return", "$", "plugins", ";", "}" ]
Get list of plugins that can fill item. @param Item $item @param string $field @return RefillerInterface[]
[ "Get", "list", "of", "plugins", "that", "can", "fill", "item", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Plugin/Fill/Refiller/Chain.php#L30-L41
train
iron-bound-designs/IronBound-WPEvents
src/EventDispatcher.php
EventDispatcher.add_listener
public function add_listener( $event_name, $listener, $priority = self::PRIORITY, $accepted_args = self::ACCEPTED ) { if ( ! is_callable( $listener, true ) ) { throw new InvalidListenerException( '$listener must be callable.' ); } if ( ! is_int( $priority ) ) { throw new \InvalidArgumentException( '$priority must be an int.' ); } if ( ! is_int( $accepted_args ) ) { throw new \InvalidArgumentException( '$accepted must be an int.' ); } add_filter( $this->get_action_name_for_event( $event_name ), $listener, $priority, $accepted_args ); return $this; }
php
public function add_listener( $event_name, $listener, $priority = self::PRIORITY, $accepted_args = self::ACCEPTED ) { if ( ! is_callable( $listener, true ) ) { throw new InvalidListenerException( '$listener must be callable.' ); } if ( ! is_int( $priority ) ) { throw new \InvalidArgumentException( '$priority must be an int.' ); } if ( ! is_int( $accepted_args ) ) { throw new \InvalidArgumentException( '$accepted must be an int.' ); } add_filter( $this->get_action_name_for_event( $event_name ), $listener, $priority, $accepted_args ); return $this; }
[ "public", "function", "add_listener", "(", "$", "event_name", ",", "$", "listener", ",", "$", "priority", "=", "self", "::", "PRIORITY", ",", "$", "accepted_args", "=", "self", "::", "ACCEPTED", ")", "{", "if", "(", "!", "is_callable", "(", "$", "listener", ",", "true", ")", ")", "{", "throw", "new", "InvalidListenerException", "(", "'$listener must be callable.'", ")", ";", "}", "if", "(", "!", "is_int", "(", "$", "priority", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$priority must be an int.'", ")", ";", "}", "if", "(", "!", "is_int", "(", "$", "accepted_args", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$accepted must be an int.'", ")", ";", "}", "add_filter", "(", "$", "this", "->", "get_action_name_for_event", "(", "$", "event_name", ")", ",", "$", "listener", ",", "$", "priority", ",", "$", "accepted_args", ")", ";", "return", "$", "this", ";", "}" ]
Add an event listener that listens for a given event. @since 1.0 @param string $event_name The fully-qualified event name to listen for. @param callable $listener Listener to be called whenever the event occurs. @param int $priority The priority of the listener. Lower priority listeners are called earlier. @param int $accepted_args Number of arguments the listener accepts. Defaults to 3. @return self
[ "Add", "an", "event", "listener", "that", "listens", "for", "a", "given", "event", "." ]
b5bdb570f5377c1a311e572547a8c29d507facf9
https://github.com/iron-bound-designs/IronBound-WPEvents/blob/b5bdb570f5377c1a311e572547a8c29d507facf9/src/EventDispatcher.php#L119-L136
train
iron-bound-designs/IronBound-WPEvents
src/EventDispatcher.php
EventDispatcher.remove_listener
public function remove_listener( $event_name, $listener, $priority = self::PRIORITY ) { if ( ! is_callable( $listener, true ) ) { throw new InvalidListenerException( '$listener must be callable.' ); } if ( ! is_int( $priority ) ) { throw new \InvalidArgumentException( '$priority must be an int.' ); } remove_filter( $event_name, $listener, $priority ); return $this; }
php
public function remove_listener( $event_name, $listener, $priority = self::PRIORITY ) { if ( ! is_callable( $listener, true ) ) { throw new InvalidListenerException( '$listener must be callable.' ); } if ( ! is_int( $priority ) ) { throw new \InvalidArgumentException( '$priority must be an int.' ); } remove_filter( $event_name, $listener, $priority ); return $this; }
[ "public", "function", "remove_listener", "(", "$", "event_name", ",", "$", "listener", ",", "$", "priority", "=", "self", "::", "PRIORITY", ")", "{", "if", "(", "!", "is_callable", "(", "$", "listener", ",", "true", ")", ")", "{", "throw", "new", "InvalidListenerException", "(", "'$listener must be callable.'", ")", ";", "}", "if", "(", "!", "is_int", "(", "$", "priority", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$priority must be an int.'", ")", ";", "}", "remove_filter", "(", "$", "event_name", ",", "$", "listener", ",", "$", "priority", ")", ";", "return", "$", "this", ";", "}" ]
Remove an event listener for a given event. @since 1.0 @param string $event_name The fully-qualified event name to remove a listener from. @param callable $listener The listener to be removed. @param int $priority The priority of the listener. @return self
[ "Remove", "an", "event", "listener", "for", "a", "given", "event", "." ]
b5bdb570f5377c1a311e572547a8c29d507facf9
https://github.com/iron-bound-designs/IronBound-WPEvents/blob/b5bdb570f5377c1a311e572547a8c29d507facf9/src/EventDispatcher.php#L149-L162
train
iron-bound-designs/IronBound-WPEvents
src/EventDispatcher.php
EventDispatcher.add_subscriber
public function add_subscriber( EventSubscriber $subscriber ) { foreach ( $subscriber->get_subscribed_events() as $event => $params ) { if ( is_string( $params ) ) { $this->add_listener( $event, array( $subscriber, $params ) ); } elseif ( is_array( $params ) && isset( $params[0] ) ) { $method = $params[0]; $priority = isset( $params[1] ) ? $params[1] : self::PRIORITY; $accepted_args = isset( $params[2] ) ? $params[2] : self::ACCEPTED; $this->add_listener( $event, array( $subscriber, $method ), $priority, $accepted_args ); } else { throw new \InvalidArgumentException( 'Invalid return format from EventSubscriber.' ); } } return $this; }
php
public function add_subscriber( EventSubscriber $subscriber ) { foreach ( $subscriber->get_subscribed_events() as $event => $params ) { if ( is_string( $params ) ) { $this->add_listener( $event, array( $subscriber, $params ) ); } elseif ( is_array( $params ) && isset( $params[0] ) ) { $method = $params[0]; $priority = isset( $params[1] ) ? $params[1] : self::PRIORITY; $accepted_args = isset( $params[2] ) ? $params[2] : self::ACCEPTED; $this->add_listener( $event, array( $subscriber, $method ), $priority, $accepted_args ); } else { throw new \InvalidArgumentException( 'Invalid return format from EventSubscriber.' ); } } return $this; }
[ "public", "function", "add_subscriber", "(", "EventSubscriber", "$", "subscriber", ")", "{", "foreach", "(", "$", "subscriber", "->", "get_subscribed_events", "(", ")", "as", "$", "event", "=>", "$", "params", ")", "{", "if", "(", "is_string", "(", "$", "params", ")", ")", "{", "$", "this", "->", "add_listener", "(", "$", "event", ",", "array", "(", "$", "subscriber", ",", "$", "params", ")", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "params", ")", "&&", "isset", "(", "$", "params", "[", "0", "]", ")", ")", "{", "$", "method", "=", "$", "params", "[", "0", "]", ";", "$", "priority", "=", "isset", "(", "$", "params", "[", "1", "]", ")", "?", "$", "params", "[", "1", "]", ":", "self", "::", "PRIORITY", ";", "$", "accepted_args", "=", "isset", "(", "$", "params", "[", "2", "]", ")", "?", "$", "params", "[", "2", "]", ":", "self", "::", "ACCEPTED", ";", "$", "this", "->", "add_listener", "(", "$", "event", ",", "array", "(", "$", "subscriber", ",", "$", "method", ")", ",", "$", "priority", ",", "$", "accepted_args", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid return format from EventSubscriber.'", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Add an event subscriber. This iterates over all of the subscribers events, and adds them as listeners. @since 1.0 @param EventSubscriber $subscriber @return self
[ "Add", "an", "event", "subscriber", "." ]
b5bdb570f5377c1a311e572547a8c29d507facf9
https://github.com/iron-bound-designs/IronBound-WPEvents/blob/b5bdb570f5377c1a311e572547a8c29d507facf9/src/EventDispatcher.php#L175-L194
train
iron-bound-designs/IronBound-WPEvents
src/EventDispatcher.php
EventDispatcher.remove_subscriber
public function remove_subscriber( EventSubscriber $subscriber ) { foreach ( $subscriber->get_subscribed_events() as $event => $params ) { if ( is_string( $params ) ) { $this->add_listener( $event, $params ); } elseif ( is_array( $params ) && isset( $params[0] ) ) { $method = $params[0]; $priority = isset( $params[1] ) ? $params[1] : self::PRIORITY; $this->remove_listener( $event, array( $subscriber, $method ), $priority ); } else { throw new \InvalidArgumentException( 'Invalid return format from EventSubscriber.' ); } } return $this; }
php
public function remove_subscriber( EventSubscriber $subscriber ) { foreach ( $subscriber->get_subscribed_events() as $event => $params ) { if ( is_string( $params ) ) { $this->add_listener( $event, $params ); } elseif ( is_array( $params ) && isset( $params[0] ) ) { $method = $params[0]; $priority = isset( $params[1] ) ? $params[1] : self::PRIORITY; $this->remove_listener( $event, array( $subscriber, $method ), $priority ); } else { throw new \InvalidArgumentException( 'Invalid return format from EventSubscriber.' ); } } return $this; }
[ "public", "function", "remove_subscriber", "(", "EventSubscriber", "$", "subscriber", ")", "{", "foreach", "(", "$", "subscriber", "->", "get_subscribed_events", "(", ")", "as", "$", "event", "=>", "$", "params", ")", "{", "if", "(", "is_string", "(", "$", "params", ")", ")", "{", "$", "this", "->", "add_listener", "(", "$", "event", ",", "$", "params", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "params", ")", "&&", "isset", "(", "$", "params", "[", "0", "]", ")", ")", "{", "$", "method", "=", "$", "params", "[", "0", "]", ";", "$", "priority", "=", "isset", "(", "$", "params", "[", "1", "]", ")", "?", "$", "params", "[", "1", "]", ":", "self", "::", "PRIORITY", ";", "$", "this", "->", "remove_listener", "(", "$", "event", ",", "array", "(", "$", "subscriber", ",", "$", "method", ")", ",", "$", "priority", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid return format from EventSubscriber.'", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove an event subscriber. This iterates over all of the subscribers events, and removes them as listeners. @since 1.0 @param EventSubscriber $subscriber @return self
[ "Remove", "an", "event", "subscriber", "." ]
b5bdb570f5377c1a311e572547a8c29d507facf9
https://github.com/iron-bound-designs/IronBound-WPEvents/blob/b5bdb570f5377c1a311e572547a8c29d507facf9/src/EventDispatcher.php#L207-L225
train
iron-bound-designs/IronBound-WPEvents
src/EventDispatcher.php
EventDispatcher.get_listener_priority
public function get_listener_priority( $event_name, $listener ) { if ( ! is_callable( $listener, true ) ) { throw new InvalidListenerException( '$listener must be callable.' ); } $priority = has_filter( $event_name, $listener ); if ( false === $priority ) { return null; } return $priority; }
php
public function get_listener_priority( $event_name, $listener ) { if ( ! is_callable( $listener, true ) ) { throw new InvalidListenerException( '$listener must be callable.' ); } $priority = has_filter( $event_name, $listener ); if ( false === $priority ) { return null; } return $priority; }
[ "public", "function", "get_listener_priority", "(", "$", "event_name", ",", "$", "listener", ")", "{", "if", "(", "!", "is_callable", "(", "$", "listener", ",", "true", ")", ")", "{", "throw", "new", "InvalidListenerException", "(", "'$listener must be callable.'", ")", ";", "}", "$", "priority", "=", "has_filter", "(", "$", "event_name", ",", "$", "listener", ")", ";", "if", "(", "false", "===", "$", "priority", ")", "{", "return", "null", ";", "}", "return", "$", "priority", ";", "}" ]
Get the listener priority for a given event. Lower priority listeners are evaluated earlier. @since 1.0 @param string $event_name The fully-qualified event name. @param callable $listener The listener to check against. @return int|null
[ "Get", "the", "listener", "priority", "for", "a", "given", "event", "." ]
b5bdb570f5377c1a311e572547a8c29d507facf9
https://github.com/iron-bound-designs/IronBound-WPEvents/blob/b5bdb570f5377c1a311e572547a8c29d507facf9/src/EventDispatcher.php#L252-L265
train
zewadesign/framework
Zewa/Config.php
Config.loadConfigFile
protected function loadConfigFile(string $key) { $key = strtolower($key); $filename = $this->path . DIRECTORY_SEPARATOR . ucfirst($key) . Config::CONFIG_FILE_EXTENSION; if (file_exists($filename)) { $this->configuration[$key] = require $filename; return; } throw new ConfigException('Unable to load resource: ' . $filename); }
php
protected function loadConfigFile(string $key) { $key = strtolower($key); $filename = $this->path . DIRECTORY_SEPARATOR . ucfirst($key) . Config::CONFIG_FILE_EXTENSION; if (file_exists($filename)) { $this->configuration[$key] = require $filename; return; } throw new ConfigException('Unable to load resource: ' . $filename); }
[ "protected", "function", "loadConfigFile", "(", "string", "$", "key", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "$", "filename", "=", "$", "this", "->", "path", ".", "DIRECTORY_SEPARATOR", ".", "ucfirst", "(", "$", "key", ")", ".", "Config", "::", "CONFIG_FILE_EXTENSION", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "this", "->", "configuration", "[", "$", "key", "]", "=", "require", "$", "filename", ";", "return", ";", "}", "throw", "new", "ConfigException", "(", "'Unable to load resource: '", ".", "$", "filename", ")", ";", "}" ]
Loads a configuration file in to memory @param $key @throws ConfigException when file is missing
[ "Loads", "a", "configuration", "file", "in", "to", "memory" ]
be74e41c674ac2c2ef924752ed310cfbaafe33b8
https://github.com/zewadesign/framework/blob/be74e41c674ac2c2ef924752ed310cfbaafe33b8/Zewa/Config.php#L57-L68
train
zewadesign/framework
Zewa/Config.php
Config.get
public function get(string $key) { $key = strtolower($key); if (empty($this->configuration[$key])) { $this->loadConfigFile($key); } return $this->configuration[$key]; }
php
public function get(string $key) { $key = strtolower($key); if (empty($this->configuration[$key])) { $this->loadConfigFile($key); } return $this->configuration[$key]; }
[ "public", "function", "get", "(", "string", "$", "key", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "configuration", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "loadConfigFile", "(", "$", "key", ")", ";", "}", "return", "$", "this", "->", "configuration", "[", "$", "key", "]", ";", "}" ]
Get Configuration Item @param $key @return \stdClass @throws ConfigException when config file not found
[ "Get", "Configuration", "Item" ]
be74e41c674ac2c2ef924752ed310cfbaafe33b8
https://github.com/zewadesign/framework/blob/be74e41c674ac2c2ef924752ed310cfbaafe33b8/Zewa/Config.php#L78-L87
train
Appsco/appsco-php-client
src/Appsco/Dashboard/ApiBundle/Client/AppscoClient.php
AppscoClient.addDashboardIcon
public function addDashboardIcon($dashboardRoleId, $appTemplateId) { $url = sprintf('%s://%s%s/api/v1/dashboard/%s/application', $this->scheme, $this->domain, $this->sufix, $dashboardRoleId); if ($this->logger) { $this->logger->info('Appsco.AppscoClient.addDashboardIcon', array( 'url' => $url, 'clientId' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), )); } $oldAuthType = $this->getAuthType(); $this->setAuthType(self::AUTH_TYPE_ACCESS_TOKEN); $json = $this->makeRequest($url, 'post', array(), array( 'application_template_id' => $appTemplateId, )); if ($this->logger) { $this->logger->info('Appsco.AppscoClient.addDashboardIcon', array( 'result' => $json, 'statusCode' => $this->httpClient->getStatusCode(), )); } $this->setAuthType($oldAuthType); }
php
public function addDashboardIcon($dashboardRoleId, $appTemplateId) { $url = sprintf('%s://%s%s/api/v1/dashboard/%s/application', $this->scheme, $this->domain, $this->sufix, $dashboardRoleId); if ($this->logger) { $this->logger->info('Appsco.AppscoClient.addDashboardIcon', array( 'url' => $url, 'clientId' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), )); } $oldAuthType = $this->getAuthType(); $this->setAuthType(self::AUTH_TYPE_ACCESS_TOKEN); $json = $this->makeRequest($url, 'post', array(), array( 'application_template_id' => $appTemplateId, )); if ($this->logger) { $this->logger->info('Appsco.AppscoClient.addDashboardIcon', array( 'result' => $json, 'statusCode' => $this->httpClient->getStatusCode(), )); } $this->setAuthType($oldAuthType); }
[ "public", "function", "addDashboardIcon", "(", "$", "dashboardRoleId", ",", "$", "appTemplateId", ")", "{", "$", "url", "=", "sprintf", "(", "'%s://%s%s/api/v1/dashboard/%s/application'", ",", "$", "this", "->", "scheme", ",", "$", "this", "->", "domain", ",", "$", "this", "->", "sufix", ",", "$", "dashboardRoleId", ")", ";", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'Appsco.AppscoClient.addDashboardIcon'", ",", "array", "(", "'url'", "=>", "$", "url", ",", "'clientId'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'client_secret'", "=>", "$", "this", "->", "getClientSecret", "(", ")", ",", ")", ")", ";", "}", "$", "oldAuthType", "=", "$", "this", "->", "getAuthType", "(", ")", ";", "$", "this", "->", "setAuthType", "(", "self", "::", "AUTH_TYPE_ACCESS_TOKEN", ")", ";", "$", "json", "=", "$", "this", "->", "makeRequest", "(", "$", "url", ",", "'post'", ",", "array", "(", ")", ",", "array", "(", "'application_template_id'", "=>", "$", "appTemplateId", ",", ")", ")", ";", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'Appsco.AppscoClient.addDashboardIcon'", ",", "array", "(", "'result'", "=>", "$", "json", ",", "'statusCode'", "=>", "$", "this", "->", "httpClient", "->", "getStatusCode", "(", ")", ",", ")", ")", ";", "}", "$", "this", "->", "setAuthType", "(", "$", "oldAuthType", ")", ";", "}" ]
Creates a dashboard icon @param int $dashboardRoleId @param int $appTemplateId
[ "Creates", "a", "dashboard", "icon" ]
1109a639c529488be41aee98165c286b3ca3d550
https://github.com/Appsco/appsco-php-client/blob/1109a639c529488be41aee98165c286b3ca3d550/src/Appsco/Dashboard/ApiBundle/Client/AppscoClient.php#L330-L357
train
Tom-Millard/php-class-gen
src/Config.php
Config.evaluateArgs
public function evaluateArgs(array $args) : void { array_shift($args); if (count($args) < 2) { $this->out->red("Not enough arguments: expects 2, got ".(count($args) - 1)."."); return; } $this->setName($args[0]); $this->setLocation($args[1]); if (isset($args[2])) { $this->additionalArgs(array_slice($args, 2, count($args))); } return; }
php
public function evaluateArgs(array $args) : void { array_shift($args); if (count($args) < 2) { $this->out->red("Not enough arguments: expects 2, got ".(count($args) - 1)."."); return; } $this->setName($args[0]); $this->setLocation($args[1]); if (isset($args[2])) { $this->additionalArgs(array_slice($args, 2, count($args))); } return; }
[ "public", "function", "evaluateArgs", "(", "array", "$", "args", ")", ":", "void", "{", "array_shift", "(", "$", "args", ")", ";", "if", "(", "count", "(", "$", "args", ")", "<", "2", ")", "{", "$", "this", "->", "out", "->", "red", "(", "\"Not enough arguments: expects 2, got \"", ".", "(", "count", "(", "$", "args", ")", "-", "1", ")", ".", "\".\"", ")", ";", "return", ";", "}", "$", "this", "->", "setName", "(", "$", "args", "[", "0", "]", ")", ";", "$", "this", "->", "setLocation", "(", "$", "args", "[", "1", "]", ")", ";", "if", "(", "isset", "(", "$", "args", "[", "2", "]", ")", ")", "{", "$", "this", "->", "additionalArgs", "(", "array_slice", "(", "$", "args", ",", "2", ",", "count", "(", "$", "args", ")", ")", ")", ";", "}", "return", ";", "}" ]
Take in an array of args and evalutate them @param array $args @return void
[ "Take", "in", "an", "array", "of", "args", "and", "evalutate", "them" ]
a4c06620589a63a98b3b64c9f64b9a85d754810e
https://github.com/Tom-Millard/php-class-gen/blob/a4c06620589a63a98b3b64c9f64b9a85d754810e/src/Config.php#L34-L50
train
Tom-Millard/php-class-gen
src/Config.php
Config.additionalArgs
public function additionalArgs(array $args) : void { foreach ($args as $a) { //match --extends if (substr($a, 0, strlen("--extends=")) == "--extends=") { $this->extends = explode("=", $a); $this->extends = $this->extends[1]; continue; } if ($a == "--no-factory") { $this->createFactory = false; continue; } if (substr($a, 0, strlen("--test=")) == "--test=") { $this->test = explode("=", $a)[1]; continue; } } }
php
public function additionalArgs(array $args) : void { foreach ($args as $a) { //match --extends if (substr($a, 0, strlen("--extends=")) == "--extends=") { $this->extends = explode("=", $a); $this->extends = $this->extends[1]; continue; } if ($a == "--no-factory") { $this->createFactory = false; continue; } if (substr($a, 0, strlen("--test=")) == "--test=") { $this->test = explode("=", $a)[1]; continue; } } }
[ "public", "function", "additionalArgs", "(", "array", "$", "args", ")", ":", "void", "{", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "//match --extends", "if", "(", "substr", "(", "$", "a", ",", "0", ",", "strlen", "(", "\"--extends=\"", ")", ")", "==", "\"--extends=\"", ")", "{", "$", "this", "->", "extends", "=", "explode", "(", "\"=\"", ",", "$", "a", ")", ";", "$", "this", "->", "extends", "=", "$", "this", "->", "extends", "[", "1", "]", ";", "continue", ";", "}", "if", "(", "$", "a", "==", "\"--no-factory\"", ")", "{", "$", "this", "->", "createFactory", "=", "false", ";", "continue", ";", "}", "if", "(", "substr", "(", "$", "a", ",", "0", ",", "strlen", "(", "\"--test=\"", ")", ")", "==", "\"--test=\"", ")", "{", "$", "this", "->", "test", "=", "explode", "(", "\"=\"", ",", "$", "a", ")", "[", "1", "]", ";", "continue", ";", "}", "}", "}" ]
Evaluate optional additional args @param array $args @return void
[ "Evaluate", "optional", "additional", "args" ]
a4c06620589a63a98b3b64c9f64b9a85d754810e
https://github.com/Tom-Millard/php-class-gen/blob/a4c06620589a63a98b3b64c9f64b9a85d754810e/src/Config.php#L58-L78
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getStateFormatted
protected function getStateFormatted(Document $document) { switch($document->getState()) { case Document::DOCUMENT_STATE_ACTIVE: $this->stateClass = 'success'; return 'Attivo'; break; case Document::DOCUMENT_STATE_DEACTIVE: $this->stateClass = 'warning'; return 'Disattivo'; break; case Document::DOCUMENT_STATE_DELETED: $this->stateClass = 'danger'; return 'Eliminato'; break; } $this->stateClass = 'danger'; return 'Error with document state'; }
php
protected function getStateFormatted(Document $document) { switch($document->getState()) { case Document::DOCUMENT_STATE_ACTIVE: $this->stateClass = 'success'; return 'Attivo'; break; case Document::DOCUMENT_STATE_DEACTIVE: $this->stateClass = 'warning'; return 'Disattivo'; break; case Document::DOCUMENT_STATE_DELETED: $this->stateClass = 'danger'; return 'Eliminato'; break; } $this->stateClass = 'danger'; return 'Error with document state'; }
[ "protected", "function", "getStateFormatted", "(", "Document", "$", "document", ")", "{", "switch", "(", "$", "document", "->", "getState", "(", ")", ")", "{", "case", "Document", "::", "DOCUMENT_STATE_ACTIVE", ":", "$", "this", "->", "stateClass", "=", "'success'", ";", "return", "'Attivo'", ";", "break", ";", "case", "Document", "::", "DOCUMENT_STATE_DEACTIVE", ":", "$", "this", "->", "stateClass", "=", "'warning'", ";", "return", "'Disattivo'", ";", "break", ";", "case", "Document", "::", "DOCUMENT_STATE_DELETED", ":", "$", "this", "->", "stateClass", "=", "'danger'", ";", "return", "'Eliminato'", ";", "break", ";", "}", "$", "this", "->", "stateClass", "=", "'danger'", ";", "return", "'Error with document state'", ";", "}" ]
This will fill the stateClass as well @param Document $document @return string
[ "This", "will", "fill", "the", "stateClass", "as", "well" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L81-L100
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getIsExpired
protected function getIsExpired(Document $document) { $date = null === $document->getDateEdit() ? $document->getDateInsert() : $document->getDateEdit(); $now = new \Datetime("now"); $interval = $date->diff($now); if ($interval->y > 0) { return true; } return $interval->m >= 6; }
php
protected function getIsExpired(Document $document) { $date = null === $document->getDateEdit() ? $document->getDateInsert() : $document->getDateEdit(); $now = new \Datetime("now"); $interval = $date->diff($now); if ($interval->y > 0) { return true; } return $interval->m >= 6; }
[ "protected", "function", "getIsExpired", "(", "Document", "$", "document", ")", "{", "$", "date", "=", "null", "===", "$", "document", "->", "getDateEdit", "(", ")", "?", "$", "document", "->", "getDateInsert", "(", ")", ":", "$", "document", "->", "getDateEdit", "(", ")", ";", "$", "now", "=", "new", "\\", "Datetime", "(", "\"now\"", ")", ";", "$", "interval", "=", "$", "date", "->", "diff", "(", "$", "now", ")", ";", "if", "(", "$", "interval", "->", "y", ">", "0", ")", "{", "return", "true", ";", "}", "return", "$", "interval", "->", "m", ">=", "6", ";", "}" ]
If the classified is >= 6 months old is expired @param Document $document @return boolean
[ "If", "the", "classified", "is", ">", "=", "6", "months", "old", "is", "expired" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L108-L119
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getUserHashId
protected function getUserHashId(Document $document, $sm) { $user = $document->getUser(); $main = $sm->get('neobazaar.service.main'); $userRepository = $main->getUserEntityRepository(); //$this->userIdNoHash = $user->getUserId(); // we do not want to give this info return $userRepository->getEncryptedId($user->getUserId()); }
php
protected function getUserHashId(Document $document, $sm) { $user = $document->getUser(); $main = $sm->get('neobazaar.service.main'); $userRepository = $main->getUserEntityRepository(); //$this->userIdNoHash = $user->getUserId(); // we do not want to give this info return $userRepository->getEncryptedId($user->getUserId()); }
[ "protected", "function", "getUserHashId", "(", "Document", "$", "document", ",", "$", "sm", ")", "{", "$", "user", "=", "$", "document", "->", "getUser", "(", ")", ";", "$", "main", "=", "$", "sm", "->", "get", "(", "'neobazaar.service.main'", ")", ";", "$", "userRepository", "=", "$", "main", "->", "getUserEntityRepository", "(", ")", ";", "//$this->userIdNoHash = $user->getUserId(); // we do not want to give this info", "return", "$", "userRepository", "->", "getEncryptedId", "(", "$", "user", "->", "getUserId", "(", ")", ")", ";", "}" ]
Return the user hash id for the classified. It's an sha1 hash. Also fill userIdNoHash @param Document $document @return string
[ "Return", "the", "user", "hash", "id", "for", "the", "classified", ".", "It", "s", "an", "sha1", "hash", ".", "Also", "fill", "userIdNoHash" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L152-L160
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getEditAddress
protected function getEditAddress(Document $document) { $key = null === $this->hashId ? $this->getHashId($document) : $this->hashId; return '/edit-classified/' . $key . '.html'; }
php
protected function getEditAddress(Document $document) { $key = null === $this->hashId ? $this->getHashId($document) : $this->hashId; return '/edit-classified/' . $key . '.html'; }
[ "protected", "function", "getEditAddress", "(", "Document", "$", "document", ")", "{", "$", "key", "=", "null", "===", "$", "this", "->", "hashId", "?", "$", "this", "->", "getHashId", "(", "$", "document", ")", ":", "$", "this", "->", "hashId", ";", "return", "'/edit-classified/'", ".", "$", "key", ".", "'.html'", ";", "}" ]
Get the address to be called to edit classified @param Document $document @return string
[ "Get", "the", "address", "to", "be", "called", "to", "edit", "classified" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L168-L174
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getHashId
protected function getHashId(Document $document, $sm) { $main = $sm->get('neobazaar.service.main'); $documentRepository = $main->getDocumentEntityRepository(); return $documentRepository->getEncryptedId($document->getDocumentId()); }
php
protected function getHashId(Document $document, $sm) { $main = $sm->get('neobazaar.service.main'); $documentRepository = $main->getDocumentEntityRepository(); return $documentRepository->getEncryptedId($document->getDocumentId()); }
[ "protected", "function", "getHashId", "(", "Document", "$", "document", ",", "$", "sm", ")", "{", "$", "main", "=", "$", "sm", "->", "get", "(", "'neobazaar.service.main'", ")", ";", "$", "documentRepository", "=", "$", "main", "->", "getDocumentEntityRepository", "(", ")", ";", "return", "$", "documentRepository", "->", "getEncryptedId", "(", "$", "document", "->", "getDocumentId", "(", ")", ")", ";", "}" ]
Return the classified hash id. It's an sha1 hash @param Document $document @return string
[ "Return", "the", "classified", "hash", "id", ".", "It", "s", "an", "sha1", "hash" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L204-L209
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getAddress
protected function getAddress(Document $document, $sm) { $firstCategory = null === $this->category ? $this->getCategory($document) : $this->category; $key = null === $this->hashId ? $this->getHashId($document, $sm) : $this->hashId; $slug = null === $this->slug ? $this->getSlug($document) : $this->slug; $url = $sm->get('ControllerPluginManager')->get('Url'); return $url->fromRoute('DocumentRegexClassified/title/id', array( 'category' => $firstCategory, 'title' => $slug, 'id' => $key ), array('force_canonical' => true)); }
php
protected function getAddress(Document $document, $sm) { $firstCategory = null === $this->category ? $this->getCategory($document) : $this->category; $key = null === $this->hashId ? $this->getHashId($document, $sm) : $this->hashId; $slug = null === $this->slug ? $this->getSlug($document) : $this->slug; $url = $sm->get('ControllerPluginManager')->get('Url'); return $url->fromRoute('DocumentRegexClassified/title/id', array( 'category' => $firstCategory, 'title' => $slug, 'id' => $key ), array('force_canonical' => true)); }
[ "protected", "function", "getAddress", "(", "Document", "$", "document", ",", "$", "sm", ")", "{", "$", "firstCategory", "=", "null", "===", "$", "this", "->", "category", "?", "$", "this", "->", "getCategory", "(", "$", "document", ")", ":", "$", "this", "->", "category", ";", "$", "key", "=", "null", "===", "$", "this", "->", "hashId", "?", "$", "this", "->", "getHashId", "(", "$", "document", ",", "$", "sm", ")", ":", "$", "this", "->", "hashId", ";", "$", "slug", "=", "null", "===", "$", "this", "->", "slug", "?", "$", "this", "->", "getSlug", "(", "$", "document", ")", ":", "$", "this", "->", "slug", ";", "$", "url", "=", "$", "sm", "->", "get", "(", "'ControllerPluginManager'", ")", "->", "get", "(", "'Url'", ")", ";", "return", "$", "url", "->", "fromRoute", "(", "'DocumentRegexClassified/title/id'", ",", "array", "(", "'category'", "=>", "$", "firstCategory", ",", "'title'", "=>", "$", "slug", ",", "'id'", "=>", "$", "key", ")", ",", "array", "(", "'force_canonical'", "=>", "true", ")", ")", ";", "}" ]
Get the classified full adress @param Document $document @return string
[ "Get", "the", "classified", "full", "adress" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L217-L234
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getCategory
protected function getCategory(Document $document) { $obj = new CategoriesToRender(); $categories = $obj($document, true, true); $firstCategory = reset($categories); return $firstCategory; }
php
protected function getCategory(Document $document) { $obj = new CategoriesToRender(); $categories = $obj($document, true, true); $firstCategory = reset($categories); return $firstCategory; }
[ "protected", "function", "getCategory", "(", "Document", "$", "document", ")", "{", "$", "obj", "=", "new", "CategoriesToRender", "(", ")", ";", "$", "categories", "=", "$", "obj", "(", "$", "document", ",", "true", ",", "true", ")", ";", "$", "firstCategory", "=", "reset", "(", "$", "categories", ")", ";", "return", "$", "firstCategory", ";", "}" ]
The first category as slug @param Document $document @return mixed
[ "The", "first", "category", "as", "slug" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L254-L261
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getLocation
protected function getLocation(Document $document, $sm) { $main = $sm->get('neobazaar.service.main'); $location = $document->getGeoname(); if(null !== $location) { if('ADM3' == $location->getFeatureCode()) { $location = $main->getGeonamesEntityRepository()->getParent($location); } } return null !== $location ? $location->getUrl() : ''; }
php
protected function getLocation(Document $document, $sm) { $main = $sm->get('neobazaar.service.main'); $location = $document->getGeoname(); if(null !== $location) { if('ADM3' == $location->getFeatureCode()) { $location = $main->getGeonamesEntityRepository()->getParent($location); } } return null !== $location ? $location->getUrl() : ''; }
[ "protected", "function", "getLocation", "(", "Document", "$", "document", ",", "$", "sm", ")", "{", "$", "main", "=", "$", "sm", "->", "get", "(", "'neobazaar.service.main'", ")", ";", "$", "location", "=", "$", "document", "->", "getGeoname", "(", ")", ";", "if", "(", "null", "!==", "$", "location", ")", "{", "if", "(", "'ADM3'", "==", "$", "location", "->", "getFeatureCode", "(", ")", ")", "{", "$", "location", "=", "$", "main", "->", "getGeonamesEntityRepository", "(", ")", "->", "getParent", "(", "$", "location", ")", ";", "}", "}", "return", "null", "!==", "$", "location", "?", "$", "location", "->", "getUrl", "(", ")", ":", "''", ";", "}" ]
Get the classified location. To make the ADM2 select populated it will use the parent entity if the location is an ADM3 @param Document $document @return string
[ "Get", "the", "classified", "location", ".", "To", "make", "the", "ADM2", "select", "populated", "it", "will", "use", "the", "parent", "entity", "if", "the", "location", "is", "an", "ADM3" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L271-L282
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getPurpose
protected function getPurpose(Document $document) { $value = ''; foreach($document->getMetadata() as $meta) { if('finalita' == $meta->getKey()) { $value = $meta->getValue(); break; } } return $value; }
php
protected function getPurpose(Document $document) { $value = ''; foreach($document->getMetadata() as $meta) { if('finalita' == $meta->getKey()) { $value = $meta->getValue(); break; } } return $value; }
[ "protected", "function", "getPurpose", "(", "Document", "$", "document", ")", "{", "$", "value", "=", "''", ";", "foreach", "(", "$", "document", "->", "getMetadata", "(", ")", "as", "$", "meta", ")", "{", "if", "(", "'finalita'", "==", "$", "meta", "->", "getKey", "(", ")", ")", "{", "$", "value", "=", "$", "meta", "->", "getValue", "(", ")", ";", "break", ";", "}", "}", "return", "$", "value", ";", "}" ]
Get the classified purpose @param Document $document @return string
[ "Get", "the", "classified", "purpose" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L303-L314
train
kaiohken1982/NeobazaarDocumentModule
src/Document/Model/Classified/AbstractModel.php
AbstractModel.getHideMobile
protected function getHideMobile(Document $document) { foreach($document->getMetadata() as $meta) { if('hidemobile' == $meta->getKey()) { $v = $meta->getValue(); return $v; break; } } return false; }
php
protected function getHideMobile(Document $document) { foreach($document->getMetadata() as $meta) { if('hidemobile' == $meta->getKey()) { $v = $meta->getValue(); return $v; break; } } return false; }
[ "protected", "function", "getHideMobile", "(", "Document", "$", "document", ")", "{", "foreach", "(", "$", "document", "->", "getMetadata", "(", ")", "as", "$", "meta", ")", "{", "if", "(", "'hidemobile'", "==", "$", "meta", "->", "getKey", "(", ")", ")", "{", "$", "v", "=", "$", "meta", "->", "getValue", "(", ")", ";", "return", "$", "v", ";", "break", ";", "}", "}", "return", "false", ";", "}" ]
Get the classified hidemobile meta value @param Document $document @return string
[ "Get", "the", "classified", "hidemobile", "meta", "value" ]
edb0223878fe02e791d2a0266c5a7c0f2029e3fe
https://github.com/kaiohken1982/NeobazaarDocumentModule/blob/edb0223878fe02e791d2a0266c5a7c0f2029e3fe/src/Document/Model/Classified/AbstractModel.php#L341-L352
train
ezra-obiwale/dSCore
src/Stdlib/Object.php
Object.add
public function add(array $data, $preserveArray = false, $preserveKeyOnly = null) { foreach ($data as $key => $value) { if (is_array($value) && (!$preserveArray || ($preserveArray && $preserveKeyOnly && $key !== $preserveKeyOnly))) { $this->$key = (array_key_exists(0, $value)) ? $value : new Object($value, $preserveArray, $preserveKeyOnly); continue; } if (is_int($key)) { $this->integerKeys[$key] = $value; continue; } $attr = Util::hyphenToCamel(Util::_toCamel($key)); $this->{$attr} = $value; } return $this; }
php
public function add(array $data, $preserveArray = false, $preserveKeyOnly = null) { foreach ($data as $key => $value) { if (is_array($value) && (!$preserveArray || ($preserveArray && $preserveKeyOnly && $key !== $preserveKeyOnly))) { $this->$key = (array_key_exists(0, $value)) ? $value : new Object($value, $preserveArray, $preserveKeyOnly); continue; } if (is_int($key)) { $this->integerKeys[$key] = $value; continue; } $attr = Util::hyphenToCamel(Util::_toCamel($key)); $this->{$attr} = $value; } return $this; }
[ "public", "function", "add", "(", "array", "$", "data", ",", "$", "preserveArray", "=", "false", ",", "$", "preserveKeyOnly", "=", "null", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "(", "!", "$", "preserveArray", "||", "(", "$", "preserveArray", "&&", "$", "preserveKeyOnly", "&&", "$", "key", "!==", "$", "preserveKeyOnly", ")", ")", ")", "{", "$", "this", "->", "$", "key", "=", "(", "array_key_exists", "(", "0", ",", "$", "value", ")", ")", "?", "$", "value", ":", "new", "Object", "(", "$", "value", ",", "$", "preserveArray", ",", "$", "preserveKeyOnly", ")", ";", "continue", ";", "}", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "this", "->", "integerKeys", "[", "$", "key", "]", "=", "$", "value", ";", "continue", ";", "}", "$", "attr", "=", "Util", "::", "hyphenToCamel", "(", "Util", "::", "_toCamel", "(", "$", "key", ")", ")", ";", "$", "this", "->", "{", "$", "attr", "}", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Adds data to the object @param array $data @param boolean $preserveArray Indicates whether to preserve array or turn them objects too @return Object @throws \Exception
[ "Adds", "data", "to", "the", "object" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Stdlib/Object.php#L25-L41
train
ezra-obiwale/dSCore
src/Stdlib/Object.php
Object.toArray
public function toArray($recursive = false) { $return = get_object_vars($this); if ($recursive) { foreach ($return as $ppt => &$val) { if ($ppt === 'integerkeys') continue; if (is_object($val) && method_exists($val, 'toArray')) { $val = $val->toArray(true); } } } unset($return['integerKeys']); return $return; }
php
public function toArray($recursive = false) { $return = get_object_vars($this); if ($recursive) { foreach ($return as $ppt => &$val) { if ($ppt === 'integerkeys') continue; if (is_object($val) && method_exists($val, 'toArray')) { $val = $val->toArray(true); } } } unset($return['integerKeys']); return $return; }
[ "public", "function", "toArray", "(", "$", "recursive", "=", "false", ")", "{", "$", "return", "=", "get_object_vars", "(", "$", "this", ")", ";", "if", "(", "$", "recursive", ")", "{", "foreach", "(", "$", "return", "as", "$", "ppt", "=>", "&", "$", "val", ")", "{", "if", "(", "$", "ppt", "===", "'integerkeys'", ")", "continue", ";", "if", "(", "is_object", "(", "$", "val", ")", "&&", "method_exists", "(", "$", "val", ",", "'toArray'", ")", ")", "{", "$", "val", "=", "$", "val", "->", "toArray", "(", "true", ")", ";", "}", "}", "}", "unset", "(", "$", "return", "[", "'integerKeys'", "]", ")", ";", "return", "$", "return", ";", "}" ]
Returns array of properties @param $recursive @return array
[ "Returns", "array", "of", "properties" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Stdlib/Object.php#L71-L84
train
drdplusinfo/drdplus-races
DrdPlus/Races/Race.php
Race.getBodyWeight
public function getBodyWeight(GenderCode $genderCode, Tables $tables): int { $weightInKg = $this->getWeightInKg($genderCode, $tables); return (new Weight($weightInKg, Weight::KG, $tables->getWeightTable()))->getBonus()->getValue(); }
php
public function getBodyWeight(GenderCode $genderCode, Tables $tables): int { $weightInKg = $this->getWeightInKg($genderCode, $tables); return (new Weight($weightInKg, Weight::KG, $tables->getWeightTable()))->getBonus()->getValue(); }
[ "public", "function", "getBodyWeight", "(", "GenderCode", "$", "genderCode", ",", "Tables", "$", "tables", ")", ":", "int", "{", "$", "weightInKg", "=", "$", "this", "->", "getWeightInKg", "(", "$", "genderCode", ",", "$", "tables", ")", ";", "return", "(", "new", "Weight", "(", "$", "weightInKg", ",", "Weight", "::", "KG", ",", "$", "tables", "->", "getWeightTable", "(", ")", ")", ")", "->", "getBonus", "(", ")", "->", "getValue", "(", ")", ";", "}" ]
Bonus of body weight @param GenderCode $genderCode @param Tables $tables @return int
[ "Bonus", "of", "body", "weight" ]
a7189555ff5235e690c5fe01afc85aec0015b21a
https://github.com/drdplusinfo/drdplus-races/blob/a7189555ff5235e690c5fe01afc85aec0015b21a/DrdPlus/Races/Race.php#L144-L149
train
stevenliebregt/crispysystem
src/Routing/Route.php
Route.any
public static function any(string $path, $handler) : array { return [ static::get($path, $handler), static::post($path, $handler), static::put($path, $handler), static::patch($path, $handler), static::delete($path, $handler), ]; }
php
public static function any(string $path, $handler) : array { return [ static::get($path, $handler), static::post($path, $handler), static::put($path, $handler), static::patch($path, $handler), static::delete($path, $handler), ]; }
[ "public", "static", "function", "any", "(", "string", "$", "path", ",", "$", "handler", ")", ":", "array", "{", "return", "[", "static", "::", "get", "(", "$", "path", ",", "$", "handler", ")", ",", "static", "::", "post", "(", "$", "path", ",", "$", "handler", ")", ",", "static", "::", "put", "(", "$", "path", ",", "$", "handler", ")", ",", "static", "::", "patch", "(", "$", "path", ",", "$", "handler", ")", ",", "static", "::", "delete", "(", "$", "path", ",", "$", "handler", ")", ",", "]", ";", "}" ]
Add a route that matches any HTTP verb @param string $path @param $handler @return array @since 1.4.0
[ "Add", "a", "route", "that", "matches", "any", "HTTP", "verb" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Routing/Route.php#L144-L153
train
stevenliebregt/crispysystem
src/Routing/Route.php
Route.match
public static function match(array $verbs, string $path, $handler) : array { $routes = []; foreach ($verbs as $verb) { switch (strtolower($verb)) { case 'get': $routes[] = static::get($path, $handler); break; case 'post': $routes[] = static::post($path, $handler); break; case 'put': $routes[] = static::put($path, $handler); break; case 'patch': $routes[] = static::patch($path, $handler); break; case 'delete': $routes[] = static::delete($path, $handler); break; } } return $routes; }
php
public static function match(array $verbs, string $path, $handler) : array { $routes = []; foreach ($verbs as $verb) { switch (strtolower($verb)) { case 'get': $routes[] = static::get($path, $handler); break; case 'post': $routes[] = static::post($path, $handler); break; case 'put': $routes[] = static::put($path, $handler); break; case 'patch': $routes[] = static::patch($path, $handler); break; case 'delete': $routes[] = static::delete($path, $handler); break; } } return $routes; }
[ "public", "static", "function", "match", "(", "array", "$", "verbs", ",", "string", "$", "path", ",", "$", "handler", ")", ":", "array", "{", "$", "routes", "=", "[", "]", ";", "foreach", "(", "$", "verbs", "as", "$", "verb", ")", "{", "switch", "(", "strtolower", "(", "$", "verb", ")", ")", "{", "case", "'get'", ":", "$", "routes", "[", "]", "=", "static", "::", "get", "(", "$", "path", ",", "$", "handler", ")", ";", "break", ";", "case", "'post'", ":", "$", "routes", "[", "]", "=", "static", "::", "post", "(", "$", "path", ",", "$", "handler", ")", ";", "break", ";", "case", "'put'", ":", "$", "routes", "[", "]", "=", "static", "::", "put", "(", "$", "path", ",", "$", "handler", ")", ";", "break", ";", "case", "'patch'", ":", "$", "routes", "[", "]", "=", "static", "::", "patch", "(", "$", "path", ",", "$", "handler", ")", ";", "break", ";", "case", "'delete'", ":", "$", "routes", "[", "]", "=", "static", "::", "delete", "(", "$", "path", ",", "$", "handler", ")", ";", "break", ";", "}", "}", "return", "$", "routes", ";", "}" ]
Add a route that matches the given HTTP verbs @param array $verbs @param string $path @param $handler @return array @since 1.4.0
[ "Add", "a", "route", "that", "matches", "the", "given", "HTTP", "verbs" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Routing/Route.php#L163-L188
train
stevenliebregt/crispysystem
src/Routing/Route.php
Route.add
protected static function add(string $verb, string $path, $handler) : Route { /** @var Router $router */ $router = static::getRouterInstance(); $route = new static($router, $verb, $path, $handler); Router::addRoute($verb, $route); return $route; }
php
protected static function add(string $verb, string $path, $handler) : Route { /** @var Router $router */ $router = static::getRouterInstance(); $route = new static($router, $verb, $path, $handler); Router::addRoute($verb, $route); return $route; }
[ "protected", "static", "function", "add", "(", "string", "$", "verb", ",", "string", "$", "path", ",", "$", "handler", ")", ":", "Route", "{", "/** @var Router $router */", "$", "router", "=", "static", "::", "getRouterInstance", "(", ")", ";", "$", "route", "=", "new", "static", "(", "$", "router", ",", "$", "verb", ",", "$", "path", ",", "$", "handler", ")", ";", "Router", "::", "addRoute", "(", "$", "verb", ",", "$", "route", ")", ";", "return", "$", "route", ";", "}" ]
Creates a new route @param string $verb @param string $path @param $handler @return Route @since 1.0.0
[ "Creates", "a", "new", "route" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Routing/Route.php#L198-L208
train
stevenliebregt/crispysystem
src/Routing/Route.php
Route.createRegex
public function createRegex() { $parts = explode('/', ltrim($this->path, '/')); $regex = '/^'; // Matches the start of the string foreach ($parts as $part) { $regex .= '\/'; // Matches starting slash // Handle non-variable parts if (stripos($part, '{') === false && stripos($part, '}') === false) { $regex .= $part; // Exactly match this part continue; } // Handle variable parts $name = str_ireplace(['{', '}'], '', $part); $this->parameterNames[] = $name; $this->parameters[$name] = null; // Check if a rule exists for this part if (isset($this->rules[$name])) { $regex .= $this->rules[$name]; continue; } // No rule exists, match all except slashes $regex .= '([^\/]+)'; } $regex .= '$/'; // Matches end of string $this->regex = $regex; }
php
public function createRegex() { $parts = explode('/', ltrim($this->path, '/')); $regex = '/^'; // Matches the start of the string foreach ($parts as $part) { $regex .= '\/'; // Matches starting slash // Handle non-variable parts if (stripos($part, '{') === false && stripos($part, '}') === false) { $regex .= $part; // Exactly match this part continue; } // Handle variable parts $name = str_ireplace(['{', '}'], '', $part); $this->parameterNames[] = $name; $this->parameters[$name] = null; // Check if a rule exists for this part if (isset($this->rules[$name])) { $regex .= $this->rules[$name]; continue; } // No rule exists, match all except slashes $regex .= '([^\/]+)'; } $regex .= '$/'; // Matches end of string $this->regex = $regex; }
[ "public", "function", "createRegex", "(", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "ltrim", "(", "$", "this", "->", "path", ",", "'/'", ")", ")", ";", "$", "regex", "=", "'/^'", ";", "// Matches the start of the string", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "regex", ".=", "'\\/'", ";", "// Matches starting slash", "// Handle non-variable parts", "if", "(", "stripos", "(", "$", "part", ",", "'{'", ")", "===", "false", "&&", "stripos", "(", "$", "part", ",", "'}'", ")", "===", "false", ")", "{", "$", "regex", ".=", "$", "part", ";", "// Exactly match this part", "continue", ";", "}", "// Handle variable parts", "$", "name", "=", "str_ireplace", "(", "[", "'{'", ",", "'}'", "]", ",", "''", ",", "$", "part", ")", ";", "$", "this", "->", "parameterNames", "[", "]", "=", "$", "name", ";", "$", "this", "->", "parameters", "[", "$", "name", "]", "=", "null", ";", "// Check if a rule exists for this part", "if", "(", "isset", "(", "$", "this", "->", "rules", "[", "$", "name", "]", ")", ")", "{", "$", "regex", ".=", "$", "this", "->", "rules", "[", "$", "name", "]", ";", "continue", ";", "}", "// No rule exists, match all except slashes", "$", "regex", ".=", "'([^\\/]+)'", ";", "}", "$", "regex", ".=", "'$/'", ";", "// Matches end of string", "$", "this", "->", "regex", "=", "$", "regex", ";", "}" ]
Creates a regular expression to match the route @since 1.0.0
[ "Creates", "a", "regular", "expression", "to", "match", "the", "route" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Routing/Route.php#L280-L306
train
phpffcms/ffcms-core
src/Network/Request/MultiLanguageFeatures.php
MultiLanguageFeatures.runMultiLanguage
private function runMultiLanguage(): void { // check if multi-language is enabled if (!App::$Properties->get('multiLanguage')) { $this->language = App::$Properties->get('singleLanguage'); return; } // check if domain-lang binding is enabled if (Any::isArray(App::$Properties->get('languageDomainAlias'))) { /** @var array $domainAlias */ $domainAlias = App::$Properties->get('languageDomainAlias'); if (Any::isArray($domainAlias) && !Str::likeEmpty($domainAlias[$this->getHost()])) { $this->language = $domainAlias[$this->getHost()]; } return; } // try to find language in pathway foreach (App::$Properties->get('languages') as $lang) { if (Str::startsWith('/' . $lang, $this->getPathInfo())) { $this->language = $lang; $this->languageInPath = true; } } // try to find in ?lang get if (!$this->language && Arr::in($this->query->get('lang'), App::$Properties->get('languages'))) { $this->language = $this->query->get('lang'); } // language still not defined?! if (!$this->language) { $this->setLanguageFromBrowser(); } }
php
private function runMultiLanguage(): void { // check if multi-language is enabled if (!App::$Properties->get('multiLanguage')) { $this->language = App::$Properties->get('singleLanguage'); return; } // check if domain-lang binding is enabled if (Any::isArray(App::$Properties->get('languageDomainAlias'))) { /** @var array $domainAlias */ $domainAlias = App::$Properties->get('languageDomainAlias'); if (Any::isArray($domainAlias) && !Str::likeEmpty($domainAlias[$this->getHost()])) { $this->language = $domainAlias[$this->getHost()]; } return; } // try to find language in pathway foreach (App::$Properties->get('languages') as $lang) { if (Str::startsWith('/' . $lang, $this->getPathInfo())) { $this->language = $lang; $this->languageInPath = true; } } // try to find in ?lang get if (!$this->language && Arr::in($this->query->get('lang'), App::$Properties->get('languages'))) { $this->language = $this->query->get('lang'); } // language still not defined?! if (!$this->language) { $this->setLanguageFromBrowser(); } }
[ "private", "function", "runMultiLanguage", "(", ")", ":", "void", "{", "// check if multi-language is enabled", "if", "(", "!", "App", "::", "$", "Properties", "->", "get", "(", "'multiLanguage'", ")", ")", "{", "$", "this", "->", "language", "=", "App", "::", "$", "Properties", "->", "get", "(", "'singleLanguage'", ")", ";", "return", ";", "}", "// check if domain-lang binding is enabled", "if", "(", "Any", "::", "isArray", "(", "App", "::", "$", "Properties", "->", "get", "(", "'languageDomainAlias'", ")", ")", ")", "{", "/** @var array $domainAlias */", "$", "domainAlias", "=", "App", "::", "$", "Properties", "->", "get", "(", "'languageDomainAlias'", ")", ";", "if", "(", "Any", "::", "isArray", "(", "$", "domainAlias", ")", "&&", "!", "Str", "::", "likeEmpty", "(", "$", "domainAlias", "[", "$", "this", "->", "getHost", "(", ")", "]", ")", ")", "{", "$", "this", "->", "language", "=", "$", "domainAlias", "[", "$", "this", "->", "getHost", "(", ")", "]", ";", "}", "return", ";", "}", "// try to find language in pathway", "foreach", "(", "App", "::", "$", "Properties", "->", "get", "(", "'languages'", ")", "as", "$", "lang", ")", "{", "if", "(", "Str", "::", "startsWith", "(", "'/'", ".", "$", "lang", ",", "$", "this", "->", "getPathInfo", "(", ")", ")", ")", "{", "$", "this", "->", "language", "=", "$", "lang", ";", "$", "this", "->", "languageInPath", "=", "true", ";", "}", "}", "// try to find in ?lang get", "if", "(", "!", "$", "this", "->", "language", "&&", "Arr", "::", "in", "(", "$", "this", "->", "query", "->", "get", "(", "'lang'", ")", ",", "App", "::", "$", "Properties", "->", "get", "(", "'languages'", ")", ")", ")", "{", "$", "this", "->", "language", "=", "$", "this", "->", "query", "->", "get", "(", "'lang'", ")", ";", "}", "// language still not defined?!", "if", "(", "!", "$", "this", "->", "language", ")", "{", "$", "this", "->", "setLanguageFromBrowser", "(", ")", ";", "}", "}" ]
Build multi language pathway binding. @return void
[ "Build", "multi", "language", "pathway", "binding", "." ]
44a309553ef9f115ccfcfd71f2ac6e381c612082
https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Network/Request/MultiLanguageFeatures.php#L27-L62
train
phpffcms/ffcms-core
src/Network/Request/MultiLanguageFeatures.php
MultiLanguageFeatures.setLanguageFromBrowser
private function setLanguageFromBrowser(): void { $userLang = App::$Properties->get('singleLanguage'); $browserAccept = $this->getLanguages(); if (Any::isArray($browserAccept) && count($browserAccept) > 0) { foreach ($browserAccept as $bLang) { if (Arr::in($bLang, App::$Properties->get('languages'))) { $userLang = $bLang; break; // stop calculating, language is founded in priority } } } // parse query string $queryString = null; if (count($this->query->all()) > 0) { $queryString = '?' . http_build_query($this->query->all()); } // build response with redirect to language-based path $redirectUrl = $this->getSchemeAndHttpHost() . $this->basePath . '/' . $userLang . $this->getPathInfo() . $queryString; $response = new RedirectResponse($redirectUrl); $response->send(); exit(); }
php
private function setLanguageFromBrowser(): void { $userLang = App::$Properties->get('singleLanguage'); $browserAccept = $this->getLanguages(); if (Any::isArray($browserAccept) && count($browserAccept) > 0) { foreach ($browserAccept as $bLang) { if (Arr::in($bLang, App::$Properties->get('languages'))) { $userLang = $bLang; break; // stop calculating, language is founded in priority } } } // parse query string $queryString = null; if (count($this->query->all()) > 0) { $queryString = '?' . http_build_query($this->query->all()); } // build response with redirect to language-based path $redirectUrl = $this->getSchemeAndHttpHost() . $this->basePath . '/' . $userLang . $this->getPathInfo() . $queryString; $response = new RedirectResponse($redirectUrl); $response->send(); exit(); }
[ "private", "function", "setLanguageFromBrowser", "(", ")", ":", "void", "{", "$", "userLang", "=", "App", "::", "$", "Properties", "->", "get", "(", "'singleLanguage'", ")", ";", "$", "browserAccept", "=", "$", "this", "->", "getLanguages", "(", ")", ";", "if", "(", "Any", "::", "isArray", "(", "$", "browserAccept", ")", "&&", "count", "(", "$", "browserAccept", ")", ">", "0", ")", "{", "foreach", "(", "$", "browserAccept", "as", "$", "bLang", ")", "{", "if", "(", "Arr", "::", "in", "(", "$", "bLang", ",", "App", "::", "$", "Properties", "->", "get", "(", "'languages'", ")", ")", ")", "{", "$", "userLang", "=", "$", "bLang", ";", "break", ";", "// stop calculating, language is founded in priority", "}", "}", "}", "// parse query string", "$", "queryString", "=", "null", ";", "if", "(", "count", "(", "$", "this", "->", "query", "->", "all", "(", ")", ")", ">", "0", ")", "{", "$", "queryString", "=", "'?'", ".", "http_build_query", "(", "$", "this", "->", "query", "->", "all", "(", ")", ")", ";", "}", "// build response with redirect to language-based path", "$", "redirectUrl", "=", "$", "this", "->", "getSchemeAndHttpHost", "(", ")", ".", "$", "this", "->", "basePath", ".", "'/'", ".", "$", "userLang", ".", "$", "this", "->", "getPathInfo", "(", ")", ".", "$", "queryString", ";", "$", "response", "=", "new", "RedirectResponse", "(", "$", "redirectUrl", ")", ";", "$", "response", "->", "send", "(", ")", ";", "exit", "(", ")", ";", "}" ]
Set language from browser headers @return void
[ "Set", "language", "from", "browser", "headers" ]
44a309553ef9f115ccfcfd71f2ac6e381c612082
https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Network/Request/MultiLanguageFeatures.php#L68-L92
train
praxigento/mobi_mod_downline
Service/Snap/Calc/A/ComposeUpdates.php
ComposeUpdates.composeSnapItem
private function composeSnapItem($customerId, $parentId, $dsChanged, $snap) { $result = new ESnap(); $result->setCustomerRef($customerId); $result->setParentRef($parentId); $result->setDate($dsChanged); if ($customerId == $parentId) { /* this is root node customer */ $newDepth = Cfg::INIT_DEPTH; $newPath = Cfg::DTPS; } else { /* this is NOT root node customer */ if (!isset($snap[$parentId])) { $breakPoint = 'inconsistency detected'; // this is code for debug only } /** @var ESnap $parent */ $parent = $snap[$parentId]; $newDepth = $parent->getDepth() + 1; $newPath = $parent->getPath() . $parentId . Cfg::DTPS; } $result->setDepth($newDepth); $result->setPath($newPath); return $result; }
php
private function composeSnapItem($customerId, $parentId, $dsChanged, $snap) { $result = new ESnap(); $result->setCustomerRef($customerId); $result->setParentRef($parentId); $result->setDate($dsChanged); if ($customerId == $parentId) { /* this is root node customer */ $newDepth = Cfg::INIT_DEPTH; $newPath = Cfg::DTPS; } else { /* this is NOT root node customer */ if (!isset($snap[$parentId])) { $breakPoint = 'inconsistency detected'; // this is code for debug only } /** @var ESnap $parent */ $parent = $snap[$parentId]; $newDepth = $parent->getDepth() + 1; $newPath = $parent->getPath() . $parentId . Cfg::DTPS; } $result->setDepth($newDepth); $result->setPath($newPath); return $result; }
[ "private", "function", "composeSnapItem", "(", "$", "customerId", ",", "$", "parentId", ",", "$", "dsChanged", ",", "$", "snap", ")", "{", "$", "result", "=", "new", "ESnap", "(", ")", ";", "$", "result", "->", "setCustomerRef", "(", "$", "customerId", ")", ";", "$", "result", "->", "setParentRef", "(", "$", "parentId", ")", ";", "$", "result", "->", "setDate", "(", "$", "dsChanged", ")", ";", "if", "(", "$", "customerId", "==", "$", "parentId", ")", "{", "/* this is root node customer */", "$", "newDepth", "=", "Cfg", "::", "INIT_DEPTH", ";", "$", "newPath", "=", "Cfg", "::", "DTPS", ";", "}", "else", "{", "/* this is NOT root node customer */", "if", "(", "!", "isset", "(", "$", "snap", "[", "$", "parentId", "]", ")", ")", "{", "$", "breakPoint", "=", "'inconsistency detected'", ";", "// this is code for debug only", "}", "/** @var ESnap $parent */", "$", "parent", "=", "$", "snap", "[", "$", "parentId", "]", ";", "$", "newDepth", "=", "$", "parent", "->", "getDepth", "(", ")", "+", "1", ";", "$", "newPath", "=", "$", "parent", "->", "getPath", "(", ")", ".", "$", "parentId", ".", "Cfg", "::", "DTPS", ";", "}", "$", "result", "->", "setDepth", "(", "$", "newDepth", ")", ";", "$", "result", "->", "setPath", "(", "$", "newPath", ")", ";", "return", "$", "result", ";", "}" ]
Compose snapshot item. @param int $customerId @param int $parentId @param string $dsChanged @param ESnap[] $snap @return ESnap
[ "Compose", "snapshot", "item", "." ]
0f3c276dfff1aa029f9fd205ccfc56f207a2e75b
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Service/Snap/Calc/A/ComposeUpdates.php#L139-L162
train
ColonelBlimp/NsanjaConfig
src/Nsanja/Platform/Config/ConfigurationAbstract.php
ConfigurationAbstract.getArrayValue
final protected function getArrayValue(string $key): array { $value = $this->getConfigValue($key); if (!$value || !\is_array($value)) { return []; } return $value; }
php
final protected function getArrayValue(string $key): array { $value = $this->getConfigValue($key); if (!$value || !\is_array($value)) { return []; } return $value; }
[ "final", "protected", "function", "getArrayValue", "(", "string", "$", "key", ")", ":", "array", "{", "$", "value", "=", "$", "this", "->", "getConfigValue", "(", "$", "key", ")", ";", "if", "(", "!", "$", "value", "||", "!", "\\", "is_array", "(", "$", "value", ")", ")", "{", "return", "[", "]", ";", "}", "return", "$", "value", ";", "}" ]
Returns an array value. @param string $key @return array
[ "Returns", "an", "array", "value", "." ]
d23609c6cd00f7c524f122b16c532681b8c489be
https://github.com/ColonelBlimp/NsanjaConfig/blob/d23609c6cd00f7c524f122b16c532681b8c489be/src/Nsanja/Platform/Config/ConfigurationAbstract.php#L105-L113
train
ColonelBlimp/NsanjaConfig
src/Nsanja/Platform/Config/ConfigurationAbstract.php
ConfigurationAbstract.getStringValue
final protected function getStringValue(string $key, string $default = ''): string { $value = $this->getConfigValue($key); if (!$value) { return $default; } return strval($value); }
php
final protected function getStringValue(string $key, string $default = ''): string { $value = $this->getConfigValue($key); if (!$value) { return $default; } return strval($value); }
[ "final", "protected", "function", "getStringValue", "(", "string", "$", "key", ",", "string", "$", "default", "=", "''", ")", ":", "string", "{", "$", "value", "=", "$", "this", "->", "getConfigValue", "(", "$", "key", ")", ";", "if", "(", "!", "$", "value", ")", "{", "return", "$", "default", ";", "}", "return", "strval", "(", "$", "value", ")", ";", "}" ]
Retrieves a string configuration parameter. @param string $key The for the value. @param string $default The default value if not found (empty string) @return string The value.
[ "Retrieves", "a", "string", "configuration", "parameter", "." ]
d23609c6cd00f7c524f122b16c532681b8c489be
https://github.com/ColonelBlimp/NsanjaConfig/blob/d23609c6cd00f7c524f122b16c532681b8c489be/src/Nsanja/Platform/Config/ConfigurationAbstract.php#L137-L145
train
ColonelBlimp/NsanjaConfig
src/Nsanja/Platform/Config/ConfigurationAbstract.php
ConfigurationAbstract.getBooleanValue
final protected function getBooleanValue(string $key, bool $default = false): bool { $value = $this->getConfigValue($key); if (!$value) { return $default; } return \boolval($value); }
php
final protected function getBooleanValue(string $key, bool $default = false): bool { $value = $this->getConfigValue($key); if (!$value) { return $default; } return \boolval($value); }
[ "final", "protected", "function", "getBooleanValue", "(", "string", "$", "key", ",", "bool", "$", "default", "=", "false", ")", ":", "bool", "{", "$", "value", "=", "$", "this", "->", "getConfigValue", "(", "$", "key", ")", ";", "if", "(", "!", "$", "value", ")", "{", "return", "$", "default", ";", "}", "return", "\\", "boolval", "(", "$", "value", ")", ";", "}" ]
Retrieves a boolean configuration parameter. @param string $key The key for the value. @param bool $default The default value if not found (false) @return bool The value
[ "Retrieves", "a", "boolean", "configuration", "parameter", "." ]
d23609c6cd00f7c524f122b16c532681b8c489be
https://github.com/ColonelBlimp/NsanjaConfig/blob/d23609c6cd00f7c524f122b16c532681b8c489be/src/Nsanja/Platform/Config/ConfigurationAbstract.php#L153-L161
train
ColonelBlimp/NsanjaConfig
src/Nsanja/Platform/Config/ConfigurationAbstract.php
ConfigurationAbstract.isBaseConfigPropertiesSet
private function isBaseConfigPropertiesSet(): bool { return isset( $this->config[ConfigurationInterface::KEY_APP_ROOT], $this->config[ConfigurationInterface::KEY_CONFIG_ROOT], $this->config[ConfigurationInterface::KEY_CACHE_ROOT], $this->config[ConfigurationInterface::KEY_THEMES_ROOT], $this->config[ConfigurationInterface::KEY_CONTENT_ROOT] ); }
php
private function isBaseConfigPropertiesSet(): bool { return isset( $this->config[ConfigurationInterface::KEY_APP_ROOT], $this->config[ConfigurationInterface::KEY_CONFIG_ROOT], $this->config[ConfigurationInterface::KEY_CACHE_ROOT], $this->config[ConfigurationInterface::KEY_THEMES_ROOT], $this->config[ConfigurationInterface::KEY_CONTENT_ROOT] ); }
[ "private", "function", "isBaseConfigPropertiesSet", "(", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "config", "[", "ConfigurationInterface", "::", "KEY_APP_ROOT", "]", ",", "$", "this", "->", "config", "[", "ConfigurationInterface", "::", "KEY_CONFIG_ROOT", "]", ",", "$", "this", "->", "config", "[", "ConfigurationInterface", "::", "KEY_CACHE_ROOT", "]", ",", "$", "this", "->", "config", "[", "ConfigurationInterface", "::", "KEY_THEMES_ROOT", "]", ",", "$", "this", "->", "config", "[", "ConfigurationInterface", "::", "KEY_CONTENT_ROOT", "]", ")", ";", "}" ]
Checks that all the mandatory properties are set. @return bool Return <code>true</code> if all the properties are set, otherwise <code>false</code>.
[ "Checks", "that", "all", "the", "mandatory", "properties", "are", "set", "." ]
d23609c6cd00f7c524f122b16c532681b8c489be
https://github.com/ColonelBlimp/NsanjaConfig/blob/d23609c6cd00f7c524f122b16c532681b8c489be/src/Nsanja/Platform/Config/ConfigurationAbstract.php#L167-L176
train
inc2734/wp-page-speed-optimization
src/App/Controller/Menu.php
Menu._pre_wp_nav_menu
public function _pre_wp_nav_menu( $output, $args ) { if ( is_customize_preview() ) { return $output; } // For the nav menu widget. if ( ! $args->theme_location ) { return $output; } if ( ! $this->_is_caching_nav_menus() ) { return $output; } if ( ! $this->_is_caching_nav_menu( $args->theme_location ) ) { return $output; } $transient = get_transient( $this->_get_transient_id( $args->theme_location ) ); if ( false !== $transient ) { return '<!-- Cached menu ' . $args->theme_location . ' -->' . $transient . '<!-- /Cached menu ' . $args->theme_location . ' -->'; } return $output; }
php
public function _pre_wp_nav_menu( $output, $args ) { if ( is_customize_preview() ) { return $output; } // For the nav menu widget. if ( ! $args->theme_location ) { return $output; } if ( ! $this->_is_caching_nav_menus() ) { return $output; } if ( ! $this->_is_caching_nav_menu( $args->theme_location ) ) { return $output; } $transient = get_transient( $this->_get_transient_id( $args->theme_location ) ); if ( false !== $transient ) { return '<!-- Cached menu ' . $args->theme_location . ' -->' . $transient . '<!-- /Cached menu ' . $args->theme_location . ' -->'; } return $output; }
[ "public", "function", "_pre_wp_nav_menu", "(", "$", "output", ",", "$", "args", ")", "{", "if", "(", "is_customize_preview", "(", ")", ")", "{", "return", "$", "output", ";", "}", "// For the nav menu widget.", "if", "(", "!", "$", "args", "->", "theme_location", ")", "{", "return", "$", "output", ";", "}", "if", "(", "!", "$", "this", "->", "_is_caching_nav_menus", "(", ")", ")", "{", "return", "$", "output", ";", "}", "if", "(", "!", "$", "this", "->", "_is_caching_nav_menu", "(", "$", "args", "->", "theme_location", ")", ")", "{", "return", "$", "output", ";", "}", "$", "transient", "=", "get_transient", "(", "$", "this", "->", "_get_transient_id", "(", "$", "args", "->", "theme_location", ")", ")", ";", "if", "(", "false", "!==", "$", "transient", ")", "{", "return", "'<!-- Cached menu '", ".", "$", "args", "->", "theme_location", ".", "' -->'", ".", "$", "transient", ".", "'<!-- /Cached menu '", ".", "$", "args", "->", "theme_location", ".", "' -->'", ";", "}", "return", "$", "output", ";", "}" ]
Output nav menu @param string $output HTML @param array $args @return string
[ "Output", "nav", "menu" ]
219963582b592eef4bde6cdd4ed1cf0dc71a6114
https://github.com/inc2734/wp-page-speed-optimization/blob/219963582b592eef4bde6cdd4ed1cf0dc71a6114/src/App/Controller/Menu.php#L95-L119
train
inc2734/wp-page-speed-optimization
src/App/Controller/Menu.php
Menu._remove_current_classes
public function _remove_current_classes( $items, $args ) { if ( is_customize_preview() ) { return $items; } if ( ! static::_is_caching_nav_menus() ) { return $items; } if ( ! $this->_is_caching_nav_menu( $args->theme_location ) ) { return $items; } foreach ( $items as $items_index => $item ) { foreach ( $item->classes as $index => $class ) { if ( false === strpos( $class, 'current' ) ) { continue; } unset( $items[ $items_index ]->classes[ $index ] ); } } return $items; }
php
public function _remove_current_classes( $items, $args ) { if ( is_customize_preview() ) { return $items; } if ( ! static::_is_caching_nav_menus() ) { return $items; } if ( ! $this->_is_caching_nav_menu( $args->theme_location ) ) { return $items; } foreach ( $items as $items_index => $item ) { foreach ( $item->classes as $index => $class ) { if ( false === strpos( $class, 'current' ) ) { continue; } unset( $items[ $items_index ]->classes[ $index ] ); } } return $items; }
[ "public", "function", "_remove_current_classes", "(", "$", "items", ",", "$", "args", ")", "{", "if", "(", "is_customize_preview", "(", ")", ")", "{", "return", "$", "items", ";", "}", "if", "(", "!", "static", "::", "_is_caching_nav_menus", "(", ")", ")", "{", "return", "$", "items", ";", "}", "if", "(", "!", "$", "this", "->", "_is_caching_nav_menu", "(", "$", "args", "->", "theme_location", ")", ")", "{", "return", "$", "items", ";", "}", "foreach", "(", "$", "items", "as", "$", "items_index", "=>", "$", "item", ")", "{", "foreach", "(", "$", "item", "->", "classes", "as", "$", "index", "=>", "$", "class", ")", "{", "if", "(", "false", "===", "strpos", "(", "$", "class", ",", "'current'", ")", ")", "{", "continue", ";", "}", "unset", "(", "$", "items", "[", "$", "items_index", "]", "->", "classes", "[", "$", "index", "]", ")", ";", "}", "}", "return", "$", "items", ";", "}" ]
Remove current classes @param string $items The menu items, sorted by each menu item's menu order. @param stdClass $args An object containing wp_nav_menu() arguments. @return string
[ "Remove", "current", "classes" ]
219963582b592eef4bde6cdd4ed1cf0dc71a6114
https://github.com/inc2734/wp-page-speed-optimization/blob/219963582b592eef4bde6cdd4ed1cf0dc71a6114/src/App/Controller/Menu.php#L128-L150
train
Vectrex/vxPHP
src/Debug/Debug.php
Debug.enable
public static function enable($reportingLevel = NULL, $displayErrors = NULL) { if (!static::$enabled) { static::$enabled = true; error_reporting(E_ALL); ErrorHandler::register($reportingLevel, $displayErrors); if (PHP_SAPI !== 'cli') { ExceptionHandler::register($reportingLevel, $displayErrors); } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { ini_set('display_errors', 1); } } }
php
public static function enable($reportingLevel = NULL, $displayErrors = NULL) { if (!static::$enabled) { static::$enabled = true; error_reporting(E_ALL); ErrorHandler::register($reportingLevel, $displayErrors); if (PHP_SAPI !== 'cli') { ExceptionHandler::register($reportingLevel, $displayErrors); } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { ini_set('display_errors', 1); } } }
[ "public", "static", "function", "enable", "(", "$", "reportingLevel", "=", "NULL", ",", "$", "displayErrors", "=", "NULL", ")", "{", "if", "(", "!", "static", "::", "$", "enabled", ")", "{", "static", "::", "$", "enabled", "=", "true", ";", "error_reporting", "(", "E_ALL", ")", ";", "ErrorHandler", "::", "register", "(", "$", "reportingLevel", ",", "$", "displayErrors", ")", ";", "if", "(", "PHP_SAPI", "!==", "'cli'", ")", "{", "ExceptionHandler", "::", "register", "(", "$", "reportingLevel", ",", "$", "displayErrors", ")", ";", "}", "elseif", "(", "$", "displayErrors", "&&", "(", "!", "ini_get", "(", "'log_errors'", ")", "||", "ini_get", "(", "'error_log'", ")", ")", ")", "{", "ini_set", "(", "'display_errors'", ",", "1", ")", ";", "}", "}", "}" ]
activate custom debugging registers error handler and exception handler @param integer $reportingLevel @param boolean $displayErrors
[ "activate", "custom", "debugging", "registers", "error", "handler", "and", "exception", "handler" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Debug/Debug.php#L30-L47
train
miknatr/grace-dbal
lib/Grace/SQLBuilder/WhereBuilderAbstract.php
WhereBuilderAbstract.sql
public function sql($sql, array $values = array()) { $this->whereSqlConditions[] = $sql; $this->arguments = array_merge($this->arguments, $values); return $this; }
php
public function sql($sql, array $values = array()) { $this->whereSqlConditions[] = $sql; $this->arguments = array_merge($this->arguments, $values); return $this; }
[ "public", "function", "sql", "(", "$", "sql", ",", "array", "$", "values", "=", "array", "(", ")", ")", "{", "$", "this", "->", "whereSqlConditions", "[", "]", "=", "$", "sql", ";", "$", "this", "->", "arguments", "=", "array_merge", "(", "$", "this", "->", "arguments", ",", "$", "values", ")", ";", "return", "$", "this", ";", "}" ]
Adds sql statement into where statement @param $sql @param array $values @return $this
[ "Adds", "sql", "statement", "into", "where", "statement" ]
b05e03040568631dc6c77477c0eaed6e60db4ba2
https://github.com/miknatr/grace-dbal/blob/b05e03040568631dc6c77477c0eaed6e60db4ba2/lib/Grace/SQLBuilder/WhereBuilderAbstract.php#L27-L32
train
miknatr/grace-dbal
lib/Grace/SQLBuilder/WhereBuilderAbstract.php
WhereBuilderAbstract.like
public function like($field, $value) { $operator = ' ' . $this->executable->provideSqlDialect()->likeOperator() . ' '; return $this->setTwoArgsOperator($field, $value, $operator); }
php
public function like($field, $value) { $operator = ' ' . $this->executable->provideSqlDialect()->likeOperator() . ' '; return $this->setTwoArgsOperator($field, $value, $operator); }
[ "public", "function", "like", "(", "$", "field", ",", "$", "value", ")", "{", "$", "operator", "=", "' '", ".", "$", "this", "->", "executable", "->", "provideSqlDialect", "(", ")", "->", "likeOperator", "(", ")", ".", "' '", ";", "return", "$", "this", "->", "setTwoArgsOperator", "(", "$", "field", ",", "$", "value", ",", "$", "operator", ")", ";", "}" ]
Adds LIKE statement into where statement @param $field @param $value @return $this
[ "Adds", "LIKE", "statement", "into", "where", "statement" ]
b05e03040568631dc6c77477c0eaed6e60db4ba2
https://github.com/miknatr/grace-dbal/blob/b05e03040568631dc6c77477c0eaed6e60db4ba2/lib/Grace/SQLBuilder/WhereBuilderAbstract.php#L168-L172
train
agentmedia/phine-builtin
src/BuiltIn/Modules/Backend/RegisterSimpleForm.php
RegisterSimpleForm.SaveElement
protected function SaveElement() { $this->register->SetConfirmUrl($this->selectorConfirm->Save($this->register->GetConfirmUrl())); $this->register->SetNextUrl($this->selectorNext->Save($this->register->GetNextUrl())); $this->register->SetMailFrom($this->Value('MailFrom')); $this->register->SetMailText1($this->Value('MailText1')); $this->register->SetMailText2($this->Value('MailText2')); $this->register->SetMailSubject($this->Value('MailSubject')); $this->register->SetMailStyles($this->Value('MailStyles')); return $this->register; }
php
protected function SaveElement() { $this->register->SetConfirmUrl($this->selectorConfirm->Save($this->register->GetConfirmUrl())); $this->register->SetNextUrl($this->selectorNext->Save($this->register->GetNextUrl())); $this->register->SetMailFrom($this->Value('MailFrom')); $this->register->SetMailText1($this->Value('MailText1')); $this->register->SetMailText2($this->Value('MailText2')); $this->register->SetMailSubject($this->Value('MailSubject')); $this->register->SetMailStyles($this->Value('MailStyles')); return $this->register; }
[ "protected", "function", "SaveElement", "(", ")", "{", "$", "this", "->", "register", "->", "SetConfirmUrl", "(", "$", "this", "->", "selectorConfirm", "->", "Save", "(", "$", "this", "->", "register", "->", "GetConfirmUrl", "(", ")", ")", ")", ";", "$", "this", "->", "register", "->", "SetNextUrl", "(", "$", "this", "->", "selectorNext", "->", "Save", "(", "$", "this", "->", "register", "->", "GetNextUrl", "(", ")", ")", ")", ";", "$", "this", "->", "register", "->", "SetMailFrom", "(", "$", "this", "->", "Value", "(", "'MailFrom'", ")", ")", ";", "$", "this", "->", "register", "->", "SetMailText1", "(", "$", "this", "->", "Value", "(", "'MailText1'", ")", ")", ";", "$", "this", "->", "register", "->", "SetMailText2", "(", "$", "this", "->", "Value", "(", "'MailText2'", ")", ")", ";", "$", "this", "->", "register", "->", "SetMailSubject", "(", "$", "this", "->", "Value", "(", "'MailSubject'", ")", ")", ";", "$", "this", "->", "register", "->", "SetMailStyles", "(", "$", "this", "->", "Value", "(", "'MailStyles'", ")", ")", ";", "return", "$", "this", "->", "register", ";", "}" ]
Saves the simple register element @return ContentRegisterSimple
[ "Saves", "the", "simple", "register", "element" ]
4dd05bc406a71e997bd4eaa16b12e23dbe62a456
https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Backend/RegisterSimpleForm.php#L160-L170
train
translationexchange/tml-php-clientsdk
library/Tr8n/Utils/HtmlTranslator.php
HtmlTranslator.prepareHtml
function prepareHtml() { // remove all tabs and new lines - as they mean nothing in HTML $this->html = trim(preg_replace('/\t\n/', '', $this->html)); // normalize multiple spaces to one space $this->html = preg_replace('/\s+/', ' ', $this->html); // replace special characters like &nbsp; $this->html = $this->replaceSpecialCharacters($this->html); // $charset = 'UTF-8'; // if (function_exists('mb_convert_encoding') && in_array(strtolower($charset), array_map('strtolower', mb_list_encodings()))) { // $this->html = mb_convert_encoding($this->html, 'HTML-ENTITIES', $charset); // } }
php
function prepareHtml() { // remove all tabs and new lines - as they mean nothing in HTML $this->html = trim(preg_replace('/\t\n/', '', $this->html)); // normalize multiple spaces to one space $this->html = preg_replace('/\s+/', ' ', $this->html); // replace special characters like &nbsp; $this->html = $this->replaceSpecialCharacters($this->html); // $charset = 'UTF-8'; // if (function_exists('mb_convert_encoding') && in_array(strtolower($charset), array_map('strtolower', mb_list_encodings()))) { // $this->html = mb_convert_encoding($this->html, 'HTML-ENTITIES', $charset); // } }
[ "function", "prepareHtml", "(", ")", "{", "// remove all tabs and new lines - as they mean nothing in HTML", "$", "this", "->", "html", "=", "trim", "(", "preg_replace", "(", "'/\\t\\n/'", ",", "''", ",", "$", "this", "->", "html", ")", ")", ";", "// normalize multiple spaces to one space", "$", "this", "->", "html", "=", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "$", "this", "->", "html", ")", ";", "// replace special characters like &nbsp;", "$", "this", "->", "html", "=", "$", "this", "->", "replaceSpecialCharacters", "(", "$", "this", "->", "html", ")", ";", "// $charset = 'UTF-8';", "// if (function_exists('mb_convert_encoding') && in_array(strtolower($charset), array_map('strtolower', mb_list_encodings()))) {", "// $this->html = mb_convert_encoding($this->html, 'HTML-ENTITIES', $charset);", "// }", "}" ]
Prepares HTML for processing
[ "Prepares", "HTML", "for", "processing" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Utils/HtmlTranslator.php#L94-L109
train
translationexchange/tml-php-clientsdk
library/Tr8n/Utils/HtmlTranslator.php
HtmlTranslator.parseDocument
function parseDocument() { $this->prepareHtml(); $current = libxml_use_internal_errors(true); $disableEntities = libxml_disable_entity_loader(true); $charset = 'UTF-8'; $this->doc = new \DOMDocument('1.0', $charset); $this->doc->strictErrorChecking = false; @$this->doc->loadHTML($this->html); libxml_use_internal_errors($current); libxml_disable_entity_loader($disableEntities); }
php
function parseDocument() { $this->prepareHtml(); $current = libxml_use_internal_errors(true); $disableEntities = libxml_disable_entity_loader(true); $charset = 'UTF-8'; $this->doc = new \DOMDocument('1.0', $charset); $this->doc->strictErrorChecking = false; @$this->doc->loadHTML($this->html); libxml_use_internal_errors($current); libxml_disable_entity_loader($disableEntities); }
[ "function", "parseDocument", "(", ")", "{", "$", "this", "->", "prepareHtml", "(", ")", ";", "$", "current", "=", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "disableEntities", "=", "libxml_disable_entity_loader", "(", "true", ")", ";", "$", "charset", "=", "'UTF-8'", ";", "$", "this", "->", "doc", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "$", "charset", ")", ";", "$", "this", "->", "doc", "->", "strictErrorChecking", "=", "false", ";", "@", "$", "this", "->", "doc", "->", "loadHTML", "(", "$", "this", "->", "html", ")", ";", "libxml_use_internal_errors", "(", "$", "current", ")", ";", "libxml_disable_entity_loader", "(", "$", "disableEntities", ")", ";", "}" ]
Parses the HTML document
[ "Parses", "the", "HTML", "document" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Utils/HtmlTranslator.php#L114-L128
train
translationexchange/tml-php-clientsdk
library/Tr8n/Utils/HtmlTranslator.php
HtmlTranslator.generateTmlTags
private function generateTmlTags($node) { $buffer = ""; foreach($node->childNodes as $child) { if ($child->nodeType == 3) { // text node $buffer = $buffer . $child->wholeText; } else { $buffer = $buffer . $this->generateTmlTags($child); } } $token_context = $this->generateHtmlToken($node); $token = $this->adjustName($node); $token = $this->contextualize($token, $token_context); $value = $this->sanitizeValue($buffer); if ($this->isSelfClosingNode($node)) return '{'.$token.'}'; if ($this->isShortToken($token, $value)) return '['.$token.': '.$value.']'; return '['.$token.']'.$value.'[/'.$token.']'; }
php
private function generateTmlTags($node) { $buffer = ""; foreach($node->childNodes as $child) { if ($child->nodeType == 3) { // text node $buffer = $buffer . $child->wholeText; } else { $buffer = $buffer . $this->generateTmlTags($child); } } $token_context = $this->generateHtmlToken($node); $token = $this->adjustName($node); $token = $this->contextualize($token, $token_context); $value = $this->sanitizeValue($buffer); if ($this->isSelfClosingNode($node)) return '{'.$token.'}'; if ($this->isShortToken($token, $value)) return '['.$token.': '.$value.']'; return '['.$token.']'.$value.'[/'.$token.']'; }
[ "private", "function", "generateTmlTags", "(", "$", "node", ")", "{", "$", "buffer", "=", "\"\"", ";", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "nodeType", "==", "3", ")", "{", "// text node", "$", "buffer", "=", "$", "buffer", ".", "$", "child", "->", "wholeText", ";", "}", "else", "{", "$", "buffer", "=", "$", "buffer", ".", "$", "this", "->", "generateTmlTags", "(", "$", "child", ")", ";", "}", "}", "$", "token_context", "=", "$", "this", "->", "generateHtmlToken", "(", "$", "node", ")", ";", "$", "token", "=", "$", "this", "->", "adjustName", "(", "$", "node", ")", ";", "$", "token", "=", "$", "this", "->", "contextualize", "(", "$", "token", ",", "$", "token_context", ")", ";", "$", "value", "=", "$", "this", "->", "sanitizeValue", "(", "$", "buffer", ")", ";", "if", "(", "$", "this", "->", "isSelfClosingNode", "(", "$", "node", ")", ")", "return", "'{'", ".", "$", "token", ".", "'}'", ";", "if", "(", "$", "this", "->", "isShortToken", "(", "$", "token", ",", "$", "value", ")", ")", "return", "'['", ".", "$", "token", ".", "': '", ".", "$", "value", ".", "']'", ";", "return", "'['", ".", "$", "token", ".", "']'", ".", "$", "value", ".", "'[/'", ".", "$", "token", ".", "']'", ";", "}" ]
TML nodes can be nested - but they CANNOT contain non-inline nodes @param $node @return string
[ "TML", "nodes", "can", "be", "nested", "-", "but", "they", "CANNOT", "contain", "non", "-", "inline", "nodes" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Utils/HtmlTranslator.php#L218-L241
train
translationexchange/tml-php-clientsdk
library/Tr8n/Utils/HtmlTranslator.php
HtmlTranslator.resetContext
private function resetContext() { $this->debug_tokens = $this->tokens; $this->tokens = array_merge(array(), $this->context); }
php
private function resetContext() { $this->debug_tokens = $this->tokens; $this->tokens = array_merge(array(), $this->context); }
[ "private", "function", "resetContext", "(", ")", "{", "$", "this", "->", "debug_tokens", "=", "$", "this", "->", "tokens", ";", "$", "this", "->", "tokens", "=", "array_merge", "(", "array", "(", ")", ",", "$", "this", "->", "context", ")", ";", "}" ]
Resets context of the current translation
[ "Resets", "context", "of", "the", "current", "translation" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Utils/HtmlTranslator.php#L275-L278
train
irfantoor/engine
src/Http/Cookie.php
Cookie.send
function send() { if (!headers_sent()) { extract($this->toArray()); setcookie($name, $value, $expires, $path, $domain, $secure, $httponly); } }
php
function send() { if (!headers_sent()) { extract($this->toArray()); setcookie($name, $value, $expires, $path, $domain, $secure, $httponly); } }
[ "function", "send", "(", ")", "{", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "extract", "(", "$", "this", "->", "toArray", "(", ")", ")", ";", "setcookie", "(", "$", "name", ",", "$", "value", ",", "$", "expires", ",", "$", "path", ",", "$", "domain", ",", "$", "secure", ",", "$", "httponly", ")", ";", "}", "}" ]
Sets the cookie to be sent by the headers
[ "Sets", "the", "cookie", "to", "be", "sent", "by", "the", "headers" ]
4d2d221add749f75100d0b4ffe1488cdbf7af5d3
https://github.com/irfantoor/engine/blob/4d2d221add749f75100d0b4ffe1488cdbf7af5d3/src/Http/Cookie.php#L80-L86
train
romm/configuration_object
Classes/Service/Items/MixedTypes/MixedTypesResolver.php
MixedTypesResolver.addError
public function addError(Error $error) { $this->result->addError($error); $this->setObjectType(self::OBJECT_TYPE_NONE); }
php
public function addError(Error $error) { $this->result->addError($error); $this->setObjectType(self::OBJECT_TYPE_NONE); }
[ "public", "function", "addError", "(", "Error", "$", "error", ")", "{", "$", "this", "->", "result", "->", "addError", "(", "$", "error", ")", ";", "$", "this", "->", "setObjectType", "(", "self", "::", "OBJECT_TYPE_NONE", ")", ";", "}" ]
Adds an error to the processor, which may then be merged with the errors of the property being currently mapped. It will also set the object type to `null`, because if there is an error, the property can probably not being converted correctly. @param Error $error
[ "Adds", "an", "error", "to", "the", "processor", "which", "may", "then", "be", "merged", "with", "the", "errors", "of", "the", "property", "being", "currently", "mapped", "." ]
d3a40903386c2e0766bd8279337fe6da45cf5ce3
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/Items/MixedTypes/MixedTypesResolver.php#L67-L71
train
modulusphp/http
Session.php
Session.key
public static function key($key, $value = null) { if ($value == null) return $_SESSION[$key]; $_SESSION[$key] = $value; }
php
public static function key($key, $value = null) { if ($value == null) return $_SESSION[$key]; $_SESSION[$key] = $value; }
[ "public", "static", "function", "key", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "value", "==", "null", ")", "return", "$", "_SESSION", "[", "$", "key", "]", ";", "$", "_SESSION", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Set or get session key @param mixed $key @param mixed $value @return void
[ "Set", "or", "get", "session", "key" ]
fc5c0f2b582a04de1685578d3fb790686a0a240c
https://github.com/modulusphp/http/blob/fc5c0f2b582a04de1685578d3fb790686a0a240c/Session.php#L42-L47
train
modulusphp/http
Session.php
Session.flash
public static function flash(string $key, $value = null) { /** * Check if session already has variables. * * If variables have already been set, merge the new * variables with the old ones. */ return $_SESSION['application']['with'] = array_merge( isset($_SESSION['application']['with']) ? $_SESSION['application']['with'] : [], [$key => $value] ); }
php
public static function flash(string $key, $value = null) { /** * Check if session already has variables. * * If variables have already been set, merge the new * variables with the old ones. */ return $_SESSION['application']['with'] = array_merge( isset($_SESSION['application']['with']) ? $_SESSION['application']['with'] : [], [$key => $value] ); }
[ "public", "static", "function", "flash", "(", "string", "$", "key", ",", "$", "value", "=", "null", ")", "{", "/**\n * Check if session already has variables.\n *\n * If variables have already been set, merge the new\n * variables with the old ones.\n */", "return", "$", "_SESSION", "[", "'application'", "]", "[", "'with'", "]", "=", "array_merge", "(", "isset", "(", "$", "_SESSION", "[", "'application'", "]", "[", "'with'", "]", ")", "?", "$", "_SESSION", "[", "'application'", "]", "[", "'with'", "]", ":", "[", "]", ",", "[", "$", "key", "=>", "$", "value", "]", ")", ";", "}" ]
Create a flash message @param string $key @param mixed $value @return
[ "Create", "a", "flash", "message" ]
fc5c0f2b582a04de1685578d3fb790686a0a240c
https://github.com/modulusphp/http/blob/fc5c0f2b582a04de1685578d3fb790686a0a240c/Session.php#L56-L68
train
libreworks/caridea-validate
src/Registry.php
Registry.register
public function register(array $definitions): self { foreach ($definitions as $name => $callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException('Values passed to register must be callable'); } $this->definitions[$name] = $callback; } return $this; }
php
public function register(array $definitions): self { foreach ($definitions as $name => $callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException('Values passed to register must be callable'); } $this->definitions[$name] = $callback; } return $this; }
[ "public", "function", "register", "(", "array", "$", "definitions", ")", ":", "self", "{", "foreach", "(", "$", "definitions", "as", "$", "name", "=>", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Values passed to register must be callable'", ")", ";", "}", "$", "this", "->", "definitions", "[", "$", "name", "]", "=", "$", "callback", ";", "}", "return", "$", "this", ";", "}" ]
Registers rule definitions. ```php $registry = new \Caridea\Validate\Registry(); $registry->register([ 'adult' => ['My\Validate\AgeRule', 'adult'], 'credit_card' => function(){return new CreditCardRule();}, 'something' => 'my_function_that_can_be_called' ]); ``` @param array<string,callable> $definitions Associative array of definition name to function callback @return $this provides a fluent interface
[ "Registers", "rule", "definitions", "." ]
625835694d34591bfb1e3b2ce60c2cc28a28d006
https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Registry.php#L96-L105
train
libreworks/caridea-validate
src/Registry.php
Registry.alias
public function alias(string $name, $rules, ?string $error = null): self { $this->definitions[$name] = function () use ($rules, $error) { return $this->parser->parse($rules)->setError($error); }; return $this; }
php
public function alias(string $name, $rules, ?string $error = null): self { $this->definitions[$name] = function () use ($rules, $error) { return $this->parser->parse($rules)->setError($error); }; return $this; }
[ "public", "function", "alias", "(", "string", "$", "name", ",", "$", "rules", ",", "?", "string", "$", "error", "=", "null", ")", ":", "self", "{", "$", "this", "->", "definitions", "[", "$", "name", "]", "=", "function", "(", ")", "use", "(", "$", "rules", ",", "$", "error", ")", "{", "return", "$", "this", "->", "parser", "->", "parse", "(", "$", "rules", ")", "->", "setError", "(", "$", "error", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Registers an alias for a ruleset. @param string $name The name of the alias @param object|array $rules The ruleset to alias @param string|null $error A custom error code to return, or `null` to use normal codes @return $this provides a fluent interface
[ "Registers", "an", "alias", "for", "a", "ruleset", "." ]
625835694d34591bfb1e3b2ce60c2cc28a28d006
https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Registry.php#L115-L121
train
libreworks/caridea-validate
src/Registry.php
Registry.aliasDefinition
public function aliasDefinition($definition): self { if (is_object($definition)) { $definition = (array) $definition; } if (!is_array($definition)) { throw new \InvalidArgumentException("Invalid alias definition: must be an object or an associative array"); } if (!isset($definition['name']) || !isset($definition['rules'])) { throw new \InvalidArgumentException("Invalid alias definition: must have 'name' and 'rules' fields"); } return $this->alias($definition['name'], $definition['rules'], $definition['error'] ?? null); }
php
public function aliasDefinition($definition): self { if (is_object($definition)) { $definition = (array) $definition; } if (!is_array($definition)) { throw new \InvalidArgumentException("Invalid alias definition: must be an object or an associative array"); } if (!isset($definition['name']) || !isset($definition['rules'])) { throw new \InvalidArgumentException("Invalid alias definition: must have 'name' and 'rules' fields"); } return $this->alias($definition['name'], $definition['rules'], $definition['error'] ?? null); }
[ "public", "function", "aliasDefinition", "(", "$", "definition", ")", ":", "self", "{", "if", "(", "is_object", "(", "$", "definition", ")", ")", "{", "$", "definition", "=", "(", "array", ")", "$", "definition", ";", "}", "if", "(", "!", "is_array", "(", "$", "definition", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid alias definition: must be an object or an associative array\"", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "definition", "[", "'name'", "]", ")", "||", "!", "isset", "(", "$", "definition", "[", "'rules'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid alias definition: must have 'name' and 'rules' fields\"", ")", ";", "}", "return", "$", "this", "->", "alias", "(", "$", "definition", "[", "'name'", "]", ",", "$", "definition", "[", "'rules'", "]", ",", "$", "definition", "[", "'error'", "]", "??", "null", ")", ";", "}" ]
Registers an alias for a ruleset, using a LIVR-compliant definition. ```javascript // alias.json { "name": "valid_address", "rules": { "nested_object": { "country": "required", "city": "required", "zip": "positive_integer" }}, error: "WRONG_ADDRESS" } ``` ```php $registry->aliasDefinition(json_decode(file_get_contents('alias.json'))); ``` @param array|object $definition The rule definition @return $this provides a fluent interface @throws \InvalidArgumentException if the definition is invalid
[ "Registers", "an", "alias", "for", "a", "ruleset", "using", "a", "LIVR", "-", "compliant", "definition", "." ]
625835694d34591bfb1e3b2ce60c2cc28a28d006
https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Registry.php#L146-L158
train
libreworks/caridea-validate
src/Registry.php
Registry.factory
public function factory(string $name, $arg = null): Rule { if (!array_key_exists($name, $this->definitions)) { throw new \InvalidArgumentException("No rule registered with name: $name"); } $vrule = is_array($arg) ? call_user_func_array($this->definitions[$name], $arg) : call_user_func($this->definitions[$name], $arg); if (!$vrule instanceof Rule) { throw new \UnexpectedValueException('Definitions must return Rule objects'); } return $vrule; }
php
public function factory(string $name, $arg = null): Rule { if (!array_key_exists($name, $this->definitions)) { throw new \InvalidArgumentException("No rule registered with name: $name"); } $vrule = is_array($arg) ? call_user_func_array($this->definitions[$name], $arg) : call_user_func($this->definitions[$name], $arg); if (!$vrule instanceof Rule) { throw new \UnexpectedValueException('Definitions must return Rule objects'); } return $vrule; }
[ "public", "function", "factory", "(", "string", "$", "name", ",", "$", "arg", "=", "null", ")", ":", "Rule", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "definitions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"No rule registered with name: $name\"", ")", ";", "}", "$", "vrule", "=", "is_array", "(", "$", "arg", ")", "?", "call_user_func_array", "(", "$", "this", "->", "definitions", "[", "$", "name", "]", ",", "$", "arg", ")", ":", "call_user_func", "(", "$", "this", "->", "definitions", "[", "$", "name", "]", ",", "$", "arg", ")", ";", "if", "(", "!", "$", "vrule", "instanceof", "Rule", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Definitions must return Rule objects'", ")", ";", "}", "return", "$", "vrule", ";", "}" ]
Constructs a validation rule. @param string $name A string name @param mixed $arg Optional constructor argument, or an array of arguments @return \Caridea\Validate\Rule The instantiated rule @throws \InvalidArgumentException if the rule name is not registered @throws \UnexpectedValueException if the factory returns a non-Rule
[ "Constructs", "a", "validation", "rule", "." ]
625835694d34591bfb1e3b2ce60c2cc28a28d006
https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Registry.php#L169-L181
train
WellCommerce/DistributionBundle
Composer/HerokuEnvironment.php
HerokuEnvironment.populateEnvironment
public static function populateEnvironment(Event $event) { $url = getenv('CLEARDB_DATABASE_URL'); if ($url) { $url = parse_url($url); putenv("SYMFONY_DATABASE_HOST={$url['host']}"); putenv("SYMFONY_DATABASE_USER={$url['user']}"); putenv("SYMFONY_DATABASE_PASSWORD={$url['pass']}"); $db = substr($url['path'], 1); putenv("SYMFONY_DATABASE_NAME={$db}"); putenv("SYMFONY_PROD_LOG_PATH=php://stderr"); $io = $event->getIO(); $io->write('CLEARDB_DATABASE_URL=' . getenv('CLEARDB_DATABASE_URL')); $io->write('SYMFONY_PROD_LOG_PATH=' . getenv('SYMFONY_PROD_LOG_PATH')); } }
php
public static function populateEnvironment(Event $event) { $url = getenv('CLEARDB_DATABASE_URL'); if ($url) { $url = parse_url($url); putenv("SYMFONY_DATABASE_HOST={$url['host']}"); putenv("SYMFONY_DATABASE_USER={$url['user']}"); putenv("SYMFONY_DATABASE_PASSWORD={$url['pass']}"); $db = substr($url['path'], 1); putenv("SYMFONY_DATABASE_NAME={$db}"); putenv("SYMFONY_PROD_LOG_PATH=php://stderr"); $io = $event->getIO(); $io->write('CLEARDB_DATABASE_URL=' . getenv('CLEARDB_DATABASE_URL')); $io->write('SYMFONY_PROD_LOG_PATH=' . getenv('SYMFONY_PROD_LOG_PATH')); } }
[ "public", "static", "function", "populateEnvironment", "(", "Event", "$", "event", ")", "{", "$", "url", "=", "getenv", "(", "'CLEARDB_DATABASE_URL'", ")", ";", "if", "(", "$", "url", ")", "{", "$", "url", "=", "parse_url", "(", "$", "url", ")", ";", "putenv", "(", "\"SYMFONY_DATABASE_HOST={$url['host']}\"", ")", ";", "putenv", "(", "\"SYMFONY_DATABASE_USER={$url['user']}\"", ")", ";", "putenv", "(", "\"SYMFONY_DATABASE_PASSWORD={$url['pass']}\"", ")", ";", "$", "db", "=", "substr", "(", "$", "url", "[", "'path'", "]", ",", "1", ")", ";", "putenv", "(", "\"SYMFONY_DATABASE_NAME={$db}\"", ")", ";", "putenv", "(", "\"SYMFONY_PROD_LOG_PATH=php://stderr\"", ")", ";", "$", "io", "=", "$", "event", "->", "getIO", "(", ")", ";", "$", "io", "->", "write", "(", "'CLEARDB_DATABASE_URL='", ".", "getenv", "(", "'CLEARDB_DATABASE_URL'", ")", ")", ";", "$", "io", "->", "write", "(", "'SYMFONY_PROD_LOG_PATH='", ".", "getenv", "(", "'SYMFONY_PROD_LOG_PATH'", ")", ")", ";", "}", "}" ]
Populate Heroku environment @param Event $event Event
[ "Populate", "Heroku", "environment" ]
82b1b4c2c5a59536aaae22506b23ccd5d141cbb0
https://github.com/WellCommerce/DistributionBundle/blob/82b1b4c2c5a59536aaae22506b23ccd5d141cbb0/Composer/HerokuEnvironment.php#L29-L47
train
praxigento/mobi_mod_downline
Helper/Registry.php
Registry.putQuoteId
public function putQuoteId($data) { if ($this->registry->registry(self::QUOTE_ID)) { $this->registry->unregister(self::QUOTE_ID); } $this->registry->register(self::QUOTE_ID, $data); }
php
public function putQuoteId($data) { if ($this->registry->registry(self::QUOTE_ID)) { $this->registry->unregister(self::QUOTE_ID); } $this->registry->register(self::QUOTE_ID, $data); }
[ "public", "function", "putQuoteId", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "registry", "->", "registry", "(", "self", "::", "QUOTE_ID", ")", ")", "{", "$", "this", "->", "registry", "->", "unregister", "(", "self", "::", "QUOTE_ID", ")", ";", "}", "$", "this", "->", "registry", "->", "register", "(", "self", "::", "QUOTE_ID", ",", "$", "data", ")", ";", "}" ]
Quote ID for newly created orders. @param int $data
[ "Quote", "ID", "for", "newly", "created", "orders", "." ]
0f3c276dfff1aa029f9fd205ccfc56f207a2e75b
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Helper/Registry.php#L62-L68
train
fxpio/fxp-default-value-bundle
DependencyInjection/Compiler/DefaultValuePass.php
DefaultValuePass.findTags
protected function findTags(ContainerBuilder $container, $tagName, $argumentPosition, $ext = false): void { $services = []; foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tag) { $class = isset($tag[0]['class']) ? $this->getRealClassName($container, $tag[0]['class']) : $this->getClassName($container, $serviceId, $tagName); $class = $this->findResolveTarget($container, $class); $this->replaceResolveTargetClass($container, $tagName, $serviceId, $class); // Flip, because we want tag classe names (= type identifiers) as keys if ($ext) { $services[$class][] = $serviceId; } else { $services[$class] = $serviceId; } } $container->getDefinition('fxp_default_value.extension')->replaceArgument($argumentPosition, $services); }
php
protected function findTags(ContainerBuilder $container, $tagName, $argumentPosition, $ext = false): void { $services = []; foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tag) { $class = isset($tag[0]['class']) ? $this->getRealClassName($container, $tag[0]['class']) : $this->getClassName($container, $serviceId, $tagName); $class = $this->findResolveTarget($container, $class); $this->replaceResolveTargetClass($container, $tagName, $serviceId, $class); // Flip, because we want tag classe names (= type identifiers) as keys if ($ext) { $services[$class][] = $serviceId; } else { $services[$class] = $serviceId; } } $container->getDefinition('fxp_default_value.extension')->replaceArgument($argumentPosition, $services); }
[ "protected", "function", "findTags", "(", "ContainerBuilder", "$", "container", ",", "$", "tagName", ",", "$", "argumentPosition", ",", "$", "ext", "=", "false", ")", ":", "void", "{", "$", "services", "=", "[", "]", ";", "foreach", "(", "$", "container", "->", "findTaggedServiceIds", "(", "$", "tagName", ")", "as", "$", "serviceId", "=>", "$", "tag", ")", "{", "$", "class", "=", "isset", "(", "$", "tag", "[", "0", "]", "[", "'class'", "]", ")", "?", "$", "this", "->", "getRealClassName", "(", "$", "container", ",", "$", "tag", "[", "0", "]", "[", "'class'", "]", ")", ":", "$", "this", "->", "getClassName", "(", "$", "container", ",", "$", "serviceId", ",", "$", "tagName", ")", ";", "$", "class", "=", "$", "this", "->", "findResolveTarget", "(", "$", "container", ",", "$", "class", ")", ";", "$", "this", "->", "replaceResolveTargetClass", "(", "$", "container", ",", "$", "tagName", ",", "$", "serviceId", ",", "$", "class", ")", ";", "// Flip, because we want tag classe names (= type identifiers) as keys", "if", "(", "$", "ext", ")", "{", "$", "services", "[", "$", "class", "]", "[", "]", "=", "$", "serviceId", ";", "}", "else", "{", "$", "services", "[", "$", "class", "]", "=", "$", "serviceId", ";", "}", "}", "$", "container", "->", "getDefinition", "(", "'fxp_default_value.extension'", ")", "->", "replaceArgument", "(", "$", "argumentPosition", ",", "$", "services", ")", ";", "}" ]
Find service tags. @param ContainerBuilder $container @param string $tagName @param int $argumentPosition @param bool $ext @throws InvalidConfigurationException
[ "Find", "service", "tags", "." ]
f2610281aa59b3d841931dc952af79664a6fc063
https://github.com/fxpio/fxp-default-value-bundle/blob/f2610281aa59b3d841931dc952af79664a6fc063/DependencyInjection/Compiler/DefaultValuePass.php#L59-L79
train
fxpio/fxp-default-value-bundle
DependencyInjection/Compiler/DefaultValuePass.php
DefaultValuePass.getRealClassName
protected function getRealClassName(ContainerBuilder $container, $classname) { return 0 === strpos($classname, '%') ? $container->getParameter(trim($classname, '%')) : $classname; }
php
protected function getRealClassName(ContainerBuilder $container, $classname) { return 0 === strpos($classname, '%') ? $container->getParameter(trim($classname, '%')) : $classname; }
[ "protected", "function", "getRealClassName", "(", "ContainerBuilder", "$", "container", ",", "$", "classname", ")", "{", "return", "0", "===", "strpos", "(", "$", "classname", ",", "'%'", ")", "?", "$", "container", "->", "getParameter", "(", "trim", "(", "$", "classname", ",", "'%'", ")", ")", ":", "$", "classname", ";", "}" ]
Get the real class name. @param ContainerBuilder $container The container @param string $classname The class name or the parameter name of classname @return string
[ "Get", "the", "real", "class", "name", "." ]
f2610281aa59b3d841931dc952af79664a6fc063
https://github.com/fxpio/fxp-default-value-bundle/blob/f2610281aa59b3d841931dc952af79664a6fc063/DependencyInjection/Compiler/DefaultValuePass.php#L89-L92
train
fxpio/fxp-default-value-bundle
DependencyInjection/Compiler/DefaultValuePass.php
DefaultValuePass.getClassName
protected function getClassName(ContainerBuilder $container, $serviceId, $tagName) { $type = $container->getDefinition($serviceId); $interfaces = class_implements($type->getClass()); if (\in_array(ObjectTypeExtensionInterface::class, $interfaces, true)) { throw new InvalidConfigurationException(sprintf('The service id "%s" must have the "class" parameter in the "%s" tag.', $serviceId, $tagName)); } if (!\in_array(ObjectTypeInterface::class, $interfaces, true)) { throw new InvalidConfigurationException(sprintf('The service id "%s" must an instance of "%s"', $serviceId, 'Fxp\Component\DefaultValue\ObjectTypeInterface')); } return $this->buildInstanceType($type, $serviceId, $tagName)->getClass(); }
php
protected function getClassName(ContainerBuilder $container, $serviceId, $tagName) { $type = $container->getDefinition($serviceId); $interfaces = class_implements($type->getClass()); if (\in_array(ObjectTypeExtensionInterface::class, $interfaces, true)) { throw new InvalidConfigurationException(sprintf('The service id "%s" must have the "class" parameter in the "%s" tag.', $serviceId, $tagName)); } if (!\in_array(ObjectTypeInterface::class, $interfaces, true)) { throw new InvalidConfigurationException(sprintf('The service id "%s" must an instance of "%s"', $serviceId, 'Fxp\Component\DefaultValue\ObjectTypeInterface')); } return $this->buildInstanceType($type, $serviceId, $tagName)->getClass(); }
[ "protected", "function", "getClassName", "(", "ContainerBuilder", "$", "container", ",", "$", "serviceId", ",", "$", "tagName", ")", "{", "$", "type", "=", "$", "container", "->", "getDefinition", "(", "$", "serviceId", ")", ";", "$", "interfaces", "=", "class_implements", "(", "$", "type", "->", "getClass", "(", ")", ")", ";", "if", "(", "\\", "in_array", "(", "ObjectTypeExtensionInterface", "::", "class", ",", "$", "interfaces", ",", "true", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'The service id \"%s\" must have the \"class\" parameter in the \"%s\" tag.'", ",", "$", "serviceId", ",", "$", "tagName", ")", ")", ";", "}", "if", "(", "!", "\\", "in_array", "(", "ObjectTypeInterface", "::", "class", ",", "$", "interfaces", ",", "true", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'The service id \"%s\" must an instance of \"%s\"'", ",", "$", "serviceId", ",", "'Fxp\\Component\\DefaultValue\\ObjectTypeInterface'", ")", ")", ";", "}", "return", "$", "this", "->", "buildInstanceType", "(", "$", "type", ",", "$", "serviceId", ",", "$", "tagName", ")", "->", "getClass", "(", ")", ";", "}" ]
Get the class name of default value type. @param ContainerBuilder $container The container service @param string $serviceId The service id of default value type @param string $tagName The tag name @throws InvalidConfigurationException When the service is not an instance of Fxp\Component\DefaultValue\ObjectTypeInterface @return string
[ "Get", "the", "class", "name", "of", "default", "value", "type", "." ]
f2610281aa59b3d841931dc952af79664a6fc063
https://github.com/fxpio/fxp-default-value-bundle/blob/f2610281aa59b3d841931dc952af79664a6fc063/DependencyInjection/Compiler/DefaultValuePass.php#L105-L118
train
fxpio/fxp-default-value-bundle
DependencyInjection/Compiler/DefaultValuePass.php
DefaultValuePass.buildInstanceType
protected function buildInstanceType(Definition $type, $serviceId, $tagName) { $parents = class_parents($type->getClass()); $args = $type->getArguments(); $ref = new \ReflectionClass($type); if (\in_array(AbstractSimpleType::class, $parents, true) && (0 === \count($args) || (1 === \count($args) && \is_string($args[0])))) { return $ref->newInstanceArgs($args); } throw new InvalidConfigurationException(sprintf('The service id "%s" must have the "class" parameter in the "%s" tag.', $serviceId, $tagName)); }
php
protected function buildInstanceType(Definition $type, $serviceId, $tagName) { $parents = class_parents($type->getClass()); $args = $type->getArguments(); $ref = new \ReflectionClass($type); if (\in_array(AbstractSimpleType::class, $parents, true) && (0 === \count($args) || (1 === \count($args) && \is_string($args[0])))) { return $ref->newInstanceArgs($args); } throw new InvalidConfigurationException(sprintf('The service id "%s" must have the "class" parameter in the "%s" tag.', $serviceId, $tagName)); }
[ "protected", "function", "buildInstanceType", "(", "Definition", "$", "type", ",", "$", "serviceId", ",", "$", "tagName", ")", "{", "$", "parents", "=", "class_parents", "(", "$", "type", "->", "getClass", "(", ")", ")", ";", "$", "args", "=", "$", "type", "->", "getArguments", "(", ")", ";", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "type", ")", ";", "if", "(", "\\", "in_array", "(", "AbstractSimpleType", "::", "class", ",", "$", "parents", ",", "true", ")", "&&", "(", "0", "===", "\\", "count", "(", "$", "args", ")", "||", "(", "1", "===", "\\", "count", "(", "$", "args", ")", "&&", "\\", "is_string", "(", "$", "args", "[", "0", "]", ")", ")", ")", ")", "{", "return", "$", "ref", "->", "newInstanceArgs", "(", "$", "args", ")", ";", "}", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'The service id \"%s\" must have the \"class\" parameter in the \"%s\" tag.'", ",", "$", "serviceId", ",", "$", "tagName", ")", ")", ";", "}" ]
Build the simple default type instance. @param Definition $type The definition of default value type @param string $serviceId The service id of default value type @param string $tagName The tag name @return ObjectTypeInterface
[ "Build", "the", "simple", "default", "type", "instance", "." ]
f2610281aa59b3d841931dc952af79664a6fc063
https://github.com/fxpio/fxp-default-value-bundle/blob/f2610281aa59b3d841931dc952af79664a6fc063/DependencyInjection/Compiler/DefaultValuePass.php#L129-L141
train
fxpio/fxp-default-value-bundle
DependencyInjection/Compiler/DefaultValuePass.php
DefaultValuePass.findResolveTarget
private function findResolveTarget(ContainerBuilder $container, $class) { $resolveTargets = $this->getResolveTargets($container); if (isset($resolveTargets[$class])) { $class = $resolveTargets[$class]; } return $class; }
php
private function findResolveTarget(ContainerBuilder $container, $class) { $resolveTargets = $this->getResolveTargets($container); if (isset($resolveTargets[$class])) { $class = $resolveTargets[$class]; } return $class; }
[ "private", "function", "findResolveTarget", "(", "ContainerBuilder", "$", "container", ",", "$", "class", ")", "{", "$", "resolveTargets", "=", "$", "this", "->", "getResolveTargets", "(", "$", "container", ")", ";", "if", "(", "isset", "(", "$", "resolveTargets", "[", "$", "class", "]", ")", ")", "{", "$", "class", "=", "$", "resolveTargets", "[", "$", "class", "]", ";", "}", "return", "$", "class", ";", "}" ]
Find the resolve target of class. @param ContainerBuilder $container The container @param string $class The class name @return string
[ "Find", "the", "resolve", "target", "of", "class", "." ]
f2610281aa59b3d841931dc952af79664a6fc063
https://github.com/fxpio/fxp-default-value-bundle/blob/f2610281aa59b3d841931dc952af79664a6fc063/DependencyInjection/Compiler/DefaultValuePass.php#L151-L160
train
fxpio/fxp-default-value-bundle
DependencyInjection/Compiler/DefaultValuePass.php
DefaultValuePass.replaceResolveTargetClass
private function replaceResolveTargetClass(ContainerBuilder $container, $tagName, $serviceId, $class): void { $def = $container->getDefinition($serviceId); $this->replaceClassInArguments($container, $def, $class); $this->replaceClassInTags($def, $tagName, $class); }
php
private function replaceResolveTargetClass(ContainerBuilder $container, $tagName, $serviceId, $class): void { $def = $container->getDefinition($serviceId); $this->replaceClassInArguments($container, $def, $class); $this->replaceClassInTags($def, $tagName, $class); }
[ "private", "function", "replaceResolveTargetClass", "(", "ContainerBuilder", "$", "container", ",", "$", "tagName", ",", "$", "serviceId", ",", "$", "class", ")", ":", "void", "{", "$", "def", "=", "$", "container", "->", "getDefinition", "(", "$", "serviceId", ")", ";", "$", "this", "->", "replaceClassInArguments", "(", "$", "container", ",", "$", "def", ",", "$", "class", ")", ";", "$", "this", "->", "replaceClassInTags", "(", "$", "def", ",", "$", "tagName", ",", "$", "class", ")", ";", "}" ]
Replace the resolve target class. @param ContainerBuilder $container The container service @param string $tagName The tag name @param string $serviceId The service id of default value type @param string $class The class name
[ "Replace", "the", "resolve", "target", "class", "." ]
f2610281aa59b3d841931dc952af79664a6fc063
https://github.com/fxpio/fxp-default-value-bundle/blob/f2610281aa59b3d841931dc952af79664a6fc063/DependencyInjection/Compiler/DefaultValuePass.php#L196-L202
train
WellCommerce/LocaleBundle
Command/DeleteLocaleCommand.php
DeleteLocaleCommand.deleteLocaleData
protected function deleteLocaleData($localeCode, OutputInterface $output) { $entityManager = $this->getDoctrineHelper()->getEntityManager(); $metadata = $this->getDoctrineHelper()->getAllMetadata(); $locale = $this->getLocaleRepository()->findOneBy(['code' => $localeCode]); if (!$locale instanceof LocaleInterface) { throw new InvalidArgumentException(sprintf('Wrong locale code "%s" was given', $localeCode)); } foreach ($metadata as $classMetadata) { $reflectionClass = $classMetadata->getReflectionClass(); if ($reflectionClass->implementsInterface(\WellCommerce\Bundle\LocaleBundle\Entity\LocaleAwareInterface::class)) { $repository = $entityManager->getRepository($reflectionClass->getName()); $this->deleteTranslatableEntities($repository, $locale, $output); } } $entityManager->remove($locale); }
php
protected function deleteLocaleData($localeCode, OutputInterface $output) { $entityManager = $this->getDoctrineHelper()->getEntityManager(); $metadata = $this->getDoctrineHelper()->getAllMetadata(); $locale = $this->getLocaleRepository()->findOneBy(['code' => $localeCode]); if (!$locale instanceof LocaleInterface) { throw new InvalidArgumentException(sprintf('Wrong locale code "%s" was given', $localeCode)); } foreach ($metadata as $classMetadata) { $reflectionClass = $classMetadata->getReflectionClass(); if ($reflectionClass->implementsInterface(\WellCommerce\Bundle\LocaleBundle\Entity\LocaleAwareInterface::class)) { $repository = $entityManager->getRepository($reflectionClass->getName()); $this->deleteTranslatableEntities($repository, $locale, $output); } } $entityManager->remove($locale); }
[ "protected", "function", "deleteLocaleData", "(", "$", "localeCode", ",", "OutputInterface", "$", "output", ")", "{", "$", "entityManager", "=", "$", "this", "->", "getDoctrineHelper", "(", ")", "->", "getEntityManager", "(", ")", ";", "$", "metadata", "=", "$", "this", "->", "getDoctrineHelper", "(", ")", "->", "getAllMetadata", "(", ")", ";", "$", "locale", "=", "$", "this", "->", "getLocaleRepository", "(", ")", "->", "findOneBy", "(", "[", "'code'", "=>", "$", "localeCode", "]", ")", ";", "if", "(", "!", "$", "locale", "instanceof", "LocaleInterface", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Wrong locale code \"%s\" was given'", ",", "$", "localeCode", ")", ")", ";", "}", "foreach", "(", "$", "metadata", "as", "$", "classMetadata", ")", "{", "$", "reflectionClass", "=", "$", "classMetadata", "->", "getReflectionClass", "(", ")", ";", "if", "(", "$", "reflectionClass", "->", "implementsInterface", "(", "\\", "WellCommerce", "\\", "Bundle", "\\", "LocaleBundle", "\\", "Entity", "\\", "LocaleAwareInterface", "::", "class", ")", ")", "{", "$", "repository", "=", "$", "entityManager", "->", "getRepository", "(", "$", "reflectionClass", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "deleteTranslatableEntities", "(", "$", "repository", ",", "$", "locale", ",", "$", "output", ")", ";", "}", "}", "$", "entityManager", "->", "remove", "(", "$", "locale", ")", ";", "}" ]
Deletes the locale @param $localeCode @param OutputInterface $output
[ "Deletes", "the", "locale" ]
da61e059b789ccc748fd3cb0e881780fe6e6d3c6
https://github.com/WellCommerce/LocaleBundle/blob/da61e059b789ccc748fd3cb0e881780fe6e6d3c6/Command/DeleteLocaleCommand.php#L74-L91
train
sil-project/SeedBatchBundle
src/Entity/SeedBatch.php
SeedBatch.setSeedFarm
public function setSeedFarm(\Librinfo\SeedBatchBundle\Entity\SeedFarm $seedFarm = null) { $this->seedFarm = $seedFarm; return $this; }
php
public function setSeedFarm(\Librinfo\SeedBatchBundle\Entity\SeedFarm $seedFarm = null) { $this->seedFarm = $seedFarm; return $this; }
[ "public", "function", "setSeedFarm", "(", "\\", "Librinfo", "\\", "SeedBatchBundle", "\\", "Entity", "\\", "SeedFarm", "$", "seedFarm", "=", "null", ")", "{", "$", "this", "->", "seedFarm", "=", "$", "seedFarm", ";", "return", "$", "this", ";", "}" ]
Set seedFarm. @param \Librinfo\SeedBatchBundle\Entity\SeedFarm $seedFarm @return SeedBatch
[ "Set", "seedFarm", "." ]
a2640b5359fe31d3bdb9c9fa2f72141ac841729c
https://github.com/sil-project/SeedBatchBundle/blob/a2640b5359fe31d3bdb9c9fa2f72141ac841729c/src/Entity/SeedBatch.php#L306-L311
train
bit55/midcore
src/Middleware/ErrorHandler.php
ErrorHandler.createErrorHandler
private function createErrorHandler() { /** * @param int $errno * @param string $errstr * @param string $errfile * @param int $errline * @return void * @throws \ErrorException if error is not within the error_reporting mask. */ return function ($errno, $errstr, $errfile, $errline) { if (! (error_reporting() & $errno)) { // error_reporting does not include this error return; } throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }; }
php
private function createErrorHandler() { /** * @param int $errno * @param string $errstr * @param string $errfile * @param int $errline * @return void * @throws \ErrorException if error is not within the error_reporting mask. */ return function ($errno, $errstr, $errfile, $errline) { if (! (error_reporting() & $errno)) { // error_reporting does not include this error return; } throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }; }
[ "private", "function", "createErrorHandler", "(", ")", "{", "/**\n * @param int $errno\n * @param string $errstr\n * @param string $errfile\n * @param int $errline\n * @return void\n * @throws \\ErrorException if error is not within the error_reporting mask.\n */", "return", "function", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "if", "(", "!", "(", "error_reporting", "(", ")", "&", "$", "errno", ")", ")", "{", "// error_reporting does not include this error", "return", ";", "}", "throw", "new", "\\", "ErrorException", "(", "$", "errstr", ",", "0", ",", "$", "errno", ",", "$", "errfile", ",", "$", "errline", ")", ";", "}", ";", "}" ]
Creates and returns a callable error handler that raises exceptions. Only raises exceptions for errors that are within the error_reporting mask. @return callable
[ "Creates", "and", "returns", "a", "callable", "error", "handler", "that", "raises", "exceptions", "." ]
53f96a82e709918b4691372f0554a6e6f6ba2ae3
https://github.com/bit55/midcore/blob/53f96a82e709918b4691372f0554a6e6f6ba2ae3/src/Middleware/ErrorHandler.php#L47-L65
train
BenGorUser/DoctrineORMBridge
src/BenGorUser/DoctrineORMBridge/Infrastructure/Persistence/EntityManagerFactory.php
EntityManagerFactory.build
public function build($aConnection, array $mappingsPaths = [], $isDevMode = true) { if (empty($mappingsPaths)) { $mappingsPaths = [__DIR__ . '/Mapping']; } Type::addType('user_id', UserIdType::class); Type::addType('user_roles', UserRolesType::class); return EntityManager::create( $aConnection, Setup::createYAMLMetadataConfiguration($mappingsPaths, $isDevMode) ); }
php
public function build($aConnection, array $mappingsPaths = [], $isDevMode = true) { if (empty($mappingsPaths)) { $mappingsPaths = [__DIR__ . '/Mapping']; } Type::addType('user_id', UserIdType::class); Type::addType('user_roles', UserRolesType::class); return EntityManager::create( $aConnection, Setup::createYAMLMetadataConfiguration($mappingsPaths, $isDevMode) ); }
[ "public", "function", "build", "(", "$", "aConnection", ",", "array", "$", "mappingsPaths", "=", "[", "]", ",", "$", "isDevMode", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "mappingsPaths", ")", ")", "{", "$", "mappingsPaths", "=", "[", "__DIR__", ".", "'/Mapping'", "]", ";", "}", "Type", "::", "addType", "(", "'user_id'", ",", "UserIdType", "::", "class", ")", ";", "Type", "::", "addType", "(", "'user_roles'", ",", "UserRolesType", "::", "class", ")", ";", "return", "EntityManager", "::", "create", "(", "$", "aConnection", ",", "Setup", "::", "createYAMLMetadataConfiguration", "(", "$", "mappingsPaths", ",", "$", "isDevMode", ")", ")", ";", "}" ]
Creates an entity manager instance enabling mappings and custom types. @param mixed $aConnection Connection parameters as db driver @param array $mappingsPaths The mapping files diretory paths @param bool $isDevMode Enables the dev mode, by default is enabled @return EntityManager
[ "Creates", "an", "entity", "manager", "instance", "enabling", "mappings", "and", "custom", "types", "." ]
0ad9799a0d7f3502f5b86292d426d83d9c245c86
https://github.com/BenGorUser/DoctrineORMBridge/blob/0ad9799a0d7f3502f5b86292d426d83d9c245c86/src/BenGorUser/DoctrineORMBridge/Infrastructure/Persistence/EntityManagerFactory.php#L37-L50
train
elifesciences/bus-sdk-php
src/Queue/CachedTransformer.php
CachedTransformer.get
public function get(string $type, string $id) { if ($this->shouldCacheEntity($type, $id)) { $key = $this->getKey($type, $id); $this->logger->debug('Fetching from cache', [ 'type' => $type, 'id' => $id, 'key' => $key, ]); if ($item = $this->cache->fetch($key)) { return $this->serializer->deserialize($item, Model::class, 'json'); } } return $this->getFreshDataWithCache(new InternalSqsMessage($type, $id)); }
php
public function get(string $type, string $id) { if ($this->shouldCacheEntity($type, $id)) { $key = $this->getKey($type, $id); $this->logger->debug('Fetching from cache', [ 'type' => $type, 'id' => $id, 'key' => $key, ]); if ($item = $this->cache->fetch($key)) { return $this->serializer->deserialize($item, Model::class, 'json'); } } return $this->getFreshDataWithCache(new InternalSqsMessage($type, $id)); }
[ "public", "function", "get", "(", "string", "$", "type", ",", "string", "$", "id", ")", "{", "if", "(", "$", "this", "->", "shouldCacheEntity", "(", "$", "type", ",", "$", "id", ")", ")", "{", "$", "key", "=", "$", "this", "->", "getKey", "(", "$", "type", ",", "$", "id", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'Fetching from cache'", ",", "[", "'type'", "=>", "$", "type", ",", "'id'", "=>", "$", "id", ",", "'key'", "=>", "$", "key", ",", "]", ")", ";", "if", "(", "$", "item", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "item", ",", "Model", "::", "class", ",", "'json'", ")", ";", "}", "}", "return", "$", "this", "->", "getFreshDataWithCache", "(", "new", "InternalSqsMessage", "(", "$", "type", ",", "$", "id", ")", ")", ";", "}" ]
Get single entity. This method will return an API SDK item when given an ID and Type. If the item should be cached ($this->shouldCache) then we check to see if the item is in the cache. - If the item IS in the cache we return it, never hitting the ApiSDK. - If the item IS NOT in the cache but it CAN be cached we request it from ApiSDK and cache it (see getFreshDataWithCache()) - If the item IS NOT in the cache and SHOULD NOT be cached, we simply query the ApiSDK and return without caching. @return mixed
[ "Get", "single", "entity", "." ]
3af0739fac110e79ea7f21aadf8d17b891f3b918
https://github.com/elifesciences/bus-sdk-php/blob/3af0739fac110e79ea7f21aadf8d17b891f3b918/src/Queue/CachedTransformer.php#L60-L75
train
elifesciences/bus-sdk-php
src/Queue/CachedTransformer.php
CachedTransformer.getFreshDataWithCache
private function getFreshDataWithCache(QueueItem $item) { $sdk = $this->getSdk($item); $entity = $sdk->get($item->getId())->wait(true); if (false === $this->shouldCacheEntity($item->getType(), $item->getId())) { return $entity; } if ($entity) { $this->logger->debug('Saving to cache', [ 'type' => $item->getType(), 'id' => $item->getId(), ]); $this->cache->save( $this->getKeyFromQueueItem($item), $this->serializer->serialize($entity, 'json', ['type' => true]), $this->lifetime ); } else { $this->logger->debug('404 from SDK', [ 'type' => $item->getType(), 'id' => $item->getId(), ]); } return $entity; }
php
private function getFreshDataWithCache(QueueItem $item) { $sdk = $this->getSdk($item); $entity = $sdk->get($item->getId())->wait(true); if (false === $this->shouldCacheEntity($item->getType(), $item->getId())) { return $entity; } if ($entity) { $this->logger->debug('Saving to cache', [ 'type' => $item->getType(), 'id' => $item->getId(), ]); $this->cache->save( $this->getKeyFromQueueItem($item), $this->serializer->serialize($entity, 'json', ['type' => true]), $this->lifetime ); } else { $this->logger->debug('404 from SDK', [ 'type' => $item->getType(), 'id' => $item->getId(), ]); } return $entity; }
[ "private", "function", "getFreshDataWithCache", "(", "QueueItem", "$", "item", ")", "{", "$", "sdk", "=", "$", "this", "->", "getSdk", "(", "$", "item", ")", ";", "$", "entity", "=", "$", "sdk", "->", "get", "(", "$", "item", "->", "getId", "(", ")", ")", "->", "wait", "(", "true", ")", ";", "if", "(", "false", "===", "$", "this", "->", "shouldCacheEntity", "(", "$", "item", "->", "getType", "(", ")", ",", "$", "item", "->", "getId", "(", ")", ")", ")", "{", "return", "$", "entity", ";", "}", "if", "(", "$", "entity", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Saving to cache'", ",", "[", "'type'", "=>", "$", "item", "->", "getType", "(", ")", ",", "'id'", "=>", "$", "item", "->", "getId", "(", ")", ",", "]", ")", ";", "$", "this", "->", "cache", "->", "save", "(", "$", "this", "->", "getKeyFromQueueItem", "(", "$", "item", ")", ",", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "entity", ",", "'json'", ",", "[", "'type'", "=>", "true", "]", ")", ",", "$", "this", "->", "lifetime", ")", ";", "}", "else", "{", "$", "this", "->", "logger", "->", "debug", "(", "'404 from SDK'", ",", "[", "'type'", "=>", "$", "item", "->", "getType", "(", ")", ",", "'id'", "=>", "$", "item", "->", "getId", "(", ")", ",", "]", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Get fresh data with cache. This method call guarantees a fresh copy of them entity in ApiSDK represented by the QueueItem. If the item should be cached, it will be cached at this point. @return mixed
[ "Get", "fresh", "data", "with", "cache", "." ]
3af0739fac110e79ea7f21aadf8d17b891f3b918
https://github.com/elifesciences/bus-sdk-php/blob/3af0739fac110e79ea7f21aadf8d17b891f3b918/src/Queue/CachedTransformer.php#L85-L110
train
johnkrovitch/Sam
Task/TaskRunner.php
TaskRunner.run
public function run(Task $task) { // get configured filters for this task $filters = $task ->getConfiguration() ->getParameter('filters'); // get sources files $sources = $this->fetchSources($task); $destinations = $this->fetchDestinations($task); foreach ($filters as $filterName) { // get current configured filter $filter = $this->getFilter($filterName); // filter the files supported by this filter $filteredSources = $this->filterSources($sources, $filter); // apply the filter $updatedSources = $filter->run($filteredSources, $destinations); // update new sources if exists if ($updatedSources === null) { $updatedSources = []; } $sources = $this->updateSources($sources, $filteredSources, $updatedSources); } if (!$this->isDebug) { foreach ($filters as $filterName) { // get current configured filter $filter = $this->getFilter($filterName); // clean the files generated by the filter $filter->clean(); } } }
php
public function run(Task $task) { // get configured filters for this task $filters = $task ->getConfiguration() ->getParameter('filters'); // get sources files $sources = $this->fetchSources($task); $destinations = $this->fetchDestinations($task); foreach ($filters as $filterName) { // get current configured filter $filter = $this->getFilter($filterName); // filter the files supported by this filter $filteredSources = $this->filterSources($sources, $filter); // apply the filter $updatedSources = $filter->run($filteredSources, $destinations); // update new sources if exists if ($updatedSources === null) { $updatedSources = []; } $sources = $this->updateSources($sources, $filteredSources, $updatedSources); } if (!$this->isDebug) { foreach ($filters as $filterName) { // get current configured filter $filter = $this->getFilter($filterName); // clean the files generated by the filter $filter->clean(); } } }
[ "public", "function", "run", "(", "Task", "$", "task", ")", "{", "// get configured filters for this task", "$", "filters", "=", "$", "task", "->", "getConfiguration", "(", ")", "->", "getParameter", "(", "'filters'", ")", ";", "// get sources files", "$", "sources", "=", "$", "this", "->", "fetchSources", "(", "$", "task", ")", ";", "$", "destinations", "=", "$", "this", "->", "fetchDestinations", "(", "$", "task", ")", ";", "foreach", "(", "$", "filters", "as", "$", "filterName", ")", "{", "// get current configured filter", "$", "filter", "=", "$", "this", "->", "getFilter", "(", "$", "filterName", ")", ";", "// filter the files supported by this filter", "$", "filteredSources", "=", "$", "this", "->", "filterSources", "(", "$", "sources", ",", "$", "filter", ")", ";", "// apply the filter", "$", "updatedSources", "=", "$", "filter", "->", "run", "(", "$", "filteredSources", ",", "$", "destinations", ")", ";", "// update new sources if exists", "if", "(", "$", "updatedSources", "===", "null", ")", "{", "$", "updatedSources", "=", "[", "]", ";", "}", "$", "sources", "=", "$", "this", "->", "updateSources", "(", "$", "sources", ",", "$", "filteredSources", ",", "$", "updatedSources", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isDebug", ")", "{", "foreach", "(", "$", "filters", "as", "$", "filterName", ")", "{", "// get current configured filter", "$", "filter", "=", "$", "this", "->", "getFilter", "(", "$", "filterName", ")", ";", "// clean the files generated by the filter", "$", "filter", "->", "clean", "(", ")", ";", "}", "}", "}" ]
Run a task, load its sources before and call the clean method on the filter. @param Task $task @throws Exception
[ "Run", "a", "task", "load", "its", "sources", "before", "and", "call", "the", "clean", "method", "on", "the", "filter", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Task/TaskRunner.php#L47-L84
train
johnkrovitch/Sam
Task/TaskRunner.php
TaskRunner.getFilter
protected function getFilter($name) { // filters must exists in configured filters if (!array_key_exists($name, $this->filters)) { throw new Exception('Invalid filter '.$name.'. Check your mapping configuration'); } return $this->filters[$name]; }
php
protected function getFilter($name) { // filters must exists in configured filters if (!array_key_exists($name, $this->filters)) { throw new Exception('Invalid filter '.$name.'. Check your mapping configuration'); } return $this->filters[$name]; }
[ "protected", "function", "getFilter", "(", "$", "name", ")", "{", "// filters must exists in configured filters", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "filters", ")", ")", "{", "throw", "new", "Exception", "(", "'Invalid filter '", ".", "$", "name", ".", "'. Check your mapping configuration'", ")", ";", "}", "return", "$", "this", "->", "filters", "[", "$", "name", "]", ";", "}" ]
Return a filter by its name. Throw an exception if it is not exists. @param string $name @return FilterInterface @throws Exception
[ "Return", "a", "filter", "by", "its", "name", ".", "Throw", "an", "exception", "if", "it", "is", "not", "exists", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Task/TaskRunner.php#L93-L101
train
johnkrovitch/Sam
Task/TaskRunner.php
TaskRunner.fetchSources
protected function fetchSources(Task $task) { $sources = []; foreach ($task->getSources() as $source) { // locate new resource and merge them to the existing sources $sources = array_merge($sources, $this->locator->locate($source)); } return $sources; }
php
protected function fetchSources(Task $task) { $sources = []; foreach ($task->getSources() as $source) { // locate new resource and merge them to the existing sources $sources = array_merge($sources, $this->locator->locate($source)); } return $sources; }
[ "protected", "function", "fetchSources", "(", "Task", "$", "task", ")", "{", "$", "sources", "=", "[", "]", ";", "foreach", "(", "$", "task", "->", "getSources", "(", ")", "as", "$", "source", ")", "{", "// locate new resource and merge them to the existing sources", "$", "sources", "=", "array_merge", "(", "$", "sources", ",", "$", "this", "->", "locator", "->", "locate", "(", "$", "source", ")", ")", ";", "}", "return", "$", "sources", ";", "}" ]
Fetch the source files from the task and return and array of SplInfo. @param Task $task @return array
[ "Fetch", "the", "source", "files", "from", "the", "task", "and", "return", "and", "array", "of", "SplInfo", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Task/TaskRunner.php#L109-L119
train
johnkrovitch/Sam
Task/TaskRunner.php
TaskRunner.fetchDestinations
protected function fetchDestinations(Task $task) { $sources = []; foreach ($task->getDestinations() as $source) { // locate new resource and merge them to the existing sources $sources[] = new SplFileInfo($source); } return $sources; }
php
protected function fetchDestinations(Task $task) { $sources = []; foreach ($task->getDestinations() as $source) { // locate new resource and merge them to the existing sources $sources[] = new SplFileInfo($source); } return $sources; }
[ "protected", "function", "fetchDestinations", "(", "Task", "$", "task", ")", "{", "$", "sources", "=", "[", "]", ";", "foreach", "(", "$", "task", "->", "getDestinations", "(", ")", "as", "$", "source", ")", "{", "// locate new resource and merge them to the existing sources", "$", "sources", "[", "]", "=", "new", "SplFileInfo", "(", "$", "source", ")", ";", "}", "return", "$", "sources", ";", "}" ]
Fetch the destination files from the task and return and array of SplInfo. @param Task $task @return SplFileInfo[]
[ "Fetch", "the", "destination", "files", "from", "the", "task", "and", "return", "and", "array", "of", "SplInfo", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Task/TaskRunner.php#L127-L137
train
johnkrovitch/Sam
Task/TaskRunner.php
TaskRunner.filterSources
protected function filterSources(array $sources, FilterInterface $filter) { $filteredSources = []; // if the filter supports no extension, there is an error if (!is_array($filter->getSupportedExtensions()) || !count($filter->getSupportedExtensions())) { throw new Exception('No supported extensions found for the filter '.$filter->getName()); } foreach ($sources as $source) { $isExtensionSupported = in_array($source->getExtension(), $filter->getSupportedExtensions()); $supportAllExtensions = in_array('*', $filter->getSupportedExtensions()); if ($isExtensionSupported || $supportAllExtensions) { $filteredSources[] = $this ->locator ->getNormalizer() ->normalize($source); } } return $filteredSources; }
php
protected function filterSources(array $sources, FilterInterface $filter) { $filteredSources = []; // if the filter supports no extension, there is an error if (!is_array($filter->getSupportedExtensions()) || !count($filter->getSupportedExtensions())) { throw new Exception('No supported extensions found for the filter '.$filter->getName()); } foreach ($sources as $source) { $isExtensionSupported = in_array($source->getExtension(), $filter->getSupportedExtensions()); $supportAllExtensions = in_array('*', $filter->getSupportedExtensions()); if ($isExtensionSupported || $supportAllExtensions) { $filteredSources[] = $this ->locator ->getNormalizer() ->normalize($source); } } return $filteredSources; }
[ "protected", "function", "filterSources", "(", "array", "$", "sources", ",", "FilterInterface", "$", "filter", ")", "{", "$", "filteredSources", "=", "[", "]", ";", "// if the filter supports no extension, there is an error", "if", "(", "!", "is_array", "(", "$", "filter", "->", "getSupportedExtensions", "(", ")", ")", "||", "!", "count", "(", "$", "filter", "->", "getSupportedExtensions", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "'No supported extensions found for the filter '", ".", "$", "filter", "->", "getName", "(", ")", ")", ";", "}", "foreach", "(", "$", "sources", "as", "$", "source", ")", "{", "$", "isExtensionSupported", "=", "in_array", "(", "$", "source", "->", "getExtension", "(", ")", ",", "$", "filter", "->", "getSupportedExtensions", "(", ")", ")", ";", "$", "supportAllExtensions", "=", "in_array", "(", "'*'", ",", "$", "filter", "->", "getSupportedExtensions", "(", ")", ")", ";", "if", "(", "$", "isExtensionSupported", "||", "$", "supportAllExtensions", ")", "{", "$", "filteredSources", "[", "]", "=", "$", "this", "->", "locator", "->", "getNormalizer", "(", ")", "->", "normalize", "(", "$", "source", ")", ";", "}", "}", "return", "$", "filteredSources", ";", "}" ]
Filter only the sources supported by the current filter. @param SplFileInfo[] $sources @param FilterInterface $filter @return array @throws Exception
[ "Filter", "only", "the", "sources", "supported", "by", "the", "current", "filter", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Task/TaskRunner.php#L147-L169
train
johnkrovitch/Sam
Task/TaskRunner.php
TaskRunner.updateSources
protected function updateSources(array $originalSources, array $filteredSources, array $updatedSources) { $sources = []; $filteredPath = []; foreach ($filteredSources as $filteredSource) { $filteredPath[] = $filteredSource->getPath(); } // keep only the not filtered files foreach ($originalSources as $originalSource) { // if an original source is not used by the current filter, we keep it in the source list if (!in_array($originalSource->getPath(), $filteredPath)) { $sources[] = $originalSource; } } // check updated files foreach ($updatedSources as $index => $source) { if (is_string($source)) { $updatedSources[$index] = new SplFileInfo($source); } else if (!($source instanceof SplFileInfo)) { throw new Exception('Invalid source file type '.gettype($source)); } } // merge with the new sources $sources = array_merge($sources, $updatedSources); return $sources; }
php
protected function updateSources(array $originalSources, array $filteredSources, array $updatedSources) { $sources = []; $filteredPath = []; foreach ($filteredSources as $filteredSource) { $filteredPath[] = $filteredSource->getPath(); } // keep only the not filtered files foreach ($originalSources as $originalSource) { // if an original source is not used by the current filter, we keep it in the source list if (!in_array($originalSource->getPath(), $filteredPath)) { $sources[] = $originalSource; } } // check updated files foreach ($updatedSources as $index => $source) { if (is_string($source)) { $updatedSources[$index] = new SplFileInfo($source); } else if (!($source instanceof SplFileInfo)) { throw new Exception('Invalid source file type '.gettype($source)); } } // merge with the new sources $sources = array_merge($sources, $updatedSources); return $sources; }
[ "protected", "function", "updateSources", "(", "array", "$", "originalSources", ",", "array", "$", "filteredSources", ",", "array", "$", "updatedSources", ")", "{", "$", "sources", "=", "[", "]", ";", "$", "filteredPath", "=", "[", "]", ";", "foreach", "(", "$", "filteredSources", "as", "$", "filteredSource", ")", "{", "$", "filteredPath", "[", "]", "=", "$", "filteredSource", "->", "getPath", "(", ")", ";", "}", "// keep only the not filtered files", "foreach", "(", "$", "originalSources", "as", "$", "originalSource", ")", "{", "// if an original source is not used by the current filter, we keep it in the source list", "if", "(", "!", "in_array", "(", "$", "originalSource", "->", "getPath", "(", ")", ",", "$", "filteredPath", ")", ")", "{", "$", "sources", "[", "]", "=", "$", "originalSource", ";", "}", "}", "// check updated files", "foreach", "(", "$", "updatedSources", "as", "$", "index", "=>", "$", "source", ")", "{", "if", "(", "is_string", "(", "$", "source", ")", ")", "{", "$", "updatedSources", "[", "$", "index", "]", "=", "new", "SplFileInfo", "(", "$", "source", ")", ";", "}", "else", "if", "(", "!", "(", "$", "source", "instanceof", "SplFileInfo", ")", ")", "{", "throw", "new", "Exception", "(", "'Invalid source file type '", ".", "gettype", "(", "$", "source", ")", ")", ";", "}", "}", "// merge with the new sources", "$", "sources", "=", "array_merge", "(", "$", "sources", ",", "$", "updatedSources", ")", ";", "return", "$", "sources", ";", "}" ]
Remove the filtered files from the sources, and merge with the new ones. @param SplFileInfo[] $originalSources @param SplFileInfo[] $filteredSources @param SplFileInfo[] $updatedSources @return SplFileInfo[] @throws Exception
[ "Remove", "the", "filtered", "files", "from", "the", "sources", "and", "merge", "with", "the", "new", "ones", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Task/TaskRunner.php#L180-L208
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.urlOfImage
public function urlOfImage($filename, $width=300, $height=300) { $url = Config::get('app.url'); $url .= '/'; $url .= Config::get('lasallecmsfrontend.images_folder_resized'); $url .= '/'; $url .= $this->parseFilenameIntoResizedFilename($filename, $width, $height); return $url; }
php
public function urlOfImage($filename, $width=300, $height=300) { $url = Config::get('app.url'); $url .= '/'; $url .= Config::get('lasallecmsfrontend.images_folder_resized'); $url .= '/'; $url .= $this->parseFilenameIntoResizedFilename($filename, $width, $height); return $url; }
[ "public", "function", "urlOfImage", "(", "$", "filename", ",", "$", "width", "=", "300", ",", "$", "height", "=", "300", ")", "{", "$", "url", "=", "Config", "::", "get", "(", "'app.url'", ")", ";", "$", "url", ".=", "'/'", ";", "$", "url", ".=", "Config", "::", "get", "(", "'lasallecmsfrontend.images_folder_resized'", ")", ";", "$", "url", ".=", "'/'", ";", "$", "url", ".=", "$", "this", "->", "parseFilenameIntoResizedFilename", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", ";", "return", "$", "url", ";", "}" ]
Put together the URL of the image. Need this for the social media tags for image. @param string $filename The uploaded image's filename @parem int $width Width of the resized image @param int $height Height of the resized image @return string
[ "Put", "together", "the", "URL", "of", "the", "image", "." ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L102-L111
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.parseFilenameIntoResizedFilename
public function parseFilenameIntoResizedFilename($filename, $width=300, $height=300) { $fileNameWithNoExtension = $this->filenameWithNoExtension($filename); $fileNameExtension = $this->filenameWithExtensionOnly($filename); $parsedFilename = ""; $parsedFilename .= $fileNameWithNoExtension; $parsedFilename .= "-"; $parsedFilename .= $width; $parsedFilename .= "x"; $parsedFilename .= "$height"; $parsedFilename .= "."; $parsedFilename .= $fileNameExtension; return $parsedFilename; }
php
public function parseFilenameIntoResizedFilename($filename, $width=300, $height=300) { $fileNameWithNoExtension = $this->filenameWithNoExtension($filename); $fileNameExtension = $this->filenameWithExtensionOnly($filename); $parsedFilename = ""; $parsedFilename .= $fileNameWithNoExtension; $parsedFilename .= "-"; $parsedFilename .= $width; $parsedFilename .= "x"; $parsedFilename .= "$height"; $parsedFilename .= "."; $parsedFilename .= $fileNameExtension; return $parsedFilename; }
[ "public", "function", "parseFilenameIntoResizedFilename", "(", "$", "filename", ",", "$", "width", "=", "300", ",", "$", "height", "=", "300", ")", "{", "$", "fileNameWithNoExtension", "=", "$", "this", "->", "filenameWithNoExtension", "(", "$", "filename", ")", ";", "$", "fileNameExtension", "=", "$", "this", "->", "filenameWithExtensionOnly", "(", "$", "filename", ")", ";", "$", "parsedFilename", "=", "\"\"", ";", "$", "parsedFilename", ".=", "$", "fileNameWithNoExtension", ";", "$", "parsedFilename", ".=", "\"-\"", ";", "$", "parsedFilename", ".=", "$", "width", ";", "$", "parsedFilename", ".=", "\"x\"", ";", "$", "parsedFilename", ".=", "\"$height\"", ";", "$", "parsedFilename", ".=", "\".\"", ";", "$", "parsedFilename", ".=", "$", "fileNameExtension", ";", "return", "$", "parsedFilename", ";", "}" ]
Take an image's filename, and return the name of the resized file. For use within the "single post" blade file. Does *NOT* create the resized image file. @param string $filename The uploaded image's filename @parem int $width Width of the resized image @param int $height Height of the resized image @return string
[ "Take", "an", "image", "s", "filename", "and", "return", "the", "name", "of", "the", "resized", "file", "." ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L126-L141
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.categoryImageResizedFilename
public function categoryImageResizedFilename($categoryFeaturedImage) { // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.category_featured_image_size'); // filename $fileNameWithNoExtension = $this->filenameWithNoExtension($categoryFeaturedImage); $fileNameExtension = $this->filenameWithExtensionOnly($categoryFeaturedImage); // iterate through the image sizes, even though there is just one size foreach ($imageSizes as $width => $height) { return $fileNameWithNoExtension.'-'.$width.'x'.$height.'.'.$fileNameExtension; } }
php
public function categoryImageResizedFilename($categoryFeaturedImage) { // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.category_featured_image_size'); // filename $fileNameWithNoExtension = $this->filenameWithNoExtension($categoryFeaturedImage); $fileNameExtension = $this->filenameWithExtensionOnly($categoryFeaturedImage); // iterate through the image sizes, even though there is just one size foreach ($imageSizes as $width => $height) { return $fileNameWithNoExtension.'-'.$width.'x'.$height.'.'.$fileNameExtension; } }
[ "public", "function", "categoryImageResizedFilename", "(", "$", "categoryFeaturedImage", ")", "{", "// grab the image sizes to create from the config", "$", "imageSizes", "=", "Config", "::", "get", "(", "'lasallecmsfrontend.category_featured_image_size'", ")", ";", "// filename", "$", "fileNameWithNoExtension", "=", "$", "this", "->", "filenameWithNoExtension", "(", "$", "categoryFeaturedImage", ")", ";", "$", "fileNameExtension", "=", "$", "this", "->", "filenameWithExtensionOnly", "(", "$", "categoryFeaturedImage", ")", ";", "// iterate through the image sizes, even though there is just one size", "foreach", "(", "$", "imageSizes", "as", "$", "width", "=>", "$", "height", ")", "{", "return", "$", "fileNameWithNoExtension", ".", "'-'", ".", "$", "width", ".", "'x'", ".", "$", "height", ".", "'.'", ".", "$", "fileNameExtension", ";", "}", "}" ]
What is the name of the resized category featured image that the view will use? Does not actually resize the image! ASSUMES THAT THERE IS JUST ONE RESIZED CATEGORY IMAGE @param string $categoryFeaturedImage The category's featured image (that is in the categories table) @return string
[ "What", "is", "the", "name", "of", "the", "resized", "category", "featured", "image", "that", "the", "view", "will", "use?" ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L192-L206
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.createCategoryResizedImageFiles
public function createCategoryResizedImageFiles($filename) { // Use the default or a specified category featured image $filename = $this->categoryImageDefaultOrSpecified($filename); // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.category_featured_image_size'); // iterate through the sizes to create new image files for each size foreach ($imageSizes as $width => $height) { if (!$this->isFileExist($this->pathFilenameOfResizedImage($filename, $width, $height))) { $this->resize($filename, $width, $height); $this->resizeAt2x($filename, $width, $height); } } }
php
public function createCategoryResizedImageFiles($filename) { // Use the default or a specified category featured image $filename = $this->categoryImageDefaultOrSpecified($filename); // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.category_featured_image_size'); // iterate through the sizes to create new image files for each size foreach ($imageSizes as $width => $height) { if (!$this->isFileExist($this->pathFilenameOfResizedImage($filename, $width, $height))) { $this->resize($filename, $width, $height); $this->resizeAt2x($filename, $width, $height); } } }
[ "public", "function", "createCategoryResizedImageFiles", "(", "$", "filename", ")", "{", "// Use the default or a specified category featured image", "$", "filename", "=", "$", "this", "->", "categoryImageDefaultOrSpecified", "(", "$", "filename", ")", ";", "// grab the image sizes to create from the config", "$", "imageSizes", "=", "Config", "::", "get", "(", "'lasallecmsfrontend.category_featured_image_size'", ")", ";", "// iterate through the sizes to create new image files for each size", "foreach", "(", "$", "imageSizes", "as", "$", "width", "=>", "$", "height", ")", "{", "if", "(", "!", "$", "this", "->", "isFileExist", "(", "$", "this", "->", "pathFilenameOfResizedImage", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", ")", ")", "{", "$", "this", "->", "resize", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", ";", "$", "this", "->", "resizeAt2x", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", ";", "}", "}", "}" ]
Create resized image files for the category featured image @param string $filename Category's UN-resized image's filename @return void
[ "Create", "resized", "image", "files", "for", "the", "category", "featured", "image" ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L216-L233
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.tagImageResizedFilename
public function tagImageResizedFilename($defaultTagImage) { // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.default_tag_image_image_size'); // filename $fileNameWithNoExtension = $this->filenameWithNoExtension($defaultTagImage); $fileNameExtension = $this->filenameWithExtensionOnly($defaultTagImage); // iterate through the image sizes$imageSizes = Config::get('lasallecmsfrontend.image_sizes');, even though there is just one size foreach ($imageSizes as $width => $height) { return $fileNameWithNoExtension.'-'.$width.'x'.$height.'.'.$fileNameExtension; } }
php
public function tagImageResizedFilename($defaultTagImage) { // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.default_tag_image_image_size'); // filename $fileNameWithNoExtension = $this->filenameWithNoExtension($defaultTagImage); $fileNameExtension = $this->filenameWithExtensionOnly($defaultTagImage); // iterate through the image sizes$imageSizes = Config::get('lasallecmsfrontend.image_sizes');, even though there is just one size foreach ($imageSizes as $width => $height) { return $fileNameWithNoExtension.'-'.$width.'x'.$height.'.'.$fileNameExtension; } }
[ "public", "function", "tagImageResizedFilename", "(", "$", "defaultTagImage", ")", "{", "// grab the image sizes to create from the config", "$", "imageSizes", "=", "Config", "::", "get", "(", "'lasallecmsfrontend.default_tag_image_image_size'", ")", ";", "// filename", "$", "fileNameWithNoExtension", "=", "$", "this", "->", "filenameWithNoExtension", "(", "$", "defaultTagImage", ")", ";", "$", "fileNameExtension", "=", "$", "this", "->", "filenameWithExtensionOnly", "(", "$", "defaultTagImage", ")", ";", "// iterate through the image sizes$imageSizes = Config::get('lasallecmsfrontend.image_sizes');, even though there is just one size", "foreach", "(", "$", "imageSizes", "as", "$", "width", "=>", "$", "height", ")", "{", "return", "$", "fileNameWithNoExtension", ".", "'-'", ".", "$", "width", ".", "'x'", ".", "$", "height", ".", "'.'", ".", "$", "fileNameExtension", ";", "}", "}" ]
What is the name of the resized tag default image that the view will use? Does not actually resize the image! @param string $defaultTagImage The defaul_tag_image config setting @return string
[ "What", "is", "the", "name", "of", "the", "resized", "tag", "default", "image", "that", "the", "view", "will", "use?" ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L250-L264
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.tagResizedImageFiles
public function tagResizedImageFiles($defaultTagImage) { // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.default_tag_image_image_size'); // iterate through the sizes to create new image files for each size foreach ($imageSizes as $width => $height) { if (!$this->isFileExist($this->pathFilenameOfResizedImage($defaultTagImage, $width, $height))) { $this->resize($defaultTagImage, $width, $height); $this->resizeAt2x($defaultTagImage, $width, $height); } } }
php
public function tagResizedImageFiles($defaultTagImage) { // grab the image sizes to create from the config $imageSizes = Config::get('lasallecmsfrontend.default_tag_image_image_size'); // iterate through the sizes to create new image files for each size foreach ($imageSizes as $width => $height) { if (!$this->isFileExist($this->pathFilenameOfResizedImage($defaultTagImage, $width, $height))) { $this->resize($defaultTagImage, $width, $height); $this->resizeAt2x($defaultTagImage, $width, $height); } } }
[ "public", "function", "tagResizedImageFiles", "(", "$", "defaultTagImage", ")", "{", "// grab the image sizes to create from the config", "$", "imageSizes", "=", "Config", "::", "get", "(", "'lasallecmsfrontend.default_tag_image_image_size'", ")", ";", "// iterate through the sizes to create new image files for each size", "foreach", "(", "$", "imageSizes", "as", "$", "width", "=>", "$", "height", ")", "{", "if", "(", "!", "$", "this", "->", "isFileExist", "(", "$", "this", "->", "pathFilenameOfResizedImage", "(", "$", "defaultTagImage", ",", "$", "width", ",", "$", "height", ")", ")", ")", "{", "$", "this", "->", "resize", "(", "$", "defaultTagImage", ",", "$", "width", ",", "$", "height", ")", ";", "$", "this", "->", "resizeAt2x", "(", "$", "defaultTagImage", ",", "$", "width", ",", "$", "height", ")", ";", "}", "}", "}" ]
Create resized image files for the tag default image @param string $defaultTagImage The defaul_tag_image config setting @return void
[ "Create", "resized", "image", "files", "for", "the", "tag", "default", "image" ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L274-L288
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.resize
public function resize($filename, $width, $height) { // open an image file $img = Image::make($this->pathOfImagesUploadFolder() .'/'. $filename); // resize image // http://image.intervention.io/api/resize // closure prevents possible upsizing $img->resize($width, $height, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); $img->save($this->pathFilenameOfResizedImage($filename, $width, $height)); }
php
public function resize($filename, $width, $height) { // open an image file $img = Image::make($this->pathOfImagesUploadFolder() .'/'. $filename); // resize image // http://image.intervention.io/api/resize // closure prevents possible upsizing $img->resize($width, $height, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); $img->save($this->pathFilenameOfResizedImage($filename, $width, $height)); }
[ "public", "function", "resize", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", "{", "// open an image file", "$", "img", "=", "Image", "::", "make", "(", "$", "this", "->", "pathOfImagesUploadFolder", "(", ")", ".", "'/'", ".", "$", "filename", ")", ";", "// resize image", "// http://image.intervention.io/api/resize", "// closure prevents possible upsizing", "$", "img", "->", "resize", "(", "$", "width", ",", "$", "height", ",", "function", "(", "$", "constraint", ")", "{", "$", "constraint", "->", "aspectRatio", "(", ")", ";", "$", "constraint", "->", "upsize", "(", ")", ";", "}", ")", ";", "$", "img", "->", "save", "(", "$", "this", "->", "pathFilenameOfResizedImage", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", ")", ";", "}" ]
Resize the image using the terrific Intervention package @param string $filename Image filename @param int $width Resized width @param int $height Resized height @return void
[ "Resize", "the", "image", "using", "the", "terrific", "Intervention", "package" ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L304-L318
train
lasallecms/lasallecms-l5-helpers-pkg
src/Images/ImagesHelper.php
ImagesHelper.pathFilenameOfResizedImage
public function pathFilenameOfResizedImage($filename, $width, $height) { $path = $this->pathOfImagesResizedFolder(); $filenameWithNoExtension = $this->filenameWithNoExtension($filename); $filenameWithExtensionOnly = $this->filenameWithExtensionOnly($filename); $resizedFilename = $path; $resizedFilename .= "/"; $resizedFilename .= $filenameWithNoExtension; $resizedFilename .= '-'; $resizedFilename .= $width; $resizedFilename .= 'x'; $resizedFilename .= $height; $resizedFilename .= '.'; $resizedFilename .= $filenameWithExtensionOnly; return $resizedFilename; }
php
public function pathFilenameOfResizedImage($filename, $width, $height) { $path = $this->pathOfImagesResizedFolder(); $filenameWithNoExtension = $this->filenameWithNoExtension($filename); $filenameWithExtensionOnly = $this->filenameWithExtensionOnly($filename); $resizedFilename = $path; $resizedFilename .= "/"; $resizedFilename .= $filenameWithNoExtension; $resizedFilename .= '-'; $resizedFilename .= $width; $resizedFilename .= 'x'; $resizedFilename .= $height; $resizedFilename .= '.'; $resizedFilename .= $filenameWithExtensionOnly; return $resizedFilename; }
[ "public", "function", "pathFilenameOfResizedImage", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", "{", "$", "path", "=", "$", "this", "->", "pathOfImagesResizedFolder", "(", ")", ";", "$", "filenameWithNoExtension", "=", "$", "this", "->", "filenameWithNoExtension", "(", "$", "filename", ")", ";", "$", "filenameWithExtensionOnly", "=", "$", "this", "->", "filenameWithExtensionOnly", "(", "$", "filename", ")", ";", "$", "resizedFilename", "=", "$", "path", ";", "$", "resizedFilename", ".=", "\"/\"", ";", "$", "resizedFilename", ".=", "$", "filenameWithNoExtension", ";", "$", "resizedFilename", ".=", "'-'", ";", "$", "resizedFilename", ".=", "$", "width", ";", "$", "resizedFilename", ".=", "'x'", ";", "$", "resizedFilename", ".=", "$", "height", ";", "$", "resizedFilename", ".=", "'.'", ";", "$", "resizedFilename", ".=", "$", "filenameWithExtensionOnly", ";", "return", "$", "resizedFilename", ";", "}" ]
Put together the path + name of the resized imaged. @param string $filename Image filename @param int $width Resized width @param int $height Resized height @return string
[ "Put", "together", "the", "path", "+", "name", "of", "the", "resized", "imaged", "." ]
733967ce3fd81a1efba5265e11663c324ff983c4
https://github.com/lasallecms/lasallecms-l5-helpers-pkg/blob/733967ce3fd81a1efba5265e11663c324ff983c4/src/Images/ImagesHelper.php#L357-L374
train
wobblecode/WobbleCodeUserBundle
Document/Contact.php
Contact.getServiceProfile
public function getServiceProfile($service) { if (isset($this->serviceProfiles[$service])) { return $this->serviceProfiles[$service]; } return null; }
php
public function getServiceProfile($service) { if (isset($this->serviceProfiles[$service])) { return $this->serviceProfiles[$service]; } return null; }
[ "public", "function", "getServiceProfile", "(", "$", "service", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "serviceProfiles", "[", "$", "service", "]", ")", ")", "{", "return", "$", "this", "->", "serviceProfiles", "[", "$", "service", "]", ";", "}", "return", "null", ";", "}" ]
Get service profile data @param string $service @return array|null
[ "Get", "service", "profile", "data" ]
7b8206f8b4a50fbc61f7bfe4f83eb466cad96440
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Contact.php#L775-L782
train