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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
6,200
jakecleary/ultrapress-library
src/Ultra/Mutator/Mutator.php
Mutator.images
public function images() { foreach($this->data as $post) { $post->images = Post::images($post->ID); } return $this; }
php
public function images() { foreach($this->data as $post) { $post->images = Post::images($post->ID); } return $this; }
[ "public", "function", "images", "(", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "post", ")", "{", "$", "post", "->", "images", "=", "Post", "::", "images", "(", "$", "post", "->", "ID", ")", ";", "}", "return", "$", "this", ";", "}" ]
Include the featured image URLs in the post object. @return Ultra\Mutator\Mutator The mutated data object
[ "Include", "the", "featured", "image", "URLs", "in", "the", "post", "object", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Mutator/Mutator.php#L136-L144
6,201
jakecleary/ultrapress-library
src/Ultra/Mutator/Mutator.php
Mutator.permalink
public function permalink() { foreach($this->data as $post) { $post->permalink = get_permalink($post->ID); } return $this; }
php
public function permalink() { foreach($this->data as $post) { $post->permalink = get_permalink($post->ID); } return $this; }
[ "public", "function", "permalink", "(", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "post", ")", "{", "$", "post", "->", "permalink", "=", "get_permalink", "(", "$", "post", "->", "ID", ")", ";", "}", "return", "$", "this", ";", "}" ]
Include the permalink in the post object. @return Ultra\Mutator\Mutator The mutated data object
[ "Include", "the", "permalink", "in", "the", "post", "object", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Mutator/Mutator.php#L151-L159
6,202
jakecleary/ultrapress-library
src/Ultra/Mutator/Mutator.php
Mutator.field
public function field($name) { foreach($this->data as $post) { $fieldType = get_field_object($name, $post->ID)['type']; if(in_array($fieldType, ['text'])) { $post->$name = get_field($name, $post->ID); } elseif(in_array($fieldType, ['image'])) { $post->$name = Data::arrayToObject(get_field($name, $post->ID)); } } return $this->data; }
php
public function field($name) { foreach($this->data as $post) { $fieldType = get_field_object($name, $post->ID)['type']; if(in_array($fieldType, ['text'])) { $post->$name = get_field($name, $post->ID); } elseif(in_array($fieldType, ['image'])) { $post->$name = Data::arrayToObject(get_field($name, $post->ID)); } } return $this->data; }
[ "public", "function", "field", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "post", ")", "{", "$", "fieldType", "=", "get_field_object", "(", "$", "name", ",", "$", "post", "->", "ID", ")", "[", "'type'", "]", ";", "if", "(", "in_array", "(", "$", "fieldType", ",", "[", "'text'", "]", ")", ")", "{", "$", "post", "->", "$", "name", "=", "get_field", "(", "$", "name", ",", "$", "post", "->", "ID", ")", ";", "}", "elseif", "(", "in_array", "(", "$", "fieldType", ",", "[", "'image'", "]", ")", ")", "{", "$", "post", "->", "$", "name", "=", "Data", "::", "arrayToObject", "(", "get_field", "(", "$", "name", ",", "$", "post", "->", "ID", ")", ")", ";", "}", "}", "return", "$", "this", "->", "data", ";", "}" ]
Get the contents of an ACF field. @param string $name The field name @return mixed The field's data
[ "Get", "the", "contents", "of", "an", "ACF", "field", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Mutator/Mutator.php#L167-L184
6,203
jakecleary/ultrapress-library
src/Ultra/Mutator/Mutator.php
Mutator.removeNamespace
public function removeNamespace($post, $namespaces) { foreach($post as $key => $value) { $splitKey = explode('_', $key); if(in_array($splitKey[0], $namespaces)) { unset($post->$key); $newKey = implode(array_slice($splitKey, 1), '_'); $post->$newKey = $value; } } return $this; }
php
public function removeNamespace($post, $namespaces) { foreach($post as $key => $value) { $splitKey = explode('_', $key); if(in_array($splitKey[0], $namespaces)) { unset($post->$key); $newKey = implode(array_slice($splitKey, 1), '_'); $post->$newKey = $value; } } return $this; }
[ "public", "function", "removeNamespace", "(", "$", "post", ",", "$", "namespaces", ")", "{", "foreach", "(", "$", "post", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "splitKey", "=", "explode", "(", "'_'", ",", "$", "key", ")", ";", "if", "(", "in_array", "(", "$", "splitKey", "[", "0", "]", ",", "$", "namespaces", ")", ")", "{", "unset", "(", "$", "post", "->", "$", "key", ")", ";", "$", "newKey", "=", "implode", "(", "array_slice", "(", "$", "splitKey", ",", "1", ")", ",", "'_'", ")", ";", "$", "post", "->", "$", "newKey", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Strip out a namespace from a data set. @param object $post WP_Post object to modify @param string $namespace The namespace to remove @return Ultra\Mutator\Mutator The mutated data object
[ "Strip", "out", "a", "namespace", "from", "a", "data", "set", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Mutator/Mutator.php#L193-L210
6,204
tux-rampage/rampage-php
library/rampage/core/Application.php
Application.handleFinalException
public static function handleFinalException(\Exception $exception) { if (PHP_SAPI == 'cli') { echo $exception; exit(1); } @header('Status: 500 Internal Error'); @header('HTTP/1.1 500 Internal Error'); while (ob_get_level() > 0) { ob_end_clean(); } $tpl = getcwd() . '/error.php'; if (is_readable($tpl) && is_file($tpl)) { include $tpl; exit(1); } echo '<html><head><title>Application Error</title></head><body style="background: #000; color: #fff;">'; if (is_readable(getcwd() . '/failure.jpg')) { echo '<img style="float: left;" src="data:image/jpeg;base64,' . base64_encode(file_get_contents(getcwd() . '/failure.jpg')) . '" />'; } echo '<h1 style="color: #f00;">Application Failure</h1>'; echo sprintf('<div style="margin-top: 40px;"><strong>Uncaught Exception (%s)</strong>: %s [code: %d]<br /><pre>%s</pre></div>', get_class($exception), $exception->getMessage(), $exception->getCode(), $exception); echo '</body></html>'; exit(1); }
php
public static function handleFinalException(\Exception $exception) { if (PHP_SAPI == 'cli') { echo $exception; exit(1); } @header('Status: 500 Internal Error'); @header('HTTP/1.1 500 Internal Error'); while (ob_get_level() > 0) { ob_end_clean(); } $tpl = getcwd() . '/error.php'; if (is_readable($tpl) && is_file($tpl)) { include $tpl; exit(1); } echo '<html><head><title>Application Error</title></head><body style="background: #000; color: #fff;">'; if (is_readable(getcwd() . '/failure.jpg')) { echo '<img style="float: left;" src="data:image/jpeg;base64,' . base64_encode(file_get_contents(getcwd() . '/failure.jpg')) . '" />'; } echo '<h1 style="color: #f00;">Application Failure</h1>'; echo sprintf('<div style="margin-top: 40px;"><strong>Uncaught Exception (%s)</strong>: %s [code: %d]<br /><pre>%s</pre></div>', get_class($exception), $exception->getMessage(), $exception->getCode(), $exception); echo '</body></html>'; exit(1); }
[ "public", "static", "function", "handleFinalException", "(", "\\", "Exception", "$", "exception", ")", "{", "if", "(", "PHP_SAPI", "==", "'cli'", ")", "{", "echo", "$", "exception", ";", "exit", "(", "1", ")", ";", "}", "@", "header", "(", "'Status: 500 Internal Error'", ")", ";", "@", "header", "(", "'HTTP/1.1 500 Internal Error'", ")", ";", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_clean", "(", ")", ";", "}", "$", "tpl", "=", "getcwd", "(", ")", ".", "'/error.php'", ";", "if", "(", "is_readable", "(", "$", "tpl", ")", "&&", "is_file", "(", "$", "tpl", ")", ")", "{", "include", "$", "tpl", ";", "exit", "(", "1", ")", ";", "}", "echo", "'<html><head><title>Application Error</title></head><body style=\"background: #000; color: #fff;\">'", ";", "if", "(", "is_readable", "(", "getcwd", "(", ")", ".", "'/failure.jpg'", ")", ")", "{", "echo", "'<img style=\"float: left;\" src=\"data:image/jpeg;base64,'", ".", "base64_encode", "(", "file_get_contents", "(", "getcwd", "(", ")", ".", "'/failure.jpg'", ")", ")", ".", "'\" />'", ";", "}", "echo", "'<h1 style=\"color: #f00;\">Application Failure</h1>'", ";", "echo", "sprintf", "(", "'<div style=\"margin-top: 40px;\"><strong>Uncaught Exception (%s)</strong>: %s [code: %d]<br /><pre>%s</pre></div>'", ",", "get_class", "(", "$", "exception", ")", ",", "$", "exception", "->", "getMessage", "(", ")", ",", "$", "exception", "->", "getCode", "(", ")", ",", "$", "exception", ")", ";", "echo", "'</body></html>'", ";", "exit", "(", "1", ")", ";", "}" ]
Handle final exception @param \Exception $exception
[ "Handle", "final", "exception" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/Application.php#L135-L164
6,205
tux-rampage/rampage-php
library/rampage/core/Application.php
Application.errorToException
public static function errorToException($errno, $errstr, $errfile, $errline) { $exclude = E_STRICT | E_NOTICE | E_USER_NOTICE; if (((error_reporting() & $errno) != $errno) || (($exclude & $errno) == $errno)) { return false; } $constants = get_defined_constants(true); $name = 'Unknown PHP Error (' . $errno . ')'; foreach ($constants['Core'] as $c => $value) { if ((substr($c, 0, 2) != 'E_') || ($value != $errno)) { continue; } $name = 'PHP ' . ucwords(str_replace('_', ' ', strtolower(substr($c, 2)))); } $exception = new \RuntimeException(sprintf('%s: %s in %s on line %d', $name, $errstr, $errfile, $errline), $errno); // Impossible to throw an exception without stack trace // happens when errors occour in shutdown scope (i.e. serialize handler) if (count($exception->getTrace()) < 1) { return false; } throw $exception; }
php
public static function errorToException($errno, $errstr, $errfile, $errline) { $exclude = E_STRICT | E_NOTICE | E_USER_NOTICE; if (((error_reporting() & $errno) != $errno) || (($exclude & $errno) == $errno)) { return false; } $constants = get_defined_constants(true); $name = 'Unknown PHP Error (' . $errno . ')'; foreach ($constants['Core'] as $c => $value) { if ((substr($c, 0, 2) != 'E_') || ($value != $errno)) { continue; } $name = 'PHP ' . ucwords(str_replace('_', ' ', strtolower(substr($c, 2)))); } $exception = new \RuntimeException(sprintf('%s: %s in %s on line %d', $name, $errstr, $errfile, $errline), $errno); // Impossible to throw an exception without stack trace // happens when errors occour in shutdown scope (i.e. serialize handler) if (count($exception->getTrace()) < 1) { return false; } throw $exception; }
[ "public", "static", "function", "errorToException", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "$", "exclude", "=", "E_STRICT", "|", "E_NOTICE", "|", "E_USER_NOTICE", ";", "if", "(", "(", "(", "error_reporting", "(", ")", "&", "$", "errno", ")", "!=", "$", "errno", ")", "||", "(", "(", "$", "exclude", "&", "$", "errno", ")", "==", "$", "errno", ")", ")", "{", "return", "false", ";", "}", "$", "constants", "=", "get_defined_constants", "(", "true", ")", ";", "$", "name", "=", "'Unknown PHP Error ('", ".", "$", "errno", ".", "')'", ";", "foreach", "(", "$", "constants", "[", "'Core'", "]", "as", "$", "c", "=>", "$", "value", ")", "{", "if", "(", "(", "substr", "(", "$", "c", ",", "0", ",", "2", ")", "!=", "'E_'", ")", "||", "(", "$", "value", "!=", "$", "errno", ")", ")", "{", "continue", ";", "}", "$", "name", "=", "'PHP '", ".", "ucwords", "(", "str_replace", "(", "'_'", ",", "' '", ",", "strtolower", "(", "substr", "(", "$", "c", ",", "2", ")", ")", ")", ")", ";", "}", "$", "exception", "=", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'%s: %s in %s on line %d'", ",", "$", "name", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", ",", "$", "errno", ")", ";", "// Impossible to throw an exception without stack trace", "// happens when errors occour in shutdown scope (i.e. serialize handler)", "if", "(", "count", "(", "$", "exception", "->", "getTrace", "(", ")", ")", "<", "1", ")", "{", "return", "false", ";", "}", "throw", "$", "exception", ";", "}" ]
Convert php errors to exceptions @throws \RuntimeException
[ "Convert", "php", "errors", "to", "exceptions" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/Application.php#L171-L197
6,206
zerospam/sdk-framework
src/Utils/Reflection/ReflectionUtil.php
ReflectionUtil.objToSnakeArray
public static function objToSnakeArray($object, $blackList = []) { if (!is_object($object)) { throw new \InvalidArgumentException('Not an object'); } return array_reduce( self::getAllProperties($object, $blackList), function ( array $result, \ReflectionProperty $property ) use ( $object ) { $property->setAccessible(true); $field = $property->getName(); $value = $property->getValue($object); $value = self::transformValue($value); if ($object instanceof WithNullableFields) { if (is_null($value) && !$object->isNullable($field)) { return $result; } if ($object->isNullable($field) && !$object->isValueChanged($field)) { return $result; } } elseif (is_null($value)) { return $result; } $result[Str::snake($field)] = $value; $property->setAccessible(false); return $result; }, [] ); }
php
public static function objToSnakeArray($object, $blackList = []) { if (!is_object($object)) { throw new \InvalidArgumentException('Not an object'); } return array_reduce( self::getAllProperties($object, $blackList), function ( array $result, \ReflectionProperty $property ) use ( $object ) { $property->setAccessible(true); $field = $property->getName(); $value = $property->getValue($object); $value = self::transformValue($value); if ($object instanceof WithNullableFields) { if (is_null($value) && !$object->isNullable($field)) { return $result; } if ($object->isNullable($field) && !$object->isValueChanged($field)) { return $result; } } elseif (is_null($value)) { return $result; } $result[Str::snake($field)] = $value; $property->setAccessible(false); return $result; }, [] ); }
[ "public", "static", "function", "objToSnakeArray", "(", "$", "object", ",", "$", "blackList", "=", "[", "]", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Not an object'", ")", ";", "}", "return", "array_reduce", "(", "self", "::", "getAllProperties", "(", "$", "object", ",", "$", "blackList", ")", ",", "function", "(", "array", "$", "result", ",", "\\", "ReflectionProperty", "$", "property", ")", "use", "(", "$", "object", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "field", "=", "$", "property", "->", "getName", "(", ")", ";", "$", "value", "=", "$", "property", "->", "getValue", "(", "$", "object", ")", ";", "$", "value", "=", "self", "::", "transformValue", "(", "$", "value", ")", ";", "if", "(", "$", "object", "instanceof", "WithNullableFields", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", "&&", "!", "$", "object", "->", "isNullable", "(", "$", "field", ")", ")", "{", "return", "$", "result", ";", "}", "if", "(", "$", "object", "->", "isNullable", "(", "$", "field", ")", "&&", "!", "$", "object", "->", "isValueChanged", "(", "$", "field", ")", ")", "{", "return", "$", "result", ";", "}", "}", "elseif", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "$", "result", ";", "}", "$", "result", "[", "Str", "::", "snake", "(", "$", "field", ")", "]", "=", "$", "value", ";", "$", "property", "->", "setAccessible", "(", "false", ")", ";", "return", "$", "result", ";", "}", ",", "[", "]", ")", ";", "}" ]
Take an object and return an array using all it's properties. Don't set the null one @param $object * @param array $blackList array containing name of properties to not serialize @throws \ReflectionException @return array
[ "Take", "an", "object", "and", "return", "an", "array", "using", "all", "it", "s", "properties", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Utils/Reflection/ReflectionUtil.php#L43-L84
6,207
zerospam/sdk-framework
src/Utils/Reflection/ReflectionUtil.php
ReflectionUtil.transformValue
private static function transformValue($value) { if (is_null($value)) { return $value; } if ($value instanceof PrimalValued) { $value = $value->toPrimitive(); } elseif ($value instanceof Arrayable) { $value = $value->toArray(); if (empty($value)) { $value = null; } } elseif (is_array($value)) { $value = array_map(function ($arrValue) { return self::transformValue($arrValue); }, $value); } elseif ($value instanceof \DateTimeZone) { $value = $value->getName(); } elseif ($value instanceof Carbon) { $value = $value->toRfc3339String(); } return $value; }
php
private static function transformValue($value) { if (is_null($value)) { return $value; } if ($value instanceof PrimalValued) { $value = $value->toPrimitive(); } elseif ($value instanceof Arrayable) { $value = $value->toArray(); if (empty($value)) { $value = null; } } elseif (is_array($value)) { $value = array_map(function ($arrValue) { return self::transformValue($arrValue); }, $value); } elseif ($value instanceof \DateTimeZone) { $value = $value->getName(); } elseif ($value instanceof Carbon) { $value = $value->toRfc3339String(); } return $value; }
[ "private", "static", "function", "transformValue", "(", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "$", "value", "instanceof", "PrimalValued", ")", "{", "$", "value", "=", "$", "value", "->", "toPrimitive", "(", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "Arrayable", ")", "{", "$", "value", "=", "$", "value", "->", "toArray", "(", ")", ";", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "$", "value", "=", "null", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "array_map", "(", "function", "(", "$", "arrValue", ")", "{", "return", "self", "::", "transformValue", "(", "$", "arrValue", ")", ";", "}", ",", "$", "value", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "\\", "DateTimeZone", ")", "{", "$", "value", "=", "$", "value", "->", "getName", "(", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "Carbon", ")", "{", "$", "value", "=", "$", "value", "->", "toRfc3339String", "(", ")", ";", "}", "return", "$", "value", ";", "}" ]
Transform the value. @param mixed $value @return array|float|int|null|string
[ "Transform", "the", "value", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Utils/Reflection/ReflectionUtil.php#L93-L117
6,208
zerospam/sdk-framework
src/Utils/Reflection/ReflectionUtil.php
ReflectionUtil.getAllProperties
public static function getAllProperties($class, $blacklist = []) { $classReflection = new \ReflectionClass($class); $properties = $classReflection->getProperties(); if ($parentClass = $classReflection->getParentClass()) { $parentProps = self::getAllProperties($parentClass->getName(), $blacklist); if (!empty($parentProps)) { $properties = array_merge($parentProps, $properties); } } if (empty($blacklist)) { return $properties; } return array_filter( $properties, function (\ReflectionProperty $property) use ($blacklist) { return !$property->isStatic() && !in_array($property->name, $blacklist); } ); }
php
public static function getAllProperties($class, $blacklist = []) { $classReflection = new \ReflectionClass($class); $properties = $classReflection->getProperties(); if ($parentClass = $classReflection->getParentClass()) { $parentProps = self::getAllProperties($parentClass->getName(), $blacklist); if (!empty($parentProps)) { $properties = array_merge($parentProps, $properties); } } if (empty($blacklist)) { return $properties; } return array_filter( $properties, function (\ReflectionProperty $property) use ($blacklist) { return !$property->isStatic() && !in_array($property->name, $blacklist); } ); }
[ "public", "static", "function", "getAllProperties", "(", "$", "class", ",", "$", "blacklist", "=", "[", "]", ")", "{", "$", "classReflection", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "properties", "=", "$", "classReflection", "->", "getProperties", "(", ")", ";", "if", "(", "$", "parentClass", "=", "$", "classReflection", "->", "getParentClass", "(", ")", ")", "{", "$", "parentProps", "=", "self", "::", "getAllProperties", "(", "$", "parentClass", "->", "getName", "(", ")", ",", "$", "blacklist", ")", ";", "if", "(", "!", "empty", "(", "$", "parentProps", ")", ")", "{", "$", "properties", "=", "array_merge", "(", "$", "parentProps", ",", "$", "properties", ")", ";", "}", "}", "if", "(", "empty", "(", "$", "blacklist", ")", ")", "{", "return", "$", "properties", ";", "}", "return", "array_filter", "(", "$", "properties", ",", "function", "(", "\\", "ReflectionProperty", "$", "property", ")", "use", "(", "$", "blacklist", ")", "{", "return", "!", "$", "property", "->", "isStatic", "(", ")", "&&", "!", "in_array", "(", "$", "property", "->", "name", ",", "$", "blacklist", ")", ";", "}", ")", ";", "}" ]
Get all the properties not blacklisted. @param $class @param array $blacklist @throws \ReflectionException @return array|\ReflectionProperty[]
[ "Get", "all", "the", "properties", "not", "blacklisted", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Utils/Reflection/ReflectionUtil.php#L129-L151
6,209
zerospam/sdk-framework
src/Utils/Reflection/ReflectionUtil.php
ReflectionUtil.populateResponseData
public static function populateResponseData(IResponse $response, &$dataObject): void { foreach (array_keys($response->data()) as $key) { $method = 'set'; $method .= ucfirst(Str::camel($key)); if (!method_exists($dataObject, $method)) { continue; } $dataObject->{$method}($response->{$key}); } }
php
public static function populateResponseData(IResponse $response, &$dataObject): void { foreach (array_keys($response->data()) as $key) { $method = 'set'; $method .= ucfirst(Str::camel($key)); if (!method_exists($dataObject, $method)) { continue; } $dataObject->{$method}($response->{$key}); } }
[ "public", "static", "function", "populateResponseData", "(", "IResponse", "$", "response", ",", "&", "$", "dataObject", ")", ":", "void", "{", "foreach", "(", "array_keys", "(", "$", "response", "->", "data", "(", ")", ")", "as", "$", "key", ")", "{", "$", "method", "=", "'set'", ";", "$", "method", ".=", "ucfirst", "(", "Str", "::", "camel", "(", "$", "key", ")", ")", ";", "if", "(", "!", "method_exists", "(", "$", "dataObject", ",", "$", "method", ")", ")", "{", "continue", ";", "}", "$", "dataObject", "->", "{", "$", "method", "}", "(", "$", "response", "->", "{", "$", "key", "}", ")", ";", "}", "}" ]
Populate the response data into a dataObject that have the corresponding setters. @param IResponse $response @param $dataObject
[ "Populate", "the", "response", "data", "into", "a", "dataObject", "that", "have", "the", "corresponding", "setters", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Utils/Reflection/ReflectionUtil.php#L159-L170
6,210
puresolcom/polyether
src/Post/Post.php
Post.registerDefaultPostTypes
private function registerDefaultPostTypes() { $this->registerPostType('post', [ 'labels' => ['name' => 'Posts', 'singular' => 'Post',], 'hierarchical' => false, 'show_ui' => true, 'icon' => 'fa fa-pencil', 'menu_position' => 10, '_built_in' => true, ]); $this->registerPostType('page', [ 'labels' => ['name' => 'Pages', 'singular' => 'Page',], 'hierarchical' => true, 'show_ui' => true, 'icon' => 'fa fa-file', 'menu_position' => 11, '_built_in' => true, ]); }
php
private function registerDefaultPostTypes() { $this->registerPostType('post', [ 'labels' => ['name' => 'Posts', 'singular' => 'Post',], 'hierarchical' => false, 'show_ui' => true, 'icon' => 'fa fa-pencil', 'menu_position' => 10, '_built_in' => true, ]); $this->registerPostType('page', [ 'labels' => ['name' => 'Pages', 'singular' => 'Page',], 'hierarchical' => true, 'show_ui' => true, 'icon' => 'fa fa-file', 'menu_position' => 11, '_built_in' => true, ]); }
[ "private", "function", "registerDefaultPostTypes", "(", ")", "{", "$", "this", "->", "registerPostType", "(", "'post'", ",", "[", "'labels'", "=>", "[", "'name'", "=>", "'Posts'", ",", "'singular'", "=>", "'Post'", ",", "]", ",", "'hierarchical'", "=>", "false", ",", "'show_ui'", "=>", "true", ",", "'icon'", "=>", "'fa fa-pencil'", ",", "'menu_position'", "=>", "10", ",", "'_built_in'", "=>", "true", ",", "]", ")", ";", "$", "this", "->", "registerPostType", "(", "'page'", ",", "[", "'labels'", "=>", "[", "'name'", "=>", "'Pages'", ",", "'singular'", "=>", "'Page'", ",", "]", ",", "'hierarchical'", "=>", "true", ",", "'show_ui'", "=>", "true", ",", "'icon'", "=>", "'fa fa-file'", ",", "'menu_position'", "=>", "11", ",", "'_built_in'", "=>", "true", ",", "]", ")", ";", "}" ]
Registering initial post types @return void;
[ "Registering", "initial", "post", "types" ]
22a7649d0dc99b0418c41f4f708e53e430bdc491
https://github.com/puresolcom/polyether/blob/22a7649d0dc99b0418c41f4f708e53e430bdc491/src/Post/Post.php#L53-L72
6,211
puresolcom/polyether
src/Post/Post.php
Post.registerPostType
public function registerPostType($post_type, $args = array()) { if ($this->postTypeObjectExists($post_type)) { return new EtherError('Post type with the same name already exists'); } // Args prefixed with an underscore are reserved for internal use. $defaults = [ 'labels' => ['name' => 'Posts', 'singular' => 'Post',], 'description' => '', 'show_ui' => true, 'show_in_admin_menu' => null, 'show_in_nav_menu' => null, 'icon' => null, 'hierarchical' => false, 'taxonomies' => [], 'permissions' => [ 'view_posts' => 'view_posts', 'create_posts' => 'create_posts', 'edit_posts' => 'edit_posts', 'delete_posts' => 'delete_posts', ], 'menu_position' => null, '_built_in' => false, ]; $args = array_merge($defaults, $args); if (null === $args[ 'show_in_admin_menu' ]) { $args[ 'show_in_admin_menu' ] = $args[ 'show_ui' ]; } if (null === $args[ 'show_in_nav_menu' ]) { $args[ 'show_in_nav_menu' ] = $args[ 'show_ui' ]; } $args = (object)$args; $args->name = $post_type; if (empty($post_type) || strlen($post_type) > 20) { return new EtherError('Post type must be less than 20 characters length'); } foreach ($args->taxonomies as $taxonomy) { Taxonomy::registerTaxonomyForObjectType($taxonomy, $post_type); } $this->postTypes[ $post_type ] = $args; }
php
public function registerPostType($post_type, $args = array()) { if ($this->postTypeObjectExists($post_type)) { return new EtherError('Post type with the same name already exists'); } // Args prefixed with an underscore are reserved for internal use. $defaults = [ 'labels' => ['name' => 'Posts', 'singular' => 'Post',], 'description' => '', 'show_ui' => true, 'show_in_admin_menu' => null, 'show_in_nav_menu' => null, 'icon' => null, 'hierarchical' => false, 'taxonomies' => [], 'permissions' => [ 'view_posts' => 'view_posts', 'create_posts' => 'create_posts', 'edit_posts' => 'edit_posts', 'delete_posts' => 'delete_posts', ], 'menu_position' => null, '_built_in' => false, ]; $args = array_merge($defaults, $args); if (null === $args[ 'show_in_admin_menu' ]) { $args[ 'show_in_admin_menu' ] = $args[ 'show_ui' ]; } if (null === $args[ 'show_in_nav_menu' ]) { $args[ 'show_in_nav_menu' ] = $args[ 'show_ui' ]; } $args = (object)$args; $args->name = $post_type; if (empty($post_type) || strlen($post_type) > 20) { return new EtherError('Post type must be less than 20 characters length'); } foreach ($args->taxonomies as $taxonomy) { Taxonomy::registerTaxonomyForObjectType($taxonomy, $post_type); } $this->postTypes[ $post_type ] = $args; }
[ "public", "function", "registerPostType", "(", "$", "post_type", ",", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "postTypeObjectExists", "(", "$", "post_type", ")", ")", "{", "return", "new", "EtherError", "(", "'Post type with the same name already exists'", ")", ";", "}", "// Args prefixed with an underscore are reserved for internal use.", "$", "defaults", "=", "[", "'labels'", "=>", "[", "'name'", "=>", "'Posts'", ",", "'singular'", "=>", "'Post'", ",", "]", ",", "'description'", "=>", "''", ",", "'show_ui'", "=>", "true", ",", "'show_in_admin_menu'", "=>", "null", ",", "'show_in_nav_menu'", "=>", "null", ",", "'icon'", "=>", "null", ",", "'hierarchical'", "=>", "false", ",", "'taxonomies'", "=>", "[", "]", ",", "'permissions'", "=>", "[", "'view_posts'", "=>", "'view_posts'", ",", "'create_posts'", "=>", "'create_posts'", ",", "'edit_posts'", "=>", "'edit_posts'", ",", "'delete_posts'", "=>", "'delete_posts'", ",", "]", ",", "'menu_position'", "=>", "null", ",", "'_built_in'", "=>", "false", ",", "]", ";", "$", "args", "=", "array_merge", "(", "$", "defaults", ",", "$", "args", ")", ";", "if", "(", "null", "===", "$", "args", "[", "'show_in_admin_menu'", "]", ")", "{", "$", "args", "[", "'show_in_admin_menu'", "]", "=", "$", "args", "[", "'show_ui'", "]", ";", "}", "if", "(", "null", "===", "$", "args", "[", "'show_in_nav_menu'", "]", ")", "{", "$", "args", "[", "'show_in_nav_menu'", "]", "=", "$", "args", "[", "'show_ui'", "]", ";", "}", "$", "args", "=", "(", "object", ")", "$", "args", ";", "$", "args", "->", "name", "=", "$", "post_type", ";", "if", "(", "empty", "(", "$", "post_type", ")", "||", "strlen", "(", "$", "post_type", ")", ">", "20", ")", "{", "return", "new", "EtherError", "(", "'Post type must be less than 20 characters length'", ")", ";", "}", "foreach", "(", "$", "args", "->", "taxonomies", "as", "$", "taxonomy", ")", "{", "Taxonomy", "::", "registerTaxonomyForObjectType", "(", "$", "taxonomy", ",", "$", "post_type", ")", ";", "}", "$", "this", "->", "postTypes", "[", "$", "post_type", "]", "=", "$", "args", ";", "}" ]
Register A Post Type @param string $post_type @param array $args @return void|EtherError
[ "Register", "A", "Post", "Type" ]
22a7649d0dc99b0418c41f4f708e53e430bdc491
https://github.com/puresolcom/polyether/blob/22a7649d0dc99b0418c41f4f708e53e430bdc491/src/Post/Post.php#L87-L138
6,212
puresolcom/polyether
src/Post/Post.php
Post.getPostTypeObject
public function getPostTypeObject($post_type) { if ( ! isset($this->postTypes[ $post_type ])) { return false; } return $this->postTypes[ $post_type ]; }
php
public function getPostTypeObject($post_type) { if ( ! isset($this->postTypes[ $post_type ])) { return false; } return $this->postTypes[ $post_type ]; }
[ "public", "function", "getPostTypeObject", "(", "$", "post_type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "postTypes", "[", "$", "post_type", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "postTypes", "[", "$", "post_type", "]", ";", "}" ]
Returns the registered post type object @param string $post_type @return false|\stdClass
[ "Returns", "the", "registered", "post", "type", "object" ]
22a7649d0dc99b0418c41f4f708e53e430bdc491
https://github.com/puresolcom/polyether/blob/22a7649d0dc99b0418c41f4f708e53e430bdc491/src/Post/Post.php#L159-L166
6,213
puresolcom/polyether
src/Post/Post.php
Post.create
public function create($postArr) { $userId = null; if (Auth::check()) { $userId = Auth::user()->id; } $default = [ 'post_author' => $userId, 'post_content' => '', 'post_title' => '', 'post_excerpt' => '', 'post_status' => 'draft', 'post_type' => 'post', 'comment_status' => '', 'post_parent' => 0, 'menu_order' => 0, ]; $postArr = array_unique(array_merge($default, $postArr)); $postArr[ 'guid' ] = sha1(time()); if (empty($postArr[ 'post_title' ])) { return new EtherError('Post title must be provided'); } if (isset($postArr[ 'post_slug' ]) && ! empty($postArr[ 'post_slug' ])) { $postArr[ 'post_slug' ] = $this->postRepository->sluggable($postArr[ 'post_slug' ], 'post_slug'); } else { $postArr[ 'post_slug' ] = $this->postRepository->sluggable($postArr[ 'post_title' ], 'post_slug'); } try { $post = $this->postRepository->create($postArr); } catch (\Exception $e) { return new EtherError($e); } return $post; }
php
public function create($postArr) { $userId = null; if (Auth::check()) { $userId = Auth::user()->id; } $default = [ 'post_author' => $userId, 'post_content' => '', 'post_title' => '', 'post_excerpt' => '', 'post_status' => 'draft', 'post_type' => 'post', 'comment_status' => '', 'post_parent' => 0, 'menu_order' => 0, ]; $postArr = array_unique(array_merge($default, $postArr)); $postArr[ 'guid' ] = sha1(time()); if (empty($postArr[ 'post_title' ])) { return new EtherError('Post title must be provided'); } if (isset($postArr[ 'post_slug' ]) && ! empty($postArr[ 'post_slug' ])) { $postArr[ 'post_slug' ] = $this->postRepository->sluggable($postArr[ 'post_slug' ], 'post_slug'); } else { $postArr[ 'post_slug' ] = $this->postRepository->sluggable($postArr[ 'post_title' ], 'post_slug'); } try { $post = $this->postRepository->create($postArr); } catch (\Exception $e) { return new EtherError($e); } return $post; }
[ "public", "function", "create", "(", "$", "postArr", ")", "{", "$", "userId", "=", "null", ";", "if", "(", "Auth", "::", "check", "(", ")", ")", "{", "$", "userId", "=", "Auth", "::", "user", "(", ")", "->", "id", ";", "}", "$", "default", "=", "[", "'post_author'", "=>", "$", "userId", ",", "'post_content'", "=>", "''", ",", "'post_title'", "=>", "''", ",", "'post_excerpt'", "=>", "''", ",", "'post_status'", "=>", "'draft'", ",", "'post_type'", "=>", "'post'", ",", "'comment_status'", "=>", "''", ",", "'post_parent'", "=>", "0", ",", "'menu_order'", "=>", "0", ",", "]", ";", "$", "postArr", "=", "array_unique", "(", "array_merge", "(", "$", "default", ",", "$", "postArr", ")", ")", ";", "$", "postArr", "[", "'guid'", "]", "=", "sha1", "(", "time", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "postArr", "[", "'post_title'", "]", ")", ")", "{", "return", "new", "EtherError", "(", "'Post title must be provided'", ")", ";", "}", "if", "(", "isset", "(", "$", "postArr", "[", "'post_slug'", "]", ")", "&&", "!", "empty", "(", "$", "postArr", "[", "'post_slug'", "]", ")", ")", "{", "$", "postArr", "[", "'post_slug'", "]", "=", "$", "this", "->", "postRepository", "->", "sluggable", "(", "$", "postArr", "[", "'post_slug'", "]", ",", "'post_slug'", ")", ";", "}", "else", "{", "$", "postArr", "[", "'post_slug'", "]", "=", "$", "this", "->", "postRepository", "->", "sluggable", "(", "$", "postArr", "[", "'post_title'", "]", ",", "'post_slug'", ")", ";", "}", "try", "{", "$", "post", "=", "$", "this", "->", "postRepository", "->", "create", "(", "$", "postArr", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "new", "EtherError", "(", "$", "e", ")", ";", "}", "return", "$", "post", ";", "}" ]
Inserts a new post and return the post id @param array $postArr @return integer|EtherError|null
[ "Inserts", "a", "new", "post", "and", "return", "the", "post", "id" ]
22a7649d0dc99b0418c41f4f708e53e430bdc491
https://github.com/puresolcom/polyether/blob/22a7649d0dc99b0418c41f4f708e53e430bdc491/src/Post/Post.php#L183-L222
6,214
puresolcom/polyether
src/Post/Post.php
Post.find
public function find($postId, $columns = ['*']) { $cache_key = (is_array($columns) && $columns[ 0 ] == '*') ? 'post_' . $postId : 'post_' . md5($postId . http_build_query($columns)); // See if we've the post cached earlier in this request and return it if it's available if (Cache::tags(['posts', 'post_' . $postId])->has($cache_key)) { return Cache::tags(['posts', 'post_' . $postId])->get($cache_key); } else { // Eventually we try to fetch the post from the database or return an error try { $post = $this->postRepository->findOrFail($postId, $columns); // Cache it using the caching system Cache::tags(['posts', 'post_' . $postId]) ->put($cache_key, $post, \Option::get('posts_cache_expires', 60)); return $post; } catch (\Exception $e) { return null; } } }
php
public function find($postId, $columns = ['*']) { $cache_key = (is_array($columns) && $columns[ 0 ] == '*') ? 'post_' . $postId : 'post_' . md5($postId . http_build_query($columns)); // See if we've the post cached earlier in this request and return it if it's available if (Cache::tags(['posts', 'post_' . $postId])->has($cache_key)) { return Cache::tags(['posts', 'post_' . $postId])->get($cache_key); } else { // Eventually we try to fetch the post from the database or return an error try { $post = $this->postRepository->findOrFail($postId, $columns); // Cache it using the caching system Cache::tags(['posts', 'post_' . $postId]) ->put($cache_key, $post, \Option::get('posts_cache_expires', 60)); return $post; } catch (\Exception $e) { return null; } } }
[ "public", "function", "find", "(", "$", "postId", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "$", "cache_key", "=", "(", "is_array", "(", "$", "columns", ")", "&&", "$", "columns", "[", "0", "]", "==", "'*'", ")", "?", "'post_'", ".", "$", "postId", ":", "'post_'", ".", "md5", "(", "$", "postId", ".", "http_build_query", "(", "$", "columns", ")", ")", ";", "// See if we've the post cached earlier in this request and return it if it's available", "if", "(", "Cache", "::", "tags", "(", "[", "'posts'", ",", "'post_'", ".", "$", "postId", "]", ")", "->", "has", "(", "$", "cache_key", ")", ")", "{", "return", "Cache", "::", "tags", "(", "[", "'posts'", ",", "'post_'", ".", "$", "postId", "]", ")", "->", "get", "(", "$", "cache_key", ")", ";", "}", "else", "{", "// Eventually we try to fetch the post from the database or return an error", "try", "{", "$", "post", "=", "$", "this", "->", "postRepository", "->", "findOrFail", "(", "$", "postId", ",", "$", "columns", ")", ";", "// Cache it using the caching system", "Cache", "::", "tags", "(", "[", "'posts'", ",", "'post_'", ".", "$", "postId", "]", ")", "->", "put", "(", "$", "cache_key", ",", "$", "post", ",", "\\", "Option", "::", "get", "(", "'posts_cache_expires'", ",", "60", ")", ")", ";", "return", "$", "post", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "null", ";", "}", "}", "}" ]
Find a post object by id @param integer $postId @return \Illuminate\Support\Collection||null
[ "Find", "a", "post", "object", "by", "id" ]
22a7649d0dc99b0418c41f4f708e53e430bdc491
https://github.com/puresolcom/polyether/blob/22a7649d0dc99b0418c41f4f708e53e430bdc491/src/Post/Post.php#L260-L280
6,215
vworldat/SimpleContentBundle
Menu/SimpleContentMenuItem.php
SimpleContentMenuItem.fetchTitle
protected function fetchTitle() { try { $this->fetchOption('title', true); } catch (OptionRequiredException $e) { // no title was set manually if (null !== $this->simpleContentPage) { $this->title = $this->simpleContentPage->getTitle(); } else { $this->title = $this->simplePageName; } } return $this; }
php
protected function fetchTitle() { try { $this->fetchOption('title', true); } catch (OptionRequiredException $e) { // no title was set manually if (null !== $this->simpleContentPage) { $this->title = $this->simpleContentPage->getTitle(); } else { $this->title = $this->simplePageName; } } return $this; }
[ "protected", "function", "fetchTitle", "(", ")", "{", "try", "{", "$", "this", "->", "fetchOption", "(", "'title'", ",", "true", ")", ";", "}", "catch", "(", "OptionRequiredException", "$", "e", ")", "{", "// no title was set manually", "if", "(", "null", "!==", "$", "this", "->", "simpleContentPage", ")", "{", "$", "this", "->", "title", "=", "$", "this", "->", "simpleContentPage", "->", "getTitle", "(", ")", ";", "}", "else", "{", "$", "this", "->", "title", "=", "$", "this", "->", "simplePageName", ";", "}", "}", "return", "$", "this", ";", "}" ]
Fetch the item's "title" option. @return MenuItem
[ "Fetch", "the", "item", "s", "title", "option", "." ]
cca691609c9e7850969f27dac524865342042c68
https://github.com/vworldat/SimpleContentBundle/blob/cca691609c9e7850969f27dac524865342042c68/Menu/SimpleContentMenuItem.php#L80-L100
6,216
fortifi/sdk
api/FortifiApi.php
FortifiApi.enableNesting
public function enableNesting($shortNesting = false) { $this->_disableNesting = false; $this->_shortNesting = $shortNesting; return $this; }
php
public function enableNesting($shortNesting = false) { $this->_disableNesting = false; $this->_shortNesting = $shortNesting; return $this; }
[ "public", "function", "enableNesting", "(", "$", "shortNesting", "=", "false", ")", "{", "$", "this", "->", "_disableNesting", "=", "false", ";", "$", "this", "->", "_shortNesting", "=", "$", "shortNesting", ";", "return", "$", "this", ";", "}" ]
Automatically load relationships @param bool $shortNesting - Return Limited DataNodes (id,fid,displayName) @return $this
[ "Automatically", "load", "relationships" ]
4d0471c72c7954271c692d32265fd42f698392e4
https://github.com/fortifi/sdk/blob/4d0471c72c7954271c692d32265fd42f698392e4/api/FortifiApi.php#L206-L211
6,217
gintonicweb/users
src/Model/Table/UsersTable.php
UsersTable.searchConfiguration
public function searchConfiguration() { $search = new Manager($this); $search->like('username', [ 'before' => true, 'after' => true, 'field' => [$this->aliasField('username')] ]); return $search; }
php
public function searchConfiguration() { $search = new Manager($this); $search->like('username', [ 'before' => true, 'after' => true, 'field' => [$this->aliasField('username')] ]); return $search; }
[ "public", "function", "searchConfiguration", "(", ")", "{", "$", "search", "=", "new", "Manager", "(", "$", "this", ")", ";", "$", "search", "->", "like", "(", "'username'", ",", "[", "'before'", "=>", "true", ",", "'after'", "=>", "true", ",", "'field'", "=>", "[", "$", "this", "->", "aliasField", "(", "'username'", ")", "]", "]", ")", ";", "return", "$", "search", ";", "}" ]
Allows to search users by partial username @return \Search\Manager
[ "Allows", "to", "search", "users", "by", "partial", "username" ]
822b5f640969020ff8165d8d376680ef33d1f9ac
https://github.com/gintonicweb/users/blob/822b5f640969020ff8165d8d376680ef33d1f9ac/src/Model/Table/UsersTable.php#L90-L99
6,218
gintonicweb/users
src/Model/Table/UsersTable.php
UsersTable.findAuth
public function findAuth($query, $options) { foreach ($options['columns'] as $column) { $query = $query->orWhere([$column => $options['username']]); } return $query; }
php
public function findAuth($query, $options) { foreach ($options['columns'] as $column) { $query = $query->orWhere([$column => $options['username']]); } return $query; }
[ "public", "function", "findAuth", "(", "$", "query", ",", "$", "options", ")", "{", "foreach", "(", "$", "options", "[", "'columns'", "]", "as", "$", "column", ")", "{", "$", "query", "=", "$", "query", "->", "orWhere", "(", "[", "$", "column", "=>", "$", "options", "[", "'username'", "]", "]", ")", ";", "}", "return", "$", "query", ";", "}" ]
Multi-column authenticate @param \Cake\ORM\Query $query The query to find with @param array $options The options to find with @return \Cake\ORM\Query The query builder
[ "Multi", "-", "column", "authenticate" ]
822b5f640969020ff8165d8d376680ef33d1f9ac
https://github.com/gintonicweb/users/blob/822b5f640969020ff8165d8d376680ef33d1f9ac/src/Model/Table/UsersTable.php#L108-L114
6,219
gintonicweb/users
src/Model/Table/UsersTable.php
UsersTable.findToken
public function findToken($query, $options) { return $this->find()->matching('Tokens', function ($q) use ($options) { return $q->where(['Tokens.token' => $options['token']]); }); }
php
public function findToken($query, $options) { return $this->find()->matching('Tokens', function ($q) use ($options) { return $q->where(['Tokens.token' => $options['token']]); }); }
[ "public", "function", "findToken", "(", "$", "query", ",", "$", "options", ")", "{", "return", "$", "this", "->", "find", "(", ")", "->", "matching", "(", "'Tokens'", ",", "function", "(", "$", "q", ")", "use", "(", "$", "options", ")", "{", "return", "$", "q", "->", "where", "(", "[", "'Tokens.token'", "=>", "$", "options", "[", "'token'", "]", "]", ")", ";", "}", ")", ";", "}" ]
Find user based on token @param \Cake\ORM\Query $query The query to find with @param array $options The options to find with @return \Cake\ORM\Query The query builder
[ "Find", "user", "based", "on", "token" ]
822b5f640969020ff8165d8d376680ef33d1f9ac
https://github.com/gintonicweb/users/blob/822b5f640969020ff8165d8d376680ef33d1f9ac/src/Model/Table/UsersTable.php#L123-L128
6,220
synapsestudios/synapse-base
src/Synapse/OAuth2/ServerServiceProvider.php
ServerServiceProvider.setFirewalls
protected function setFirewalls(Application $app) { $app->extend('security.firewalls', function ($firewalls, $app) { $logout = new RequestMatcher('^/oauth/logout', null, ['POST']); $oAuth = new RequestMatcher('^/oauth'); $breedFirewalls = [ 'oauth-logout' => [ 'pattern' => $logout, 'oauth' => true, ], 'oauth-public' => [ 'pattern' => $oAuth, 'anonymous' => true, ], ]; return array_merge($breedFirewalls, $firewalls); }); }
php
protected function setFirewalls(Application $app) { $app->extend('security.firewalls', function ($firewalls, $app) { $logout = new RequestMatcher('^/oauth/logout', null, ['POST']); $oAuth = new RequestMatcher('^/oauth'); $breedFirewalls = [ 'oauth-logout' => [ 'pattern' => $logout, 'oauth' => true, ], 'oauth-public' => [ 'pattern' => $oAuth, 'anonymous' => true, ], ]; return array_merge($breedFirewalls, $firewalls); }); }
[ "protected", "function", "setFirewalls", "(", "Application", "$", "app", ")", "{", "$", "app", "->", "extend", "(", "'security.firewalls'", ",", "function", "(", "$", "firewalls", ",", "$", "app", ")", "{", "$", "logout", "=", "new", "RequestMatcher", "(", "'^/oauth/logout'", ",", "null", ",", "[", "'POST'", "]", ")", ";", "$", "oAuth", "=", "new", "RequestMatcher", "(", "'^/oauth'", ")", ";", "$", "breedFirewalls", "=", "[", "'oauth-logout'", "=>", "[", "'pattern'", "=>", "$", "logout", ",", "'oauth'", "=>", "true", ",", "]", ",", "'oauth-public'", "=>", "[", "'pattern'", "=>", "$", "oAuth", ",", "'anonymous'", "=>", "true", ",", "]", ",", "]", ";", "return", "array_merge", "(", "$", "breedFirewalls", ",", "$", "firewalls", ")", ";", "}", ")", ";", "}" ]
Set OAuth related firewalls @param Application $app
[ "Set", "OAuth", "related", "firewalls" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/OAuth2/ServerServiceProvider.php#L122-L141
6,221
ojhaujjwal/UserRbac
src/Identity/IdentityRoleProvider.php
IdentityRoleProvider.getIdentityRoles
public function getIdentityRoles(UserInterface $user = null) { if ($user === null) { $user = $this->getDefaultIdentity(); if (!$user) { return (array) $this->getModuleOptions()->getDefaultGuestRole(); } } $resultSet = $this->getUserRoleLinkerMapper()->findByUser($user); if (count($resultSet) > 0) { // if exists in database $roles = array(); foreach ($resultSet as $userRoleLinker) { $roles[] = $userRoleLinker->getRoleId(); } return $roles; } else { return (array) $this->getModuleOptions()->getDefaultUserRole(); } }
php
public function getIdentityRoles(UserInterface $user = null) { if ($user === null) { $user = $this->getDefaultIdentity(); if (!$user) { return (array) $this->getModuleOptions()->getDefaultGuestRole(); } } $resultSet = $this->getUserRoleLinkerMapper()->findByUser($user); if (count($resultSet) > 0) { // if exists in database $roles = array(); foreach ($resultSet as $userRoleLinker) { $roles[] = $userRoleLinker->getRoleId(); } return $roles; } else { return (array) $this->getModuleOptions()->getDefaultUserRole(); } }
[ "public", "function", "getIdentityRoles", "(", "UserInterface", "$", "user", "=", "null", ")", "{", "if", "(", "$", "user", "===", "null", ")", "{", "$", "user", "=", "$", "this", "->", "getDefaultIdentity", "(", ")", ";", "if", "(", "!", "$", "user", ")", "{", "return", "(", "array", ")", "$", "this", "->", "getModuleOptions", "(", ")", "->", "getDefaultGuestRole", "(", ")", ";", "}", "}", "$", "resultSet", "=", "$", "this", "->", "getUserRoleLinkerMapper", "(", ")", "->", "findByUser", "(", "$", "user", ")", ";", "if", "(", "count", "(", "$", "resultSet", ")", ">", "0", ")", "{", "// if exists in database", "$", "roles", "=", "array", "(", ")", ";", "foreach", "(", "$", "resultSet", "as", "$", "userRoleLinker", ")", "{", "$", "roles", "[", "]", "=", "$", "userRoleLinker", "->", "getRoleId", "(", ")", ";", "}", "return", "$", "roles", ";", "}", "else", "{", "return", "(", "array", ")", "$", "this", "->", "getModuleOptions", "(", ")", "->", "getDefaultUserRole", "(", ")", ";", "}", "}" ]
Get the list of roles of a user @return string[]
[ "Get", "the", "list", "of", "roles", "of", "a", "user" ]
ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe
https://github.com/ojhaujjwal/UserRbac/blob/ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe/src/Identity/IdentityRoleProvider.php#L104-L126
6,222
emaphp/eMapper
lib/eMapper/ORM/Dynamic/Statement.php
Statement.saveStatement
protected function saveStatement($query, ClassProfile $entity, $asList = true) { //fetched columns depend on the entity used //setting a result map avoids getting imcomplete results $config = array_merge(['map.result' => $this->entity, 'map.type' => $asList ? $this->buildListExpression($entity) : $this->buildExpression($entity)], $this->config); $this->statement = new SQLStatement($query, $config); }
php
protected function saveStatement($query, ClassProfile $entity, $asList = true) { //fetched columns depend on the entity used //setting a result map avoids getting imcomplete results $config = array_merge(['map.result' => $this->entity, 'map.type' => $asList ? $this->buildListExpression($entity) : $this->buildExpression($entity)], $this->config); $this->statement = new SQLStatement($query, $config); }
[ "protected", "function", "saveStatement", "(", "$", "query", ",", "ClassProfile", "$", "entity", ",", "$", "asList", "=", "true", ")", "{", "//fetched columns depend on the entity used", "//setting a result map avoids getting imcomplete results", "$", "config", "=", "array_merge", "(", "[", "'map.result'", "=>", "$", "this", "->", "entity", ",", "'map.type'", "=>", "$", "asList", "?", "$", "this", "->", "buildListExpression", "(", "$", "entity", ")", ":", "$", "this", "->", "buildExpression", "(", "$", "entity", ")", "]", ",", "$", "this", "->", "config", ")", ";", "$", "this", "->", "statement", "=", "new", "SQLStatement", "(", "$", "query", ",", "$", "config", ")", ";", "}" ]
Stores a new Statement instance with the given configuration @param string $query @param \eMapper\Reflection\ClassProfile $entity @param string $asList
[ "Stores", "a", "new", "Statement", "instance", "with", "the", "given", "configuration" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/ORM/Dynamic/Statement.php#L83-L88
6,223
slickframework/mvc
src/Controller.php
Controller.register
public function register( ServerRequestInterface $request, ResponseInterface $response ) { $this->request = $request; $this->response = $response; return $this; }
php
public function register( ServerRequestInterface $request, ResponseInterface $response ) { $this->request = $request; $this->response = $response; return $this; }
[ "public", "function", "register", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "this", "->", "request", "=", "$", "request", ";", "$", "this", "->", "response", "=", "$", "response", ";", "return", "$", "this", ";", "}" ]
Registers the current HTTP request and response @param ServerRequestInterface $request @param ResponseInterface $response @return Controller|$this|self|ControllerInterface
[ "Registers", "the", "current", "HTTP", "request", "and", "response" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller.php#L56-L62
6,224
slickframework/mvc
src/Controller.php
Controller.set
public function set($key, $value = null) { if (is_string($key)) { return $this->registerVar($key, $value); } foreach ($key as $name => $value) { $this->registerVar($name, $value); } return $this; }
php
public function set($key, $value = null) { if (is_string($key)) { return $this->registerVar($key, $value); } foreach ($key as $name => $value) { $this->registerVar($name, $value); } return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "registerVar", "(", "$", "key", ",", "$", "value", ")", ";", "}", "foreach", "(", "$", "key", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "registerVar", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets a value to be used by render The key argument can be an associative array with values to be set or a string naming the passed value. If an array is given then the value will be ignored. Those values must be set in the request attributes so they can be used latter by any other middle ware in the stack. @param string|array $key @param mixed $value @return Controller|$this|self|ControllerInterface
[ "Sets", "a", "value", "to", "be", "used", "by", "render" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller.php#L99-L109
6,225
slickframework/mvc
src/Controller.php
Controller.disableRendering
public function disableRendering($disable = true) { $this->request = $this->request->withAttribute('render', !$disable); return $this; }
php
public function disableRendering($disable = true) { $this->request = $this->request->withAttribute('render', !$disable); return $this; }
[ "public", "function", "disableRendering", "(", "$", "disable", "=", "true", ")", "{", "$", "this", "->", "request", "=", "$", "this", "->", "request", "->", "withAttribute", "(", "'render'", ",", "!", "$", "disable", ")", ";", "return", "$", "this", ";", "}" ]
Enables or disables rendering @param bool $disable @return ControllerInterface|self|$this
[ "Enables", "or", "disables", "rendering" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller.php#L127-L131
6,226
slickframework/mvc
src/Controller.php
Controller.getRouteAttributes
public function getRouteAttributes($name = null, $default = null) { /** @var Route $route */ $route = $this->request->getAttribute('route', false); $attributes = $route ? $route->attributes : []; if (null == $name) { return $attributes; } return array_key_exists($name, $attributes) ? $attributes[$name] : $default; }
php
public function getRouteAttributes($name = null, $default = null) { /** @var Route $route */ $route = $this->request->getAttribute('route', false); $attributes = $route ? $route->attributes : []; if (null == $name) { return $attributes; } return array_key_exists($name, $attributes) ? $attributes[$name] : $default; }
[ "public", "function", "getRouteAttributes", "(", "$", "name", "=", "null", ",", "$", "default", "=", "null", ")", "{", "/** @var Route $route */", "$", "route", "=", "$", "this", "->", "request", "->", "getAttribute", "(", "'route'", ",", "false", ")", ";", "$", "attributes", "=", "$", "route", "?", "$", "route", "->", "attributes", ":", "[", "]", ";", "if", "(", "null", "==", "$", "name", ")", "{", "return", "$", "attributes", ";", "}", "return", "array_key_exists", "(", "$", "name", ",", "$", "attributes", ")", "?", "$", "attributes", "[", "$", "name", "]", ":", "$", "default", ";", "}" ]
Get the routed request attributes @param null|string $name @param mixed $default @return mixed
[ "Get", "the", "routed", "request", "attributes" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller.php#L169-L184
6,227
logikostech/core
src/Application/Bootstrap.php
Bootstrap.getEventsManager
public function getEventsManager() { if (!is_object(parent::getEventsManager())) { $em = $this->getUserOption('eventsManager'); if (!is_object($em)) { $em = new EventsManager(); } $em->enablePriorities(true); $this->setEventsManager($em); } return parent::getEventsManager(); }
php
public function getEventsManager() { if (!is_object(parent::getEventsManager())) { $em = $this->getUserOption('eventsManager'); if (!is_object($em)) { $em = new EventsManager(); } $em->enablePriorities(true); $this->setEventsManager($em); } return parent::getEventsManager(); }
[ "public", "function", "getEventsManager", "(", ")", "{", "if", "(", "!", "is_object", "(", "parent", "::", "getEventsManager", "(", ")", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getUserOption", "(", "'eventsManager'", ")", ";", "if", "(", "!", "is_object", "(", "$", "em", ")", ")", "{", "$", "em", "=", "new", "EventsManager", "(", ")", ";", "}", "$", "em", "->", "enablePriorities", "(", "true", ")", ";", "$", "this", "->", "setEventsManager", "(", "$", "em", ")", ";", "}", "return", "parent", "::", "getEventsManager", "(", ")", ";", "}" ]
Returns the internal event manager @return \Phalcon\Events\ManagerInterface
[ "Returns", "the", "internal", "event", "manager" ]
b41e298af220219bd663b1b910b24df19bbca516
https://github.com/logikostech/core/blob/b41e298af220219bd663b1b910b24df19bbca516/src/Application/Bootstrap.php#L284-L294
6,228
sebastianmonzel/webfiles-framework-php
source/core/datastore/types/mail/MImapDatastore.php
MImapDatastore.getNextWebfileForTimestamp
public function getNextWebfileForTimestamp($time) { $webfiles = $this->getWebfilesAsStream()->getWebfiles(); ksort($webfiles); foreach ($webfiles as $key => $value) { if ($key > $time) { return $value; } } return null; }
php
public function getNextWebfileForTimestamp($time) { $webfiles = $this->getWebfilesAsStream()->getWebfiles(); ksort($webfiles); foreach ($webfiles as $key => $value) { if ($key > $time) { return $value; } } return null; }
[ "public", "function", "getNextWebfileForTimestamp", "(", "$", "time", ")", "{", "$", "webfiles", "=", "$", "this", "->", "getWebfilesAsStream", "(", ")", "->", "getWebfiles", "(", ")", ";", "ksort", "(", "$", "webfiles", ")", ";", "foreach", "(", "$", "webfiles", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", ">", "$", "time", ")", "{", "return", "$", "value", ";", "}", "}", "return", "null", ";", "}" ]
According to the given timestamp the next matching webfile will be searched and returned. @param int $time @return MWebfile
[ "According", "to", "the", "given", "timestamp", "the", "next", "matching", "webfile", "will", "be", "searched", "and", "returned", "." ]
5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d
https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datastore/types/mail/MImapDatastore.php#L61-L73
6,229
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.render
public function render() { $result = $this->arguments['result']; $this->conf = $this->arguments['conf']; $domImplementation = new \DOMImplementation(); $this->doc = $domImplementation->createDocument(); $li = $this->doc->createElement('li'); $this->doc->appendChild($li); $li->setAttribute('class', 'pz2-detailsVisible'); $iconElement = $this->doc->createElement('span'); $li->appendChild($iconElement); $mediaClass = 'other'; if (count($result['md-medium']) == 1) { $mediaClass = $result['md-medium'][0]['values'][0]; } elseif (count($result['md-medium']) > 1) { $mediaClass = 'multiple'; } $iconElement->setAttribute('class', 'pz2-mediaIcon ' . $mediaClass); $iconElement->setAttribute('title', LocalizationUtility::translate('media-type-' . $mediaClass, 'Pazpar2')); // basic title/author information $this->appendInfoToContainer($this->titleInfo($result), $li); $authors = $this->authorInfo($result); $this->appendInfoToContainer($authors, $li); // year or journal + year information $journal = $this->journalInfo($result); $this->appendInfoToContainer($journal, $li); if (!$journal) { $spaceBefore = ' '; if ($authors) { $spaceBefore = ', '; } $this->appendMarkupForFieldToContainer('date', $result, $li, $spaceBefore, '.'); } if ($this->conf['provideCOinSExport'] == 1) { // Insert COinS information $this->appendCOinSSpansToContainer($result, $li); } // detailed information about the publication $this->appendInfoToContainer($this->renderDetails($result), $li); return $this->doc->saveHTML(); }
php
public function render() { $result = $this->arguments['result']; $this->conf = $this->arguments['conf']; $domImplementation = new \DOMImplementation(); $this->doc = $domImplementation->createDocument(); $li = $this->doc->createElement('li'); $this->doc->appendChild($li); $li->setAttribute('class', 'pz2-detailsVisible'); $iconElement = $this->doc->createElement('span'); $li->appendChild($iconElement); $mediaClass = 'other'; if (count($result['md-medium']) == 1) { $mediaClass = $result['md-medium'][0]['values'][0]; } elseif (count($result['md-medium']) > 1) { $mediaClass = 'multiple'; } $iconElement->setAttribute('class', 'pz2-mediaIcon ' . $mediaClass); $iconElement->setAttribute('title', LocalizationUtility::translate('media-type-' . $mediaClass, 'Pazpar2')); // basic title/author information $this->appendInfoToContainer($this->titleInfo($result), $li); $authors = $this->authorInfo($result); $this->appendInfoToContainer($authors, $li); // year or journal + year information $journal = $this->journalInfo($result); $this->appendInfoToContainer($journal, $li); if (!$journal) { $spaceBefore = ' '; if ($authors) { $spaceBefore = ', '; } $this->appendMarkupForFieldToContainer('date', $result, $li, $spaceBefore, '.'); } if ($this->conf['provideCOinSExport'] == 1) { // Insert COinS information $this->appendCOinSSpansToContainer($result, $li); } // detailed information about the publication $this->appendInfoToContainer($this->renderDetails($result), $li); return $this->doc->saveHTML(); }
[ "public", "function", "render", "(", ")", "{", "$", "result", "=", "$", "this", "->", "arguments", "[", "'result'", "]", ";", "$", "this", "->", "conf", "=", "$", "this", "->", "arguments", "[", "'conf'", "]", ";", "$", "domImplementation", "=", "new", "\\", "DOMImplementation", "(", ")", ";", "$", "this", "->", "doc", "=", "$", "domImplementation", "->", "createDocument", "(", ")", ";", "$", "li", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'li'", ")", ";", "$", "this", "->", "doc", "->", "appendChild", "(", "$", "li", ")", ";", "$", "li", "->", "setAttribute", "(", "'class'", ",", "'pz2-detailsVisible'", ")", ";", "$", "iconElement", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'span'", ")", ";", "$", "li", "->", "appendChild", "(", "$", "iconElement", ")", ";", "$", "mediaClass", "=", "'other'", ";", "if", "(", "count", "(", "$", "result", "[", "'md-medium'", "]", ")", "==", "1", ")", "{", "$", "mediaClass", "=", "$", "result", "[", "'md-medium'", "]", "[", "0", "]", "[", "'values'", "]", "[", "0", "]", ";", "}", "elseif", "(", "count", "(", "$", "result", "[", "'md-medium'", "]", ")", ">", "1", ")", "{", "$", "mediaClass", "=", "'multiple'", ";", "}", "$", "iconElement", "->", "setAttribute", "(", "'class'", ",", "'pz2-mediaIcon '", ".", "$", "mediaClass", ")", ";", "$", "iconElement", "->", "setAttribute", "(", "'title'", ",", "LocalizationUtility", "::", "translate", "(", "'media-type-'", ".", "$", "mediaClass", ",", "'Pazpar2'", ")", ")", ";", "// basic title/author information", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "titleInfo", "(", "$", "result", ")", ",", "$", "li", ")", ";", "$", "authors", "=", "$", "this", "->", "authorInfo", "(", "$", "result", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "authors", ",", "$", "li", ")", ";", "// year or journal + year information", "$", "journal", "=", "$", "this", "->", "journalInfo", "(", "$", "result", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "journal", ",", "$", "li", ")", ";", "if", "(", "!", "$", "journal", ")", "{", "$", "spaceBefore", "=", "' '", ";", "if", "(", "$", "authors", ")", "{", "$", "spaceBefore", "=", "', '", ";", "}", "$", "this", "->", "appendMarkupForFieldToContainer", "(", "'date'", ",", "$", "result", ",", "$", "li", ",", "$", "spaceBefore", ",", "'.'", ")", ";", "}", "if", "(", "$", "this", "->", "conf", "[", "'provideCOinSExport'", "]", "==", "1", ")", "{", "// Insert COinS information", "$", "this", "->", "appendCOinSSpansToContainer", "(", "$", "result", ",", "$", "li", ")", ";", "}", "// detailed information about the publication", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "renderDetails", "(", "$", "result", ")", ",", "$", "li", ")", ";", "return", "$", "this", "->", "doc", "->", "saveHTML", "(", ")", ";", "}" ]
Main function called by Fluid. @return string
[ "Main", "function", "called", "by", "Fluid", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L83-L133
6,230
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.appendInfoToContainer
protected function appendInfoToContainer($info, $container) { if ($info && $container) { if (is_array($info) == false) { $container->appendChild($info); } else { foreach ($info as $infoItem) { $container->appendChild($infoItem); } } } }
php
protected function appendInfoToContainer($info, $container) { if ($info && $container) { if (is_array($info) == false) { $container->appendChild($info); } else { foreach ($info as $infoItem) { $container->appendChild($infoItem); } } } }
[ "protected", "function", "appendInfoToContainer", "(", "$", "info", ",", "$", "container", ")", "{", "if", "(", "$", "info", "&&", "$", "container", ")", "{", "if", "(", "is_array", "(", "$", "info", ")", "==", "false", ")", "{", "$", "container", "->", "appendChild", "(", "$", "info", ")", ";", "}", "else", "{", "foreach", "(", "$", "info", "as", "$", "infoItem", ")", "{", "$", "container", "->", "appendChild", "(", "$", "infoItem", ")", ";", "}", "}", "}", "}" ]
Convenince method to append an item to another one, even if undefineds and arrays are involved. @param $info - the DOM element(s) to insert @param \DOMElement $container - the DOM element to insert info to
[ "Convenince", "method", "to", "append", "an", "item", "to", "another", "one", "even", "if", "undefineds", "and", "arrays", "are", "involved", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L140-L151
6,231
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.appendMarkupForFieldToContainer
protected function appendMarkupForFieldToContainer($fieldName, $result, $container, $prepend = '', $append = '') { $span = null; $fieldContent = $result['md-' . $fieldName][0]['values'][0]; if ($fieldContent && $container) { $span = $this->doc->createElement('span'); $span->setAttribute('class', 'pz2-' . $fieldName); $span->appendChild($this->doc->createTextNode($fieldContent)); if ($prepend != '') { $container->appendChild($this->doc->createTextNode($prepend)); } $container->appendChild($span); if ($append != '') { $container->appendChild($this->doc->createTextNode($append)); } } return $span; }
php
protected function appendMarkupForFieldToContainer($fieldName, $result, $container, $prepend = '', $append = '') { $span = null; $fieldContent = $result['md-' . $fieldName][0]['values'][0]; if ($fieldContent && $container) { $span = $this->doc->createElement('span'); $span->setAttribute('class', 'pz2-' . $fieldName); $span->appendChild($this->doc->createTextNode($fieldContent)); if ($prepend != '') { $container->appendChild($this->doc->createTextNode($prepend)); } $container->appendChild($span); if ($append != '') { $container->appendChild($this->doc->createTextNode($append)); } } return $span; }
[ "protected", "function", "appendMarkupForFieldToContainer", "(", "$", "fieldName", ",", "$", "result", ",", "$", "container", ",", "$", "prepend", "=", "''", ",", "$", "append", "=", "''", ")", "{", "$", "span", "=", "null", ";", "$", "fieldContent", "=", "$", "result", "[", "'md-'", ".", "$", "fieldName", "]", "[", "0", "]", "[", "'values'", "]", "[", "0", "]", ";", "if", "(", "$", "fieldContent", "&&", "$", "container", ")", "{", "$", "span", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'span'", ")", ";", "$", "span", "->", "setAttribute", "(", "'class'", ",", "'pz2-'", ".", "$", "fieldName", ")", ";", "$", "span", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "$", "fieldContent", ")", ")", ";", "if", "(", "$", "prepend", "!=", "''", ")", "{", "$", "container", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "$", "prepend", ")", ")", ";", "}", "$", "container", "->", "appendChild", "(", "$", "span", ")", ";", "if", "(", "$", "append", "!=", "''", ")", "{", "$", "container", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "$", "append", ")", ")", ";", "}", "}", "return", "$", "span", ";", "}" ]
Creates span DOM element and content for a field name; Appends it to the given container. @param string $fieldName @param string $result result array to look the fieldName up in @param \DOMElement $container @param string $prepend @param string $append @return \DOMElement
[ "Creates", "span", "DOM", "element", "and", "content", "for", "a", "field", "name", ";", "Appends", "it", "to", "the", "given", "container", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L185-L207
6,232
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.titleInfo
protected function titleInfo($result) { $titleCompleteElement = $this->doc->createElement('span'); $titleCompleteElement->setAttribute('class', 'pz2-title-complete'); $titleMainElement = $this->doc->createElement('span'); $titleCompleteElement->appendChild($titleMainElement); $titleMainElement->setAttribute('class', 'pz2-title-main'); $this->appendMarkupForFieldToContainer('title', $result, $titleMainElement); $this->appendMarkupForFieldToContainer('multivolume-title', $result, $titleMainElement, ' '); $this->appendMarkupForFieldToContainer('title-remainder', $result, $titleCompleteElement, ' '); $this->appendMarkupForFieldToContainer('title-number-section', $result, $titleCompleteElement, ' '); $titleCompleteElement->appendChild($this->doc->createTextNode('. ')); return $titleCompleteElement; }
php
protected function titleInfo($result) { $titleCompleteElement = $this->doc->createElement('span'); $titleCompleteElement->setAttribute('class', 'pz2-title-complete'); $titleMainElement = $this->doc->createElement('span'); $titleCompleteElement->appendChild($titleMainElement); $titleMainElement->setAttribute('class', 'pz2-title-main'); $this->appendMarkupForFieldToContainer('title', $result, $titleMainElement); $this->appendMarkupForFieldToContainer('multivolume-title', $result, $titleMainElement, ' '); $this->appendMarkupForFieldToContainer('title-remainder', $result, $titleCompleteElement, ' '); $this->appendMarkupForFieldToContainer('title-number-section', $result, $titleCompleteElement, ' '); $titleCompleteElement->appendChild($this->doc->createTextNode('. ')); return $titleCompleteElement; }
[ "protected", "function", "titleInfo", "(", "$", "result", ")", "{", "$", "titleCompleteElement", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'span'", ")", ";", "$", "titleCompleteElement", "->", "setAttribute", "(", "'class'", ",", "'pz2-title-complete'", ")", ";", "$", "titleMainElement", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'span'", ")", ";", "$", "titleCompleteElement", "->", "appendChild", "(", "$", "titleMainElement", ")", ";", "$", "titleMainElement", "->", "setAttribute", "(", "'class'", ",", "'pz2-title-main'", ")", ";", "$", "this", "->", "appendMarkupForFieldToContainer", "(", "'title'", ",", "$", "result", ",", "$", "titleMainElement", ")", ";", "$", "this", "->", "appendMarkupForFieldToContainer", "(", "'multivolume-title'", ",", "$", "result", ",", "$", "titleMainElement", ",", "' '", ")", ";", "$", "this", "->", "appendMarkupForFieldToContainer", "(", "'title-remainder'", ",", "$", "result", ",", "$", "titleCompleteElement", ",", "' '", ")", ";", "$", "this", "->", "appendMarkupForFieldToContainer", "(", "'title-number-section'", ",", "$", "result", ",", "$", "titleCompleteElement", ",", "' '", ")", ";", "$", "titleCompleteElement", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "'. '", ")", ")", ";", "return", "$", "titleCompleteElement", ";", "}" ]
Returns DOM SPAN element with markup for the current hit's title. @param array $result @return \DOMElement
[ "Returns", "DOM", "SPAN", "element", "with", "markup", "for", "the", "current", "hit", "s", "title", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L214-L231
6,233
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.authorInfo
protected function authorInfo($result) { $outputElement = null; if ($result['md-title-responsibility'][0]['values']) { $outputText = implode('; ', $result['md-title-responsibility'][0]['values']); if (!$outputText && $result['md-author']) { $authors = []; foreach ($result['md-author'] as $index => $author) { if ($index < self::MAX_AUTHORS) { $authorName = $author['values'][0]; $authors[] = $authorName; } else { $authors[] = LocalizationUtility::translate('et al.', 'Pazpar2'); break; } } $outputText = implode('; ', $authors); } } if (isset($outputText)) { $outputElement = $this->doc->createElement('span'); $outputElement->setAttribute('class', 'pz2-item-responsibility'); $outputElement->appendChild($this->doc->createTextNode($outputText)); } return $outputElement; }
php
protected function authorInfo($result) { $outputElement = null; if ($result['md-title-responsibility'][0]['values']) { $outputText = implode('; ', $result['md-title-responsibility'][0]['values']); if (!$outputText && $result['md-author']) { $authors = []; foreach ($result['md-author'] as $index => $author) { if ($index < self::MAX_AUTHORS) { $authorName = $author['values'][0]; $authors[] = $authorName; } else { $authors[] = LocalizationUtility::translate('et al.', 'Pazpar2'); break; } } $outputText = implode('; ', $authors); } } if (isset($outputText)) { $outputElement = $this->doc->createElement('span'); $outputElement->setAttribute('class', 'pz2-item-responsibility'); $outputElement->appendChild($this->doc->createTextNode($outputText)); } return $outputElement; }
[ "protected", "function", "authorInfo", "(", "$", "result", ")", "{", "$", "outputElement", "=", "null", ";", "if", "(", "$", "result", "[", "'md-title-responsibility'", "]", "[", "0", "]", "[", "'values'", "]", ")", "{", "$", "outputText", "=", "implode", "(", "'; '", ",", "$", "result", "[", "'md-title-responsibility'", "]", "[", "0", "]", "[", "'values'", "]", ")", ";", "if", "(", "!", "$", "outputText", "&&", "$", "result", "[", "'md-author'", "]", ")", "{", "$", "authors", "=", "[", "]", ";", "foreach", "(", "$", "result", "[", "'md-author'", "]", "as", "$", "index", "=>", "$", "author", ")", "{", "if", "(", "$", "index", "<", "self", "::", "MAX_AUTHORS", ")", "{", "$", "authorName", "=", "$", "author", "[", "'values'", "]", "[", "0", "]", ";", "$", "authors", "[", "]", "=", "$", "authorName", ";", "}", "else", "{", "$", "authors", "[", "]", "=", "LocalizationUtility", "::", "translate", "(", "'et al.'", ",", "'Pazpar2'", ")", ";", "break", ";", "}", "}", "$", "outputText", "=", "implode", "(", "'; '", ",", "$", "authors", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "outputText", ")", ")", "{", "$", "outputElement", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'span'", ")", ";", "$", "outputElement", "->", "setAttribute", "(", "'class'", ",", "'pz2-item-responsibility'", ")", ";", "$", "outputElement", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "$", "outputText", ")", ")", ";", "}", "return", "$", "outputElement", ";", "}" ]
Returns DOM SPAN element with markup for the current hit's author information. The pre-formatted title-responsibility field is preferred and a list of author names is used as a fallback. @param array $result @return \DOMElement
[ "Returns", "DOM", "SPAN", "element", "with", "markup", "for", "the", "current", "hit", "s", "author", "information", ".", "The", "pre", "-", "formatted", "title", "-", "responsibility", "field", "is", "preferred", "and", "a", "list", "of", "author", "names", "is", "used", "as", "a", "fallback", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L240-L269
6,234
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.markupInfoItems
protected function markupInfoItems($infoItems) { $result = null; if (count($infoItems) == 1) { $result = $infoItems[0]; } else { $result = $this->doc->createElement('ul'); foreach ($infoItems as $item) { $li = $this->doc->createElement('li'); $result->appendChild($li); $li->appendChild($item); } } return $result; }
php
protected function markupInfoItems($infoItems) { $result = null; if (count($infoItems) == 1) { $result = $infoItems[0]; } else { $result = $this->doc->createElement('ul'); foreach ($infoItems as $item) { $li = $this->doc->createElement('li'); $result->appendChild($li); $li->appendChild($item); } } return $result; }
[ "protected", "function", "markupInfoItems", "(", "$", "infoItems", ")", "{", "$", "result", "=", "null", ";", "if", "(", "count", "(", "$", "infoItems", ")", "==", "1", ")", "{", "$", "result", "=", "$", "infoItems", "[", "0", "]", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'ul'", ")", ";", "foreach", "(", "$", "infoItems", "as", "$", "item", ")", "{", "$", "li", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'li'", ")", ";", "$", "result", "->", "appendChild", "(", "$", "li", ")", ";", "$", "li", "->", "appendChild", "(", "$", "item", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns marked up version of the DOM items passed, putting them into a list if necessary. @param array $elements (DOM Elements) @return array
[ "Returns", "marked", "up", "version", "of", "the", "DOM", "items", "passed", "putting", "them", "into", "a", "list", "if", "necessary", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L549-L565
6,235
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.locationDetails
protected function locationDetails($result) { $locationDetails = []; foreach ($result['location'] as $locationAll) { $location = $locationAll['ch']; $detailsData = $this->doc->createElement('dd'); if ($location['md-medium'][0]['values'][0] != 'article') { $this->appendInfoToContainer($this->detailInfoItem('edition', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('publication-name', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('publication-place', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('date', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('physical-extent', $location), $detailsData); } // $this->cleanISBNs(); not implemented in PHP version $this->appendInfoToContainer($this->detailInfoItem('isbn', $location), $detailsData); $this->appendInfoToContainer($this->electronicURLs($location, $result), $detailsData); $this->appendInfoToContainer($this->parentLink($locationAll, $result), $detailsData); $this->appendInfoToContainer($this->catalogueLink($locationAll), $detailsData); // Only append location information if additional details exist if ($detailsData->hasChildNodes()) { $detailsHeading = $this->doc->createElement('dt'); $locationDetails[] = $detailsHeading; $detailsHeading->appendChild($this->doc->createTextNode(LocalizationUtility::translate('Ausgabe', 'Pazpar2') . ':')); $locationDetails[] = $detailsData; } } return $locationDetails; }
php
protected function locationDetails($result) { $locationDetails = []; foreach ($result['location'] as $locationAll) { $location = $locationAll['ch']; $detailsData = $this->doc->createElement('dd'); if ($location['md-medium'][0]['values'][0] != 'article') { $this->appendInfoToContainer($this->detailInfoItem('edition', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('publication-name', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('publication-place', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('date', $location), $detailsData); $this->appendInfoToContainer($this->detailInfoItem('physical-extent', $location), $detailsData); } // $this->cleanISBNs(); not implemented in PHP version $this->appendInfoToContainer($this->detailInfoItem('isbn', $location), $detailsData); $this->appendInfoToContainer($this->electronicURLs($location, $result), $detailsData); $this->appendInfoToContainer($this->parentLink($locationAll, $result), $detailsData); $this->appendInfoToContainer($this->catalogueLink($locationAll), $detailsData); // Only append location information if additional details exist if ($detailsData->hasChildNodes()) { $detailsHeading = $this->doc->createElement('dt'); $locationDetails[] = $detailsHeading; $detailsHeading->appendChild($this->doc->createTextNode(LocalizationUtility::translate('Ausgabe', 'Pazpar2') . ':')); $locationDetails[] = $detailsData; } } return $locationDetails; }
[ "protected", "function", "locationDetails", "(", "$", "result", ")", "{", "$", "locationDetails", "=", "[", "]", ";", "foreach", "(", "$", "result", "[", "'location'", "]", "as", "$", "locationAll", ")", "{", "$", "location", "=", "$", "locationAll", "[", "'ch'", "]", ";", "$", "detailsData", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'dd'", ")", ";", "if", "(", "$", "location", "[", "'md-medium'", "]", "[", "0", "]", "[", "'values'", "]", "[", "0", "]", "!=", "'article'", ")", "{", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "detailInfoItem", "(", "'edition'", ",", "$", "location", ")", ",", "$", "detailsData", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "detailInfoItem", "(", "'publication-name'", ",", "$", "location", ")", ",", "$", "detailsData", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "detailInfoItem", "(", "'publication-place'", ",", "$", "location", ")", ",", "$", "detailsData", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "detailInfoItem", "(", "'date'", ",", "$", "location", ")", ",", "$", "detailsData", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "detailInfoItem", "(", "'physical-extent'", ",", "$", "location", ")", ",", "$", "detailsData", ")", ";", "}", "// $this->cleanISBNs(); not implemented in PHP version", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "detailInfoItem", "(", "'isbn'", ",", "$", "location", ")", ",", "$", "detailsData", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "electronicURLs", "(", "$", "location", ",", "$", "result", ")", ",", "$", "detailsData", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "parentLink", "(", "$", "locationAll", ",", "$", "result", ")", ",", "$", "detailsData", ")", ";", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "catalogueLink", "(", "$", "locationAll", ")", ",", "$", "detailsData", ")", ";", "// Only append location information if additional details exist", "if", "(", "$", "detailsData", "->", "hasChildNodes", "(", ")", ")", "{", "$", "detailsHeading", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'dt'", ")", ";", "$", "locationDetails", "[", "]", "=", "$", "detailsHeading", ";", "$", "detailsHeading", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "LocalizationUtility", "::", "translate", "(", "'Ausgabe'", ",", "'Pazpar2'", ")", ".", "':'", ")", ")", ";", "$", "locationDetails", "[", "]", "=", "$", "detailsData", ";", "}", "}", "return", "$", "locationDetails", ";", "}" ]
Returns markup for each location of the item found from the current data. @param array $result @return array of DOM elements
[ "Returns", "markup", "for", "each", "location", "of", "the", "item", "found", "from", "the", "current", "data", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L572-L603
6,236
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.cleanURLList
protected function cleanURLList($location, $result) { $URLs = $location['md-electronic-url']; if ($URLs) { // Figure out which URLs are duplicates and collect indexes of those to remove. $indexesToRemove = []; foreach ($URLs as $URLIndex => &$URLInfo) { $URLInfo['attrs']['originalPosition'] = $URLIndex; $URL = $URLInfo['values'][0]; // Check for duplicates in the electronic-urls field. for ($remainingURLIndex = $URLIndex + 1; $remainingURLIndex < count($URLs); $remainingURLIndex++) { $remainingURLInfo = $URLs[$remainingURLIndex]; $remainingURL = $remainingURLInfo['values'][0]; if ($URL == $remainingURL) { // Two of the URLs are identical. // Keep the one with the title if only one of them has one, // keep the first one otherwise. $URLIndexToRemove = $URLIndex + $remainingURLIndex; if (!$URLInfo['attrs'] && $remainingURLInfo['attrs']) { $URLIndexToRemove = $URLIndex; } $indexesToRemove[$URLIndexToRemove] = true; } } // Check for duplicates among the DOIs. $DOIs = $result['md-doi']; if ($DOIs) { foreach ($DOIs as $DOI) { if (strpos($DOI['values'][0], $URL) !== false) { $indexesToRemove[$URLIndexToRemove] = true; break; } } } } // Remove the duplicate URLs. foreach (array_keys($indexesToRemove) as $index) { $URLs[$index] = false; } $URLs = array_filter($URLs); // Re-order URLs so those with explicit labels appear at the beginning. usort($URLs, [$this, 'URLSort']); } return $URLs; }
php
protected function cleanURLList($location, $result) { $URLs = $location['md-electronic-url']; if ($URLs) { // Figure out which URLs are duplicates and collect indexes of those to remove. $indexesToRemove = []; foreach ($URLs as $URLIndex => &$URLInfo) { $URLInfo['attrs']['originalPosition'] = $URLIndex; $URL = $URLInfo['values'][0]; // Check for duplicates in the electronic-urls field. for ($remainingURLIndex = $URLIndex + 1; $remainingURLIndex < count($URLs); $remainingURLIndex++) { $remainingURLInfo = $URLs[$remainingURLIndex]; $remainingURL = $remainingURLInfo['values'][0]; if ($URL == $remainingURL) { // Two of the URLs are identical. // Keep the one with the title if only one of them has one, // keep the first one otherwise. $URLIndexToRemove = $URLIndex + $remainingURLIndex; if (!$URLInfo['attrs'] && $remainingURLInfo['attrs']) { $URLIndexToRemove = $URLIndex; } $indexesToRemove[$URLIndexToRemove] = true; } } // Check for duplicates among the DOIs. $DOIs = $result['md-doi']; if ($DOIs) { foreach ($DOIs as $DOI) { if (strpos($DOI['values'][0], $URL) !== false) { $indexesToRemove[$URLIndexToRemove] = true; break; } } } } // Remove the duplicate URLs. foreach (array_keys($indexesToRemove) as $index) { $URLs[$index] = false; } $URLs = array_filter($URLs); // Re-order URLs so those with explicit labels appear at the beginning. usort($URLs, [$this, 'URLSort']); } return $URLs; }
[ "protected", "function", "cleanURLList", "(", "$", "location", ",", "$", "result", ")", "{", "$", "URLs", "=", "$", "location", "[", "'md-electronic-url'", "]", ";", "if", "(", "$", "URLs", ")", "{", "// Figure out which URLs are duplicates and collect indexes of those to remove.", "$", "indexesToRemove", "=", "[", "]", ";", "foreach", "(", "$", "URLs", "as", "$", "URLIndex", "=>", "&", "$", "URLInfo", ")", "{", "$", "URLInfo", "[", "'attrs'", "]", "[", "'originalPosition'", "]", "=", "$", "URLIndex", ";", "$", "URL", "=", "$", "URLInfo", "[", "'values'", "]", "[", "0", "]", ";", "// Check for duplicates in the electronic-urls field.", "for", "(", "$", "remainingURLIndex", "=", "$", "URLIndex", "+", "1", ";", "$", "remainingURLIndex", "<", "count", "(", "$", "URLs", ")", ";", "$", "remainingURLIndex", "++", ")", "{", "$", "remainingURLInfo", "=", "$", "URLs", "[", "$", "remainingURLIndex", "]", ";", "$", "remainingURL", "=", "$", "remainingURLInfo", "[", "'values'", "]", "[", "0", "]", ";", "if", "(", "$", "URL", "==", "$", "remainingURL", ")", "{", "// Two of the URLs are identical.", "// Keep the one with the title if only one of them has one,", "// keep the first one otherwise.", "$", "URLIndexToRemove", "=", "$", "URLIndex", "+", "$", "remainingURLIndex", ";", "if", "(", "!", "$", "URLInfo", "[", "'attrs'", "]", "&&", "$", "remainingURLInfo", "[", "'attrs'", "]", ")", "{", "$", "URLIndexToRemove", "=", "$", "URLIndex", ";", "}", "$", "indexesToRemove", "[", "$", "URLIndexToRemove", "]", "=", "true", ";", "}", "}", "// Check for duplicates among the DOIs.", "$", "DOIs", "=", "$", "result", "[", "'md-doi'", "]", ";", "if", "(", "$", "DOIs", ")", "{", "foreach", "(", "$", "DOIs", "as", "$", "DOI", ")", "{", "if", "(", "strpos", "(", "$", "DOI", "[", "'values'", "]", "[", "0", "]", ",", "$", "URL", ")", "!==", "false", ")", "{", "$", "indexesToRemove", "[", "$", "URLIndexToRemove", "]", "=", "true", ";", "break", ";", "}", "}", "}", "}", "// Remove the duplicate URLs.", "foreach", "(", "array_keys", "(", "$", "indexesToRemove", ")", "as", "$", "index", ")", "{", "$", "URLs", "[", "$", "index", "]", "=", "false", ";", "}", "$", "URLs", "=", "array_filter", "(", "$", "URLs", ")", ";", "// Re-order URLs so those with explicit labels appear at the beginning.", "usort", "(", "$", "URLs", ",", "[", "$", "this", ",", "'URLSort'", "]", ")", ";", "}", "return", "$", "URLs", ";", "}" ]
Returns a cleaned and sorted list of the URLs in the md-electronic-url fields. @param array $location @param array $result the result containing $location @return array subarray of $location without duplicates and sorted
[ "Returns", "a", "cleaned", "and", "sorted", "list", "of", "the", "URLs", "in", "the", "md", "-", "electronic", "-", "url", "fields", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L693-L742
6,237
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.electronicURLs
protected function electronicURLs($location, $result) { $electronicURLs = $this->cleanURLList($location, $result); $URLsContainer = null; if ($electronicURLs && count($electronicURLs) != 0) { $URLsContainer = $this->doc->createElement('span'); foreach ($electronicURLs as $URLInfo) { $linkTexts = []; $linkURL = $URLInfo['values'][0]; if ($URLInfo['attrs']['name']) { $linkTexts[] = $URLInfo['attrs']['name']; if ($URLInfo['attrs']['note']) { $linkTexts[] = $URLInfo['attrs']['note']; } } elseif ($URLInfo['attrs']['note']) { $linkTexts[] = $URLInfo['attrs']['note']; } elseif ($URLInfo['attrs']['fulltextfile']) { $linkTexts[] = 'Document'; } else { $linkTexts[] = 'Link'; } $localisedLinkTexts = []; foreach ($linkTexts as $linkText) { $localisedLinkText = LocalizationUtility::translate('link-description-' . $linkText, 'Pazpar2'); if (!$localisedLinkText) { $localisedLinkText = $linkText; } $localisedLinkTexts[] = $localisedLinkText; } $linkText = '[' . implode(', ', $localisedLinkTexts) . ']'; if ($URLsContainer->hasChildNodes()) { $URLsContainer->appendChild($this->doc->createTextNode(', ')); } $link = $this->doc->createElement('a'); $URLsContainer->appendChild($link); $link->setAttribute('class', 'pz2-electronic-url'); $link->setAttribute('href', $linkURL); $this->turnIntoNewWindowLink($link); $link->appendChild($this->doc->createTextNode($linkText)); } $URLsContainer->appendChild($this->doc->createTextNode('; ')); } return $URLsContainer; }
php
protected function electronicURLs($location, $result) { $electronicURLs = $this->cleanURLList($location, $result); $URLsContainer = null; if ($electronicURLs && count($electronicURLs) != 0) { $URLsContainer = $this->doc->createElement('span'); foreach ($electronicURLs as $URLInfo) { $linkTexts = []; $linkURL = $URLInfo['values'][0]; if ($URLInfo['attrs']['name']) { $linkTexts[] = $URLInfo['attrs']['name']; if ($URLInfo['attrs']['note']) { $linkTexts[] = $URLInfo['attrs']['note']; } } elseif ($URLInfo['attrs']['note']) { $linkTexts[] = $URLInfo['attrs']['note']; } elseif ($URLInfo['attrs']['fulltextfile']) { $linkTexts[] = 'Document'; } else { $linkTexts[] = 'Link'; } $localisedLinkTexts = []; foreach ($linkTexts as $linkText) { $localisedLinkText = LocalizationUtility::translate('link-description-' . $linkText, 'Pazpar2'); if (!$localisedLinkText) { $localisedLinkText = $linkText; } $localisedLinkTexts[] = $localisedLinkText; } $linkText = '[' . implode(', ', $localisedLinkTexts) . ']'; if ($URLsContainer->hasChildNodes()) { $URLsContainer->appendChild($this->doc->createTextNode(', ')); } $link = $this->doc->createElement('a'); $URLsContainer->appendChild($link); $link->setAttribute('class', 'pz2-electronic-url'); $link->setAttribute('href', $linkURL); $this->turnIntoNewWindowLink($link); $link->appendChild($this->doc->createTextNode($linkText)); } $URLsContainer->appendChild($this->doc->createTextNode('; ')); } return $URLsContainer; }
[ "protected", "function", "electronicURLs", "(", "$", "location", ",", "$", "result", ")", "{", "$", "electronicURLs", "=", "$", "this", "->", "cleanURLList", "(", "$", "location", ",", "$", "result", ")", ";", "$", "URLsContainer", "=", "null", ";", "if", "(", "$", "electronicURLs", "&&", "count", "(", "$", "electronicURLs", ")", "!=", "0", ")", "{", "$", "URLsContainer", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'span'", ")", ";", "foreach", "(", "$", "electronicURLs", "as", "$", "URLInfo", ")", "{", "$", "linkTexts", "=", "[", "]", ";", "$", "linkURL", "=", "$", "URLInfo", "[", "'values'", "]", "[", "0", "]", ";", "if", "(", "$", "URLInfo", "[", "'attrs'", "]", "[", "'name'", "]", ")", "{", "$", "linkTexts", "[", "]", "=", "$", "URLInfo", "[", "'attrs'", "]", "[", "'name'", "]", ";", "if", "(", "$", "URLInfo", "[", "'attrs'", "]", "[", "'note'", "]", ")", "{", "$", "linkTexts", "[", "]", "=", "$", "URLInfo", "[", "'attrs'", "]", "[", "'note'", "]", ";", "}", "}", "elseif", "(", "$", "URLInfo", "[", "'attrs'", "]", "[", "'note'", "]", ")", "{", "$", "linkTexts", "[", "]", "=", "$", "URLInfo", "[", "'attrs'", "]", "[", "'note'", "]", ";", "}", "elseif", "(", "$", "URLInfo", "[", "'attrs'", "]", "[", "'fulltextfile'", "]", ")", "{", "$", "linkTexts", "[", "]", "=", "'Document'", ";", "}", "else", "{", "$", "linkTexts", "[", "]", "=", "'Link'", ";", "}", "$", "localisedLinkTexts", "=", "[", "]", ";", "foreach", "(", "$", "linkTexts", "as", "$", "linkText", ")", "{", "$", "localisedLinkText", "=", "LocalizationUtility", "::", "translate", "(", "'link-description-'", ".", "$", "linkText", ",", "'Pazpar2'", ")", ";", "if", "(", "!", "$", "localisedLinkText", ")", "{", "$", "localisedLinkText", "=", "$", "linkText", ";", "}", "$", "localisedLinkTexts", "[", "]", "=", "$", "localisedLinkText", ";", "}", "$", "linkText", "=", "'['", ".", "implode", "(", "', '", ",", "$", "localisedLinkTexts", ")", ".", "']'", ";", "if", "(", "$", "URLsContainer", "->", "hasChildNodes", "(", ")", ")", "{", "$", "URLsContainer", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "', '", ")", ")", ";", "}", "$", "link", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'a'", ")", ";", "$", "URLsContainer", "->", "appendChild", "(", "$", "link", ")", ";", "$", "link", "->", "setAttribute", "(", "'class'", ",", "'pz2-electronic-url'", ")", ";", "$", "link", "->", "setAttribute", "(", "'href'", ",", "$", "linkURL", ")", ";", "$", "this", "->", "turnIntoNewWindowLink", "(", "$", "link", ")", ";", "$", "link", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "$", "linkText", ")", ")", ";", "}", "$", "URLsContainer", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "'; '", ")", ")", ";", "}", "return", "$", "URLsContainer", ";", "}" ]
Create markup for URLs in current location data. @param array $location @param array $result the result containing $location @return \DOMElement
[ "Create", "markup", "for", "URLs", "in", "current", "location", "data", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L750-L800
6,238
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.catalogueLink
protected function catalogueLink($locationAll) { $linkElement = null; $URL = $locationAll['ch']['md-catalogue-url'][0]['values'][0]; $targetName = $locationAll['attrs']['name']; if ($URL && $targetName) { $linkElement = $this->doc->createElement('a'); $linkElement->setAttribute('href', $URL); $linkTitle = LocalizationUtility::translate('Im Katalog ansehen', 'Pazpar2'); $linkElement->setAttribute('title', $linkTitle); $this->turnIntoNewWindowLink($linkElement); $linkElement->setAttribute('class', 'pz2-detail-catalogueLink'); /* Try to localise catalogue name, fall back to original target name if no localisation is available */ $linkText = LocalizationUtility::translate('catalogue-name-' . $targetName, 'Pazpar2'); if ($linkText === null) { $linkText = $targetName; } $linkElement->appendChild($this->doc->createTextNode($linkText)); } return $linkElement; }
php
protected function catalogueLink($locationAll) { $linkElement = null; $URL = $locationAll['ch']['md-catalogue-url'][0]['values'][0]; $targetName = $locationAll['attrs']['name']; if ($URL && $targetName) { $linkElement = $this->doc->createElement('a'); $linkElement->setAttribute('href', $URL); $linkTitle = LocalizationUtility::translate('Im Katalog ansehen', 'Pazpar2'); $linkElement->setAttribute('title', $linkTitle); $this->turnIntoNewWindowLink($linkElement); $linkElement->setAttribute('class', 'pz2-detail-catalogueLink'); /* Try to localise catalogue name, fall back to original target name if no localisation is available */ $linkText = LocalizationUtility::translate('catalogue-name-' . $targetName, 'Pazpar2'); if ($linkText === null) { $linkText = $targetName; } $linkElement->appendChild($this->doc->createTextNode($linkText)); } return $linkElement; }
[ "protected", "function", "catalogueLink", "(", "$", "locationAll", ")", "{", "$", "linkElement", "=", "null", ";", "$", "URL", "=", "$", "locationAll", "[", "'ch'", "]", "[", "'md-catalogue-url'", "]", "[", "0", "]", "[", "'values'", "]", "[", "0", "]", ";", "$", "targetName", "=", "$", "locationAll", "[", "'attrs'", "]", "[", "'name'", "]", ";", "if", "(", "$", "URL", "&&", "$", "targetName", ")", "{", "$", "linkElement", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'a'", ")", ";", "$", "linkElement", "->", "setAttribute", "(", "'href'", ",", "$", "URL", ")", ";", "$", "linkTitle", "=", "LocalizationUtility", "::", "translate", "(", "'Im Katalog ansehen'", ",", "'Pazpar2'", ")", ";", "$", "linkElement", "->", "setAttribute", "(", "'title'", ",", "$", "linkTitle", ")", ";", "$", "this", "->", "turnIntoNewWindowLink", "(", "$", "linkElement", ")", ";", "$", "linkElement", "->", "setAttribute", "(", "'class'", ",", "'pz2-detail-catalogueLink'", ")", ";", "/* Try to localise catalogue name, fall back to original target name\n if no localisation is available */", "$", "linkText", "=", "LocalizationUtility", "::", "translate", "(", "'catalogue-name-'", ".", "$", "targetName", ",", "'Pazpar2'", ")", ";", "if", "(", "$", "linkText", "===", "null", ")", "{", "$", "linkText", "=", "$", "targetName", ";", "}", "$", "linkElement", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "$", "linkText", ")", ")", ";", "}", "return", "$", "linkElement", ";", "}" ]
Returns a link for the current record that points to the catalogue page for that item. @param array $locationAll @return \DOMElement
[ "Returns", "a", "link", "for", "the", "current", "record", "that", "points", "to", "the", "catalogue", "page", "for", "that", "item", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L835-L859
6,239
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.exportLinks
protected function exportLinks($result) { $extraLinkList = $this->doc->createElement('ul'); $labelFormat = LocalizationUtility::translate('download-label-format-simple', 'Pazpar2'); if (count($result['location']) > 1) { $labelFormat = LocalizationUtility::translate('download-label-format-all', 'Pazpar2'); } if ($this->conf['showKVKLink'] == 1) { $this->appendInfoToContainer($this->KVKItem($result), $extraLinkList); } $this->appendExportItemsTo($result['location'], $labelFormat, $extraLinkList); // Separate submenus for individual locations not implemented in the PHP version. $exportLinks = null; if ($extraLinkList->hasChildNodes()) { $exportLinks = $this->doc->createElement('div'); $exportLinks->setAttribute('class', 'pz2-extraLinks'); $exportLinksLabel = $this->doc->createElement('span'); $exportLinks->appendChild($exportLinksLabel); $exportLinksLabel->setAttribute('class', 'pz2-extraLinksLabel'); $exportLinksLabel->appendChild($this->doc->createTextNode(LocalizationUtility::translate('mehr Links', 'Pazpar2'))); $exportLinks->appendChild($extraLinkList); } return $exportLinks; }
php
protected function exportLinks($result) { $extraLinkList = $this->doc->createElement('ul'); $labelFormat = LocalizationUtility::translate('download-label-format-simple', 'Pazpar2'); if (count($result['location']) > 1) { $labelFormat = LocalizationUtility::translate('download-label-format-all', 'Pazpar2'); } if ($this->conf['showKVKLink'] == 1) { $this->appendInfoToContainer($this->KVKItem($result), $extraLinkList); } $this->appendExportItemsTo($result['location'], $labelFormat, $extraLinkList); // Separate submenus for individual locations not implemented in the PHP version. $exportLinks = null; if ($extraLinkList->hasChildNodes()) { $exportLinks = $this->doc->createElement('div'); $exportLinks->setAttribute('class', 'pz2-extraLinks'); $exportLinksLabel = $this->doc->createElement('span'); $exportLinks->appendChild($exportLinksLabel); $exportLinksLabel->setAttribute('class', 'pz2-extraLinksLabel'); $exportLinksLabel->appendChild($this->doc->createTextNode(LocalizationUtility::translate('mehr Links', 'Pazpar2'))); $exportLinks->appendChild($extraLinkList); } return $exportLinks; }
[ "protected", "function", "exportLinks", "(", "$", "result", ")", "{", "$", "extraLinkList", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'ul'", ")", ";", "$", "labelFormat", "=", "LocalizationUtility", "::", "translate", "(", "'download-label-format-simple'", ",", "'Pazpar2'", ")", ";", "if", "(", "count", "(", "$", "result", "[", "'location'", "]", ")", ">", "1", ")", "{", "$", "labelFormat", "=", "LocalizationUtility", "::", "translate", "(", "'download-label-format-all'", ",", "'Pazpar2'", ")", ";", "}", "if", "(", "$", "this", "->", "conf", "[", "'showKVKLink'", "]", "==", "1", ")", "{", "$", "this", "->", "appendInfoToContainer", "(", "$", "this", "->", "KVKItem", "(", "$", "result", ")", ",", "$", "extraLinkList", ")", ";", "}", "$", "this", "->", "appendExportItemsTo", "(", "$", "result", "[", "'location'", "]", ",", "$", "labelFormat", ",", "$", "extraLinkList", ")", ";", "// Separate submenus for individual locations not implemented in the PHP version.", "$", "exportLinks", "=", "null", ";", "if", "(", "$", "extraLinkList", "->", "hasChildNodes", "(", ")", ")", "{", "$", "exportLinks", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'div'", ")", ";", "$", "exportLinks", "->", "setAttribute", "(", "'class'", ",", "'pz2-extraLinks'", ")", ";", "$", "exportLinksLabel", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'span'", ")", ";", "$", "exportLinks", "->", "appendChild", "(", "$", "exportLinksLabel", ")", ";", "$", "exportLinksLabel", "->", "setAttribute", "(", "'class'", ",", "'pz2-extraLinksLabel'", ")", ";", "$", "exportLinksLabel", "->", "appendChild", "(", "$", "this", "->", "doc", "->", "createTextNode", "(", "LocalizationUtility", "::", "translate", "(", "'mehr Links'", ",", "'Pazpar2'", ")", ")", ")", ";", "$", "exportLinks", "->", "appendChild", "(", "$", "extraLinkList", ")", ";", "}", "return", "$", "exportLinks", ";", "}" ]
Returns markup for links to each active export format. @param array $result @return \DOMElement
[ "Returns", "markup", "for", "links", "to", "each", "active", "export", "format", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L999-L1025
6,240
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.appendExportItemsTo
protected function appendExportItemsTo($locations, $labelFormat, $container) { foreach ($this->conf['exportFormats'] as $name => $active) { if ($active) { $container->appendChild($this->exportItem($locations, $name, $labelFormat)); } } }
php
protected function appendExportItemsTo($locations, $labelFormat, $container) { foreach ($this->conf['exportFormats'] as $name => $active) { if ($active) { $container->appendChild($this->exportItem($locations, $name, $labelFormat)); } } }
[ "protected", "function", "appendExportItemsTo", "(", "$", "locations", ",", "$", "labelFormat", ",", "$", "container", ")", "{", "foreach", "(", "$", "this", "->", "conf", "[", "'exportFormats'", "]", "as", "$", "name", "=>", "$", "active", ")", "{", "if", "(", "$", "active", ")", "{", "$", "container", "->", "appendChild", "(", "$", "this", "->", "exportItem", "(", "$", "locations", ",", "$", "name", ",", "$", "labelFormat", ")", ")", ";", "}", "}", "}" ]
Appends list items with an export form for each exportFormat to the container. @param array $locations @param string $labelFormat @param \DOMElement $container
[ "Appends", "list", "items", "with", "an", "export", "form", "for", "each", "exportFormat", "to", "the", "container", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L1034-L1041
6,241
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.exportItem
protected function exportItem($locations, $exportFormat, $labelFormat) { $form = $this->dataConversionForm($locations, $exportFormat, $labelFormat); $item = null; if ($form) { $item = $this->doc->createElement('li'); $item->appendChild($form); } return $item; }
php
protected function exportItem($locations, $exportFormat, $labelFormat) { $form = $this->dataConversionForm($locations, $exportFormat, $labelFormat); $item = null; if ($form) { $item = $this->doc->createElement('li'); $item->appendChild($form); } return $item; }
[ "protected", "function", "exportItem", "(", "$", "locations", ",", "$", "exportFormat", ",", "$", "labelFormat", ")", "{", "$", "form", "=", "$", "this", "->", "dataConversionForm", "(", "$", "locations", ",", "$", "exportFormat", ",", "$", "labelFormat", ")", ";", "$", "item", "=", "null", ";", "if", "(", "$", "form", ")", "{", "$", "item", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'li'", ")", ";", "$", "item", "->", "appendChild", "(", "$", "form", ")", ";", "}", "return", "$", "item", ";", "}" ]
Returns a list item containing the form for export data conversion. The parameters are passed to dataConversionForm. @param array $locations @param string $exportFormat @param string $labelFormat @return \DOMElement
[ "Returns", "a", "list", "item", "containing", "the", "form", "for", "export", "data", "conversion", ".", "The", "parameters", "are", "passed", "to", "dataConversionForm", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L1052-L1062
6,242
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.dataConversionForm
protected function dataConversionForm($locations, $exportFormat, $labelFormat) { $recordXML = $this->XMLForLocations($locations); $XMLString = $recordXML->saveXML(); $form = null; if ($XMLString) { $form = $this->doc->createElement('form'); $form->setAttribute('method', 'POST'); $scriptPath = 'typo3conf/ext/pazpar2/Resources/Public/pz2-client/converter/convert-pazpar2-record.php'; $scriptGetParameters = ['format' => $exportFormat]; if ($GLOBALS['TSFE']->lang) { $scriptGetParameters['language'] = $GLOBALS['TSFE']->lang; } if ($this->conf['siteName']) { $scriptGetParameters['filename'] = $this->conf['siteName']; } $form->setAttribute('action', $scriptPath . '?' . http_build_query($scriptGetParameters)); $qInput = $this->doc->createElement('input'); $qInput->setAttribute('name', 'q'); $qInput->setAttribute('type', 'hidden'); $qInput->setAttribute('value', $XMLString); $form->appendChild($qInput); $submitButton = $this->doc->createElement('input'); $form->appendChild($submitButton); $submitButton->setAttribute('type', 'submit'); $buttonText = LocalizationUtility::translate('download-label-' . $exportFormat, 'Pazpar2'); $submitButton->setAttribute('value', $buttonText); if ($labelFormat) { $labelText = str_replace('*', $buttonText, $labelFormat); $submitButton->setAttribute('title', $labelText); } } return $form; }
php
protected function dataConversionForm($locations, $exportFormat, $labelFormat) { $recordXML = $this->XMLForLocations($locations); $XMLString = $recordXML->saveXML(); $form = null; if ($XMLString) { $form = $this->doc->createElement('form'); $form->setAttribute('method', 'POST'); $scriptPath = 'typo3conf/ext/pazpar2/Resources/Public/pz2-client/converter/convert-pazpar2-record.php'; $scriptGetParameters = ['format' => $exportFormat]; if ($GLOBALS['TSFE']->lang) { $scriptGetParameters['language'] = $GLOBALS['TSFE']->lang; } if ($this->conf['siteName']) { $scriptGetParameters['filename'] = $this->conf['siteName']; } $form->setAttribute('action', $scriptPath . '?' . http_build_query($scriptGetParameters)); $qInput = $this->doc->createElement('input'); $qInput->setAttribute('name', 'q'); $qInput->setAttribute('type', 'hidden'); $qInput->setAttribute('value', $XMLString); $form->appendChild($qInput); $submitButton = $this->doc->createElement('input'); $form->appendChild($submitButton); $submitButton->setAttribute('type', 'submit'); $buttonText = LocalizationUtility::translate('download-label-' . $exportFormat, 'Pazpar2'); $submitButton->setAttribute('value', $buttonText); if ($labelFormat) { $labelText = str_replace('*', $buttonText, $labelFormat); $submitButton->setAttribute('title', $labelText); } } return $form; }
[ "protected", "function", "dataConversionForm", "(", "$", "locations", ",", "$", "exportFormat", ",", "$", "labelFormat", ")", "{", "$", "recordXML", "=", "$", "this", "->", "XMLForLocations", "(", "$", "locations", ")", ";", "$", "XMLString", "=", "$", "recordXML", "->", "saveXML", "(", ")", ";", "$", "form", "=", "null", ";", "if", "(", "$", "XMLString", ")", "{", "$", "form", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'form'", ")", ";", "$", "form", "->", "setAttribute", "(", "'method'", ",", "'POST'", ")", ";", "$", "scriptPath", "=", "'typo3conf/ext/pazpar2/Resources/Public/pz2-client/converter/convert-pazpar2-record.php'", ";", "$", "scriptGetParameters", "=", "[", "'format'", "=>", "$", "exportFormat", "]", ";", "if", "(", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "lang", ")", "{", "$", "scriptGetParameters", "[", "'language'", "]", "=", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "lang", ";", "}", "if", "(", "$", "this", "->", "conf", "[", "'siteName'", "]", ")", "{", "$", "scriptGetParameters", "[", "'filename'", "]", "=", "$", "this", "->", "conf", "[", "'siteName'", "]", ";", "}", "$", "form", "->", "setAttribute", "(", "'action'", ",", "$", "scriptPath", ".", "'?'", ".", "http_build_query", "(", "$", "scriptGetParameters", ")", ")", ";", "$", "qInput", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'input'", ")", ";", "$", "qInput", "->", "setAttribute", "(", "'name'", ",", "'q'", ")", ";", "$", "qInput", "->", "setAttribute", "(", "'type'", ",", "'hidden'", ")", ";", "$", "qInput", "->", "setAttribute", "(", "'value'", ",", "$", "XMLString", ")", ";", "$", "form", "->", "appendChild", "(", "$", "qInput", ")", ";", "$", "submitButton", "=", "$", "this", "->", "doc", "->", "createElement", "(", "'input'", ")", ";", "$", "form", "->", "appendChild", "(", "$", "submitButton", ")", ";", "$", "submitButton", "->", "setAttribute", "(", "'type'", ",", "'submit'", ")", ";", "$", "buttonText", "=", "LocalizationUtility", "::", "translate", "(", "'download-label-'", ".", "$", "exportFormat", ",", "'Pazpar2'", ")", ";", "$", "submitButton", "->", "setAttribute", "(", "'value'", ",", "$", "buttonText", ")", ";", "if", "(", "$", "labelFormat", ")", "{", "$", "labelText", "=", "str_replace", "(", "'*'", ",", "$", "buttonText", ",", "$", "labelFormat", ")", ";", "$", "submitButton", "->", "setAttribute", "(", "'title'", ",", "$", "labelText", ")", ";", "}", "}", "return", "$", "form", ";", "}" ]
Returns form Element containing the record information to initiate data conversion. @param array $locations @param string $exportFormat @param string $labelFormat @return \DOMElement
[ "Returns", "form", "Element", "containing", "the", "record", "information", "to", "initiate", "data", "conversion", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L1071-L1108
6,243
subugoe/typo3-pazpar2
Classes/ViewHelpers/ResultViewHelper.php
ResultViewHelper.XMLForLocations
protected function XMLForLocations($locations) { $XML = new \DOMDocument(); $locationsElement = $XML->createElement('locations'); $XML->appendChild($locationsElement); foreach ($locations as $location) { $locationElement = $XML->createElement('location'); $locationsElement->appendChild($locationElement); // copy attributes if (array_key_exists('attrs', $location)) { foreach ($location['attrs'] as $attributeName => $attributeContent) { $locationElement->setAttribute($attributeName, $attributeContent); } } // copy child elements if (array_key_exists('ch', $location)) { foreach ($location['ch'] as $fieldName => $fields) { foreach ($fields as $field) { $childElement = $XML->createElement($fieldName); $locationElement->appendChild($childElement); $childElement->appendChild($XML->createTextNode($field['values'][0])); // copy attributes of child elements if (array_key_exists('attr', $field)) { foreach ($field['attr'] as $attributeName => $attributeContent) { $childElement->setAttribute($attributeName, $attributeContent); } } } } } } return $XML; }
php
protected function XMLForLocations($locations) { $XML = new \DOMDocument(); $locationsElement = $XML->createElement('locations'); $XML->appendChild($locationsElement); foreach ($locations as $location) { $locationElement = $XML->createElement('location'); $locationsElement->appendChild($locationElement); // copy attributes if (array_key_exists('attrs', $location)) { foreach ($location['attrs'] as $attributeName => $attributeContent) { $locationElement->setAttribute($attributeName, $attributeContent); } } // copy child elements if (array_key_exists('ch', $location)) { foreach ($location['ch'] as $fieldName => $fields) { foreach ($fields as $field) { $childElement = $XML->createElement($fieldName); $locationElement->appendChild($childElement); $childElement->appendChild($XML->createTextNode($field['values'][0])); // copy attributes of child elements if (array_key_exists('attr', $field)) { foreach ($field['attr'] as $attributeName => $attributeContent) { $childElement->setAttribute($attributeName, $attributeContent); } } } } } } return $XML; }
[ "protected", "function", "XMLForLocations", "(", "$", "locations", ")", "{", "$", "XML", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "locationsElement", "=", "$", "XML", "->", "createElement", "(", "'locations'", ")", ";", "$", "XML", "->", "appendChild", "(", "$", "locationsElement", ")", ";", "foreach", "(", "$", "locations", "as", "$", "location", ")", "{", "$", "locationElement", "=", "$", "XML", "->", "createElement", "(", "'location'", ")", ";", "$", "locationsElement", "->", "appendChild", "(", "$", "locationElement", ")", ";", "// copy attributes", "if", "(", "array_key_exists", "(", "'attrs'", ",", "$", "location", ")", ")", "{", "foreach", "(", "$", "location", "[", "'attrs'", "]", "as", "$", "attributeName", "=>", "$", "attributeContent", ")", "{", "$", "locationElement", "->", "setAttribute", "(", "$", "attributeName", ",", "$", "attributeContent", ")", ";", "}", "}", "// copy child elements", "if", "(", "array_key_exists", "(", "'ch'", ",", "$", "location", ")", ")", "{", "foreach", "(", "$", "location", "[", "'ch'", "]", "as", "$", "fieldName", "=>", "$", "fields", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "childElement", "=", "$", "XML", "->", "createElement", "(", "$", "fieldName", ")", ";", "$", "locationElement", "->", "appendChild", "(", "$", "childElement", ")", ";", "$", "childElement", "->", "appendChild", "(", "$", "XML", "->", "createTextNode", "(", "$", "field", "[", "'values'", "]", "[", "0", "]", ")", ")", ";", "// copy attributes of child elements", "if", "(", "array_key_exists", "(", "'attr'", ",", "$", "field", ")", ")", "{", "foreach", "(", "$", "field", "[", "'attr'", "]", "as", "$", "attributeName", "=>", "$", "attributeContent", ")", "{", "$", "childElement", "->", "setAttribute", "(", "$", "attributeName", ",", "$", "attributeContent", ")", ";", "}", "}", "}", "}", "}", "}", "return", "$", "XML", ";", "}" ]
Returns XML representing the passed locations. @param array $locations @return \DOMDocument
[ "Returns", "XML", "representing", "the", "passed", "locations", "." ]
3da8c483e24228d92dbb9fff034f0ff50ac937ef
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/ViewHelpers/ResultViewHelper.php#L1115-L1152
6,244
slickframework/configuration
src/Driver/Environment.php
Environment.transformKey
private function transformKey($key) { $regEx = '/(?#! splitCamelCase Rev:20140412) # Split camelCase "words". Two global alternatives. Either g1of2: (?<=[a-z]) # Position is after a lowercase, (?=[A-Z]) # and before an uppercase letter. | (?<=[A-Z]) # Or g2of2; Position is after uppercase, (?=[A-Z][a-z]) # and before upper-then-lower case. /x'; $words = preg_split($regEx, $key); $envName = implode('_', $words); $envName = str_replace(['.', '_', '-'], '_', $envName); $envName = strtoupper($envName); return $envName; }
php
private function transformKey($key) { $regEx = '/(?#! splitCamelCase Rev:20140412) # Split camelCase "words". Two global alternatives. Either g1of2: (?<=[a-z]) # Position is after a lowercase, (?=[A-Z]) # and before an uppercase letter. | (?<=[A-Z]) # Or g2of2; Position is after uppercase, (?=[A-Z][a-z]) # and before upper-then-lower case. /x'; $words = preg_split($regEx, $key); $envName = implode('_', $words); $envName = str_replace(['.', '_', '-'], '_', $envName); $envName = strtoupper($envName); return $envName; }
[ "private", "function", "transformKey", "(", "$", "key", ")", "{", "$", "regEx", "=", "'/(?#! splitCamelCase Rev:20140412)\n # Split camelCase \"words\". Two global alternatives. Either g1of2:\n (?<=[a-z]) # Position is after a lowercase,\n (?=[A-Z]) # and before an uppercase letter.\n | (?<=[A-Z]) # Or g2of2; Position is after uppercase,\n (?=[A-Z][a-z]) # and before upper-then-lower case.\n /x'", ";", "$", "words", "=", "preg_split", "(", "$", "regEx", ",", "$", "key", ")", ";", "$", "envName", "=", "implode", "(", "'_'", ",", "$", "words", ")", ";", "$", "envName", "=", "str_replace", "(", "[", "'.'", ",", "'_'", ",", "'-'", "]", ",", "'_'", ",", "$", "envName", ")", ";", "$", "envName", "=", "strtoupper", "(", "$", "envName", ")", ";", "return", "$", "envName", ";", "}" ]
Transforms the provided key to a environment variable name @param string $key @return string
[ "Transforms", "the", "provided", "key", "to", "a", "environment", "variable", "name" ]
9aa1edbddd007b4af4032a2b383c39f4db47d87e
https://github.com/slickframework/configuration/blob/9aa1edbddd007b4af4032a2b383c39f4db47d87e/src/Driver/Environment.php#L50-L66
6,245
xloit/xloit-bridge-zend-validator
src/File/FileTrait.php
FileTrait.isFileEmpty
protected function isFileEmpty($value, $file = null) { $source = null; $filename = null; if (is_string($value) && is_array($file)) { // Legacy Zend\Transfer API support $filename = $file['name']; $source = $file['tmp_name']; } elseif (is_array($value)) { /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($value['tmp_name'])) { $source = $value['tmp_name']; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($value['name'])) { $filename = $value['name']; } } else { $source = $value; $filename = basename($source); } /** @noinspection IsEmptyFunctionUsageInspection */ return empty($source) || empty($filename); }
php
protected function isFileEmpty($value, $file = null) { $source = null; $filename = null; if (is_string($value) && is_array($file)) { // Legacy Zend\Transfer API support $filename = $file['name']; $source = $file['tmp_name']; } elseif (is_array($value)) { /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($value['tmp_name'])) { $source = $value['tmp_name']; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($value['name'])) { $filename = $value['name']; } } else { $source = $value; $filename = basename($source); } /** @noinspection IsEmptyFunctionUsageInspection */ return empty($source) || empty($filename); }
[ "protected", "function", "isFileEmpty", "(", "$", "value", ",", "$", "file", "=", "null", ")", "{", "$", "source", "=", "null", ";", "$", "filename", "=", "null", ";", "if", "(", "is_string", "(", "$", "value", ")", "&&", "is_array", "(", "$", "file", ")", ")", "{", "// Legacy Zend\\Transfer API support", "$", "filename", "=", "$", "file", "[", "'name'", "]", ";", "$", "source", "=", "$", "file", "[", "'tmp_name'", "]", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "value", "[", "'tmp_name'", "]", ")", ")", "{", "$", "source", "=", "$", "value", "[", "'tmp_name'", "]", ";", "}", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "value", "[", "'name'", "]", ")", ")", "{", "$", "filename", "=", "$", "value", "[", "'name'", "]", ";", "}", "}", "else", "{", "$", "source", "=", "$", "value", ";", "$", "filename", "=", "basename", "(", "$", "source", ")", ";", "}", "/** @noinspection IsEmptyFunctionUsageInspection */", "return", "empty", "(", "$", "source", ")", "||", "empty", "(", "$", "filename", ")", ";", "}" ]
Indicates whether the file is defined. @param string|array $value Real file to check. @param array $file File data from {@link \Zend\File\Transfer\Transfer} (optional). @return bool
[ "Indicates", "whether", "the", "file", "is", "defined", "." ]
2e789986e6551f157d4e07cf4c27d027dd070324
https://github.com/xloit/xloit-bridge-zend-validator/blob/2e789986e6551f157d4e07cf4c27d027dd070324/src/File/FileTrait.php#L66-L92
6,246
bytepark/lib-migration
src/Repository/Database.php
Database.replace
public function replace(UnitOfWork $replacement) { parent::replace($replacement); $this->connection->execute( sprintf("DELETE FROM %s WHERE unique_id = ?", $this->tableName), array ( $replacement->getUniqueId(), ) ); unset($this->presentUidsOnConstruction[$replacement->getUniqueId()]); }
php
public function replace(UnitOfWork $replacement) { parent::replace($replacement); $this->connection->execute( sprintf("DELETE FROM %s WHERE unique_id = ?", $this->tableName), array ( $replacement->getUniqueId(), ) ); unset($this->presentUidsOnConstruction[$replacement->getUniqueId()]); }
[ "public", "function", "replace", "(", "UnitOfWork", "$", "replacement", ")", "{", "parent", "::", "replace", "(", "$", "replacement", ")", ";", "$", "this", "->", "connection", "->", "execute", "(", "sprintf", "(", "\"DELETE FROM %s WHERE unique_id = ?\"", ",", "$", "this", "->", "tableName", ")", ",", "array", "(", "$", "replacement", "->", "getUniqueId", "(", ")", ",", ")", ")", ";", "unset", "(", "$", "this", "->", "presentUidsOnConstruction", "[", "$", "replacement", "->", "getUniqueId", "(", ")", "]", ")", ";", "}" ]
Next to replacing the unit internally, the entry has to be also removed in the database @param UnitOfWork $replacement @throws \Bytepark\Component\Migration\Exception\UnitNotPresentException @return void
[ "Next", "to", "replacing", "the", "unit", "internally", "the", "entry", "has", "to", "be", "also", "removed", "in", "the", "database" ]
14d75f6978e257f456493c673175ca5d07b28c84
https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/Database.php#L106-L117
6,247
bytepark/lib-migration
src/Repository/Database.php
Database.buildMigrations
private function buildMigrations() { $unitDataArray = $this->loadUnitDataIteratorFromDatabase(); foreach ($unitDataArray as $unitData) { $unitOfWork = UnitOfWorkFactory::BuildFromFlatArray($unitData); $this->presentUidsOnConstruction[$unitOfWork->getUniqueId()] = true; $this->add($unitOfWork); } }
php
private function buildMigrations() { $unitDataArray = $this->loadUnitDataIteratorFromDatabase(); foreach ($unitDataArray as $unitData) { $unitOfWork = UnitOfWorkFactory::BuildFromFlatArray($unitData); $this->presentUidsOnConstruction[$unitOfWork->getUniqueId()] = true; $this->add($unitOfWork); } }
[ "private", "function", "buildMigrations", "(", ")", "{", "$", "unitDataArray", "=", "$", "this", "->", "loadUnitDataIteratorFromDatabase", "(", ")", ";", "foreach", "(", "$", "unitDataArray", "as", "$", "unitData", ")", "{", "$", "unitOfWork", "=", "UnitOfWorkFactory", "::", "BuildFromFlatArray", "(", "$", "unitData", ")", ";", "$", "this", "->", "presentUidsOnConstruction", "[", "$", "unitOfWork", "->", "getUniqueId", "(", ")", "]", "=", "true", ";", "$", "this", "->", "add", "(", "$", "unitOfWork", ")", ";", "}", "}" ]
Builds the migrations from the database @return void
[ "Builds", "the", "migrations", "from", "the", "database" ]
14d75f6978e257f456493c673175ca5d07b28c84
https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/Database.php#L140-L148
6,248
bytepark/lib-migration
src/Repository/Database.php
Database.loadUnitDataIteratorFromDatabase
private function loadUnitDataIteratorFromDatabase() { $result = $this->connection->query( sprintf("SELECT * FROM %s ORDER BY unique_id ASC", $this->tableName) ); return new \ArrayIterator($result); }
php
private function loadUnitDataIteratorFromDatabase() { $result = $this->connection->query( sprintf("SELECT * FROM %s ORDER BY unique_id ASC", $this->tableName) ); return new \ArrayIterator($result); }
[ "private", "function", "loadUnitDataIteratorFromDatabase", "(", ")", "{", "$", "result", "=", "$", "this", "->", "connection", "->", "query", "(", "sprintf", "(", "\"SELECT * FROM %s ORDER BY unique_id ASC\"", ",", "$", "this", "->", "tableName", ")", ")", ";", "return", "new", "\\", "ArrayIterator", "(", "$", "result", ")", ";", "}" ]
Loads the UnitsOfWork from the database as Iterator @return \ArrayIterator
[ "Loads", "the", "UnitsOfWork", "from", "the", "database", "as", "Iterator" ]
14d75f6978e257f456493c673175ca5d07b28c84
https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/Database.php#L155-L162
6,249
marando/phpSOFA
src/Marando/IAU/iauSp00.php
iauSp00.Sp00
public static function Sp00($date1, $date2) { $t; $sp; /* Interval between fundamental epoch J2000.0 and current date (JC). */ $t = (($date1 - DJ00) + $date2) / DJC; /* Approximate s'. */ $sp = -47e-6 * $t * DAS2R; return $sp; }
php
public static function Sp00($date1, $date2) { $t; $sp; /* Interval between fundamental epoch J2000.0 and current date (JC). */ $t = (($date1 - DJ00) + $date2) / DJC; /* Approximate s'. */ $sp = -47e-6 * $t * DAS2R; return $sp; }
[ "public", "static", "function", "Sp00", "(", "$", "date1", ",", "$", "date2", ")", "{", "$", "t", ";", "$", "sp", ";", "/* Interval between fundamental epoch J2000.0 and current date (JC). */", "$", "t", "=", "(", "(", "$", "date1", "-", "DJ00", ")", "+", "$", "date2", ")", "/", "DJC", ";", "/* Approximate s'. */", "$", "sp", "=", "-", "47e-6", "*", "$", "t", "*", "DAS2R", ";", "return", "$", "sp", ";", "}" ]
- - - - - - - - i a u S p 0 0 - - - - - - - - The TIO locator s', positioning the Terrestrial Intermediate Origin on the equator of the Celestial Intermediate Pole. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: canonical model. Given: date1,date2 double TT as a 2-part Julian Date (Note 1) Returned (function value): double the TIO locator s' in radians (Note 2) Notes: 1) The TT date date1+date2 is a Julian Date, apportioned in any convenient way between the two arguments. For example, JD(TT)=2450123.7 could be expressed in any of these ways, among others: date1 date2 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable. The J2000 method is best matched to the way the argument is handled internally and will deliver the optimum resolution. The MJD method and the date & time methods are both good compromises between resolution and convenience. 2) The TIO locator s' is obtained from polar motion observations by numerical integration, and so is in essence unpredictable. However, it is dominated by a secular drift of about 47 microarcseconds per century, which is the approximation evaluated by the present function. Reference: McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004) This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "S", "p", "0", "0", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauSp00.php#L64-L75
6,250
unimatrix/cake
src/Lib/Lexicon.php
Lexicon.match
public static function match($keyword, $text = '', &$matches = false) { return (bool)preg_match(sprintf(self::$re, self::regex($keyword)), $text, $matches, PREG_OFFSET_CAPTURE); }
php
public static function match($keyword, $text = '', &$matches = false) { return (bool)preg_match(sprintf(self::$re, self::regex($keyword)), $text, $matches, PREG_OFFSET_CAPTURE); }
[ "public", "static", "function", "match", "(", "$", "keyword", ",", "$", "text", "=", "''", ",", "&", "$", "matches", "=", "false", ")", "{", "return", "(", "bool", ")", "preg_match", "(", "sprintf", "(", "self", "::", "$", "re", ",", "self", "::", "regex", "(", "$", "keyword", ")", ")", ",", "$", "text", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", ")", ";", "}" ]
Match romanian regex @param string $keyword @param string $text @param array matches @return bool
[ "Match", "romanian", "regex" ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Lib/Lexicon.php#L25-L27
6,251
unimatrix/cake
src/Lib/Lexicon.php
Lexicon.cuttext
public static function cuttext($value, $length = 200, $ellipsis = '...') { if(!is_array($value)) { $string = $value; $match_to = $value{0}; } else list($string, $match_to) = $value; self::match($match_to, $string, $matches); $match_start = isset($matches[0]) && isset($matches[0][1]) ? mb_substr($string, mb_strlen(substr($string, 0, $matches[0][1]))) : false; $match_compute = $match_start ? (mb_strlen($string) - mb_strlen($match_start)) : 0; if(mb_strlen($string) > $length) { if($match_compute < ($length - mb_strlen($match_to))) { $pre_string = mb_substr($string, 0, $length); $pos_end = mb_strrpos($pre_string, ' '); if($pos_end === false) $string = trim($pre_string).$ellipsis; else $string = trim(mb_substr($pre_string, 0, $pos_end)).$ellipsis; } else if($match_compute > (mb_strlen($string) - ($length - mb_strlen($match_to)))) { $pre_string = mb_substr($string, (mb_strlen($string) - ($length - mb_strlen($match_to)))); $pos_start = mb_strpos($pre_string, ' '); if($pos_start === false) $string = $ellipsis.trim($pre_string); else $string = $ellipsis.trim(mb_substr($pre_string, $pos_start)); } else { $pre_string = mb_substr($string, ($match_compute - round(($length / 3))), $length); $pos_start = mb_strpos($pre_string, ' '); if($pos_start === false) $pre_string = $ellipsis.trim($pre_string); else $pre_string = $ellipsis.trim(mb_substr($pre_string, $pos_start)); $pos_end = mb_strrpos($pre_string, ' '); if($pos_end === false) $pre_string = trim($pre_string).$ellipsis; else $pre_string = trim(mb_substr($pre_string, 0, $pos_end)).$ellipsis; $string = $pre_string; } } return trim($string); }
php
public static function cuttext($value, $length = 200, $ellipsis = '...') { if(!is_array($value)) { $string = $value; $match_to = $value{0}; } else list($string, $match_to) = $value; self::match($match_to, $string, $matches); $match_start = isset($matches[0]) && isset($matches[0][1]) ? mb_substr($string, mb_strlen(substr($string, 0, $matches[0][1]))) : false; $match_compute = $match_start ? (mb_strlen($string) - mb_strlen($match_start)) : 0; if(mb_strlen($string) > $length) { if($match_compute < ($length - mb_strlen($match_to))) { $pre_string = mb_substr($string, 0, $length); $pos_end = mb_strrpos($pre_string, ' '); if($pos_end === false) $string = trim($pre_string).$ellipsis; else $string = trim(mb_substr($pre_string, 0, $pos_end)).$ellipsis; } else if($match_compute > (mb_strlen($string) - ($length - mb_strlen($match_to)))) { $pre_string = mb_substr($string, (mb_strlen($string) - ($length - mb_strlen($match_to)))); $pos_start = mb_strpos($pre_string, ' '); if($pos_start === false) $string = $ellipsis.trim($pre_string); else $string = $ellipsis.trim(mb_substr($pre_string, $pos_start)); } else { $pre_string = mb_substr($string, ($match_compute - round(($length / 3))), $length); $pos_start = mb_strpos($pre_string, ' '); if($pos_start === false) $pre_string = $ellipsis.trim($pre_string); else $pre_string = $ellipsis.trim(mb_substr($pre_string, $pos_start)); $pos_end = mb_strrpos($pre_string, ' '); if($pos_end === false) $pre_string = trim($pre_string).$ellipsis; else $pre_string = trim(mb_substr($pre_string, 0, $pos_end)).$ellipsis; $string = $pre_string; } } return trim($string); }
[ "public", "static", "function", "cuttext", "(", "$", "value", ",", "$", "length", "=", "200", ",", "$", "ellipsis", "=", "'...'", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "string", "=", "$", "value", ";", "$", "match_to", "=", "$", "value", "{", "0", "}", ";", "}", "else", "list", "(", "$", "string", ",", "$", "match_to", ")", "=", "$", "value", ";", "self", "::", "match", "(", "$", "match_to", ",", "$", "string", ",", "$", "matches", ")", ";", "$", "match_start", "=", "isset", "(", "$", "matches", "[", "0", "]", ")", "&&", "isset", "(", "$", "matches", "[", "0", "]", "[", "1", "]", ")", "?", "mb_substr", "(", "$", "string", ",", "mb_strlen", "(", "substr", "(", "$", "string", ",", "0", ",", "$", "matches", "[", "0", "]", "[", "1", "]", ")", ")", ")", ":", "false", ";", "$", "match_compute", "=", "$", "match_start", "?", "(", "mb_strlen", "(", "$", "string", ")", "-", "mb_strlen", "(", "$", "match_start", ")", ")", ":", "0", ";", "if", "(", "mb_strlen", "(", "$", "string", ")", ">", "$", "length", ")", "{", "if", "(", "$", "match_compute", "<", "(", "$", "length", "-", "mb_strlen", "(", "$", "match_to", ")", ")", ")", "{", "$", "pre_string", "=", "mb_substr", "(", "$", "string", ",", "0", ",", "$", "length", ")", ";", "$", "pos_end", "=", "mb_strrpos", "(", "$", "pre_string", ",", "' '", ")", ";", "if", "(", "$", "pos_end", "===", "false", ")", "$", "string", "=", "trim", "(", "$", "pre_string", ")", ".", "$", "ellipsis", ";", "else", "$", "string", "=", "trim", "(", "mb_substr", "(", "$", "pre_string", ",", "0", ",", "$", "pos_end", ")", ")", ".", "$", "ellipsis", ";", "}", "else", "if", "(", "$", "match_compute", ">", "(", "mb_strlen", "(", "$", "string", ")", "-", "(", "$", "length", "-", "mb_strlen", "(", "$", "match_to", ")", ")", ")", ")", "{", "$", "pre_string", "=", "mb_substr", "(", "$", "string", ",", "(", "mb_strlen", "(", "$", "string", ")", "-", "(", "$", "length", "-", "mb_strlen", "(", "$", "match_to", ")", ")", ")", ")", ";", "$", "pos_start", "=", "mb_strpos", "(", "$", "pre_string", ",", "' '", ")", ";", "if", "(", "$", "pos_start", "===", "false", ")", "$", "string", "=", "$", "ellipsis", ".", "trim", "(", "$", "pre_string", ")", ";", "else", "$", "string", "=", "$", "ellipsis", ".", "trim", "(", "mb_substr", "(", "$", "pre_string", ",", "$", "pos_start", ")", ")", ";", "}", "else", "{", "$", "pre_string", "=", "mb_substr", "(", "$", "string", ",", "(", "$", "match_compute", "-", "round", "(", "(", "$", "length", "/", "3", ")", ")", ")", ",", "$", "length", ")", ";", "$", "pos_start", "=", "mb_strpos", "(", "$", "pre_string", ",", "' '", ")", ";", "if", "(", "$", "pos_start", "===", "false", ")", "$", "pre_string", "=", "$", "ellipsis", ".", "trim", "(", "$", "pre_string", ")", ";", "else", "$", "pre_string", "=", "$", "ellipsis", ".", "trim", "(", "mb_substr", "(", "$", "pre_string", ",", "$", "pos_start", ")", ")", ";", "$", "pos_end", "=", "mb_strrpos", "(", "$", "pre_string", ",", "' '", ")", ";", "if", "(", "$", "pos_end", "===", "false", ")", "$", "pre_string", "=", "trim", "(", "$", "pre_string", ")", ".", "$", "ellipsis", ";", "else", "$", "pre_string", "=", "trim", "(", "mb_substr", "(", "$", "pre_string", ",", "0", ",", "$", "pos_end", ")", ")", ".", "$", "ellipsis", ";", "$", "string", "=", "$", "pre_string", ";", "}", "}", "return", "trim", "(", "$", "string", ")", ";", "}" ]
Cut text left middle right @param string or array $value @param integer $length @param string $ellipsis
[ "Cut", "text", "left", "middle", "right" ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Lib/Lexicon.php#L66-L100
6,252
kiler129/CherryHttp
src/_legacyCode/Server.php
Server.bind
public function bind($ip = '0.0.0.0', $port = 8080, $ssl = false) { $this->addNode(new HttpListenerNode($this, $ip, $port, $ssl, $this->logger)); }
php
public function bind($ip = '0.0.0.0', $port = 8080, $ssl = false) { $this->addNode(new HttpListenerNode($this, $ip, $port, $ssl, $this->logger)); }
[ "public", "function", "bind", "(", "$", "ip", "=", "'0.0.0.0'", ",", "$", "port", "=", "8080", ",", "$", "ssl", "=", "false", ")", "{", "$", "this", "->", "addNode", "(", "new", "HttpListenerNode", "(", "$", "this", ",", "$", "ip", ",", "$", "port", ",", "$", "ssl", ",", "$", "this", "->", "logger", ")", ")", ";", "}" ]
Creates listener using default HttpListenerNode class @param string $ip @param int $port @param bool $ssl @throws ServerException @see ListenerNode
[ "Creates", "listener", "using", "default", "HttpListenerNode", "class" ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/Server.php#L58-L61
6,253
kiler129/CherryHttp
src/_legacyCode/Server.php
Server.upgradeClient
private function upgradeClient(ClientUpgradeException $upgrade) { $oldClient = $upgrade->getOldClient(); if (!isset($oldClient->socket, $this->nodes[(int)$oldClient->socket])) { $this->logger->emergency("Client $oldClient not found during upgrade"); throw new ServerException('Tried to upgrade non existing client!'); } $this->nodes[(int)$oldClient->socket] = $upgrade->getNewClient(); }
php
private function upgradeClient(ClientUpgradeException $upgrade) { $oldClient = $upgrade->getOldClient(); if (!isset($oldClient->socket, $this->nodes[(int)$oldClient->socket])) { $this->logger->emergency("Client $oldClient not found during upgrade"); throw new ServerException('Tried to upgrade non existing client!'); } $this->nodes[(int)$oldClient->socket] = $upgrade->getNewClient(); }
[ "private", "function", "upgradeClient", "(", "ClientUpgradeException", "$", "upgrade", ")", "{", "$", "oldClient", "=", "$", "upgrade", "->", "getOldClient", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "oldClient", "->", "socket", ",", "$", "this", "->", "nodes", "[", "(", "int", ")", "$", "oldClient", "->", "socket", "]", ")", ")", "{", "$", "this", "->", "logger", "->", "emergency", "(", "\"Client $oldClient not found during upgrade\"", ")", ";", "throw", "new", "ServerException", "(", "'Tried to upgrade non existing client!'", ")", ";", "}", "$", "this", "->", "nodes", "[", "(", "int", ")", "$", "oldClient", "->", "socket", "]", "=", "$", "upgrade", "->", "getNewClient", "(", ")", ";", "}" ]
Upgrades client protocol. It's done by replacing whole client class in nodes table. @param ClientUpgradeException $upgrade @throws ServerException Old client cannot be found on server (it's serious error)
[ "Upgrades", "client", "protocol", ".", "It", "s", "done", "by", "replacing", "whole", "client", "class", "in", "nodes", "table", "." ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/Server.php#L344-L354
6,254
digit-soft/re-action-clients-pool
src/PoolClientTrait.php
PoolClientTrait.getClientId
public function getClientId() { if (!isset($this->_poolClientId)) { while (!isset($id) || !$this->isPoolClientIdUnique($id)) { $id = static::generatePoolClientId(); } $this->_poolClientId = $id; } return $this->_poolClientId; }
php
public function getClientId() { if (!isset($this->_poolClientId)) { while (!isset($id) || !$this->isPoolClientIdUnique($id)) { $id = static::generatePoolClientId(); } $this->_poolClientId = $id; } return $this->_poolClientId; }
[ "public", "function", "getClientId", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_poolClientId", ")", ")", "{", "while", "(", "!", "isset", "(", "$", "id", ")", "||", "!", "$", "this", "->", "isPoolClientIdUnique", "(", "$", "id", ")", ")", "{", "$", "id", "=", "static", "::", "generatePoolClientId", "(", ")", ";", "}", "$", "this", "->", "_poolClientId", "=", "$", "id", ";", "}", "return", "$", "this", "->", "_poolClientId", ";", "}" ]
Get client unique ID @return string
[ "Get", "client", "unique", "ID" ]
f1ac06550320ab0456df16b3e1e3f49da1aa4b98
https://github.com/digit-soft/re-action-clients-pool/blob/f1ac06550320ab0456df16b3e1e3f49da1aa4b98/src/PoolClientTrait.php#L33-L42
6,255
digit-soft/re-action-clients-pool
src/PoolClientTrait.php
PoolClientTrait.changeState
protected function changeState($state) { $currState = $this->_poolClientState; //Save previous state if (isset($currState) && $currState !== PoolClientInterface::CLIENT_POOL_STATE_LOCKED) { $this->_poolClientStatePrev = $currState; } $this->_poolClientState = $state; $this->emit(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE, [$state]); }
php
protected function changeState($state) { $currState = $this->_poolClientState; //Save previous state if (isset($currState) && $currState !== PoolClientInterface::CLIENT_POOL_STATE_LOCKED) { $this->_poolClientStatePrev = $currState; } $this->_poolClientState = $state; $this->emit(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE, [$state]); }
[ "protected", "function", "changeState", "(", "$", "state", ")", "{", "$", "currState", "=", "$", "this", "->", "_poolClientState", ";", "//Save previous state", "if", "(", "isset", "(", "$", "currState", ")", "&&", "$", "currState", "!==", "PoolClientInterface", "::", "CLIENT_POOL_STATE_LOCKED", ")", "{", "$", "this", "->", "_poolClientStatePrev", "=", "$", "currState", ";", "}", "$", "this", "->", "_poolClientState", "=", "$", "state", ";", "$", "this", "->", "emit", "(", "PoolClientInterface", "::", "CLIENT_POOL_EVENT_CHANGE_STATE", ",", "[", "$", "state", "]", ")", ";", "}" ]
Change client state helper @param int $state
[ "Change", "client", "state", "helper" ]
f1ac06550320ab0456df16b3e1e3f49da1aa4b98
https://github.com/digit-soft/re-action-clients-pool/blob/f1ac06550320ab0456df16b3e1e3f49da1aa4b98/src/PoolClientTrait.php#L90-L99
6,256
digit-soft/re-action-clients-pool
src/PoolClientTrait.php
PoolClientTrait.changeQueueCount
protected function changeQueueCount($queueCounter) { if ($queueCounter < 0) { $queueCounter = 0; } $this->_poolClientQueueCounter = $queueCounter; //Automatically change client state to `ClientInterface::CLIENT_POOL_STATE_READY` on empty queue if ($this->_poolClientQueueCounter === 0 && $this->_poolClientState === PoolClientInterface::CLIENT_POOL_STATE_BUSY) { $this->changeState(PoolClientInterface::CLIENT_POOL_STATE_READY); } elseif ($this->_poolClientQueueCounter > 0 && $this->_poolClientState === PoolClientInterface::CLIENT_POOL_STATE_READY) { $this->changeState(PoolClientInterface::CLIENT_POOL_STATE_BUSY); } $this->emit(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE, [$queueCounter]); }
php
protected function changeQueueCount($queueCounter) { if ($queueCounter < 0) { $queueCounter = 0; } $this->_poolClientQueueCounter = $queueCounter; //Automatically change client state to `ClientInterface::CLIENT_POOL_STATE_READY` on empty queue if ($this->_poolClientQueueCounter === 0 && $this->_poolClientState === PoolClientInterface::CLIENT_POOL_STATE_BUSY) { $this->changeState(PoolClientInterface::CLIENT_POOL_STATE_READY); } elseif ($this->_poolClientQueueCounter > 0 && $this->_poolClientState === PoolClientInterface::CLIENT_POOL_STATE_READY) { $this->changeState(PoolClientInterface::CLIENT_POOL_STATE_BUSY); } $this->emit(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE, [$queueCounter]); }
[ "protected", "function", "changeQueueCount", "(", "$", "queueCounter", ")", "{", "if", "(", "$", "queueCounter", "<", "0", ")", "{", "$", "queueCounter", "=", "0", ";", "}", "$", "this", "->", "_poolClientQueueCounter", "=", "$", "queueCounter", ";", "//Automatically change client state to `ClientInterface::CLIENT_POOL_STATE_READY` on empty queue", "if", "(", "$", "this", "->", "_poolClientQueueCounter", "===", "0", "&&", "$", "this", "->", "_poolClientState", "===", "PoolClientInterface", "::", "CLIENT_POOL_STATE_BUSY", ")", "{", "$", "this", "->", "changeState", "(", "PoolClientInterface", "::", "CLIENT_POOL_STATE_READY", ")", ";", "}", "elseif", "(", "$", "this", "->", "_poolClientQueueCounter", ">", "0", "&&", "$", "this", "->", "_poolClientState", "===", "PoolClientInterface", "::", "CLIENT_POOL_STATE_READY", ")", "{", "$", "this", "->", "changeState", "(", "PoolClientInterface", "::", "CLIENT_POOL_STATE_BUSY", ")", ";", "}", "$", "this", "->", "emit", "(", "PoolClientInterface", "::", "CLIENT_POOL_EVENT_CHANGE_QUEUE", ",", "[", "$", "queueCounter", "]", ")", ";", "}" ]
Change client queue counter helper @param int $queueCounter
[ "Change", "client", "queue", "counter", "helper" ]
f1ac06550320ab0456df16b3e1e3f49da1aa4b98
https://github.com/digit-soft/re-action-clients-pool/blob/f1ac06550320ab0456df16b3e1e3f49da1aa4b98/src/PoolClientTrait.php#L114-L127
6,257
digit-soft/re-action-clients-pool
src/PoolClientTrait.php
PoolClientTrait.generatePoolClientId
private static function generatePoolClientId() { $now = ceil(microtime(true) * 10000); if (class_exists('Reaction', false)) { $rand = \Reaction::$app->security->generateRandomString(8); } else { $rand = static::randomStr(); } return static::getClientIdPrefix() . $now . $rand; }
php
private static function generatePoolClientId() { $now = ceil(microtime(true) * 10000); if (class_exists('Reaction', false)) { $rand = \Reaction::$app->security->generateRandomString(8); } else { $rand = static::randomStr(); } return static::getClientIdPrefix() . $now . $rand; }
[ "private", "static", "function", "generatePoolClientId", "(", ")", "{", "$", "now", "=", "ceil", "(", "microtime", "(", "true", ")", "*", "10000", ")", ";", "if", "(", "class_exists", "(", "'Reaction'", ",", "false", ")", ")", "{", "$", "rand", "=", "\\", "Reaction", "::", "$", "app", "->", "security", "->", "generateRandomString", "(", "8", ")", ";", "}", "else", "{", "$", "rand", "=", "static", "::", "randomStr", "(", ")", ";", "}", "return", "static", "::", "getClientIdPrefix", "(", ")", ".", "$", "now", ".", "$", "rand", ";", "}" ]
Generate random client ID @return string
[ "Generate", "random", "client", "ID" ]
f1ac06550320ab0456df16b3e1e3f49da1aa4b98
https://github.com/digit-soft/re-action-clients-pool/blob/f1ac06550320ab0456df16b3e1e3f49da1aa4b98/src/PoolClientTrait.php#L190-L199
6,258
blast-project/UtilsBundle
src/Entity/CustomFilter.php
CustomFilter.setRouteParameters
public function setRouteParameters($routeParameters) { if (!is_string($routeParameters)) { $this->routeParameters = json_encode($routeParameters); } else { $this->routeParameters = $routeParameters; } return $this; }
php
public function setRouteParameters($routeParameters) { if (!is_string($routeParameters)) { $this->routeParameters = json_encode($routeParameters); } else { $this->routeParameters = $routeParameters; } return $this; }
[ "public", "function", "setRouteParameters", "(", "$", "routeParameters", ")", "{", "if", "(", "!", "is_string", "(", "$", "routeParameters", ")", ")", "{", "$", "this", "->", "routeParameters", "=", "json_encode", "(", "$", "routeParameters", ")", ";", "}", "else", "{", "$", "this", "->", "routeParameters", "=", "$", "routeParameters", ";", "}", "return", "$", "this", ";", "}" ]
Set routeParameters. @param string|mixed $routeParameters @return CustomFilter
[ "Set", "routeParameters", "." ]
89eaecd717ad8737dbbab778d75e639f18bd26f8
https://github.com/blast-project/UtilsBundle/blob/89eaecd717ad8737dbbab778d75e639f18bd26f8/src/Entity/CustomFilter.php#L101-L110
6,259
blast-project/UtilsBundle
src/Entity/CustomFilter.php
CustomFilter.setFilterParameters
public function setFilterParameters($filterParameters) { if (!is_string($filterParameters)) { $this->filterParameters = json_encode($filterParameters); } else { $this->filterParameters = $filterParameters; } return $this; }
php
public function setFilterParameters($filterParameters) { if (!is_string($filterParameters)) { $this->filterParameters = json_encode($filterParameters); } else { $this->filterParameters = $filterParameters; } return $this; }
[ "public", "function", "setFilterParameters", "(", "$", "filterParameters", ")", "{", "if", "(", "!", "is_string", "(", "$", "filterParameters", ")", ")", "{", "$", "this", "->", "filterParameters", "=", "json_encode", "(", "$", "filterParameters", ")", ";", "}", "else", "{", "$", "this", "->", "filterParameters", "=", "$", "filterParameters", ";", "}", "return", "$", "this", ";", "}" ]
Set filterParameters. @param string|mixed $filterParameters @return CustomFilter
[ "Set", "filterParameters", "." ]
89eaecd717ad8737dbbab778d75e639f18bd26f8
https://github.com/blast-project/UtilsBundle/blob/89eaecd717ad8737dbbab778d75e639f18bd26f8/src/Entity/CustomFilter.php#L129-L138
6,260
jaeger-app/date-time
src/Traits/DateTime.php
DateTime.getDt
public function getDt() { if (is_null($this->dt)) { $this->dt = new Carbon(); $this->dt->setTimezone($this->getTz()); } return $this->dt; }
php
public function getDt() { if (is_null($this->dt)) { $this->dt = new Carbon(); $this->dt->setTimezone($this->getTz()); } return $this->dt; }
[ "public", "function", "getDt", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "dt", ")", ")", "{", "$", "this", "->", "dt", "=", "new", "Carbon", "(", ")", ";", "$", "this", "->", "dt", "->", "setTimezone", "(", "$", "this", "->", "getTz", "(", ")", ")", ";", "}", "return", "$", "this", "->", "dt", ";", "}" ]
Returns an instance of our DateTime object @return \Carbon\Carbon
[ "Returns", "an", "instance", "of", "our", "DateTime", "object" ]
36ccfc21f7bc9457b735098b6805e98db71fef68
https://github.com/jaeger-app/date-time/blob/36ccfc21f7bc9457b735098b6805e98db71fef68/src/Traits/DateTime.php#L62-L70
6,261
jaeger-app/date-time
src/Traits/DateTime.php
DateTime.convertTimestamp
public function convertTimestamp($date, $format) { if (! is_numeric($date)) { $date = strtotime($date); } return $this->getDt() ->createFromTimestamp($date, $this->getTz()) ->format($format); }
php
public function convertTimestamp($date, $format) { if (! is_numeric($date)) { $date = strtotime($date); } return $this->getDt() ->createFromTimestamp($date, $this->getTz()) ->format($format); }
[ "public", "function", "convertTimestamp", "(", "$", "date", ",", "$", "format", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "date", ")", ")", "{", "$", "date", "=", "strtotime", "(", "$", "date", ")", ";", "}", "return", "$", "this", "->", "getDt", "(", ")", "->", "createFromTimestamp", "(", "$", "date", ",", "$", "this", "->", "getTz", "(", ")", ")", "->", "format", "(", "$", "format", ")", ";", "}" ]
Converts a timestamp from one format to another @param mixed $date @param string $format
[ "Converts", "a", "timestamp", "from", "one", "format", "to", "another" ]
36ccfc21f7bc9457b735098b6805e98db71fef68
https://github.com/jaeger-app/date-time/blob/36ccfc21f7bc9457b735098b6805e98db71fef68/src/Traits/DateTime.php#L100-L109
6,262
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.withNameSpace
public function withNameSpace($namespace) { $namespace = (string) $namespace; if (! isset(static::$namespaces[$namespace])) { $new = clone $this; $new->setNamespace($namespace); $new->setEnabled($this->enabled); static::$namespaces[$namespace] = $new; } return static::$namespaces[$namespace]; }
php
public function withNameSpace($namespace) { $namespace = (string) $namespace; if (! isset(static::$namespaces[$namespace])) { $new = clone $this; $new->setNamespace($namespace); $new->setEnabled($this->enabled); static::$namespaces[$namespace] = $new; } return static::$namespaces[$namespace]; }
[ "public", "function", "withNameSpace", "(", "$", "namespace", ")", "{", "$", "namespace", "=", "(", "string", ")", "$", "namespace", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "namespaces", "[", "$", "namespace", "]", ")", ")", "{", "$", "new", "=", "clone", "$", "this", ";", "$", "new", "->", "setNamespace", "(", "$", "namespace", ")", ";", "$", "new", "->", "setEnabled", "(", "$", "this", "->", "enabled", ")", ";", "static", "::", "$", "namespaces", "[", "$", "namespace", "]", "=", "$", "new", ";", "}", "return", "static", "::", "$", "namespaces", "[", "$", "namespace", "]", ";", "}" ]
Returns the instance with specified namespace. @param string $namespace The namespace @return self The new instance with specified namespace
[ "Returns", "the", "instance", "with", "specified", "namespace", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L101-L113
6,263
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.setEnabled
public function setEnabled($state = true) { $this->enabled = (bool) $state; if ($this->enabled) { try { $this->createNamespace(); } catch (Exception $ex) { throw new RuntimeException(sprintf( 'Failed to enable the cache adapter of class "%s" ' . 'with namespace "%s".', static::CLASS, $this->namespace ), null, $ex); } } return $this; }
php
public function setEnabled($state = true) { $this->enabled = (bool) $state; if ($this->enabled) { try { $this->createNamespace(); } catch (Exception $ex) { throw new RuntimeException(sprintf( 'Failed to enable the cache adapter of class "%s" ' . 'with namespace "%s".', static::CLASS, $this->namespace ), null, $ex); } } return $this; }
[ "public", "function", "setEnabled", "(", "$", "state", "=", "true", ")", "{", "$", "this", "->", "enabled", "=", "(", "bool", ")", "$", "state", ";", "if", "(", "$", "this", "->", "enabled", ")", "{", "try", "{", "$", "this", "->", "createNamespace", "(", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Failed to enable the cache adapter of class \"%s\" '", ".", "'with namespace \"%s\".'", ",", "static", "::", "CLASS", ",", "$", "this", "->", "namespace", ")", ",", "null", ",", "$", "ex", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Sets the state of adapter to "enabled state" or to "disabled state". @param bool $state Optional; true by default. The adapter state @throws \RuntimeException If failed to enable the cache adapter @return self
[ "Sets", "the", "state", "of", "adapter", "to", "enabled", "state", "or", "to", "disabled", "state", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L124-L142
6,264
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.get
public function get($key) { if (! $this->enabled) { return; } $file = $this->getPath($key); if (! file_exists($file)) { return false; } set_error_handler(function () { throw new Exception('An error occurred.'); }, E_WARNING); try { if (filemtime($file) < time()) { throw new Exception('Term life data has expired.'); } $data = file_get_contents($file); } catch (Exception $ex) { restore_error_handler(); $this->remove($key); return false; } restore_error_handler(); return call_user_func($this->restoringFilter, $data); }
php
public function get($key) { if (! $this->enabled) { return; } $file = $this->getPath($key); if (! file_exists($file)) { return false; } set_error_handler(function () { throw new Exception('An error occurred.'); }, E_WARNING); try { if (filemtime($file) < time()) { throw new Exception('Term life data has expired.'); } $data = file_get_contents($file); } catch (Exception $ex) { restore_error_handler(); $this->remove($key); return false; } restore_error_handler(); return call_user_func($this->restoringFilter, $data); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", ")", "{", "return", ";", "}", "$", "file", "=", "$", "this", "->", "getPath", "(", "$", "key", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "return", "false", ";", "}", "set_error_handler", "(", "function", "(", ")", "{", "throw", "new", "Exception", "(", "'An error occurred.'", ")", ";", "}", ",", "E_WARNING", ")", ";", "try", "{", "if", "(", "filemtime", "(", "$", "file", ")", "<", "time", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'Term life data has expired.'", ")", ";", "}", "$", "data", "=", "file_get_contents", "(", "$", "file", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "restore_error_handler", "(", ")", ";", "$", "this", "->", "remove", "(", "$", "key", ")", ";", "return", "false", ";", "}", "restore_error_handler", "(", ")", ";", "return", "call_user_func", "(", "$", "this", "->", "restoringFilter", ",", "$", "data", ")", ";", "}" ]
Gets a stored variable from the cache. @param string $key The variable name @return mixed Returns null if adapter is disabled, stored data on success, false otherwise
[ "Gets", "a", "stored", "variable", "from", "the", "cache", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L235-L263
6,265
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.remove
public function remove($key) { if (! $this->enabled) { return; } $file = $this->getPath($key); if (! file_exists($file)) { return true; } set_error_handler(function () { throw new Exception('An error occurred.'); }, E_WARNING); try { unlink($file); } catch (Exception $ex) { restore_error_handler(); return false; } restore_error_handler(); return true; }
php
public function remove($key) { if (! $this->enabled) { return; } $file = $this->getPath($key); if (! file_exists($file)) { return true; } set_error_handler(function () { throw new Exception('An error occurred.'); }, E_WARNING); try { unlink($file); } catch (Exception $ex) { restore_error_handler(); return false; } restore_error_handler(); return true; }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", ")", "{", "return", ";", "}", "$", "file", "=", "$", "this", "->", "getPath", "(", "$", "key", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "return", "true", ";", "}", "set_error_handler", "(", "function", "(", ")", "{", "throw", "new", "Exception", "(", "'An error occurred.'", ")", ";", "}", ",", "E_WARNING", ")", ";", "try", "{", "unlink", "(", "$", "file", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "restore_error_handler", "(", ")", ";", "return", "false", ";", "}", "restore_error_handler", "(", ")", ";", "return", "true", ";", "}" ]
Removes a stored variable from the cache. @param string $key The variable name @return null|bool Returns null if adapter is disabled, true on success, false otherwise
[ "Removes", "a", "stored", "variable", "from", "the", "cache", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L273-L297
6,266
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.clearNamespace
public function clearNamespace() { if (! $this->enabled) { return; } $error = false; set_error_handler(function () use (&$error) { $error = true; }, E_WARNING); foreach (glob($this->getPath() . '/*.dat') as $file) { unlink($file); } restore_error_handler(); return ! $error; }
php
public function clearNamespace() { if (! $this->enabled) { return; } $error = false; set_error_handler(function () use (&$error) { $error = true; }, E_WARNING); foreach (glob($this->getPath() . '/*.dat') as $file) { unlink($file); } restore_error_handler(); return ! $error; }
[ "public", "function", "clearNamespace", "(", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", ")", "{", "return", ";", "}", "$", "error", "=", "false", ";", "set_error_handler", "(", "function", "(", ")", "use", "(", "&", "$", "error", ")", "{", "$", "error", "=", "true", ";", "}", ",", "E_WARNING", ")", ";", "foreach", "(", "glob", "(", "$", "this", "->", "getPath", "(", ")", ".", "'/*.dat'", ")", "as", "$", "file", ")", "{", "unlink", "(", "$", "file", ")", ";", "}", "restore_error_handler", "(", ")", ";", "return", "!", "$", "error", ";", "}" ]
Cleans the namespace. Remove any previously stored for the current namespace. @return null|bool Returns null if adapter is disabled, true on success, false otherwise
[ "Cleans", "the", "namespace", ".", "Remove", "any", "previously", "stored", "for", "the", "current", "namespace", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L306-L323
6,267
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.clearExpired
public function clearExpired() { if (! $this->enabled) { return; } $error = false; set_error_handler(function () use (&$error) { $error = true; }, E_WARNING); foreach (glob($this->getPath() . '/*.dat') as $file) { if (filemtime($file) < time()) { unlink($file); } } restore_error_handler(); return ! $error; }
php
public function clearExpired() { if (! $this->enabled) { return; } $error = false; set_error_handler(function () use (&$error) { $error = true; }, E_WARNING); foreach (glob($this->getPath() . '/*.dat') as $file) { if (filemtime($file) < time()) { unlink($file); } } restore_error_handler(); return ! $error; }
[ "public", "function", "clearExpired", "(", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", ")", "{", "return", ";", "}", "$", "error", "=", "false", ";", "set_error_handler", "(", "function", "(", ")", "use", "(", "&", "$", "error", ")", "{", "$", "error", "=", "true", ";", "}", ",", "E_WARNING", ")", ";", "foreach", "(", "glob", "(", "$", "this", "->", "getPath", "(", ")", ".", "'/*.dat'", ")", "as", "$", "file", ")", "{", "if", "(", "filemtime", "(", "$", "file", ")", "<", "time", "(", ")", ")", "{", "unlink", "(", "$", "file", ")", ";", "}", "}", "restore_error_handler", "(", ")", ";", "return", "!", "$", "error", ";", "}" ]
Cleans all expired variables. It is recommended not to use this method directly. This method is called from the destructor if necessary. @return null|bool Returns null if adapter is disabled, true on success, false otherwise
[ "Cleans", "all", "expired", "variables", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L334-L352
6,268
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.getPath
protected function getPath($variableName = '') { $hash = function ($name) { return hash($this->hashingAlgorithm, $name); }; $path = $this->basedir . PHP_DS . $hash($this->namespace); if ($variableName) { $path .= PHP_DS . $hash($variableName) . '.dat'; return $path; } return $path; }
php
protected function getPath($variableName = '') { $hash = function ($name) { return hash($this->hashingAlgorithm, $name); }; $path = $this->basedir . PHP_DS . $hash($this->namespace); if ($variableName) { $path .= PHP_DS . $hash($variableName) . '.dat'; return $path; } return $path; }
[ "protected", "function", "getPath", "(", "$", "variableName", "=", "''", ")", "{", "$", "hash", "=", "function", "(", "$", "name", ")", "{", "return", "hash", "(", "$", "this", "->", "hashingAlgorithm", ",", "$", "name", ")", ";", "}", ";", "$", "path", "=", "$", "this", "->", "basedir", ".", "PHP_DS", ".", "$", "hash", "(", "$", "this", "->", "namespace", ")", ";", "if", "(", "$", "variableName", ")", "{", "$", "path", ".=", "PHP_DS", ".", "$", "hash", "(", "$", "variableName", ")", ".", "'.dat'", ";", "return", "$", "path", ";", "}", "return", "$", "path", ";", "}" ]
Gets the path to the file appropriate variable or path to namespace directory. @param string $variableName Optional; the name of variable @return string If the variable name received, returns the path to appropriate file, otherwise returns the path to directory of namespace
[ "Gets", "the", "path", "to", "the", "file", "appropriate", "variable", "or", "path", "to", "namespace", "directory", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L363-L376
6,269
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.setDirPermissions
protected function setDirPermissions($permissions) { $permissions = (int) $permissions; if (! (0b100000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for reading.', decoct($permissions) )); } if (! (0b010000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for writing.', decoct($permissions) )); } if (! (0b001000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for directories. ' . 'The content of directories will not available.', decoct($permissions) )); } $this->dirPermissions = $permissions; }
php
protected function setDirPermissions($permissions) { $permissions = (int) $permissions; if (! (0b100000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for reading.', decoct($permissions) )); } if (! (0b010000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for writing.', decoct($permissions) )); } if (! (0b001000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for directories. ' . 'The content of directories will not available.', decoct($permissions) )); } $this->dirPermissions = $permissions; }
[ "protected", "function", "setDirPermissions", "(", "$", "permissions", ")", "{", "$", "permissions", "=", "(", "int", ")", "$", "permissions", ";", "if", "(", "!", "(", "0b100000000", "&", "$", "permissions", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid permissions \"%s\" for directories. '", ".", "'Directories will not available for reading.'", ",", "decoct", "(", "$", "permissions", ")", ")", ")", ";", "}", "if", "(", "!", "(", "0b010000000", "&", "$", "permissions", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid permissions \"%s\" for directories. '", ".", "'Directories will not available for writing.'", ",", "decoct", "(", "$", "permissions", ")", ")", ")", ";", "}", "if", "(", "!", "(", "0b001000000", "&", "$", "permissions", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid permissions \"%s\" for directories. '", ".", "'The content of directories will not available.'", ",", "decoct", "(", "$", "permissions", ")", ")", ")", ";", "}", "$", "this", "->", "dirPermissions", "=", "$", "permissions", ";", "}" ]
Sets permissions for directories. @param int $permissions The directory permissions @throws \InvalidArgumentException If the permissions do not allow write to directory or read from directory
[ "Sets", "permissions", "for", "directories", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L409-L435
6,270
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.setFilePermissions
protected function setFilePermissions($permissions) { $permissions = (int) $permissions; if (! (0b100000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for files. ' . 'Files will not available for reading.', decoct($permissions) )); } if (! (0b010000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for files. ' . 'Files will not available for writing.', decoct($permissions) )); } $this->filePermissions = $permissions; }
php
protected function setFilePermissions($permissions) { $permissions = (int) $permissions; if (! (0b100000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for files. ' . 'Files will not available for reading.', decoct($permissions) )); } if (! (0b010000000 & $permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid permissions "%s" for files. ' . 'Files will not available for writing.', decoct($permissions) )); } $this->filePermissions = $permissions; }
[ "protected", "function", "setFilePermissions", "(", "$", "permissions", ")", "{", "$", "permissions", "=", "(", "int", ")", "$", "permissions", ";", "if", "(", "!", "(", "0b100000000", "&", "$", "permissions", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid permissions \"%s\" for files. '", ".", "'Files will not available for reading.'", ",", "decoct", "(", "$", "permissions", ")", ")", ")", ";", "}", "if", "(", "!", "(", "0b010000000", "&", "$", "permissions", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid permissions \"%s\" for files. '", ".", "'Files will not available for writing.'", ",", "decoct", "(", "$", "permissions", ")", ")", ")", ";", "}", "$", "this", "->", "filePermissions", "=", "$", "permissions", ";", "}" ]
Sets permissions for files. @param int $permissions The file permissions @throws \InvalidArgumentException If the permissions do not allow write to file or read from file
[ "Sets", "permissions", "for", "files", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L445-L464
6,271
easy-system/es-cache
src/Adapter/FileCache.php
FileCache.createNamespace
protected function createNamespace() { $dir = $this->getPath(); if (! file_exists($dir) || ! is_dir($dir)) { set_error_handler(function () { throw new Exception('An error occurred.'); }, E_WARNING); try { mkdir($dir, $this->dirPermissions, true); } catch (Exception $ex) { restore_error_handler(); throw new RuntimeException( sprintf('Failed to create cache directory "%s".', $dir) ); } restore_error_handler(); } if (! is_writable($dir)) { throw new RuntimeException( sprintf('The cache directory "%s" is not writable.', $dir) ); } if (! is_readable($dir)) { throw new RuntimeException( sprintf('The cache directory "%s" is not readable.', $dir) ); } }
php
protected function createNamespace() { $dir = $this->getPath(); if (! file_exists($dir) || ! is_dir($dir)) { set_error_handler(function () { throw new Exception('An error occurred.'); }, E_WARNING); try { mkdir($dir, $this->dirPermissions, true); } catch (Exception $ex) { restore_error_handler(); throw new RuntimeException( sprintf('Failed to create cache directory "%s".', $dir) ); } restore_error_handler(); } if (! is_writable($dir)) { throw new RuntimeException( sprintf('The cache directory "%s" is not writable.', $dir) ); } if (! is_readable($dir)) { throw new RuntimeException( sprintf('The cache directory "%s" is not readable.', $dir) ); } }
[ "protected", "function", "createNamespace", "(", ")", "{", "$", "dir", "=", "$", "this", "->", "getPath", "(", ")", ";", "if", "(", "!", "file_exists", "(", "$", "dir", ")", "||", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "set_error_handler", "(", "function", "(", ")", "{", "throw", "new", "Exception", "(", "'An error occurred.'", ")", ";", "}", ",", "E_WARNING", ")", ";", "try", "{", "mkdir", "(", "$", "dir", ",", "$", "this", "->", "dirPermissions", ",", "true", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "restore_error_handler", "(", ")", ";", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Failed to create cache directory \"%s\".'", ",", "$", "dir", ")", ")", ";", "}", "restore_error_handler", "(", ")", ";", "}", "if", "(", "!", "is_writable", "(", "$", "dir", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The cache directory \"%s\" is not writable.'", ",", "$", "dir", ")", ")", ";", "}", "if", "(", "!", "is_readable", "(", "$", "dir", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The cache directory \"%s\" is not readable.'", ",", "$", "dir", ")", ")", ";", "}", "}" ]
Creates directory for current namespace if not exists. @throws RuntimeException - If unable to create the directory for specified namespace. - If the directory for specified namespace exists, but not writable. - If the directory for specified namespace exists, but not readable.
[ "Creates", "directory", "for", "current", "namespace", "if", "not", "exists", "." ]
94ceacd8ac21b673ad2f2f222bc08696603ff2c6
https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/Adapter/FileCache.php#L475-L502
6,272
linnella/core
src/Form/Field/Select.php
Select.load
public function load($field, $sourceUrl, $idField = 'id', $textField = 'text') { if (Str::contains($field, '.')) { $field = $this->formatName($field); $class = str_replace(['[', ']'], '_', $field); } else { $class = $field; } $script = <<<EOT $(document).on('change', "{$this->getElementClassSelector()}", function () { var target = $(this).closest('.fields-group').find(".$class"); $.get("$sourceUrl?q="+this.value, function (data) { target.find("option").remove(); $(target).select2({ data: $.map(data, function (d) { d.id = d.$idField; d.text = d.$textField; return d; }) }).trigger('change'); }); }); EOT; Admin::script($script); return $this; }
php
public function load($field, $sourceUrl, $idField = 'id', $textField = 'text') { if (Str::contains($field, '.')) { $field = $this->formatName($field); $class = str_replace(['[', ']'], '_', $field); } else { $class = $field; } $script = <<<EOT $(document).on('change', "{$this->getElementClassSelector()}", function () { var target = $(this).closest('.fields-group').find(".$class"); $.get("$sourceUrl?q="+this.value, function (data) { target.find("option").remove(); $(target).select2({ data: $.map(data, function (d) { d.id = d.$idField; d.text = d.$textField; return d; }) }).trigger('change'); }); }); EOT; Admin::script($script); return $this; }
[ "public", "function", "load", "(", "$", "field", ",", "$", "sourceUrl", ",", "$", "idField", "=", "'id'", ",", "$", "textField", "=", "'text'", ")", "{", "if", "(", "Str", "::", "contains", "(", "$", "field", ",", "'.'", ")", ")", "{", "$", "field", "=", "$", "this", "->", "formatName", "(", "$", "field", ")", ";", "$", "class", "=", "str_replace", "(", "[", "'['", ",", "']'", "]", ",", "'_'", ",", "$", "field", ")", ";", "}", "else", "{", "$", "class", "=", "$", "field", ";", "}", "$", "script", "=", " <<<EOT\n\n$(document).on('change', \"{$this->getElementClassSelector()}\", function () {\n var target = $(this).closest('.fields-group').find(\".$class\");\n $.get(\"$sourceUrl?q=\"+this.value, function (data) {\n target.find(\"option\").remove();\n $(target).select2({\n data: $.map(data, function (d) {\n d.id = d.$idField;\n d.text = d.$textField;\n return d;\n })\n }).trigger('change');\n });\n});\nEOT", ";", "Admin", "::", "script", "(", "$", "script", ")", ";", "return", "$", "this", ";", "}" ]
Load options for other select on change. @param string $field @param string $sourceUrl @param string $idField @param string $textField @return $this
[ "Load", "options", "for", "other", "select", "on", "change", "." ]
381a49feddf2cbfab0ae4d0548b6c0a10da6f9fa
https://github.com/linnella/core/blob/381a49feddf2cbfab0ae4d0548b6c0a10da6f9fa/src/Form/Field/Select.php#L81-L110
6,273
mszewcz/php-light-framework
src/Session/Integrity.php
Integrity.getLooseIP
private static function getLooseIP(): string { return md5( static::$tokenUseLooseIP && isset($_SERVER['REMOTE_ADDR']) ? \long2ip(\ip2long($_SERVER['REMOTE_ADDR']) & \ip2long('255.255.0.0')) : '' ); }
php
private static function getLooseIP(): string { return md5( static::$tokenUseLooseIP && isset($_SERVER['REMOTE_ADDR']) ? \long2ip(\ip2long($_SERVER['REMOTE_ADDR']) & \ip2long('255.255.0.0')) : '' ); }
[ "private", "static", "function", "getLooseIP", "(", ")", ":", "string", "{", "return", "md5", "(", "static", "::", "$", "tokenUseLooseIP", "&&", "isset", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "?", "\\", "long2ip", "(", "\\", "ip2long", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "&", "\\", "ip2long", "(", "'255.255.0.0'", ")", ")", ":", "''", ")", ";", "}" ]
Returns user's loose IP @return string
[ "Returns", "user", "s", "loose", "IP" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Session/Integrity.php#L60-L67
6,274
mszewcz/php-light-framework
src/Session/Integrity.php
Integrity.buildToken
private static function buildToken(): string { return \md5( \sprintf( 'MF_SESSION_INTEGRITY_TOKEN:%s%s%s%s%s%s', static::getLooseIP(), static::getHttpUserAgent(), static::getHttpAccept(), static::getHttpAcceptEncoding(), static::getHttpAcceptLanguage(), static::getHttpAcceptCharset() ) ); }
php
private static function buildToken(): string { return \md5( \sprintf( 'MF_SESSION_INTEGRITY_TOKEN:%s%s%s%s%s%s', static::getLooseIP(), static::getHttpUserAgent(), static::getHttpAccept(), static::getHttpAcceptEncoding(), static::getHttpAcceptLanguage(), static::getHttpAcceptCharset() ) ); }
[ "private", "static", "function", "buildToken", "(", ")", ":", "string", "{", "return", "\\", "md5", "(", "\\", "sprintf", "(", "'MF_SESSION_INTEGRITY_TOKEN:%s%s%s%s%s%s'", ",", "static", "::", "getLooseIP", "(", ")", ",", "static", "::", "getHttpUserAgent", "(", ")", ",", "static", "::", "getHttpAccept", "(", ")", ",", "static", "::", "getHttpAcceptEncoding", "(", ")", ",", "static", "::", "getHttpAcceptLanguage", "(", ")", ",", "static", "::", "getHttpAcceptCharset", "(", ")", ")", ")", ";", "}" ]
Returns session integrity token based on session configuration @return string
[ "Returns", "session", "integrity", "token", "based", "on", "session", "configuration" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Session/Integrity.php#L144-L157
6,275
mszewcz/php-light-framework
src/Session/Integrity.php
Integrity.setToken
public static function setToken(string $variableName = '_MF_SESSION_INTEGRITY_TOKEN_'): bool { static::init(); $variableName = (string)$variableName; $vHandler = Variables::getInstance(); $vHandler->session->set($variableName, static::buildToken()); return true; }
php
public static function setToken(string $variableName = '_MF_SESSION_INTEGRITY_TOKEN_'): bool { static::init(); $variableName = (string)$variableName; $vHandler = Variables::getInstance(); $vHandler->session->set($variableName, static::buildToken()); return true; }
[ "public", "static", "function", "setToken", "(", "string", "$", "variableName", "=", "'_MF_SESSION_INTEGRITY_TOKEN_'", ")", ":", "bool", "{", "static", "::", "init", "(", ")", ";", "$", "variableName", "=", "(", "string", ")", "$", "variableName", ";", "$", "vHandler", "=", "Variables", "::", "getInstance", "(", ")", ";", "$", "vHandler", "->", "session", "->", "set", "(", "$", "variableName", ",", "static", "::", "buildToken", "(", ")", ")", ";", "return", "true", ";", "}" ]
Sets session integrity token according to session configuration @param string $variableName @return bool
[ "Sets", "session", "integrity", "token", "according", "to", "session", "configuration" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Session/Integrity.php#L165-L172
6,276
mszewcz/php-light-framework
src/Session/Integrity.php
Integrity.check
public static function check(string $variableName = '_MF_SESSION_INTEGRITY_TOKEN_'): bool { static::init(); $variableName = (string)$variableName; $vHandler = Variables::getInstance(); $userToken = $vHandler->session->get($variableName, $vHandler::TYPE_STRING); $httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $rIntegrity = static::$refererIntegrityEnabled ? \stripos($httpReferer, static::$serverName) !== false : true; $tIntegrity = static::$tokenIntegrityEnabled ? $userToken === static::buildToken() : true; return $rIntegrity && $tIntegrity; }
php
public static function check(string $variableName = '_MF_SESSION_INTEGRITY_TOKEN_'): bool { static::init(); $variableName = (string)$variableName; $vHandler = Variables::getInstance(); $userToken = $vHandler->session->get($variableName, $vHandler::TYPE_STRING); $httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $rIntegrity = static::$refererIntegrityEnabled ? \stripos($httpReferer, static::$serverName) !== false : true; $tIntegrity = static::$tokenIntegrityEnabled ? $userToken === static::buildToken() : true; return $rIntegrity && $tIntegrity; }
[ "public", "static", "function", "check", "(", "string", "$", "variableName", "=", "'_MF_SESSION_INTEGRITY_TOKEN_'", ")", ":", "bool", "{", "static", "::", "init", "(", ")", ";", "$", "variableName", "=", "(", "string", ")", "$", "variableName", ";", "$", "vHandler", "=", "Variables", "::", "getInstance", "(", ")", ";", "$", "userToken", "=", "$", "vHandler", "->", "session", "->", "get", "(", "$", "variableName", ",", "$", "vHandler", "::", "TYPE_STRING", ")", ";", "$", "httpReferer", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ":", "''", ";", "$", "rIntegrity", "=", "static", "::", "$", "refererIntegrityEnabled", "?", "\\", "stripos", "(", "$", "httpReferer", ",", "static", "::", "$", "serverName", ")", "!==", "false", ":", "true", ";", "$", "tIntegrity", "=", "static", "::", "$", "tokenIntegrityEnabled", "?", "$", "userToken", "===", "static", "::", "buildToken", "(", ")", ":", "true", ";", "return", "$", "rIntegrity", "&&", "$", "tIntegrity", ";", "}" ]
Checks session integrity according to session configuration @param string $variableName @return bool
[ "Checks", "session", "integrity", "according", "to", "session", "configuration" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Session/Integrity.php#L180-L190
6,277
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/Message.php
Message.setMetadata
public function setMetadata($spec, $value = null) { if (is_scalar($spec)) { $this->metadata[$spec] = $value; return $this; } if (!is_array($spec) && !$spec instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( 'Expected a string, array, or Traversable argument in first position; received "%s"', (is_object($spec) ? get_class($spec) : gettype($spec)) )); } foreach ($spec as $key => $value) { $this->metadata[$key] = $value; } return $this; }
php
public function setMetadata($spec, $value = null) { if (is_scalar($spec)) { $this->metadata[$spec] = $value; return $this; } if (!is_array($spec) && !$spec instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( 'Expected a string, array, or Traversable argument in first position; received "%s"', (is_object($spec) ? get_class($spec) : gettype($spec)) )); } foreach ($spec as $key => $value) { $this->metadata[$key] = $value; } return $this; }
[ "public", "function", "setMetadata", "(", "$", "spec", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_scalar", "(", "$", "spec", ")", ")", "{", "$", "this", "->", "metadata", "[", "$", "spec", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_array", "(", "$", "spec", ")", "&&", "!", "$", "spec", "instanceof", "Traversable", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Expected a string, array, or Traversable argument in first position; received \"%s\"'", ",", "(", "is_object", "(", "$", "spec", ")", "?", "get_class", "(", "$", "spec", ")", ":", "gettype", "(", "$", "spec", ")", ")", ")", ")", ";", "}", "foreach", "(", "$", "spec", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "metadata", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set message metadata Non-destructive setting of message metadata; always adds to the metadata, never overwrites the entire metadata container. @param string|int|array|Traversable $spec @param mixed $value @throws Exception\InvalidArgumentException @return Message
[ "Set", "message", "metadata" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/Message.php#L37-L53
6,278
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/Message.php
Message.getMetadata
public function getMetadata($key = null, $default = null) { if (null === $key) { return $this->metadata; } if (!is_scalar($key)) { throw new Exception\InvalidArgumentException('Non-scalar argument provided for key'); } if (array_key_exists($key, $this->metadata)) { return $this->metadata[$key]; } return $default; }
php
public function getMetadata($key = null, $default = null) { if (null === $key) { return $this->metadata; } if (!is_scalar($key)) { throw new Exception\InvalidArgumentException('Non-scalar argument provided for key'); } if (array_key_exists($key, $this->metadata)) { return $this->metadata[$key]; } return $default; }
[ "public", "function", "getMetadata", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "null", "===", "$", "key", ")", "{", "return", "$", "this", "->", "metadata", ";", "}", "if", "(", "!", "is_scalar", "(", "$", "key", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Non-scalar argument provided for key'", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "metadata", ")", ")", "{", "return", "$", "this", "->", "metadata", "[", "$", "key", "]", ";", "}", "return", "$", "default", ";", "}" ]
Retrieve all metadata or a single metadatum as specified by key @param null|string|int $key @param null|mixed $default @throws Exception\InvalidArgumentException @return mixed
[ "Retrieve", "all", "metadata", "or", "a", "single", "metadatum", "as", "specified", "by", "key" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/Message.php#L63-L78
6,279
native5/native5-sdk-services-php
src/Native5/Services/Users/DefaultUserManager.php
DefaultUserManager.saveUser
public function saveUser(\Native5\Services\Users\User $user, $updates) { $logger = $GLOBALS['logger']; $path = 'users/'.$user->getId(); $request = $this->_remoteServer->put($path, array(), json_encode($updates)); try { $response = $request->send(); return $response->getBody('true'); } catch(\Guzzle\Http\Exception\BadResponseException $e) { $logger->info($e->getResponse()->getBody('true'), array()); return false; } }
php
public function saveUser(\Native5\Services\Users\User $user, $updates) { $logger = $GLOBALS['logger']; $path = 'users/'.$user->getId(); $request = $this->_remoteServer->put($path, array(), json_encode($updates)); try { $response = $request->send(); return $response->getBody('true'); } catch(\Guzzle\Http\Exception\BadResponseException $e) { $logger->info($e->getResponse()->getBody('true'), array()); return false; } }
[ "public", "function", "saveUser", "(", "\\", "Native5", "\\", "Services", "\\", "Users", "\\", "User", "$", "user", ",", "$", "updates", ")", "{", "$", "logger", "=", "$", "GLOBALS", "[", "'logger'", "]", ";", "$", "path", "=", "'users/'", ".", "$", "user", "->", "getId", "(", ")", ";", "$", "request", "=", "$", "this", "->", "_remoteServer", "->", "put", "(", "$", "path", ",", "array", "(", ")", ",", "json_encode", "(", "$", "updates", ")", ")", ";", "try", "{", "$", "response", "=", "$", "request", "->", "send", "(", ")", ";", "return", "$", "response", "->", "getBody", "(", "'true'", ")", ";", "}", "catch", "(", "\\", "Guzzle", "\\", "Http", "\\", "Exception", "\\", "BadResponseException", "$", "e", ")", "{", "$", "logger", "->", "info", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", "'true'", ")", ",", "array", "(", ")", ")", ";", "return", "false", ";", "}", "}" ]
Updates user details @param mixed $user @access public @return void
[ "Updates", "user", "details" ]
037bb45b5adaab40a3fe6e0a721268b483f15a94
https://github.com/native5/native5-sdk-services-php/blob/037bb45b5adaab40a3fe6e0a721268b483f15a94/src/Native5/Services/Users/DefaultUserManager.php#L91-L103
6,280
native5/native5-sdk-services-php
src/Native5/Services/Users/DefaultUserManager.php
DefaultUserManager.verifyToken
public function verifyToken($email, $token) { $path = 'users/verify_token'; $request = $this->_remoteServer->get($path); $request->getQuery()->set('email', $email); $request->getQuery()->set('token', $token); $response = $request->send(); return $response->getBody('true'); }
php
public function verifyToken($email, $token) { $path = 'users/verify_token'; $request = $this->_remoteServer->get($path); $request->getQuery()->set('email', $email); $request->getQuery()->set('token', $token); $response = $request->send(); return $response->getBody('true'); }
[ "public", "function", "verifyToken", "(", "$", "email", ",", "$", "token", ")", "{", "$", "path", "=", "'users/verify_token'", ";", "$", "request", "=", "$", "this", "->", "_remoteServer", "->", "get", "(", "$", "path", ")", ";", "$", "request", "->", "getQuery", "(", ")", "->", "set", "(", "'email'", ",", "$", "email", ")", ";", "$", "request", "->", "getQuery", "(", ")", "->", "set", "(", "'token'", ",", "$", "token", ")", ";", "$", "response", "=", "$", "request", "->", "send", "(", ")", ";", "return", "$", "response", "->", "getBody", "(", "'true'", ")", ";", "}" ]
Verifies token given the user id & the token. @param mixed $email User e-mail @param mixed $token API token @access public @return void
[ "Verifies", "token", "given", "the", "user", "id", "&", "the", "token", "." ]
037bb45b5adaab40a3fe6e0a721268b483f15a94
https://github.com/native5/native5-sdk-services-php/blob/037bb45b5adaab40a3fe6e0a721268b483f15a94/src/Native5/Services/Users/DefaultUserManager.php#L196-L205
6,281
native5/native5-sdk-services-php
src/Native5/Services/Users/DefaultUserManager.php
DefaultUserManager.createUser
public function createUser(\Native5\Services\Users\User $user) { global $logger; $path = 'users/create'; $request = $this->_remoteServer->post($path) ->setPostField('username', $user->getUsername()) ->setPostField('password', $user->getPassword()) ->setPostField('name', $user->getName()) ->setPostField('roles', json_encode($user->getRoles())) ->setPostField('aliases', json_encode($user->getAliases())); try { $response = $request->send(); } catch(\Guzzle\Http\Exception\BadResponseException $e) { $logger->info($e->getResponse()->getBody('true'), array()); return false; } return true; }
php
public function createUser(\Native5\Services\Users\User $user) { global $logger; $path = 'users/create'; $request = $this->_remoteServer->post($path) ->setPostField('username', $user->getUsername()) ->setPostField('password', $user->getPassword()) ->setPostField('name', $user->getName()) ->setPostField('roles', json_encode($user->getRoles())) ->setPostField('aliases', json_encode($user->getAliases())); try { $response = $request->send(); } catch(\Guzzle\Http\Exception\BadResponseException $e) { $logger->info($e->getResponse()->getBody('true'), array()); return false; } return true; }
[ "public", "function", "createUser", "(", "\\", "Native5", "\\", "Services", "\\", "Users", "\\", "User", "$", "user", ")", "{", "global", "$", "logger", ";", "$", "path", "=", "'users/create'", ";", "$", "request", "=", "$", "this", "->", "_remoteServer", "->", "post", "(", "$", "path", ")", "->", "setPostField", "(", "'username'", ",", "$", "user", "->", "getUsername", "(", ")", ")", "->", "setPostField", "(", "'password'", ",", "$", "user", "->", "getPassword", "(", ")", ")", "->", "setPostField", "(", "'name'", ",", "$", "user", "->", "getName", "(", ")", ")", "->", "setPostField", "(", "'roles'", ",", "json_encode", "(", "$", "user", "->", "getRoles", "(", ")", ")", ")", "->", "setPostField", "(", "'aliases'", ",", "json_encode", "(", "$", "user", "->", "getAliases", "(", ")", ")", ")", ";", "try", "{", "$", "response", "=", "$", "request", "->", "send", "(", ")", ";", "}", "catch", "(", "\\", "Guzzle", "\\", "Http", "\\", "Exception", "\\", "BadResponseException", "$", "e", ")", "{", "$", "logger", "->", "info", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", "'true'", ")", ",", "array", "(", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
createUser Create User for an application @param mixed $username Login username @param mixed $password Login password @param mixed $name User name @param array $roles Optional user roles as an array @param array $aliases Optional user aliases as an associative array @access public @return boolean true on success, false otherwise
[ "createUser", "Create", "User", "for", "an", "application" ]
037bb45b5adaab40a3fe6e0a721268b483f15a94
https://github.com/native5/native5-sdk-services-php/blob/037bb45b5adaab40a3fe6e0a721268b483f15a94/src/Native5/Services/Users/DefaultUserManager.php#L218-L235
6,282
native5/native5-sdk-services-php
src/Native5/Services/Users/DefaultUserManager.php
DefaultUserManager.getAllUsers
public function getAllUsers($count=1000, $offset=0, $searchToken=null) { global $logger; $path = 'users'; $request = $this->_remoteServer->get($path); if(!empty($searchToken)) { $request->getQuery()->set('searchToken', $searchToken); } $request->getQuery()->set('numUsers', $count); $request->getQuery()->set('offset', $offset); try { $response = $request->send(); } catch(\Guzzle\Http\Exception\BadResponseException $e) { $logger->info($e->getResponse()->getBody('true'), array()); return false; } return $response->json(); }
php
public function getAllUsers($count=1000, $offset=0, $searchToken=null) { global $logger; $path = 'users'; $request = $this->_remoteServer->get($path); if(!empty($searchToken)) { $request->getQuery()->set('searchToken', $searchToken); } $request->getQuery()->set('numUsers', $count); $request->getQuery()->set('offset', $offset); try { $response = $request->send(); } catch(\Guzzle\Http\Exception\BadResponseException $e) { $logger->info($e->getResponse()->getBody('true'), array()); return false; } return $response->json(); }
[ "public", "function", "getAllUsers", "(", "$", "count", "=", "1000", ",", "$", "offset", "=", "0", ",", "$", "searchToken", "=", "null", ")", "{", "global", "$", "logger", ";", "$", "path", "=", "'users'", ";", "$", "request", "=", "$", "this", "->", "_remoteServer", "->", "get", "(", "$", "path", ")", ";", "if", "(", "!", "empty", "(", "$", "searchToken", ")", ")", "{", "$", "request", "->", "getQuery", "(", ")", "->", "set", "(", "'searchToken'", ",", "$", "searchToken", ")", ";", "}", "$", "request", "->", "getQuery", "(", ")", "->", "set", "(", "'numUsers'", ",", "$", "count", ")", ";", "$", "request", "->", "getQuery", "(", ")", "->", "set", "(", "'offset'", ",", "$", "offset", ")", ";", "try", "{", "$", "response", "=", "$", "request", "->", "send", "(", ")", ";", "}", "catch", "(", "\\", "Guzzle", "\\", "Http", "\\", "Exception", "\\", "BadResponseException", "$", "e", ")", "{", "$", "logger", "->", "info", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", "'true'", ")", ",", "array", "(", ")", ")", ";", "return", "false", ";", "}", "return", "$", "response", "->", "json", "(", ")", ";", "}" ]
getAllUsers List all users for an application @access public @return array array of user associative arrays
[ "getAllUsers", "List", "all", "users", "for", "an", "application" ]
037bb45b5adaab40a3fe6e0a721268b483f15a94
https://github.com/native5/native5-sdk-services-php/blob/037bb45b5adaab40a3fe6e0a721268b483f15a94/src/Native5/Services/Users/DefaultUserManager.php#L243-L260
6,283
easy-system/es-view
src/View.php
View.getLayout
public function getLayout() { if (! $this->layout) { $layout = new ViewModel(); $layout->setTemplate('layout/layout'); $this->layout = $layout; } return $this->layout; }
php
public function getLayout() { if (! $this->layout) { $layout = new ViewModel(); $layout->setTemplate('layout/layout'); $this->layout = $layout; } return $this->layout; }
[ "public", "function", "getLayout", "(", ")", "{", "if", "(", "!", "$", "this", "->", "layout", ")", "{", "$", "layout", "=", "new", "ViewModel", "(", ")", ";", "$", "layout", "->", "setTemplate", "(", "'layout/layout'", ")", ";", "$", "this", "->", "layout", "=", "$", "layout", ";", "}", "return", "$", "this", "->", "layout", ";", "}" ]
Gets the layout. @return \Es\Mvc\ViewModelInterface The layout
[ "Gets", "the", "layout", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/View.php#L53-L62
6,284
easy-system/es-view
src/View.php
View.getEvents
public function getEvents() { if (! $this->events) { $services = $this->getServices(); $events = $services->get('Events'); $this->setEvents($events); } return $this->events; }
php
public function getEvents() { if (! $this->events) { $services = $this->getServices(); $events = $services->get('Events'); $this->setEvents($events); } return $this->events; }
[ "public", "function", "getEvents", "(", ")", "{", "if", "(", "!", "$", "this", "->", "events", ")", "{", "$", "services", "=", "$", "this", "->", "getServices", "(", ")", ";", "$", "events", "=", "$", "services", "->", "get", "(", "'Events'", ")", ";", "$", "this", "->", "setEvents", "(", "$", "events", ")", ";", "}", "return", "$", "this", "->", "events", ";", "}" ]
Gets the events. @return \Es\Events\EventsInterface The events
[ "Gets", "the", "events", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/View.php#L79-L88
6,285
easy-system/es-view
src/View.php
View.render
public function render(ViewModelInterface $model) { foreach ($model as $child) { $groupId = $child->getGroupId(); if (empty($groupId)) { continue; } $result = $this->render($child); $oldResult = $model->getVariable($groupId, ''); $model->setVariable($groupId, $oldResult . $result); } $events = $this->getEvents(); $event = new ViewEvent($model); $events->trigger($event); return $event->getResult(); }
php
public function render(ViewModelInterface $model) { foreach ($model as $child) { $groupId = $child->getGroupId(); if (empty($groupId)) { continue; } $result = $this->render($child); $oldResult = $model->getVariable($groupId, ''); $model->setVariable($groupId, $oldResult . $result); } $events = $this->getEvents(); $event = new ViewEvent($model); $events->trigger($event); return $event->getResult(); }
[ "public", "function", "render", "(", "ViewModelInterface", "$", "model", ")", "{", "foreach", "(", "$", "model", "as", "$", "child", ")", "{", "$", "groupId", "=", "$", "child", "->", "getGroupId", "(", ")", ";", "if", "(", "empty", "(", "$", "groupId", ")", ")", "{", "continue", ";", "}", "$", "result", "=", "$", "this", "->", "render", "(", "$", "child", ")", ";", "$", "oldResult", "=", "$", "model", "->", "getVariable", "(", "$", "groupId", ",", "''", ")", ";", "$", "model", "->", "setVariable", "(", "$", "groupId", ",", "$", "oldResult", ".", "$", "result", ")", ";", "}", "$", "events", "=", "$", "this", "->", "getEvents", "(", ")", ";", "$", "event", "=", "new", "ViewEvent", "(", "$", "model", ")", ";", "$", "events", "->", "trigger", "(", "$", "event", ")", ";", "return", "$", "event", "->", "getResult", "(", ")", ";", "}" ]
Renders the view model. @param \Es\Mvc\ViewModelInterface $model The view model @return mixed The result of rendering
[ "Renders", "the", "view", "model", "." ]
8a29efcef8cd59640c98f5440379a93d0f504212
https://github.com/easy-system/es-view/blob/8a29efcef8cd59640c98f5440379a93d0f504212/src/View.php#L97-L114
6,286
theluckyteam/php-jira
src/jira/Util/IssueLinkHelper.php
IssueLinkHelper.getLinkName
public static function getLinkName($issueLink) { $linkName = null; if (isset($issueLink['outwardIssue'])) { if (isset($issueLink['outwardIssue']['key'], $issueLink['type']['outward'])) { $linkName = $issueLink['type']['outward']; } } elseif (isset($issueLink['inwardIssue'], $issueLink['type']['inward'])) { if (isset($issueLink['inwardIssue']['key'])) { $linkName = $issueLink['type']['inward']; } } return $linkName; }
php
public static function getLinkName($issueLink) { $linkName = null; if (isset($issueLink['outwardIssue'])) { if (isset($issueLink['outwardIssue']['key'], $issueLink['type']['outward'])) { $linkName = $issueLink['type']['outward']; } } elseif (isset($issueLink['inwardIssue'], $issueLink['type']['inward'])) { if (isset($issueLink['inwardIssue']['key'])) { $linkName = $issueLink['type']['inward']; } } return $linkName; }
[ "public", "static", "function", "getLinkName", "(", "$", "issueLink", ")", "{", "$", "linkName", "=", "null", ";", "if", "(", "isset", "(", "$", "issueLink", "[", "'outwardIssue'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "issueLink", "[", "'outwardIssue'", "]", "[", "'key'", "]", ",", "$", "issueLink", "[", "'type'", "]", "[", "'outward'", "]", ")", ")", "{", "$", "linkName", "=", "$", "issueLink", "[", "'type'", "]", "[", "'outward'", "]", ";", "}", "}", "elseif", "(", "isset", "(", "$", "issueLink", "[", "'inwardIssue'", "]", ",", "$", "issueLink", "[", "'type'", "]", "[", "'inward'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "issueLink", "[", "'inwardIssue'", "]", "[", "'key'", "]", ")", ")", "{", "$", "linkName", "=", "$", "issueLink", "[", "'type'", "]", "[", "'inward'", "]", ";", "}", "}", "return", "$", "linkName", ";", "}" ]
Returns name of link from Issue link @param array $issueLink An array of Issue link @return string Name of link
[ "Returns", "name", "of", "link", "from", "Issue", "link" ]
5a50ab4fc57dd77239f1b7e9c87738318c258c38
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Util/IssueLinkHelper.php#L18-L33
6,287
theluckyteam/php-jira
src/jira/Util/IssueLinkHelper.php
IssueLinkHelper.getLinkedIssueKey
public static function getLinkedIssueKey($issueLink) { $linkedIssueKey = null; if (isset($issueLink['outwardIssue'])) { if (isset($issueLink['outwardIssue']['key'], $issueLink['type']['outward'])) { $linkedIssueKey = $issueLink['outwardIssue']['key']; } } elseif (isset($issueLink['inwardIssue'], $issueLink['type']['inward'])) { if (isset($issueLink['inwardIssue']['key'])) { $linkedIssueKey = $issueLink['inwardIssue']['key']; } } return $linkedIssueKey; }
php
public static function getLinkedIssueKey($issueLink) { $linkedIssueKey = null; if (isset($issueLink['outwardIssue'])) { if (isset($issueLink['outwardIssue']['key'], $issueLink['type']['outward'])) { $linkedIssueKey = $issueLink['outwardIssue']['key']; } } elseif (isset($issueLink['inwardIssue'], $issueLink['type']['inward'])) { if (isset($issueLink['inwardIssue']['key'])) { $linkedIssueKey = $issueLink['inwardIssue']['key']; } } return $linkedIssueKey; }
[ "public", "static", "function", "getLinkedIssueKey", "(", "$", "issueLink", ")", "{", "$", "linkedIssueKey", "=", "null", ";", "if", "(", "isset", "(", "$", "issueLink", "[", "'outwardIssue'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "issueLink", "[", "'outwardIssue'", "]", "[", "'key'", "]", ",", "$", "issueLink", "[", "'type'", "]", "[", "'outward'", "]", ")", ")", "{", "$", "linkedIssueKey", "=", "$", "issueLink", "[", "'outwardIssue'", "]", "[", "'key'", "]", ";", "}", "}", "elseif", "(", "isset", "(", "$", "issueLink", "[", "'inwardIssue'", "]", ",", "$", "issueLink", "[", "'type'", "]", "[", "'inward'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "issueLink", "[", "'inwardIssue'", "]", "[", "'key'", "]", ")", ")", "{", "$", "linkedIssueKey", "=", "$", "issueLink", "[", "'inwardIssue'", "]", "[", "'key'", "]", ";", "}", "}", "return", "$", "linkedIssueKey", ";", "}" ]
Returns key of linked Issue from Issue link @param array $issueLink An array of Issue link @return string Key of linked Issue
[ "Returns", "key", "of", "linked", "Issue", "from", "Issue", "link" ]
5a50ab4fc57dd77239f1b7e9c87738318c258c38
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Util/IssueLinkHelper.php#L42-L57
6,288
Label305/Auja-PHP
src/Label305/Auja/Menu/Resource.php
Resource.addItem
public function addItem(MenuItem $item) { if($item instanceof ResourceMenuItem){ throw new \InvalidArgumentException('ResourceMenuItem passed to Resource::addItem(MenuItem). You cannot nest ResourceMenuItems.'); } $this->items[] = $item; return $this; }
php
public function addItem(MenuItem $item) { if($item instanceof ResourceMenuItem){ throw new \InvalidArgumentException('ResourceMenuItem passed to Resource::addItem(MenuItem). You cannot nest ResourceMenuItems.'); } $this->items[] = $item; return $this; }
[ "public", "function", "addItem", "(", "MenuItem", "$", "item", ")", "{", "if", "(", "$", "item", "instanceof", "ResourceMenuItem", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'ResourceMenuItem passed to Resource::addItem(MenuItem). You cannot nest ResourceMenuItems.'", ")", ";", "}", "$", "this", "->", "items", "[", "]", "=", "$", "item", ";", "return", "$", "this", ";", "}" ]
Adds a `MenuItem`, which contains a database entry. @param MenuItem $item The item to add. Must not be a `ResourceMenuItem`. @return $this
[ "Adds", "a", "MenuItem", "which", "contains", "a", "database", "entry", "." ]
64712af949c4b80e6ca19ed1936e6b37f8965a4c
https://github.com/Label305/Auja-PHP/blob/64712af949c4b80e6ca19ed1936e6b37f8965a4c/src/Label305/Auja/Menu/Resource.php#L65-L73
6,289
Label305/Auja-PHP
src/Label305/Auja/Menu/Resource.php
Resource.aujaSerialize
public function aujaSerialize() { $result = array(); $result['type'] = $this->getType(); $result[$this->getType()] = $this->basicSerialize(); if ($this->nextPageUrl != null || $this->totalPageUrl != null) { $result['paging'] = array(); if ($this->nextPageUrl != null) { $result['paging']['next'] = $this->nextPageUrl; } if ($this->totalPageUrl != null) { $result['paging']['total'] = $this->totalPageUrl; } } return $result; }
php
public function aujaSerialize() { $result = array(); $result['type'] = $this->getType(); $result[$this->getType()] = $this->basicSerialize(); if ($this->nextPageUrl != null || $this->totalPageUrl != null) { $result['paging'] = array(); if ($this->nextPageUrl != null) { $result['paging']['next'] = $this->nextPageUrl; } if ($this->totalPageUrl != null) { $result['paging']['total'] = $this->totalPageUrl; } } return $result; }
[ "public", "function", "aujaSerialize", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'type'", "]", "=", "$", "this", "->", "getType", "(", ")", ";", "$", "result", "[", "$", "this", "->", "getType", "(", ")", "]", "=", "$", "this", "->", "basicSerialize", "(", ")", ";", "if", "(", "$", "this", "->", "nextPageUrl", "!=", "null", "||", "$", "this", "->", "totalPageUrl", "!=", "null", ")", "{", "$", "result", "[", "'paging'", "]", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "nextPageUrl", "!=", "null", ")", "{", "$", "result", "[", "'paging'", "]", "[", "'next'", "]", "=", "$", "this", "->", "nextPageUrl", ";", "}", "if", "(", "$", "this", "->", "totalPageUrl", "!=", "null", ")", "{", "$", "result", "[", "'paging'", "]", "[", "'total'", "]", "=", "$", "this", "->", "totalPageUrl", ";", "}", "}", "return", "$", "result", ";", "}" ]
Overridden to add an extra `paging` section to the result. @return array The ready-to-use `array`.
[ "Overridden", "to", "add", "an", "extra", "paging", "section", "to", "the", "result", "." ]
64712af949c4b80e6ca19ed1936e6b37f8965a4c
https://github.com/Label305/Auja-PHP/blob/64712af949c4b80e6ca19ed1936e6b37f8965a4c/src/Label305/Auja/Menu/Resource.php#L132-L149
6,290
bugotech/http
src/Wizard/WizardTrait.php
WizardTrait.flow
protected function flow($step) { // Carregar id do flow $flow = router()->current()->parameter('flow'); if (is_null($flow)) { error('Flow not information'); } // Carregar model $this->model = call_user_func_array([$this->modelName, 'find'], [$flow]); if (is_null($this->model)) { error('Flow "%s" not found', $flow); } // Carregar step $step = is_null($step) ? $this->model->steps->firstId() : $step; if (! $this->model->steps->exists($step)) { error('Step "%s" not found', $step); } $this->model->steps->setCurrent($step); return $this->model->steps->current(); }
php
protected function flow($step) { // Carregar id do flow $flow = router()->current()->parameter('flow'); if (is_null($flow)) { error('Flow not information'); } // Carregar model $this->model = call_user_func_array([$this->modelName, 'find'], [$flow]); if (is_null($this->model)) { error('Flow "%s" not found', $flow); } // Carregar step $step = is_null($step) ? $this->model->steps->firstId() : $step; if (! $this->model->steps->exists($step)) { error('Step "%s" not found', $step); } $this->model->steps->setCurrent($step); return $this->model->steps->current(); }
[ "protected", "function", "flow", "(", "$", "step", ")", "{", "// Carregar id do flow", "$", "flow", "=", "router", "(", ")", "->", "current", "(", ")", "->", "parameter", "(", "'flow'", ")", ";", "if", "(", "is_null", "(", "$", "flow", ")", ")", "{", "error", "(", "'Flow not information'", ")", ";", "}", "// Carregar model", "$", "this", "->", "model", "=", "call_user_func_array", "(", "[", "$", "this", "->", "modelName", ",", "'find'", "]", ",", "[", "$", "flow", "]", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "model", ")", ")", "{", "error", "(", "'Flow \"%s\" not found'", ",", "$", "flow", ")", ";", "}", "// Carregar step", "$", "step", "=", "is_null", "(", "$", "step", ")", "?", "$", "this", "->", "model", "->", "steps", "->", "firstId", "(", ")", ":", "$", "step", ";", "if", "(", "!", "$", "this", "->", "model", "->", "steps", "->", "exists", "(", "$", "step", ")", ")", "{", "error", "(", "'Step \"%s\" not found'", ",", "$", "step", ")", ";", "}", "$", "this", "->", "model", "->", "steps", "->", "setCurrent", "(", "$", "step", ")", ";", "return", "$", "this", "->", "model", "->", "steps", "->", "current", "(", ")", ";", "}" ]
Define com step atual e retornal o objeto. @param string $step @return Step
[ "Define", "com", "step", "atual", "e", "retornal", "o", "objeto", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Wizard/WizardTrait.php#L50-L73
6,291
bugotech/http
src/Wizard/WizardTrait.php
WizardTrait.createFlow
public function createFlow() { $model = app($this->modelName); $model->save(); $step = $model->steps->firstId(); return redirect()->route(sprintf('%s.get', $this->prefixRoute), ['flow' => $model->_id, 'step' => $step]); }
php
public function createFlow() { $model = app($this->modelName); $model->save(); $step = $model->steps->firstId(); return redirect()->route(sprintf('%s.get', $this->prefixRoute), ['flow' => $model->_id, 'step' => $step]); }
[ "public", "function", "createFlow", "(", ")", "{", "$", "model", "=", "app", "(", "$", "this", "->", "modelName", ")", ";", "$", "model", "->", "save", "(", ")", ";", "$", "step", "=", "$", "model", "->", "steps", "->", "firstId", "(", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "sprintf", "(", "'%s.get'", ",", "$", "this", "->", "prefixRoute", ")", ",", "[", "'flow'", "=>", "$", "model", "->", "_id", ",", "'step'", "=>", "$", "step", "]", ")", ";", "}" ]
Cria novo flow. @return \Illuminate\Http\RedirectResponse
[ "Cria", "novo", "flow", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Wizard/WizardTrait.php#L79-L87
6,292
bugotech/http
src/Wizard/WizardTrait.php
WizardTrait.getSteps
public function getSteps() { // Carregar step do conexto e atual $step = $this->flow(router()->current()->parameter('step')); // Carregar view $view_id = sprintf('%s.%s', $this->prefixViewName, $step->key); if (! view()->exists($view_id)) { error('View of step "%s" not found', $view_id); } $view = view($view_id); $view->with('steps', $this->model->steps); $view->with('step', $step); $view->with('model', $this->model); $view->with($this->viewParams); $view->with('step_url', function ($step, $method = 'get') { return $this->stepUrl($step, $method); }); return $view; }
php
public function getSteps() { // Carregar step do conexto e atual $step = $this->flow(router()->current()->parameter('step')); // Carregar view $view_id = sprintf('%s.%s', $this->prefixViewName, $step->key); if (! view()->exists($view_id)) { error('View of step "%s" not found', $view_id); } $view = view($view_id); $view->with('steps', $this->model->steps); $view->with('step', $step); $view->with('model', $this->model); $view->with($this->viewParams); $view->with('step_url', function ($step, $method = 'get') { return $this->stepUrl($step, $method); }); return $view; }
[ "public", "function", "getSteps", "(", ")", "{", "// Carregar step do conexto e atual", "$", "step", "=", "$", "this", "->", "flow", "(", "router", "(", ")", "->", "current", "(", ")", "->", "parameter", "(", "'step'", ")", ")", ";", "// Carregar view", "$", "view_id", "=", "sprintf", "(", "'%s.%s'", ",", "$", "this", "->", "prefixViewName", ",", "$", "step", "->", "key", ")", ";", "if", "(", "!", "view", "(", ")", "->", "exists", "(", "$", "view_id", ")", ")", "{", "error", "(", "'View of step \"%s\" not found'", ",", "$", "view_id", ")", ";", "}", "$", "view", "=", "view", "(", "$", "view_id", ")", ";", "$", "view", "->", "with", "(", "'steps'", ",", "$", "this", "->", "model", "->", "steps", ")", ";", "$", "view", "->", "with", "(", "'step'", ",", "$", "step", ")", ";", "$", "view", "->", "with", "(", "'model'", ",", "$", "this", "->", "model", ")", ";", "$", "view", "->", "with", "(", "$", "this", "->", "viewParams", ")", ";", "$", "view", "->", "with", "(", "'step_url'", ",", "function", "(", "$", "step", ",", "$", "method", "=", "'get'", ")", "{", "return", "$", "this", "->", "stepUrl", "(", "$", "step", ",", "$", "method", ")", ";", "}", ")", ";", "return", "$", "view", ";", "}" ]
Retorna a view do step. @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "Retorna", "a", "view", "do", "step", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Wizard/WizardTrait.php#L93-L115
6,293
bugotech/http
src/Wizard/WizardTrait.php
WizardTrait.stepUrl
protected function stepUrl(Step $step, $method = 'get') { $id = sprintf('%s.%s', $this->prefixRoute, $method); return route($id, ['step' => $step->key]); }
php
protected function stepUrl(Step $step, $method = 'get') { $id = sprintf('%s.%s', $this->prefixRoute, $method); return route($id, ['step' => $step->key]); }
[ "protected", "function", "stepUrl", "(", "Step", "$", "step", ",", "$", "method", "=", "'get'", ")", "{", "$", "id", "=", "sprintf", "(", "'%s.%s'", ",", "$", "this", "->", "prefixRoute", ",", "$", "method", ")", ";", "return", "route", "(", "$", "id", ",", "[", "'step'", "=>", "$", "step", "->", "key", "]", ")", ";", "}" ]
Retorna url do step. @param Step $step @param string $method @return string
[ "Retorna", "url", "do", "step", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Wizard/WizardTrait.php#L182-L187
6,294
bugotech/http
src/Wizard/WizardTrait.php
WizardTrait.routesRegister
public static function routesRegister(Router $router, $prefixPart, $routePrefix) { $class = get_called_class(); // Get - Create flow $part = sprintf('%s', $prefixPart); $uses = sprintf('\%s@createFlow', $class); $as = sprintf('%s.create', $routePrefix); $router->get($part, ['uses' => $uses, 'as' => $as]); // Get - Step $part = sprintf('%s/{flow}/{step}', $prefixPart); $uses = sprintf('\%s@getSteps', $class); $as = sprintf('%s.get', $routePrefix); $router->get($part, ['uses' => $uses, 'as' => $as]); // Post - Step $part = sprintf('%s/{flow}', $prefixPart); $uses = sprintf('\%s@setSteps', $class); $as = sprintf('%s.post', $routePrefix); $router->post($part, ['uses' => $uses, 'as' => $as]); }
php
public static function routesRegister(Router $router, $prefixPart, $routePrefix) { $class = get_called_class(); // Get - Create flow $part = sprintf('%s', $prefixPart); $uses = sprintf('\%s@createFlow', $class); $as = sprintf('%s.create', $routePrefix); $router->get($part, ['uses' => $uses, 'as' => $as]); // Get - Step $part = sprintf('%s/{flow}/{step}', $prefixPart); $uses = sprintf('\%s@getSteps', $class); $as = sprintf('%s.get', $routePrefix); $router->get($part, ['uses' => $uses, 'as' => $as]); // Post - Step $part = sprintf('%s/{flow}', $prefixPart); $uses = sprintf('\%s@setSteps', $class); $as = sprintf('%s.post', $routePrefix); $router->post($part, ['uses' => $uses, 'as' => $as]); }
[ "public", "static", "function", "routesRegister", "(", "Router", "$", "router", ",", "$", "prefixPart", ",", "$", "routePrefix", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "// Get - Create flow", "$", "part", "=", "sprintf", "(", "'%s'", ",", "$", "prefixPart", ")", ";", "$", "uses", "=", "sprintf", "(", "'\\%s@createFlow'", ",", "$", "class", ")", ";", "$", "as", "=", "sprintf", "(", "'%s.create'", ",", "$", "routePrefix", ")", ";", "$", "router", "->", "get", "(", "$", "part", ",", "[", "'uses'", "=>", "$", "uses", ",", "'as'", "=>", "$", "as", "]", ")", ";", "// Get - Step", "$", "part", "=", "sprintf", "(", "'%s/{flow}/{step}'", ",", "$", "prefixPart", ")", ";", "$", "uses", "=", "sprintf", "(", "'\\%s@getSteps'", ",", "$", "class", ")", ";", "$", "as", "=", "sprintf", "(", "'%s.get'", ",", "$", "routePrefix", ")", ";", "$", "router", "->", "get", "(", "$", "part", ",", "[", "'uses'", "=>", "$", "uses", ",", "'as'", "=>", "$", "as", "]", ")", ";", "// Post - Step", "$", "part", "=", "sprintf", "(", "'%s/{flow}'", ",", "$", "prefixPart", ")", ";", "$", "uses", "=", "sprintf", "(", "'\\%s@setSteps'", ",", "$", "class", ")", ";", "$", "as", "=", "sprintf", "(", "'%s.post'", ",", "$", "routePrefix", ")", ";", "$", "router", "->", "post", "(", "$", "part", ",", "[", "'uses'", "=>", "$", "uses", ",", "'as'", "=>", "$", "as", "]", ")", ";", "}" ]
Register routes of flow. @param Router $router @param $prefixPart @param $routePrefix
[ "Register", "routes", "of", "flow", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Wizard/WizardTrait.php#L207-L228
6,295
jarrus90/yii2-multilang
Components/MultilangRequest.php
MultilangRequest.resolve
public function resolve() { $resolve = parent::resolve(); $languages = Language::getDb()->cache(function ($db) { return Language::find()->where(['is_active' => true])->asArray()->all(); }); Yii::$app->params['languages'] = ArrayHelper::map($languages, 'code', 'code'); Yii::$app->language = $this->getCurrentLang(); return $resolve; }
php
public function resolve() { $resolve = parent::resolve(); $languages = Language::getDb()->cache(function ($db) { return Language::find()->where(['is_active' => true])->asArray()->all(); }); Yii::$app->params['languages'] = ArrayHelper::map($languages, 'code', 'code'); Yii::$app->language = $this->getCurrentLang(); return $resolve; }
[ "public", "function", "resolve", "(", ")", "{", "$", "resolve", "=", "parent", "::", "resolve", "(", ")", ";", "$", "languages", "=", "Language", "::", "getDb", "(", ")", "->", "cache", "(", "function", "(", "$", "db", ")", "{", "return", "Language", "::", "find", "(", ")", "->", "where", "(", "[", "'is_active'", "=>", "true", "]", ")", "->", "asArray", "(", ")", "->", "all", "(", ")", ";", "}", ")", ";", "Yii", "::", "$", "app", "->", "params", "[", "'languages'", "]", "=", "ArrayHelper", "::", "map", "(", "$", "languages", ",", "'code'", ",", "'code'", ")", ";", "Yii", "::", "$", "app", "->", "language", "=", "$", "this", "->", "getCurrentLang", "(", ")", ";", "return", "$", "resolve", ";", "}" ]
Resolve Resolves the current request into a route and the associated parameters. Sets default application language @return array the first element is the route, and the second is the associated parameters. @throws \yii\web\NotFoundHttpException if the request cannot be resolved.
[ "Resolve", "Resolves", "the", "current", "request", "into", "a", "route", "and", "the", "associated", "parameters", ".", "Sets", "default", "application", "language" ]
611e7b5fcc36ef79a0400cdede2bf54d17eccfce
https://github.com/jarrus90/yii2-multilang/blob/611e7b5fcc36ef79a0400cdede2bf54d17eccfce/Components/MultilangRequest.php#L32-L40
6,296
jarrus90/yii2-multilang
Components/MultilangRequest.php
MultilangRequest.getCurrentLang
protected function getCurrentLang(){ if(!Yii::$app->user->isGuest && !empty(Yii::$app->user->identity->lang)) { $lang = Yii::$app->user->identity->lang; } else if(Yii::$app->session->get('lang')) { $lang = Yii::$app->session->get('lang'); } else { $lang = Yii::$app->getRequest()->getPreferredLanguage(); } return $lang; }
php
protected function getCurrentLang(){ if(!Yii::$app->user->isGuest && !empty(Yii::$app->user->identity->lang)) { $lang = Yii::$app->user->identity->lang; } else if(Yii::$app->session->get('lang')) { $lang = Yii::$app->session->get('lang'); } else { $lang = Yii::$app->getRequest()->getPreferredLanguage(); } return $lang; }
[ "protected", "function", "getCurrentLang", "(", ")", "{", "if", "(", "!", "Yii", "::", "$", "app", "->", "user", "->", "isGuest", "&&", "!", "empty", "(", "Yii", "::", "$", "app", "->", "user", "->", "identity", "->", "lang", ")", ")", "{", "$", "lang", "=", "Yii", "::", "$", "app", "->", "user", "->", "identity", "->", "lang", ";", "}", "else", "if", "(", "Yii", "::", "$", "app", "->", "session", "->", "get", "(", "'lang'", ")", ")", "{", "$", "lang", "=", "Yii", "::", "$", "app", "->", "session", "->", "get", "(", "'lang'", ")", ";", "}", "else", "{", "$", "lang", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "getPreferredLanguage", "(", ")", ";", "}", "return", "$", "lang", ";", "}" ]
Get current language If user is logged in gets its language Otherwise from session Otherwise from request @return string
[ "Get", "current", "language", "If", "user", "is", "logged", "in", "gets", "its", "language", "Otherwise", "from", "session", "Otherwise", "from", "request" ]
611e7b5fcc36ef79a0400cdede2bf54d17eccfce
https://github.com/jarrus90/yii2-multilang/blob/611e7b5fcc36ef79a0400cdede2bf54d17eccfce/Components/MultilangRequest.php#L49-L59
6,297
teeebor/decoy-framework
Application.php
Application.toRoute
public function toRoute($route) { if ($this->caller != null) $this->disableRender[] = $this->caller->identifier; $r = $this->router->getRoute($route); if ($r != null) { $this->currentRoute = $r; try { $this->execute(); } catch (\Exception $e) { Logger::Log('log/error.txt', $e->getMessage()); \decoy\base\ErrorController::$errors[] = $e->getMessage(); $this->toRoute('error_page'); } } $this->caller = null; }
php
public function toRoute($route) { if ($this->caller != null) $this->disableRender[] = $this->caller->identifier; $r = $this->router->getRoute($route); if ($r != null) { $this->currentRoute = $r; try { $this->execute(); } catch (\Exception $e) { Logger::Log('log/error.txt', $e->getMessage()); \decoy\base\ErrorController::$errors[] = $e->getMessage(); $this->toRoute('error_page'); } } $this->caller = null; }
[ "public", "function", "toRoute", "(", "$", "route", ")", "{", "if", "(", "$", "this", "->", "caller", "!=", "null", ")", "$", "this", "->", "disableRender", "[", "]", "=", "$", "this", "->", "caller", "->", "identifier", ";", "$", "r", "=", "$", "this", "->", "router", "->", "getRoute", "(", "$", "route", ")", ";", "if", "(", "$", "r", "!=", "null", ")", "{", "$", "this", "->", "currentRoute", "=", "$", "r", ";", "try", "{", "$", "this", "->", "execute", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Logger", "::", "Log", "(", "'log/error.txt'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "\\", "decoy", "\\", "base", "\\", "ErrorController", "::", "$", "errors", "[", "]", "=", "$", "e", "->", "getMessage", "(", ")", ";", "$", "this", "->", "toRoute", "(", "'error_page'", ")", ";", "}", "}", "$", "this", "->", "caller", "=", "null", ";", "}" ]
Redirecting the execution route. This will not change the URL. All the not fully executed instance will finish. If you dont't want that, return after this method was called. @param string $route
[ "Redirecting", "the", "execution", "route", ".", "This", "will", "not", "change", "the", "URL", ".", "All", "the", "not", "fully", "executed", "instance", "will", "finish", ".", "If", "you", "dont", "t", "want", "that", "return", "after", "this", "method", "was", "called", "." ]
3881ae63a7d13088efda5afd3932c1af1fc18b23
https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/Application.php#L205-L221
6,298
teeebor/decoy-framework
Application.php
Application.execute
private function execute() { if ($this->currentRoute == null) { $this->router->getRoute('error_page')->setAction('_notFound'); $this->toRoute('error_page'); return; } $controllerName = $this->currentRoute->getController(); if ($controllerName == '') { if ($this->currentRoute->getParams() != null && array_key_exists('controller', $this->currentRoute->getParams())) $controllerName = $this->currentRoute->getParams()['controller']; elseif ($this->currentRoute->getDefault() != null) $controllerName = $this->currentRoute->getDefault()->getController(); else { throw new \Exception($this->translator->translate("The requested url has a bad route configuration!")); } } if (array_key_exists($controllerName, $this->invokable)) $controllerName = $this->invokable[$controllerName]; elseif (strpos($controllerName, 'decoy\base') === false) throw new \Exception('The requested Controller: \'' . $controllerName . '\' is not registered!'); $c = new $controllerName($this); if ($c->getResult() && !in_array($c->identifier, $this->disableRender) && $this->enableRender) { echo $this->response->output($c); } }
php
private function execute() { if ($this->currentRoute == null) { $this->router->getRoute('error_page')->setAction('_notFound'); $this->toRoute('error_page'); return; } $controllerName = $this->currentRoute->getController(); if ($controllerName == '') { if ($this->currentRoute->getParams() != null && array_key_exists('controller', $this->currentRoute->getParams())) $controllerName = $this->currentRoute->getParams()['controller']; elseif ($this->currentRoute->getDefault() != null) $controllerName = $this->currentRoute->getDefault()->getController(); else { throw new \Exception($this->translator->translate("The requested url has a bad route configuration!")); } } if (array_key_exists($controllerName, $this->invokable)) $controllerName = $this->invokable[$controllerName]; elseif (strpos($controllerName, 'decoy\base') === false) throw new \Exception('The requested Controller: \'' . $controllerName . '\' is not registered!'); $c = new $controllerName($this); if ($c->getResult() && !in_array($c->identifier, $this->disableRender) && $this->enableRender) { echo $this->response->output($c); } }
[ "private", "function", "execute", "(", ")", "{", "if", "(", "$", "this", "->", "currentRoute", "==", "null", ")", "{", "$", "this", "->", "router", "->", "getRoute", "(", "'error_page'", ")", "->", "setAction", "(", "'_notFound'", ")", ";", "$", "this", "->", "toRoute", "(", "'error_page'", ")", ";", "return", ";", "}", "$", "controllerName", "=", "$", "this", "->", "currentRoute", "->", "getController", "(", ")", ";", "if", "(", "$", "controllerName", "==", "''", ")", "{", "if", "(", "$", "this", "->", "currentRoute", "->", "getParams", "(", ")", "!=", "null", "&&", "array_key_exists", "(", "'controller'", ",", "$", "this", "->", "currentRoute", "->", "getParams", "(", ")", ")", ")", "$", "controllerName", "=", "$", "this", "->", "currentRoute", "->", "getParams", "(", ")", "[", "'controller'", "]", ";", "elseif", "(", "$", "this", "->", "currentRoute", "->", "getDefault", "(", ")", "!=", "null", ")", "$", "controllerName", "=", "$", "this", "->", "currentRoute", "->", "getDefault", "(", ")", "->", "getController", "(", ")", ";", "else", "{", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "translator", "->", "translate", "(", "\"The requested url has a bad route configuration!\"", ")", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "$", "controllerName", ",", "$", "this", "->", "invokable", ")", ")", "$", "controllerName", "=", "$", "this", "->", "invokable", "[", "$", "controllerName", "]", ";", "elseif", "(", "strpos", "(", "$", "controllerName", ",", "'decoy\\base'", ")", "===", "false", ")", "throw", "new", "\\", "Exception", "(", "'The requested Controller: \\''", ".", "$", "controllerName", ".", "'\\' is not registered!'", ")", ";", "$", "c", "=", "new", "$", "controllerName", "(", "$", "this", ")", ";", "if", "(", "$", "c", "->", "getResult", "(", ")", "&&", "!", "in_array", "(", "$", "c", "->", "identifier", ",", "$", "this", "->", "disableRender", ")", "&&", "$", "this", "->", "enableRender", ")", "{", "echo", "$", "this", "->", "response", "->", "output", "(", "$", "c", ")", ";", "}", "}" ]
Executing the current route
[ "Executing", "the", "current", "route" ]
3881ae63a7d13088efda5afd3932c1af1fc18b23
https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/Application.php#L244-L270
6,299
teeebor/decoy-framework
Application.php
Application.parseRequestBody
private function parseRequestBody() { $content_type = $this->getRequestHeader()->getContentType(); if (strpos($content_type, 'application/json') !== false) { $this->requestBody = new JsonBody(); } elseif (strpos($content_type, 'application/x-www-form-urlencoded') !== false) { $this->requestBody = new FormBody(); } elseif (strpos($content_type, 'text/plain') !== false) { $this->requestBody = new PlainBody(); } elseif (strpos($content_type, 'multipart/form-data') !== false) { $this->requestBody = new MultipartBody(); } else { $this->requestBody = new HttpBody(); } }
php
private function parseRequestBody() { $content_type = $this->getRequestHeader()->getContentType(); if (strpos($content_type, 'application/json') !== false) { $this->requestBody = new JsonBody(); } elseif (strpos($content_type, 'application/x-www-form-urlencoded') !== false) { $this->requestBody = new FormBody(); } elseif (strpos($content_type, 'text/plain') !== false) { $this->requestBody = new PlainBody(); } elseif (strpos($content_type, 'multipart/form-data') !== false) { $this->requestBody = new MultipartBody(); } else { $this->requestBody = new HttpBody(); } }
[ "private", "function", "parseRequestBody", "(", ")", "{", "$", "content_type", "=", "$", "this", "->", "getRequestHeader", "(", ")", "->", "getContentType", "(", ")", ";", "if", "(", "strpos", "(", "$", "content_type", ",", "'application/json'", ")", "!==", "false", ")", "{", "$", "this", "->", "requestBody", "=", "new", "JsonBody", "(", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "content_type", ",", "'application/x-www-form-urlencoded'", ")", "!==", "false", ")", "{", "$", "this", "->", "requestBody", "=", "new", "FormBody", "(", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "content_type", ",", "'text/plain'", ")", "!==", "false", ")", "{", "$", "this", "->", "requestBody", "=", "new", "PlainBody", "(", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "content_type", ",", "'multipart/form-data'", ")", "!==", "false", ")", "{", "$", "this", "->", "requestBody", "=", "new", "MultipartBody", "(", ")", ";", "}", "else", "{", "$", "this", "->", "requestBody", "=", "new", "HttpBody", "(", ")", ";", "}", "}" ]
Setting up the request body parser
[ "Setting", "up", "the", "request", "body", "parser" ]
3881ae63a7d13088efda5afd3932c1af1fc18b23
https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/Application.php#L302-L316