repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
datasift/php_webdriver
src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php
BrowserMobProxySession.getHAR
public function getHAR($logName = 'default') { $this->requireOpenConnection(); $response = $this->curl( 'GET', '/proxy/' . $this->port . '/har' ); $har = new HttpArchive(); $har->initFromProxyData($response); return $har; }
php
public function getHAR($logName = 'default') { $this->requireOpenConnection(); $response = $this->curl( 'GET', '/proxy/' . $this->port . '/har' ); $har = new HttpArchive(); $har->initFromProxyData($response); return $har; }
[ "public", "function", "getHAR", "(", "$", "logName", "=", "'default'", ")", "{", "$", "this", "->", "requireOpenConnection", "(", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "(", "'GET'", ",", "'/proxy/'", ".", "$", "this", "->", "port", ".", "'/har'", ")", ";", "$", "har", "=", "new", "HttpArchive", "(", ")", ";", "$", "har", "->", "initFromProxyData", "(", "$", "response", ")", ";", "return", "$", "har", ";", "}" ]
get the HTTP request/response details about the last page, in HTTP Archive (HAR) format @param string $logName name of the log used with startHAR() @return HttpArchive
[ "get", "the", "HTTP", "request", "/", "response", "details", "about", "the", "last", "page", "in", "HTTP", "Archive", "(", "HAR", ")", "format" ]
train
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php#L123-L136
datasift/php_webdriver
src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php
BrowserMobProxySession.setHeaders
public function setHeaders($headers) { $this->requireOpenConnection(); $response = $this->curl( 'POST', '/proxy/' . $this->port . '/headers', (object)$headers ); }
php
public function setHeaders($headers) { $this->requireOpenConnection(); $response = $this->curl( 'POST', '/proxy/' . $this->port . '/headers', (object)$headers ); }
[ "public", "function", "setHeaders", "(", "$", "headers", ")", "{", "$", "this", "->", "requireOpenConnection", "(", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "(", "'POST'", ",", "'/proxy/'", ".", "$", "this", "->", "port", ".", "'/headers'", ",", "(", "object", ")", "$", "headers", ")", ";", "}" ]
inject a set of headers into all subsequent requests @param array(string => string) $headers a list of headers to inject, with the array key being the name of the header, and the array value being the value of the header @return void
[ "inject", "a", "set", "of", "headers", "into", "all", "subsequent", "requests" ]
train
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php#L147-L156
datasift/php_webdriver
src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php
BrowserMobProxySession.removeHeader
public function removeHeader($name) { $this->requireOpenConnection(); $this->requireFeature('headerGetDelete'); $response = $this->curl( 'DELETE', '/proxy/' . $this->port . '/header/' . urlencode($name) ); }
php
public function removeHeader($name) { $this->requireOpenConnection(); $this->requireFeature('headerGetDelete'); $response = $this->curl( 'DELETE', '/proxy/' . $this->port . '/header/' . urlencode($name) ); }
[ "public", "function", "removeHeader", "(", "$", "name", ")", "{", "$", "this", "->", "requireOpenConnection", "(", ")", ";", "$", "this", "->", "requireFeature", "(", "'headerGetDelete'", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "(", "'DELETE'", ",", "'/proxy/'", ".", "$", "this", "->", "port", ".", "'/header/'", ".", "urlencode", "(", "$", "name", ")", ")", ";", "}" ]
remove a header from the list of headers that browsermob-proxy injects for us @param string the header to remove @return void
[ "remove", "a", "header", "from", "the", "list", "of", "headers", "that", "browsermob", "-", "proxy", "injects", "for", "us" ]
train
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php#L167-L175
datasift/php_webdriver
src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php
BrowserMobProxySession.removeAllHeaders
public function removeAllHeaders() { $this->requireOpenConnection(); $this->requireFeature('headerGetDelete'); $response = $this->curl( 'DELETE', '/proxy/' . $this->port . '/headers' ); }
php
public function removeAllHeaders() { $this->requireOpenConnection(); $this->requireFeature('headerGetDelete'); $response = $this->curl( 'DELETE', '/proxy/' . $this->port . '/headers' ); }
[ "public", "function", "removeAllHeaders", "(", ")", "{", "$", "this", "->", "requireOpenConnection", "(", ")", ";", "$", "this", "->", "requireFeature", "(", "'headerGetDelete'", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "(", "'DELETE'", ",", "'/proxy/'", ".", "$", "this", "->", "port", ".", "'/headers'", ")", ";", "}" ]
remove all of the headers that browsermob-proxy injects for us @return void
[ "remove", "all", "of", "the", "headers", "that", "browsermob", "-", "proxy", "injects", "for", "us" ]
train
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php#L182-L190
datasift/php_webdriver
src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php
BrowserMobProxySession.setHttpBasicAuth
public function setHttpBasicAuth($domain, $username, $password) { $this->requireOpenConnection(); $this->requireFeature('authBasic'); $response = $this->curl( 'PUT', '/proxy/' . $this->port . '/auth/basic/' . urlencode($domain), array( 'username' => $username, 'password' => $password ) ); }
php
public function setHttpBasicAuth($domain, $username, $password) { $this->requireOpenConnection(); $this->requireFeature('authBasic'); $response = $this->curl( 'PUT', '/proxy/' . $this->port . '/auth/basic/' . urlencode($domain), array( 'username' => $username, 'password' => $password ) ); }
[ "public", "function", "setHttpBasicAuth", "(", "$", "domain", ",", "$", "username", ",", "$", "password", ")", "{", "$", "this", "->", "requireOpenConnection", "(", ")", ";", "$", "this", "->", "requireFeature", "(", "'authBasic'", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "(", "'PUT'", ",", "'/proxy/'", ".", "$", "this", "->", "port", ".", "'/auth/basic/'", ".", "urlencode", "(", "$", "domain", ")", ",", "array", "(", "'username'", "=>", "$", "username", ",", "'password'", "=>", "$", "password", ")", ")", ";", "}" ]
enable HTTP BASIC auth @param string $domain the DNS domain to send HTTP BASIC auth info to @param $username the username to send to the web server @param string $password the password to send to the web server
[ "enable", "HTTP", "BASIC", "auth" ]
train
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php#L222-L234
datasift/php_webdriver
src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php
BrowserMobProxySession.close
public function close() { $this->requireOpenConnection(); $response = $this->curl( 'DELETE', '/proxy/' . $this->port ); $this->closed = true; }
php
public function close() { $this->requireOpenConnection(); $response = $this->curl( 'DELETE', '/proxy/' . $this->port ); $this->closed = true; }
[ "public", "function", "close", "(", ")", "{", "$", "this", "->", "requireOpenConnection", "(", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "(", "'DELETE'", ",", "'/proxy/'", ".", "$", "this", "->", "port", ")", ";", "$", "this", "->", "closed", "=", "true", ";", "}" ]
delete the proxy, because we're done @return void
[ "delete", "the", "proxy", "because", "we", "re", "done" ]
train
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/BrowserMobProxy/BrowserMobProxySession.php#L241-L251
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Consoles/Command.php
Command.choice
public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null) { return parent::choice($this->setTextPrompt($question), $choices, $default, $attempts, $multiple); }
php
public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null) { return parent::choice($this->setTextPrompt($question), $choices, $default, $attempts, $multiple); }
[ "public", "function", "choice", "(", "$", "question", ",", "array", "$", "choices", ",", "$", "default", "=", "null", ",", "$", "attempts", "=", "null", ",", "$", "multiple", "=", "null", ")", "{", "return", "parent", "::", "choice", "(", "$", "this", "->", "setTextPrompt", "(", "$", "question", ")", ",", "$", "choices", ",", "$", "default", ",", "$", "attempts", ",", "$", "multiple", ")", ";", "}" ]
Give the user a single choice from an array of answers. @param string $question @param array $choices @param string $default @param mixed $attempts @param bool $multiple @return string
[ "Give", "the", "user", "a", "single", "choice", "from", "an", "array", "of", "answers", "." ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Consoles/Command.php#L45-L48
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Consoles/Command.php
Command.title
public function title($string, $backgorund='blue', $forgeground='white') { $string = $this->paintString(" {$string} ", $forgeground, $backgorund); echo $string ."\n\r"; }
php
public function title($string, $backgorund='blue', $forgeground='white') { $string = $this->paintString(" {$string} ", $forgeground, $backgorund); echo $string ."\n\r"; }
[ "public", "function", "title", "(", "$", "string", ",", "$", "backgorund", "=", "'blue'", ",", "$", "forgeground", "=", "'white'", ")", "{", "$", "string", "=", "$", "this", "->", "paintString", "(", "\" {$string} \"", ",", "$", "forgeground", ",", "$", "backgorund", ")", ";", "echo", "$", "string", ".", "\"\\n\\r\"", ";", "}" ]
Write title output. @param string $string @return void
[ "Write", "title", "output", "." ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Consoles/Command.php#L83-L88
webforge-labs/psc-cms
lib/Psc/CMS/Modules.php
Modules.create
protected function create($name) { $c = $this->avaibleModules[$name]['class']; $module = new $c($this->project, $this->inTests); $module->setName($name); $this->modules[$name] = $module; PSC::getEventManager()->dispatchEvent('Psc.ModuleCreated', NULL, $module); return $module; }
php
protected function create($name) { $c = $this->avaibleModules[$name]['class']; $module = new $c($this->project, $this->inTests); $module->setName($name); $this->modules[$name] = $module; PSC::getEventManager()->dispatchEvent('Psc.ModuleCreated', NULL, $module); return $module; }
[ "protected", "function", "create", "(", "$", "name", ")", "{", "$", "c", "=", "$", "this", "->", "avaibleModules", "[", "$", "name", "]", "[", "'class'", "]", ";", "$", "module", "=", "new", "$", "c", "(", "$", "this", "->", "project", ",", "$", "this", "->", "inTests", ")", ";", "$", "module", "->", "setName", "(", "$", "name", ")", ";", "$", "this", "->", "modules", "[", "$", "name", "]", "=", "$", "module", ";", "PSC", "::", "getEventManager", "(", ")", "->", "dispatchEvent", "(", "'Psc.ModuleCreated'", ",", "NULL", ",", "$", "module", ")", ";", "return", "$", "module", ";", "}" ]
Erstellt ein neues Modul wird nur einmal aufgerufen pro Request vorher wurde mit isModule ($name) bereits überprüft @return Psc\CMS\Module
[ "Erstellt", "ein", "neues", "Modul" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Modules.php#L50-L60
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Loader/XmlFileLoader.php
XmlFileLoader.toArray
private function toArray(DOMElement $node) { $value = null; switch ($node->nodeName) { case 'array': $value = array(); if ($node->hasChildNodes()) { for ($i = 0; $i < $node->childNodes->length; $i++) { /** @var $child DOMElement */ $child = $node->childNodes->item($i); if ($child->hasAttribute('key')) { $value[$child->getAttribute('key')] = $this->toArray($child); } else { $value[] = $this->toArray($child); } } } break; case 'bool': $value = (bool) $node->textContent; break; case 'float': $value = (float) $node->textContent; break; case 'int': $value = (int) $node->textContent; break; case 'str': $value = $node->textContent; break; } return $value; }
php
private function toArray(DOMElement $node) { $value = null; switch ($node->nodeName) { case 'array': $value = array(); if ($node->hasChildNodes()) { for ($i = 0; $i < $node->childNodes->length; $i++) { /** @var $child DOMElement */ $child = $node->childNodes->item($i); if ($child->hasAttribute('key')) { $value[$child->getAttribute('key')] = $this->toArray($child); } else { $value[] = $this->toArray($child); } } } break; case 'bool': $value = (bool) $node->textContent; break; case 'float': $value = (float) $node->textContent; break; case 'int': $value = (int) $node->textContent; break; case 'str': $value = $node->textContent; break; } return $value; }
[ "private", "function", "toArray", "(", "DOMElement", "$", "node", ")", "{", "$", "value", "=", "null", ";", "switch", "(", "$", "node", "->", "nodeName", ")", "{", "case", "'array'", ":", "$", "value", "=", "array", "(", ")", ";", "if", "(", "$", "node", "->", "hasChildNodes", "(", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "node", "->", "childNodes", "->", "length", ";", "$", "i", "++", ")", "{", "/** @var $child DOMElement */", "$", "child", "=", "$", "node", "->", "childNodes", "->", "item", "(", "$", "i", ")", ";", "if", "(", "$", "child", "->", "hasAttribute", "(", "'key'", ")", ")", "{", "$", "value", "[", "$", "child", "->", "getAttribute", "(", "'key'", ")", "]", "=", "$", "this", "->", "toArray", "(", "$", "child", ")", ";", "}", "else", "{", "$", "value", "[", "]", "=", "$", "this", "->", "toArray", "(", "$", "child", ")", ";", "}", "}", "}", "break", ";", "case", "'bool'", ":", "$", "value", "=", "(", "bool", ")", "$", "node", "->", "textContent", ";", "break", ";", "case", "'float'", ":", "$", "value", "=", "(", "float", ")", "$", "node", "->", "textContent", ";", "break", ";", "case", "'int'", ":", "$", "value", "=", "(", "int", ")", "$", "node", "->", "textContent", ";", "break", ";", "case", "'str'", ":", "$", "value", "=", "$", "node", "->", "textContent", ";", "break", ";", "}", "return", "$", "value", ";", "}" ]
Converts a DOM elements to native PHP values. @param DOMElement $node The node. @return mixed The result.
[ "Converts", "a", "DOM", "elements", "to", "native", "PHP", "values", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Loader/XmlFileLoader.php#L46-L82
2amigos/yiifoundation
widgets/InterChange.php
Interchange.init
public function init() { $this->assets = array( 'js' => YII_DEBUG ? 'foundation/foundation.interchange.js' : 'foundation.min.js' ); $this->htmlOptions['src'] = $this->src; parent::init(); }
php
public function init() { $this->assets = array( 'js' => YII_DEBUG ? 'foundation/foundation.interchange.js' : 'foundation.min.js' ); $this->htmlOptions['src'] = $this->src; parent::init(); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "assets", "=", "array", "(", "'js'", "=>", "YII_DEBUG", "?", "'foundation/foundation.interchange.js'", ":", "'foundation.min.js'", ")", ";", "$", "this", "->", "htmlOptions", "[", "'src'", "]", "=", "$", "this", "->", "src", ";", "parent", "::", "init", "(", ")", ";", "}" ]
Initializes the widget
[ "Initializes", "the", "widget" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/InterChange.php#L40-L49
2amigos/yiifoundation
widgets/InterChange.php
Interchange.renderImage
public function renderImage() { $rules = array(); foreach ($this->rules as $rule) { $rules[] = '[' . implode(", ", $rule) . ']'; } $this->htmlOptions['data-interchange'] = implode(", ", $rules); return \CHtml::tag('img', $this->htmlOptions); }
php
public function renderImage() { $rules = array(); foreach ($this->rules as $rule) { $rules[] = '[' . implode(", ", $rule) . ']'; } $this->htmlOptions['data-interchange'] = implode(", ", $rules); return \CHtml::tag('img', $this->htmlOptions); }
[ "public", "function", "renderImage", "(", ")", "{", "$", "rules", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "rules", "as", "$", "rule", ")", "{", "$", "rules", "[", "]", "=", "'['", ".", "implode", "(", "\", \"", ",", "$", "rule", ")", ".", "']'", ";", "}", "$", "this", "->", "htmlOptions", "[", "'data-interchange'", "]", "=", "implode", "(", "\", \"", ",", "$", "rules", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'img'", ",", "$", "this", "->", "htmlOptions", ")", ";", "}" ]
Renders the interchange image @return string the resulting img tag
[ "Renders", "the", "interchange", "image" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/InterChange.php#L63-L71
Chill-project/Main
Controller/UserController.php
UserController.createAction
public function createAction(Request $request) { $user = new User(); $form = $this->createCreateForm($user); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $user->setPassword($this->get('security.password_encoder') ->encodePassword($user, $form['plainPassword']['password']->getData())); $em->persist($user); $em->flush(); return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId()))); } return $this->render('ChillMainBundle:User:new.html.twig', array( 'entity' => $user, 'form' => $form->createView(), )); }
php
public function createAction(Request $request) { $user = new User(); $form = $this->createCreateForm($user); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $user->setPassword($this->get('security.password_encoder') ->encodePassword($user, $form['plainPassword']['password']->getData())); $em->persist($user); $em->flush(); return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId()))); } return $this->render('ChillMainBundle:User:new.html.twig', array( 'entity' => $user, 'form' => $form->createView(), )); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "new", "User", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "user", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "user", "->", "setPassword", "(", "$", "this", "->", "get", "(", "'security.password_encoder'", ")", "->", "encodePassword", "(", "$", "user", ",", "$", "form", "[", "'plainPassword'", "]", "[", "'password'", "]", "->", "getData", "(", ")", ")", ")", ";", "$", "em", "->", "persist", "(", "$", "user", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_user_show'", ",", "array", "(", "'id'", "=>", "$", "user", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:User:new.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "user", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Creates a new User entity.
[ "Creates", "a", "new", "User", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L41-L63
Chill-project/Main
Controller/UserController.php
UserController.createCreateForm
private function createCreateForm(User $entity) { $form = $this->createForm(new UserType(), $entity, array( 'action' => $this->generateUrl('admin_user_create'), 'method' => 'POST', 'is_creation' => true )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(User $entity) { $form = $this->createForm(new UserType(), $entity, array( 'action' => $this->generateUrl('admin_user_create'), 'method' => 'POST', 'is_creation' => true )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "User", "$", "entity", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "UserType", "(", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_user_create'", ")", ",", "'method'", "=>", "'POST'", ",", "'is_creation'", "=>", "true", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a User entity. @param User $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "User", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L72-L83
Chill-project/Main
Controller/UserController.php
UserController.newAction
public function newAction() { $user = new User(); $form = $this->createCreateForm($user); return $this->render('ChillMainBundle:User:new.html.twig', array( 'entity' => $user, 'form' => $form->createView(), )); }
php
public function newAction() { $user = new User(); $form = $this->createCreateForm($user); return $this->render('ChillMainBundle:User:new.html.twig', array( 'entity' => $user, 'form' => $form->createView(), )); }
[ "public", "function", "newAction", "(", ")", "{", "$", "user", "=", "new", "User", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "user", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:User:new.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "user", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to create a new User entity.
[ "Displays", "a", "form", "to", "create", "a", "new", "User", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L89-L98
Chill-project/Main
Controller/UserController.php
UserController.editAction
public function editAction($id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditForm($user); return $this->render('ChillMainBundle:User:edit.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView(), 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), 'delete_groupcenter_form' => array_map( function(\Symfony\Component\Form\Form $form) { return $form->createView(); }, iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) )); }
php
public function editAction($id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditForm($user); return $this->render('ChillMainBundle:User:edit.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView(), 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), 'delete_groupcenter_form' => array_map( function(\Symfony\Component\Form\Form $form) { return $form->createView(); }, iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) )); }
[ "public", "function", "editAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:User'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "user", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find User entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "user", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:User:edit.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "user", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'add_groupcenter_form'", "=>", "$", "this", "->", "createAddLinkGroupCenterForm", "(", "$", "user", ")", "->", "createView", "(", ")", ",", "'delete_groupcenter_form'", "=>", "array_map", "(", "function", "(", "\\", "Symfony", "\\", "Component", "\\", "Form", "\\", "Form", "$", "form", ")", "{", "return", "$", "form", "->", "createView", "(", ")", ";", "}", ",", "iterator_to_array", "(", "$", "this", "->", "getDeleteLinkGroupCenterByUser", "(", "$", "user", ")", ",", "true", ")", ")", ")", ")", ";", "}" ]
Displays a form to edit an existing User entity.
[ "Displays", "a", "form", "to", "edit", "an", "existing", "User", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L123-L146
Chill-project/Main
Controller/UserController.php
UserController.editPasswordAction
public function editPasswordAction($id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditPasswordForm($user); return $this->render('ChillMainBundle:User:edit_password.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView() )); }
php
public function editPasswordAction($id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditPasswordForm($user); return $this->render('ChillMainBundle:User:edit_password.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView() )); }
[ "public", "function", "editPasswordAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:User'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "user", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find User entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditPasswordForm", "(", "$", "user", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:User:edit_password.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "user", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ")", ")", ";", "}" ]
Displays a form to edit the user password.
[ "Displays", "a", "form", "to", "edit", "the", "user", "password", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L152-L168
Chill-project/Main
Controller/UserController.php
UserController.createEditForm
private function createEditForm(User $user) { $form = $this->createForm(new UserType(), $user, array( 'action' => $this->generateUrl('admin_user_update', array('id' => $user->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
private function createEditForm(User $user) { $form = $this->createForm(new UserType(), $user, array( 'action' => $this->generateUrl('admin_user_update', array('id' => $user->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
[ "private", "function", "createEditForm", "(", "User", "$", "user", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "UserType", "(", ")", ",", "$", "user", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_user_update'", ",", "array", "(", "'id'", "=>", "$", "user", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to edit a User entity. @param User $user The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "User", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L291-L301
Chill-project/Main
Controller/UserController.php
UserController.updateAction
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditForm($user); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); } return $this->render('ChillMainBundle:User:edit.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView(), 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), 'delete_groupcenter_form' => array_map( function(\Symfony\Component\Form\Form $form) { return $form->createView(); }, iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) )); }
php
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditForm($user); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); } return $this->render('ChillMainBundle:User:edit.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView(), 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), 'delete_groupcenter_form' => array_map( function(\Symfony\Component\Form\Form $form) { return $form->createView(); }, iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) )); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:User'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "user", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find User entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "user", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_user_edit'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:User:edit.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "user", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'add_groupcenter_form'", "=>", "$", "this", "->", "createAddLinkGroupCenterForm", "(", "$", "user", ")", "->", "createView", "(", ")", ",", "'delete_groupcenter_form'", "=>", "array_map", "(", "function", "(", "\\", "Symfony", "\\", "Component", "\\", "Form", "\\", "Form", "$", "form", ")", "{", "return", "$", "form", "->", "createView", "(", ")", ";", "}", ",", "iterator_to_array", "(", "$", "this", "->", "getDeleteLinkGroupCenterByUser", "(", "$", "user", ")", ",", "true", ")", ")", ")", ")", ";", "}" ]
Edits an existing User entity.
[ "Edits", "an", "existing", "User", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L307-L337
Chill-project/Main
Controller/UserController.php
UserController.updatePasswordAction
public function updatePasswordAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditPasswordForm($user); $editForm->handleRequest($request); if ($editForm->isValid()) { $password = $editForm->getData()->getPassword(); // logging for debug !! WARNING print the new password !! $this->get('logger')->debug('update password for an user', array('method' => __METHOD__, 'password' => $password, 'user' => $user->getUsername())); // logging for prod $this->get('logger')->info('update password for an user', array('method' => __METHOD__, 'user' => $user->getUsername())); $user->setPassword($this->get('security.password_encoder') ->encodePassword($user, $password)); $em->flush(); $this->addFlash('success', $this->get('translator')->trans('Password successfully updated!')); return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); } return $this->render('ChillMainBundle:User:edit_password.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView(), )); }
php
public function updatePasswordAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('ChillMainBundle:User')->find($id); if (!$user) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditPasswordForm($user); $editForm->handleRequest($request); if ($editForm->isValid()) { $password = $editForm->getData()->getPassword(); // logging for debug !! WARNING print the new password !! $this->get('logger')->debug('update password for an user', array('method' => __METHOD__, 'password' => $password, 'user' => $user->getUsername())); // logging for prod $this->get('logger')->info('update password for an user', array('method' => __METHOD__, 'user' => $user->getUsername())); $user->setPassword($this->get('security.password_encoder') ->encodePassword($user, $password)); $em->flush(); $this->addFlash('success', $this->get('translator')->trans('Password successfully updated!')); return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); } return $this->render('ChillMainBundle:User:edit_password.html.twig', array( 'entity' => $user, 'edit_form' => $editForm->createView(), )); }
[ "public", "function", "updatePasswordAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:User'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "user", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find User entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditPasswordForm", "(", "$", "user", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "password", "=", "$", "editForm", "->", "getData", "(", ")", "->", "getPassword", "(", ")", ";", "// logging for debug !! WARNING print the new password !!", "$", "this", "->", "get", "(", "'logger'", ")", "->", "debug", "(", "'update password for an user'", ",", "array", "(", "'method'", "=>", "__METHOD__", ",", "'password'", "=>", "$", "password", ",", "'user'", "=>", "$", "user", "->", "getUsername", "(", ")", ")", ")", ";", "// logging for prod", "$", "this", "->", "get", "(", "'logger'", ")", "->", "info", "(", "'update password for an user'", ",", "array", "(", "'method'", "=>", "__METHOD__", ",", "'user'", "=>", "$", "user", "->", "getUsername", "(", ")", ")", ")", ";", "$", "user", "->", "setPassword", "(", "$", "this", "->", "get", "(", "'security.password_encoder'", ")", "->", "encodePassword", "(", "$", "user", ",", "$", "password", ")", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "addFlash", "(", "'success'", ",", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'Password successfully updated!'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_user_edit'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:User:edit_password.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "user", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Edits the user password
[ "Edits", "the", "user", "password" ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L343-L381
Chill-project/Main
Controller/UserController.php
UserController.createDeleteLinkGroupCenterForm
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_user_delete_group_center', array('uid' => $user->getId(), 'gcid' => $groupCenter->getId()))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() ; }
php
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_user_delete_group_center', array('uid' => $user->getId(), 'gcid' => $groupCenter->getId()))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() ; }
[ "private", "function", "createDeleteLinkGroupCenterForm", "(", "User", "$", "user", ",", "GroupCenter", "$", "groupCenter", ")", "{", "return", "$", "this", "->", "createFormBuilder", "(", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'admin_user_delete_group_center'", ",", "array", "(", "'uid'", "=>", "$", "user", "->", "getId", "(", ")", ",", "'gcid'", "=>", "$", "groupCenter", "->", "getId", "(", ")", ")", ")", ")", "->", "setMethod", "(", "'DELETE'", ")", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Delete'", ")", ")", "->", "getForm", "(", ")", ";", "}" ]
Creates a form to delete a link to a GroupCenter @param mixed $permissionsGroup The entity id @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "delete", "a", "link", "to", "a", "GroupCenter" ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L391-L400
Chill-project/Main
Controller/UserController.php
UserController.createAddLinkGroupCenterForm
private function createAddLinkGroupCenterForm(User $user) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_user_add_group_center', array('uid' => $user->getId()))) ->setMethod('POST') ->add(self::FORM_GROUP_CENTER_COMPOSED, new ComposedGroupCenterType()) ->add('submit', 'submit', array('label' => 'Add a new groupCenter')) ->getForm() ; }
php
private function createAddLinkGroupCenterForm(User $user) { return $this->createFormBuilder() ->setAction($this->generateUrl('admin_user_add_group_center', array('uid' => $user->getId()))) ->setMethod('POST') ->add(self::FORM_GROUP_CENTER_COMPOSED, new ComposedGroupCenterType()) ->add('submit', 'submit', array('label' => 'Add a new groupCenter')) ->getForm() ; }
[ "private", "function", "createAddLinkGroupCenterForm", "(", "User", "$", "user", ")", "{", "return", "$", "this", "->", "createFormBuilder", "(", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'admin_user_add_group_center'", ",", "array", "(", "'uid'", "=>", "$", "user", "->", "getId", "(", ")", ")", ")", ")", "->", "setMethod", "(", "'POST'", ")", "->", "add", "(", "self", "::", "FORM_GROUP_CENTER_COMPOSED", ",", "new", "ComposedGroupCenterType", "(", ")", ")", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Add a new groupCenter'", ")", ")", "->", "getForm", "(", ")", ";", "}" ]
create a form to add a link to a groupcenter @param User $user @return \Symfony\Component\Form\Form
[ "create", "a", "form", "to", "add", "a", "link", "to", "a", "groupcenter" ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/UserController.php#L408-L418
FuriosoJack/LaraException
src/Core/Manager.php
Manager.getCallBack
public function getCallBack($request, \Exception $exception) { foreach ($this->exceptionsCallbacks as $callback){ if(is_callable($callback)){ $data = call_user_func($callback,$request,$exception); if(!is_null($data)){ return $data; } } } }
php
public function getCallBack($request, \Exception $exception) { foreach ($this->exceptionsCallbacks as $callback){ if(is_callable($callback)){ $data = call_user_func($callback,$request,$exception); if(!is_null($data)){ return $data; } } } }
[ "public", "function", "getCallBack", "(", "$", "request", ",", "\\", "Exception", "$", "exception", ")", "{", "foreach", "(", "$", "this", "->", "exceptionsCallbacks", "as", "$", "callback", ")", "{", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "data", "=", "call_user_func", "(", "$", "callback", ",", "$", "request", ",", "$", "exception", ")", ";", "if", "(", "!", "is_null", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "}", "}", "}" ]
Obtiene el callback de excepcion que se mostrara Entonces Se obtiene el pimer callback que cumpla con que retorne algo @param $request @param \Exception $exception @return mixed
[ "Obtiene", "el", "callback", "de", "excepcion", "que", "se", "mostrara", "Entonces", "Se", "obtiene", "el", "pimer", "callback", "que", "cumpla", "con", "que", "retorne", "algo" ]
train
https://github.com/FuriosoJack/LaraException/blob/b30ec2ed3331d99fca4d0ae47c8710a522bd0c19/src/Core/Manager.php#L57-L68
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Section/Footer.php
PHPWord_Section_Footer.addTable
public function addTable($style = null) { $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); $this->_elementCollection[] = $table; return $table; }
php
public function addTable($style = null) { $table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); $this->_elementCollection[] = $table; return $table; }
[ "public", "function", "addTable", "(", "$", "style", "=", "null", ")", "{", "$", "table", "=", "new", "PHPWord_Section_Table", "(", "'footer'", ",", "$", "this", "->", "_footerCount", ",", "$", "style", ")", ";", "$", "this", "->", "_elementCollection", "[", "]", "=", "$", "table", ";", "return", "$", "table", ";", "}" ]
Add a Table Element @param mixed $style @return PHPWord_Section_Table
[ "Add", "a", "Table", "Element" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Footer.php#L108-L112
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Section/Footer.php
PHPWord_Section_Footer.addImage
public function addImage($src, $style = null) { $image = new PHPWord_Section_Image($src, $style); if(!is_null($image->getSource())) { $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); $image->setRelationId($rID); $this->_elementCollection[] = $image; return $image; } else { trigger_error('Src does not exist or invalid image type.', E_ERROR); } }
php
public function addImage($src, $style = null) { $image = new PHPWord_Section_Image($src, $style); if(!is_null($image->getSource())) { $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); $image->setRelationId($rID); $this->_elementCollection[] = $image; return $image; } else { trigger_error('Src does not exist or invalid image type.', E_ERROR); } }
[ "public", "function", "addImage", "(", "$", "src", ",", "$", "style", "=", "null", ")", "{", "$", "image", "=", "new", "PHPWord_Section_Image", "(", "$", "src", ",", "$", "style", ")", ";", "if", "(", "!", "is_null", "(", "$", "image", "->", "getSource", "(", ")", ")", ")", "{", "$", "rID", "=", "PHPWord_Media", "::", "addFooterMediaElement", "(", "$", "this", "->", "_footerCount", ",", "$", "src", ")", ";", "$", "image", "->", "setRelationId", "(", "$", "rID", ")", ";", "$", "this", "->", "_elementCollection", "[", "]", "=", "$", "image", ";", "return", "$", "image", ";", "}", "else", "{", "trigger_error", "(", "'Src does not exist or invalid image type.'", ",", "E_ERROR", ")", ";", "}", "}" ]
Add a Image Element @param string $src @param mixed $style @return PHPWord_Section_Image
[ "Add", "a", "Image", "Element" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Footer.php#L121-L133
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Section/Footer.php
PHPWord_Section_Footer.addMemoryImage
public function addMemoryImage($link, $style = null) { $memoryImage = new PHPWord_Section_MemoryImage($link, $style); if(!is_null($memoryImage->getSource())) { $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); $memoryImage->setRelationId($rID); $this->_elementCollection[] = $memoryImage; return $memoryImage; } else { trigger_error('Unsupported image type.'); } }
php
public function addMemoryImage($link, $style = null) { $memoryImage = new PHPWord_Section_MemoryImage($link, $style); if(!is_null($memoryImage->getSource())) { $rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); $memoryImage->setRelationId($rID); $this->_elementCollection[] = $memoryImage; return $memoryImage; } else { trigger_error('Unsupported image type.'); } }
[ "public", "function", "addMemoryImage", "(", "$", "link", ",", "$", "style", "=", "null", ")", "{", "$", "memoryImage", "=", "new", "PHPWord_Section_MemoryImage", "(", "$", "link", ",", "$", "style", ")", ";", "if", "(", "!", "is_null", "(", "$", "memoryImage", "->", "getSource", "(", ")", ")", ")", "{", "$", "rID", "=", "PHPWord_Media", "::", "addFooterMediaElement", "(", "$", "this", "->", "_footerCount", ",", "$", "link", ",", "$", "memoryImage", ")", ";", "$", "memoryImage", "->", "setRelationId", "(", "$", "rID", ")", ";", "$", "this", "->", "_elementCollection", "[", "]", "=", "$", "memoryImage", ";", "return", "$", "memoryImage", ";", "}", "else", "{", "trigger_error", "(", "'Unsupported image type.'", ")", ";", "}", "}" ]
Add a by PHP created Image Element @param string $link @param mixed $style @return PHPWord_Section_MemoryImage
[ "Add", "a", "by", "PHP", "created", "Image", "Element" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Footer.php#L142-L153
factorio-item-browser/export-data
src/Entity/Icon/Layer.php
Layer.writeData
public function writeData(): array { $dataBuilder = new DataBuilder(); $dataBuilder->setString('f', $this->getFileName(), '') ->setArray('c', $this->tintColor->writeData(), null, []) ->setInteger('x', $this->getOffsetX(), 0) ->setInteger('y', $this->getOffsetY(), 0) ->setFloat('s', $this->getScale(), 1.); return $dataBuilder->getData(); }
php
public function writeData(): array { $dataBuilder = new DataBuilder(); $dataBuilder->setString('f', $this->getFileName(), '') ->setArray('c', $this->tintColor->writeData(), null, []) ->setInteger('x', $this->getOffsetX(), 0) ->setInteger('y', $this->getOffsetY(), 0) ->setFloat('s', $this->getScale(), 1.); return $dataBuilder->getData(); }
[ "public", "function", "writeData", "(", ")", ":", "array", "{", "$", "dataBuilder", "=", "new", "DataBuilder", "(", ")", ";", "$", "dataBuilder", "->", "setString", "(", "'f'", ",", "$", "this", "->", "getFileName", "(", ")", ",", "''", ")", "->", "setArray", "(", "'c'", ",", "$", "this", "->", "tintColor", "->", "writeData", "(", ")", ",", "null", ",", "[", "]", ")", "->", "setInteger", "(", "'x'", ",", "$", "this", "->", "getOffsetX", "(", ")", ",", "0", ")", "->", "setInteger", "(", "'y'", ",", "$", "this", "->", "getOffsetY", "(", ")", ",", "0", ")", "->", "setFloat", "(", "'s'", ",", "$", "this", "->", "getScale", "(", ")", ",", "1.", ")", ";", "return", "$", "dataBuilder", "->", "getData", "(", ")", ";", "}" ]
Writes the entity data to an array. @return array
[ "Writes", "the", "entity", "data", "to", "an", "array", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Layer.php#L170-L179
factorio-item-browser/export-data
src/Entity/Icon/Layer.php
Layer.readData
public function readData(DataContainer $data) { $this->fileName = $data->getString('f', ''); $this->tintColor->readData($data->getObject('c')); $this->offsetX = $data->getInteger('x', 0); $this->offsetY = $data->getInteger('y', 0); $this->scale = $data->getFloat('s', 1.); return $this; }
php
public function readData(DataContainer $data) { $this->fileName = $data->getString('f', ''); $this->tintColor->readData($data->getObject('c')); $this->offsetX = $data->getInteger('x', 0); $this->offsetY = $data->getInteger('y', 0); $this->scale = $data->getFloat('s', 1.); return $this; }
[ "public", "function", "readData", "(", "DataContainer", "$", "data", ")", "{", "$", "this", "->", "fileName", "=", "$", "data", "->", "getString", "(", "'f'", ",", "''", ")", ";", "$", "this", "->", "tintColor", "->", "readData", "(", "$", "data", "->", "getObject", "(", "'c'", ")", ")", ";", "$", "this", "->", "offsetX", "=", "$", "data", "->", "getInteger", "(", "'x'", ",", "0", ")", ";", "$", "this", "->", "offsetY", "=", "$", "data", "->", "getInteger", "(", "'y'", ",", "0", ")", ";", "$", "this", "->", "scale", "=", "$", "data", "->", "getFloat", "(", "'s'", ",", "1.", ")", ";", "return", "$", "this", ";", "}" ]
Reads the entity data. @param DataContainer $data @return $this
[ "Reads", "the", "entity", "data", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Layer.php#L186-L194
factorio-item-browser/export-data
src/Entity/Icon/Layer.php
Layer.calculateHash
public function calculateHash(): string { return EntityUtils::calculateHashOfArray([ $this->fileName, $this->tintColor->calculateHash(), $this->offsetX, $this->offsetY, $this->scale, ]); }
php
public function calculateHash(): string { return EntityUtils::calculateHashOfArray([ $this->fileName, $this->tintColor->calculateHash(), $this->offsetX, $this->offsetY, $this->scale, ]); }
[ "public", "function", "calculateHash", "(", ")", ":", "string", "{", "return", "EntityUtils", "::", "calculateHashOfArray", "(", "[", "$", "this", "->", "fileName", ",", "$", "this", "->", "tintColor", "->", "calculateHash", "(", ")", ",", "$", "this", "->", "offsetX", ",", "$", "this", "->", "offsetY", ",", "$", "this", "->", "scale", ",", "]", ")", ";", "}" ]
Calculates a hash value representing the entity. @return string
[ "Calculates", "a", "hash", "value", "representing", "the", "entity", "." ]
train
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Layer.php#L200-L209
qcubed/orm
src/Query/Builder.php
Builder.setOrderByClause
public function setOrderByClause(Clause\OrderBy $objOrderByClause) { if ($this->objOrderByClause) { throw new Caller('You can only have one OrderBy clause in a query.'); } $this->objOrderByClause = $objOrderByClause; }
php
public function setOrderByClause(Clause\OrderBy $objOrderByClause) { if ($this->objOrderByClause) { throw new Caller('You can only have one OrderBy clause in a query.'); } $this->objOrderByClause = $objOrderByClause; }
[ "public", "function", "setOrderByClause", "(", "Clause", "\\", "OrderBy", "$", "objOrderByClause", ")", "{", "if", "(", "$", "this", "->", "objOrderByClause", ")", "{", "throw", "new", "Caller", "(", "'You can only have one OrderBy clause in a query.'", ")", ";", "}", "$", "this", "->", "objOrderByClause", "=", "$", "objOrderByClause", ";", "}" ]
Sets the one order by clause allowed in a query. Stores it for delayed processing. @param Clause\OrderBy $objOrderByClause @throws Caller
[ "Sets", "the", "one", "order", "by", "clause", "allowed", "in", "a", "query", ".", "Stores", "it", "for", "delayed", "processing", "." ]
train
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Builder.php#L455-L461
ray-di/Ray.ValidateModule
src/ValidateModule.php
ValidateModule.configure
protected function configure() { $this->bind(Reader::class)->to(AnnotationReader::class)->in(Scope::SINGLETON); $this->bindInterceptor( $this->matcher->any(), $this->matcher->annotatedWith(Valid::class), [ValidateInterceptor::class] ); }
php
protected function configure() { $this->bind(Reader::class)->to(AnnotationReader::class)->in(Scope::SINGLETON); $this->bindInterceptor( $this->matcher->any(), $this->matcher->annotatedWith(Valid::class), [ValidateInterceptor::class] ); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "bind", "(", "Reader", "::", "class", ")", "->", "to", "(", "AnnotationReader", "::", "class", ")", "->", "in", "(", "Scope", "::", "SINGLETON", ")", ";", "$", "this", "->", "bindInterceptor", "(", "$", "this", "->", "matcher", "->", "any", "(", ")", ",", "$", "this", "->", "matcher", "->", "annotatedWith", "(", "Valid", "::", "class", ")", ",", "[", "ValidateInterceptor", "::", "class", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.ValidateModule/blob/7e4e3c4a05e11dc989d689202ac6ae625695588e/src/ValidateModule.php#L20-L28
freearhey/sparql
src/GraphBuilder.php
GraphBuilder.service
public function service( $service, $subject, $predicate = null, $object = null ) { $graphBuilder = $this->getGraphBuilder( $subject, $predicate, $object ); $this->services[$service] = $graphBuilder->getSPARQL(); return $this; }
php
public function service( $service, $subject, $predicate = null, $object = null ) { $graphBuilder = $this->getGraphBuilder( $subject, $predicate, $object ); $this->services[$service] = $graphBuilder->getSPARQL(); return $this; }
[ "public", "function", "service", "(", "$", "service", ",", "$", "subject", ",", "$", "predicate", "=", "null", ",", "$", "object", "=", "null", ")", "{", "$", "graphBuilder", "=", "$", "this", "->", "getGraphBuilder", "(", "$", "subject", ",", "$", "predicate", ",", "$", "object", ")", ";", "$", "this", "->", "services", "[", "$", "service", "]", "=", "$", "graphBuilder", "->", "getSPARQL", "(", ")", ";", "return", "$", "this", ";", "}" ]
Adds the given graph or triple as an services condition. @param string|GraphBuilder $subject @param string|null $predicate @param string|null $object @return self @throws InvalidArgumentException
[ "Adds", "the", "given", "graph", "or", "triple", "as", "an", "services", "condition", "." ]
train
https://github.com/freearhey/sparql/blob/622a8ea661dc5939122b0e8b430a6a94b3bc49c7/src/GraphBuilder.php#L211-L215
CakeCMS/Core
src/Toolbar/ToolbarHelper.php
ToolbarHelper.add
public static function add($title = null, $url = ['action' => 'add'], $icon = 'plus', array $options = []) { $toolbar = Toolbar::getInstance(self::$_toolbar); $options += [ 'icon' => $icon, 'button' => 'green lighten-2' ]; $toolbar->appendButton('Core.link', $title, $url, $options); }
php
public static function add($title = null, $url = ['action' => 'add'], $icon = 'plus', array $options = []) { $toolbar = Toolbar::getInstance(self::$_toolbar); $options += [ 'icon' => $icon, 'button' => 'green lighten-2' ]; $toolbar->appendButton('Core.link', $title, $url, $options); }
[ "public", "static", "function", "add", "(", "$", "title", "=", "null", ",", "$", "url", "=", "[", "'action'", "=>", "'add'", "]", ",", "$", "icon", "=", "'plus'", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "toolbar", "=", "Toolbar", "::", "getInstance", "(", "self", "::", "$", "_toolbar", ")", ";", "$", "options", "+=", "[", "'icon'", "=>", "$", "icon", ",", "'button'", "=>", "'green lighten-2'", "]", ";", "$", "toolbar", "->", "appendButton", "(", "'Core.link'", ",", "$", "title", ",", "$", "url", ",", "$", "options", ")", ";", "}" ]
Create add link. @param string|null $title @param array|string $url @param string $icon @param array $options @return void
[ "Create", "add", "link", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarHelper.php#L48-L57
CakeCMS/Core
src/Toolbar/ToolbarHelper.php
ToolbarHelper.apply
public static function apply($title = null) { $toolbar = Toolbar::getInstance(self::$_toolbar); $title = (empty($title)) ? __d('core', 'Apply') : $title; $toolbar->appendButton('Core.action', $title, self::ACTION_APPLY, [ 'class' => 'jsFormButton', 'icon' => 'check-square-o', 'button' => 'green lighten-2', ]); }
php
public static function apply($title = null) { $toolbar = Toolbar::getInstance(self::$_toolbar); $title = (empty($title)) ? __d('core', 'Apply') : $title; $toolbar->appendButton('Core.action', $title, self::ACTION_APPLY, [ 'class' => 'jsFormButton', 'icon' => 'check-square-o', 'button' => 'green lighten-2', ]); }
[ "public", "static", "function", "apply", "(", "$", "title", "=", "null", ")", "{", "$", "toolbar", "=", "Toolbar", "::", "getInstance", "(", "self", "::", "$", "_toolbar", ")", ";", "$", "title", "=", "(", "empty", "(", "$", "title", ")", ")", "?", "__d", "(", "'core'", ",", "'Apply'", ")", ":", "$", "title", ";", "$", "toolbar", "->", "appendButton", "(", "'Core.action'", ",", "$", "title", ",", "self", "::", "ACTION_APPLY", ",", "[", "'class'", "=>", "'jsFormButton'", ",", "'icon'", "=>", "'check-square-o'", ",", "'button'", "=>", "'green lighten-2'", ",", "]", ")", ";", "}" ]
Apply form button. @param null|string $title @return void
[ "Apply", "form", "button", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarHelper.php#L65-L75
CakeCMS/Core
src/Toolbar/ToolbarHelper.php
ToolbarHelper.cancel
public static function cancel($title = null, $url = null, array $options = []) { $toolbar = Toolbar::getInstance(self::$_toolbar); $options += [ 'icon' => 'close', 'iconClass' => 'ckTextRed', 'button' => 'grey lighten-3' ]; if (empty($url)) { $url = ['action' => 'index']; } $title = (empty($title)) ? __d('core', 'Cancel') : $title; $toolbar->appendButton('Core.link', $title, $url, $options); }
php
public static function cancel($title = null, $url = null, array $options = []) { $toolbar = Toolbar::getInstance(self::$_toolbar); $options += [ 'icon' => 'close', 'iconClass' => 'ckTextRed', 'button' => 'grey lighten-3' ]; if (empty($url)) { $url = ['action' => 'index']; } $title = (empty($title)) ? __d('core', 'Cancel') : $title; $toolbar->appendButton('Core.link', $title, $url, $options); }
[ "public", "static", "function", "cancel", "(", "$", "title", "=", "null", ",", "$", "url", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "toolbar", "=", "Toolbar", "::", "getInstance", "(", "self", "::", "$", "_toolbar", ")", ";", "$", "options", "+=", "[", "'icon'", "=>", "'close'", ",", "'iconClass'", "=>", "'ckTextRed'", ",", "'button'", "=>", "'grey lighten-3'", "]", ";", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "$", "url", "=", "[", "'action'", "=>", "'index'", "]", ";", "}", "$", "title", "=", "(", "empty", "(", "$", "title", ")", ")", "?", "__d", "(", "'core'", ",", "'Cancel'", ")", ":", "$", "title", ";", "$", "toolbar", "->", "appendButton", "(", "'Core.link'", ",", "$", "title", ",", "$", "url", ",", "$", "options", ")", ";", "}" ]
Cancel form button. @param string|null $title @param null|string|array $url @param array $options @return void
[ "Cancel", "form", "button", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarHelper.php#L85-L101
CakeCMS/Core
src/Toolbar/ToolbarHelper.php
ToolbarHelper.delete
public static function delete($title = null) { $toolbar = Toolbar::getInstance(self::$_toolbar); $title = (empty($title)) ? __d('core', 'Delete') : $title; $toolbar->appendButton('Core.action', $title, self::ACTION_DELETE, []); }
php
public static function delete($title = null) { $toolbar = Toolbar::getInstance(self::$_toolbar); $title = (empty($title)) ? __d('core', 'Delete') : $title; $toolbar->appendButton('Core.action', $title, self::ACTION_DELETE, []); }
[ "public", "static", "function", "delete", "(", "$", "title", "=", "null", ")", "{", "$", "toolbar", "=", "Toolbar", "::", "getInstance", "(", "self", "::", "$", "_toolbar", ")", ";", "$", "title", "=", "(", "empty", "(", "$", "title", ")", ")", "?", "__d", "(", "'core'", ",", "'Delete'", ")", ":", "$", "title", ";", "$", "toolbar", "->", "appendButton", "(", "'Core.action'", ",", "$", "title", ",", "self", "::", "ACTION_DELETE", ",", "[", "]", ")", ";", "}" ]
Delete for process form. @param string|null $title @return void
[ "Delete", "for", "process", "form", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarHelper.php#L109-L115
CakeCMS/Core
src/Toolbar/ToolbarHelper.php
ToolbarHelper.link
public static function link($title, $url, array $options = []) { $toolbar = Toolbar::getInstance(self::$_toolbar); $options += [ 'icon' => 'link', 'button' => 'grey lighten-3' ]; $toolbar->appendButton('Core.link', $title, $url, $options); }
php
public static function link($title, $url, array $options = []) { $toolbar = Toolbar::getInstance(self::$_toolbar); $options += [ 'icon' => 'link', 'button' => 'grey lighten-3' ]; $toolbar->appendButton('Core.link', $title, $url, $options); }
[ "public", "static", "function", "link", "(", "$", "title", ",", "$", "url", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "toolbar", "=", "Toolbar", "::", "getInstance", "(", "self", "::", "$", "_toolbar", ")", ";", "$", "options", "+=", "[", "'icon'", "=>", "'link'", ",", "'button'", "=>", "'grey lighten-3'", "]", ";", "$", "toolbar", "->", "appendButton", "(", "'Core.link'", ",", "$", "title", ",", "$", "url", ",", "$", "options", ")", ";", "}" ]
Create link output. @param string $title @param string|array $url @param array $options
[ "Create", "link", "output", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarHelper.php#L124-L133
CakeCMS/Core
src/Toolbar/ToolbarHelper.php
ToolbarHelper.save
public static function save($title = null) { $toolbar = Toolbar::getInstance(self::$_toolbar); $title = (empty($title)) ? __d('core', 'Save') : $title; $toolbar->appendButton('Core.action', $title, self::ACTION_SAVE, [ 'icon' => 'check', 'class' => 'jsFormButton', 'iconClass' => 'ckTextGreen', 'button' => 'grey lighten-3', ]); }
php
public static function save($title = null) { $toolbar = Toolbar::getInstance(self::$_toolbar); $title = (empty($title)) ? __d('core', 'Save') : $title; $toolbar->appendButton('Core.action', $title, self::ACTION_SAVE, [ 'icon' => 'check', 'class' => 'jsFormButton', 'iconClass' => 'ckTextGreen', 'button' => 'grey lighten-3', ]); }
[ "public", "static", "function", "save", "(", "$", "title", "=", "null", ")", "{", "$", "toolbar", "=", "Toolbar", "::", "getInstance", "(", "self", "::", "$", "_toolbar", ")", ";", "$", "title", "=", "(", "empty", "(", "$", "title", ")", ")", "?", "__d", "(", "'core'", ",", "'Save'", ")", ":", "$", "title", ";", "$", "toolbar", "->", "appendButton", "(", "'Core.action'", ",", "$", "title", ",", "self", "::", "ACTION_SAVE", ",", "[", "'icon'", "=>", "'check'", ",", "'class'", "=>", "'jsFormButton'", ",", "'iconClass'", "=>", "'ckTextGreen'", ",", "'button'", "=>", "'grey lighten-3'", ",", "]", ")", ";", "}" ]
Save form button. @param null|string $title @return void
[ "Save", "form", "button", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarHelper.php#L141-L152
afrittella/back-project
src/app/Http/Controllers/Auth/ResetPasswordController.php
ResetPasswordController.showResetForm
public function showResetForm(Request $request, $token = null) { $this->data['title'] = trans('back-project::base.reset_password'); // set the page title return view('back-project::auth.passwords.reset', $this->data)->with( ['token' => $token, 'email' => $request->email] ); }
php
public function showResetForm(Request $request, $token = null) { $this->data['title'] = trans('back-project::base.reset_password'); // set the page title return view('back-project::auth.passwords.reset', $this->data)->with( ['token' => $token, 'email' => $request->email] ); }
[ "public", "function", "showResetForm", "(", "Request", "$", "request", ",", "$", "token", "=", "null", ")", "{", "$", "this", "->", "data", "[", "'title'", "]", "=", "trans", "(", "'back-project::base.reset_password'", ")", ";", "// set the page title", "return", "view", "(", "'back-project::auth.passwords.reset'", ",", "$", "this", "->", "data", ")", "->", "with", "(", "[", "'token'", "=>", "$", "token", ",", "'email'", "=>", "$", "request", "->", "email", "]", ")", ";", "}" ]
Display the password reset view for the given token. If no token is present, display the link request form. @param \Illuminate\Http\Request $request @param string|null $token @return \Illuminate\Http\Response
[ "Display", "the", "password", "reset", "view", "for", "the", "given", "token", "." ]
train
https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Http/Controllers/Auth/ResetPasswordController.php#L48-L55
ripaclub/zf2-sphinxsearch-tool
src/Controller/Traits/ConfigTrait.php
ConfigTrait.getConfig
protected function getConfig($file = null) { // Config $appConfig = $this->getServiceLocator()->get('Config'); if (!isset($appConfig['sphinxsearch'])) { throw new \InvalidArgumentException('Config not found with name: "sphinxsearch"'); } else { $config = new Config($appConfig['sphinxsearch'], true); // defaults if (!is_null($file)) { $fileConfig = Factory::fromFile($file, true); if (!isset($fileConfig['sphinxsearch'])) { throw new \InvalidArgumentException('Config not found with name: "sphinxsearch"'); } $config->merge($fileConfig['sphinxsearch']); } } return $config; }
php
protected function getConfig($file = null) { // Config $appConfig = $this->getServiceLocator()->get('Config'); if (!isset($appConfig['sphinxsearch'])) { throw new \InvalidArgumentException('Config not found with name: "sphinxsearch"'); } else { $config = new Config($appConfig['sphinxsearch'], true); // defaults if (!is_null($file)) { $fileConfig = Factory::fromFile($file, true); if (!isset($fileConfig['sphinxsearch'])) { throw new \InvalidArgumentException('Config not found with name: "sphinxsearch"'); } $config->merge($fileConfig['sphinxsearch']); } } return $config; }
[ "protected", "function", "getConfig", "(", "$", "file", "=", "null", ")", "{", "// Config", "$", "appConfig", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Config'", ")", ";", "if", "(", "!", "isset", "(", "$", "appConfig", "[", "'sphinxsearch'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Config not found with name: \"sphinxsearch\"'", ")", ";", "}", "else", "{", "$", "config", "=", "new", "Config", "(", "$", "appConfig", "[", "'sphinxsearch'", "]", ",", "true", ")", ";", "// defaults", "if", "(", "!", "is_null", "(", "$", "file", ")", ")", "{", "$", "fileConfig", "=", "Factory", "::", "fromFile", "(", "$", "file", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "fileConfig", "[", "'sphinxsearch'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Config not found with name: \"sphinxsearch\"'", ")", ";", "}", "$", "config", "->", "merge", "(", "$", "fileConfig", "[", "'sphinxsearch'", "]", ")", ";", "}", "}", "return", "$", "config", ";", "}" ]
Retrieve the config of sphinxsearch node @param string|null $file @return Config
[ "Retrieve", "the", "config", "of", "sphinxsearch", "node" ]
train
https://github.com/ripaclub/zf2-sphinxsearch-tool/blob/4cb51341ccf1db9942e3e578855a579afd608d69/src/Controller/Traits/ConfigTrait.php#L27-L46
steeffeen/FancyManiaLinks
FML/Stylesheet/SkyGradientKey.php
SkyGradientKey.render
public function render(\DOMDocument $domDocument) { $domElement = $domDocument->createElement("key"); $domElement->setAttribute("x", $this->x); $domElement->setAttribute("color", $this->color); return $domElement; }
php
public function render(\DOMDocument $domDocument) { $domElement = $domDocument->createElement("key"); $domElement->setAttribute("x", $this->x); $domElement->setAttribute("color", $this->color); return $domElement; }
[ "public", "function", "render", "(", "\\", "DOMDocument", "$", "domDocument", ")", "{", "$", "domElement", "=", "$", "domDocument", "->", "createElement", "(", "\"key\"", ")", ";", "$", "domElement", "->", "setAttribute", "(", "\"x\"", ",", "$", "this", "->", "x", ")", ";", "$", "domElement", "->", "setAttribute", "(", "\"color\"", ",", "$", "this", "->", "color", ")", ";", "return", "$", "domElement", ";", "}" ]
Render the SkyGradientKey @param \DOMDocument $domDocument DOMDocument for which the Sky Gradient Key should be rendered @return \DOMElement
[ "Render", "the", "SkyGradientKey" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/SkyGradientKey.php#L109-L115
m0ppers/MopArangoDbBundle
DependencyInjection/MopArangoDbExtension.php
MopArangoDbExtension.load
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration($container->getParameter('kernel.debug')); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); if (true === $container->getParameter('kernel.debug')) { $loader->load('logger.xml'); } if (isset($config['connections'])) { if (!isset($config['default_connection'])) { $keys = array_keys($config['connections']); $config['default_connection'] = reset($keys); } $loader->load('connection.xml'); foreach ($config['connections'] as $name => $connection) { $arguments = array_merge(array($name), array_values($connection)); $logger = new Reference('mop_arangodb.data_collector'); if (true === $container->getParameter('kernel.debug')) { $container->getDefinition('mop_arangodb.connection_factory')->addMethodCall('addLogger', array($logger)); } $container ->setDefinition('mop_arangodb.connections.'.$name, new DefinitionDecorator('mop_arangodb.connection')) ->setArguments($arguments); } } if ($config['default_connection']) { $container->setAlias('mop_arangodb.default_connection', 'mop_arangodb.connections.'.$config['default_connection']); } if (isset($config['fos'])) { $container->setParameter('mop_arangodb.fos.collection', $config['fos']['collection']); $container->setAlias('mop_arangodb.fos.connection', 'mop_arangodb.connections.'.$config['fos']['connection']); $loader->load('fos.xml'); } }
php
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration($container->getParameter('kernel.debug')); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); if (true === $container->getParameter('kernel.debug')) { $loader->load('logger.xml'); } if (isset($config['connections'])) { if (!isset($config['default_connection'])) { $keys = array_keys($config['connections']); $config['default_connection'] = reset($keys); } $loader->load('connection.xml'); foreach ($config['connections'] as $name => $connection) { $arguments = array_merge(array($name), array_values($connection)); $logger = new Reference('mop_arangodb.data_collector'); if (true === $container->getParameter('kernel.debug')) { $container->getDefinition('mop_arangodb.connection_factory')->addMethodCall('addLogger', array($logger)); } $container ->setDefinition('mop_arangodb.connections.'.$name, new DefinitionDecorator('mop_arangodb.connection')) ->setArguments($arguments); } } if ($config['default_connection']) { $container->setAlias('mop_arangodb.default_connection', 'mop_arangodb.connections.'.$config['default_connection']); } if (isset($config['fos'])) { $container->setParameter('mop_arangodb.fos.collection', $config['fos']['collection']); $container->setAlias('mop_arangodb.fos.connection', 'mop_arangodb.connections.'.$config['fos']['connection']); $loader->load('fos.xml'); } }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "configuration", "=", "new", "Configuration", "(", "$", "container", "->", "getParameter", "(", "'kernel.debug'", ")", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "$", "loader", "=", "new", "Loader", "\\", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "if", "(", "true", "===", "$", "container", "->", "getParameter", "(", "'kernel.debug'", ")", ")", "{", "$", "loader", "->", "load", "(", "'logger.xml'", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'connections'", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'default_connection'", "]", ")", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "config", "[", "'connections'", "]", ")", ";", "$", "config", "[", "'default_connection'", "]", "=", "reset", "(", "$", "keys", ")", ";", "}", "$", "loader", "->", "load", "(", "'connection.xml'", ")", ";", "foreach", "(", "$", "config", "[", "'connections'", "]", "as", "$", "name", "=>", "$", "connection", ")", "{", "$", "arguments", "=", "array_merge", "(", "array", "(", "$", "name", ")", ",", "array_values", "(", "$", "connection", ")", ")", ";", "$", "logger", "=", "new", "Reference", "(", "'mop_arangodb.data_collector'", ")", ";", "if", "(", "true", "===", "$", "container", "->", "getParameter", "(", "'kernel.debug'", ")", ")", "{", "$", "container", "->", "getDefinition", "(", "'mop_arangodb.connection_factory'", ")", "->", "addMethodCall", "(", "'addLogger'", ",", "array", "(", "$", "logger", ")", ")", ";", "}", "$", "container", "->", "setDefinition", "(", "'mop_arangodb.connections.'", ".", "$", "name", ",", "new", "DefinitionDecorator", "(", "'mop_arangodb.connection'", ")", ")", "->", "setArguments", "(", "$", "arguments", ")", ";", "}", "}", "if", "(", "$", "config", "[", "'default_connection'", "]", ")", "{", "$", "container", "->", "setAlias", "(", "'mop_arangodb.default_connection'", ",", "'mop_arangodb.connections.'", ".", "$", "config", "[", "'default_connection'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'fos'", "]", ")", ")", "{", "$", "container", "->", "setParameter", "(", "'mop_arangodb.fos.collection'", ",", "$", "config", "[", "'fos'", "]", "[", "'collection'", "]", ")", ";", "$", "container", "->", "setAlias", "(", "'mop_arangodb.fos.connection'", ",", "'mop_arangodb.connections.'", ".", "$", "config", "[", "'fos'", "]", "[", "'connection'", "]", ")", ";", "$", "loader", "->", "load", "(", "'fos.xml'", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/m0ppers/MopArangoDbBundle/blob/95ea747f0a6ddce434605038021525e98d98a83e/DependencyInjection/MopArangoDbExtension.php#L22-L61
steeffeen/FancyManiaLinks
FML/Controls/Graph.php
Graph.createSettings
protected function createSettings() { $this->graphSettings = new GraphSettings($this); $this->addScriptFeature($this->graphSettings); return $this->graphSettings; }
php
protected function createSettings() { $this->graphSettings = new GraphSettings($this); $this->addScriptFeature($this->graphSettings); return $this->graphSettings; }
[ "protected", "function", "createSettings", "(", ")", "{", "$", "this", "->", "graphSettings", "=", "new", "GraphSettings", "(", "$", "this", ")", ";", "$", "this", "->", "addScriptFeature", "(", "$", "this", "->", "graphSettings", ")", ";", "return", "$", "this", "->", "graphSettings", ";", "}" ]
Create new graph settings @return GraphSettings
[ "Create", "new", "graph", "settings" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Graph.php#L48-L53
steeffeen/FancyManiaLinks
FML/Controls/Graph.php
Graph.addCurve
public function addCurve(GraphCurve $curve) { $curve->setGraph($this); $this->addScriptFeature($curve); array_push($this->curves, $curve); return $this; }
php
public function addCurve(GraphCurve $curve) { $curve->setGraph($this); $this->addScriptFeature($curve); array_push($this->curves, $curve); return $this; }
[ "public", "function", "addCurve", "(", "GraphCurve", "$", "curve", ")", "{", "$", "curve", "->", "setGraph", "(", "$", "this", ")", ";", "$", "this", "->", "addScriptFeature", "(", "$", "curve", ")", ";", "array_push", "(", "$", "this", "->", "curves", ",", "$", "curve", ")", ";", "return", "$", "this", ";", "}" ]
Add curve @api @param GraphCurve $curve Curve @return static
[ "Add", "curve" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Graph.php#L73-L79
iocaste/microservice-foundation
src/Data/Models/Parameter/Parameter.php
Parameter.choices
public function choices(): HasMany { return $this->hasMany(\Iocaste\Microservice\Foundation\Data\Models\Parameter\Choice::class); }
php
public function choices(): HasMany { return $this->hasMany(\Iocaste\Microservice\Foundation\Data\Models\Parameter\Choice::class); }
[ "public", "function", "choices", "(", ")", ":", "HasMany", "{", "return", "$", "this", "->", "hasMany", "(", "\\", "Iocaste", "\\", "Microservice", "\\", "Foundation", "\\", "Data", "\\", "Models", "\\", "Parameter", "\\", "Choice", "::", "class", ")", ";", "}" ]
One-to-Many Relationship One Parameter has Many Choices. @return \Illuminate\Database\Eloquent\Relations\HasMany
[ "One", "-", "to", "-", "Many", "Relationship", "One", "Parameter", "has", "Many", "Choices", "." ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Data/Models/Parameter/Parameter.php#L71-L74
phrest/sdk
src/Generator/Helper/ClassDiff.php
ClassDiff.getGeneratorFromReflection
public function getGeneratorFromReflection(ClassReflection $classReflection) { // class generator $cg = new ClassGenerator($classReflection->getName()); $cg->setSourceContent($cg->getSourceContent()); $cg->setSourceDirty(false); if ($classReflection->getDocComment() != '') { $docblock = DocBlockGenerator::fromReflection($classReflection->getDocBlock()); $docblock->setIndentation(Generator::$indentation); $cg->setDocBlock($docblock); } $cg->setAbstract($classReflection->isAbstract()); // set the namespace if ($classReflection->inNamespace()) { $cg->setNamespaceName($classReflection->getNamespaceName()); } /* @var \Zend\Code\Reflection\ClassReflection $parentClass */ $parentClass = $classReflection->getParentClass(); if ($parentClass) { $cg->setExtendedClass('\\' . ltrim($parentClass->getName(), '\\')); $interfaces = array_diff($classReflection->getInterfaces(), $parentClass->getInterfaces()); } else { $interfaces = $classReflection->getInterfaces(); } $interfaceNames = array(); foreach ($interfaces as $interface) { /* @var \Zend\Code\Reflection\ClassReflection $interface */ $interfaceNames[] = $interface->getName(); } $cg->setImplementedInterfaces($interfaceNames); $properties = array(); foreach ($classReflection->getProperties() as $reflectionProperty) { if ( $reflectionProperty->getDeclaringClass()->getName() == $classReflection->getName() ) { $property = PropertyGenerator::fromReflection($reflectionProperty); $property->setIndentation(Generator::$indentation); $properties[] = $property; } } $cg->addProperties($properties); $methods = array(); foreach ($classReflection->getMethods() as $reflectionMethod) { $className = ($cg->getNamespaceName()) ? $cg->getNamespaceName() . "\\" . $cg->getName() : $cg->getName(); if ($reflectionMethod->getDeclaringClass()->getName() == $className) { $method = MethodGenerator::fromReflection($reflectionMethod); $method->setBody( preg_replace( "/^" . Generator::$indentation . Generator::$indentation . "/m", '', $method->getBody() ) ); $method->setIndentation(Generator::$indentation); $methods[] = $method; } } $cg->addMethods($methods); return $cg; }
php
public function getGeneratorFromReflection(ClassReflection $classReflection) { // class generator $cg = new ClassGenerator($classReflection->getName()); $cg->setSourceContent($cg->getSourceContent()); $cg->setSourceDirty(false); if ($classReflection->getDocComment() != '') { $docblock = DocBlockGenerator::fromReflection($classReflection->getDocBlock()); $docblock->setIndentation(Generator::$indentation); $cg->setDocBlock($docblock); } $cg->setAbstract($classReflection->isAbstract()); // set the namespace if ($classReflection->inNamespace()) { $cg->setNamespaceName($classReflection->getNamespaceName()); } /* @var \Zend\Code\Reflection\ClassReflection $parentClass */ $parentClass = $classReflection->getParentClass(); if ($parentClass) { $cg->setExtendedClass('\\' . ltrim($parentClass->getName(), '\\')); $interfaces = array_diff($classReflection->getInterfaces(), $parentClass->getInterfaces()); } else { $interfaces = $classReflection->getInterfaces(); } $interfaceNames = array(); foreach ($interfaces as $interface) { /* @var \Zend\Code\Reflection\ClassReflection $interface */ $interfaceNames[] = $interface->getName(); } $cg->setImplementedInterfaces($interfaceNames); $properties = array(); foreach ($classReflection->getProperties() as $reflectionProperty) { if ( $reflectionProperty->getDeclaringClass()->getName() == $classReflection->getName() ) { $property = PropertyGenerator::fromReflection($reflectionProperty); $property->setIndentation(Generator::$indentation); $properties[] = $property; } } $cg->addProperties($properties); $methods = array(); foreach ($classReflection->getMethods() as $reflectionMethod) { $className = ($cg->getNamespaceName()) ? $cg->getNamespaceName() . "\\" . $cg->getName() : $cg->getName(); if ($reflectionMethod->getDeclaringClass()->getName() == $className) { $method = MethodGenerator::fromReflection($reflectionMethod); $method->setBody( preg_replace( "/^" . Generator::$indentation . Generator::$indentation . "/m", '', $method->getBody() ) ); $method->setIndentation(Generator::$indentation); $methods[] = $method; } } $cg->addMethods($methods); return $cg; }
[ "public", "function", "getGeneratorFromReflection", "(", "ClassReflection", "$", "classReflection", ")", "{", "// class generator", "$", "cg", "=", "new", "ClassGenerator", "(", "$", "classReflection", "->", "getName", "(", ")", ")", ";", "$", "cg", "->", "setSourceContent", "(", "$", "cg", "->", "getSourceContent", "(", ")", ")", ";", "$", "cg", "->", "setSourceDirty", "(", "false", ")", ";", "if", "(", "$", "classReflection", "->", "getDocComment", "(", ")", "!=", "''", ")", "{", "$", "docblock", "=", "DocBlockGenerator", "::", "fromReflection", "(", "$", "classReflection", "->", "getDocBlock", "(", ")", ")", ";", "$", "docblock", "->", "setIndentation", "(", "Generator", "::", "$", "indentation", ")", ";", "$", "cg", "->", "setDocBlock", "(", "$", "docblock", ")", ";", "}", "$", "cg", "->", "setAbstract", "(", "$", "classReflection", "->", "isAbstract", "(", ")", ")", ";", "// set the namespace", "if", "(", "$", "classReflection", "->", "inNamespace", "(", ")", ")", "{", "$", "cg", "->", "setNamespaceName", "(", "$", "classReflection", "->", "getNamespaceName", "(", ")", ")", ";", "}", "/* @var \\Zend\\Code\\Reflection\\ClassReflection $parentClass */", "$", "parentClass", "=", "$", "classReflection", "->", "getParentClass", "(", ")", ";", "if", "(", "$", "parentClass", ")", "{", "$", "cg", "->", "setExtendedClass", "(", "'\\\\'", ".", "ltrim", "(", "$", "parentClass", "->", "getName", "(", ")", ",", "'\\\\'", ")", ")", ";", "$", "interfaces", "=", "array_diff", "(", "$", "classReflection", "->", "getInterfaces", "(", ")", ",", "$", "parentClass", "->", "getInterfaces", "(", ")", ")", ";", "}", "else", "{", "$", "interfaces", "=", "$", "classReflection", "->", "getInterfaces", "(", ")", ";", "}", "$", "interfaceNames", "=", "array", "(", ")", ";", "foreach", "(", "$", "interfaces", "as", "$", "interface", ")", "{", "/* @var \\Zend\\Code\\Reflection\\ClassReflection $interface */", "$", "interfaceNames", "[", "]", "=", "$", "interface", "->", "getName", "(", ")", ";", "}", "$", "cg", "->", "setImplementedInterfaces", "(", "$", "interfaceNames", ")", ";", "$", "properties", "=", "array", "(", ")", ";", "foreach", "(", "$", "classReflection", "->", "getProperties", "(", ")", "as", "$", "reflectionProperty", ")", "{", "if", "(", "$", "reflectionProperty", "->", "getDeclaringClass", "(", ")", "->", "getName", "(", ")", "==", "$", "classReflection", "->", "getName", "(", ")", ")", "{", "$", "property", "=", "PropertyGenerator", "::", "fromReflection", "(", "$", "reflectionProperty", ")", ";", "$", "property", "->", "setIndentation", "(", "Generator", "::", "$", "indentation", ")", ";", "$", "properties", "[", "]", "=", "$", "property", ";", "}", "}", "$", "cg", "->", "addProperties", "(", "$", "properties", ")", ";", "$", "methods", "=", "array", "(", ")", ";", "foreach", "(", "$", "classReflection", "->", "getMethods", "(", ")", "as", "$", "reflectionMethod", ")", "{", "$", "className", "=", "(", "$", "cg", "->", "getNamespaceName", "(", ")", ")", "?", "$", "cg", "->", "getNamespaceName", "(", ")", ".", "\"\\\\\"", ".", "$", "cg", "->", "getName", "(", ")", ":", "$", "cg", "->", "getName", "(", ")", ";", "if", "(", "$", "reflectionMethod", "->", "getDeclaringClass", "(", ")", "->", "getName", "(", ")", "==", "$", "className", ")", "{", "$", "method", "=", "MethodGenerator", "::", "fromReflection", "(", "$", "reflectionMethod", ")", ";", "$", "method", "->", "setBody", "(", "preg_replace", "(", "\"/^\"", ".", "Generator", "::", "$", "indentation", ".", "Generator", "::", "$", "indentation", ".", "\"/m\"", ",", "''", ",", "$", "method", "->", "getBody", "(", ")", ")", ")", ";", "$", "method", "->", "setIndentation", "(", "Generator", "::", "$", "indentation", ")", ";", "$", "methods", "[", "]", "=", "$", "method", ";", "}", "}", "$", "cg", "->", "addMethods", "(", "$", "methods", ")", ";", "return", "$", "cg", ";", "}" ]
Copied from ClassGenerator::fromReflection and tweaked slightly @param ClassReflection $classReflection @return ClassGenerator
[ "Copied", "from", "ClassGenerator", "::", "fromReflection", "and", "tweaked", "slightly" ]
train
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator/Helper/ClassDiff.php#L140-L223
userfriendly/SocialUserBundle
Model/User.php
User.setEmail
public function setEmail( $email ) { if ( !$email ) $this->setEmailCanonical( NULL ); if ( NULL === $email ) $email = ''; return parent::setEmail($email); }
php
public function setEmail( $email ) { if ( !$email ) $this->setEmailCanonical( NULL ); if ( NULL === $email ) $email = ''; return parent::setEmail($email); }
[ "public", "function", "setEmail", "(", "$", "email", ")", "{", "if", "(", "!", "$", "email", ")", "$", "this", "->", "setEmailCanonical", "(", "NULL", ")", ";", "if", "(", "NULL", "===", "$", "email", ")", "$", "email", "=", "''", ";", "return", "parent", "::", "setEmail", "(", "$", "email", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/Model/User.php#L81-L86
userfriendly/SocialUserBundle
Model/User.php
User.getIdentitiesAsStrings
public function getIdentitiesAsStrings() { $result = array(); foreach ( $this->identities as $identity ) { $result[] = $identity->getTypeString(); } return $result; }
php
public function getIdentitiesAsStrings() { $result = array(); foreach ( $this->identities as $identity ) { $result[] = $identity->getTypeString(); } return $result; }
[ "public", "function", "getIdentitiesAsStrings", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "identities", "as", "$", "identity", ")", "{", "$", "result", "[", "]", "=", "$", "identity", "->", "getTypeString", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/Model/User.php#L177-L185
linkorb/database-manager
src/DatabaseManager/Command/ConnectionConfigCommand.php
ConnectionConfigCommand.configure
protected function configure() { $this->ignoreValidationErrors(); $this ->setName('connection:config') ->setDefinition(array( new InputArgument('dbname', InputArgument::REQUIRED, 'Database name') )) ->setDescription('Display datatbase configuration info') ; }
php
protected function configure() { $this->ignoreValidationErrors(); $this ->setName('connection:config') ->setDefinition(array( new InputArgument('dbname', InputArgument::REQUIRED, 'Database name') )) ->setDescription('Display datatbase configuration info') ; }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "ignoreValidationErrors", "(", ")", ";", "$", "this", "->", "setName", "(", "'connection:config'", ")", "->", "setDefinition", "(", "array", "(", "new", "InputArgument", "(", "'dbname'", ",", "InputArgument", "::", "REQUIRED", ",", "'Database name'", ")", ")", ")", "->", "setDescription", "(", "'Display datatbase configuration info'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/linkorb/database-manager/blob/7e3eabfe9a85ec31b0a1097bcf64c3a1f819156a/src/DatabaseManager/Command/ConnectionConfigCommand.php#L25-L36
linkorb/database-manager
src/DatabaseManager/Command/ConnectionConfigCommand.php
ConnectionConfigCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $dbname = $input->getArgument('dbname'); $manager = new DatabaseManager(); $databaseconfig = $manager->getDatabaseConfigByDatabaseName($dbname); echo "NAME: [" . $databaseconfig->getName() . "]\n"; foreach ($databaseconfig->getConnectionConfigs() as $connectionconfig) { echo " Connection [" . $connectionconfig->getName() . "]\n"; echo " dsn: [" . $connectionconfig->getDsn() . "]\n"; echo " username: [" . $connectionconfig->getUsername() . "]\n"; echo " password: [" . $connectionconfig->getPassword() . "]\n"; echo " host: [" . $connectionconfig->getHost() . "]\n"; echo " port: [" . $connectionconfig->getPort() . "]\n"; echo "\n"; } $pdo = $manager->getPdo($dbname, 'default'); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $dbname = $input->getArgument('dbname'); $manager = new DatabaseManager(); $databaseconfig = $manager->getDatabaseConfigByDatabaseName($dbname); echo "NAME: [" . $databaseconfig->getName() . "]\n"; foreach ($databaseconfig->getConnectionConfigs() as $connectionconfig) { echo " Connection [" . $connectionconfig->getName() . "]\n"; echo " dsn: [" . $connectionconfig->getDsn() . "]\n"; echo " username: [" . $connectionconfig->getUsername() . "]\n"; echo " password: [" . $connectionconfig->getPassword() . "]\n"; echo " host: [" . $connectionconfig->getHost() . "]\n"; echo " port: [" . $connectionconfig->getPort() . "]\n"; echo "\n"; } $pdo = $manager->getPdo($dbname, 'default'); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "dbname", "=", "$", "input", "->", "getArgument", "(", "'dbname'", ")", ";", "$", "manager", "=", "new", "DatabaseManager", "(", ")", ";", "$", "databaseconfig", "=", "$", "manager", "->", "getDatabaseConfigByDatabaseName", "(", "$", "dbname", ")", ";", "echo", "\"NAME: [\"", ".", "$", "databaseconfig", "->", "getName", "(", ")", ".", "\"]\\n\"", ";", "foreach", "(", "$", "databaseconfig", "->", "getConnectionConfigs", "(", ")", "as", "$", "connectionconfig", ")", "{", "echo", "\" Connection [\"", ".", "$", "connectionconfig", "->", "getName", "(", ")", ".", "\"]\\n\"", ";", "echo", "\" dsn: [\"", ".", "$", "connectionconfig", "->", "getDsn", "(", ")", ".", "\"]\\n\"", ";", "echo", "\" username: [\"", ".", "$", "connectionconfig", "->", "getUsername", "(", ")", ".", "\"]\\n\"", ";", "echo", "\" password: [\"", ".", "$", "connectionconfig", "->", "getPassword", "(", ")", ".", "\"]\\n\"", ";", "echo", "\" host: [\"", ".", "$", "connectionconfig", "->", "getHost", "(", ")", ".", "\"]\\n\"", ";", "echo", "\" port: [\"", ".", "$", "connectionconfig", "->", "getPort", "(", ")", ".", "\"]\\n\"", ";", "echo", "\"\\n\"", ";", "}", "$", "pdo", "=", "$", "manager", "->", "getPdo", "(", "$", "dbname", ",", "'default'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/linkorb/database-manager/blob/7e3eabfe9a85ec31b0a1097bcf64c3a1f819156a/src/DatabaseManager/Command/ConnectionConfigCommand.php#L41-L61
milkyway-multimedia/ss-mwm-formfields
src/Composite/Model/ComponentFieldHolder.php
ComponentFieldHolder.getTemplates
public function getTemplates() { $template = parent::getTemplates(); if ($default = $this->defaultTemplate) { $key = array_search('FormField', $template); if ($key !== false) { $default[$key] = $this->defaultTemplate; } } return $template; }
php
public function getTemplates() { $template = parent::getTemplates(); if ($default = $this->defaultTemplate) { $key = array_search('FormField', $template); if ($key !== false) { $default[$key] = $this->defaultTemplate; } } return $template; }
[ "public", "function", "getTemplates", "(", ")", "{", "$", "template", "=", "parent", "::", "getTemplates", "(", ")", ";", "if", "(", "$", "default", "=", "$", "this", "->", "defaultTemplate", ")", "{", "$", "key", "=", "array_search", "(", "'FormField'", ",", "$", "template", ")", ";", "if", "(", "$", "key", "!==", "false", ")", "{", "$", "default", "[", "$", "key", "]", "=", "$", "this", "->", "defaultTemplate", ";", "}", "}", "return", "$", "template", ";", "}" ]
Returns an array of templates to use for rendering {@link FieldH} @return array
[ "Returns", "an", "array", "of", "templates", "to", "use", "for", "rendering", "{", "@link", "FieldH", "}" ]
train
https://github.com/milkyway-multimedia/ss-mwm-formfields/blob/b98d84d494c92d6881dcea50c9c8334e5f487e1d/src/Composite/Model/ComponentFieldHolder.php#L157-L170
ClanCats/Core
src/classes/CCCookie.php
CCCookie.set
public static function set( $key, $value, $expire = 0 ) { // set the expire date if ( $expire > 0 ) { if ( $expire < time() ) { $expire = time() + $expire; } } CCServer::$_instance->COOKIE[$key] = $value; /* * Finally set the cookie * @toDo: just at the cookie to an array an set the set cookie header from the CCResponse */ return setcookie( $key, $value, $expire, static::$path, static::$domain, static::$secure, static::$httponly ); }
php
public static function set( $key, $value, $expire = 0 ) { // set the expire date if ( $expire > 0 ) { if ( $expire < time() ) { $expire = time() + $expire; } } CCServer::$_instance->COOKIE[$key] = $value; /* * Finally set the cookie * @toDo: just at the cookie to an array an set the set cookie header from the CCResponse */ return setcookie( $key, $value, $expire, static::$path, static::$domain, static::$secure, static::$httponly ); }
[ "public", "static", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "expire", "=", "0", ")", "{", "// set the expire date ", "if", "(", "$", "expire", ">", "0", ")", "{", "if", "(", "$", "expire", "<", "time", "(", ")", ")", "{", "$", "expire", "=", "time", "(", ")", "+", "$", "expire", ";", "}", "}", "CCServer", "::", "$", "_instance", "->", "COOKIE", "[", "$", "key", "]", "=", "$", "value", ";", "/*\n\t\t * Finally set the cookie\n\t\t * @toDo: just at the cookie to an array an set the set cookie header from the CCResponse\n\t\t */", "return", "setcookie", "(", "$", "key", ",", "$", "value", ",", "$", "expire", ",", "static", "::", "$", "path", ",", "static", "::", "$", "domain", ",", "static", "::", "$", "secure", ",", "static", "::", "$", "httponly", ")", ";", "}" ]
Set a cookie @param string $key @param string $value @param int $expire @return bool
[ "Set", "a", "cookie" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCookie.php#L45-L70
ClanCats/Core
src/classes/CCCookie.php
CCCookie.get
public static function get( $key, $default = null ) { if ( !isset( CCServer::$_instance->COOKIE[$key] ) ) { return $default; } return CCServer::$_instance->COOKIE[$key]; }
php
public static function get( $key, $default = null ) { if ( !isset( CCServer::$_instance->COOKIE[$key] ) ) { return $default; } return CCServer::$_instance->COOKIE[$key]; }
[ "public", "static", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "CCServer", "::", "$", "_instance", "->", "COOKIE", "[", "$", "key", "]", ")", ")", "{", "return", "$", "default", ";", "}", "return", "CCServer", "::", "$", "_instance", "->", "COOKIE", "[", "$", "key", "]", ";", "}" ]
get a cookie @param string $key @return mixed
[ "get", "a", "cookie" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCookie.php#L78-L85
ClanCats/Core
src/classes/CCCookie.php
CCCookie.once
public static function once( $key ) { if ( !is_null( static::get( $key ) ) ) { $cookie = static::get( $key ); static::delete( $key ); return $cookie; } }
php
public static function once( $key ) { if ( !is_null( static::get( $key ) ) ) { $cookie = static::get( $key ); static::delete( $key ); return $cookie; } }
[ "public", "static", "function", "once", "(", "$", "key", ")", "{", "if", "(", "!", "is_null", "(", "static", "::", "get", "(", "$", "key", ")", ")", ")", "{", "$", "cookie", "=", "static", "::", "get", "(", "$", "key", ")", ";", "static", "::", "delete", "(", "$", "key", ")", ";", "return", "$", "cookie", ";", "}", "}" ]
eat a cookie, means get it once @param string $key @return mixed
[ "eat", "a", "cookie", "means", "get", "it", "once" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCookie.php#L93-L101
meccado/acl-admin-control-panel
src/AclAdminControlPanelServiceProvider.php
AclAdminControlPanelServiceProvider.boot
public function boot(Router $router) { $router->middleware('roles', \App\Http\Middleware\HasRole::class); $router->middleware('admin', \App\Http\Middleware\AdminMiddleware::class); if (! $this->app->routesAreCached()) { require __DIR__.'/Http/routes.php'; } $configFiles = ['acl']; foreach ($configFiles as $config) { $this->mergeConfigFrom(__DIR__."/config/{$config}.php", 'acl'); } $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'acl'); $this->loadViewsFrom(__DIR__ . '/resources/views', 'acl'); //Publish middleware $this->publishes([ __DIR__ . '/Middleware/' => app_path('Http/Middleware'), ]); //Publish providers $this->publishes([ __DIR__ . '/Providers/' => app_path('Providers'), ]); //Publish views $this->publishes([ // __DIR__.'/resources/views' => resource_path('views/vendor/user-auth'), __DIR__.'/resources/views' => resource_path('views'), ], 'views'); //Publish translations $this->publishes([ __DIR__.'/resources/lang/' => resource_path('lang/'), // __DIR__.'/resources/lang/pagination.php' => resource_path('lang/pagination.php'), // __DIR__.'/resources/lang/password.php' => resource_path('lang/password.php'), // __DIR__.'/resources/lang/validation.php' => resource_path('lang/validation.php'), ], 'translations'); // Publish a config file $this->publishes([ __DIR__.'/config/acl.php' => config_path('acl.php'), ], 'config'); //Publish migrations $this->publishes([ __DIR__ . '/database/migrations' => database_path('migrations'), __DIR__ . '/database/seeds' => database_path('seeds'), ], 'migrations'); $this->publishes([ __DIR__.'/assets/bower_components/AdminLTE/' => public_path('/assets/bower_components/AdminLTE/'), ], 'public'); $this->publishes([ __DIR__ . '/Http/Controllers/Auth/' => app_path('/Http/Controllers/Auth/'), __DIR__ . '/Http/Controllers/Admin/' => app_path('/Http/Controllers/Admin/'), ], 'controllers'); $this->publishes([ __DIR__ . '/Models/Admin/' => app_path(), ], 'models'); }
php
public function boot(Router $router) { $router->middleware('roles', \App\Http\Middleware\HasRole::class); $router->middleware('admin', \App\Http\Middleware\AdminMiddleware::class); if (! $this->app->routesAreCached()) { require __DIR__.'/Http/routes.php'; } $configFiles = ['acl']; foreach ($configFiles as $config) { $this->mergeConfigFrom(__DIR__."/config/{$config}.php", 'acl'); } $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'acl'); $this->loadViewsFrom(__DIR__ . '/resources/views', 'acl'); //Publish middleware $this->publishes([ __DIR__ . '/Middleware/' => app_path('Http/Middleware'), ]); //Publish providers $this->publishes([ __DIR__ . '/Providers/' => app_path('Providers'), ]); //Publish views $this->publishes([ // __DIR__.'/resources/views' => resource_path('views/vendor/user-auth'), __DIR__.'/resources/views' => resource_path('views'), ], 'views'); //Publish translations $this->publishes([ __DIR__.'/resources/lang/' => resource_path('lang/'), // __DIR__.'/resources/lang/pagination.php' => resource_path('lang/pagination.php'), // __DIR__.'/resources/lang/password.php' => resource_path('lang/password.php'), // __DIR__.'/resources/lang/validation.php' => resource_path('lang/validation.php'), ], 'translations'); // Publish a config file $this->publishes([ __DIR__.'/config/acl.php' => config_path('acl.php'), ], 'config'); //Publish migrations $this->publishes([ __DIR__ . '/database/migrations' => database_path('migrations'), __DIR__ . '/database/seeds' => database_path('seeds'), ], 'migrations'); $this->publishes([ __DIR__.'/assets/bower_components/AdminLTE/' => public_path('/assets/bower_components/AdminLTE/'), ], 'public'); $this->publishes([ __DIR__ . '/Http/Controllers/Auth/' => app_path('/Http/Controllers/Auth/'), __DIR__ . '/Http/Controllers/Admin/' => app_path('/Http/Controllers/Admin/'), ], 'controllers'); $this->publishes([ __DIR__ . '/Models/Admin/' => app_path(), ], 'models'); }
[ "public", "function", "boot", "(", "Router", "$", "router", ")", "{", "$", "router", "->", "middleware", "(", "'roles'", ",", "\\", "App", "\\", "Http", "\\", "Middleware", "\\", "HasRole", "::", "class", ")", ";", "$", "router", "->", "middleware", "(", "'admin'", ",", "\\", "App", "\\", "Http", "\\", "Middleware", "\\", "AdminMiddleware", "::", "class", ")", ";", "if", "(", "!", "$", "this", "->", "app", "->", "routesAreCached", "(", ")", ")", "{", "require", "__DIR__", ".", "'/Http/routes.php'", ";", "}", "$", "configFiles", "=", "[", "'acl'", "]", ";", "foreach", "(", "$", "configFiles", "as", "$", "config", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "\"/config/{$config}.php\"", ",", "'acl'", ")", ";", "}", "$", "this", "->", "loadTranslationsFrom", "(", "__DIR__", ".", "'/resources/lang'", ",", "'acl'", ")", ";", "$", "this", "->", "loadViewsFrom", "(", "__DIR__", ".", "'/resources/views'", ",", "'acl'", ")", ";", "//Publish middleware", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/Middleware/'", "=>", "app_path", "(", "'Http/Middleware'", ")", ",", "]", ")", ";", "//Publish providers", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/Providers/'", "=>", "app_path", "(", "'Providers'", ")", ",", "]", ")", ";", "//Publish views", "$", "this", "->", "publishes", "(", "[", "// __DIR__.'/resources/views' => resource_path('views/vendor/user-auth'),", "__DIR__", ".", "'/resources/views'", "=>", "resource_path", "(", "'views'", ")", ",", "]", ",", "'views'", ")", ";", "//Publish translations", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/resources/lang/'", "=>", "resource_path", "(", "'lang/'", ")", ",", "// __DIR__.'/resources/lang/pagination.php' => resource_path('lang/pagination.php'),", "// __DIR__.'/resources/lang/password.php' => resource_path('lang/password.php'),", "// __DIR__.'/resources/lang/validation.php' => resource_path('lang/validation.php'),", "]", ",", "'translations'", ")", ";", "// Publish a config file", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/config/acl.php'", "=>", "config_path", "(", "'acl.php'", ")", ",", "]", ",", "'config'", ")", ";", "//Publish migrations", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/database/migrations'", "=>", "database_path", "(", "'migrations'", ")", ",", "__DIR__", ".", "'/database/seeds'", "=>", "database_path", "(", "'seeds'", ")", ",", "]", ",", "'migrations'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/assets/bower_components/AdminLTE/'", "=>", "public_path", "(", "'/assets/bower_components/AdminLTE/'", ")", ",", "]", ",", "'public'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/Http/Controllers/Auth/'", "=>", "app_path", "(", "'/Http/Controllers/Auth/'", ")", ",", "__DIR__", ".", "'/Http/Controllers/Admin/'", "=>", "app_path", "(", "'/Http/Controllers/Admin/'", ")", ",", "]", ",", "'controllers'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/Models/Admin/'", "=>", "app_path", "(", ")", ",", "]", ",", "'models'", ")", ";", "}" ]
Perform post-registration booting of services. @return void
[ "Perform", "post", "-", "registration", "booting", "of", "services", "." ]
train
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/AclAdminControlPanelServiceProvider.php#L17-L79
meccado/acl-admin-control-panel
src/AclAdminControlPanelServiceProvider.php
AclAdminControlPanelServiceProvider.register
public function register() { $this->app->bind('acl', function($app){ return new AclAdminControlPanel; }); //Register dependency packages $this->app->register('Collective\Html\HtmlServiceProvider'); $this->app->register('Intervention\Image\ImageServiceProvider'); // Register dependancy aliases $this->app->booting(function() { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Form', 'Collective\Html\FormFacade'); $loader->alias('HTML', 'Collective\Html\HtmlFacade'); $loader->alias('Image', 'Intervention\Image\Facades\Image'); }); }
php
public function register() { $this->app->bind('acl', function($app){ return new AclAdminControlPanel; }); //Register dependency packages $this->app->register('Collective\Html\HtmlServiceProvider'); $this->app->register('Intervention\Image\ImageServiceProvider'); // Register dependancy aliases $this->app->booting(function() { $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Form', 'Collective\Html\FormFacade'); $loader->alias('HTML', 'Collective\Html\HtmlFacade'); $loader->alias('Image', 'Intervention\Image\Facades\Image'); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'acl'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "AclAdminControlPanel", ";", "}", ")", ";", "//Register dependency packages", "$", "this", "->", "app", "->", "register", "(", "'Collective\\Html\\HtmlServiceProvider'", ")", ";", "$", "this", "->", "app", "->", "register", "(", "'Intervention\\Image\\ImageServiceProvider'", ")", ";", "// Register dependancy aliases", "$", "this", "->", "app", "->", "booting", "(", "function", "(", ")", "{", "$", "loader", "=", "\\", "Illuminate", "\\", "Foundation", "\\", "AliasLoader", "::", "getInstance", "(", ")", ";", "$", "loader", "->", "alias", "(", "'Form'", ",", "'Collective\\Html\\FormFacade'", ")", ";", "$", "loader", "->", "alias", "(", "'HTML'", ",", "'Collective\\Html\\HtmlFacade'", ")", ";", "$", "loader", "->", "alias", "(", "'Image'", ",", "'Intervention\\Image\\Facades\\Image'", ")", ";", "}", ")", ";", "}" ]
Register any package services. @return void
[ "Register", "any", "package", "services", "." ]
train
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/AclAdminControlPanelServiceProvider.php#L86-L105
sparwelt/imgix-lib
src/Components/ImageGenerator.php
ImageGenerator.generateImage
public function generateImage($originalUrl, array $attributesFilters) { if (empty($attributesFilters)) { throw new \InvalidArgumentException('Please provide at least one key for attribute generation (e.g. \'src\') '); } $image = (new \DOMDocument())->createElement('img'); try { foreach ($attributesFilters as $attributeName => $filters) { $attributeValue = $this->attributeGenerator->generateAttributeValue($originalUrl, $filters); if ('' !== $attributeValue) { $image->setAttribute($attributeName, $attributeValue); } } } catch (ResolutionException $e) { $image->setAttribute('src', $originalUrl); } return $this->renderer->render($image); }
php
public function generateImage($originalUrl, array $attributesFilters) { if (empty($attributesFilters)) { throw new \InvalidArgumentException('Please provide at least one key for attribute generation (e.g. \'src\') '); } $image = (new \DOMDocument())->createElement('img'); try { foreach ($attributesFilters as $attributeName => $filters) { $attributeValue = $this->attributeGenerator->generateAttributeValue($originalUrl, $filters); if ('' !== $attributeValue) { $image->setAttribute($attributeName, $attributeValue); } } } catch (ResolutionException $e) { $image->setAttribute('src', $originalUrl); } return $this->renderer->render($image); }
[ "public", "function", "generateImage", "(", "$", "originalUrl", ",", "array", "$", "attributesFilters", ")", "{", "if", "(", "empty", "(", "$", "attributesFilters", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Please provide at least one key for attribute generation (e.g. \\'src\\') '", ")", ";", "}", "$", "image", "=", "(", "new", "\\", "DOMDocument", "(", ")", ")", "->", "createElement", "(", "'img'", ")", ";", "try", "{", "foreach", "(", "$", "attributesFilters", "as", "$", "attributeName", "=>", "$", "filters", ")", "{", "$", "attributeValue", "=", "$", "this", "->", "attributeGenerator", "->", "generateAttributeValue", "(", "$", "originalUrl", ",", "$", "filters", ")", ";", "if", "(", "''", "!==", "$", "attributeValue", ")", "{", "$", "image", "->", "setAttribute", "(", "$", "attributeName", ",", "$", "attributeValue", ")", ";", "}", "}", "}", "catch", "(", "ResolutionException", "$", "e", ")", "{", "$", "image", "->", "setAttribute", "(", "'src'", ",", "$", "originalUrl", ")", ";", "}", "return", "$", "this", "->", "renderer", "->", "render", "(", "$", "image", ")", ";", "}" ]
@param string $originalUrl @param array $attributesFilters @return string @throws \InvalidArgumentException
[ "@param", "string", "$originalUrl", "@param", "array", "$attributesFilters" ]
train
https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/Components/ImageGenerator.php#L42-L62
whisller/IrcBotBundle
DependencyInjection/WhisnetIrcBotExtension.php
WhisnetIrcBotExtension.load
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); foreach (array('core', 'server_messages', 'commands') as $basename) { $loader->load(sprintf('%s.xml', $basename)); } $container->setParameter('whisnet_irc_bot.connection_class', $config['connection_class']); $container->setParameter('whisnet_irc_bot.user', $config['user']); $container->setParameter('whisnet_irc_bot.host', $config['host']); $container->setParameter('whisnet_irc_bot.port', $config['port']); $container->setParameter('whisnet_irc_bot.channels', $config['channels']); $container->setParameter('whisnet_irc_bot.bot_command_prefix', $config['command_prefix']); if (!$container->hasDefinition('whisnet_irc_bot.commands_info_holder')) { $taggedServiceHolder = new Definition(); $taggedServiceHolder->setClass('SplDoublyLinkedList'); $container->setDefinition('whisnet_irc_bot.commands_info_holder', $taggedServiceHolder); } }
php
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); foreach (array('core', 'server_messages', 'commands') as $basename) { $loader->load(sprintf('%s.xml', $basename)); } $container->setParameter('whisnet_irc_bot.connection_class', $config['connection_class']); $container->setParameter('whisnet_irc_bot.user', $config['user']); $container->setParameter('whisnet_irc_bot.host', $config['host']); $container->setParameter('whisnet_irc_bot.port', $config['port']); $container->setParameter('whisnet_irc_bot.channels', $config['channels']); $container->setParameter('whisnet_irc_bot.bot_command_prefix', $config['command_prefix']); if (!$container->hasDefinition('whisnet_irc_bot.commands_info_holder')) { $taggedServiceHolder = new Definition(); $taggedServiceHolder->setClass('SplDoublyLinkedList'); $container->setDefinition('whisnet_irc_bot.commands_info_holder', $taggedServiceHolder); } }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "configuration", "=", "new", "Configuration", "(", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "$", "loader", "=", "new", "Loader", "\\", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "foreach", "(", "array", "(", "'core'", ",", "'server_messages'", ",", "'commands'", ")", "as", "$", "basename", ")", "{", "$", "loader", "->", "load", "(", "sprintf", "(", "'%s.xml'", ",", "$", "basename", ")", ")", ";", "}", "$", "container", "->", "setParameter", "(", "'whisnet_irc_bot.connection_class'", ",", "$", "config", "[", "'connection_class'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'whisnet_irc_bot.user'", ",", "$", "config", "[", "'user'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'whisnet_irc_bot.host'", ",", "$", "config", "[", "'host'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'whisnet_irc_bot.port'", ",", "$", "config", "[", "'port'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'whisnet_irc_bot.channels'", ",", "$", "config", "[", "'channels'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'whisnet_irc_bot.bot_command_prefix'", ",", "$", "config", "[", "'command_prefix'", "]", ")", ";", "if", "(", "!", "$", "container", "->", "hasDefinition", "(", "'whisnet_irc_bot.commands_info_holder'", ")", ")", "{", "$", "taggedServiceHolder", "=", "new", "Definition", "(", ")", ";", "$", "taggedServiceHolder", "->", "setClass", "(", "'SplDoublyLinkedList'", ")", ";", "$", "container", "->", "setDefinition", "(", "'whisnet_irc_bot.commands_info_holder'", ",", "$", "taggedServiceHolder", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/whisller/IrcBotBundle/blob/d8bcafc1599cbbc7756b0a59f51ee988a2de0f2e/DependencyInjection/WhisnetIrcBotExtension.php#L21-L44
PortaText/php-sdk
src/PortaText/Command/Factory.php
Factory.get
public function get($command) { $className = ucfirst($command); $className = "PortaText\\Command\\Api\\$className"; if (!class_exists($className)) { throw new \InvalidArgumentException( "Command $command does not exist" ); } return new $className(); }
php
public function get($command) { $className = ucfirst($command); $className = "PortaText\\Command\\Api\\$className"; if (!class_exists($className)) { throw new \InvalidArgumentException( "Command $command does not exist" ); } return new $className(); }
[ "public", "function", "get", "(", "$", "command", ")", "{", "$", "className", "=", "ucfirst", "(", "$", "command", ")", ";", "$", "className", "=", "\"PortaText\\\\Command\\\\Api\\\\$className\"", ";", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Command $command does not exist\"", ")", ";", "}", "return", "new", "$", "className", "(", ")", ";", "}" ]
Returns a command instance based on the command name requested. @param string $command The name of the command. @return PortaText\Command\ICommand @throws InvalidArgumentException
[ "Returns", "a", "command", "instance", "based", "on", "the", "command", "name", "requested", "." ]
train
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Factory.php#L24-L34
tylercd100/monolog-mailgun
src/Handler/MailgunHandler.php
MailgunHandler.send
protected function send($content, array $records) { $auth = base64_encode("api:".$this->token); $fields = http_build_query([ 'from' => $this->from, 'to' => $this->to, 'subject' => $this->subject, 'text' => $content ]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://{$this->host}/{$this->version}/{$this->domain}/messages"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Basic ".$auth ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_exec($ch); curl_close($ch); }
php
protected function send($content, array $records) { $auth = base64_encode("api:".$this->token); $fields = http_build_query([ 'from' => $this->from, 'to' => $this->to, 'subject' => $this->subject, 'text' => $content ]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://{$this->host}/{$this->version}/{$this->domain}/messages"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Basic ".$auth ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_exec($ch); curl_close($ch); }
[ "protected", "function", "send", "(", "$", "content", ",", "array", "$", "records", ")", "{", "$", "auth", "=", "base64_encode", "(", "\"api:\"", ".", "$", "this", "->", "token", ")", ";", "$", "fields", "=", "http_build_query", "(", "[", "'from'", "=>", "$", "this", "->", "from", ",", "'to'", "=>", "$", "this", "->", "to", ",", "'subject'", "=>", "$", "this", "->", "subject", ",", "'text'", "=>", "$", "content", "]", ")", ";", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "\"https://{$this->host}/{$this->version}/{$this->domain}/messages\"", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "[", "\"Authorization: Basic \"", ".", "$", "auth", "]", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "fields", ")", ";", "curl_exec", "(", "$", "ch", ")", ";", "curl_close", "(", "$", "ch", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/tylercd100/monolog-mailgun/blob/3f64ecaf66ac128092592dbf8d5ab3d9361417cc/src/Handler/MailgunHandler.php#L39-L62
vorbind/influx-analytics
src/Adapter/InfluxDatabaseAdapter.php
InfluxDatabaseAdapter.getDatabaseAdapter
public function getDatabaseAdapter() { try { if (isset($this->db)) { return $this->db; } $config = $this->reader->getDbsConfig(); if ( !isset($config['influx']) || !isset($config['influx']["username"]) || !isset($config['influx']["password"]) || !isset($config['influx']["host"]) || !isset($config['influx']["port"]) || !isset($config['influx']["database"]) ) { throw new Exception("Influx config is not valid!"); } $username = $config['influx']["username"]; $password = $config['influx']["password"]; $host = $config['influx']["host"]; $port = $config['influx']["port"]; $dbname = $config['influx']["database"]; $client = new \InfluxDB\Client($host, $port, $username, $password); $this->db = $client->selectDB($dbname); return $this->db; } catch (Exception $ex) { print("ERROR:" . $ex->getMessage()); throw new Exception("Faild connect to influx db!"); } }
php
public function getDatabaseAdapter() { try { if (isset($this->db)) { return $this->db; } $config = $this->reader->getDbsConfig(); if ( !isset($config['influx']) || !isset($config['influx']["username"]) || !isset($config['influx']["password"]) || !isset($config['influx']["host"]) || !isset($config['influx']["port"]) || !isset($config['influx']["database"]) ) { throw new Exception("Influx config is not valid!"); } $username = $config['influx']["username"]; $password = $config['influx']["password"]; $host = $config['influx']["host"]; $port = $config['influx']["port"]; $dbname = $config['influx']["database"]; $client = new \InfluxDB\Client($host, $port, $username, $password); $this->db = $client->selectDB($dbname); return $this->db; } catch (Exception $ex) { print("ERROR:" . $ex->getMessage()); throw new Exception("Faild connect to influx db!"); } }
[ "public", "function", "getDatabaseAdapter", "(", ")", "{", "try", "{", "if", "(", "isset", "(", "$", "this", "->", "db", ")", ")", "{", "return", "$", "this", "->", "db", ";", "}", "$", "config", "=", "$", "this", "->", "reader", "->", "getDbsConfig", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'influx'", "]", ")", "||", "!", "isset", "(", "$", "config", "[", "'influx'", "]", "[", "\"username\"", "]", ")", "||", "!", "isset", "(", "$", "config", "[", "'influx'", "]", "[", "\"password\"", "]", ")", "||", "!", "isset", "(", "$", "config", "[", "'influx'", "]", "[", "\"host\"", "]", ")", "||", "!", "isset", "(", "$", "config", "[", "'influx'", "]", "[", "\"port\"", "]", ")", "||", "!", "isset", "(", "$", "config", "[", "'influx'", "]", "[", "\"database\"", "]", ")", ")", "{", "throw", "new", "Exception", "(", "\"Influx config is not valid!\"", ")", ";", "}", "$", "username", "=", "$", "config", "[", "'influx'", "]", "[", "\"username\"", "]", ";", "$", "password", "=", "$", "config", "[", "'influx'", "]", "[", "\"password\"", "]", ";", "$", "host", "=", "$", "config", "[", "'influx'", "]", "[", "\"host\"", "]", ";", "$", "port", "=", "$", "config", "[", "'influx'", "]", "[", "\"port\"", "]", ";", "$", "dbname", "=", "$", "config", "[", "'influx'", "]", "[", "\"database\"", "]", ";", "$", "client", "=", "new", "\\", "InfluxDB", "\\", "Client", "(", "$", "host", ",", "$", "port", ",", "$", "username", ",", "$", "password", ")", ";", "$", "this", "->", "db", "=", "$", "client", "->", "selectDB", "(", "$", "dbname", ")", ";", "return", "$", "this", "->", "db", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "print", "(", "\"ERROR:\"", ".", "$", "ex", "->", "getMessage", "(", ")", ")", ";", "throw", "new", "Exception", "(", "\"Faild connect to influx db!\"", ")", ";", "}", "}" ]
Get db adapter @return InfluxDB @throws Exception
[ "Get", "db", "adapter" ]
train
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Adapter/InfluxDatabaseAdapter.php#L53-L83
steeffeen/FancyManiaLinks
FML/Components/RadioButtonGroup.php
RadioButtonGroup.setName
public function setName($name) { $this->name = (string)$name; $this->getEntry() ->setName($this->name); return $this; }
php
public function setName($name) { $this->name = (string)$name; $this->getEntry() ->setName($this->name); return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "$", "this", "->", "name", "=", "(", "string", ")", "$", "name", ";", "$", "this", "->", "getEntry", "(", ")", "->", "setName", "(", "$", "this", "->", "name", ")", ";", "return", "$", "this", ";", "}" ]
Set the name @api @param string $name RadioButtonGroup name @return static
[ "Set", "the", "name" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/RadioButtonGroup.php#L64-L70
joseph-walker/vector
src/Lib/Strings.php
Strings.__split
protected static function __split(string $on, string $string) : array { if ($on === '') { return str_split($string); } return array_filter(explode($on, $string)); }
php
protected static function __split(string $on, string $string) : array { if ($on === '') { return str_split($string); } return array_filter(explode($on, $string)); }
[ "protected", "static", "function", "__split", "(", "string", "$", "on", ",", "string", "$", "string", ")", ":", "array", "{", "if", "(", "$", "on", "===", "''", ")", "{", "return", "str_split", "(", "$", "string", ")", ";", "}", "return", "array_filter", "(", "explode", "(", "$", "on", ",", "$", "string", ")", ")", ";", "}" ]
String Splitting Split a string into parts based on a delimiter. Operates similar to php `explode`, but is more consistent. Can split on empty delimiters, and trims out empty strings after exploding. @example Strings::split('-', 'Hello-World'); // ['Hello', 'World'] @example Strings::split('', 'asdf'); // ['a', 's', 'd', 'f'] @example Strings::split('-', 'foo-bar-'); ['foo', 'bar'] @type String -> String -> [String] @param String $on Split delimiter @param String $string Thing to split into pieces @return array List of chunks from splitting the string
[ "String", "Splitting" ]
train
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Strings.php#L67-L74
joseph-walker/vector
src/Lib/Strings.php
Strings.__startsWith
protected static function __startsWith(string $subStr, string $str) : bool { return substr($str, 0, strlen($subStr)) === $subStr; }
php
protected static function __startsWith(string $subStr, string $str) : bool { return substr($str, 0, strlen($subStr)) === $subStr; }
[ "protected", "static", "function", "__startsWith", "(", "string", "$", "subStr", ",", "string", "$", "str", ")", ":", "bool", "{", "return", "substr", "(", "$", "str", ",", "0", ",", "strlen", "(", "$", "subStr", ")", ")", "===", "$", "subStr", ";", "}" ]
Substring Match Determines if a string starts with a specific substring. Returns true if the string matches the substring at its start, otherwise false. @example Strings::startsWith('as', 'asdf'); true @example Strings::startsWith('foo', 'barfoo'); false @type String -> String -> Bool @param String $subStr Substring to test @param String $str String to run test on @return Bool Whether or not the string starts with the substring
[ "Substring", "Match" ]
train
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Strings.php#L94-L97
joseph-walker/vector
src/Lib/Strings.php
Strings.__lchomp
protected static function __lchomp(string $toChomp, string $string) : string { $length = strlen($toChomp); if (strcmp(substr($string, 0, $length), $toChomp) === 0) { return substr($string, $length); } return $string; }
php
protected static function __lchomp(string $toChomp, string $string) : string { $length = strlen($toChomp); if (strcmp(substr($string, 0, $length), $toChomp) === 0) { return substr($string, $length); } return $string; }
[ "protected", "static", "function", "__lchomp", "(", "string", "$", "toChomp", ",", "string", "$", "string", ")", ":", "string", "{", "$", "length", "=", "strlen", "(", "$", "toChomp", ")", ";", "if", "(", "strcmp", "(", "substr", "(", "$", "string", ",", "0", ",", "$", "length", ")", ",", "$", "toChomp", ")", "===", "0", ")", "{", "return", "substr", "(", "$", "string", ",", "$", "length", ")", ";", "}", "return", "$", "string", ";", "}" ]
Left Chomp Removes the specified substring from the left end of the target string. Unlike PHP's trim function, the substring to chomp is not a character mask -- rather it is a full substring. This function is case sensitive. @example Strings::lchomp('He', 'Hello World'); // 'llo World' Strings::lchomp('Hi', 'Hello World'); // 'Hello World' Strings::lchomp('he', 'Hello World'); // 'Hello World' @type String -> String @param String $toChomp string to chomp @param String $string string to be chomped @return string
[ "Left", "Chomp" ]
train
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Strings.php#L172-L181
joseph-walker/vector
src/Lib/Strings.php
Strings.__rchomp
protected static function __rchomp(string $toChomp, string $string) : string { $length = strlen($toChomp); if (strcmp(substr($string, -$length, $length), $toChomp) === 0) { $string = substr($string, 0, -$length); } return $string; }
php
protected static function __rchomp(string $toChomp, string $string) : string { $length = strlen($toChomp); if (strcmp(substr($string, -$length, $length), $toChomp) === 0) { $string = substr($string, 0, -$length); } return $string; }
[ "protected", "static", "function", "__rchomp", "(", "string", "$", "toChomp", ",", "string", "$", "string", ")", ":", "string", "{", "$", "length", "=", "strlen", "(", "$", "toChomp", ")", ";", "if", "(", "strcmp", "(", "substr", "(", "$", "string", ",", "-", "$", "length", ",", "$", "length", ")", ",", "$", "toChomp", ")", "===", "0", ")", "{", "$", "string", "=", "substr", "(", "$", "string", ",", "0", ",", "-", "$", "length", ")", ";", "}", "return", "$", "string", ";", "}" ]
Right Chomp Removes the specified substring from the right end of the target string. Unlike PHP's trim function, the substring to chomp is not a character mask -- rather it is a full substring. This function is case sensitive. @example Strings::rchomp('ld', 'Hello World'); // 'Hello Wor' Strings::rchomp('li', 'Hello World'); // 'Hello World' Strings::rchomp('LD', 'Hello World'); // 'Hello World' @type String -> String @param String $toChomp string to chomp @param String $string string to be chomped @return string
[ "Right", "Chomp" ]
train
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Strings.php#L201-L210
joseph-walker/vector
src/Lib/Strings.php
Strings.__chomp
protected static function __chomp(string $toChomp, string $string) : string { /** @noinspection PhpParamsInspection */ $chomp = Lambda::compose(self::lchomp($toChomp), self::rchomp($toChomp)); return $chomp($string); }
php
protected static function __chomp(string $toChomp, string $string) : string { /** @noinspection PhpParamsInspection */ $chomp = Lambda::compose(self::lchomp($toChomp), self::rchomp($toChomp)); return $chomp($string); }
[ "protected", "static", "function", "__chomp", "(", "string", "$", "toChomp", ",", "string", "$", "string", ")", ":", "string", "{", "/** @noinspection PhpParamsInspection */", "$", "chomp", "=", "Lambda", "::", "compose", "(", "self", "::", "lchomp", "(", "$", "toChomp", ")", ",", "self", "::", "rchomp", "(", "$", "toChomp", ")", ")", ";", "return", "$", "chomp", "(", "$", "string", ")", ";", "}" ]
Two-Sided Chomp Removes the specified substring from both ends of the target string. Unlike PHP's trim function, the substring to chomp is not a character mask -- rather it is a full substring. This function is case sensitive. @example Strings::chomp('a', 'abccba'); // 'bccb' Strings::chomp('ab', 'abccba'); // 'abccba' Strings::chomp('A', 'abccba'); // 'abccba' @type String -> String @param String $toChomp string to chomp @param String $string string to be chomped @return string
[ "Two", "-", "Sided", "Chomp" ]
train
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Strings.php#L230-L236
joseph-walker/vector
src/Lib/Strings.php
Strings.__replace
protected static function __replace(string $substring, string $replacement, string $string) : string { return str_replace($substring, $replacement, $string); }
php
protected static function __replace(string $substring, string $replacement, string $string) : string { return str_replace($substring, $replacement, $string); }
[ "protected", "static", "function", "__replace", "(", "string", "$", "substring", ",", "string", "$", "replacement", ",", "string", "$", "string", ")", ":", "string", "{", "return", "str_replace", "(", "$", "substring", ",", "$", "replacement", ",", "$", "string", ")", ";", "}" ]
String Replace Replace all occurrences of the search string with the replacement string. @example Strings::replace('test', 'passes', 'this test']); // 'this passes' @param String $substring Substring to find @param $replacement @param String $string Replacement string @return String $string Result after replacement @internal param String $ -> String -> String
[ "String", "Replace" ]
train
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Strings.php#L276-L279
phpmob/changmin
src/PhpMob/WidgetBundle/Registry/WidgetRegistry.php
WidgetRegistry.getWidgetClass
public function getWidgetClass($name) { if (!array_key_exists($name, $this->widgets)) { throw new \InvalidArgumentException("Not found widget by name `$name`."); } return $this->widgets[$name]; }
php
public function getWidgetClass($name) { if (!array_key_exists($name, $this->widgets)) { throw new \InvalidArgumentException("Not found widget by name `$name`."); } return $this->widgets[$name]; }
[ "public", "function", "getWidgetClass", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "widgets", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Not found widget by name `$name`.\"", ")", ";", "}", "return", "$", "this", "->", "widgets", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/WidgetBundle/Registry/WidgetRegistry.php#L37-L44
aedart/laravel-helpers
src/Traits/Filesystem/StorageFactoryTrait.php
StorageFactoryTrait.getStorageFactory
public function getStorageFactory(): ?Factory { if (!$this->hasStorageFactory()) { $this->setStorageFactory($this->getDefaultStorageFactory()); } return $this->storageFactory; }
php
public function getStorageFactory(): ?Factory { if (!$this->hasStorageFactory()) { $this->setStorageFactory($this->getDefaultStorageFactory()); } return $this->storageFactory; }
[ "public", "function", "getStorageFactory", "(", ")", ":", "?", "Factory", "{", "if", "(", "!", "$", "this", "->", "hasStorageFactory", "(", ")", ")", "{", "$", "this", "->", "setStorageFactory", "(", "$", "this", "->", "getDefaultStorageFactory", "(", ")", ")", ";", "}", "return", "$", "this", "->", "storageFactory", ";", "}" ]
Get storage factory If no storage factory has been set, this method will set and return a default storage factory, if any such value is available @see getDefaultStorageFactory() @return Factory|null storage factory or null if none storage factory has been set
[ "Get", "storage", "factory" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Filesystem/StorageFactoryTrait.php#L53-L59
xavieryang007/xcron-expression
src/Cron/FieldFactory.php
FieldFactory.getField
public function getField($position) { if (!isset($this->fields[$position])) { switch ($position) { case 0: $this->fields[$position] = new SecondsField(); break; case 1: $this->fields[$position] = new MinutesField(); break; case 2: $this->fields[$position] = new HoursField(); break; case 3: $this->fields[$position] = new DayOfMonthField(); break; case 4: $this->fields[$position] = new MonthField(); break; case 5: $this->fields[$position] = new DayOfWeekField(); break; default: throw new InvalidArgumentException( $position . ' is not a valid position' ); } } return $this->fields[$position]; }
php
public function getField($position) { if (!isset($this->fields[$position])) { switch ($position) { case 0: $this->fields[$position] = new SecondsField(); break; case 1: $this->fields[$position] = new MinutesField(); break; case 2: $this->fields[$position] = new HoursField(); break; case 3: $this->fields[$position] = new DayOfMonthField(); break; case 4: $this->fields[$position] = new MonthField(); break; case 5: $this->fields[$position] = new DayOfWeekField(); break; default: throw new InvalidArgumentException( $position . ' is not a valid position' ); } } return $this->fields[$position]; }
[ "public", "function", "getField", "(", "$", "position", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fields", "[", "$", "position", "]", ")", ")", "{", "switch", "(", "$", "position", ")", "{", "case", "0", ":", "$", "this", "->", "fields", "[", "$", "position", "]", "=", "new", "SecondsField", "(", ")", ";", "break", ";", "case", "1", ":", "$", "this", "->", "fields", "[", "$", "position", "]", "=", "new", "MinutesField", "(", ")", ";", "break", ";", "case", "2", ":", "$", "this", "->", "fields", "[", "$", "position", "]", "=", "new", "HoursField", "(", ")", ";", "break", ";", "case", "3", ":", "$", "this", "->", "fields", "[", "$", "position", "]", "=", "new", "DayOfMonthField", "(", ")", ";", "break", ";", "case", "4", ":", "$", "this", "->", "fields", "[", "$", "position", "]", "=", "new", "MonthField", "(", ")", ";", "break", ";", "case", "5", ":", "$", "this", "->", "fields", "[", "$", "position", "]", "=", "new", "DayOfWeekField", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "InvalidArgumentException", "(", "$", "position", ".", "' is not a valid position'", ")", ";", "}", "}", "return", "$", "this", "->", "fields", "[", "$", "position", "]", ";", "}" ]
Get an instance of a field object for a cron expression position @param int $position CRON expression position value to retrieve @return FieldInterface @throws InvalidArgumentException if a position is not valid
[ "Get", "an", "instance", "of", "a", "field", "object", "for", "a", "cron", "expression", "position" ]
train
https://github.com/xavieryang007/xcron-expression/blob/a7fa8108ee8ad636625425a9795aae8ba4fee1b3/src/Cron/FieldFactory.php#L26-L55
weew/url
src/Weew/Url/UrlQuery.php
UrlQuery.toString
public function toString($encode = false) { $query = http_build_query($this->query, '', '&', PHP_QUERY_RFC3986); if ( ! $encode) { return rawurldecode($query); } return $query; }
php
public function toString($encode = false) { $query = http_build_query($this->query, '', '&', PHP_QUERY_RFC3986); if ( ! $encode) { return rawurldecode($query); } return $query; }
[ "public", "function", "toString", "(", "$", "encode", "=", "false", ")", "{", "$", "query", "=", "http_build_query", "(", "$", "this", "->", "query", ",", "''", ",", "'&'", ",", "PHP_QUERY_RFC3986", ")", ";", "if", "(", "!", "$", "encode", ")", "{", "return", "rawurldecode", "(", "$", "query", ")", ";", "}", "return", "$", "query", ";", "}" ]
@param bool $encode @return string
[ "@param", "bool", "$encode" ]
train
https://github.com/weew/url/blob/117be15e899cc343f22f04f5eb9e92e2164c56c1/src/Weew/Url/UrlQuery.php#L64-L72
weew/url
src/Weew/Url/UrlQuery.php
UrlQuery.parseQuery
private function parseQuery($query) { if (is_array($query)) { return $query; } // "+" sign is reserved and must always be encoded, // otherwise it is interpreted as a space $queryString = str_replace('+', '%2B', $query); parse_str($queryString, $query); return $query; }
php
private function parseQuery($query) { if (is_array($query)) { return $query; } // "+" sign is reserved and must always be encoded, // otherwise it is interpreted as a space $queryString = str_replace('+', '%2B', $query); parse_str($queryString, $query); return $query; }
[ "private", "function", "parseQuery", "(", "$", "query", ")", "{", "if", "(", "is_array", "(", "$", "query", ")", ")", "{", "return", "$", "query", ";", "}", "// \"+\" sign is reserved and must always be encoded,", "// otherwise it is interpreted as a space", "$", "queryString", "=", "str_replace", "(", "'+'", ",", "'%2B'", ",", "$", "query", ")", ";", "parse_str", "(", "$", "queryString", ",", "$", "query", ")", ";", "return", "$", "query", ";", "}" ]
@param string|array $query @return array
[ "@param", "string|array", "$query" ]
train
https://github.com/weew/url/blob/117be15e899cc343f22f04f5eb9e92e2164c56c1/src/Weew/Url/UrlQuery.php#L100-L111
jfusion/org.jfusion.framework
src/Plugin/Platform.php
Platform.hasFile
final public function hasFile($file) { $helloReflection = new \ReflectionClass($this); $dir = dirname($helloReflection->getFilename()); if(file_exists($dir . '/' . $file)) { return $dir . '/' . $file; } return false; }
php
final public function hasFile($file) { $helloReflection = new \ReflectionClass($this); $dir = dirname($helloReflection->getFilename()); if(file_exists($dir . '/' . $file)) { return $dir . '/' . $file; } return false; }
[ "final", "public", "function", "hasFile", "(", "$", "file", ")", "{", "$", "helloReflection", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "dir", "=", "dirname", "(", "$", "helloReflection", "->", "getFilename", "(", ")", ")", ";", "if", "(", "file_exists", "(", "$", "dir", ".", "'/'", ".", "$", "file", ")", ")", "{", "return", "$", "dir", ".", "'/'", ".", "$", "file", ";", "}", "return", "false", ";", "}" ]
framework has file? @param $file @return boolean|string
[ "framework", "has", "file?" ]
train
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Platform.php#L55-L64
webforge-labs/psc-cms
lib/Psc/Doctrine/HydrationCollectionSynchronizer.php
HydrationCollectionSynchronizer.process
public function process($fromCollection, $toCollection) { // wir haben keine Ahnung welche Objekte in der $fromCollection und welche in der $toCollection sind $fromCollection = \Psc\Code\Code::castArray($fromCollection); // damit wir eine copy machen $updates = $inserts = $deletes = array(); $index = array(); foreach ($toCollection as $toCollectionKey => $toObject) { $fromObject = $this->hydrateUniqueObject($toObject, $toCollectionKey); // kein objekt konnte hydriert werden if ($fromObject === NULL) { $inserts[] = $this->dispatchInsert($toObject, array('key'=>$toCollectionKey)); // inserts müssen nicht in den index, da sie nicht im universum gefunden wurden, können sie auch nicht in $fromCollection sein } else { // objekt hydriert, kann mit korrekter id sein oder matching unique-constraint $updates[] = $this->dispatchUpdate($fromObject, array('from'=>$fromObject, 'to'=>$toObject, 'key'=>$toCollectionKey)); $index[$this->hashObject($fromObject)] = TRUE; } } foreach ($fromCollection as $fromObject) { if (!array_key_exists($this->hashObject($fromObject), $index)) { // object ist weder ein insert noch ein update $deletes[] = $this->dispatchDelete($fromObject); } } return array($inserts, $updates, $deletes); }
php
public function process($fromCollection, $toCollection) { // wir haben keine Ahnung welche Objekte in der $fromCollection und welche in der $toCollection sind $fromCollection = \Psc\Code\Code::castArray($fromCollection); // damit wir eine copy machen $updates = $inserts = $deletes = array(); $index = array(); foreach ($toCollection as $toCollectionKey => $toObject) { $fromObject = $this->hydrateUniqueObject($toObject, $toCollectionKey); // kein objekt konnte hydriert werden if ($fromObject === NULL) { $inserts[] = $this->dispatchInsert($toObject, array('key'=>$toCollectionKey)); // inserts müssen nicht in den index, da sie nicht im universum gefunden wurden, können sie auch nicht in $fromCollection sein } else { // objekt hydriert, kann mit korrekter id sein oder matching unique-constraint $updates[] = $this->dispatchUpdate($fromObject, array('from'=>$fromObject, 'to'=>$toObject, 'key'=>$toCollectionKey)); $index[$this->hashObject($fromObject)] = TRUE; } } foreach ($fromCollection as $fromObject) { if (!array_key_exists($this->hashObject($fromObject), $index)) { // object ist weder ein insert noch ein update $deletes[] = $this->dispatchDelete($fromObject); } } return array($inserts, $updates, $deletes); }
[ "public", "function", "process", "(", "$", "fromCollection", ",", "$", "toCollection", ")", "{", "// wir haben keine Ahnung welche Objekte in der $fromCollection und welche in der $toCollection sind", "$", "fromCollection", "=", "\\", "Psc", "\\", "Code", "\\", "Code", "::", "castArray", "(", "$", "fromCollection", ")", ";", "// damit wir eine copy machen", "$", "updates", "=", "$", "inserts", "=", "$", "deletes", "=", "array", "(", ")", ";", "$", "index", "=", "array", "(", ")", ";", "foreach", "(", "$", "toCollection", "as", "$", "toCollectionKey", "=>", "$", "toObject", ")", "{", "$", "fromObject", "=", "$", "this", "->", "hydrateUniqueObject", "(", "$", "toObject", ",", "$", "toCollectionKey", ")", ";", "// kein objekt konnte hydriert werden", "if", "(", "$", "fromObject", "===", "NULL", ")", "{", "$", "inserts", "[", "]", "=", "$", "this", "->", "dispatchInsert", "(", "$", "toObject", ",", "array", "(", "'key'", "=>", "$", "toCollectionKey", ")", ")", ";", "// inserts müssen nicht in den index, da sie nicht im universum gefunden wurden, können sie auch nicht in $fromCollection sein", "}", "else", "{", "// objekt hydriert, kann mit korrekter id sein oder matching unique-constraint", "$", "updates", "[", "]", "=", "$", "this", "->", "dispatchUpdate", "(", "$", "fromObject", ",", "array", "(", "'from'", "=>", "$", "fromObject", ",", "'to'", "=>", "$", "toObject", ",", "'key'", "=>", "$", "toCollectionKey", ")", ")", ";", "$", "index", "[", "$", "this", "->", "hashObject", "(", "$", "fromObject", ")", "]", "=", "TRUE", ";", "}", "}", "foreach", "(", "$", "fromCollection", "as", "$", "fromObject", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "hashObject", "(", "$", "fromObject", ")", ",", "$", "index", ")", ")", "{", "// object ist weder ein insert noch ein update", "$", "deletes", "[", "]", "=", "$", "this", "->", "dispatchDelete", "(", "$", "fromObject", ")", ";", "}", "}", "return", "array", "(", "$", "inserts", ",", "$", "updates", ",", "$", "deletes", ")", ";", "}" ]
Synchronisiert eine Collection von (Datenbank-)Objekten mit einer Collection von Daten / Unique-Kriterien oder Exportieren Objekten Die $fromCollection ist die Collection der bereits hydrierten Objekte. (fertige Tags) die $toCollection ist die noch nicht hydrierte Collection der Objekte die Objekte in $fromCollection repräsentieren (Tag Labels) zur Hilfe werden zwei Funktionen benötigt. Die hydrierFunktion erstellt aus den Daten asu $toCollection ein Objekt aus $fromCollection ( $label ===> Entity $tag ) die hash Funktion erstellt aus einem Objekt von $fromCollection einen Skalar ( Entity $tag => $id ) Article und Test beispiel: $fromCollection = $article->getTags(); $toCollection = array('Tag1Name','Tag2Name','....'); so ungefähr!! muss NULL zurückgeben nicht array $hydrateUniqueObject = function (\stdClass $json) { return $em->createQueryBuilder() ->select('tag')->from('Entities\Tag') ->where('id = :id OR uniqueconstraint = :unique) ->setParameter( array( 'id'=>$json->id, 'unique'>$json->label ) ) ; }; $hashObject = function (Tag $tag) { return $tag->getIdentifier(); }; @param ArrayCollection $dbCollection die Collection als fertige Objekte aus der Datenbank @param collection $toCollection eine noch nicht hydrierte Collection von Objekten die Objekte in $fromCollection repräsentieren kann @return list($insert,$updates,$deletes) die jeweiligen listen von dispatchten events
[ "Synchronisiert", "eine", "Collection", "von", "(", "Datenbank", "-", ")", "Objekten", "mit", "einer", "Collection", "von", "Daten", "/", "Unique", "-", "Kriterien", "oder", "Exportieren", "Objekten" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/HydrationCollectionSynchronizer.php#L53-L83
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.open
public function open(Response $response, $target = '', $tree = false, $init = false) { $target = $target ?: $this->driverOptions['path']; $url = $this->driverOptions['host'].DIRECTORY_SEPARATOR.$this->driverOptions['path'].DIRECTORY_SEPARATOR; $this->addOption('path', $target); $this->addOption('url', $url); $this->addOption('tmbURL', $url.$this->driverOptions['tmbPath'].DIRECTORY_SEPARATOR); $dir = $this->getFileInfo($target); $response->setCwd($dir); $response->setFiles($this->scanDir($target)); $response->appendFiles($this->scanDir($this->driverOptions['path'])); if ($init) { $response->setUplMaxSize(ini_get('upload_max_filesize')); } if ($tree) { $this->tree($response, $this->driverOptions['path']); } return $response; }
php
public function open(Response $response, $target = '', $tree = false, $init = false) { $target = $target ?: $this->driverOptions['path']; $url = $this->driverOptions['host'].DIRECTORY_SEPARATOR.$this->driverOptions['path'].DIRECTORY_SEPARATOR; $this->addOption('path', $target); $this->addOption('url', $url); $this->addOption('tmbURL', $url.$this->driverOptions['tmbPath'].DIRECTORY_SEPARATOR); $dir = $this->getFileInfo($target); $response->setCwd($dir); $response->setFiles($this->scanDir($target)); $response->appendFiles($this->scanDir($this->driverOptions['path'])); if ($init) { $response->setUplMaxSize(ini_get('upload_max_filesize')); } if ($tree) { $this->tree($response, $this->driverOptions['path']); } return $response; }
[ "public", "function", "open", "(", "Response", "$", "response", ",", "$", "target", "=", "''", ",", "$", "tree", "=", "false", ",", "$", "init", "=", "false", ")", "{", "$", "target", "=", "$", "target", "?", ":", "$", "this", "->", "driverOptions", "[", "'path'", "]", ";", "$", "url", "=", "$", "this", "->", "driverOptions", "[", "'host'", "]", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "driverOptions", "[", "'path'", "]", ".", "DIRECTORY_SEPARATOR", ";", "$", "this", "->", "addOption", "(", "'path'", ",", "$", "target", ")", ";", "$", "this", "->", "addOption", "(", "'url'", ",", "$", "url", ")", ";", "$", "this", "->", "addOption", "(", "'tmbURL'", ",", "$", "url", ".", "$", "this", "->", "driverOptions", "[", "'tmbPath'", "]", ".", "DIRECTORY_SEPARATOR", ")", ";", "$", "dir", "=", "$", "this", "->", "getFileInfo", "(", "$", "target", ")", ";", "$", "response", "->", "setCwd", "(", "$", "dir", ")", ";", "$", "response", "->", "setFiles", "(", "$", "this", "->", "scanDir", "(", "$", "target", ")", ")", ";", "$", "response", "->", "appendFiles", "(", "$", "this", "->", "scanDir", "(", "$", "this", "->", "driverOptions", "[", "'path'", "]", ")", ")", ";", "if", "(", "$", "init", ")", "{", "$", "response", "->", "setUplMaxSize", "(", "ini_get", "(", "'upload_max_filesize'", ")", ")", ";", "}", "if", "(", "$", "tree", ")", "{", "$", "this", "->", "tree", "(", "$", "response", ",", "$", "this", "->", "driverOptions", "[", "'path'", "]", ")", ";", "}", "return", "$", "response", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L63-L86
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.getRootFileInfo
public function getRootFileInfo() { $root = $this->getFileInfo($this->driverOptions['path']); $root->setVolumeid($this->getDriverId().'_'); $root->setPhash(null); return $root; }
php
public function getRootFileInfo() { $root = $this->getFileInfo($this->driverOptions['path']); $root->setVolumeid($this->getDriverId().'_'); $root->setPhash(null); return $root; }
[ "public", "function", "getRootFileInfo", "(", ")", "{", "$", "root", "=", "$", "this", "->", "getFileInfo", "(", "$", "this", "->", "driverOptions", "[", "'path'", "]", ")", ";", "$", "root", "->", "setVolumeid", "(", "$", "this", "->", "getDriverId", "(", ")", ".", "'_'", ")", ";", "$", "root", "->", "setPhash", "(", "null", ")", ";", "return", "$", "root", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L91-L98
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.tree
public function tree(Response $response, $target) { $response->setTree($this->scanDir($target, GLOB_ONLYDIR)); return $response; }
php
public function tree(Response $response, $target) { $response->setTree($this->scanDir($target, GLOB_ONLYDIR)); return $response; }
[ "public", "function", "tree", "(", "Response", "$", "response", ",", "$", "target", ")", "{", "$", "response", "->", "setTree", "(", "$", "this", "->", "scanDir", "(", "$", "target", ",", "GLOB_ONLYDIR", ")", ")", ";", "return", "$", "response", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L103-L108
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.parents
public function parents(Response $response, $target) { do { $this->tree($response, $target); } while ($target = trim(dirname($target), '.')); }
php
public function parents(Response $response, $target) { do { $this->tree($response, $target); } while ($target = trim(dirname($target), '.')); }
[ "public", "function", "parents", "(", "Response", "$", "response", ",", "$", "target", ")", "{", "do", "{", "$", "this", "->", "tree", "(", "$", "response", ",", "$", "target", ")", ";", "}", "while", "(", "$", "target", "=", "trim", "(", "dirname", "(", "$", "target", ")", ",", "'.'", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L113-L118
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.upload
public function upload(Response $response, $target, $files) { if (is_array($files)) { $files = new FileBag($files); } /* @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */ $files = $files->all(); foreach ($files['upload'] as $file) { $fileName = $file->getClientOriginalName(); $file->move($target, $fileName); $originalFileName = $target.DIRECTORY_SEPARATOR.$fileName; $fileInfo = $this->getFileInfo($originalFileName); $response->addAdded($fileInfo); if ($fileInfo->getTmb()) { $manager = $this->getImageManager(); $image = $manager->make($originalFileName); foreach ($this->additionalImages as $additionalImage) { $fileTmb = $target.DIRECTORY_SEPARATOR.$additionalImage['prefix'].'_'.$fileName; $mode = $additionalImage['mode']; $image->{$mode}($additionalImage['width'], $additionalImage['height']); $image->save($fileTmb); $fileInfo = $this->getFileInfo($fileTmb); $response->addAdded($fileInfo); } } } }
php
public function upload(Response $response, $target, $files) { if (is_array($files)) { $files = new FileBag($files); } /* @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */ $files = $files->all(); foreach ($files['upload'] as $file) { $fileName = $file->getClientOriginalName(); $file->move($target, $fileName); $originalFileName = $target.DIRECTORY_SEPARATOR.$fileName; $fileInfo = $this->getFileInfo($originalFileName); $response->addAdded($fileInfo); if ($fileInfo->getTmb()) { $manager = $this->getImageManager(); $image = $manager->make($originalFileName); foreach ($this->additionalImages as $additionalImage) { $fileTmb = $target.DIRECTORY_SEPARATOR.$additionalImage['prefix'].'_'.$fileName; $mode = $additionalImage['mode']; $image->{$mode}($additionalImage['width'], $additionalImage['height']); $image->save($fileTmb); $fileInfo = $this->getFileInfo($fileTmb); $response->addAdded($fileInfo); } } } }
[ "public", "function", "upload", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "files", ")", "{", "if", "(", "is_array", "(", "$", "files", ")", ")", "{", "$", "files", "=", "new", "FileBag", "(", "$", "files", ")", ";", "}", "/* @var \\Symfony\\Component\\HttpFoundation\\File\\UploadedFile $file */", "$", "files", "=", "$", "files", "->", "all", "(", ")", ";", "foreach", "(", "$", "files", "[", "'upload'", "]", "as", "$", "file", ")", "{", "$", "fileName", "=", "$", "file", "->", "getClientOriginalName", "(", ")", ";", "$", "file", "->", "move", "(", "$", "target", ",", "$", "fileName", ")", ";", "$", "originalFileName", "=", "$", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "fileName", ";", "$", "fileInfo", "=", "$", "this", "->", "getFileInfo", "(", "$", "originalFileName", ")", ";", "$", "response", "->", "addAdded", "(", "$", "fileInfo", ")", ";", "if", "(", "$", "fileInfo", "->", "getTmb", "(", ")", ")", "{", "$", "manager", "=", "$", "this", "->", "getImageManager", "(", ")", ";", "$", "image", "=", "$", "manager", "->", "make", "(", "$", "originalFileName", ")", ";", "foreach", "(", "$", "this", "->", "additionalImages", "as", "$", "additionalImage", ")", "{", "$", "fileTmb", "=", "$", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "additionalImage", "[", "'prefix'", "]", ".", "'_'", ".", "$", "fileName", ";", "$", "mode", "=", "$", "additionalImage", "[", "'mode'", "]", ";", "$", "image", "->", "{", "$", "mode", "}", "(", "$", "additionalImage", "[", "'width'", "]", ",", "$", "additionalImage", "[", "'height'", "]", ")", ";", "$", "image", "->", "save", "(", "$", "fileTmb", ")", ";", "$", "fileInfo", "=", "$", "this", "->", "getFileInfo", "(", "$", "fileTmb", ")", ";", "$", "response", "->", "addAdded", "(", "$", "fileInfo", ")", ";", "}", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L123-L149
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.file
public function file(Response $response, $target, $download = false) { return new BinaryFileResponse($target, 200, [], false, $download ? 'attachment' : 'inline'); }
php
public function file(Response $response, $target, $download = false) { return new BinaryFileResponse($target, 200, [], false, $download ? 'attachment' : 'inline'); }
[ "public", "function", "file", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "download", "=", "false", ")", "{", "return", "new", "BinaryFileResponse", "(", "$", "target", ",", "200", ",", "[", "]", ",", "false", ",", "$", "download", "?", "'attachment'", ":", "'inline'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L154-L157
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.ls
public function ls(Response $response, $target) { $files = array_filter( glob($target.'/*', GLOB_MARK), function ($val) { return substr($val, -1, 1) != DIRECTORY_SEPARATOR; } ); $files = array_map( function ($val) { return $this->basename($val); }, $files ); $response->setList(array_values($files)); }
php
public function ls(Response $response, $target) { $files = array_filter( glob($target.'/*', GLOB_MARK), function ($val) { return substr($val, -1, 1) != DIRECTORY_SEPARATOR; } ); $files = array_map( function ($val) { return $this->basename($val); }, $files ); $response->setList(array_values($files)); }
[ "public", "function", "ls", "(", "Response", "$", "response", ",", "$", "target", ")", "{", "$", "files", "=", "array_filter", "(", "glob", "(", "$", "target", ".", "'/*'", ",", "GLOB_MARK", ")", ",", "function", "(", "$", "val", ")", "{", "return", "substr", "(", "$", "val", ",", "-", "1", ",", "1", ")", "!=", "DIRECTORY_SEPARATOR", ";", "}", ")", ";", "$", "files", "=", "array_map", "(", "function", "(", "$", "val", ")", "{", "return", "$", "this", "->", "basename", "(", "$", "val", ")", ";", "}", ",", "$", "files", ")", ";", "$", "response", "->", "setList", "(", "array_values", "(", "$", "files", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L162-L177
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.search
public function search(Response $response, $q) { $pattern = '/*'; do { $files = glob($this->driverOptions['path'].$pattern.$q.'*'); foreach ($files as $file) { $response->addFile($this->getFileInfo($file)); } $pattern = $pattern.'/*'; } while (glob($this->driverOptions['path'].$pattern, GLOB_ONLYDIR)); }
php
public function search(Response $response, $q) { $pattern = '/*'; do { $files = glob($this->driverOptions['path'].$pattern.$q.'*'); foreach ($files as $file) { $response->addFile($this->getFileInfo($file)); } $pattern = $pattern.'/*'; } while (glob($this->driverOptions['path'].$pattern, GLOB_ONLYDIR)); }
[ "public", "function", "search", "(", "Response", "$", "response", ",", "$", "q", ")", "{", "$", "pattern", "=", "'/*'", ";", "do", "{", "$", "files", "=", "glob", "(", "$", "this", "->", "driverOptions", "[", "'path'", "]", ".", "$", "pattern", ".", "$", "q", ".", "'*'", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "response", "->", "addFile", "(", "$", "this", "->", "getFileInfo", "(", "$", "file", ")", ")", ";", "}", "$", "pattern", "=", "$", "pattern", ".", "'/*'", ";", "}", "while", "(", "glob", "(", "$", "this", "->", "driverOptions", "[", "'path'", "]", ".", "$", "pattern", ",", "GLOB_ONLYDIR", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L182-L192
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.size
public function size(Response $response, array $targets) { $response->incSize(0); foreach ($targets as $target) { if (is_dir($target)) { $this->size($response, glob($target.DIRECTORY_SEPARATOR.'*')); } else { $response->incSize(filesize($target)); } } }
php
public function size(Response $response, array $targets) { $response->incSize(0); foreach ($targets as $target) { if (is_dir($target)) { $this->size($response, glob($target.DIRECTORY_SEPARATOR.'*')); } else { $response->incSize(filesize($target)); } } }
[ "public", "function", "size", "(", "Response", "$", "response", ",", "array", "$", "targets", ")", "{", "$", "response", "->", "incSize", "(", "0", ")", ";", "foreach", "(", "$", "targets", "as", "$", "target", ")", "{", "if", "(", "is_dir", "(", "$", "target", ")", ")", "{", "$", "this", "->", "size", "(", "$", "response", ",", "glob", "(", "$", "target", ".", "DIRECTORY_SEPARATOR", ".", "'*'", ")", ")", ";", "}", "else", "{", "$", "response", "->", "incSize", "(", "filesize", "(", "$", "target", ")", ")", ";", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L197-L207
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.mkdir
public function mkdir(Response $response, $target, $name) { $dirName = $target.DIRECTORY_SEPARATOR.$name; @mkdir($dirName); $dir = $this->getFileInfo($dirName); $response->addAdded($dir); return $response; }
php
public function mkdir(Response $response, $target, $name) { $dirName = $target.DIRECTORY_SEPARATOR.$name; @mkdir($dirName); $dir = $this->getFileInfo($dirName); $response->addAdded($dir); return $response; }
[ "public", "function", "mkdir", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "name", ")", "{", "$", "dirName", "=", "$", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "@", "mkdir", "(", "$", "dirName", ")", ";", "$", "dir", "=", "$", "this", "->", "getFileInfo", "(", "$", "dirName", ")", ";", "$", "response", "->", "addAdded", "(", "$", "dir", ")", ";", "return", "$", "response", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L212-L220
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.rm
public function rm(Response $response, array $targets) { foreach ($targets as $target) { if (is_dir($target)) { $files = []; $d = dir($target); while (false !== ($entry = $d->read())) { $file = $target.DIRECTORY_SEPARATOR.$entry; if ($this->isShowFile($entry, true)) { $files[] = $file; } } $d->close(); $this->rm($response, $files); rmdir($target); } else { $tmb = $this->getThumb($target); unlink($target); if (file_exists($tmb)) { unlink($tmb); } } $response->addRemoved(FileInfo::createHash($target, $this->driverId)); } return $response; }
php
public function rm(Response $response, array $targets) { foreach ($targets as $target) { if (is_dir($target)) { $files = []; $d = dir($target); while (false !== ($entry = $d->read())) { $file = $target.DIRECTORY_SEPARATOR.$entry; if ($this->isShowFile($entry, true)) { $files[] = $file; } } $d->close(); $this->rm($response, $files); rmdir($target); } else { $tmb = $this->getThumb($target); unlink($target); if (file_exists($tmb)) { unlink($tmb); } } $response->addRemoved(FileInfo::createHash($target, $this->driverId)); } return $response; }
[ "public", "function", "rm", "(", "Response", "$", "response", ",", "array", "$", "targets", ")", "{", "foreach", "(", "$", "targets", "as", "$", "target", ")", "{", "if", "(", "is_dir", "(", "$", "target", ")", ")", "{", "$", "files", "=", "[", "]", ";", "$", "d", "=", "dir", "(", "$", "target", ")", ";", "while", "(", "false", "!==", "(", "$", "entry", "=", "$", "d", "->", "read", "(", ")", ")", ")", "{", "$", "file", "=", "$", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ";", "if", "(", "$", "this", "->", "isShowFile", "(", "$", "entry", ",", "true", ")", ")", "{", "$", "files", "[", "]", "=", "$", "file", ";", "}", "}", "$", "d", "->", "close", "(", ")", ";", "$", "this", "->", "rm", "(", "$", "response", ",", "$", "files", ")", ";", "rmdir", "(", "$", "target", ")", ";", "}", "else", "{", "$", "tmb", "=", "$", "this", "->", "getThumb", "(", "$", "target", ")", ";", "unlink", "(", "$", "target", ")", ";", "if", "(", "file_exists", "(", "$", "tmb", ")", ")", "{", "unlink", "(", "$", "tmb", ")", ";", "}", "}", "$", "response", "->", "addRemoved", "(", "FileInfo", "::", "createHash", "(", "$", "target", ",", "$", "this", "->", "driverId", ")", ")", ";", "}", "return", "$", "response", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L225-L251
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.rename
public function rename(Response $response, $target, $name) { $name = pathinfo($target, PATHINFO_DIRNAME).DIRECTORY_SEPARATOR.$name; rename($target, $name); $tmb = $this->getThumb($target); if (file_exists($tmb)) { unlink($tmb); } $response->addRemoved(FileInfo::createHash($target, $this->driverId)); $response->addAdded($this->getFileInfo($name)); }
php
public function rename(Response $response, $target, $name) { $name = pathinfo($target, PATHINFO_DIRNAME).DIRECTORY_SEPARATOR.$name; rename($target, $name); $tmb = $this->getThumb($target); if (file_exists($tmb)) { unlink($tmb); } $response->addRemoved(FileInfo::createHash($target, $this->driverId)); $response->addAdded($this->getFileInfo($name)); }
[ "public", "function", "rename", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "name", ")", "{", "$", "name", "=", "pathinfo", "(", "$", "target", ",", "PATHINFO_DIRNAME", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "rename", "(", "$", "target", ",", "$", "name", ")", ";", "$", "tmb", "=", "$", "this", "->", "getThumb", "(", "$", "target", ")", ";", "if", "(", "file_exists", "(", "$", "tmb", ")", ")", "{", "unlink", "(", "$", "tmb", ")", ";", "}", "$", "response", "->", "addRemoved", "(", "FileInfo", "::", "createHash", "(", "$", "target", ",", "$", "this", "->", "driverId", ")", ")", ";", "$", "response", "->", "addAdded", "(", "$", "this", "->", "getFileInfo", "(", "$", "name", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L256-L266
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.duplicate
public function duplicate(Response $response, array $targets) { foreach ($targets as $target) { $pathInfo = pathinfo($target); $isDir = is_dir($target); for ($i = 0; $i < 1000000; ++$i) { $newName = $isDir ? $target.'_'.$i : $pathInfo['dirname'].DIRECTORY_SEPARATOR.$pathInfo['filename'].'_'.$i.'.'.$pathInfo['extension']; if (!file_exists($newName)) { if ($isDir) { $this->copyDir($response, $target, $target, $newName); } else { copy($target, $newName); } $response->addAdded($this->getFileInfo($newName)); break; } } } }
php
public function duplicate(Response $response, array $targets) { foreach ($targets as $target) { $pathInfo = pathinfo($target); $isDir = is_dir($target); for ($i = 0; $i < 1000000; ++$i) { $newName = $isDir ? $target.'_'.$i : $pathInfo['dirname'].DIRECTORY_SEPARATOR.$pathInfo['filename'].'_'.$i.'.'.$pathInfo['extension']; if (!file_exists($newName)) { if ($isDir) { $this->copyDir($response, $target, $target, $newName); } else { copy($target, $newName); } $response->addAdded($this->getFileInfo($newName)); break; } } } }
[ "public", "function", "duplicate", "(", "Response", "$", "response", ",", "array", "$", "targets", ")", "{", "foreach", "(", "$", "targets", "as", "$", "target", ")", "{", "$", "pathInfo", "=", "pathinfo", "(", "$", "target", ")", ";", "$", "isDir", "=", "is_dir", "(", "$", "target", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "1000000", ";", "++", "$", "i", ")", "{", "$", "newName", "=", "$", "isDir", "?", "$", "target", ".", "'_'", ".", "$", "i", ":", "$", "pathInfo", "[", "'dirname'", "]", ".", "DIRECTORY_SEPARATOR", ".", "$", "pathInfo", "[", "'filename'", "]", ".", "'_'", ".", "$", "i", ".", "'.'", ".", "$", "pathInfo", "[", "'extension'", "]", ";", "if", "(", "!", "file_exists", "(", "$", "newName", ")", ")", "{", "if", "(", "$", "isDir", ")", "{", "$", "this", "->", "copyDir", "(", "$", "response", ",", "$", "target", ",", "$", "target", ",", "$", "newName", ")", ";", "}", "else", "{", "copy", "(", "$", "target", ",", "$", "newName", ")", ";", "}", "$", "response", "->", "addAdded", "(", "$", "this", "->", "getFileInfo", "(", "$", "newName", ")", ")", ";", "break", ";", "}", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L271-L289
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.paste
public function paste(Response $response, $src, $dst, array $targets, $cut = 0) { foreach ($targets as $target) { if (is_dir($target)) { $this->copyDir($response, $target, $dst); } else { $fileName = $dst.DIRECTORY_SEPARATOR.$this->basename($target); copy($target, $fileName); $response->addAdded($this->getFileInfo($dst.DIRECTORY_SEPARATOR.$fileName)); } } if ($cut) { $this->rm($response, $targets); } }
php
public function paste(Response $response, $src, $dst, array $targets, $cut = 0) { foreach ($targets as $target) { if (is_dir($target)) { $this->copyDir($response, $target, $dst); } else { $fileName = $dst.DIRECTORY_SEPARATOR.$this->basename($target); copy($target, $fileName); $response->addAdded($this->getFileInfo($dst.DIRECTORY_SEPARATOR.$fileName)); } } if ($cut) { $this->rm($response, $targets); } }
[ "public", "function", "paste", "(", "Response", "$", "response", ",", "$", "src", ",", "$", "dst", ",", "array", "$", "targets", ",", "$", "cut", "=", "0", ")", "{", "foreach", "(", "$", "targets", "as", "$", "target", ")", "{", "if", "(", "is_dir", "(", "$", "target", ")", ")", "{", "$", "this", "->", "copyDir", "(", "$", "response", ",", "$", "target", ",", "$", "dst", ")", ";", "}", "else", "{", "$", "fileName", "=", "$", "dst", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "basename", "(", "$", "target", ")", ";", "copy", "(", "$", "target", ",", "$", "fileName", ")", ";", "$", "response", "->", "addAdded", "(", "$", "this", "->", "getFileInfo", "(", "$", "dst", ".", "DIRECTORY_SEPARATOR", ".", "$", "fileName", ")", ")", ";", "}", "}", "if", "(", "$", "cut", ")", "{", "$", "this", "->", "rm", "(", "$", "response", ",", "$", "targets", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L294-L308
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.info
public function info(Response $response, array $targets) { foreach ($targets as $target) { $response->addFile($this->getFileInfo($target)); } }
php
public function info(Response $response, array $targets) { foreach ($targets as $target) { $response->addFile($this->getFileInfo($target)); } }
[ "public", "function", "info", "(", "Response", "$", "response", ",", "array", "$", "targets", ")", "{", "foreach", "(", "$", "targets", "as", "$", "target", ")", "{", "$", "response", "->", "addFile", "(", "$", "this", "->", "getFileInfo", "(", "$", "target", ")", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L313-L318
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.put
public function put(Response $response, $target, $content = '') { $fp = fopen($target, 'w'); fwrite($fp, $content); fclose($fp); }
php
public function put(Response $response, $target, $content = '') { $fp = fopen($target, 'w'); fwrite($fp, $content); fclose($fp); }
[ "public", "function", "put", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "content", "=", "''", ")", "{", "$", "fp", "=", "fopen", "(", "$", "target", ",", "'w'", ")", ";", "fwrite", "(", "$", "fp", ",", "$", "content", ")", ";", "fclose", "(", "$", "fp", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L331-L336
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.mkfile
public function mkfile(Response $response, $target, $name) { $fullName = $target.DIRECTORY_SEPARATOR.$name; $fp = fopen($fullName, 'w'); fclose($fp); $file = $this->getFileInfo($fullName); $response->addAdded($file); }
php
public function mkfile(Response $response, $target, $name) { $fullName = $target.DIRECTORY_SEPARATOR.$name; $fp = fopen($fullName, 'w'); fclose($fp); $file = $this->getFileInfo($fullName); $response->addAdded($file); }
[ "public", "function", "mkfile", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "name", ")", "{", "$", "fullName", "=", "$", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "$", "fp", "=", "fopen", "(", "$", "fullName", ",", "'w'", ")", ";", "fclose", "(", "$", "fp", ")", ";", "$", "file", "=", "$", "this", "->", "getFileInfo", "(", "$", "fullName", ")", ";", "$", "response", "->", "addAdded", "(", "$", "file", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L341-L348
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.tmb
public function tmb(Response $response, array $targets) { $data = ['images' => [], 'tmb' => false]; $manager = $this->getImageManager(); if (!empty($this->driverOptions['tmbPath']) && !empty($this->driverOptions['path'])) { foreach ($targets as $target) { $pInfo = pathinfo($target); $tmbPath = $pInfo['dirname'].DIRECTORY_SEPARATOR.$this->driverOptions['tmbPath'].DIRECTORY_SEPARATOR; if (!file_exists($tmbPath)) { mkdir($tmbPath); } $filename = FileInfo::createHash($target, $this->driverId); $tmbFile = $tmbPath.$this->basename($target); $image = $manager->make($target); $image->fit($this->driverOptions['tmbSize']); $image->save($tmbFile); $data['images'][$filename] = DIRECTORY_SEPARATOR.$tmbFile; } } return new JsonResponse($data); }
php
public function tmb(Response $response, array $targets) { $data = ['images' => [], 'tmb' => false]; $manager = $this->getImageManager(); if (!empty($this->driverOptions['tmbPath']) && !empty($this->driverOptions['path'])) { foreach ($targets as $target) { $pInfo = pathinfo($target); $tmbPath = $pInfo['dirname'].DIRECTORY_SEPARATOR.$this->driverOptions['tmbPath'].DIRECTORY_SEPARATOR; if (!file_exists($tmbPath)) { mkdir($tmbPath); } $filename = FileInfo::createHash($target, $this->driverId); $tmbFile = $tmbPath.$this->basename($target); $image = $manager->make($target); $image->fit($this->driverOptions['tmbSize']); $image->save($tmbFile); $data['images'][$filename] = DIRECTORY_SEPARATOR.$tmbFile; } } return new JsonResponse($data); }
[ "public", "function", "tmb", "(", "Response", "$", "response", ",", "array", "$", "targets", ")", "{", "$", "data", "=", "[", "'images'", "=>", "[", "]", ",", "'tmb'", "=>", "false", "]", ";", "$", "manager", "=", "$", "this", "->", "getImageManager", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "driverOptions", "[", "'tmbPath'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "driverOptions", "[", "'path'", "]", ")", ")", "{", "foreach", "(", "$", "targets", "as", "$", "target", ")", "{", "$", "pInfo", "=", "pathinfo", "(", "$", "target", ")", ";", "$", "tmbPath", "=", "$", "pInfo", "[", "'dirname'", "]", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "driverOptions", "[", "'tmbPath'", "]", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "file_exists", "(", "$", "tmbPath", ")", ")", "{", "mkdir", "(", "$", "tmbPath", ")", ";", "}", "$", "filename", "=", "FileInfo", "::", "createHash", "(", "$", "target", ",", "$", "this", "->", "driverId", ")", ";", "$", "tmbFile", "=", "$", "tmbPath", ".", "$", "this", "->", "basename", "(", "$", "target", ")", ";", "$", "image", "=", "$", "manager", "->", "make", "(", "$", "target", ")", ";", "$", "image", "->", "fit", "(", "$", "this", "->", "driverOptions", "[", "'tmbSize'", "]", ")", ";", "$", "image", "->", "save", "(", "$", "tmbFile", ")", ";", "$", "data", "[", "'images'", "]", "[", "$", "filename", "]", "=", "DIRECTORY_SEPARATOR", ".", "$", "tmbFile", ";", "}", "}", "return", "new", "JsonResponse", "(", "$", "data", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L353-L374
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.resize
public function resize(Response $response, $target, $width, $height, $mode, $x = 0, $y = 0, $degree = 0) { $image = $this->getImageManager()->make($target); switch ($mode) { case 'resize': $image->resize($width, $height); break; case 'crop': $image->crop($width, $height, $x, $y); break; case 'rotate': $image->rotate($degree * -1); break; default: throw new CommandNotSupportException(sprintf('command "%s" not supported', $mode)); break; } $image->save($target); $this->open($response, $target); }
php
public function resize(Response $response, $target, $width, $height, $mode, $x = 0, $y = 0, $degree = 0) { $image = $this->getImageManager()->make($target); switch ($mode) { case 'resize': $image->resize($width, $height); break; case 'crop': $image->crop($width, $height, $x, $y); break; case 'rotate': $image->rotate($degree * -1); break; default: throw new CommandNotSupportException(sprintf('command "%s" not supported', $mode)); break; } $image->save($target); $this->open($response, $target); }
[ "public", "function", "resize", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "width", ",", "$", "height", ",", "$", "mode", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ",", "$", "degree", "=", "0", ")", "{", "$", "image", "=", "$", "this", "->", "getImageManager", "(", ")", "->", "make", "(", "$", "target", ")", ";", "switch", "(", "$", "mode", ")", "{", "case", "'resize'", ":", "$", "image", "->", "resize", "(", "$", "width", ",", "$", "height", ")", ";", "break", ";", "case", "'crop'", ":", "$", "image", "->", "crop", "(", "$", "width", ",", "$", "height", ",", "$", "x", ",", "$", "y", ")", ";", "break", ";", "case", "'rotate'", ":", "$", "image", "->", "rotate", "(", "$", "degree", "*", "-", "1", ")", ";", "break", ";", "default", ":", "throw", "new", "CommandNotSupportException", "(", "sprintf", "(", "'command \"%s\" not supported'", ",", "$", "mode", ")", ")", ";", "break", ";", "}", "$", "image", "->", "save", "(", "$", "target", ")", ";", "$", "this", "->", "open", "(", "$", "response", ",", "$", "target", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L379-L398
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.dim
public function dim(Response $response, $target) { $img = $this->getImageManager()->make($target); $response->setDim($img->getWidth().'x'.$img->getHeight()); }
php
public function dim(Response $response, $target) { $img = $this->getImageManager()->make($target); $response->setDim($img->getWidth().'x'.$img->getHeight()); }
[ "public", "function", "dim", "(", "Response", "$", "response", ",", "$", "target", ")", "{", "$", "img", "=", "$", "this", "->", "getImageManager", "(", ")", "->", "make", "(", "$", "target", ")", ";", "$", "response", "->", "setDim", "(", "$", "img", "->", "getWidth", "(", ")", ".", "'x'", ".", "$", "img", "->", "getHeight", "(", ")", ")", ";", "}" ]
return image dimensions. @param Response $response @param string $target
[ "return", "image", "dimensions", "." ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L406-L410
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.setAdditionalImages
public function setAdditionalImages(array $additionalImages) { $resolver = new OptionsResolver(); $this->configureAdditionalImage($resolver); $this->additionalImages = $additionalImages; foreach ($additionalImages as $additionalImage) { $this->addAdditionalImage($additionalImage, $resolver); } return $this; }
php
public function setAdditionalImages(array $additionalImages) { $resolver = new OptionsResolver(); $this->configureAdditionalImage($resolver); $this->additionalImages = $additionalImages; foreach ($additionalImages as $additionalImage) { $this->addAdditionalImage($additionalImage, $resolver); } return $this; }
[ "public", "function", "setAdditionalImages", "(", "array", "$", "additionalImages", ")", "{", "$", "resolver", "=", "new", "OptionsResolver", "(", ")", ";", "$", "this", "->", "configureAdditionalImage", "(", "$", "resolver", ")", ";", "$", "this", "->", "additionalImages", "=", "$", "additionalImages", ";", "foreach", "(", "$", "additionalImages", "as", "$", "additionalImage", ")", "{", "$", "this", "->", "addAdditionalImage", "(", "$", "additionalImage", ",", "$", "resolver", ")", ";", "}", "return", "$", "this", ";", "}" ]
set Additional Images. @param array $additionalImages @return $this
[ "set", "Additional", "Images", "." ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L419-L429
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.addAdditionalImage
protected function addAdditionalImage(array $additionalImage, OptionsResolver $resolver) { $image = $resolver->resolve($additionalImage); $this->additionalImages[$image['prefix']] = $image; return $this; }
php
protected function addAdditionalImage(array $additionalImage, OptionsResolver $resolver) { $image = $resolver->resolve($additionalImage); $this->additionalImages[$image['prefix']] = $image; return $this; }
[ "protected", "function", "addAdditionalImage", "(", "array", "$", "additionalImage", ",", "OptionsResolver", "$", "resolver", ")", "{", "$", "image", "=", "$", "resolver", "->", "resolve", "(", "$", "additionalImage", ")", ";", "$", "this", "->", "additionalImages", "[", "$", "image", "[", "'prefix'", "]", "]", "=", "$", "image", ";", "return", "$", "this", ";", "}" ]
add Additional Image. @param array $additionalImage @param OptionsResolver $resolver @return $this
[ "add", "Additional", "Image", "." ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L439-L445
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.configureAdditionalImage
protected function configureAdditionalImage(OptionsResolver $resolver) { $resolver ->setRequired(['prefix', 'width', 'height']) ->setOptional(['mode']) ->setDefaults(['mode' => 'fit']) ->addAllowedTypes( [ 'prefix' => 'string', 'mode' => 'string', 'width' => 'integer', 'height' => 'integer', ] ) ->addAllowedValues(['mode' => ['crop', 'resize', 'fit']]); return $this; }
php
protected function configureAdditionalImage(OptionsResolver $resolver) { $resolver ->setRequired(['prefix', 'width', 'height']) ->setOptional(['mode']) ->setDefaults(['mode' => 'fit']) ->addAllowedTypes( [ 'prefix' => 'string', 'mode' => 'string', 'width' => 'integer', 'height' => 'integer', ] ) ->addAllowedValues(['mode' => ['crop', 'resize', 'fit']]); return $this; }
[ "protected", "function", "configureAdditionalImage", "(", "OptionsResolver", "$", "resolver", ")", "{", "$", "resolver", "->", "setRequired", "(", "[", "'prefix'", ",", "'width'", ",", "'height'", "]", ")", "->", "setOptional", "(", "[", "'mode'", "]", ")", "->", "setDefaults", "(", "[", "'mode'", "=>", "'fit'", "]", ")", "->", "addAllowedTypes", "(", "[", "'prefix'", "=>", "'string'", ",", "'mode'", "=>", "'string'", ",", "'width'", "=>", "'integer'", ",", "'height'", "=>", "'integer'", ",", "]", ")", "->", "addAllowedValues", "(", "[", "'mode'", "=>", "[", "'crop'", ",", "'resize'", ",", "'fit'", "]", "]", ")", ";", "return", "$", "this", ";", "}" ]
configure Additional Image. @param OptionsResolver $resolver @return $this
[ "configure", "Additional", "Image", "." ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L454-L471
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.copyDir
private function copyDir(Response $response, $target, $dst, $newFolder = '') { $folder = trim(strrchr($target, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR); $newFolder = $newFolder ?: $dst.DIRECTORY_SEPARATOR.$folder; if (file_exists($newFolder)) { throw new ExistsException(sprintf('folder "%s" exists', $newFolder)); } mkdir($newFolder); $response->addAdded($this->getFileInfo($newFolder)); foreach (glob($target.'/*') as $name) { if (is_dir($name)) { $this->copyDir($response, $name, $newFolder); } else { $filename = $newFolder.DIRECTORY_SEPARATOR.$this->basename($name); copy($name, $filename); $response->addAdded($this->getFileInfo($filename)); } } }
php
private function copyDir(Response $response, $target, $dst, $newFolder = '') { $folder = trim(strrchr($target, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR); $newFolder = $newFolder ?: $dst.DIRECTORY_SEPARATOR.$folder; if (file_exists($newFolder)) { throw new ExistsException(sprintf('folder "%s" exists', $newFolder)); } mkdir($newFolder); $response->addAdded($this->getFileInfo($newFolder)); foreach (glob($target.'/*') as $name) { if (is_dir($name)) { $this->copyDir($response, $name, $newFolder); } else { $filename = $newFolder.DIRECTORY_SEPARATOR.$this->basename($name); copy($name, $filename); $response->addAdded($this->getFileInfo($filename)); } } }
[ "private", "function", "copyDir", "(", "Response", "$", "response", ",", "$", "target", ",", "$", "dst", ",", "$", "newFolder", "=", "''", ")", "{", "$", "folder", "=", "trim", "(", "strrchr", "(", "$", "target", ",", "DIRECTORY_SEPARATOR", ")", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "newFolder", "=", "$", "newFolder", "?", ":", "$", "dst", ".", "DIRECTORY_SEPARATOR", ".", "$", "folder", ";", "if", "(", "file_exists", "(", "$", "newFolder", ")", ")", "{", "throw", "new", "ExistsException", "(", "sprintf", "(", "'folder \"%s\" exists'", ",", "$", "newFolder", ")", ")", ";", "}", "mkdir", "(", "$", "newFolder", ")", ";", "$", "response", "->", "addAdded", "(", "$", "this", "->", "getFileInfo", "(", "$", "newFolder", ")", ")", ";", "foreach", "(", "glob", "(", "$", "target", ".", "'/*'", ")", "as", "$", "name", ")", "{", "if", "(", "is_dir", "(", "$", "name", ")", ")", "{", "$", "this", "->", "copyDir", "(", "$", "response", ",", "$", "name", ",", "$", "newFolder", ")", ";", "}", "else", "{", "$", "filename", "=", "$", "newFolder", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "basename", "(", "$", "name", ")", ";", "copy", "(", "$", "name", ",", "$", "filename", ")", ";", "$", "response", "->", "addAdded", "(", "$", "this", "->", "getFileInfo", "(", "$", "filename", ")", ")", ";", "}", "}", "}" ]
copy dir and all inside. @param Response $response @param string $target @param string $dst @param string $newFolder
[ "copy", "dir", "and", "all", "inside", "." ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L481-L499
4devs/ElfinderPhpConnector
Driver/LocalDriver.php
LocalDriver.isShowFile
private function isShowFile($name, $showHidden = false) { $response = true; if ($name == '.' || $name == '..' || (!$showHidden && strpos($name, '.') === 0)) { $response = false; } return $response; }
php
private function isShowFile($name, $showHidden = false) { $response = true; if ($name == '.' || $name == '..' || (!$showHidden && strpos($name, '.') === 0)) { $response = false; } return $response; }
[ "private", "function", "isShowFile", "(", "$", "name", ",", "$", "showHidden", "=", "false", ")", "{", "$", "response", "=", "true", ";", "if", "(", "$", "name", "==", "'.'", "||", "$", "name", "==", "'..'", "||", "(", "!", "$", "showHidden", "&&", "strpos", "(", "$", "name", ",", "'.'", ")", "===", "0", ")", ")", "{", "$", "response", "=", "false", ";", "}", "return", "$", "response", ";", "}" ]
is Show File. @param string $name @return bool
[ "is", "Show", "File", "." ]
train
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/LocalDriver.php#L508-L516