id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
238,700
strident/Trident
src/Trident/Component/HttpKernel/Controller/ControllerResolver.php
ControllerResolver.getController
public function getController(Request $request, array $matched) { if (null !== $request->attributes->get('_controller')) { return $this->createController($request->attributes->get('_controller')); } if ( ! $controller = $matched['_controller']) { throw new \InvalidArgumentException('Unable to look for controller as the "_controller" parameter is missing'); } $callable = $this->createController($controller); if ( ! is_callable($callable)) { throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request)); } return $callable; }
php
public function getController(Request $request, array $matched) { if (null !== $request->attributes->get('_controller')) { return $this->createController($request->attributes->get('_controller')); } if ( ! $controller = $matched['_controller']) { throw new \InvalidArgumentException('Unable to look for controller as the "_controller" parameter is missing'); } $callable = $this->createController($controller); if ( ! is_callable($callable)) { throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request)); } return $callable; }
[ "public", "function", "getController", "(", "Request", "$", "request", ",", "array", "$", "matched", ")", "{", "if", "(", "null", "!==", "$", "request", "->", "attributes", "->", "get", "(", "'_controller'", ")", ")", "{", "return", "$", "this", "->", "createController", "(", "$", "request", "->", "attributes", "->", "get", "(", "'_controller'", ")", ")", ";", "}", "if", "(", "!", "$", "controller", "=", "$", "matched", "[", "'_controller'", "]", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unable to look for controller as the \"_controller\" parameter is missing'", ")", ";", "}", "$", "callable", "=", "$", "this", "->", "createController", "(", "$", "controller", ")", ";", "if", "(", "!", "is_callable", "(", "$", "callable", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Controller \"%s\" for URI \"%s\" is not callable.'", ",", "$", "controller", ",", "$", "request", ")", ")", ";", "}", "return", "$", "callable", ";", "}" ]
Get a callable controller @param Request $request @param array $matched @return callable
[ "Get", "a", "callable", "controller" ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/HttpKernel/Controller/ControllerResolver.php#L46-L63
238,701
strident/Trident
src/Trident/Component/HttpKernel/Controller/ControllerResolver.php
ControllerResolver.createController
protected function createController($controller) { if (false === strpos($controller, '::')) { throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller)); } list($class, $method) = explode('::', $controller, 2); if ($this->container->has($class)) { $controller = $this->container->get($class); } else { if ( ! class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); } $controller = new $class(); } if ($controller instanceof ContainerAwareInterface) { $controller->setContainer($this->container); } return array($controller, $method); }
php
protected function createController($controller) { if (false === strpos($controller, '::')) { throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller)); } list($class, $method) = explode('::', $controller, 2); if ($this->container->has($class)) { $controller = $this->container->get($class); } else { if ( ! class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); } $controller = new $class(); } if ($controller instanceof ContainerAwareInterface) { $controller->setContainer($this->container); } return array($controller, $method); }
[ "protected", "function", "createController", "(", "$", "controller", ")", "{", "if", "(", "false", "===", "strpos", "(", "$", "controller", ",", "'::'", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Unable to find controller \"%s\".'", ",", "$", "controller", ")", ")", ";", "}", "list", "(", "$", "class", ",", "$", "method", ")", "=", "explode", "(", "'::'", ",", "$", "controller", ",", "2", ")", ";", "if", "(", "$", "this", "->", "container", "->", "has", "(", "$", "class", ")", ")", "{", "$", "controller", "=", "$", "this", "->", "container", "->", "get", "(", "$", "class", ")", ";", "}", "else", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Class \"%s\" does not exist.'", ",", "$", "class", ")", ")", ";", "}", "$", "controller", "=", "new", "$", "class", "(", ")", ";", "}", "if", "(", "$", "controller", "instanceof", "ContainerAwareInterface", ")", "{", "$", "controller", "->", "setContainer", "(", "$", "this", "->", "container", ")", ";", "}", "return", "array", "(", "$", "controller", ",", "$", "method", ")", ";", "}" ]
Creates the callable from the controller string @param string $controller @return callable
[ "Creates", "the", "callable", "from", "the", "controller", "string" ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/HttpKernel/Controller/ControllerResolver.php#L71-L94
238,702
strident/Trident
src/Trident/Component/HttpKernel/Controller/ControllerResolver.php
ControllerResolver.getArguments
public function getArguments(Request $request, array $controller, array $matched) { $reflection = new \ReflectionMethod($controller[0], $controller[1]); $attributes = $request->attributes->all(); $arguments = []; foreach ($reflection->getParameters() as $param) { if (array_key_exists($param->name, $matched)) { $arguments[] = $matched[$param->name]; } elseif (array_key_exists($param->name, $attributes)) { $arguments[] = $attributes[$param->name]; } elseif ($param->isDefaultValueAvailable()) { $arguments[] = $param->getDefaultValue(); } else { $controller = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (either because there is no default value, or because there is a non-optional argument after this one).', $controller, $param->name)); } } return $arguments; }
php
public function getArguments(Request $request, array $controller, array $matched) { $reflection = new \ReflectionMethod($controller[0], $controller[1]); $attributes = $request->attributes->all(); $arguments = []; foreach ($reflection->getParameters() as $param) { if (array_key_exists($param->name, $matched)) { $arguments[] = $matched[$param->name]; } elseif (array_key_exists($param->name, $attributes)) { $arguments[] = $attributes[$param->name]; } elseif ($param->isDefaultValueAvailable()) { $arguments[] = $param->getDefaultValue(); } else { $controller = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (either because there is no default value, or because there is a non-optional argument after this one).', $controller, $param->name)); } } return $arguments; }
[ "public", "function", "getArguments", "(", "Request", "$", "request", ",", "array", "$", "controller", ",", "array", "$", "matched", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionMethod", "(", "$", "controller", "[", "0", "]", ",", "$", "controller", "[", "1", "]", ")", ";", "$", "attributes", "=", "$", "request", "->", "attributes", "->", "all", "(", ")", ";", "$", "arguments", "=", "[", "]", ";", "foreach", "(", "$", "reflection", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "if", "(", "array_key_exists", "(", "$", "param", "->", "name", ",", "$", "matched", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "matched", "[", "$", "param", "->", "name", "]", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "param", "->", "name", ",", "$", "attributes", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "attributes", "[", "$", "param", "->", "name", "]", ";", "}", "elseif", "(", "$", "param", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "param", "->", "getDefaultValue", "(", ")", ";", "}", "else", "{", "$", "controller", "=", "sprintf", "(", "'%s::%s()'", ",", "get_class", "(", "$", "controller", "[", "0", "]", ")", ",", "$", "controller", "[", "1", "]", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Controller \"%s\" requires that you provide a value for the \"$%s\" argument (either because there is no default value, or because there is a non-optional argument after this one).'", ",", "$", "controller", ",", "$", "param", "->", "name", ")", ")", ";", "}", "}", "return", "$", "arguments", ";", "}" ]
Get controller action arguments @param Request $request @param array $controller @param array $matched @return array
[ "Get", "controller", "action", "arguments" ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/HttpKernel/Controller/ControllerResolver.php#L104-L124
238,703
wearenolte/wp-endpoints-post
src/Inc/Type.php
Type.get
public static function get( $post ) { $post = is_a( $post, 'WP_Post' ) ? $post : get_post( $post ); $type = $post->post_type; if ( 'page' === $type ) { $template_slug = get_page_template_slug( $post->ID ); if ( ! empty( $template_slug ) ) { $type .= '-' . wp_basename( $template_slug, '.php' ); } } return $type; }
php
public static function get( $post ) { $post = is_a( $post, 'WP_Post' ) ? $post : get_post( $post ); $type = $post->post_type; if ( 'page' === $type ) { $template_slug = get_page_template_slug( $post->ID ); if ( ! empty( $template_slug ) ) { $type .= '-' . wp_basename( $template_slug, '.php' ); } } return $type; }
[ "public", "static", "function", "get", "(", "$", "post", ")", "{", "$", "post", "=", "is_a", "(", "$", "post", ",", "'WP_Post'", ")", "?", "$", "post", ":", "get_post", "(", "$", "post", ")", ";", "$", "type", "=", "$", "post", "->", "post_type", ";", "if", "(", "'page'", "===", "$", "type", ")", "{", "$", "template_slug", "=", "get_page_template_slug", "(", "$", "post", "->", "ID", ")", ";", "if", "(", "!", "empty", "(", "$", "template_slug", ")", ")", "{", "$", "type", ".=", "'-'", ".", "wp_basename", "(", "$", "template_slug", ",", "'.php'", ")", ";", "}", "}", "return", "$", "type", ";", "}" ]
Returns the type for the post, the term template applies to what type of post is or what type of template is using. @param Int|\WP_Post $post The post @return string
[ "Returns", "the", "type", "for", "the", "post", "the", "term", "template", "applies", "to", "what", "type", "of", "post", "is", "or", "what", "type", "of", "template", "is", "using", "." ]
11f17af89a3164faade5bd05be714cc3ab6e3c08
https://github.com/wearenolte/wp-endpoints-post/blob/11f17af89a3164faade5bd05be714cc3ab6e3c08/src/Inc/Type.php#L17-L27
238,704
lembarek/auth
src/Controllers/AuthController.php
AuthController.postRegister
public function postRegister(RegisterRequest $request) { $inputs = $request->except('_token'); $inputs['password'] = Hash::make($inputs['password']); $user = $this->userRepo->create($inputs); Event::fire(new UserHasCreated($user)); return Redirect::to('/'); }
php
public function postRegister(RegisterRequest $request) { $inputs = $request->except('_token'); $inputs['password'] = Hash::make($inputs['password']); $user = $this->userRepo->create($inputs); Event::fire(new UserHasCreated($user)); return Redirect::to('/'); }
[ "public", "function", "postRegister", "(", "RegisterRequest", "$", "request", ")", "{", "$", "inputs", "=", "$", "request", "->", "except", "(", "'_token'", ")", ";", "$", "inputs", "[", "'password'", "]", "=", "Hash", "::", "make", "(", "$", "inputs", "[", "'password'", "]", ")", ";", "$", "user", "=", "$", "this", "->", "userRepo", "->", "create", "(", "$", "inputs", ")", ";", "Event", "::", "fire", "(", "new", "UserHasCreated", "(", "$", "user", ")", ")", ";", "return", "Redirect", "::", "to", "(", "'/'", ")", ";", "}" ]
create a new user in DB @return Response
[ "create", "a", "new", "user", "in", "DB" ]
783aad2bcde9d8014be34092ba0cbe38b2bbc60a
https://github.com/lembarek/auth/blob/783aad2bcde9d8014be34092ba0cbe38b2bbc60a/src/Controllers/AuthController.php#L41-L50
238,705
lembarek/auth
src/Controllers/AuthController.php
AuthController.postLogin
public function postLogin(LoginRequest $request) { $inputs = $request->except('_token','rememberme'); $rememberme = $request->get('rememberme'); $attemp = Auth::attempt($inputs, !!$rememberme); if (!$attemp) { $request->session()->flash('error', trans('auth.failed')); return Redirect::back(); } return Redirect::intended('/'); }
php
public function postLogin(LoginRequest $request) { $inputs = $request->except('_token','rememberme'); $rememberme = $request->get('rememberme'); $attemp = Auth::attempt($inputs, !!$rememberme); if (!$attemp) { $request->session()->flash('error', trans('auth.failed')); return Redirect::back(); } return Redirect::intended('/'); }
[ "public", "function", "postLogin", "(", "LoginRequest", "$", "request", ")", "{", "$", "inputs", "=", "$", "request", "->", "except", "(", "'_token'", ",", "'rememberme'", ")", ";", "$", "rememberme", "=", "$", "request", "->", "get", "(", "'rememberme'", ")", ";", "$", "attemp", "=", "Auth", "::", "attempt", "(", "$", "inputs", ",", "!", "!", "$", "rememberme", ")", ";", "if", "(", "!", "$", "attemp", ")", "{", "$", "request", "->", "session", "(", ")", "->", "flash", "(", "'error'", ",", "trans", "(", "'auth.failed'", ")", ")", ";", "return", "Redirect", "::", "back", "(", ")", ";", "}", "return", "Redirect", "::", "intended", "(", "'/'", ")", ";", "}" ]
try to login the user @return Response
[ "try", "to", "login", "the", "user" ]
783aad2bcde9d8014be34092ba0cbe38b2bbc60a
https://github.com/lembarek/auth/blob/783aad2bcde9d8014be34092ba0cbe38b2bbc60a/src/Controllers/AuthController.php#L69-L84
238,706
zepi/turbo-base
Zepi/Web/General/src/Manager/TemplatesManager.php
TemplatesManager.loadTemplates
protected function loadTemplates() { $templates = $this->templatesObjectBackend->loadObject(); if (!is_array($templates)) { $templates = array(); } $this->templates = $templates; }
php
protected function loadTemplates() { $templates = $this->templatesObjectBackend->loadObject(); if (!is_array($templates)) { $templates = array(); } $this->templates = $templates; }
[ "protected", "function", "loadTemplates", "(", ")", "{", "$", "templates", "=", "$", "this", "->", "templatesObjectBackend", "->", "loadObject", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "templates", ")", ")", "{", "$", "templates", "=", "array", "(", ")", ";", "}", "$", "this", "->", "templates", "=", "$", "templates", ";", "}" ]
Loads the templates from the object backend @access public
[ "Loads", "the", "templates", "from", "the", "object", "backend" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L106-L114
238,707
zepi/turbo-base
Zepi/Web/General/src/Manager/TemplatesManager.php
TemplatesManager.addTemplate
public function addTemplate($key, $file, $priority = 10) { // If the file does not exists we can't add the file // to the templates... if (!file_exists($file) || !is_readable($file)) { return false; } // Create the arrays, if they are not existing if (!isset($this->templates[$key]) || !is_array($this->templates[$key])) { $this->templates[$key] = array(); } $this->templates[$key][$priority] = $file; ksort($this->templates[$key]); $this->saveTemplates(); return true; }
php
public function addTemplate($key, $file, $priority = 10) { // If the file does not exists we can't add the file // to the templates... if (!file_exists($file) || !is_readable($file)) { return false; } // Create the arrays, if they are not existing if (!isset($this->templates[$key]) || !is_array($this->templates[$key])) { $this->templates[$key] = array(); } $this->templates[$key][$priority] = $file; ksort($this->templates[$key]); $this->saveTemplates(); return true; }
[ "public", "function", "addTemplate", "(", "$", "key", ",", "$", "file", ",", "$", "priority", "=", "10", ")", "{", "// If the file does not exists we can't add the file", "// to the templates...", "if", "(", "!", "file_exists", "(", "$", "file", ")", "||", "!", "is_readable", "(", "$", "file", ")", ")", "{", "return", "false", ";", "}", "// Create the arrays, if they are not existing", "if", "(", "!", "isset", "(", "$", "this", "->", "templates", "[", "$", "key", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "templates", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "templates", "[", "$", "key", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "templates", "[", "$", "key", "]", "[", "$", "priority", "]", "=", "$", "file", ";", "ksort", "(", "$", "this", "->", "templates", "[", "$", "key", "]", ")", ";", "$", "this", "->", "saveTemplates", "(", ")", ";", "return", "true", ";", "}" ]
Adds a new template file to the given key with the given priority. @access public @param string $key @param string $file @param integer $priority @return boolean
[ "Adds", "a", "new", "template", "file", "to", "the", "given", "key", "with", "the", "given", "priority", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L135-L155
238,708
zepi/turbo-base
Zepi/Web/General/src/Manager/TemplatesManager.php
TemplatesManager.removeTemplate
public function removeTemplate($key, $file, $priority = 10) { // If we can't find the template file we do not have to remove anything. if (!isset($this->templates[$key][$priority])) { return false; } // Remove the template file. unset($this->templates[$key][$priority]); }
php
public function removeTemplate($key, $file, $priority = 10) { // If we can't find the template file we do not have to remove anything. if (!isset($this->templates[$key][$priority])) { return false; } // Remove the template file. unset($this->templates[$key][$priority]); }
[ "public", "function", "removeTemplate", "(", "$", "key", ",", "$", "file", ",", "$", "priority", "=", "10", ")", "{", "// If we can't find the template file we do not have to remove anything.", "if", "(", "!", "isset", "(", "$", "this", "->", "templates", "[", "$", "key", "]", "[", "$", "priority", "]", ")", ")", "{", "return", "false", ";", "}", "// Remove the template file.", "unset", "(", "$", "this", "->", "templates", "[", "$", "key", "]", "[", "$", "priority", "]", ")", ";", "}" ]
Removes the template file for the given key and priority. @access public @param string $key @param string $file @param integer $priority
[ "Removes", "the", "template", "file", "for", "the", "given", "key", "and", "priority", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L165-L174
238,709
zepi/turbo-base
Zepi/Web/General/src/Manager/TemplatesManager.php
TemplatesManager.addRenderer
public function addRenderer(RendererAbstract $renderer) { $extension = $renderer->getExtension(); if (isset($this->renderer[$extension])) { return false; } $this->renderer[$extension] = $renderer; return true; }
php
public function addRenderer(RendererAbstract $renderer) { $extension = $renderer->getExtension(); if (isset($this->renderer[$extension])) { return false; } $this->renderer[$extension] = $renderer; return true; }
[ "public", "function", "addRenderer", "(", "RendererAbstract", "$", "renderer", ")", "{", "$", "extension", "=", "$", "renderer", "->", "getExtension", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "renderer", "[", "$", "extension", "]", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "renderer", "[", "$", "extension", "]", "=", "$", "renderer", ";", "return", "true", ";", "}" ]
Add a renderer. @access public @param \Zepi\Web\General\Template\RendererAbstract $renderer @return boolean
[ "Add", "a", "renderer", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L183-L193
238,710
zepi/turbo-base
Zepi/Web/General/src/Manager/TemplatesManager.php
TemplatesManager.renderTemplate
public function renderTemplate($key, $additionalData = array()) { if (!isset($this->templates[$key])) { return ''; } $output = ''; // Render the template files foreach ($this->templates[$key] as $priority => $templateFile) { $output .= $this->searchRendererAndRenderTemplate($templateFile, $additionalData); } return $output; }
php
public function renderTemplate($key, $additionalData = array()) { if (!isset($this->templates[$key])) { return ''; } $output = ''; // Render the template files foreach ($this->templates[$key] as $priority => $templateFile) { $output .= $this->searchRendererAndRenderTemplate($templateFile, $additionalData); } return $output; }
[ "public", "function", "renderTemplate", "(", "$", "key", ",", "$", "additionalData", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "templates", "[", "$", "key", "]", ")", ")", "{", "return", "''", ";", "}", "$", "output", "=", "''", ";", "// Render the template files", "foreach", "(", "$", "this", "->", "templates", "[", "$", "key", "]", "as", "$", "priority", "=>", "$", "templateFile", ")", "{", "$", "output", ".=", "$", "this", "->", "searchRendererAndRenderTemplate", "(", "$", "templateFile", ",", "$", "additionalData", ")", ";", "}", "return", "$", "output", ";", "}" ]
Renders all template files for the given template key. @access public @param string $key @param array $additionalData @return string
[ "Renders", "all", "template", "files", "for", "the", "given", "template", "key", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L203-L217
238,711
zepi/turbo-base
Zepi/Web/General/src/Manager/TemplatesManager.php
TemplatesManager.searchRendererAndRenderTemplate
protected function searchRendererAndRenderTemplate($templateFile, $additionalData = array()) { // Get the file information for the template file $fileInfo = pathinfo($templateFile); $extension = $fileInfo['extension']; // If we haven't a renderer for this extension we return an // empty string to prevent everything from failing. if (!isset($this->renderer[$extension])) { return ''; } // Take the renderer... $renderer = $this->renderer[$extension]; // ...and render the template file. return $renderer->renderTemplateFile( $templateFile, $this->framework, $this->framework->getRequest(), $this->framework->getResponse(), $additionalData ); }
php
protected function searchRendererAndRenderTemplate($templateFile, $additionalData = array()) { // Get the file information for the template file $fileInfo = pathinfo($templateFile); $extension = $fileInfo['extension']; // If we haven't a renderer for this extension we return an // empty string to prevent everything from failing. if (!isset($this->renderer[$extension])) { return ''; } // Take the renderer... $renderer = $this->renderer[$extension]; // ...and render the template file. return $renderer->renderTemplateFile( $templateFile, $this->framework, $this->framework->getRequest(), $this->framework->getResponse(), $additionalData ); }
[ "protected", "function", "searchRendererAndRenderTemplate", "(", "$", "templateFile", ",", "$", "additionalData", "=", "array", "(", ")", ")", "{", "// Get the file information for the template file", "$", "fileInfo", "=", "pathinfo", "(", "$", "templateFile", ")", ";", "$", "extension", "=", "$", "fileInfo", "[", "'extension'", "]", ";", "// If we haven't a renderer for this extension we return an", "// empty string to prevent everything from failing.", "if", "(", "!", "isset", "(", "$", "this", "->", "renderer", "[", "$", "extension", "]", ")", ")", "{", "return", "''", ";", "}", "// Take the renderer...", "$", "renderer", "=", "$", "this", "->", "renderer", "[", "$", "extension", "]", ";", "// ...and render the template file.", "return", "$", "renderer", "->", "renderTemplateFile", "(", "$", "templateFile", ",", "$", "this", "->", "framework", ",", "$", "this", "->", "framework", "->", "getRequest", "(", ")", ",", "$", "this", "->", "framework", "->", "getResponse", "(", ")", ",", "$", "additionalData", ")", ";", "}" ]
Searches a renderer for the given template file and renders the file. @access protected @param string $templateFile @param array $additionalData @return string
[ "Searches", "a", "renderer", "for", "the", "given", "template", "file", "and", "renders", "the", "file", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L228-L251
238,712
10usb/css-lib
autoloader.php
Autoloader.load
public static function load($name){ if(substr($name, 0, 7)!='csslib\\') return false; $filename = __DIR__.'/src/'.implode('/', array_slice(explode('\\', $name), 1)).'.php'; if(!file_exists($filename)) throw new \Exception('File "'.$filename.'" not found'); require_once $filename; if(class_exists($name) || interface_exists($name)) return true; throw new \Exception('Class or Interface "'.$name.'" not exists'); }
php
public static function load($name){ if(substr($name, 0, 7)!='csslib\\') return false; $filename = __DIR__.'/src/'.implode('/', array_slice(explode('\\', $name), 1)).'.php'; if(!file_exists($filename)) throw new \Exception('File "'.$filename.'" not found'); require_once $filename; if(class_exists($name) || interface_exists($name)) return true; throw new \Exception('Class or Interface "'.$name.'" not exists'); }
[ "public", "static", "function", "load", "(", "$", "name", ")", "{", "if", "(", "substr", "(", "$", "name", ",", "0", ",", "7", ")", "!=", "'csslib\\\\'", ")", "return", "false", ";", "$", "filename", "=", "__DIR__", ".", "'/src/'", ".", "implode", "(", "'/'", ",", "array_slice", "(", "explode", "(", "'\\\\'", ",", "$", "name", ")", ",", "1", ")", ")", ".", "'.php'", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "throw", "new", "\\", "Exception", "(", "'File \"'", ".", "$", "filename", ".", "'\" not found'", ")", ";", "require_once", "$", "filename", ";", "if", "(", "class_exists", "(", "$", "name", ")", "||", "interface_exists", "(", "$", "name", ")", ")", "return", "true", ";", "throw", "new", "\\", "Exception", "(", "'Class or Interface \"'", ".", "$", "name", ".", "'\" not exists'", ")", ";", "}" ]
Load a class or interface by its name, ain't that cool? @param string $name Class name @throws \Exception @return boolean
[ "Load", "a", "class", "or", "interface", "by", "its", "name", "ain", "t", "that", "cool?" ]
6370b1404bae3eecb44c214ed4eaaf33113858dd
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/autoloader.php#L22-L35
238,713
prototypemvc/prototypemvc
Core/Model.php
Model.load
public static function load($model = false) { $path = DOC_ROOT . Config::get('paths', 'modules'); if ($model && File::isFile($path . $model . '.php')) { $array = explode('/', $model); $modelName = end($array); require $path . $model . '.php'; return new $modelName(); } return false; }
php
public static function load($model = false) { $path = DOC_ROOT . Config::get('paths', 'modules'); if ($model && File::isFile($path . $model . '.php')) { $array = explode('/', $model); $modelName = end($array); require $path . $model . '.php'; return new $modelName(); } return false; }
[ "public", "static", "function", "load", "(", "$", "model", "=", "false", ")", "{", "$", "path", "=", "DOC_ROOT", ".", "Config", "::", "get", "(", "'paths'", ",", "'modules'", ")", ";", "if", "(", "$", "model", "&&", "File", "::", "isFile", "(", "$", "path", ".", "$", "model", ".", "'.php'", ")", ")", "{", "$", "array", "=", "explode", "(", "'/'", ",", "$", "model", ")", ";", "$", "modelName", "=", "end", "(", "$", "array", ")", ";", "require", "$", "path", ".", "$", "model", ".", "'.php'", ";", "return", "new", "$", "modelName", "(", ")", ";", "}", "return", "false", ";", "}" ]
Load a given model. @param string path to file @example load('blog/model/blog') @example load('blog/model/blog.php') @return object
[ "Load", "a", "given", "model", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Model.php#L17-L32
238,714
Silvestra/Silvestra
src/Silvestra/Component/Media/Templating/ImageTemplatingHelper.php
ImageTemplatingHelper.getImagePath
private function getImagePath($path) { if ($path && file_exists($this->filesystem->getRootDir() . $path)) { return $path; } return $this->noImagePath; }
php
private function getImagePath($path) { if ($path && file_exists($this->filesystem->getRootDir() . $path)) { return $path; } return $this->noImagePath; }
[ "private", "function", "getImagePath", "(", "$", "path", ")", "{", "if", "(", "$", "path", "&&", "file_exists", "(", "$", "this", "->", "filesystem", "->", "getRootDir", "(", ")", ".", "$", "path", ")", ")", "{", "return", "$", "path", ";", "}", "return", "$", "this", "->", "noImagePath", ";", "}" ]
Get image path. @param string $path @return string
[ "Get", "image", "path", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Templating/ImageTemplatingHelper.php#L89-L96
238,715
xpl-php/Common
src/Storage/Registry.php
Registry.set
public function set($key, $object) { if (! is_object($object)) { throw new \InvalidArgumentException("Registry only accepts objects, given: ".gettype($object)); } $this->_data[$key] = $object; return $this; }
php
public function set($key, $object) { if (! is_object($object)) { throw new \InvalidArgumentException("Registry only accepts objects, given: ".gettype($object)); } $this->_data[$key] = $object; return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Registry only accepts objects, given: \"", ".", "gettype", "(", "$", "object", ")", ")", ";", "}", "$", "this", "->", "_data", "[", "$", "key", "]", "=", "$", "object", ";", "return", "$", "this", ";", "}" ]
Sets an object. @param string $key Item key. @param object $object Object instance. @return $this
[ "Sets", "an", "object", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L28-L37
238,716
xpl-php/Common
src/Storage/Registry.php
Registry.add
public function add(array $items) { foreach($items as $name => $object) { $this->set($name, $object); } return $this; }
php
public function add(array $items) { foreach($items as $name => $object) { $this->set($name, $object); } return $this; }
[ "public", "function", "add", "(", "array", "$", "items", ")", "{", "foreach", "(", "$", "items", "as", "$", "name", "=>", "$", "object", ")", "{", "$", "this", "->", "set", "(", "$", "name", ",", "$", "object", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds an array of items. @param array $items @return $this
[ "Adds", "an", "array", "of", "items", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L46-L53
238,717
xpl-php/Common
src/Storage/Registry.php
Registry.get
public function get($key) { if (isset($this->_data[$key])) { return $this->_data[$key]; } if (isset($this->registered[$key])) { return $this->_data[$key] = call_user_func($this->registered[$key], $this); } return null; }
php
public function get($key) { if (isset($this->_data[$key])) { return $this->_data[$key]; } if (isset($this->registered[$key])) { return $this->_data[$key] = call_user_func($this->registered[$key], $this); } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "_data", "[", "$", "key", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "registered", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "_data", "[", "$", "key", "]", "=", "call_user_func", "(", "$", "this", "->", "registered", "[", "$", "key", "]", ",", "$", "this", ")", ";", "}", "return", "null", ";", "}" ]
Returns a registered value. @param string $key Item key. @return mixed
[ "Returns", "a", "registered", "value", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L62-L73
238,718
xpl-php/Common
src/Storage/Registry.php
Registry.exists
public function exists($key) { return isset($this->_data[$key]) || isset($this->registered[$key]); }
php
public function exists($key) { return isset($this->_data[$key]) || isset($this->registered[$key]); }
[ "public", "function", "exists", "(", "$", "key", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", ")", "||", "isset", "(", "$", "this", "->", "registered", "[", "$", "key", "]", ")", ";", "}" ]
Checks whether an key can be resolved to an object or registered closure. @param string $key Item key. @return boolean True if the item can be resolved to an object.
[ "Checks", "whether", "an", "key", "can", "be", "resolved", "to", "an", "object", "or", "registered", "closure", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L124-L126
238,719
lfalmeida/lbase
src/Controllers/ApiBaseController.php
ApiBaseController.paginate
protected function paginate(Request $request) { $fields = $request->input('fields') ? explode(',', $request->input('fields')) : ['*']; $pageSize = $request->input('pageSize') ? (int)$request->input('pageSize') : null; $sort = $request->input('sort') ? $request->input('sort') : null; $order = $request->input('order') ? $request->input('order') : 'asc'; $pagination = $this->repository->paginate($pageSize, $fields, $sort, $order); $pagination->appends($request->except(['page'])); return Response::apiResponse([ 'data' => $pagination ]); }
php
protected function paginate(Request $request) { $fields = $request->input('fields') ? explode(',', $request->input('fields')) : ['*']; $pageSize = $request->input('pageSize') ? (int)$request->input('pageSize') : null; $sort = $request->input('sort') ? $request->input('sort') : null; $order = $request->input('order') ? $request->input('order') : 'asc'; $pagination = $this->repository->paginate($pageSize, $fields, $sort, $order); $pagination->appends($request->except(['page'])); return Response::apiResponse([ 'data' => $pagination ]); }
[ "protected", "function", "paginate", "(", "Request", "$", "request", ")", "{", "$", "fields", "=", "$", "request", "->", "input", "(", "'fields'", ")", "?", "explode", "(", "','", ",", "$", "request", "->", "input", "(", "'fields'", ")", ")", ":", "[", "'*'", "]", ";", "$", "pageSize", "=", "$", "request", "->", "input", "(", "'pageSize'", ")", "?", "(", "int", ")", "$", "request", "->", "input", "(", "'pageSize'", ")", ":", "null", ";", "$", "sort", "=", "$", "request", "->", "input", "(", "'sort'", ")", "?", "$", "request", "->", "input", "(", "'sort'", ")", ":", "null", ";", "$", "order", "=", "$", "request", "->", "input", "(", "'order'", ")", "?", "$", "request", "->", "input", "(", "'order'", ")", ":", "'asc'", ";", "$", "pagination", "=", "$", "this", "->", "repository", "->", "paginate", "(", "$", "pageSize", ",", "$", "fields", ",", "$", "sort", ",", "$", "order", ")", ";", "$", "pagination", "->", "appends", "(", "$", "request", "->", "except", "(", "[", "'page'", "]", ")", ")", ";", "return", "Response", "::", "apiResponse", "(", "[", "'data'", "=>", "$", "pagination", "]", ")", ";", "}" ]
Retorna os resultados paginados. Este método aceita os seguintes parâmetros fornecidos via Request: **fields, pageSize, sort, order**. - **fields**: String com as colunas desejadas no retorno, separadas por vírgula. - **pageSise**: Inteiro indicando a quantidade de resultados por página. - **sort**: Coluna para ordenação - **order**: Direção da ordenação @internal Este método não é exposto via url, sendo acessado via método index @param Request $request
[ "Retorna", "os", "resultados", "paginados", "." ]
d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37
https://github.com/lfalmeida/lbase/blob/d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37/src/Controllers/ApiBaseController.php#L151-L165
238,720
lfalmeida/lbase
src/Controllers/ApiBaseController.php
ApiBaseController.update
public function update(Request $request, $id) { $response = $this->repository->update($id, $request->all()); return Response::apiResponse([ 'data' => $response ]); }
php
public function update(Request $request, $id) { $response = $this->repository->update($id, $request->all()); return Response::apiResponse([ 'data' => $response ]); }
[ "public", "function", "update", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "response", "=", "$", "this", "->", "repository", "->", "update", "(", "$", "id", ",", "$", "request", "->", "all", "(", ")", ")", ";", "return", "Response", "::", "apiResponse", "(", "[", "'data'", "=>", "$", "response", "]", ")", ";", "}" ]
Atualiza os dados de uma entidade com base nos dados obtidos no Request. @param \Illuminate\Http\Request $request @param int $id Id da entidade a ser atualizada @return \Illuminate\Http\Response
[ "Atualiza", "os", "dados", "de", "uma", "entidade", "com", "base", "nos", "dados", "obtidos", "no", "Request", "." ]
d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37
https://github.com/lfalmeida/lbase/blob/d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37/src/Controllers/ApiBaseController.php#L223-L230
238,721
prestaconcept/PrestaComposerPublicBundle
Command/BlendCommand.php
BlendCommand.getBundlesToBlend
private function getBundlesToBlend() { $toBlend = array(); foreach ($this->config['blend'] as $key => $params) { $vendor = isset($params['vendor']) ? $params['vendor'] : null; $name = isset($params['name']) ? $params['name'] : null; $path = isset($params['path']) ? $params['path'] : null; if (!$vendor && !$name) { list($vendor, $name) = explode('/', $key, 2); } if (!isset($toBlend[$vendor][$name])) { $toBlend[$vendor][$name] = $path; } } return $toBlend; }
php
private function getBundlesToBlend() { $toBlend = array(); foreach ($this->config['blend'] as $key => $params) { $vendor = isset($params['vendor']) ? $params['vendor'] : null; $name = isset($params['name']) ? $params['name'] : null; $path = isset($params['path']) ? $params['path'] : null; if (!$vendor && !$name) { list($vendor, $name) = explode('/', $key, 2); } if (!isset($toBlend[$vendor][$name])) { $toBlend[$vendor][$name] = $path; } } return $toBlend; }
[ "private", "function", "getBundlesToBlend", "(", ")", "{", "$", "toBlend", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "config", "[", "'blend'", "]", "as", "$", "key", "=>", "$", "params", ")", "{", "$", "vendor", "=", "isset", "(", "$", "params", "[", "'vendor'", "]", ")", "?", "$", "params", "[", "'vendor'", "]", ":", "null", ";", "$", "name", "=", "isset", "(", "$", "params", "[", "'name'", "]", ")", "?", "$", "params", "[", "'name'", "]", ":", "null", ";", "$", "path", "=", "isset", "(", "$", "params", "[", "'path'", "]", ")", "?", "$", "params", "[", "'path'", "]", ":", "null", ";", "if", "(", "!", "$", "vendor", "&&", "!", "$", "name", ")", "{", "list", "(", "$", "vendor", ",", "$", "name", ")", "=", "explode", "(", "'/'", ",", "$", "key", ",", "2", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "toBlend", "[", "$", "vendor", "]", "[", "$", "name", "]", ")", ")", "{", "$", "toBlend", "[", "$", "vendor", "]", "[", "$", "name", "]", "=", "$", "path", ";", "}", "}", "return", "$", "toBlend", ";", "}" ]
Extract bundles to blend from config @return array
[ "Extract", "bundles", "to", "blend", "from", "config" ]
2d7da2998141c4777301910f912a19d4cc5e8a74
https://github.com/prestaconcept/PrestaComposerPublicBundle/blob/2d7da2998141c4777301910f912a19d4cc5e8a74/Command/BlendCommand.php#L71-L90
238,722
prestaconcept/PrestaComposerPublicBundle
Command/BlendCommand.php
BlendCommand.blend
private function blend($toBlend, OutputInterface $output) { $fs = new Filesystem(); $vendorDir = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor'; foreach ($toBlend as $vendor => $names) { foreach ($names as $name => $path) { $originPath = realpath($vendorDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR)); $targetDir = realpath($this->bundlePath) . DIRECTORY_SEPARATOR . $vendor; $targetPath = $targetDir . DIRECTORY_SEPARATOR . $name; if (!$originPath) { throw new \InvalidArgumentException(sprintf('The origin path for "%s" does not exist : "%s"', "$vendor/$name", $originPath)); } if (!$fs->exists($targetDir)) { $fs->mkdir($targetDir); } // Switch for symlink to hard copy or from hard copy to symlink if (is_link($targetPath) && (!isset($this->config['symlink']) || !$this->config['symlink']) || is_dir($targetPath) && isset($this->config['symlink']) && $this->config['symlink'] ) { $fs->remove($targetPath); } if (isset($this->config['symlink']) && $this->config['symlink']) { $fs->symlink($originPath, $targetPath); } else { $fs->mirror($originPath, $targetPath, null, array('delete' => true, 'override' => true)); } $output->writeln(sprintf('The library <info>%s/%s</info> has been added', $vendor, $name)); } } }
php
private function blend($toBlend, OutputInterface $output) { $fs = new Filesystem(); $vendorDir = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor'; foreach ($toBlend as $vendor => $names) { foreach ($names as $name => $path) { $originPath = realpath($vendorDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR)); $targetDir = realpath($this->bundlePath) . DIRECTORY_SEPARATOR . $vendor; $targetPath = $targetDir . DIRECTORY_SEPARATOR . $name; if (!$originPath) { throw new \InvalidArgumentException(sprintf('The origin path for "%s" does not exist : "%s"', "$vendor/$name", $originPath)); } if (!$fs->exists($targetDir)) { $fs->mkdir($targetDir); } // Switch for symlink to hard copy or from hard copy to symlink if (is_link($targetPath) && (!isset($this->config['symlink']) || !$this->config['symlink']) || is_dir($targetPath) && isset($this->config['symlink']) && $this->config['symlink'] ) { $fs->remove($targetPath); } if (isset($this->config['symlink']) && $this->config['symlink']) { $fs->symlink($originPath, $targetPath); } else { $fs->mirror($originPath, $targetPath, null, array('delete' => true, 'override' => true)); } $output->writeln(sprintf('The library <info>%s/%s</info> has been added', $vendor, $name)); } } }
[ "private", "function", "blend", "(", "$", "toBlend", ",", "OutputInterface", "$", "output", ")", "{", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "$", "vendorDir", "=", "$", "this", "->", "getContainer", "(", ")", "->", "getParameter", "(", "'kernel.root_dir'", ")", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'vendor'", ";", "foreach", "(", "$", "toBlend", "as", "$", "vendor", "=>", "$", "names", ")", "{", "foreach", "(", "$", "names", "as", "$", "name", "=>", "$", "path", ")", "{", "$", "originPath", "=", "realpath", "(", "$", "vendorDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "vendor", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ".", "DIRECTORY_SEPARATOR", ".", "ltrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ")", ";", "$", "targetDir", "=", "realpath", "(", "$", "this", "->", "bundlePath", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "vendor", ";", "$", "targetPath", "=", "$", "targetDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "if", "(", "!", "$", "originPath", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The origin path for \"%s\" does not exist : \"%s\"'", ",", "\"$vendor/$name\"", ",", "$", "originPath", ")", ")", ";", "}", "if", "(", "!", "$", "fs", "->", "exists", "(", "$", "targetDir", ")", ")", "{", "$", "fs", "->", "mkdir", "(", "$", "targetDir", ")", ";", "}", "// Switch for symlink to hard copy or from hard copy to symlink", "if", "(", "is_link", "(", "$", "targetPath", ")", "&&", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'symlink'", "]", ")", "||", "!", "$", "this", "->", "config", "[", "'symlink'", "]", ")", "||", "is_dir", "(", "$", "targetPath", ")", "&&", "isset", "(", "$", "this", "->", "config", "[", "'symlink'", "]", ")", "&&", "$", "this", "->", "config", "[", "'symlink'", "]", ")", "{", "$", "fs", "->", "remove", "(", "$", "targetPath", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'symlink'", "]", ")", "&&", "$", "this", "->", "config", "[", "'symlink'", "]", ")", "{", "$", "fs", "->", "symlink", "(", "$", "originPath", ",", "$", "targetPath", ")", ";", "}", "else", "{", "$", "fs", "->", "mirror", "(", "$", "originPath", ",", "$", "targetPath", ",", "null", ",", "array", "(", "'delete'", "=>", "true", ",", "'override'", "=>", "true", ")", ")", ";", "}", "$", "output", "->", "writeln", "(", "sprintf", "(", "'The library <info>%s/%s</info> has been added'", ",", "$", "vendor", ",", "$", "name", ")", ")", ";", "}", "}", "}" ]
Blend bundles into prestaComposer vendor directory @param $toBlend @param OutputInterface $output @throws \InvalidArgumentException
[ "Blend", "bundles", "into", "prestaComposer", "vendor", "directory" ]
2d7da2998141c4777301910f912a19d4cc5e8a74
https://github.com/prestaconcept/PrestaComposerPublicBundle/blob/2d7da2998141c4777301910f912a19d4cc5e8a74/Command/BlendCommand.php#L99-L135
238,723
n0m4dz/laracasa
Zend/Gdata/Spreadsheets/ListQuery.php
Zend_Gdata_Spreadsheets_ListQuery.setSpreadsheetQuery
public function setSpreadsheetQuery($value) { if ($value != null) { $this->_params['sq'] = $value; } else { unset($this->_params['sq']); } return $this; }
php
public function setSpreadsheetQuery($value) { if ($value != null) { $this->_params['sq'] = $value; } else { unset($this->_params['sq']); } return $this; }
[ "public", "function", "setSpreadsheetQuery", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "null", ")", "{", "$", "this", "->", "_params", "[", "'sq'", "]", "=", "$", "value", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "_params", "[", "'sq'", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the spreadsheet key for this query. @param string $value @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
[ "Sets", "the", "spreadsheet", "key", "for", "this", "query", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListQuery.php#L170-L178
238,724
n0m4dz/laracasa
Zend/Gdata/Spreadsheets/ListQuery.php
Zend_Gdata_Spreadsheets_ListQuery.setReverse
public function setReverse($value) { if ($value != null) { $this->_params['reverse'] = $value; } else { unset($this->_params['reverse']); } return $this; }
php
public function setReverse($value) { if ($value != null) { $this->_params['reverse'] = $value; } else { unset($this->_params['reverse']); } return $this; }
[ "public", "function", "setReverse", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "null", ")", "{", "$", "this", "->", "_params", "[", "'reverse'", "]", "=", "$", "value", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "_params", "[", "'reverse'", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the reverse attribute for this query. @param string $value @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
[ "Sets", "the", "reverse", "attribute", "for", "this", "query", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListQuery.php#L226-L234
238,725
znframework/package-image
Thumb.php
Thumb.size
public function size(Int $width, Int $height) : Thumb { $this->sets['width'] = $width; $this->sets['height'] = $height; return $this; }
php
public function size(Int $width, Int $height) : Thumb { $this->sets['width'] = $width; $this->sets['height'] = $height; return $this; }
[ "public", "function", "size", "(", "Int", "$", "width", ",", "Int", "$", "height", ")", ":", "Thumb", "{", "$", "this", "->", "sets", "[", "'width'", "]", "=", "$", "width", ";", "$", "this", "->", "sets", "[", "'height'", "]", "=", "$", "height", ";", "return", "$", "this", ";", "}" ]
Sets image size @param int $width @param int $height @return Thumb
[ "Sets", "image", "size" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L109-L115
238,726
znframework/package-image
Thumb.php
Thumb.resize
public function resize(Int $width, Int $height) : Thumb { $this->sets['rewidth'] = $width; $this->sets['reheight'] = $height; return $this; }
php
public function resize(Int $width, Int $height) : Thumb { $this->sets['rewidth'] = $width; $this->sets['reheight'] = $height; return $this; }
[ "public", "function", "resize", "(", "Int", "$", "width", ",", "Int", "$", "height", ")", ":", "Thumb", "{", "$", "this", "->", "sets", "[", "'rewidth'", "]", "=", "$", "width", ";", "$", "this", "->", "sets", "[", "'reheight'", "]", "=", "$", "height", ";", "return", "$", "this", ";", "}" ]
Sets image resize @param int $width @param int $height @return Thumb
[ "Sets", "image", "resize" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L125-L131
238,727
znframework/package-image
Thumb.php
Thumb.prosize
public function prosize(Int $width, Int $height = 0) : Thumb { $this->sets['prowidth'] = $width; $this->sets['proheight'] = $height; return $this; }
php
public function prosize(Int $width, Int $height = 0) : Thumb { $this->sets['prowidth'] = $width; $this->sets['proheight'] = $height; return $this; }
[ "public", "function", "prosize", "(", "Int", "$", "width", ",", "Int", "$", "height", "=", "0", ")", ":", "Thumb", "{", "$", "this", "->", "sets", "[", "'prowidth'", "]", "=", "$", "width", ";", "$", "this", "->", "sets", "[", "'proheight'", "]", "=", "$", "height", ";", "return", "$", "this", ";", "}" ]
Sets image proportional size @param int $width @param int $height @return Thumb
[ "Sets", "image", "proportional", "size" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L141-L147
238,728
znframework/package-image
Thumb.php
Thumb.create
public function create(String $path = NULL) : String { if( isset($this->sets['filePath']) ) { $path = $this->sets['filePath']; } # It keeps the used filters belonging to the GD class. # [5.7.8]added $this->sets['filters'] = $this->filters; $settings = $this->sets; $this->sets = []; return $this->image->thumb($path, $settings); }
php
public function create(String $path = NULL) : String { if( isset($this->sets['filePath']) ) { $path = $this->sets['filePath']; } # It keeps the used filters belonging to the GD class. # [5.7.8]added $this->sets['filters'] = $this->filters; $settings = $this->sets; $this->sets = []; return $this->image->thumb($path, $settings); }
[ "public", "function", "create", "(", "String", "$", "path", "=", "NULL", ")", ":", "String", "{", "if", "(", "isset", "(", "$", "this", "->", "sets", "[", "'filePath'", "]", ")", ")", "{", "$", "path", "=", "$", "this", "->", "sets", "[", "'filePath'", "]", ";", "}", "# It keeps the used filters belonging to the GD class.", "# [5.7.8]added", "$", "this", "->", "sets", "[", "'filters'", "]", "=", "$", "this", "->", "filters", ";", "$", "settings", "=", "$", "this", "->", "sets", ";", "$", "this", "->", "sets", "=", "[", "]", ";", "return", "$", "this", "->", "image", "->", "thumb", "(", "$", "path", ",", "$", "settings", ")", ";", "}" ]
Create new image @param string $path = NULL @return string
[ "Create", "new", "image" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L156-L172
238,729
znframework/package-image
Thumb.php
Thumb.getProsize
public function getProsize(Int $width = 0, Int $height = 0) { if( ! isset($this->sets['filePath']) ) { return false; } return $this->image->getProsize($this->sets['filePath'], $width, $height); }
php
public function getProsize(Int $width = 0, Int $height = 0) { if( ! isset($this->sets['filePath']) ) { return false; } return $this->image->getProsize($this->sets['filePath'], $width, $height); }
[ "public", "function", "getProsize", "(", "Int", "$", "width", "=", "0", ",", "Int", "$", "height", "=", "0", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "sets", "[", "'filePath'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "image", "->", "getProsize", "(", "$", "this", "->", "sets", "[", "'filePath'", "]", ",", "$", "width", ",", "$", "height", ")", ";", "}" ]
Get proportional size @param int $width = 0 @param int $height = 0 @return object|false
[ "Get", "proportional", "size" ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L182-L190
238,730
jaeger-app/log
src/Traits/Log.php
Log.getPathToLogFile
public function getPathToLogFile($name = 'm62') { if (is_null($this->log_path)) { $this->log_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'logs') . DIRECTORY_SEPARATOR . $name . '.log'; } return $this->log_path; }
php
public function getPathToLogFile($name = 'm62') { if (is_null($this->log_path)) { $this->log_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'logs') . DIRECTORY_SEPARATOR . $name . '.log'; } return $this->log_path; }
[ "public", "function", "getPathToLogFile", "(", "$", "name", "=", "'m62'", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "log_path", ")", ")", "{", "$", "this", "->", "log_path", "=", "realpath", "(", "dirname", "(", "__FILE__", ")", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'logs'", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ".", "'.log'", ";", "}", "return", "$", "this", "->", "log_path", ";", "}" ]
Returns the path to the log file @param string $name The name of the log file to use @return \mithra62\Traits::$log_path
[ "Returns", "the", "path", "to", "the", "log", "file" ]
8b8f81d142cdce5806fc611342441f2d47f15578
https://github.com/jaeger-app/log/blob/8b8f81d142cdce5806fc611342441f2d47f15578/src/Traits/Log.php#L115-L122
238,731
jaeger-app/log
src/Traits/Log.php
Log.removeLogFile
public function removeLogFile() { if (file_exists($this->log_path)) { $this->logger = null; unlink($this->log_path); } return $this; }
php
public function removeLogFile() { if (file_exists($this->log_path)) { $this->logger = null; unlink($this->log_path); } return $this; }
[ "public", "function", "removeLogFile", "(", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "log_path", ")", ")", "{", "$", "this", "->", "logger", "=", "null", ";", "unlink", "(", "$", "this", "->", "log_path", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes the logging file @return \mithra62\Traits\Log
[ "Removes", "the", "logging", "file" ]
8b8f81d142cdce5806fc611342441f2d47f15578
https://github.com/jaeger-app/log/blob/8b8f81d142cdce5806fc611342441f2d47f15578/src/Traits/Log.php#L143-L151
238,732
elumina-elearning/event
src/Emitter.php
Emitter.ensureListener
protected function ensureListener($listener) { if ($listener instanceof ListenerInterface) { return $listener; } if (is_callable($listener)) { return CallbackListener::fromCallable($listener); } throw new InvalidArgumentException('Listeners should be be ListenerInterface, Closure or callable. Received type: '.gettype($listener)); }
php
protected function ensureListener($listener) { if ($listener instanceof ListenerInterface) { return $listener; } if (is_callable($listener)) { return CallbackListener::fromCallable($listener); } throw new InvalidArgumentException('Listeners should be be ListenerInterface, Closure or callable. Received type: '.gettype($listener)); }
[ "protected", "function", "ensureListener", "(", "$", "listener", ")", "{", "if", "(", "$", "listener", "instanceof", "ListenerInterface", ")", "{", "return", "$", "listener", ";", "}", "if", "(", "is_callable", "(", "$", "listener", ")", ")", "{", "return", "CallbackListener", "::", "fromCallable", "(", "$", "listener", ")", ";", "}", "throw", "new", "InvalidArgumentException", "(", "'Listeners should be be ListenerInterface, Closure or callable. Received type: '", ".", "gettype", "(", "$", "listener", ")", ")", ";", "}" ]
Ensure the input is a listener. @param ListenerInterface|callable $listener @throws InvalidArgumentException @return ListenerInterface
[ "Ensure", "the", "input", "is", "a", "listener", "." ]
e311372ee4b62388aee3629fb4b3ea530b42d17f
https://github.com/elumina-elearning/event/blob/e311372ee4b62388aee3629fb4b3ea530b42d17f/src/Emitter.php#L106-L117
238,733
Flowpack/Flowpack.SingleSignOn.Server
Classes/Flowpack/SingleSignOn/Server/Controller/SessionController.php
SessionController.touchAction
public function touchAction($sessionId) { if ($this->request->getHttpRequest()->getMethod() !== 'POST') { $this->response->setStatus(405); $this->response->setHeader('Allow', 'POST'); return; } $session = $this->sessionManager->getSession($sessionId); if ($session !== NULL) { $session->touch(); if ($this->ssoLogger !== NULL) { $this->ssoLogger->log('Touched session "' . $sessionId . '"' , LOG_DEBUG); } $this->view->assign('value', array('success' => TRUE)); } else { $this->response->setStatus(404); $this->view->assign('value', array('error' => 'SessionNotFound')); } }
php
public function touchAction($sessionId) { if ($this->request->getHttpRequest()->getMethod() !== 'POST') { $this->response->setStatus(405); $this->response->setHeader('Allow', 'POST'); return; } $session = $this->sessionManager->getSession($sessionId); if ($session !== NULL) { $session->touch(); if ($this->ssoLogger !== NULL) { $this->ssoLogger->log('Touched session "' . $sessionId . '"' , LOG_DEBUG); } $this->view->assign('value', array('success' => TRUE)); } else { $this->response->setStatus(404); $this->view->assign('value', array('error' => 'SessionNotFound')); } }
[ "public", "function", "touchAction", "(", "$", "sessionId", ")", "{", "if", "(", "$", "this", "->", "request", "->", "getHttpRequest", "(", ")", "->", "getMethod", "(", ")", "!==", "'POST'", ")", "{", "$", "this", "->", "response", "->", "setStatus", "(", "405", ")", ";", "$", "this", "->", "response", "->", "setHeader", "(", "'Allow'", ",", "'POST'", ")", ";", "return", ";", "}", "$", "session", "=", "$", "this", "->", "sessionManager", "->", "getSession", "(", "$", "sessionId", ")", ";", "if", "(", "$", "session", "!==", "NULL", ")", "{", "$", "session", "->", "touch", "(", ")", ";", "if", "(", "$", "this", "->", "ssoLogger", "!==", "NULL", ")", "{", "$", "this", "->", "ssoLogger", "->", "log", "(", "'Touched session \"'", ".", "$", "sessionId", ".", "'\"'", ",", "LOG_DEBUG", ")", ";", "}", "$", "this", "->", "view", "->", "assign", "(", "'value'", ",", "array", "(", "'success'", "=>", "TRUE", ")", ")", ";", "}", "else", "{", "$", "this", "->", "response", "->", "setStatus", "(", "404", ")", ";", "$", "this", "->", "view", "->", "assign", "(", "'value'", ",", "array", "(", "'error'", "=>", "'SessionNotFound'", ")", ")", ";", "}", "}" ]
Touch a session to refresh the last active timestamp POST /sso/session/xyz-123/touch @param string $sessionId The session id
[ "Touch", "a", "session", "to", "refresh", "the", "last", "active", "timestamp" ]
b1fa014f31d0d101a79cb95d5585b9973f35347d
https://github.com/Flowpack/Flowpack.SingleSignOn.Server/blob/b1fa014f31d0d101a79cb95d5585b9973f35347d/Classes/Flowpack/SingleSignOn/Server/Controller/SessionController.php#L73-L94
238,734
Thuata/FrameworkBundle
Repository/RepositoryFactory.php
RepositoryFactory.getRepositoryForEntity
public function getRepositoryForEntity(string $entityName, string $connectionName = null): AbstractRepository { /** @var AbstractRepository $repository */ $repository = $this->loadFactorableInstance($entityName); if (is_string($connectionName)) { $entityManager = $this->getContainer()->get('doctrine')->getManager($connectionName); $repository->setEntityManager($entityManager); } $this->onFactorableLoaded($repository); return $repository; }
php
public function getRepositoryForEntity(string $entityName, string $connectionName = null): AbstractRepository { /** @var AbstractRepository $repository */ $repository = $this->loadFactorableInstance($entityName); if (is_string($connectionName)) { $entityManager = $this->getContainer()->get('doctrine')->getManager($connectionName); $repository->setEntityManager($entityManager); } $this->onFactorableLoaded($repository); return $repository; }
[ "public", "function", "getRepositoryForEntity", "(", "string", "$", "entityName", ",", "string", "$", "connectionName", "=", "null", ")", ":", "AbstractRepository", "{", "/** @var AbstractRepository $repository */", "$", "repository", "=", "$", "this", "->", "loadFactorableInstance", "(", "$", "entityName", ")", ";", "if", "(", "is_string", "(", "$", "connectionName", ")", ")", "{", "$", "entityManager", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", "$", "connectionName", ")", ";", "$", "repository", "->", "setEntityManager", "(", "$", "entityManager", ")", ";", "}", "$", "this", "->", "onFactorableLoaded", "(", "$", "repository", ")", ";", "return", "$", "repository", ";", "}" ]
Gets a repository for an entity @param string $entityName @param string $connectionName @return AbstractRepository
[ "Gets", "a", "repository", "for", "an", "entity" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/RepositoryFactory.php#L130-L143
238,735
Flowpack/Flowpack.SingleSignOn.Client
Classes/Flowpack/SingleSignOn/Client/Domain/Factory/SsoClientFactory.php
SsoClientFactory.create
public function create() { $ssoClient = new \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient(); if ((string)$this->clientServiceBaseUri === '') { throw new Exception('Missing Flowpack.SingleSignOn.Client.client.serviceBaseUri setting', 1351075078); } $ssoClient->setServiceBaseUri($this->clientServiceBaseUri); if ((string)$this->clientPublicKeyFingerprint === '') { throw new Exception('Missing Flowpack.SingleSignOn.Client.client.publicKeyFingerprint setting', 1351075159); } $ssoClient->setPublicKeyFingerprint($this->clientPublicKeyFingerprint); return $ssoClient; }
php
public function create() { $ssoClient = new \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient(); if ((string)$this->clientServiceBaseUri === '') { throw new Exception('Missing Flowpack.SingleSignOn.Client.client.serviceBaseUri setting', 1351075078); } $ssoClient->setServiceBaseUri($this->clientServiceBaseUri); if ((string)$this->clientPublicKeyFingerprint === '') { throw new Exception('Missing Flowpack.SingleSignOn.Client.client.publicKeyFingerprint setting', 1351075159); } $ssoClient->setPublicKeyFingerprint($this->clientPublicKeyFingerprint); return $ssoClient; }
[ "public", "function", "create", "(", ")", "{", "$", "ssoClient", "=", "new", "\\", "Flowpack", "\\", "SingleSignOn", "\\", "Client", "\\", "Domain", "\\", "Model", "\\", "SsoClient", "(", ")", ";", "if", "(", "(", "string", ")", "$", "this", "->", "clientServiceBaseUri", "===", "''", ")", "{", "throw", "new", "Exception", "(", "'Missing Flowpack.SingleSignOn.Client.client.serviceBaseUri setting'", ",", "1351075078", ")", ";", "}", "$", "ssoClient", "->", "setServiceBaseUri", "(", "$", "this", "->", "clientServiceBaseUri", ")", ";", "if", "(", "(", "string", ")", "$", "this", "->", "clientPublicKeyFingerprint", "===", "''", ")", "{", "throw", "new", "Exception", "(", "'Missing Flowpack.SingleSignOn.Client.client.publicKeyFingerprint setting'", ",", "1351075159", ")", ";", "}", "$", "ssoClient", "->", "setPublicKeyFingerprint", "(", "$", "this", "->", "clientPublicKeyFingerprint", ")", ";", "return", "$", "ssoClient", ";", "}" ]
Build a SSO client instance from settings Note: Every SSO entry point and authentication provider uses the same SSO client. @return \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient
[ "Build", "a", "SSO", "client", "instance", "from", "settings" ]
0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00
https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Domain/Factory/SsoClientFactory.php#L51-L62
238,736
novuso/common
src/Domain/Type/StringObject.php
StringObject.delimitString
private static function delimitString(string $string, string $delimiter): string { $output = []; if (preg_match('/\A[a-z0-9]+\z/ui', $string) && strtoupper($string) !== $string) { $parts = self::explodeOnCaps($string); } else { $parts = self::explodeOnDelims($string); } foreach ($parts as $part) { $output[] = $part.$delimiter; } return rtrim(implode('', $output), $delimiter); }
php
private static function delimitString(string $string, string $delimiter): string { $output = []; if (preg_match('/\A[a-z0-9]+\z/ui', $string) && strtoupper($string) !== $string) { $parts = self::explodeOnCaps($string); } else { $parts = self::explodeOnDelims($string); } foreach ($parts as $part) { $output[] = $part.$delimiter; } return rtrim(implode('', $output), $delimiter); }
[ "private", "static", "function", "delimitString", "(", "string", "$", "string", ",", "string", "$", "delimiter", ")", ":", "string", "{", "$", "output", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'/\\A[a-z0-9]+\\z/ui'", ",", "$", "string", ")", "&&", "strtoupper", "(", "$", "string", ")", "!==", "$", "string", ")", "{", "$", "parts", "=", "self", "::", "explodeOnCaps", "(", "$", "string", ")", ";", "}", "else", "{", "$", "parts", "=", "self", "::", "explodeOnDelims", "(", "$", "string", ")", ";", "}", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "output", "[", "]", "=", "$", "part", ".", "$", "delimiter", ";", "}", "return", "rtrim", "(", "implode", "(", "''", ",", "$", "output", ")", ",", "$", "delimiter", ")", ";", "}" ]
Applies delimiter formatting to a string @param string $string The original string @param string $delimiter The delimiter @return string
[ "Applies", "delimiter", "formatting", "to", "a", "string" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Type/StringObject.php#L909-L924
238,737
novuso/common
src/Domain/Type/StringObject.php
StringObject.explodeOnCaps
private static function explodeOnCaps(string $string): array { $string = preg_replace('/\B([A-Z])/', '_\1', $string); $string = preg_replace('/([0-9]+)/', '_\1', $string); $string = preg_replace('/_+/', '_', $string); $string = trim($string, '_'); return explode('_', $string); }
php
private static function explodeOnCaps(string $string): array { $string = preg_replace('/\B([A-Z])/', '_\1', $string); $string = preg_replace('/([0-9]+)/', '_\1', $string); $string = preg_replace('/_+/', '_', $string); $string = trim($string, '_'); return explode('_', $string); }
[ "private", "static", "function", "explodeOnCaps", "(", "string", "$", "string", ")", ":", "array", "{", "$", "string", "=", "preg_replace", "(", "'/\\B([A-Z])/'", ",", "'_\\1'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'/([0-9]+)/'", ",", "'_\\1'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'/_+/'", ",", "'_'", ",", "$", "string", ")", ";", "$", "string", "=", "trim", "(", "$", "string", ",", "'_'", ")", ";", "return", "explode", "(", "'_'", ",", "$", "string", ")", ";", "}" ]
Splits a string into a list on capital letters @param string $string The input string @return array
[ "Splits", "a", "string", "into", "a", "list", "on", "capital", "letters" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Type/StringObject.php#L933-L941
238,738
novuso/common
src/Domain/Type/StringObject.php
StringObject.explodeOnDelims
private static function explodeOnDelims(string $string): array { $string = preg_replace('/[^a-z0-9]+/i', '_', $string); $string = trim($string, '_'); return explode('_', $string); }
php
private static function explodeOnDelims(string $string): array { $string = preg_replace('/[^a-z0-9]+/i', '_', $string); $string = trim($string, '_'); return explode('_', $string); }
[ "private", "static", "function", "explodeOnDelims", "(", "string", "$", "string", ")", ":", "array", "{", "$", "string", "=", "preg_replace", "(", "'/[^a-z0-9]+/i'", ",", "'_'", ",", "$", "string", ")", ";", "$", "string", "=", "trim", "(", "$", "string", ",", "'_'", ")", ";", "return", "explode", "(", "'_'", ",", "$", "string", ")", ";", "}" ]
Splits a string into a list on non-word breaks @param string $string The input string @return array
[ "Splits", "a", "string", "into", "a", "list", "on", "non", "-", "word", "breaks" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Type/StringObject.php#L950-L956
238,739
gibboncms/gibbon
src/Modules/ModuleBag.php
ModuleBag.get
public function get($key = null) { if ($key === null) { return $this; } if (!isset($this->modules[$key])) { throw new ModuleDoesntExistException($key); } return $this->modules[$key]; }
php
public function get($key = null) { if ($key === null) { return $this; } if (!isset($this->modules[$key])) { throw new ModuleDoesntExistException($key); } return $this->modules[$key]; }
[ "public", "function", "get", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "modules", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "ModuleDoesntExistException", "(", "$", "key", ")", ";", "}", "return", "$", "this", "->", "modules", "[", "$", "key", "]", ";", "}" ]
Retrieve a registered module @param string|null $key @return \GibbonCms\Gibbon\Modules\Module|self
[ "Retrieve", "a", "registered", "module" ]
2905e90b2902149b3358b385264e98b97cf4fc00
https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Modules/ModuleBag.php#L32-L43
238,740
JumpGateio/Menu
src/JumpGate/Menu/Traits/Linkable.php
Linkable.insertMenuObject
private function insertMenuObject($slug, $callback, $object) { $object->slug = $this->snakeName($slug); $object->menu = $this->getMenu(); call_user_func($callback, $object); if (! $object->insert) { $this->links[] = $object; } }
php
private function insertMenuObject($slug, $callback, $object) { $object->slug = $this->snakeName($slug); $object->menu = $this->getMenu(); call_user_func($callback, $object); if (! $object->insert) { $this->links[] = $object; } }
[ "private", "function", "insertMenuObject", "(", "$", "slug", ",", "$", "callback", ",", "$", "object", ")", "{", "$", "object", "->", "slug", "=", "$", "this", "->", "snakeName", "(", "$", "slug", ")", ";", "$", "object", "->", "menu", "=", "$", "this", "->", "getMenu", "(", ")", ";", "call_user_func", "(", "$", "callback", ",", "$", "object", ")", ";", "if", "(", "!", "$", "object", "->", "insert", ")", "{", "$", "this", "->", "links", "[", "]", "=", "$", "object", ";", "}", "}" ]
Insert an object into the menu @param $slug @param $callback @param $object
[ "Insert", "an", "object", "into", "the", "menu" ]
53e339cc0a070e3b8a8332fe32850699663fa215
https://github.com/JumpGateio/Menu/blob/53e339cc0a070e3b8a8332fe32850699663fa215/src/JumpGate/Menu/Traits/Linkable.php#L101-L111
238,741
lexide/reposition
src/Repository/AbstractRepository.php
AbstractRepository.configureMetadata
protected function configureMetadata() { $this->entityMetadata->setCollection($this->collectionName); if (!empty($this->primaryKey)) { $this->entityMetadata->setPrimaryKey($this->primaryKey); } }
php
protected function configureMetadata() { $this->entityMetadata->setCollection($this->collectionName); if (!empty($this->primaryKey)) { $this->entityMetadata->setPrimaryKey($this->primaryKey); } }
[ "protected", "function", "configureMetadata", "(", ")", "{", "$", "this", "->", "entityMetadata", "->", "setCollection", "(", "$", "this", "->", "collectionName", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "primaryKey", ")", ")", "{", "$", "this", "->", "entityMetadata", "->", "setPrimaryKey", "(", "$", "this", "->", "primaryKey", ")", ";", "}", "}" ]
Configure the metadata for the entity this repository interacts with Override this method to set additional fields or define relationships with other entities
[ "Configure", "the", "metadata", "for", "the", "entity", "this", "repository", "interacts", "with" ]
aa02735271f0c0ee4a3fb679093d4d3823963b3a
https://github.com/lexide/reposition/blob/aa02735271f0c0ee4a3fb679093d4d3823963b3a/src/Repository/AbstractRepository.php#L97-L103
238,742
jc21/filelist
src/jc21/FileList.php
FileList.sort
protected function sort($items, $type = self::TYPE_BOTH, $by = self::KEY_NAME, $direction = self::ASC) { $returnArray = array(); if (count($items) > 0) { $tmpArray = array(); foreach($items as $key => $value) { $tmpArray[$key] = $value[$by]; } natcasesort($tmpArray); if ($direction == self::DESC) { $tmpArray = array_reverse($tmpArray, true); } foreach($tmpArray as $key => $value) { $returnArray[] = $items[$key]; } // If sorting by name, lets seperate the files from the dirs. if ($by == self::KEY_NAME && $type == self::TYPE_BOTH) { $files = array(); $dirs = array(); foreach ($returnArray as $value) { if ($value[self::KEY_TYPE] == self::TYPE_FILE) { $files[] = $value; } elseif ($value[self::KEY_TYPE] == self::TYPE_DIR) { $dirs[] = $value; } } if ($direction == self::DESC) { $returnArray = array_merge($files, $dirs); } else { $returnArray = array_merge($dirs, $files); } } } return $returnArray; }
php
protected function sort($items, $type = self::TYPE_BOTH, $by = self::KEY_NAME, $direction = self::ASC) { $returnArray = array(); if (count($items) > 0) { $tmpArray = array(); foreach($items as $key => $value) { $tmpArray[$key] = $value[$by]; } natcasesort($tmpArray); if ($direction == self::DESC) { $tmpArray = array_reverse($tmpArray, true); } foreach($tmpArray as $key => $value) { $returnArray[] = $items[$key]; } // If sorting by name, lets seperate the files from the dirs. if ($by == self::KEY_NAME && $type == self::TYPE_BOTH) { $files = array(); $dirs = array(); foreach ($returnArray as $value) { if ($value[self::KEY_TYPE] == self::TYPE_FILE) { $files[] = $value; } elseif ($value[self::KEY_TYPE] == self::TYPE_DIR) { $dirs[] = $value; } } if ($direction == self::DESC) { $returnArray = array_merge($files, $dirs); } else { $returnArray = array_merge($dirs, $files); } } } return $returnArray; }
[ "protected", "function", "sort", "(", "$", "items", ",", "$", "type", "=", "self", "::", "TYPE_BOTH", ",", "$", "by", "=", "self", "::", "KEY_NAME", ",", "$", "direction", "=", "self", "::", "ASC", ")", "{", "$", "returnArray", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "items", ")", ">", "0", ")", "{", "$", "tmpArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "tmpArray", "[", "$", "key", "]", "=", "$", "value", "[", "$", "by", "]", ";", "}", "natcasesort", "(", "$", "tmpArray", ")", ";", "if", "(", "$", "direction", "==", "self", "::", "DESC", ")", "{", "$", "tmpArray", "=", "array_reverse", "(", "$", "tmpArray", ",", "true", ")", ";", "}", "foreach", "(", "$", "tmpArray", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "returnArray", "[", "]", "=", "$", "items", "[", "$", "key", "]", ";", "}", "// If sorting by name, lets seperate the files from the dirs.", "if", "(", "$", "by", "==", "self", "::", "KEY_NAME", "&&", "$", "type", "==", "self", "::", "TYPE_BOTH", ")", "{", "$", "files", "=", "array", "(", ")", ";", "$", "dirs", "=", "array", "(", ")", ";", "foreach", "(", "$", "returnArray", "as", "$", "value", ")", "{", "if", "(", "$", "value", "[", "self", "::", "KEY_TYPE", "]", "==", "self", "::", "TYPE_FILE", ")", "{", "$", "files", "[", "]", "=", "$", "value", ";", "}", "elseif", "(", "$", "value", "[", "self", "::", "KEY_TYPE", "]", "==", "self", "::", "TYPE_DIR", ")", "{", "$", "dirs", "[", "]", "=", "$", "value", ";", "}", "}", "if", "(", "$", "direction", "==", "self", "::", "DESC", ")", "{", "$", "returnArray", "=", "array_merge", "(", "$", "files", ",", "$", "dirs", ")", ";", "}", "else", "{", "$", "returnArray", "=", "array_merge", "(", "$", "dirs", ",", "$", "files", ")", ";", "}", "}", "}", "return", "$", "returnArray", ";", "}" ]
Order the results of a directory listing @param array $items @param string $type @param string $by @param string $direction @return array
[ "Order", "the", "results", "of", "a", "directory", "listing" ]
240c4c20e5ec584e7c5f35305cdec3f95fd48ffc
https://github.com/jc21/filelist/blob/240c4c20e5ec584e7c5f35305cdec3f95fd48ffc/src/jc21/FileList.php#L76-L116
238,743
jc21/filelist
src/jc21/FileList.php
FileList.get
public function get($directory, $type = self::TYPE_BOTH, $order = self::KEY_NAME, $direction = self::ASC, $limit = null, $fileExtensions = array()) { // Get the contents of the dir $items = array(); $directory = rtrim($directory,'/'); // Check Dir if (!is_dir($directory)) { throw new \Exception('Directory does not exist: ' . $directory); } // Get Raw Listing $directoryHandle = opendir($directory); while (false !== ($file = readdir($directoryHandle))) { // skip anything that starts with a '.' i.e.:('.', '..', or any hidden file) if (substr($file, 0, 1) != '.') { // Directories if (is_dir($directory . '/' . $file) && ($type == self::TYPE_BOTH || $type == self::TYPE_DIR)) { $items[] = array( self::KEY_TYPE => self::TYPE_DIR, self::KEY_NAME => $file, self::KEY_DATE => filemtime($directory.'/'.$file), self::KEY_SIZE => filesize($directory.'/'.$file), self::KEY_EXT => '' ); // Files } else if (is_file($directory.'/'.$file) && ($type == self::TYPE_BOTH || $type == self::TYPE_FILE)) { if (!count($fileExtensions) || in_array(self::getExtension($file), $fileExtensions)) { $items[] = array( self::KEY_TYPE => self::TYPE_FILE, self::KEY_NAME => $file, self::KEY_DATE => filemtime($directory.'/'.$file), self::KEY_SIZE => filesize($directory.'/'.$file), self::KEY_EXT => self::getExtension($file) ); } } } // Impose Limit, if specified if ($limit && count($items) >= $limit) { break; } } closedir($directoryHandle); // Sorting $items = $this->sort($items, $type, $order, $direction); // Callbacks if ($this->filterCallback) { $items = call_user_func($this->filterCallback, $items); } // Total Size $totalSize = 0; foreach ($items as $item) { $totalSize += $item[self::KEY_SIZE]; } $this->lastSize = $totalSize; $this->lastItemCount = count($items); return $items; }
php
public function get($directory, $type = self::TYPE_BOTH, $order = self::KEY_NAME, $direction = self::ASC, $limit = null, $fileExtensions = array()) { // Get the contents of the dir $items = array(); $directory = rtrim($directory,'/'); // Check Dir if (!is_dir($directory)) { throw new \Exception('Directory does not exist: ' . $directory); } // Get Raw Listing $directoryHandle = opendir($directory); while (false !== ($file = readdir($directoryHandle))) { // skip anything that starts with a '.' i.e.:('.', '..', or any hidden file) if (substr($file, 0, 1) != '.') { // Directories if (is_dir($directory . '/' . $file) && ($type == self::TYPE_BOTH || $type == self::TYPE_DIR)) { $items[] = array( self::KEY_TYPE => self::TYPE_DIR, self::KEY_NAME => $file, self::KEY_DATE => filemtime($directory.'/'.$file), self::KEY_SIZE => filesize($directory.'/'.$file), self::KEY_EXT => '' ); // Files } else if (is_file($directory.'/'.$file) && ($type == self::TYPE_BOTH || $type == self::TYPE_FILE)) { if (!count($fileExtensions) || in_array(self::getExtension($file), $fileExtensions)) { $items[] = array( self::KEY_TYPE => self::TYPE_FILE, self::KEY_NAME => $file, self::KEY_DATE => filemtime($directory.'/'.$file), self::KEY_SIZE => filesize($directory.'/'.$file), self::KEY_EXT => self::getExtension($file) ); } } } // Impose Limit, if specified if ($limit && count($items) >= $limit) { break; } } closedir($directoryHandle); // Sorting $items = $this->sort($items, $type, $order, $direction); // Callbacks if ($this->filterCallback) { $items = call_user_func($this->filterCallback, $items); } // Total Size $totalSize = 0; foreach ($items as $item) { $totalSize += $item[self::KEY_SIZE]; } $this->lastSize = $totalSize; $this->lastItemCount = count($items); return $items; }
[ "public", "function", "get", "(", "$", "directory", ",", "$", "type", "=", "self", "::", "TYPE_BOTH", ",", "$", "order", "=", "self", "::", "KEY_NAME", ",", "$", "direction", "=", "self", "::", "ASC", ",", "$", "limit", "=", "null", ",", "$", "fileExtensions", "=", "array", "(", ")", ")", "{", "// Get the contents of the dir", "$", "items", "=", "array", "(", ")", ";", "$", "directory", "=", "rtrim", "(", "$", "directory", ",", "'/'", ")", ";", "// Check Dir", "if", "(", "!", "is_dir", "(", "$", "directory", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Directory does not exist: '", ".", "$", "directory", ")", ";", "}", "// Get Raw Listing", "$", "directoryHandle", "=", "opendir", "(", "$", "directory", ")", ";", "while", "(", "false", "!==", "(", "$", "file", "=", "readdir", "(", "$", "directoryHandle", ")", ")", ")", "{", "// skip anything that starts with a '.' i.e.:('.', '..', or any hidden file)", "if", "(", "substr", "(", "$", "file", ",", "0", ",", "1", ")", "!=", "'.'", ")", "{", "// Directories", "if", "(", "is_dir", "(", "$", "directory", ".", "'/'", ".", "$", "file", ")", "&&", "(", "$", "type", "==", "self", "::", "TYPE_BOTH", "||", "$", "type", "==", "self", "::", "TYPE_DIR", ")", ")", "{", "$", "items", "[", "]", "=", "array", "(", "self", "::", "KEY_TYPE", "=>", "self", "::", "TYPE_DIR", ",", "self", "::", "KEY_NAME", "=>", "$", "file", ",", "self", "::", "KEY_DATE", "=>", "filemtime", "(", "$", "directory", ".", "'/'", ".", "$", "file", ")", ",", "self", "::", "KEY_SIZE", "=>", "filesize", "(", "$", "directory", ".", "'/'", ".", "$", "file", ")", ",", "self", "::", "KEY_EXT", "=>", "''", ")", ";", "// Files", "}", "else", "if", "(", "is_file", "(", "$", "directory", ".", "'/'", ".", "$", "file", ")", "&&", "(", "$", "type", "==", "self", "::", "TYPE_BOTH", "||", "$", "type", "==", "self", "::", "TYPE_FILE", ")", ")", "{", "if", "(", "!", "count", "(", "$", "fileExtensions", ")", "||", "in_array", "(", "self", "::", "getExtension", "(", "$", "file", ")", ",", "$", "fileExtensions", ")", ")", "{", "$", "items", "[", "]", "=", "array", "(", "self", "::", "KEY_TYPE", "=>", "self", "::", "TYPE_FILE", ",", "self", "::", "KEY_NAME", "=>", "$", "file", ",", "self", "::", "KEY_DATE", "=>", "filemtime", "(", "$", "directory", ".", "'/'", ".", "$", "file", ")", ",", "self", "::", "KEY_SIZE", "=>", "filesize", "(", "$", "directory", ".", "'/'", ".", "$", "file", ")", ",", "self", "::", "KEY_EXT", "=>", "self", "::", "getExtension", "(", "$", "file", ")", ")", ";", "}", "}", "}", "// Impose Limit, if specified", "if", "(", "$", "limit", "&&", "count", "(", "$", "items", ")", ">=", "$", "limit", ")", "{", "break", ";", "}", "}", "closedir", "(", "$", "directoryHandle", ")", ";", "// Sorting", "$", "items", "=", "$", "this", "->", "sort", "(", "$", "items", ",", "$", "type", ",", "$", "order", ",", "$", "direction", ")", ";", "// Callbacks", "if", "(", "$", "this", "->", "filterCallback", ")", "{", "$", "items", "=", "call_user_func", "(", "$", "this", "->", "filterCallback", ",", "$", "items", ")", ";", "}", "// Total Size", "$", "totalSize", "=", "0", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "totalSize", "+=", "$", "item", "[", "self", "::", "KEY_SIZE", "]", ";", "}", "$", "this", "->", "lastSize", "=", "$", "totalSize", ";", "$", "this", "->", "lastItemCount", "=", "count", "(", "$", "items", ")", ";", "return", "$", "items", ";", "}" ]
Return the listing of a directory @param string $directory @param string $type @param string $order @param string $direction @param int $limit @param array $fileExtensions @return array @throws \Exception
[ "Return", "the", "listing", "of", "a", "directory" ]
240c4c20e5ec584e7c5f35305cdec3f95fd48ffc
https://github.com/jc21/filelist/blob/240c4c20e5ec584e7c5f35305cdec3f95fd48ffc/src/jc21/FileList.php#L131-L196
238,744
jc21/filelist
src/jc21/FileList.php
FileList.getExtension
protected function getExtension($file) { if (strpos($file, '.') !== false) { $tempExt = strtolower(substr($file, strrpos($file, '.') + 1, strlen($file) - strrpos($file, '.'))); return strtolower(trim($tempExt,'/')); } return ''; }
php
protected function getExtension($file) { if (strpos($file, '.') !== false) { $tempExt = strtolower(substr($file, strrpos($file, '.') + 1, strlen($file) - strrpos($file, '.'))); return strtolower(trim($tempExt,'/')); } return ''; }
[ "protected", "function", "getExtension", "(", "$", "file", ")", "{", "if", "(", "strpos", "(", "$", "file", ",", "'.'", ")", "!==", "false", ")", "{", "$", "tempExt", "=", "strtolower", "(", "substr", "(", "$", "file", ",", "strrpos", "(", "$", "file", ",", "'.'", ")", "+", "1", ",", "strlen", "(", "$", "file", ")", "-", "strrpos", "(", "$", "file", ",", "'.'", ")", ")", ")", ";", "return", "strtolower", "(", "trim", "(", "$", "tempExt", ",", "'/'", ")", ")", ";", "}", "return", "''", ";", "}" ]
Returns the extension of a file, lowercase @param string $file @return string
[ "Returns", "the", "extension", "of", "a", "file", "lowercase" ]
240c4c20e5ec584e7c5f35305cdec3f95fd48ffc
https://github.com/jc21/filelist/blob/240c4c20e5ec584e7c5f35305cdec3f95fd48ffc/src/jc21/FileList.php#L205-L212
238,745
cubiclab/project-cube
controllers/SriController.php
SriController.actionTaskstatusindex
public function actionTaskstatusindex() { $searchModel = new SRITaskstatusSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('taskstatus_index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
php
public function actionTaskstatusindex() { $searchModel = new SRITaskstatusSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('taskstatus_index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
[ "public", "function", "actionTaskstatusindex", "(", ")", "{", "$", "searchModel", "=", "new", "SRITaskstatusSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", ")", ";", "return", "$", "this", "->", "render", "(", "'taskstatus_index'", ",", "[", "'searchModel'", "=>", "$", "searchModel", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "]", ")", ";", "}" ]
Lists all SRITaskstatus models. @return mixed
[ "Lists", "all", "SRITaskstatus", "models", "." ]
3a2a425d95ed76b999136c8a52bae9f3154b800a
https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/SriController.php#L38-L47
238,746
cubiclab/project-cube
controllers/SriController.php
SriController.actionTaskstatuscreate
public function actionTaskstatuscreate() { $model = new SRI_Taskstatus(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['taskstatusview', 'id' => $model->id]); } else { return $this->render('taskstatus_create', [ 'model' => $model, ]); } }
php
public function actionTaskstatuscreate() { $model = new SRI_Taskstatus(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['taskstatusview', 'id' => $model->id]); } else { return $this->render('taskstatus_create', [ 'model' => $model, ]); } }
[ "public", "function", "actionTaskstatuscreate", "(", ")", "{", "$", "model", "=", "new", "SRI_Taskstatus", "(", ")", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'taskstatusview'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "render", "(", "'taskstatus_create'", ",", "[", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}", "}" ]
Creates a new SRITaskstatus model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "SRITaskstatus", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
3a2a425d95ed76b999136c8a52bae9f3154b800a
https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/SriController.php#L66-L77
238,747
cubiclab/project-cube
controllers/SriController.php
SriController.actionTaskstatusupdate
public function actionTaskstatusupdate($id) { $model = $this->findTaskstatusmodel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['taskstatusview', 'id' => $model->id]); } else { return $this->render('taskstatus_update', [ 'model' => $model, ]); } }
php
public function actionTaskstatusupdate($id) { $model = $this->findTaskstatusmodel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['taskstatusview', 'id' => $model->id]); } else { return $this->render('taskstatus_update', [ 'model' => $model, ]); } }
[ "public", "function", "actionTaskstatusupdate", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findTaskstatusmodel", "(", "$", "id", ")", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'taskstatusview'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "render", "(", "'taskstatus_update'", ",", "[", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}", "}" ]
Updates an existing SRITaskstatus model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "SRITaskstatus", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
3a2a425d95ed76b999136c8a52bae9f3154b800a
https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/SriController.php#L85-L96
238,748
easy-system/es-http
src/Uploading/UploadTarget.php
UploadTarget.set
public function set($target) { if (! is_string($target) || empty($target)) { throw new InvalidArgumentException( 'Invalid target provided. Must be an non-empty string.' ); } $this->target = $target; }
php
public function set($target) { if (! is_string($target) || empty($target)) { throw new InvalidArgumentException( 'Invalid target provided. Must be an non-empty string.' ); } $this->target = $target; }
[ "public", "function", "set", "(", "$", "target", ")", "{", "if", "(", "!", "is_string", "(", "$", "target", ")", "||", "empty", "(", "$", "target", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid target provided. Must be an non-empty string.'", ")", ";", "}", "$", "this", "->", "target", "=", "$", "target", ";", "}" ]
Sets the target of upload. @param string $target The target of upload @throws \InvalidArgumentException If the target is not string or empty string
[ "Sets", "the", "target", "of", "upload", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/UploadTarget.php#L43-L51
238,749
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Expr.php
Expr.references
public function references($document) { if ($this->currentField) { $mapping = $this->class->getFieldMapping($this->currentField); $dbRef = $this->dm->createDBRef($document, $mapping); if (isset($mapping['simple']) && $mapping['simple']) { $this->query[$mapping['name']] = $dbRef; } else { $keys = array('ref' => true, 'id' => true, 'db' => true); if (isset($mapping['targetDocument'])) { unset($keys['ref'], $keys['db']); } foreach ($keys as $key => $value) { $this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key]; } } } else { $dbRef = $this->dm->createDBRef($document); $this->query = $dbRef; } return $this; }
php
public function references($document) { if ($this->currentField) { $mapping = $this->class->getFieldMapping($this->currentField); $dbRef = $this->dm->createDBRef($document, $mapping); if (isset($mapping['simple']) && $mapping['simple']) { $this->query[$mapping['name']] = $dbRef; } else { $keys = array('ref' => true, 'id' => true, 'db' => true); if (isset($mapping['targetDocument'])) { unset($keys['ref'], $keys['db']); } foreach ($keys as $key => $value) { $this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key]; } } } else { $dbRef = $this->dm->createDBRef($document); $this->query = $dbRef; } return $this; }
[ "public", "function", "references", "(", "$", "document", ")", "{", "if", "(", "$", "this", "->", "currentField", ")", "{", "$", "mapping", "=", "$", "this", "->", "class", "->", "getFieldMapping", "(", "$", "this", "->", "currentField", ")", ";", "$", "dbRef", "=", "$", "this", "->", "dm", "->", "createDBRef", "(", "$", "document", ",", "$", "mapping", ")", ";", "if", "(", "isset", "(", "$", "mapping", "[", "'simple'", "]", ")", "&&", "$", "mapping", "[", "'simple'", "]", ")", "{", "$", "this", "->", "query", "[", "$", "mapping", "[", "'name'", "]", "]", "=", "$", "dbRef", ";", "}", "else", "{", "$", "keys", "=", "array", "(", "'ref'", "=>", "true", ",", "'id'", "=>", "true", ",", "'db'", "=>", "true", ")", ";", "if", "(", "isset", "(", "$", "mapping", "[", "'targetDocument'", "]", ")", ")", "{", "unset", "(", "$", "keys", "[", "'ref'", "]", ",", "$", "keys", "[", "'db'", "]", ")", ";", "}", "foreach", "(", "$", "keys", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "query", "[", "$", "this", "->", "currentField", ".", "'.$'", ".", "$", "key", "]", "=", "$", "dbRef", "[", "'$'", ".", "$", "key", "]", ";", "}", "}", "}", "else", "{", "$", "dbRef", "=", "$", "this", "->", "dm", "->", "createDBRef", "(", "$", "document", ")", ";", "$", "this", "->", "query", "=", "$", "dbRef", ";", "}", "return", "$", "this", ";", "}" ]
Checks that the value of the current field is a reference to the supplied document.
[ "Checks", "that", "the", "value", "of", "the", "current", "field", "is", "a", "reference", "to", "the", "supplied", "document", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Query/Expr.php#L60-L85
238,750
northern/PHP-Common
src/Northern/Common/Util/ObjectUtil.php
ObjectUtil.apply
public static function apply($object, array $values) { foreach ($values as $property => $value) { // Check if the value is a map (associative array) by checking for // a zero index. if (is_array($value) and ! isset($value[0])) { $method = "get".ucfirst($property); if (method_exists($object, $method)) { //$object->{$method}()->apply( $value ); static::apply($object->{$method}(), $value); } } elseif (is_array($value) and isset($value[0])) { // Check if the value is a collection, i.e. an indexed array. If this // is the case then the $value is an interable array. If the object // has an "add" method for the property then we call this x times. $method = "add".ucfirst($property); if (method_exists($object, $method)) { foreach ($value as $arguments) { if (! is_array($arguments)) { $arguments = array( $arguments ); } call_user_func_array(array( $object, $method ), $arguments); } } } else { // Check if the value has a corresponding setter method // on the object. $method = "set".ucfirst($property); if (method_exists($object, $method)) { $object->{$method}($value); } } } }
php
public static function apply($object, array $values) { foreach ($values as $property => $value) { // Check if the value is a map (associative array) by checking for // a zero index. if (is_array($value) and ! isset($value[0])) { $method = "get".ucfirst($property); if (method_exists($object, $method)) { //$object->{$method}()->apply( $value ); static::apply($object->{$method}(), $value); } } elseif (is_array($value) and isset($value[0])) { // Check if the value is a collection, i.e. an indexed array. If this // is the case then the $value is an interable array. If the object // has an "add" method for the property then we call this x times. $method = "add".ucfirst($property); if (method_exists($object, $method)) { foreach ($value as $arguments) { if (! is_array($arguments)) { $arguments = array( $arguments ); } call_user_func_array(array( $object, $method ), $arguments); } } } else { // Check if the value has a corresponding setter method // on the object. $method = "set".ucfirst($property); if (method_exists($object, $method)) { $object->{$method}($value); } } } }
[ "public", "static", "function", "apply", "(", "$", "object", ",", "array", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "property", "=>", "$", "value", ")", "{", "// Check if the value is a map (associative array) by checking for", "// a zero index.", "if", "(", "is_array", "(", "$", "value", ")", "and", "!", "isset", "(", "$", "value", "[", "0", "]", ")", ")", "{", "$", "method", "=", "\"get\"", ".", "ucfirst", "(", "$", "property", ")", ";", "if", "(", "method_exists", "(", "$", "object", ",", "$", "method", ")", ")", "{", "//$object->{$method}()->apply( $value );", "static", "::", "apply", "(", "$", "object", "->", "{", "$", "method", "}", "(", ")", ",", "$", "value", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "value", ")", "and", "isset", "(", "$", "value", "[", "0", "]", ")", ")", "{", "// Check if the value is a collection, i.e. an indexed array. If this", "// is the case then the $value is an interable array. If the object", "// has an \"add\" method for the property then we call this x times.", "$", "method", "=", "\"add\"", ".", "ucfirst", "(", "$", "property", ")", ";", "if", "(", "method_exists", "(", "$", "object", ",", "$", "method", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "arguments", ")", "{", "if", "(", "!", "is_array", "(", "$", "arguments", ")", ")", "{", "$", "arguments", "=", "array", "(", "$", "arguments", ")", ";", "}", "call_user_func_array", "(", "array", "(", "$", "object", ",", "$", "method", ")", ",", "$", "arguments", ")", ";", "}", "}", "}", "else", "{", "// Check if the value has a corresponding setter method", "// on the object.", "$", "method", "=", "\"set\"", ".", "ucfirst", "(", "$", "property", ")", ";", "if", "(", "method_exists", "(", "$", "object", ",", "$", "method", ")", ")", "{", "$", "object", "->", "{", "$", "method", "}", "(", "$", "value", ")", ";", "}", "}", "}", "}" ]
This method applies a given set of values to a given object. The array with values supplied must be actual values of the object and must be exposed through a corresponding setter method. E.g. if you wish to set the value on a property called 'firstname' then the object needs to have a 'setFirstname' setter method. If the setter is not available the property will not be set and the corresponding value will not be applied. @param object $object @param array $values
[ "This", "method", "applies", "a", "given", "set", "of", "values", "to", "a", "given", "object", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ObjectUtil.php#L98-L135
238,751
northern/PHP-Common
src/Northern/Common/Util/ObjectUtil.php
ObjectUtil.validate
public static function validate($object, array $values, array $constraints) { $errors = array(); // Build a validator and get the entity constraints from the // entity object. $validatorBuilder = new ValidatorBuilder(); $validator = $validatorBuilder->getValidator(); // Loop through all the passed in values. Each $value represents a // value of a $property on the object. foreach ($values as $property => $value) { // Check if we have contraints for this property. If not, test next property. if (! isset($constraints[ $property ])) { continue; } // Check if the $value is a map (i.e. an array without a zero index). If so, // then we're dealing with a complex object into which we need to recurse into. if (is_array($value) and ! isset($value[0])) { // We're going to recurise into the sub-object but to get access to it we // need to construct it's "getter" method. $method = "get".ucfirst($property); // Check if the "getter" method exists on the and the property exists in the // constraints before calling it. If either doesn't exist we fail silently // and skip to the next property. if (method_exists($object, $method) and array_key_exists($property, $constraints)) { // The method exists so we can recurse into it. The $value represents an // array of property/value pairs that must be set on the sub-object. $results = static::validate($object->{$method}(), $value, $constraints[ $property ]); // The $results represent the errors that were caused by the validation // of the sub-entity. If we have errors, then apply them to the error // object. if (! empty($results)) { $errors[ $property ] = $results; } } } else { // We're dealing with a simple property. The $value represents the new // value that the property must be set to and we grab the contraints // based on the property name. $results = $validator->validateValue($value, $constraints[ $property ]); // A property can have many constraints. E.g. an email address must be // a valid email address and cannot be blank. This means that the validation // can return multiple errors for a single field. Here we add each individual // error for the validated property. if ($results->count() > 0) { foreach ($results as $result) { $errors[ $property ][] = $result->getMessage(); } } } } return $errors; }
php
public static function validate($object, array $values, array $constraints) { $errors = array(); // Build a validator and get the entity constraints from the // entity object. $validatorBuilder = new ValidatorBuilder(); $validator = $validatorBuilder->getValidator(); // Loop through all the passed in values. Each $value represents a // value of a $property on the object. foreach ($values as $property => $value) { // Check if we have contraints for this property. If not, test next property. if (! isset($constraints[ $property ])) { continue; } // Check if the $value is a map (i.e. an array without a zero index). If so, // then we're dealing with a complex object into which we need to recurse into. if (is_array($value) and ! isset($value[0])) { // We're going to recurise into the sub-object but to get access to it we // need to construct it's "getter" method. $method = "get".ucfirst($property); // Check if the "getter" method exists on the and the property exists in the // constraints before calling it. If either doesn't exist we fail silently // and skip to the next property. if (method_exists($object, $method) and array_key_exists($property, $constraints)) { // The method exists so we can recurse into it. The $value represents an // array of property/value pairs that must be set on the sub-object. $results = static::validate($object->{$method}(), $value, $constraints[ $property ]); // The $results represent the errors that were caused by the validation // of the sub-entity. If we have errors, then apply them to the error // object. if (! empty($results)) { $errors[ $property ] = $results; } } } else { // We're dealing with a simple property. The $value represents the new // value that the property must be set to and we grab the contraints // based on the property name. $results = $validator->validateValue($value, $constraints[ $property ]); // A property can have many constraints. E.g. an email address must be // a valid email address and cannot be blank. This means that the validation // can return multiple errors for a single field. Here we add each individual // error for the validated property. if ($results->count() > 0) { foreach ($results as $result) { $errors[ $property ][] = $result->getMessage(); } } } } return $errors; }
[ "public", "static", "function", "validate", "(", "$", "object", ",", "array", "$", "values", ",", "array", "$", "constraints", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "// Build a validator and get the entity constraints from the", "// entity object.", "$", "validatorBuilder", "=", "new", "ValidatorBuilder", "(", ")", ";", "$", "validator", "=", "$", "validatorBuilder", "->", "getValidator", "(", ")", ";", "// Loop through all the passed in values. Each $value represents a", "// value of a $property on the object.", "foreach", "(", "$", "values", "as", "$", "property", "=>", "$", "value", ")", "{", "// Check if we have contraints for this property. If not, test next property.", "if", "(", "!", "isset", "(", "$", "constraints", "[", "$", "property", "]", ")", ")", "{", "continue", ";", "}", "// Check if the $value is a map (i.e. an array without a zero index). If so,", "// then we're dealing with a complex object into which we need to recurse into.", "if", "(", "is_array", "(", "$", "value", ")", "and", "!", "isset", "(", "$", "value", "[", "0", "]", ")", ")", "{", "// We're going to recurise into the sub-object but to get access to it we", "// need to construct it's \"getter\" method.", "$", "method", "=", "\"get\"", ".", "ucfirst", "(", "$", "property", ")", ";", "// Check if the \"getter\" method exists on the and the property exists in the", "// constraints before calling it. If either doesn't exist we fail silently", "// and skip to the next property.", "if", "(", "method_exists", "(", "$", "object", ",", "$", "method", ")", "and", "array_key_exists", "(", "$", "property", ",", "$", "constraints", ")", ")", "{", "// The method exists so we can recurse into it. The $value represents an", "// array of property/value pairs that must be set on the sub-object.", "$", "results", "=", "static", "::", "validate", "(", "$", "object", "->", "{", "$", "method", "}", "(", ")", ",", "$", "value", ",", "$", "constraints", "[", "$", "property", "]", ")", ";", "// The $results represent the errors that were caused by the validation", "// of the sub-entity. If we have errors, then apply them to the error", "// object.", "if", "(", "!", "empty", "(", "$", "results", ")", ")", "{", "$", "errors", "[", "$", "property", "]", "=", "$", "results", ";", "}", "}", "}", "else", "{", "// We're dealing with a simple property. The $value represents the new", "// value that the property must be set to and we grab the contraints", "// based on the property name.", "$", "results", "=", "$", "validator", "->", "validateValue", "(", "$", "value", ",", "$", "constraints", "[", "$", "property", "]", ")", ";", "// A property can have many constraints. E.g. an email address must be", "// a valid email address and cannot be blank. This means that the validation", "// can return multiple errors for a single field. Here we add each individual", "// error for the validated property.", "if", "(", "$", "results", "->", "count", "(", ")", ">", "0", ")", "{", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "$", "errors", "[", "$", "property", "]", "[", "]", "=", "$", "result", "->", "getMessage", "(", ")", ";", "}", "}", "}", "}", "return", "$", "errors", ";", "}" ]
This method will validate an object with the specified values. If any of the values does not validate an array with errors will be returned. The error message will be generated by the constraints which are defined in the entity getConstraints method. @param array $values @throws \Btq\Core\Exception\MethodDoesNotExistException @return array
[ "This", "method", "will", "validate", "an", "object", "with", "the", "specified", "values", "." ]
7c63ef19252fd540fb412a18af956b8563afaa55
https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ObjectUtil.php#L148-L206
238,752
jhorlima/wp-mocabonita
src/tools/MbResponse.php
MbResponse.redirect
public function redirect($url, array $params = [], $status = 302) { if (!empty($params)) { $url = rtrim(preg_replace('/\?.*/', '', $url), '/'); $url .= "?" . http_build_query($params); } $this->statusCode = $status; $this->headers->set('Location', $url); $this->getMbAudit()->setResponseType('redirect'); $this->getMbAudit()->setResponseData([ 'url' => $url, ]); return true; }
php
public function redirect($url, array $params = [], $status = 302) { if (!empty($params)) { $url = rtrim(preg_replace('/\?.*/', '', $url), '/'); $url .= "?" . http_build_query($params); } $this->statusCode = $status; $this->headers->set('Location', $url); $this->getMbAudit()->setResponseType('redirect'); $this->getMbAudit()->setResponseData([ 'url' => $url, ]); return true; }
[ "public", "function", "redirect", "(", "$", "url", ",", "array", "$", "params", "=", "[", "]", ",", "$", "status", "=", "302", ")", "{", "if", "(", "!", "empty", "(", "$", "params", ")", ")", "{", "$", "url", "=", "rtrim", "(", "preg_replace", "(", "'/\\?.*/'", ",", "''", ",", "$", "url", ")", ",", "'/'", ")", ";", "$", "url", ".=", "\"?\"", ".", "http_build_query", "(", "$", "params", ")", ";", "}", "$", "this", "->", "statusCode", "=", "$", "status", ";", "$", "this", "->", "headers", "->", "set", "(", "'Location'", ",", "$", "url", ")", ";", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseType", "(", "'redirect'", ")", ";", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseData", "(", "[", "'url'", "=>", "$", "url", ",", "]", ")", ";", "return", "true", ";", "}" ]
Redirect a page @param string $url @param array $params @param int $status @return bool
[ "Redirect", "a", "page" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L175-L191
238,753
jhorlima/wp-mocabonita
src/tools/MbResponse.php
MbResponse.ajaxContent
protected function ajaxContent($content) { $message = null; $this->header('Content-Type', 'application/json'); if ($content instanceof Arrayable) { $content = $content->toArray(); } elseif (is_string($content)) { $content = ['content' => $content]; } elseif (!is_array($content) && !$content instanceof \Exception) { return $this->ajaxContent(new \Exception("No valid content has been submitted!", BaseResponse::HTTP_BAD_REQUEST)); } elseif ($content instanceof \Exception) { $this->setStatusCode($content->getCode() < 300 ? BaseResponse::HTTP_BAD_REQUEST : $content->getCode()); $message = $content->getMessage(); if ($content instanceof MbException) { $content = $content->getMessages(); } else { $content = null; } } $this->original = [ 'meta' => [ 'code' => $this->getStatusCode(), 'message' => $message, ], 'data' => $content, ]; $this->getMbAudit()->setResponseType('ajax'); $this->getMbAudit()->setResponseData($this->original); return $this->original; }
php
protected function ajaxContent($content) { $message = null; $this->header('Content-Type', 'application/json'); if ($content instanceof Arrayable) { $content = $content->toArray(); } elseif (is_string($content)) { $content = ['content' => $content]; } elseif (!is_array($content) && !$content instanceof \Exception) { return $this->ajaxContent(new \Exception("No valid content has been submitted!", BaseResponse::HTTP_BAD_REQUEST)); } elseif ($content instanceof \Exception) { $this->setStatusCode($content->getCode() < 300 ? BaseResponse::HTTP_BAD_REQUEST : $content->getCode()); $message = $content->getMessage(); if ($content instanceof MbException) { $content = $content->getMessages(); } else { $content = null; } } $this->original = [ 'meta' => [ 'code' => $this->getStatusCode(), 'message' => $message, ], 'data' => $content, ]; $this->getMbAudit()->setResponseType('ajax'); $this->getMbAudit()->setResponseData($this->original); return $this->original; }
[ "protected", "function", "ajaxContent", "(", "$", "content", ")", "{", "$", "message", "=", "null", ";", "$", "this", "->", "header", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "if", "(", "$", "content", "instanceof", "Arrayable", ")", "{", "$", "content", "=", "$", "content", "->", "toArray", "(", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "content", ")", ")", "{", "$", "content", "=", "[", "'content'", "=>", "$", "content", "]", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "content", ")", "&&", "!", "$", "content", "instanceof", "\\", "Exception", ")", "{", "return", "$", "this", "->", "ajaxContent", "(", "new", "\\", "Exception", "(", "\"No valid content has been submitted!\"", ",", "BaseResponse", "::", "HTTP_BAD_REQUEST", ")", ")", ";", "}", "elseif", "(", "$", "content", "instanceof", "\\", "Exception", ")", "{", "$", "this", "->", "setStatusCode", "(", "$", "content", "->", "getCode", "(", ")", "<", "300", "?", "BaseResponse", "::", "HTTP_BAD_REQUEST", ":", "$", "content", "->", "getCode", "(", ")", ")", ";", "$", "message", "=", "$", "content", "->", "getMessage", "(", ")", ";", "if", "(", "$", "content", "instanceof", "MbException", ")", "{", "$", "content", "=", "$", "content", "->", "getMessages", "(", ")", ";", "}", "else", "{", "$", "content", "=", "null", ";", "}", "}", "$", "this", "->", "original", "=", "[", "'meta'", "=>", "[", "'code'", "=>", "$", "this", "->", "getStatusCode", "(", ")", ",", "'message'", "=>", "$", "message", ",", "]", ",", "'data'", "=>", "$", "content", ",", "]", ";", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseType", "(", "'ajax'", ")", ";", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseData", "(", "$", "this", "->", "original", ")", ";", "return", "$", "this", "->", "original", ";", "}" ]
Format content for json output @param array|\Exception $content @return array[]
[ "Format", "content", "for", "json", "output" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L200-L237
238,754
jhorlima/wp-mocabonita
src/tools/MbResponse.php
MbResponse.htmlContent
protected function htmlContent($content) { try { $this->getMbAudit()->setResponseType('html'); if ($content instanceof \Exception) { throw $content; } elseif ($content instanceof \SplFileInfo && !$this->getMbRequest()->isBlogAdmin()) { $this->downloadFile($content); } elseif (!is_string($content) && !$content instanceof Renderable) { $this->getMbAudit()->setResponseType('debug'); $this->getMbAudit()->setResponseData($content); ob_start(); (new Dumper)->dump($content); $this->original = ob_get_contents(); ob_end_clean(); } else { $this->getMbAudit()->setResponseData($content); $this->original = $content; } parent::setContent($this->original); } catch (\Exception $e) { $this->getMbAudit()->setResponseData($e->getMessage()); if ($this->getMbRequest()->isBlogAdmin()) { $this->adminNotice($e->getMessage(), 'error'); } else { $this->original = "<strong>Erro:</strong> {$e->getMessage()}<br>"; } parent::setContent($this->original); } }
php
protected function htmlContent($content) { try { $this->getMbAudit()->setResponseType('html'); if ($content instanceof \Exception) { throw $content; } elseif ($content instanceof \SplFileInfo && !$this->getMbRequest()->isBlogAdmin()) { $this->downloadFile($content); } elseif (!is_string($content) && !$content instanceof Renderable) { $this->getMbAudit()->setResponseType('debug'); $this->getMbAudit()->setResponseData($content); ob_start(); (new Dumper)->dump($content); $this->original = ob_get_contents(); ob_end_clean(); } else { $this->getMbAudit()->setResponseData($content); $this->original = $content; } parent::setContent($this->original); } catch (\Exception $e) { $this->getMbAudit()->setResponseData($e->getMessage()); if ($this->getMbRequest()->isBlogAdmin()) { $this->adminNotice($e->getMessage(), 'error'); } else { $this->original = "<strong>Erro:</strong> {$e->getMessage()}<br>"; } parent::setContent($this->original); } }
[ "protected", "function", "htmlContent", "(", "$", "content", ")", "{", "try", "{", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseType", "(", "'html'", ")", ";", "if", "(", "$", "content", "instanceof", "\\", "Exception", ")", "{", "throw", "$", "content", ";", "}", "elseif", "(", "$", "content", "instanceof", "\\", "SplFileInfo", "&&", "!", "$", "this", "->", "getMbRequest", "(", ")", "->", "isBlogAdmin", "(", ")", ")", "{", "$", "this", "->", "downloadFile", "(", "$", "content", ")", ";", "}", "elseif", "(", "!", "is_string", "(", "$", "content", ")", "&&", "!", "$", "content", "instanceof", "Renderable", ")", "{", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseType", "(", "'debug'", ")", ";", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseData", "(", "$", "content", ")", ";", "ob_start", "(", ")", ";", "(", "new", "Dumper", ")", "->", "dump", "(", "$", "content", ")", ";", "$", "this", "->", "original", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "}", "else", "{", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseData", "(", "$", "content", ")", ";", "$", "this", "->", "original", "=", "$", "content", ";", "}", "parent", "::", "setContent", "(", "$", "this", "->", "original", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "getMbAudit", "(", ")", "->", "setResponseData", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "this", "->", "getMbRequest", "(", ")", "->", "isBlogAdmin", "(", ")", ")", "{", "$", "this", "->", "adminNotice", "(", "$", "e", "->", "getMessage", "(", ")", ",", "'error'", ")", ";", "}", "else", "{", "$", "this", "->", "original", "=", "\"<strong>Erro:</strong> {$e->getMessage()}<br>\"", ";", "}", "parent", "::", "setContent", "(", "$", "this", "->", "original", ")", ";", "}", "}" ]
Format content for html output @param $content @return void
[ "Format", "content", "for", "html", "output" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L246-L291
238,755
jhorlima/wp-mocabonita
src/tools/MbResponse.php
MbResponse.adminNotice
public function adminNotice($message, $type = 'success') { MbWPActionHook::addActionCallback('admin_notices', function () use ($message, $type) { echo self::adminNoticeTemplate($message, $type); }); }
php
public function adminNotice($message, $type = 'success') { MbWPActionHook::addActionCallback('admin_notices', function () use ($message, $type) { echo self::adminNoticeTemplate($message, $type); }); }
[ "public", "function", "adminNotice", "(", "$", "message", ",", "$", "type", "=", "'success'", ")", "{", "MbWPActionHook", "::", "addActionCallback", "(", "'admin_notices'", ",", "function", "(", ")", "use", "(", "$", "message", ",", "$", "type", ")", "{", "echo", "self", "::", "adminNoticeTemplate", "(", "$", "message", ",", "$", "type", ")", ";", "}", ")", ";", "}" ]
Post an admin notice on the dashboard @param string $message @param string $type
[ "Post", "an", "admin", "notice", "on", "the", "dashboard" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L372-L377
238,756
ronanchilvers/silex-spot2-provider
src/Provider/Spot2ServiceProvider.php
Spot2ServiceProvider.register
public function register(Container $container) { $container['spot2.connections'] = []; $container['spot2.connections.default'] = null; $container['spot2.config'] = function (Container $container) { $config = new Config(); foreach ($container['spot2.connections'] as $name => $data) { $default = ($container['spot2.connections.default'] === $name) ? true : false ; $config->addConnection($name, $data, $default); } return $config; }; $container['spot2.locator'] = function (Container $container) { return new Locator($container['spot2.config']); }; }
php
public function register(Container $container) { $container['spot2.connections'] = []; $container['spot2.connections.default'] = null; $container['spot2.config'] = function (Container $container) { $config = new Config(); foreach ($container['spot2.connections'] as $name => $data) { $default = ($container['spot2.connections.default'] === $name) ? true : false ; $config->addConnection($name, $data, $default); } return $config; }; $container['spot2.locator'] = function (Container $container) { return new Locator($container['spot2.config']); }; }
[ "public", "function", "register", "(", "Container", "$", "container", ")", "{", "$", "container", "[", "'spot2.connections'", "]", "=", "[", "]", ";", "$", "container", "[", "'spot2.connections.default'", "]", "=", "null", ";", "$", "container", "[", "'spot2.config'", "]", "=", "function", "(", "Container", "$", "container", ")", "{", "$", "config", "=", "new", "Config", "(", ")", ";", "foreach", "(", "$", "container", "[", "'spot2.connections'", "]", "as", "$", "name", "=>", "$", "data", ")", "{", "$", "default", "=", "(", "$", "container", "[", "'spot2.connections.default'", "]", "===", "$", "name", ")", "?", "true", ":", "false", ";", "$", "config", "->", "addConnection", "(", "$", "name", ",", "$", "data", ",", "$", "default", ")", ";", "}", "return", "$", "config", ";", "}", ";", "$", "container", "[", "'spot2.locator'", "]", "=", "function", "(", "Container", "$", "container", ")", "{", "return", "new", "Locator", "(", "$", "container", "[", "'spot2.config'", "]", ")", ";", "}", ";", "}" ]
Register this provider. The spot2.connections array can have an arbitrary number of connections in it. The array should use the following format: <code> $connections = [ 'my_sqlite' => 'sqlite://path/to/my_database.sqlite', 'my_sqlite' => [ 'dbname' => 'my_database', 'user' => 'username', 'password' => 'sshhh-secret', 'host' => 'localhost', 'drivers' => 'pdo_mysql' ] ]; </code> @param Pimple\Container $container @author Ronan Chilvers <ronan@d3r.com>
[ "Register", "this", "provider", "." ]
9b13856d9560f13604ad885ee4c94e374d5e3635
https://github.com/ronanchilvers/silex-spot2-provider/blob/9b13856d9560f13604ad885ee4c94e374d5e3635/src/Provider/Spot2ServiceProvider.php#L45-L61
238,757
setrun/setrun-component-sys
src/controllers/backend/LanguageController.php
LanguageController.actionEdit
public function actionEdit($id) { $model = $this->findModel($id); $form = new LanguageForm($model); if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())){ if (!$errors = ActiveForm::validate($form)) { try { $this->service->edit($form->id, $form); $this->output['status'] = 1; } catch (YiiException $e) { $errors = ErrorHelper::checkModel($e->data, $form); } } return $this->output['errors'] = $errors; } return $this->render('edit', ['model' => $form]); }
php
public function actionEdit($id) { $model = $this->findModel($id); $form = new LanguageForm($model); if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())){ if (!$errors = ActiveForm::validate($form)) { try { $this->service->edit($form->id, $form); $this->output['status'] = 1; } catch (YiiException $e) { $errors = ErrorHelper::checkModel($e->data, $form); } } return $this->output['errors'] = $errors; } return $this->render('edit', ['model' => $form]); }
[ "public", "function", "actionEdit", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "form", "=", "new", "LanguageForm", "(", "$", "model", ")", ";", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", "&&", "$", "form", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", ")", "{", "if", "(", "!", "$", "errors", "=", "ActiveForm", "::", "validate", "(", "$", "form", ")", ")", "{", "try", "{", "$", "this", "->", "service", "->", "edit", "(", "$", "form", "->", "id", ",", "$", "form", ")", ";", "$", "this", "->", "output", "[", "'status'", "]", "=", "1", ";", "}", "catch", "(", "YiiException", "$", "e", ")", "{", "$", "errors", "=", "ErrorHelper", "::", "checkModel", "(", "$", "e", "->", "data", ",", "$", "form", ")", ";", "}", "}", "return", "$", "this", "->", "output", "[", "'errors'", "]", "=", "$", "errors", ";", "}", "return", "$", "this", "->", "render", "(", "'edit'", ",", "[", "'model'", "=>", "$", "form", "]", ")", ";", "}" ]
Edites an existing Language model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Edites", "an", "existing", "Language", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/controllers/backend/LanguageController.php#L96-L112
238,758
n0m4dz/laracasa
Zend/Gdata/AuthSub.php
Zend_Gdata_AuthSub.getAuthSubTokenUri
public static function getAuthSubTokenUri($next, $scope, $secure=0, $session=0, $request_uri = self::AUTHSUB_REQUEST_URI) { $querystring = '?next=' . urlencode($next) . '&scope=' . urldecode($scope) . '&secure=' . urlencode($secure) . '&session=' . urlencode($session); return $request_uri . $querystring; }
php
public static function getAuthSubTokenUri($next, $scope, $secure=0, $session=0, $request_uri = self::AUTHSUB_REQUEST_URI) { $querystring = '?next=' . urlencode($next) . '&scope=' . urldecode($scope) . '&secure=' . urlencode($secure) . '&session=' . urlencode($session); return $request_uri . $querystring; }
[ "public", "static", "function", "getAuthSubTokenUri", "(", "$", "next", ",", "$", "scope", ",", "$", "secure", "=", "0", ",", "$", "session", "=", "0", ",", "$", "request_uri", "=", "self", "::", "AUTHSUB_REQUEST_URI", ")", "{", "$", "querystring", "=", "'?next='", ".", "urlencode", "(", "$", "next", ")", ".", "'&scope='", ".", "urldecode", "(", "$", "scope", ")", ".", "'&secure='", ".", "urlencode", "(", "$", "secure", ")", ".", "'&session='", ".", "urlencode", "(", "$", "session", ")", ";", "return", "$", "request_uri", ".", "$", "querystring", ";", "}" ]
Creates a URI to request a single-use AuthSub token. @param string $next (required) URL identifying the service to be accessed. The resulting token will enable access to the specified service only. Some services may limit scope further, such as read-only access. @param string $scope (required) URL identifying the service to be accessed. The resulting token will enable access to the specified service only. Some services may limit scope further, such as read-only access. @param int $secure (optional) Boolean flag indicating whether the authentication transaction should issue a secure token (1) or a non-secure token (0). Secure tokens are available to registered applications only. @param int $session (optional) Boolean flag indicating whether the one-time-use token may be exchanged for a session token (1) or not (0). @param string $request_uri (optional) URI to which to direct the authentication request.
[ "Creates", "a", "URI", "to", "request", "a", "single", "-", "use", "AuthSub", "token", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L79-L87
238,759
n0m4dz/laracasa
Zend/Gdata/AuthSub.php
Zend_Gdata_AuthSub.getAuthSubSessionToken
public static function getAuthSubSessionToken( $token, $client = null, $request_uri = self::AUTHSUB_SESSION_TOKEN_URI) { $client = self::getHttpClient($token, $client); if ($client instanceof Zend_Gdata_HttpClient) { $filterResult = $client->filterHttpRequest('GET', $request_uri); $url = $filterResult['url']; $headers = $filterResult['headers']; $client->setHeaders($headers); $client->setUri($url); } else { $client->setUri($request_uri); } try { $response = $client->request('GET'); } catch (Zend_Http_Client_Exception $e) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException($e->getMessage(), $e); } // Parse Google's response if ($response->isSuccessful()) { $goog_resp = array(); foreach (explode("\n", $response->getBody()) as $l) { $l = chop($l); if ($l) { list($key, $val) = explode('=', chop($l), 2); $goog_resp[$key] = $val; } } return $goog_resp['Token']; } else { require_once 'Zend/Gdata/App/AuthException.php'; throw new Zend_Gdata_App_AuthException( 'Token upgrade failed. Reason: ' . $response->getBody()); } }
php
public static function getAuthSubSessionToken( $token, $client = null, $request_uri = self::AUTHSUB_SESSION_TOKEN_URI) { $client = self::getHttpClient($token, $client); if ($client instanceof Zend_Gdata_HttpClient) { $filterResult = $client->filterHttpRequest('GET', $request_uri); $url = $filterResult['url']; $headers = $filterResult['headers']; $client->setHeaders($headers); $client->setUri($url); } else { $client->setUri($request_uri); } try { $response = $client->request('GET'); } catch (Zend_Http_Client_Exception $e) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException($e->getMessage(), $e); } // Parse Google's response if ($response->isSuccessful()) { $goog_resp = array(); foreach (explode("\n", $response->getBody()) as $l) { $l = chop($l); if ($l) { list($key, $val) = explode('=', chop($l), 2); $goog_resp[$key] = $val; } } return $goog_resp['Token']; } else { require_once 'Zend/Gdata/App/AuthException.php'; throw new Zend_Gdata_App_AuthException( 'Token upgrade failed. Reason: ' . $response->getBody()); } }
[ "public", "static", "function", "getAuthSubSessionToken", "(", "$", "token", ",", "$", "client", "=", "null", ",", "$", "request_uri", "=", "self", "::", "AUTHSUB_SESSION_TOKEN_URI", ")", "{", "$", "client", "=", "self", "::", "getHttpClient", "(", "$", "token", ",", "$", "client", ")", ";", "if", "(", "$", "client", "instanceof", "Zend_Gdata_HttpClient", ")", "{", "$", "filterResult", "=", "$", "client", "->", "filterHttpRequest", "(", "'GET'", ",", "$", "request_uri", ")", ";", "$", "url", "=", "$", "filterResult", "[", "'url'", "]", ";", "$", "headers", "=", "$", "filterResult", "[", "'headers'", "]", ";", "$", "client", "->", "setHeaders", "(", "$", "headers", ")", ";", "$", "client", "->", "setUri", "(", "$", "url", ")", ";", "}", "else", "{", "$", "client", "->", "setUri", "(", "$", "request_uri", ")", ";", "}", "try", "{", "$", "response", "=", "$", "client", "->", "request", "(", "'GET'", ")", ";", "}", "catch", "(", "Zend_Http_Client_Exception", "$", "e", ")", "{", "require_once", "'Zend/Gdata/App/HttpException.php'", ";", "throw", "new", "Zend_Gdata_App_HttpException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", ")", ";", "}", "// Parse Google's response", "if", "(", "$", "response", "->", "isSuccessful", "(", ")", ")", "{", "$", "goog_resp", "=", "array", "(", ")", ";", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "response", "->", "getBody", "(", ")", ")", "as", "$", "l", ")", "{", "$", "l", "=", "chop", "(", "$", "l", ")", ";", "if", "(", "$", "l", ")", "{", "list", "(", "$", "key", ",", "$", "val", ")", "=", "explode", "(", "'='", ",", "chop", "(", "$", "l", ")", ",", "2", ")", ";", "$", "goog_resp", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "return", "$", "goog_resp", "[", "'Token'", "]", ";", "}", "else", "{", "require_once", "'Zend/Gdata/App/AuthException.php'", ";", "throw", "new", "Zend_Gdata_App_AuthException", "(", "'Token upgrade failed. Reason: '", ".", "$", "response", "->", "getBody", "(", ")", ")", ";", "}", "}" ]
Upgrades a single use token to a session token @param string $token The single use token which is to be upgraded @param Zend_Http_Client $client (optional) HTTP client to use to make the request @param string $request_uri (optional) URI to which to direct the session token upgrade @return string The upgraded token value @throws Zend_Gdata_App_AuthException @throws Zend_Gdata_App_HttpException
[ "Upgrades", "a", "single", "use", "token", "to", "a", "session", "token" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L102-L141
238,760
n0m4dz/laracasa
Zend/Gdata/AuthSub.php
Zend_Gdata_AuthSub.AuthSubRevokeToken
public static function AuthSubRevokeToken($token, $client = null, $request_uri = self::AUTHSUB_REVOKE_TOKEN_URI) { $client = self::getHttpClient($token, $client); if ($client instanceof Zend_Gdata_HttpClient) { $filterResult = $client->filterHttpRequest('GET', $request_uri); $url = $filterResult['url']; $headers = $filterResult['headers']; $client->setHeaders($headers); $client->setUri($url); $client->resetParameters(); } else { $client->setUri($request_uri); } ob_start(); try { $response = $client->request('GET'); } catch (Zend_Http_Client_Exception $e) { ob_end_clean(); require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException($e->getMessage(), $e); } ob_end_clean(); // Parse Google's response if ($response->isSuccessful()) { return true; } else { return false; } }
php
public static function AuthSubRevokeToken($token, $client = null, $request_uri = self::AUTHSUB_REVOKE_TOKEN_URI) { $client = self::getHttpClient($token, $client); if ($client instanceof Zend_Gdata_HttpClient) { $filterResult = $client->filterHttpRequest('GET', $request_uri); $url = $filterResult['url']; $headers = $filterResult['headers']; $client->setHeaders($headers); $client->setUri($url); $client->resetParameters(); } else { $client->setUri($request_uri); } ob_start(); try { $response = $client->request('GET'); } catch (Zend_Http_Client_Exception $e) { ob_end_clean(); require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException($e->getMessage(), $e); } ob_end_clean(); // Parse Google's response if ($response->isSuccessful()) { return true; } else { return false; } }
[ "public", "static", "function", "AuthSubRevokeToken", "(", "$", "token", ",", "$", "client", "=", "null", ",", "$", "request_uri", "=", "self", "::", "AUTHSUB_REVOKE_TOKEN_URI", ")", "{", "$", "client", "=", "self", "::", "getHttpClient", "(", "$", "token", ",", "$", "client", ")", ";", "if", "(", "$", "client", "instanceof", "Zend_Gdata_HttpClient", ")", "{", "$", "filterResult", "=", "$", "client", "->", "filterHttpRequest", "(", "'GET'", ",", "$", "request_uri", ")", ";", "$", "url", "=", "$", "filterResult", "[", "'url'", "]", ";", "$", "headers", "=", "$", "filterResult", "[", "'headers'", "]", ";", "$", "client", "->", "setHeaders", "(", "$", "headers", ")", ";", "$", "client", "->", "setUri", "(", "$", "url", ")", ";", "$", "client", "->", "resetParameters", "(", ")", ";", "}", "else", "{", "$", "client", "->", "setUri", "(", "$", "request_uri", ")", ";", "}", "ob_start", "(", ")", ";", "try", "{", "$", "response", "=", "$", "client", "->", "request", "(", "'GET'", ")", ";", "}", "catch", "(", "Zend_Http_Client_Exception", "$", "e", ")", "{", "ob_end_clean", "(", ")", ";", "require_once", "'Zend/Gdata/App/HttpException.php'", ";", "throw", "new", "Zend_Gdata_App_HttpException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", ")", ";", "}", "ob_end_clean", "(", ")", ";", "// Parse Google's response", "if", "(", "$", "response", "->", "isSuccessful", "(", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Revoke a token @param string $token The token to revoke @param Zend_Http_Client $client (optional) HTTP client to use to make the request @param string $request_uri (optional) URI to which to direct the revokation request @return boolean Whether the revokation was successful @throws Zend_Gdata_App_HttpException
[ "Revoke", "a", "token" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L152-L183
238,761
n0m4dz/laracasa
Zend/Gdata/AuthSub.php
Zend_Gdata_AuthSub.getAuthSubTokenInfo
public static function getAuthSubTokenInfo( $token, $client = null, $request_uri = self::AUTHSUB_TOKEN_INFO_URI) { $client = self::getHttpClient($token, $client); if ($client instanceof Zend_Gdata_HttpClient) { $filterResult = $client->filterHttpRequest('GET', $request_uri); $url = $filterResult['url']; $headers = $filterResult['headers']; $client->setHeaders($headers); $client->setUri($url); } else { $client->setUri($request_uri); } ob_start(); try { $response = $client->request('GET'); } catch (Zend_Http_Client_Exception $e) { ob_end_clean(); require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException($e->getMessage(), $e); } ob_end_clean(); return $response->getBody(); }
php
public static function getAuthSubTokenInfo( $token, $client = null, $request_uri = self::AUTHSUB_TOKEN_INFO_URI) { $client = self::getHttpClient($token, $client); if ($client instanceof Zend_Gdata_HttpClient) { $filterResult = $client->filterHttpRequest('GET', $request_uri); $url = $filterResult['url']; $headers = $filterResult['headers']; $client->setHeaders($headers); $client->setUri($url); } else { $client->setUri($request_uri); } ob_start(); try { $response = $client->request('GET'); } catch (Zend_Http_Client_Exception $e) { ob_end_clean(); require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException($e->getMessage(), $e); } ob_end_clean(); return $response->getBody(); }
[ "public", "static", "function", "getAuthSubTokenInfo", "(", "$", "token", ",", "$", "client", "=", "null", ",", "$", "request_uri", "=", "self", "::", "AUTHSUB_TOKEN_INFO_URI", ")", "{", "$", "client", "=", "self", "::", "getHttpClient", "(", "$", "token", ",", "$", "client", ")", ";", "if", "(", "$", "client", "instanceof", "Zend_Gdata_HttpClient", ")", "{", "$", "filterResult", "=", "$", "client", "->", "filterHttpRequest", "(", "'GET'", ",", "$", "request_uri", ")", ";", "$", "url", "=", "$", "filterResult", "[", "'url'", "]", ";", "$", "headers", "=", "$", "filterResult", "[", "'headers'", "]", ";", "$", "client", "->", "setHeaders", "(", "$", "headers", ")", ";", "$", "client", "->", "setUri", "(", "$", "url", ")", ";", "}", "else", "{", "$", "client", "->", "setUri", "(", "$", "request_uri", ")", ";", "}", "ob_start", "(", ")", ";", "try", "{", "$", "response", "=", "$", "client", "->", "request", "(", "'GET'", ")", ";", "}", "catch", "(", "Zend_Http_Client_Exception", "$", "e", ")", "{", "ob_end_clean", "(", ")", ";", "require_once", "'Zend/Gdata/App/HttpException.php'", ";", "throw", "new", "Zend_Gdata_App_HttpException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", ")", ";", "}", "ob_end_clean", "(", ")", ";", "return", "$", "response", "->", "getBody", "(", ")", ";", "}" ]
get token information @param string $token The token to retrieve information about @param Zend_Http_Client $client (optional) HTTP client to use to make the request @param string $request_uri (optional) URI to which to direct the information request
[ "get", "token", "information" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L195-L220
238,762
n0m4dz/laracasa
Zend/Gdata/AuthSub.php
Zend_Gdata_AuthSub.getHttpClient
public static function getHttpClient($token, $client = null) { if ($client == null) { $client = new Zend_Gdata_HttpClient(); } if (!$client instanceof Zend_Gdata_HttpClient) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException('Client is not an instance of Zend_Gdata_HttpClient.'); } $useragent = 'Zend_Framework_Gdata/' . Zend_Version::VERSION; $client->setConfig(array( 'strictredirects' => true, 'useragent' => $useragent ) ); $client->setAuthSubToken($token); return $client; }
php
public static function getHttpClient($token, $client = null) { if ($client == null) { $client = new Zend_Gdata_HttpClient(); } if (!$client instanceof Zend_Gdata_HttpClient) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException('Client is not an instance of Zend_Gdata_HttpClient.'); } $useragent = 'Zend_Framework_Gdata/' . Zend_Version::VERSION; $client->setConfig(array( 'strictredirects' => true, 'useragent' => $useragent ) ); $client->setAuthSubToken($token); return $client; }
[ "public", "static", "function", "getHttpClient", "(", "$", "token", ",", "$", "client", "=", "null", ")", "{", "if", "(", "$", "client", "==", "null", ")", "{", "$", "client", "=", "new", "Zend_Gdata_HttpClient", "(", ")", ";", "}", "if", "(", "!", "$", "client", "instanceof", "Zend_Gdata_HttpClient", ")", "{", "require_once", "'Zend/Gdata/App/HttpException.php'", ";", "throw", "new", "Zend_Gdata_App_HttpException", "(", "'Client is not an instance of Zend_Gdata_HttpClient.'", ")", ";", "}", "$", "useragent", "=", "'Zend_Framework_Gdata/'", ".", "Zend_Version", "::", "VERSION", ";", "$", "client", "->", "setConfig", "(", "array", "(", "'strictredirects'", "=>", "true", ",", "'useragent'", "=>", "$", "useragent", ")", ")", ";", "$", "client", "->", "setAuthSubToken", "(", "$", "token", ")", ";", "return", "$", "client", ";", "}" ]
Retrieve a HTTP client object with AuthSub credentials attached as the Authorization header @param string $token The token to retrieve information about @param Zend_Gdata_HttpClient $client (optional) HTTP client to use to make the request
[ "Retrieve", "a", "HTTP", "client", "object", "with", "AuthSub", "credentials", "attached", "as", "the", "Authorization", "header" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L229-L246
238,763
easy-system/es-dispatcher
src/Listener/DispatchesControllerListener.php
DispatchesControllerListener.onDispatch
public function onDispatch(SystemEvent $event) { $server = $this->getServer(); $request = $server->getRequest(); $controllerName = $request->getAttribute('controller'); if (! $controllerName) { throw new RuntimeException( 'Unable to dispatch the system event, the server request not ' . 'contains the "controller" attribute.' ); } $actionName = $request->getAttribute('action', 'index'); $events = $this->getEvents(); $controllers = $this->getControllers(); $controller = $controllers->get($controllerName); $event->setContext($controller); $dispatchEvent = new DispatchEvent( $controller, $controllerName, $actionName, $event->getParams() ); $events->trigger($dispatchEvent); $result = $dispatchEvent->getResult(); $target = SystemEvent::DISPATCH; if ($result instanceof ResponseInterface) { $target = SystemEvent::FINISH; } $event->setResult($target, $result); }
php
public function onDispatch(SystemEvent $event) { $server = $this->getServer(); $request = $server->getRequest(); $controllerName = $request->getAttribute('controller'); if (! $controllerName) { throw new RuntimeException( 'Unable to dispatch the system event, the server request not ' . 'contains the "controller" attribute.' ); } $actionName = $request->getAttribute('action', 'index'); $events = $this->getEvents(); $controllers = $this->getControllers(); $controller = $controllers->get($controllerName); $event->setContext($controller); $dispatchEvent = new DispatchEvent( $controller, $controllerName, $actionName, $event->getParams() ); $events->trigger($dispatchEvent); $result = $dispatchEvent->getResult(); $target = SystemEvent::DISPATCH; if ($result instanceof ResponseInterface) { $target = SystemEvent::FINISH; } $event->setResult($target, $result); }
[ "public", "function", "onDispatch", "(", "SystemEvent", "$", "event", ")", "{", "$", "server", "=", "$", "this", "->", "getServer", "(", ")", ";", "$", "request", "=", "$", "server", "->", "getRequest", "(", ")", ";", "$", "controllerName", "=", "$", "request", "->", "getAttribute", "(", "'controller'", ")", ";", "if", "(", "!", "$", "controllerName", ")", "{", "throw", "new", "RuntimeException", "(", "'Unable to dispatch the system event, the server request not '", ".", "'contains the \"controller\" attribute.'", ")", ";", "}", "$", "actionName", "=", "$", "request", "->", "getAttribute", "(", "'action'", ",", "'index'", ")", ";", "$", "events", "=", "$", "this", "->", "getEvents", "(", ")", ";", "$", "controllers", "=", "$", "this", "->", "getControllers", "(", ")", ";", "$", "controller", "=", "$", "controllers", "->", "get", "(", "$", "controllerName", ")", ";", "$", "event", "->", "setContext", "(", "$", "controller", ")", ";", "$", "dispatchEvent", "=", "new", "DispatchEvent", "(", "$", "controller", ",", "$", "controllerName", ",", "$", "actionName", ",", "$", "event", "->", "getParams", "(", ")", ")", ";", "$", "events", "->", "trigger", "(", "$", "dispatchEvent", ")", ";", "$", "result", "=", "$", "dispatchEvent", "->", "getResult", "(", ")", ";", "$", "target", "=", "SystemEvent", "::", "DISPATCH", ";", "if", "(", "$", "result", "instanceof", "ResponseInterface", ")", "{", "$", "target", "=", "SystemEvent", "::", "FINISH", ";", "}", "$", "event", "->", "setResult", "(", "$", "target", ",", "$", "result", ")", ";", "}" ]
Triggers the DispatchEvent. @param \Es\System\SystemEvent $event The system event @throws \RuntimeException If the ServerRequest not contain the "controller" attribute
[ "Triggers", "the", "DispatchEvent", "." ]
3a2420113c72e544e15c1500717c918e7d5d4bf8
https://github.com/easy-system/es-dispatcher/blob/3a2420113c72e544e15c1500717c918e7d5d4bf8/src/Listener/DispatchesControllerListener.php#L35-L66
238,764
easy-system/es-dispatcher
src/Listener/DispatchesControllerListener.php
DispatchesControllerListener.doDispatch
public function doDispatch(DispatchEvent $event) { $controller = $event->getContext(); $action = $event->getParam('action') . 'Action'; $server = $this->getServer(); $request = $server->getRequest()->withAddedAttributes($event->getParams()); $response = $server->getResponse(); $result = call_user_func_array([$controller, $action], [$request, $response]); $event->setResult($result); }
php
public function doDispatch(DispatchEvent $event) { $controller = $event->getContext(); $action = $event->getParam('action') . 'Action'; $server = $this->getServer(); $request = $server->getRequest()->withAddedAttributes($event->getParams()); $response = $server->getResponse(); $result = call_user_func_array([$controller, $action], [$request, $response]); $event->setResult($result); }
[ "public", "function", "doDispatch", "(", "DispatchEvent", "$", "event", ")", "{", "$", "controller", "=", "$", "event", "->", "getContext", "(", ")", ";", "$", "action", "=", "$", "event", "->", "getParam", "(", "'action'", ")", ".", "'Action'", ";", "$", "server", "=", "$", "this", "->", "getServer", "(", ")", ";", "$", "request", "=", "$", "server", "->", "getRequest", "(", ")", "->", "withAddedAttributes", "(", "$", "event", "->", "getParams", "(", ")", ")", ";", "$", "response", "=", "$", "server", "->", "getResponse", "(", ")", ";", "$", "result", "=", "call_user_func_array", "(", "[", "$", "controller", ",", "$", "action", "]", ",", "[", "$", "request", ",", "$", "response", "]", ")", ";", "$", "event", "->", "setResult", "(", "$", "result", ")", ";", "}" ]
Dispatch the controller. @param \Es\Dispatcher\DispatchEvent $event The event of dispatch
[ "Dispatch", "the", "controller", "." ]
3a2420113c72e544e15c1500717c918e7d5d4bf8
https://github.com/easy-system/es-dispatcher/blob/3a2420113c72e544e15c1500717c918e7d5d4bf8/src/Listener/DispatchesControllerListener.php#L73-L84
238,765
phossa2/libs
src/Phossa2/Cache/Utility/CachedCallable.php
CachedCallable.getTtlAndKey
protected function getTtlAndKey(array &$args)/*# : array */ { if (is_numeric($args[0])) { $ttl = (int) array_shift($args); $key = $this->generateKey($args); } else { $key = $this->generateKey($args); $ttl = $this->ttl; } return [$ttl, $key]; }
php
protected function getTtlAndKey(array &$args)/*# : array */ { if (is_numeric($args[0])) { $ttl = (int) array_shift($args); $key = $this->generateKey($args); } else { $key = $this->generateKey($args); $ttl = $this->ttl; } return [$ttl, $key]; }
[ "protected", "function", "getTtlAndKey", "(", "array", "&", "$", "args", ")", "/*# : array */", "{", "if", "(", "is_numeric", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "ttl", "=", "(", "int", ")", "array_shift", "(", "$", "args", ")", ";", "$", "key", "=", "$", "this", "->", "generateKey", "(", "$", "args", ")", ";", "}", "else", "{", "$", "key", "=", "$", "this", "->", "generateKey", "(", "$", "args", ")", ";", "$", "ttl", "=", "$", "this", "->", "ttl", ";", "}", "return", "[", "$", "ttl", ",", "$", "key", "]", ";", "}" ]
Get TTL and unique key @param array &$args @return array @access protected
[ "Get", "TTL", "and", "unique", "key" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Utility/CachedCallable.php#L112-L122
238,766
browserfs/base
src/Event.php
Event.create
public static function create( $eventName, $eventArgs = null ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected!'); } if ( null !== $eventArgs && !is_array( $eventArgs ) ) { throw new \browserfs\Exception('Invalid argument $eventArgs: any[] | null expected'); } return new static( $eventName, null === $eventArgs ? [] : array_values( $eventArgs ) ); }
php
public static function create( $eventName, $eventArgs = null ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected!'); } if ( null !== $eventArgs && !is_array( $eventArgs ) ) { throw new \browserfs\Exception('Invalid argument $eventArgs: any[] | null expected'); } return new static( $eventName, null === $eventArgs ? [] : array_values( $eventArgs ) ); }
[ "public", "static", "function", "create", "(", "$", "eventName", ",", "$", "eventArgs", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: string expected!'", ")", ";", "}", "if", "(", "null", "!==", "$", "eventArgs", "&&", "!", "is_array", "(", "$", "eventArgs", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventArgs: any[] | null expected'", ")", ";", "}", "return", "new", "static", "(", "$", "eventName", ",", "null", "===", "$", "eventArgs", "?", "[", "]", ":", "array_values", "(", "$", "eventArgs", ")", ")", ";", "}" ]
Creates a new event. Static constructor. @param eventName - string - the name of the event @param eventArgs - any[] | null - event arguments. @throws \browserfs\Exception - if arguments are invalid @return \browserfs\Event
[ "Creates", "a", "new", "event", ".", "Static", "constructor", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/Event.php#L84-L95
238,767
monomelodies/dabble
src/Adapter.php
Adapter.select
public function select($table, $fields, $where = [], $options = []) { if (is_scalar($fields)) { $fields = explode(',', $fields); } $query = new Select( $this, $table, $fields, new Where($where), new Options($options) ); return $query->execute(); }
php
public function select($table, $fields, $where = [], $options = []) { if (is_scalar($fields)) { $fields = explode(',', $fields); } $query = new Select( $this, $table, $fields, new Where($where), new Options($options) ); return $query->execute(); }
[ "public", "function", "select", "(", "$", "table", ",", "$", "fields", ",", "$", "where", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_scalar", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "explode", "(", "','", ",", "$", "fields", ")", ";", "}", "$", "query", "=", "new", "Select", "(", "$", "this", ",", "$", "table", ",", "$", "fields", ",", "new", "Where", "(", "$", "where", ")", ",", "new", "Options", "(", "$", "options", ")", ")", ";", "return", "$", "query", "->", "execute", "(", ")", ";", "}" ]
Select rows from a table. @param string $table The table(s) to query. @param mixed $fields The field (column) to query. @param mixed $where The where-clause. @param mixed $options The options (limit, offset etc.). @return function A lambda allowing you to access the found rows. @throws Dabble\Query\SelectException when no rows found. @throws Dabble\Query\SqlException on error.
[ "Select", "rows", "from", "a", "table", "." ]
4ba771cf90116b61821af8d15652cb6e5665e4b7
https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L213-L226
238,768
monomelodies/dabble
src/Adapter.php
Adapter.fetch
public function fetch($table, $fields, $where = null, $options = []) { $options['limit'] = 1; if (!isset($options['offset'])) { $options['offset'] = 0; } $result = $this->select($table, $fields, $where, $options); foreach ($result as $row) { return $row; } }
php
public function fetch($table, $fields, $where = null, $options = []) { $options['limit'] = 1; if (!isset($options['offset'])) { $options['offset'] = 0; } $result = $this->select($table, $fields, $where, $options); foreach ($result as $row) { return $row; } }
[ "public", "function", "fetch", "(", "$", "table", ",", "$", "fields", ",", "$", "where", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'limit'", "]", "=", "1", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'offset'", "]", ")", ")", "{", "$", "options", "[", "'offset'", "]", "=", "0", ";", "}", "$", "result", "=", "$", "this", "->", "select", "(", "$", "table", ",", "$", "fields", ",", "$", "where", ",", "$", "options", ")", ";", "foreach", "(", "$", "result", "as", "$", "row", ")", "{", "return", "$", "row", ";", "}", "}" ]
Retrieve a single row from the database. @param string $table The table(s) to query. @param string|array $fields The field(s) (column(s)) to query. @param array $where An SQL where-array. @param array $options Array of options. @return array An array containing the result. @throws Dabble\Query\SelectException when no row was found. @throws Dabble\Query\SqlException on error.
[ "Retrieve", "a", "single", "row", "from", "the", "database", "." ]
4ba771cf90116b61821af8d15652cb6e5665e4b7
https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L272-L282
238,769
monomelodies/dabble
src/Adapter.php
Adapter.column
public function column($table, $field, $where = null, $options = null) { $results = $this->fetch($table, $field, $where, $options); return array_shift($results); }
php
public function column($table, $field, $where = null, $options = null) { $results = $this->fetch($table, $field, $where, $options); return array_shift($results); }
[ "public", "function", "column", "(", "$", "table", ",", "$", "field", ",", "$", "where", "=", "null", ",", "$", "options", "=", "null", ")", "{", "$", "results", "=", "$", "this", "->", "fetch", "(", "$", "table", ",", "$", "field", ",", "$", "where", ",", "$", "options", ")", ";", "return", "array_shift", "(", "$", "results", ")", ";", "}" ]
Retrieve a single value from a single column. @param string $table The table(s) to query. @param string $field The field (column) to query. @param array $where An SQL where-array. @param array $options Array of options. @return mixed A scalar containing the result, or null. @throws Dabble\Query\SelectException when no row was found. @throws Dabble\Query\SqlException on error.
[ "Retrieve", "a", "single", "value", "from", "a", "single", "column", "." ]
4ba771cf90116b61821af8d15652cb6e5665e4b7
https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L295-L299
238,770
monomelodies/dabble
src/Adapter.php
Adapter.fetchObject
public function fetchObject( $class = null, $table, $fields, $where = null, $options = [] ) { if (is_null($class)) { $class = 'StdClass'; } elseif (is_object($class)) { $class = get_class($class); } if (is_scalar($fields)) { $fields = explode(',', $fields); } $query = new Select( $this, $table, $fields, new Where($where), new Options($options) ); $stmt = $this->prepare($query->__toString()); $stmt->execute($query->getBindings()); $result = $stmt->fetchObject($class); if (!$result) { throw new SelectException($stmt->queryString); } return $result; }
php
public function fetchObject( $class = null, $table, $fields, $where = null, $options = [] ) { if (is_null($class)) { $class = 'StdClass'; } elseif (is_object($class)) { $class = get_class($class); } if (is_scalar($fields)) { $fields = explode(',', $fields); } $query = new Select( $this, $table, $fields, new Where($where), new Options($options) ); $stmt = $this->prepare($query->__toString()); $stmt->execute($query->getBindings()); $result = $stmt->fetchObject($class); if (!$result) { throw new SelectException($stmt->queryString); } return $result; }
[ "public", "function", "fetchObject", "(", "$", "class", "=", "null", ",", "$", "table", ",", "$", "fields", ",", "$", "where", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_null", "(", "$", "class", ")", ")", "{", "$", "class", "=", "'StdClass'", ";", "}", "elseif", "(", "is_object", "(", "$", "class", ")", ")", "{", "$", "class", "=", "get_class", "(", "$", "class", ")", ";", "}", "if", "(", "is_scalar", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "explode", "(", "','", ",", "$", "fields", ")", ";", "}", "$", "query", "=", "new", "Select", "(", "$", "this", ",", "$", "table", ",", "$", "fields", ",", "new", "Where", "(", "$", "where", ")", ",", "new", "Options", "(", "$", "options", ")", ")", ";", "$", "stmt", "=", "$", "this", "->", "prepare", "(", "$", "query", "->", "__toString", "(", ")", ")", ";", "$", "stmt", "->", "execute", "(", "$", "query", "->", "getBindings", "(", ")", ")", ";", "$", "result", "=", "$", "stmt", "->", "fetchObject", "(", "$", "class", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "SelectException", "(", "$", "stmt", "->", "queryString", ")", ";", "}", "return", "$", "result", ";", "}" ]
Retrieve a single row as an object. @param mixed $class Classname, object or null (defaults to StdClass) to select into. @param string $table The table(s) to query. @param string $field The field (column) to query. @param array $where An SQL where-array. @param array $options Array of options. @return mixed An object of the desired class initialized with the row's values. @throws Dabble\Query\SelectException when no row was found. @throws Dabble\Query\SqlException on error.
[ "Retrieve", "a", "single", "row", "as", "an", "object", "." ]
4ba771cf90116b61821af8d15652cb6e5665e4b7
https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L324-L354
238,771
monomelodies/dabble
src/Adapter.php
Adapter.update
public function update($table, array $fields, $where, $options = null) { $query = new Update( $this, $table, $fields, new Where($where), new Options($options) ); return $query->execute(); }
php
public function update($table, array $fields, $where, $options = null) { $query = new Update( $this, $table, $fields, new Where($where), new Options($options) ); return $query->execute(); }
[ "public", "function", "update", "(", "$", "table", ",", "array", "$", "fields", ",", "$", "where", ",", "$", "options", "=", "null", ")", "{", "$", "query", "=", "new", "Update", "(", "$", "this", ",", "$", "table", ",", "$", "fields", ",", "new", "Where", "(", "$", "where", ")", ",", "new", "Options", "(", "$", "options", ")", ")", ";", "return", "$", "query", "->", "execute", "(", ")", ";", "}" ]
Update one or more rows in the database. @param string $table The table to update. @param array $fields Array Field => value pairs to update. @param array $where Array of where statements to limit updates. @return integer The number of affected (updated) rows. @throws Dabble\Query\UpdateException if no rows were updated. @throws Dabble\Query\SqlException on error.
[ "Update", "one", "or", "more", "rows", "in", "the", "database", "." ]
4ba771cf90116b61821af8d15652cb6e5665e4b7
https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L392-L402
238,772
monomelodies/dabble
src/Adapter.php
Adapter.delete
public function delete($table, array $where) { $query = new Delete($this, $table, new Where($where)); return $query->execute(); }
php
public function delete($table, array $where) { $query = new Delete($this, $table, new Where($where)); return $query->execute(); }
[ "public", "function", "delete", "(", "$", "table", ",", "array", "$", "where", ")", "{", "$", "query", "=", "new", "Delete", "(", "$", "this", ",", "$", "table", ",", "new", "Where", "(", "$", "where", ")", ")", ";", "return", "$", "query", "->", "execute", "(", ")", ";", "}" ]
Delete a row from the database. @param string $table The table to delete from. @param array $where Array of where statements to limit deletes. @return int The number of deleted rows. @throws Dabble\Query\DeleteException if no rows were deleted. @throws Dabble\Query\SqlException on error.
[ "Delete", "a", "row", "from", "the", "database", "." ]
4ba771cf90116b61821af8d15652cb6e5665e4b7
https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L413-L417
238,773
rollun-com/rollun-permission
src/Permission/src/ConfigProvider.php
ConfigProvider.getDependencies
protected function getDependencies() { return [ 'factories' => [ PermissionMiddleware::class => PermissionMiddlewareFactory::class, ExpressiveRouteName::class => InvokableFactory::class, PermissionMiddleware::class => PermissionMiddlewareFactory::class, ResourceResolver::class => ResourceResolverAbstractFactory::class, RoleResolver::class => RoleResolverFactory::class, AclMiddleware::class => AclMiddlewareFactory::class, Acl::class => AclFromDataStoreFactory::class, UserRepository::class => UserRepositoryFactory::class, GuestAuthentication::class => GuestAuthenticationFactory::class, RedirectMiddleware::class => RedirectMiddlewareFactory::class, GoogleClient::class => GoogleClientFactory::class, ], 'aliases' => [ ConfigProvider::AUTHENTICATION_MIDDLEWARE_SERVICE => AuthenticationMiddleware::class, AuthenticationInterface::class => 'authenticationServiceChain', UserRepositoryInterface::class => UserRepository::class, self::RULE_DATASTORE_SERVICE => AclRulesTable::class, self::ROLE_DATASTORE_SERVICE => AclRolesTable::class, self::RESOURCE_DATASTORE_SERVICE => AclResourceTable::class, self::PRIVILEGE_DATASTORE_SERVICE => AclPrivilegeTable::class, self::USER_DATASTORE_SERVICE => AclUsersTable::class, self::USER_ROLE_DATASTORE_SERVICE => AclUserRolesTable::class, ], 'abstract_factories' => [ ResourceResolverAbstractFactory::class, RouteAttributeAbstractFactory::class, RouteNameAbstractFactory::class, MiddlewarePipeAbstractFactory::class, AuthenticationChainAbstractFactory::class, BasicAccessAbstractFactory::class, PhpSessionAbstractFactory::class, CredentialMiddlewareAbstractFactory::class, ], 'invokables' => [ PrivilegeResolver::class => PrivilegeResolver::class, AccessForbiddenHandler::class => AccessForbiddenHandler::class, ExpressiveRouteName::class => ExpressiveRouteName::class, ], ]; }
php
protected function getDependencies() { return [ 'factories' => [ PermissionMiddleware::class => PermissionMiddlewareFactory::class, ExpressiveRouteName::class => InvokableFactory::class, PermissionMiddleware::class => PermissionMiddlewareFactory::class, ResourceResolver::class => ResourceResolverAbstractFactory::class, RoleResolver::class => RoleResolverFactory::class, AclMiddleware::class => AclMiddlewareFactory::class, Acl::class => AclFromDataStoreFactory::class, UserRepository::class => UserRepositoryFactory::class, GuestAuthentication::class => GuestAuthenticationFactory::class, RedirectMiddleware::class => RedirectMiddlewareFactory::class, GoogleClient::class => GoogleClientFactory::class, ], 'aliases' => [ ConfigProvider::AUTHENTICATION_MIDDLEWARE_SERVICE => AuthenticationMiddleware::class, AuthenticationInterface::class => 'authenticationServiceChain', UserRepositoryInterface::class => UserRepository::class, self::RULE_DATASTORE_SERVICE => AclRulesTable::class, self::ROLE_DATASTORE_SERVICE => AclRolesTable::class, self::RESOURCE_DATASTORE_SERVICE => AclResourceTable::class, self::PRIVILEGE_DATASTORE_SERVICE => AclPrivilegeTable::class, self::USER_DATASTORE_SERVICE => AclUsersTable::class, self::USER_ROLE_DATASTORE_SERVICE => AclUserRolesTable::class, ], 'abstract_factories' => [ ResourceResolverAbstractFactory::class, RouteAttributeAbstractFactory::class, RouteNameAbstractFactory::class, MiddlewarePipeAbstractFactory::class, AuthenticationChainAbstractFactory::class, BasicAccessAbstractFactory::class, PhpSessionAbstractFactory::class, CredentialMiddlewareAbstractFactory::class, ], 'invokables' => [ PrivilegeResolver::class => PrivilegeResolver::class, AccessForbiddenHandler::class => AccessForbiddenHandler::class, ExpressiveRouteName::class => ExpressiveRouteName::class, ], ]; }
[ "protected", "function", "getDependencies", "(", ")", "{", "return", "[", "'factories'", "=>", "[", "PermissionMiddleware", "::", "class", "=>", "PermissionMiddlewareFactory", "::", "class", ",", "ExpressiveRouteName", "::", "class", "=>", "InvokableFactory", "::", "class", ",", "PermissionMiddleware", "::", "class", "=>", "PermissionMiddlewareFactory", "::", "class", ",", "ResourceResolver", "::", "class", "=>", "ResourceResolverAbstractFactory", "::", "class", ",", "RoleResolver", "::", "class", "=>", "RoleResolverFactory", "::", "class", ",", "AclMiddleware", "::", "class", "=>", "AclMiddlewareFactory", "::", "class", ",", "Acl", "::", "class", "=>", "AclFromDataStoreFactory", "::", "class", ",", "UserRepository", "::", "class", "=>", "UserRepositoryFactory", "::", "class", ",", "GuestAuthentication", "::", "class", "=>", "GuestAuthenticationFactory", "::", "class", ",", "RedirectMiddleware", "::", "class", "=>", "RedirectMiddlewareFactory", "::", "class", ",", "GoogleClient", "::", "class", "=>", "GoogleClientFactory", "::", "class", ",", "]", ",", "'aliases'", "=>", "[", "ConfigProvider", "::", "AUTHENTICATION_MIDDLEWARE_SERVICE", "=>", "AuthenticationMiddleware", "::", "class", ",", "AuthenticationInterface", "::", "class", "=>", "'authenticationServiceChain'", ",", "UserRepositoryInterface", "::", "class", "=>", "UserRepository", "::", "class", ",", "self", "::", "RULE_DATASTORE_SERVICE", "=>", "AclRulesTable", "::", "class", ",", "self", "::", "ROLE_DATASTORE_SERVICE", "=>", "AclRolesTable", "::", "class", ",", "self", "::", "RESOURCE_DATASTORE_SERVICE", "=>", "AclResourceTable", "::", "class", ",", "self", "::", "PRIVILEGE_DATASTORE_SERVICE", "=>", "AclPrivilegeTable", "::", "class", ",", "self", "::", "USER_DATASTORE_SERVICE", "=>", "AclUsersTable", "::", "class", ",", "self", "::", "USER_ROLE_DATASTORE_SERVICE", "=>", "AclUserRolesTable", "::", "class", ",", "]", ",", "'abstract_factories'", "=>", "[", "ResourceResolverAbstractFactory", "::", "class", ",", "RouteAttributeAbstractFactory", "::", "class", ",", "RouteNameAbstractFactory", "::", "class", ",", "MiddlewarePipeAbstractFactory", "::", "class", ",", "AuthenticationChainAbstractFactory", "::", "class", ",", "BasicAccessAbstractFactory", "::", "class", ",", "PhpSessionAbstractFactory", "::", "class", ",", "CredentialMiddlewareAbstractFactory", "::", "class", ",", "]", ",", "'invokables'", "=>", "[", "PrivilegeResolver", "::", "class", "=>", "PrivilegeResolver", "::", "class", ",", "AccessForbiddenHandler", "::", "class", "=>", "AccessForbiddenHandler", "::", "class", ",", "ExpressiveRouteName", "::", "class", "=>", "ExpressiveRouteName", "::", "class", ",", "]", ",", "]", ";", "}" ]
Returns the container dependencies @return array
[ "Returns", "the", "container", "dependencies" ]
9f58c814337fcfd1e52ecfbf496f95d276d8217e
https://github.com/rollun-com/rollun-permission/blob/9f58c814337fcfd1e52ecfbf496f95d276d8217e/src/Permission/src/ConfigProvider.php#L140-L184
238,774
binsoul/common
src/PropertyGenerator.php
PropertyGenerator.getGeneratedProperties
protected function getGeneratedProperties(): array { $reflectionObject = new \ReflectionObject($this); $properties = $reflectionObject->getProperties(\ReflectionProperty::IS_PUBLIC); $result = []; foreach ($properties as $property) { if (!$property->isPublic() || @$property->isDefault()) { continue; } $result[] = $property; } return $result; }
php
protected function getGeneratedProperties(): array { $reflectionObject = new \ReflectionObject($this); $properties = $reflectionObject->getProperties(\ReflectionProperty::IS_PUBLIC); $result = []; foreach ($properties as $property) { if (!$property->isPublic() || @$property->isDefault()) { continue; } $result[] = $property; } return $result; }
[ "protected", "function", "getGeneratedProperties", "(", ")", ":", "array", "{", "$", "reflectionObject", "=", "new", "\\", "ReflectionObject", "(", "$", "this", ")", ";", "$", "properties", "=", "$", "reflectionObject", "->", "getProperties", "(", "\\", "ReflectionProperty", "::", "IS_PUBLIC", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "if", "(", "!", "$", "property", "->", "isPublic", "(", ")", "||", "@", "$", "property", "->", "isDefault", "(", ")", ")", "{", "continue", ";", "}", "$", "result", "[", "]", "=", "$", "property", ";", "}", "return", "$", "result", ";", "}" ]
Returns an array of generated public properties. @return \ReflectionProperty[]
[ "Returns", "an", "array", "of", "generated", "public", "properties", "." ]
668a62dada22727c0b75e9484dce587d7a490889
https://github.com/binsoul/common/blob/668a62dada22727c0b75e9484dce587d7a490889/src/PropertyGenerator.php#L70-L84
238,775
binsoul/common
src/PropertyGenerator.php
PropertyGenerator.removeGeneratedProperties
protected function removeGeneratedProperties() { $properties = $this->getGeneratedProperties(); foreach ($properties as $property) { $name = $property->getName(); unset($this->{$name}); } }
php
protected function removeGeneratedProperties() { $properties = $this->getGeneratedProperties(); foreach ($properties as $property) { $name = $property->getName(); unset($this->{$name}); } }
[ "protected", "function", "removeGeneratedProperties", "(", ")", "{", "$", "properties", "=", "$", "this", "->", "getGeneratedProperties", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "name", "=", "$", "property", "->", "getName", "(", ")", ";", "unset", "(", "$", "this", "->", "{", "$", "name", "}", ")", ";", "}", "}" ]
Removes all generated public properties.
[ "Removes", "all", "generated", "public", "properties", "." ]
668a62dada22727c0b75e9484dce587d7a490889
https://github.com/binsoul/common/blob/668a62dada22727c0b75e9484dce587d7a490889/src/PropertyGenerator.php#L89-L97
238,776
vitodtagliente/pure-template
View.php
View.namespace
public static function namespace($key, $path){ if(!array_key_exists($key, self::$namespaces)) self::$namespaces[$key] = $path; }
php
public static function namespace($key, $path){ if(!array_key_exists($key, self::$namespaces)) self::$namespaces[$key] = $path; }
[ "public", "static", "function", "namespace", "(", "$", "key", ",", "$", "path", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "self", "::", "$", "namespaces", ")", ")", "self", "::", "$", "namespaces", "[", "$", "key", "]", "=", "$", "path", ";", "}" ]
specifica di namespace per le path
[ "specifica", "di", "namespace", "per", "le", "path" ]
d3f3e38d7e425a5f9f6e17df405037f6001ff3e9
https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/View.php#L54-L57
238,777
vitodtagliente/pure-template
View.php
View.render
public function render($direct_output = true) { // controlla che il file esista if($this->exists() == false) return false; // Carica il contenuto e imposta i parametri settati // come variabili di contesto extract($this->params); ob_start(); include($this->filename); $content = ob_get_contents(); ob_end_clean(); // view engines foreach($this->engines as $key => $engine) { $content = $engine->map($content, $this->params); } // pulisci l'output di eventuali sezioni non sovrascritte if($this->can_clear) { foreach (ViewUtility::find_rules($content, '@section', ')') as $rule) { $content = str_replace($rule, '', $content); } } // controlla se occorre produrre a schermo // o semplicemente ritornare il contenuto if($direct_output) { echo $content; return true; } else return $content; }
php
public function render($direct_output = true) { // controlla che il file esista if($this->exists() == false) return false; // Carica il contenuto e imposta i parametri settati // come variabili di contesto extract($this->params); ob_start(); include($this->filename); $content = ob_get_contents(); ob_end_clean(); // view engines foreach($this->engines as $key => $engine) { $content = $engine->map($content, $this->params); } // pulisci l'output di eventuali sezioni non sovrascritte if($this->can_clear) { foreach (ViewUtility::find_rules($content, '@section', ')') as $rule) { $content = str_replace($rule, '', $content); } } // controlla se occorre produrre a schermo // o semplicemente ritornare il contenuto if($direct_output) { echo $content; return true; } else return $content; }
[ "public", "function", "render", "(", "$", "direct_output", "=", "true", ")", "{", "// controlla che il file esista", "if", "(", "$", "this", "->", "exists", "(", ")", "==", "false", ")", "return", "false", ";", "// Carica il contenuto e imposta i parametri settati", "// come variabili di contesto", "extract", "(", "$", "this", "->", "params", ")", ";", "ob_start", "(", ")", ";", "include", "(", "$", "this", "->", "filename", ")", ";", "$", "content", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "// view engines", "foreach", "(", "$", "this", "->", "engines", "as", "$", "key", "=>", "$", "engine", ")", "{", "$", "content", "=", "$", "engine", "->", "map", "(", "$", "content", ",", "$", "this", "->", "params", ")", ";", "}", "// pulisci l'output di eventuali sezioni non sovrascritte", "if", "(", "$", "this", "->", "can_clear", ")", "{", "foreach", "(", "ViewUtility", "::", "find_rules", "(", "$", "content", ",", "'@section'", ",", "')'", ")", "as", "$", "rule", ")", "{", "$", "content", "=", "str_replace", "(", "$", "rule", ",", "''", ",", "$", "content", ")", ";", "}", "}", "// controlla se occorre produrre a schermo", "// o semplicemente ritornare il contenuto", "if", "(", "$", "direct_output", ")", "{", "echo", "$", "content", ";", "return", "true", ";", "}", "else", "return", "$", "content", ";", "}" ]
genera la vista
[ "genera", "la", "vista" ]
d3f3e38d7e425a5f9f6e17df405037f6001ff3e9
https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/View.php#L92-L128
238,778
vitodtagliente/pure-template
View.php
View.make
public static function make($filename, $params = array(), $direct_output = true){ $view = new View($filename, $params); return $view->render($direct_output); }
php
public static function make($filename, $params = array(), $direct_output = true){ $view = new View($filename, $params); return $view->render($direct_output); }
[ "public", "static", "function", "make", "(", "$", "filename", ",", "$", "params", "=", "array", "(", ")", ",", "$", "direct_output", "=", "true", ")", "{", "$", "view", "=", "new", "View", "(", "$", "filename", ",", "$", "params", ")", ";", "return", "$", "view", "->", "render", "(", "$", "direct_output", ")", ";", "}" ]
funzione statica per la generazione di viste immediate
[ "funzione", "statica", "per", "la", "generazione", "di", "viste", "immediate" ]
d3f3e38d7e425a5f9f6e17df405037f6001ff3e9
https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/View.php#L139-L142
238,779
tacowordpress/util
src/Util/Html.php
Html.attribs
public static function attribs($attribs, $leading_space = true) { if (!Arr::iterable($attribs)) { return ''; } $out = array(); foreach ($attribs as $k => $v) { $v = (is_array($v)) ? join(' ', $v) : $v; $out[] = $k . '="' . str_replace('"', '\"', $v) . '"'; } return (($leading_space) ? ' ' : '') . join(' ', $out); }
php
public static function attribs($attribs, $leading_space = true) { if (!Arr::iterable($attribs)) { return ''; } $out = array(); foreach ($attribs as $k => $v) { $v = (is_array($v)) ? join(' ', $v) : $v; $out[] = $k . '="' . str_replace('"', '\"', $v) . '"'; } return (($leading_space) ? ' ' : '') . join(' ', $out); }
[ "public", "static", "function", "attribs", "(", "$", "attribs", ",", "$", "leading_space", "=", "true", ")", "{", "if", "(", "!", "Arr", "::", "iterable", "(", "$", "attribs", ")", ")", "{", "return", "''", ";", "}", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "attribs", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "v", "=", "(", "is_array", "(", "$", "v", ")", ")", "?", "join", "(", "' '", ",", "$", "v", ")", ":", "$", "v", ";", "$", "out", "[", "]", "=", "$", "k", ".", "'=\"'", ".", "str_replace", "(", "'\"'", ",", "'\\\"'", ",", "$", "v", ")", ".", "'\"'", ";", "}", "return", "(", "(", "$", "leading_space", ")", "?", "' '", ":", "''", ")", ".", "join", "(", "' '", ",", "$", "out", ")", ";", "}" ]
Get a string of attributes given the attributes as an array @param array $attribs @param $leading_space @return string
[ "Get", "a", "string", "of", "attributes", "given", "the", "attributes", "as", "an", "array" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L17-L29
238,780
tacowordpress/util
src/Util/Html.php
Html.image
public static function image($src, $alt = null, $attribs = array()) { $attribs = array_merge(array('src'=>$src), $attribs); if ($alt) { $attribs['alt'] = htmlentities($alt); } return self::tag('img', null, $attribs); }
php
public static function image($src, $alt = null, $attribs = array()) { $attribs = array_merge(array('src'=>$src), $attribs); if ($alt) { $attribs['alt'] = htmlentities($alt); } return self::tag('img', null, $attribs); }
[ "public", "static", "function", "image", "(", "$", "src", ",", "$", "alt", "=", "null", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "attribs", "=", "array_merge", "(", "array", "(", "'src'", "=>", "$", "src", ")", ",", "$", "attribs", ")", ";", "if", "(", "$", "alt", ")", "{", "$", "attribs", "[", "'alt'", "]", "=", "htmlentities", "(", "$", "alt", ")", ";", "}", "return", "self", "::", "tag", "(", "'img'", ",", "null", ",", "$", "attribs", ")", ";", "}" ]
Generate an img tag @param string $src @param string $alt @param array $attribs @return string
[ "Generate", "an", "img", "tag" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L74-L82
238,781
tacowordpress/util
src/Util/Html.php
Html.listy
public static function listy($items, $attribs = array(), $type = 'ul') { if (!Arr::iterable($items)) { return ''; } $htmls = array(); $htmls[] = '<' . $type . self::attribs($attribs) . '>'; foreach ($items as $item) { $htmls[] = '<li>' . $item . '</li>'; } $htmls[] = '</' . $type . '>'; return join("\n", $htmls); }
php
public static function listy($items, $attribs = array(), $type = 'ul') { if (!Arr::iterable($items)) { return ''; } $htmls = array(); $htmls[] = '<' . $type . self::attribs($attribs) . '>'; foreach ($items as $item) { $htmls[] = '<li>' . $item . '</li>'; } $htmls[] = '</' . $type . '>'; return join("\n", $htmls); }
[ "public", "static", "function", "listy", "(", "$", "items", ",", "$", "attribs", "=", "array", "(", ")", ",", "$", "type", "=", "'ul'", ")", "{", "if", "(", "!", "Arr", "::", "iterable", "(", "$", "items", ")", ")", "{", "return", "''", ";", "}", "$", "htmls", "=", "array", "(", ")", ";", "$", "htmls", "[", "]", "=", "'<'", ".", "$", "type", ".", "self", "::", "attribs", "(", "$", "attribs", ")", ".", "'>'", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "htmls", "[", "]", "=", "'<li>'", ".", "$", "item", ".", "'</li>'", ";", "}", "$", "htmls", "[", "]", "=", "'</'", ".", "$", "type", ".", "'>'", ";", "return", "join", "(", "\"\\n\"", ",", "$", "htmls", ")", ";", "}" ]
Get an HTML list @param array $items @param array $attribs @param string $type
[ "Get", "an", "HTML", "list" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L144-L157
238,782
tacowordpress/util
src/Util/Html.php
Html.alisty
public static function alisty($items, $attribs = array(), $type = 'ul', $active_title = null) { if (!Arr::iterable($items)) { return ''; } $htmls = array(); $htmls[] = '<' . $type . self::attribs($attribs) . '>'; foreach ($items as $title => $href) { $body = (is_array($href)) ? Html::a($title, $href) : Html::link($href, $title); $classes = array(Str::machine($title)); if ($active_title === $title) { $classes[] = 'active'; } $htmls[] = sprintf('<li class="%s">', join(' ', $classes)) . $body . '</li>'; } $htmls[] = '</' . $type . '>'; return join("\n", $htmls); }
php
public static function alisty($items, $attribs = array(), $type = 'ul', $active_title = null) { if (!Arr::iterable($items)) { return ''; } $htmls = array(); $htmls[] = '<' . $type . self::attribs($attribs) . '>'; foreach ($items as $title => $href) { $body = (is_array($href)) ? Html::a($title, $href) : Html::link($href, $title); $classes = array(Str::machine($title)); if ($active_title === $title) { $classes[] = 'active'; } $htmls[] = sprintf('<li class="%s">', join(' ', $classes)) . $body . '</li>'; } $htmls[] = '</' . $type . '>'; return join("\n", $htmls); }
[ "public", "static", "function", "alisty", "(", "$", "items", ",", "$", "attribs", "=", "array", "(", ")", ",", "$", "type", "=", "'ul'", ",", "$", "active_title", "=", "null", ")", "{", "if", "(", "!", "Arr", "::", "iterable", "(", "$", "items", ")", ")", "{", "return", "''", ";", "}", "$", "htmls", "=", "array", "(", ")", ";", "$", "htmls", "[", "]", "=", "'<'", ".", "$", "type", ".", "self", "::", "attribs", "(", "$", "attribs", ")", ".", "'>'", ";", "foreach", "(", "$", "items", "as", "$", "title", "=>", "$", "href", ")", "{", "$", "body", "=", "(", "is_array", "(", "$", "href", ")", ")", "?", "Html", "::", "a", "(", "$", "title", ",", "$", "href", ")", ":", "Html", "::", "link", "(", "$", "href", ",", "$", "title", ")", ";", "$", "classes", "=", "array", "(", "Str", "::", "machine", "(", "$", "title", ")", ")", ";", "if", "(", "$", "active_title", "===", "$", "title", ")", "{", "$", "classes", "[", "]", "=", "'active'", ";", "}", "$", "htmls", "[", "]", "=", "sprintf", "(", "'<li class=\"%s\">'", ",", "join", "(", "' '", ",", "$", "classes", ")", ")", ".", "$", "body", ".", "'</li>'", ";", "}", "$", "htmls", "[", "]", "=", "'</'", ".", "$", "type", ".", "'>'", ";", "return", "join", "(", "\"\\n\"", ",", "$", "htmls", ")", ";", "}" ]
Get an HTML list of links @param array $items @param array $attribs @param string $type @param string $active_title
[ "Get", "an", "HTML", "list", "of", "links" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L167-L187
238,783
tacowordpress/util
src/Util/Html.php
Html.selecty
public static function selecty($options, $selected = null, $attribs = array()) { $htmls = array(); $htmls[] = self::select(null, $attribs, false); if (Arr::iterable($options)) { foreach ($options as $value => $title) { $option_attribs = array('value'=>$value); if ((string) $selected === (string) $value) { $option_attribs['selected'] = 'selected'; } $htmls[] = self::option($title, $option_attribs); } } $htmls[] = '</select>'; return join("\n", $htmls); }
php
public static function selecty($options, $selected = null, $attribs = array()) { $htmls = array(); $htmls[] = self::select(null, $attribs, false); if (Arr::iterable($options)) { foreach ($options as $value => $title) { $option_attribs = array('value'=>$value); if ((string) $selected === (string) $value) { $option_attribs['selected'] = 'selected'; } $htmls[] = self::option($title, $option_attribs); } } $htmls[] = '</select>'; return join("\n", $htmls); }
[ "public", "static", "function", "selecty", "(", "$", "options", ",", "$", "selected", "=", "null", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "htmls", "=", "array", "(", ")", ";", "$", "htmls", "[", "]", "=", "self", "::", "select", "(", "null", ",", "$", "attribs", ",", "false", ")", ";", "if", "(", "Arr", "::", "iterable", "(", "$", "options", ")", ")", "{", "foreach", "(", "$", "options", "as", "$", "value", "=>", "$", "title", ")", "{", "$", "option_attribs", "=", "array", "(", "'value'", "=>", "$", "value", ")", ";", "if", "(", "(", "string", ")", "$", "selected", "===", "(", "string", ")", "$", "value", ")", "{", "$", "option_attribs", "[", "'selected'", "]", "=", "'selected'", ";", "}", "$", "htmls", "[", "]", "=", "self", "::", "option", "(", "$", "title", ",", "$", "option_attribs", ")", ";", "}", "}", "$", "htmls", "[", "]", "=", "'</select>'", ";", "return", "join", "(", "\"\\n\"", ",", "$", "htmls", ")", ";", "}" ]
Get a select list @param array $options @param string $selected @param array $attribs @return string
[ "Get", "a", "select", "list" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L197-L213
238,784
tacowordpress/util
src/Util/Html.php
Html.tably
public static function tably($records) { if (count($records) === 0) { return null; } $htmls = array(); $htmls[] = '<table>'; foreach ($records as $record) { $htmls[] = '<tr>'; foreach ($record as $k => $v) { $htmls[] = sprintf('<td class="%s">%s</td>', Str::machine($k), $v); } $htmls[] = '</tr>'; } $htmls[] = '</table>'; return join("\n", $htmls); }
php
public static function tably($records) { if (count($records) === 0) { return null; } $htmls = array(); $htmls[] = '<table>'; foreach ($records as $record) { $htmls[] = '<tr>'; foreach ($record as $k => $v) { $htmls[] = sprintf('<td class="%s">%s</td>', Str::machine($k), $v); } $htmls[] = '</tr>'; } $htmls[] = '</table>'; return join("\n", $htmls); }
[ "public", "static", "function", "tably", "(", "$", "records", ")", "{", "if", "(", "count", "(", "$", "records", ")", "===", "0", ")", "{", "return", "null", ";", "}", "$", "htmls", "=", "array", "(", ")", ";", "$", "htmls", "[", "]", "=", "'<table>'", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "htmls", "[", "]", "=", "'<tr>'", ";", "foreach", "(", "$", "record", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "htmls", "[", "]", "=", "sprintf", "(", "'<td class=\"%s\">%s</td>'", ",", "Str", "::", "machine", "(", "$", "k", ")", ",", "$", "v", ")", ";", "}", "$", "htmls", "[", "]", "=", "'</tr>'", ";", "}", "$", "htmls", "[", "]", "=", "'</table>'", ";", "return", "join", "(", "\"\\n\"", ",", "$", "htmls", ")", ";", "}" ]
Get a table @param array $records @return string
[ "Get", "a", "table" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L221-L238
238,785
donquixote/hasty-reflection-common
src/Reflection/ClassLike/AllInterfaces/AllInterfacesBase.php
AllInterfacesBase.getAllInterfaces
function getAllInterfaces($includeSelf) { if (NULL === $this->interfacesAll) { $this->interfacesAllInclSelf = $this->interfacesAll = $this->buildAllInterfacesWithoutSelf(); if (NULL !== $this->selfInterfaceName) { $selfInterface = $this->classIndex->classGetReflection($this->selfInterfaceName); if (NULL !== $selfInterface) { $this->interfacesAllInclSelf = array($this->selfInterfaceName => $selfInterface) + $this->interfacesAllInclSelf; } } } return $includeSelf ? $this->interfacesAllInclSelf : $this->interfacesAll; }
php
function getAllInterfaces($includeSelf) { if (NULL === $this->interfacesAll) { $this->interfacesAllInclSelf = $this->interfacesAll = $this->buildAllInterfacesWithoutSelf(); if (NULL !== $this->selfInterfaceName) { $selfInterface = $this->classIndex->classGetReflection($this->selfInterfaceName); if (NULL !== $selfInterface) { $this->interfacesAllInclSelf = array($this->selfInterfaceName => $selfInterface) + $this->interfacesAllInclSelf; } } } return $includeSelf ? $this->interfacesAllInclSelf : $this->interfacesAll; }
[ "function", "getAllInterfaces", "(", "$", "includeSelf", ")", "{", "if", "(", "NULL", "===", "$", "this", "->", "interfacesAll", ")", "{", "$", "this", "->", "interfacesAllInclSelf", "=", "$", "this", "->", "interfacesAll", "=", "$", "this", "->", "buildAllInterfacesWithoutSelf", "(", ")", ";", "if", "(", "NULL", "!==", "$", "this", "->", "selfInterfaceName", ")", "{", "$", "selfInterface", "=", "$", "this", "->", "classIndex", "->", "classGetReflection", "(", "$", "this", "->", "selfInterfaceName", ")", ";", "if", "(", "NULL", "!==", "$", "selfInterface", ")", "{", "$", "this", "->", "interfacesAllInclSelf", "=", "array", "(", "$", "this", "->", "selfInterfaceName", "=>", "$", "selfInterface", ")", "+", "$", "this", "->", "interfacesAllInclSelf", ";", "}", "}", "}", "return", "$", "includeSelf", "?", "$", "this", "->", "interfacesAllInclSelf", ":", "$", "this", "->", "interfacesAll", ";", "}" ]
Gets all interfaces directly or indirectly implemented by this class. Will include the class itself if it is an interface. @param bool $includeSelf @return \Donquixote\HastyReflectionCommon\Reflection\ClassLike\ClassLikeReflectionInterface[]
[ "Gets", "all", "interfaces", "directly", "or", "indirectly", "implemented", "by", "this", "class", "." ]
e1f4851a80fe82b90e8e145a01e26e90c7f6e3c2
https://github.com/donquixote/hasty-reflection-common/blob/e1f4851a80fe82b90e8e145a01e26e90c7f6e3c2/src/Reflection/ClassLike/AllInterfaces/AllInterfacesBase.php#L51-L64
238,786
zepi/turbo-base
Zepi/Web/General/src/Entity/MenuEntry.php
MenuEntry.hasVisibleChildren
public function hasVisibleChildren() { foreach ($this->children as $child) { if (!($child instanceof \Zepi\Web\General\Entity\HiddenMenuEntry)) { return true; } } return false; }
php
public function hasVisibleChildren() { foreach ($this->children as $child) { if (!($child instanceof \Zepi\Web\General\Entity\HiddenMenuEntry)) { return true; } } return false; }
[ "public", "function", "hasVisibleChildren", "(", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "!", "(", "$", "child", "instanceof", "\\", "Zepi", "\\", "Web", "\\", "General", "\\", "Entity", "\\", "HiddenMenuEntry", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if the menu entry has one or more children which are visible. Otherwise returns false. @access public @return boolean
[ "Returns", "true", "if", "the", "menu", "entry", "has", "one", "or", "more", "children", "which", "are", "visible", ".", "Otherwise", "returns", "false", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Entity/MenuEntry.php#L243-L252
238,787
zepi/turbo-base
Zepi/Web/General/src/Entity/MenuEntry.php
MenuEntry.shouldHide
public function shouldHide() { if (!$this->hideWhenEmpty) { return false; } foreach ($this->children as $child) { if (!$child->shouldHide()) { return false; } } return true; }
php
public function shouldHide() { if (!$this->hideWhenEmpty) { return false; } foreach ($this->children as $child) { if (!$child->shouldHide()) { return false; } } return true; }
[ "public", "function", "shouldHide", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hideWhenEmpty", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "!", "$", "child", "->", "shouldHide", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Returns true if the menu entry should be hidden @access public @return boolean
[ "Returns", "true", "if", "the", "menu", "entry", "should", "be", "hidden" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Entity/MenuEntry.php#L260-L273
238,788
zepi/turbo-base
Zepi/Web/General/src/Entity/MenuEntry.php
MenuEntry.addChild
public function addChild(MenuEntry $child) { if (isset($this->children[$child->getKey()])) { return false; } $this->children[$child->getKey()] = $child; // Sets this MenuEntry as parent of the child $child->setParent($this); return true; }
php
public function addChild(MenuEntry $child) { if (isset($this->children[$child->getKey()])) { return false; } $this->children[$child->getKey()] = $child; // Sets this MenuEntry as parent of the child $child->setParent($this); return true; }
[ "public", "function", "addChild", "(", "MenuEntry", "$", "child", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "children", "[", "$", "child", "->", "getKey", "(", ")", "]", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "children", "[", "$", "child", "->", "getKey", "(", ")", "]", "=", "$", "child", ";", "// Sets this MenuEntry as parent of the child", "$", "child", "->", "setParent", "(", "$", "this", ")", ";", "return", "true", ";", "}" ]
Adds a MenuEntry as child and add this MenuEntry as parent of the child. @access public @param \Zepi\Web\General\Entity\MenuEntry $child @return boolean
[ "Adds", "a", "MenuEntry", "as", "child", "and", "add", "this", "MenuEntry", "as", "parent", "of", "the", "child", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Entity/MenuEntry.php#L301-L313
238,789
zepi/turbo-base
Zepi/Web/General/src/Entity/MenuEntry.php
MenuEntry.getBestTarget
public function getBestTarget() { if ($this->hasParent() && ($this->target == '' || $this->target == '#')) { return $this->parent->getBestTarget(); } return $this->target; }
php
public function getBestTarget() { if ($this->hasParent() && ($this->target == '' || $this->target == '#')) { return $this->parent->getBestTarget(); } return $this->target; }
[ "public", "function", "getBestTarget", "(", ")", "{", "if", "(", "$", "this", "->", "hasParent", "(", ")", "&&", "(", "$", "this", "->", "target", "==", "''", "||", "$", "this", "->", "target", "==", "'#'", ")", ")", "{", "return", "$", "this", "->", "parent", "->", "getBestTarget", "(", ")", ";", "}", "return", "$", "this", "->", "target", ";", "}" ]
Returns the best available target, if the menu entry has no target the target of the parent object will be returned. @return string
[ "Returns", "the", "best", "available", "target", "if", "the", "menu", "entry", "has", "no", "target", "the", "target", "of", "the", "parent", "object", "will", "be", "returned", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Entity/MenuEntry.php#L354-L361
238,790
zepi/turbo-base
Zepi/Web/General/src/Entity/MenuEntry.php
MenuEntry.setActive
public function setActive($isActive) { $this->isActive = (bool) $isActive; if ($this->parent !== null) { $this->parent->setActive($isActive); } }
php
public function setActive($isActive) { $this->isActive = (bool) $isActive; if ($this->parent !== null) { $this->parent->setActive($isActive); } }
[ "public", "function", "setActive", "(", "$", "isActive", ")", "{", "$", "this", "->", "isActive", "=", "(", "bool", ")", "$", "isActive", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", ")", "{", "$", "this", "->", "parent", "->", "setActive", "(", "$", "isActive", ")", ";", "}", "}" ]
Sets the menu entry as active @access public @param boolean $isActive
[ "Sets", "the", "menu", "entry", "as", "active" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Entity/MenuEntry.php#L369-L376
238,791
jagilpe/entity-list-bundle
EntityList/Cell/SingleFieldCell.php
SingleFieldCell.getFieldGetter
protected function getFieldGetter(\ReflectionClass $reflectionClass, $fieldName) { foreach (array('get', 'is', 'has') as $prefix) { $getter = $prefix.ucfirst($fieldName); $reflectionMethod = $reflectionClass->getMethod($getter); if ($reflectionMethod && $reflectionMethod->isPublic()) { return $reflectionMethod; } } throw new EntityListException("The field $fieldName does not exist or is not accessible."); }
php
protected function getFieldGetter(\ReflectionClass $reflectionClass, $fieldName) { foreach (array('get', 'is', 'has') as $prefix) { $getter = $prefix.ucfirst($fieldName); $reflectionMethod = $reflectionClass->getMethod($getter); if ($reflectionMethod && $reflectionMethod->isPublic()) { return $reflectionMethod; } } throw new EntityListException("The field $fieldName does not exist or is not accessible."); }
[ "protected", "function", "getFieldGetter", "(", "\\", "ReflectionClass", "$", "reflectionClass", ",", "$", "fieldName", ")", "{", "foreach", "(", "array", "(", "'get'", ",", "'is'", ",", "'has'", ")", "as", "$", "prefix", ")", "{", "$", "getter", "=", "$", "prefix", ".", "ucfirst", "(", "$", "fieldName", ")", ";", "$", "reflectionMethod", "=", "$", "reflectionClass", "->", "getMethod", "(", "$", "getter", ")", ";", "if", "(", "$", "reflectionMethod", "&&", "$", "reflectionMethod", "->", "isPublic", "(", ")", ")", "{", "return", "$", "reflectionMethod", ";", "}", "}", "throw", "new", "EntityListException", "(", "\"The field $fieldName does not exist or is not accessible.\"", ")", ";", "}" ]
Returns the Reflection Method of the getter of the field @param \ReflectionClass $reflectionClass @param string $fieldName @throws EntityListException @return ReflectionMethod
[ "Returns", "the", "Reflection", "Method", "of", "the", "getter", "of", "the", "field" ]
54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc
https://github.com/jagilpe/entity-list-bundle/blob/54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc/EntityList/Cell/SingleFieldCell.php#L154-L166
238,792
bkdotcom/Form
src/Field.php
Field.build
public function build($propOverride = array()) { $this->debug->info(__METHOD__, $this->attribs['name']); if ($propOverride == 'tagOnly') { $propOverride = array('tagOnly' => true); } elseif (!\is_array($propOverride)) { $this->debug->warn('invalid propOverride', $propOverride, 'expect array or "tagOnly"'); $propOverride = array(); } if ($propOverride) { $this->props = $this->mergeProps(array( $this->props, $propOverride, )); } $return = $this->buildControl->build($this); return $return; }
php
public function build($propOverride = array()) { $this->debug->info(__METHOD__, $this->attribs['name']); if ($propOverride == 'tagOnly') { $propOverride = array('tagOnly' => true); } elseif (!\is_array($propOverride)) { $this->debug->warn('invalid propOverride', $propOverride, 'expect array or "tagOnly"'); $propOverride = array(); } if ($propOverride) { $this->props = $this->mergeProps(array( $this->props, $propOverride, )); } $return = $this->buildControl->build($this); return $return; }
[ "public", "function", "build", "(", "$", "propOverride", "=", "array", "(", ")", ")", "{", "$", "this", "->", "debug", "->", "info", "(", "__METHOD__", ",", "$", "this", "->", "attribs", "[", "'name'", "]", ")", ";", "if", "(", "$", "propOverride", "==", "'tagOnly'", ")", "{", "$", "propOverride", "=", "array", "(", "'tagOnly'", "=>", "true", ")", ";", "}", "elseif", "(", "!", "\\", "is_array", "(", "$", "propOverride", ")", ")", "{", "$", "this", "->", "debug", "->", "warn", "(", "'invalid propOverride'", ",", "$", "propOverride", ",", "'expect array or \"tagOnly\"'", ")", ";", "$", "propOverride", "=", "array", "(", ")", ";", "}", "if", "(", "$", "propOverride", ")", "{", "$", "this", "->", "props", "=", "$", "this", "->", "mergeProps", "(", "array", "(", "$", "this", "->", "props", ",", "$", "propOverride", ",", ")", ")", ";", "}", "$", "return", "=", "$", "this", "->", "buildControl", "->", "build", "(", "$", "this", ")", ";", "return", "$", "return", ";", "}" ]
Build html control @param array $propOverride properties to override @return string
[ "Build", "html", "control" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L93-L110
238,793
bkdotcom/Form
src/Field.php
Field.doValidate
public function doValidate() { $isValid = true; if ($this->props['validate']) { $isValid = \call_user_func($this->props['validate'], $this); } return $isValid; }
php
public function doValidate() { $isValid = true; if ($this->props['validate']) { $isValid = \call_user_func($this->props['validate'], $this); } return $isValid; }
[ "public", "function", "doValidate", "(", ")", "{", "$", "isValid", "=", "true", ";", "if", "(", "$", "this", "->", "props", "[", "'validate'", "]", ")", "{", "$", "isValid", "=", "\\", "call_user_func", "(", "$", "this", "->", "props", "[", "'validate'", "]", ",", "$", "this", ")", ";", "}", "return", "$", "isValid", ";", "}" ]
Extend me to perform custom validation @return boolean valid?
[ "Extend", "me", "to", "perform", "custom", "validation" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L141-L148
238,794
bkdotcom/Form
src/Field.php
Field.flag
public function flag($reason = null) { $this->props['isValid'] = false; $this->classAdd($this->props['attribsContainer'], 'has-error'); if ($this->attribs['type'] == 'file' && isset($this->form->currentValues[ $this->attribs['name'] ])) { $fileInfo = $this->form->currentValues[ $this->attribs['name'] ]; \unlink($fileInfo['tmp_name']); unset($this->form->currentValues[ $this->attribs['name'] ]); } if (!\is_null($reason)) { $this->props['invalidReason'] = $reason; } return; }
php
public function flag($reason = null) { $this->props['isValid'] = false; $this->classAdd($this->props['attribsContainer'], 'has-error'); if ($this->attribs['type'] == 'file' && isset($this->form->currentValues[ $this->attribs['name'] ])) { $fileInfo = $this->form->currentValues[ $this->attribs['name'] ]; \unlink($fileInfo['tmp_name']); unset($this->form->currentValues[ $this->attribs['name'] ]); } if (!\is_null($reason)) { $this->props['invalidReason'] = $reason; } return; }
[ "public", "function", "flag", "(", "$", "reason", "=", "null", ")", "{", "$", "this", "->", "props", "[", "'isValid'", "]", "=", "false", ";", "$", "this", "->", "classAdd", "(", "$", "this", "->", "props", "[", "'attribsContainer'", "]", ",", "'has-error'", ")", ";", "if", "(", "$", "this", "->", "attribs", "[", "'type'", "]", "==", "'file'", "&&", "isset", "(", "$", "this", "->", "form", "->", "currentValues", "[", "$", "this", "->", "attribs", "[", "'name'", "]", "]", ")", ")", "{", "$", "fileInfo", "=", "$", "this", "->", "form", "->", "currentValues", "[", "$", "this", "->", "attribs", "[", "'name'", "]", "]", ";", "\\", "unlink", "(", "$", "fileInfo", "[", "'tmp_name'", "]", ")", ";", "unset", "(", "$", "this", "->", "form", "->", "currentValues", "[", "$", "this", "->", "attribs", "[", "'name'", "]", "]", ")", ";", "}", "if", "(", "!", "\\", "is_null", "(", "$", "reason", ")", ")", "{", "$", "this", "->", "props", "[", "'invalidReason'", "]", "=", "$", "reason", ";", "}", "return", ";", "}" ]
Flag a field as invalid @param string $reason The reason that will be given to the user @return void
[ "Flag", "a", "field", "as", "invalid" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L157-L170
238,795
bkdotcom/Form
src/Field.php
Field.focus
public function focus() { if (\in_array($this->attribs['type'], array('checkbox', 'radio'))) { $keys = \array_keys($this->props['options']); $this->props['options'][ $keys[0] ]['autofocus'] = true; } else { $this->attribs['autofocus'] = true; } }
php
public function focus() { if (\in_array($this->attribs['type'], array('checkbox', 'radio'))) { $keys = \array_keys($this->props['options']); $this->props['options'][ $keys[0] ]['autofocus'] = true; } else { $this->attribs['autofocus'] = true; } }
[ "public", "function", "focus", "(", ")", "{", "if", "(", "\\", "in_array", "(", "$", "this", "->", "attribs", "[", "'type'", "]", ",", "array", "(", "'checkbox'", ",", "'radio'", ")", ")", ")", "{", "$", "keys", "=", "\\", "array_keys", "(", "$", "this", "->", "props", "[", "'options'", "]", ")", ";", "$", "this", "->", "props", "[", "'options'", "]", "[", "$", "keys", "[", "0", "]", "]", "[", "'autofocus'", "]", "=", "true", ";", "}", "else", "{", "$", "this", "->", "attribs", "[", "'autofocus'", "]", "=", "true", ";", "}", "}" ]
Sets autofocus attribute @return void
[ "Sets", "autofocus", "attribute" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L177-L185
238,796
bkdotcom/Form
src/Field.php
Field.getId
public function getId() { $id = $this->props['attribs']['id']; $sepChar = '_'; // character to join prefix and id $repChar = '_'; // replace \W with this char if (!$id && $this->props['attribs']['name']) { $id = \preg_replace('/\W/', $repChar, $this->props['attribs']['name']); $id = \preg_replace('/'.$repChar.'+/', $repChar, $id); $id = \trim($id, $repChar); if ($id && $this->props['idPrefix']) { $prefix = $this->props['idPrefix']; if (\preg_match('/[a-z]$/i', $prefix)) { $prefix = $prefix.$sepChar; } $id = $prefix.$id; } if ($id) { $this->props['attribs']['id'] = $id; } } return $id; }
php
public function getId() { $id = $this->props['attribs']['id']; $sepChar = '_'; // character to join prefix and id $repChar = '_'; // replace \W with this char if (!$id && $this->props['attribs']['name']) { $id = \preg_replace('/\W/', $repChar, $this->props['attribs']['name']); $id = \preg_replace('/'.$repChar.'+/', $repChar, $id); $id = \trim($id, $repChar); if ($id && $this->props['idPrefix']) { $prefix = $this->props['idPrefix']; if (\preg_match('/[a-z]$/i', $prefix)) { $prefix = $prefix.$sepChar; } $id = $prefix.$id; } if ($id) { $this->props['attribs']['id'] = $id; } } return $id; }
[ "public", "function", "getId", "(", ")", "{", "$", "id", "=", "$", "this", "->", "props", "[", "'attribs'", "]", "[", "'id'", "]", ";", "$", "sepChar", "=", "'_'", ";", "// character to join prefix and id", "$", "repChar", "=", "'_'", ";", "// replace \\W with this char", "if", "(", "!", "$", "id", "&&", "$", "this", "->", "props", "[", "'attribs'", "]", "[", "'name'", "]", ")", "{", "$", "id", "=", "\\", "preg_replace", "(", "'/\\W/'", ",", "$", "repChar", ",", "$", "this", "->", "props", "[", "'attribs'", "]", "[", "'name'", "]", ")", ";", "$", "id", "=", "\\", "preg_replace", "(", "'/'", ".", "$", "repChar", ".", "'+/'", ",", "$", "repChar", ",", "$", "id", ")", ";", "$", "id", "=", "\\", "trim", "(", "$", "id", ",", "$", "repChar", ")", ";", "if", "(", "$", "id", "&&", "$", "this", "->", "props", "[", "'idPrefix'", "]", ")", "{", "$", "prefix", "=", "$", "this", "->", "props", "[", "'idPrefix'", "]", ";", "if", "(", "\\", "preg_match", "(", "'/[a-z]$/i'", ",", "$", "prefix", ")", ")", "{", "$", "prefix", "=", "$", "prefix", ".", "$", "sepChar", ";", "}", "$", "id", "=", "$", "prefix", ".", "$", "id", ";", "}", "if", "(", "$", "id", ")", "{", "$", "this", "->", "props", "[", "'attribs'", "]", "[", "'id'", "]", "=", "$", "id", ";", "}", "}", "return", "$", "id", ";", "}" ]
Returns ID attribute If ID attribute is non-existant, ID will be derived from name and prefix @return string|null
[ "Returns", "ID", "attribute", "If", "ID", "attribute", "is", "non", "-", "existant", "ID", "will", "be", "derived", "from", "name", "and", "prefix" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L193-L214
238,797
bkdotcom/Form
src/Field.php
Field.getUniqueId
public function getUniqueId($increment = true) { $id = $this->getId(); if ($id) { $sepChar = '_'; if (isset(self::$idCounts[$id])) { if ($increment) { self::$idCounts[$id] ++; } if (self::$idCounts[$id] > 1) { $id .= $sepChar.self::$idCounts[$id]; } } else { self::$idCounts[$id] = 1; } } return $id; }
php
public function getUniqueId($increment = true) { $id = $this->getId(); if ($id) { $sepChar = '_'; if (isset(self::$idCounts[$id])) { if ($increment) { self::$idCounts[$id] ++; } if (self::$idCounts[$id] > 1) { $id .= $sepChar.self::$idCounts[$id]; } } else { self::$idCounts[$id] = 1; } } return $id; }
[ "public", "function", "getUniqueId", "(", "$", "increment", "=", "true", ")", "{", "$", "id", "=", "$", "this", "->", "getId", "(", ")", ";", "if", "(", "$", "id", ")", "{", "$", "sepChar", "=", "'_'", ";", "if", "(", "isset", "(", "self", "::", "$", "idCounts", "[", "$", "id", "]", ")", ")", "{", "if", "(", "$", "increment", ")", "{", "self", "::", "$", "idCounts", "[", "$", "id", "]", "++", ";", "}", "if", "(", "self", "::", "$", "idCounts", "[", "$", "id", "]", ">", "1", ")", "{", "$", "id", ".=", "$", "sepChar", ".", "self", "::", "$", "idCounts", "[", "$", "id", "]", ";", "}", "}", "else", "{", "self", "::", "$", "idCounts", "[", "$", "id", "]", "=", "1", ";", "}", "}", "return", "$", "id", ";", "}" ]
Returns unique ID. Checks if ID already used... Increments static counter @param boolean $increment increment static counter? @return string|null u\Unique ID
[ "Returns", "unique", "ID", "." ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L225-L242
238,798
bkdotcom/Form
src/Field.php
Field.isRequired
public function isRequired() { $isRequired = $this->attribs['required']; if (\is_string($isRequired)) { $replaced = \preg_replace('/{{(.*?)}}/', '$this->form->getField("$1")->val()', $isRequired); $evalString = '$isRequired = (bool) '.$replaced.';'; eval($evalString); } return $isRequired; }
php
public function isRequired() { $isRequired = $this->attribs['required']; if (\is_string($isRequired)) { $replaced = \preg_replace('/{{(.*?)}}/', '$this->form->getField("$1")->val()', $isRequired); $evalString = '$isRequired = (bool) '.$replaced.';'; eval($evalString); } return $isRequired; }
[ "public", "function", "isRequired", "(", ")", "{", "$", "isRequired", "=", "$", "this", "->", "attribs", "[", "'required'", "]", ";", "if", "(", "\\", "is_string", "(", "$", "isRequired", ")", ")", "{", "$", "replaced", "=", "\\", "preg_replace", "(", "'/{{(.*?)}}/'", ",", "'$this->form->getField(\"$1\")->val()'", ",", "$", "isRequired", ")", ";", "$", "evalString", "=", "'$isRequired = (bool) '", ".", "$", "replaced", ".", "';'", ";", "eval", "(", "$", "evalString", ")", ";", "}", "return", "$", "isRequired", ";", "}" ]
Is field required? @return boolean
[ "Is", "field", "required?" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L249-L258
238,799
bkdotcom/Form
src/Field.php
Field.setProps
public function setProps($props = array()) { $props = $this->moveShortcuts($props); $type = isset($props['attribs']['type']) ? $props['attribs']['type'] : null; $typeChanging = $type && (!isset($this->attribs['type']) || $type !== $this->attribs['type']); $propsType = $typeChanging && isset($this->defaultPropsType[$type]) ? $this->defaultPropsType[$type] : array(); $this->props = $this->mergeProps(array( $this->props, $propsType, $props, )); if (empty($this->props['attribs']['x-moz-errormessage']) && !empty($this->props['invalidReason'])) { $this->props['attribs']['x-moz-errormessage'] = $this->props['invalidReason']; } $this->attribs = &$this->props['attribs']; $this->getId(); if (\in_array($type, array('checkbox','radio','select'))) { $this->normalizeCrs(); } elseif ($type == 'submit' && empty($props['label']) && !empty($props['attribs']['value'])) { $props['label'] = $props['attribs']['value']; } }
php
public function setProps($props = array()) { $props = $this->moveShortcuts($props); $type = isset($props['attribs']['type']) ? $props['attribs']['type'] : null; $typeChanging = $type && (!isset($this->attribs['type']) || $type !== $this->attribs['type']); $propsType = $typeChanging && isset($this->defaultPropsType[$type]) ? $this->defaultPropsType[$type] : array(); $this->props = $this->mergeProps(array( $this->props, $propsType, $props, )); if (empty($this->props['attribs']['x-moz-errormessage']) && !empty($this->props['invalidReason'])) { $this->props['attribs']['x-moz-errormessage'] = $this->props['invalidReason']; } $this->attribs = &$this->props['attribs']; $this->getId(); if (\in_array($type, array('checkbox','radio','select'))) { $this->normalizeCrs(); } elseif ($type == 'submit' && empty($props['label']) && !empty($props['attribs']['value'])) { $props['label'] = $props['attribs']['value']; } }
[ "public", "function", "setProps", "(", "$", "props", "=", "array", "(", ")", ")", "{", "$", "props", "=", "$", "this", "->", "moveShortcuts", "(", "$", "props", ")", ";", "$", "type", "=", "isset", "(", "$", "props", "[", "'attribs'", "]", "[", "'type'", "]", ")", "?", "$", "props", "[", "'attribs'", "]", "[", "'type'", "]", ":", "null", ";", "$", "typeChanging", "=", "$", "type", "&&", "(", "!", "isset", "(", "$", "this", "->", "attribs", "[", "'type'", "]", ")", "||", "$", "type", "!==", "$", "this", "->", "attribs", "[", "'type'", "]", ")", ";", "$", "propsType", "=", "$", "typeChanging", "&&", "isset", "(", "$", "this", "->", "defaultPropsType", "[", "$", "type", "]", ")", "?", "$", "this", "->", "defaultPropsType", "[", "$", "type", "]", ":", "array", "(", ")", ";", "$", "this", "->", "props", "=", "$", "this", "->", "mergeProps", "(", "array", "(", "$", "this", "->", "props", ",", "$", "propsType", ",", "$", "props", ",", ")", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "props", "[", "'attribs'", "]", "[", "'x-moz-errormessage'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "props", "[", "'invalidReason'", "]", ")", ")", "{", "$", "this", "->", "props", "[", "'attribs'", "]", "[", "'x-moz-errormessage'", "]", "=", "$", "this", "->", "props", "[", "'invalidReason'", "]", ";", "}", "$", "this", "->", "attribs", "=", "&", "$", "this", "->", "props", "[", "'attribs'", "]", ";", "$", "this", "->", "getId", "(", ")", ";", "if", "(", "\\", "in_array", "(", "$", "type", ",", "array", "(", "'checkbox'", ",", "'radio'", ",", "'select'", ")", ")", ")", "{", "$", "this", "->", "normalizeCrs", "(", ")", ";", "}", "elseif", "(", "$", "type", "==", "'submit'", "&&", "empty", "(", "$", "props", "[", "'label'", "]", ")", "&&", "!", "empty", "(", "$", "props", "[", "'attribs'", "]", "[", "'value'", "]", ")", ")", "{", "$", "props", "[", "'label'", "]", "=", "$", "props", "[", "'attribs'", "]", "[", "'value'", "]", ";", "}", "}" ]
Set field properties @param array $props [description] @return void
[ "Set", "field", "properties" ]
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L267-L290