repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
Sectorr/Core
Sectorr/Core/Http/Route.php
Route.findRoute
public static function findRoute($route, $properties = []) { // Check if properties for dynamic routing are given. if (! empty($properties)) { // Loop through all the created routes foreach (self::$routes as $r) { // Check if the given route name is equal to the route in the current loop. if ($r['props']['as'] == $route) { // Divide the url in different parts by exploding on a '/'. $parts = explode('/', $r['url']); $url = ""; // Creates empty string to put in the dynamic url. $count = 1; // Create a counter to check if reached the last piece of the url. foreach ($parts as $part) { // Check if the current piece is a dynamic piece. if (substr($part, 0, 1) == '{' && substr($part, -1, 1) == '}') { $prop = str_replace('}', '', str_replace('{', '', $part)); // Get the needed property and add it to the url $url .= (count($parts) == $count ? $properties[$prop] : $properties[$prop]."/"); } else { $url .= (count($parts) == $count ? $part : $part."/"); } $count++; } return ($url == '/' ? $url : "/{$url}"); } } } foreach (self::$routes as $r) { if ($r['props']['as'] == $route) { return ($r['url'] == '/' ? $r['url'] : "/{$r['url']}"); } } throw new RouteNotFoundException($route); }
php
public static function findRoute($route, $properties = []) { // Check if properties for dynamic routing are given. if (! empty($properties)) { // Loop through all the created routes foreach (self::$routes as $r) { // Check if the given route name is equal to the route in the current loop. if ($r['props']['as'] == $route) { // Divide the url in different parts by exploding on a '/'. $parts = explode('/', $r['url']); $url = ""; // Creates empty string to put in the dynamic url. $count = 1; // Create a counter to check if reached the last piece of the url. foreach ($parts as $part) { // Check if the current piece is a dynamic piece. if (substr($part, 0, 1) == '{' && substr($part, -1, 1) == '}') { $prop = str_replace('}', '', str_replace('{', '', $part)); // Get the needed property and add it to the url $url .= (count($parts) == $count ? $properties[$prop] : $properties[$prop]."/"); } else { $url .= (count($parts) == $count ? $part : $part."/"); } $count++; } return ($url == '/' ? $url : "/{$url}"); } } } foreach (self::$routes as $r) { if ($r['props']['as'] == $route) { return ($r['url'] == '/' ? $r['url'] : "/{$r['url']}"); } } throw new RouteNotFoundException($route); }
[ "public", "static", "function", "findRoute", "(", "$", "route", ",", "$", "properties", "=", "[", "]", ")", "{", "// Check if properties for dynamic routing are given.", "if", "(", "!", "empty", "(", "$", "properties", ")", ")", "{", "// Loop through all the created routes", "foreach", "(", "self", "::", "$", "routes", "as", "$", "r", ")", "{", "// Check if the given route name is equal to the route in the current loop.", "if", "(", "$", "r", "[", "'props'", "]", "[", "'as'", "]", "==", "$", "route", ")", "{", "// Divide the url in different parts by exploding on a '/'.", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "r", "[", "'url'", "]", ")", ";", "$", "url", "=", "\"\"", ";", "// Creates empty string to put in the dynamic url.", "$", "count", "=", "1", ";", "// Create a counter to check if reached the last piece of the url.", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "// Check if the current piece is a dynamic piece.", "if", "(", "substr", "(", "$", "part", ",", "0", ",", "1", ")", "==", "'{'", "&&", "substr", "(", "$", "part", ",", "-", "1", ",", "1", ")", "==", "'}'", ")", "{", "$", "prop", "=", "str_replace", "(", "'}'", ",", "''", ",", "str_replace", "(", "'{'", ",", "''", ",", "$", "part", ")", ")", ";", "// Get the needed property and add it to the url", "$", "url", ".=", "(", "count", "(", "$", "parts", ")", "==", "$", "count", "?", "$", "properties", "[", "$", "prop", "]", ":", "$", "properties", "[", "$", "prop", "]", ".", "\"/\"", ")", ";", "}", "else", "{", "$", "url", ".=", "(", "count", "(", "$", "parts", ")", "==", "$", "count", "?", "$", "part", ":", "$", "part", ".", "\"/\"", ")", ";", "}", "$", "count", "++", ";", "}", "return", "(", "$", "url", "==", "'/'", "?", "$", "url", ":", "\"/{$url}\"", ")", ";", "}", "}", "}", "foreach", "(", "self", "::", "$", "routes", "as", "$", "r", ")", "{", "if", "(", "$", "r", "[", "'props'", "]", "[", "'as'", "]", "==", "$", "route", ")", "{", "return", "(", "$", "r", "[", "'url'", "]", "==", "'/'", "?", "$", "r", "[", "'url'", "]", ":", "\"/{$r['url']}\"", ")", ";", "}", "}", "throw", "new", "RouteNotFoundException", "(", "$", "route", ")", ";", "}" ]
Finds a route by the given route name. Also takes properties to put into the route url. @param $route @param array $properties @return string
[ "Finds", "a", "route", "by", "the", "given", "route", "name", ".", "Also", "takes", "properties", "to", "put", "into", "the", "route", "url", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Http/Route.php#L56-L95
train
Sectorr/Core
Sectorr/Core/Http/Route.php
Route.callController
private static function callController($route, $properties = []) { $props = $route['props']; $uses = $props['uses']; // Check if any middleware has been set. if (! empty($props['middleware'])) { if (! ctype_upper(substr($props['middleware'], 0, 1))) { $middleware = substr_replace($props['middleware'], strtoupper(substr($props['middleware'], 0, 1)), 0); $middleware .= substr($props['middleware'], 1, strlen($props['middleware'])); } else { $middleware = $props['middleware']; } if (! file_exists(PATH . '/app/Middleware/' . $middleware . '.php')) { throw new MiddlewareNotFoundException($middleware); } $class = self::$middlewareNamespace . $middleware; $allowal = $class::allow($route, $properties); if ($allowal !== true) { return $allowal; } } $controller = explode('@', $uses)[0]; $method = explode('@', $uses)[1]; if (file_exists(PATH . '/app/Controllers/' . $controller . '.php')) { // Calling controller method. $controller = self::$namespace . $controller; $cont = new $controller; return $cont->$method($properties); } throw new ControllerNotFoundException($controller); }
php
private static function callController($route, $properties = []) { $props = $route['props']; $uses = $props['uses']; // Check if any middleware has been set. if (! empty($props['middleware'])) { if (! ctype_upper(substr($props['middleware'], 0, 1))) { $middleware = substr_replace($props['middleware'], strtoupper(substr($props['middleware'], 0, 1)), 0); $middleware .= substr($props['middleware'], 1, strlen($props['middleware'])); } else { $middleware = $props['middleware']; } if (! file_exists(PATH . '/app/Middleware/' . $middleware . '.php')) { throw new MiddlewareNotFoundException($middleware); } $class = self::$middlewareNamespace . $middleware; $allowal = $class::allow($route, $properties); if ($allowal !== true) { return $allowal; } } $controller = explode('@', $uses)[0]; $method = explode('@', $uses)[1]; if (file_exists(PATH . '/app/Controllers/' . $controller . '.php')) { // Calling controller method. $controller = self::$namespace . $controller; $cont = new $controller; return $cont->$method($properties); } throw new ControllerNotFoundException($controller); }
[ "private", "static", "function", "callController", "(", "$", "route", ",", "$", "properties", "=", "[", "]", ")", "{", "$", "props", "=", "$", "route", "[", "'props'", "]", ";", "$", "uses", "=", "$", "props", "[", "'uses'", "]", ";", "// Check if any middleware has been set.", "if", "(", "!", "empty", "(", "$", "props", "[", "'middleware'", "]", ")", ")", "{", "if", "(", "!", "ctype_upper", "(", "substr", "(", "$", "props", "[", "'middleware'", "]", ",", "0", ",", "1", ")", ")", ")", "{", "$", "middleware", "=", "substr_replace", "(", "$", "props", "[", "'middleware'", "]", ",", "strtoupper", "(", "substr", "(", "$", "props", "[", "'middleware'", "]", ",", "0", ",", "1", ")", ")", ",", "0", ")", ";", "$", "middleware", ".=", "substr", "(", "$", "props", "[", "'middleware'", "]", ",", "1", ",", "strlen", "(", "$", "props", "[", "'middleware'", "]", ")", ")", ";", "}", "else", "{", "$", "middleware", "=", "$", "props", "[", "'middleware'", "]", ";", "}", "if", "(", "!", "file_exists", "(", "PATH", ".", "'/app/Middleware/'", ".", "$", "middleware", ".", "'.php'", ")", ")", "{", "throw", "new", "MiddlewareNotFoundException", "(", "$", "middleware", ")", ";", "}", "$", "class", "=", "self", "::", "$", "middlewareNamespace", ".", "$", "middleware", ";", "$", "allowal", "=", "$", "class", "::", "allow", "(", "$", "route", ",", "$", "properties", ")", ";", "if", "(", "$", "allowal", "!==", "true", ")", "{", "return", "$", "allowal", ";", "}", "}", "$", "controller", "=", "explode", "(", "'@'", ",", "$", "uses", ")", "[", "0", "]", ";", "$", "method", "=", "explode", "(", "'@'", ",", "$", "uses", ")", "[", "1", "]", ";", "if", "(", "file_exists", "(", "PATH", ".", "'/app/Controllers/'", ".", "$", "controller", ".", "'.php'", ")", ")", "{", "// Calling controller method.", "$", "controller", "=", "self", "::", "$", "namespace", ".", "$", "controller", ";", "$", "cont", "=", "new", "$", "controller", ";", "return", "$", "cont", "->", "$", "method", "(", "$", "properties", ")", ";", "}", "throw", "new", "ControllerNotFoundException", "(", "$", "controller", ")", ";", "}" ]
Call controller by route. @param $route @param array $properties @return @throws ControllerNotFoundException @throws MiddlewareNotFoundException
[ "Call", "controller", "by", "route", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Http/Route.php#L118-L155
train
Sectorr/Core
Sectorr/Core/Http/Route.php
Route.execute
public static function execute($currentRoute) { $currentRouteParts = explode('/', $currentRoute); foreach (self::$routes as $route) { // Check if route matches complete URL. if ($route['url'] == $currentRoute) { return self::callController($route); } // Exploding route parts for dynamic checking. $routeParts = explode('/', $route['url']); // If route parts does not match current URL parts, continue. if (count($currentRouteParts) !== count($routeParts)) { continue; } $parts = count($routeParts) - 1; $valid = true; $properties = []; foreach ($routeParts as $key => $routePart) { $dynamicRoute = false; // Current route is not valid, continuing. if (! $valid) { continue; } // Current route part is dynamic, add to array. if (substr($routePart, 0, 1) == '{' && substr($routePart, -1, 1) == '}') { $properties[substr($routePart, 1, -1)] = $currentRouteParts[$key]; $dynamicRoute = true; } // If is not dynamic part, and does not match current URL part, make route invalid and continue. if (! $dynamicRoute && $routePart != $currentRouteParts[$key]) { $valid = false; continue; } // Check passed, call controller for current route. if ($key == $parts && $valid == true) { return self::callController($route, $properties); } } } // No valid route for current route, throw exception. throw new RouteNotFoundException($currentRoute); }
php
public static function execute($currentRoute) { $currentRouteParts = explode('/', $currentRoute); foreach (self::$routes as $route) { // Check if route matches complete URL. if ($route['url'] == $currentRoute) { return self::callController($route); } // Exploding route parts for dynamic checking. $routeParts = explode('/', $route['url']); // If route parts does not match current URL parts, continue. if (count($currentRouteParts) !== count($routeParts)) { continue; } $parts = count($routeParts) - 1; $valid = true; $properties = []; foreach ($routeParts as $key => $routePart) { $dynamicRoute = false; // Current route is not valid, continuing. if (! $valid) { continue; } // Current route part is dynamic, add to array. if (substr($routePart, 0, 1) == '{' && substr($routePart, -1, 1) == '}') { $properties[substr($routePart, 1, -1)] = $currentRouteParts[$key]; $dynamicRoute = true; } // If is not dynamic part, and does not match current URL part, make route invalid and continue. if (! $dynamicRoute && $routePart != $currentRouteParts[$key]) { $valid = false; continue; } // Check passed, call controller for current route. if ($key == $parts && $valid == true) { return self::callController($route, $properties); } } } // No valid route for current route, throw exception. throw new RouteNotFoundException($currentRoute); }
[ "public", "static", "function", "execute", "(", "$", "currentRoute", ")", "{", "$", "currentRouteParts", "=", "explode", "(", "'/'", ",", "$", "currentRoute", ")", ";", "foreach", "(", "self", "::", "$", "routes", "as", "$", "route", ")", "{", "// Check if route matches complete URL.", "if", "(", "$", "route", "[", "'url'", "]", "==", "$", "currentRoute", ")", "{", "return", "self", "::", "callController", "(", "$", "route", ")", ";", "}", "// Exploding route parts for dynamic checking.", "$", "routeParts", "=", "explode", "(", "'/'", ",", "$", "route", "[", "'url'", "]", ")", ";", "// If route parts does not match current URL parts, continue.", "if", "(", "count", "(", "$", "currentRouteParts", ")", "!==", "count", "(", "$", "routeParts", ")", ")", "{", "continue", ";", "}", "$", "parts", "=", "count", "(", "$", "routeParts", ")", "-", "1", ";", "$", "valid", "=", "true", ";", "$", "properties", "=", "[", "]", ";", "foreach", "(", "$", "routeParts", "as", "$", "key", "=>", "$", "routePart", ")", "{", "$", "dynamicRoute", "=", "false", ";", "// Current route is not valid, continuing.", "if", "(", "!", "$", "valid", ")", "{", "continue", ";", "}", "// Current route part is dynamic, add to array.", "if", "(", "substr", "(", "$", "routePart", ",", "0", ",", "1", ")", "==", "'{'", "&&", "substr", "(", "$", "routePart", ",", "-", "1", ",", "1", ")", "==", "'}'", ")", "{", "$", "properties", "[", "substr", "(", "$", "routePart", ",", "1", ",", "-", "1", ")", "]", "=", "$", "currentRouteParts", "[", "$", "key", "]", ";", "$", "dynamicRoute", "=", "true", ";", "}", "// If is not dynamic part, and does not match current URL part, make route invalid and continue.", "if", "(", "!", "$", "dynamicRoute", "&&", "$", "routePart", "!=", "$", "currentRouteParts", "[", "$", "key", "]", ")", "{", "$", "valid", "=", "false", ";", "continue", ";", "}", "// Check passed, call controller for current route.", "if", "(", "$", "key", "==", "$", "parts", "&&", "$", "valid", "==", "true", ")", "{", "return", "self", "::", "callController", "(", "$", "route", ",", "$", "properties", ")", ";", "}", "}", "}", "// No valid route for current route, throw exception.", "throw", "new", "RouteNotFoundException", "(", "$", "currentRoute", ")", ";", "}" ]
Execute routing. @param $currentRoute @throws RouteNotFoundException @return
[ "Execute", "routing", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Http/Route.php#L164-L216
train
flipbox/transformer
src/filters/TransformFilter.php
TransformFilter.transformDataProvider
protected function transformDataProvider(DataProviderInterface $dataProvider) { if (Craft::$app->getRequest()->getIsHead()) { return null; } else { if (!$transformer = $this->dataTransformer()) { return $dataProvider; } // The transformed data $models = Factory::collection( $this->resolveTransformer($transformer), $dataProvider->getModels(), $this->getTransformConfig() ); if ($this->collectionEnvelope === null) { return $models; } else { return [ $this->collectionEnvelope => $models, ]; } } }
php
protected function transformDataProvider(DataProviderInterface $dataProvider) { if (Craft::$app->getRequest()->getIsHead()) { return null; } else { if (!$transformer = $this->dataTransformer()) { return $dataProvider; } // The transformed data $models = Factory::collection( $this->resolveTransformer($transformer), $dataProvider->getModels(), $this->getTransformConfig() ); if ($this->collectionEnvelope === null) { return $models; } else { return [ $this->collectionEnvelope => $models, ]; } } }
[ "protected", "function", "transformDataProvider", "(", "DataProviderInterface", "$", "dataProvider", ")", "{", "if", "(", "Craft", "::", "$", "app", "->", "getRequest", "(", ")", "->", "getIsHead", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "if", "(", "!", "$", "transformer", "=", "$", "this", "->", "dataTransformer", "(", ")", ")", "{", "return", "$", "dataProvider", ";", "}", "// The transformed data", "$", "models", "=", "Factory", "::", "collection", "(", "$", "this", "->", "resolveTransformer", "(", "$", "transformer", ")", ",", "$", "dataProvider", "->", "getModels", "(", ")", ",", "$", "this", "->", "getTransformConfig", "(", ")", ")", ";", "if", "(", "$", "this", "->", "collectionEnvelope", "===", "null", ")", "{", "return", "$", "models", ";", "}", "else", "{", "return", "[", "$", "this", "->", "collectionEnvelope", "=>", "$", "models", ",", "]", ";", "}", "}", "}" ]
Serializes a data provider. @param DataProviderInterface $dataProvider @return array|DataProviderInterface the array representation of the data provider.
[ "Serializes", "a", "data", "provider", "." ]
1ca989b545f5e94520504a6890e2237610571726
https://github.com/flipbox/transformer/blob/1ca989b545f5e94520504a6890e2237610571726/src/filters/TransformFilter.php#L137-L161
train
WellCommerce/CategoryBundle
Manager/CategoryManager.php
CategoryManager.sortCategories
public function sortCategories(array $items) { $repository = $this->getRepository(); $em = $this->getDoctrineHelper()->getEntityManager(); foreach ($items as $item) { $parent = $repository->find($item['parent']); $child = $repository->find($item['id']); if (null !== $child) { $child->setParent($parent); $child->setHierarchy($item['weight']); $em->persist($child); } } $em->flush(); }
php
public function sortCategories(array $items) { $repository = $this->getRepository(); $em = $this->getDoctrineHelper()->getEntityManager(); foreach ($items as $item) { $parent = $repository->find($item['parent']); $child = $repository->find($item['id']); if (null !== $child) { $child->setParent($parent); $child->setHierarchy($item['weight']); $em->persist($child); } } $em->flush(); }
[ "public", "function", "sortCategories", "(", "array", "$", "items", ")", "{", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "em", "=", "$", "this", "->", "getDoctrineHelper", "(", ")", "->", "getEntityManager", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "parent", "=", "$", "repository", "->", "find", "(", "$", "item", "[", "'parent'", "]", ")", ";", "$", "child", "=", "$", "repository", "->", "find", "(", "$", "item", "[", "'id'", "]", ")", ";", "if", "(", "null", "!==", "$", "child", ")", "{", "$", "child", "->", "setParent", "(", "$", "parent", ")", ";", "$", "child", "->", "setHierarchy", "(", "$", "item", "[", "'weight'", "]", ")", ";", "$", "em", "->", "persist", "(", "$", "child", ")", ";", "}", "}", "$", "em", "->", "flush", "(", ")", ";", "}" ]
Sorts categories passed in request @param array $items
[ "Sorts", "categories", "passed", "in", "request" ]
7a23ac678f91d15e86bdff624c4799be7b076e1a
https://github.com/WellCommerce/CategoryBundle/blob/7a23ac678f91d15e86bdff624c4799be7b076e1a/Manager/CategoryManager.php#L33-L49
train
WellCommerce/CategoryBundle
Manager/CategoryManager.php
CategoryManager.translateCategory
protected function translateCategory(Locale $locale, CategoryInterface $category, $name) { /** * @var $translation \WellCommerce\Bundle\CategoryBundle\Entity\CategoryTranslation */ $translation = $category->translate($locale->getCode()); $slug = $this->getLocaleSlug($locale, $name); $translation->setName($name); $translation->setSlug($slug); $category->mergeNewTranslations(); }
php
protected function translateCategory(Locale $locale, CategoryInterface $category, $name) { /** * @var $translation \WellCommerce\Bundle\CategoryBundle\Entity\CategoryTranslation */ $translation = $category->translate($locale->getCode()); $slug = $this->getLocaleSlug($locale, $name); $translation->setName($name); $translation->setSlug($slug); $category->mergeNewTranslations(); }
[ "protected", "function", "translateCategory", "(", "Locale", "$", "locale", ",", "CategoryInterface", "$", "category", ",", "$", "name", ")", "{", "/**\n * @var $translation \\WellCommerce\\Bundle\\CategoryBundle\\Entity\\CategoryTranslation\n */", "$", "translation", "=", "$", "category", "->", "translate", "(", "$", "locale", "->", "getCode", "(", ")", ")", ";", "$", "slug", "=", "$", "this", "->", "getLocaleSlug", "(", "$", "locale", ",", "$", "name", ")", ";", "$", "translation", "->", "setName", "(", "$", "name", ")", ";", "$", "translation", "->", "setSlug", "(", "$", "slug", ")", ";", "$", "category", "->", "mergeNewTranslations", "(", ")", ";", "}" ]
Translates the category @param Locale $locale @param CategoryInterface $category @param string $name
[ "Translates", "the", "category" ]
7a23ac678f91d15e86bdff624c4799be7b076e1a
https://github.com/WellCommerce/CategoryBundle/blob/7a23ac678f91d15e86bdff624c4799be7b076e1a/Manager/CategoryManager.php#L87-L97
train
WellCommerce/CategoryBundle
Manager/CategoryManager.php
CategoryManager.getLocaleSlug
protected function getLocaleSlug(Locale $locale, $categoryName) { $slug = Sluggable::makeSlug($categoryName); $currentLocale = $this->getRequestHelper()->getCurrentLocale(); if ($locale->getCode() != $currentLocale) { $slug = Sluggable::makeSlug(sprintf('%s-%s', $categoryName, $locale->getCode())); } return $slug; }
php
protected function getLocaleSlug(Locale $locale, $categoryName) { $slug = Sluggable::makeSlug($categoryName); $currentLocale = $this->getRequestHelper()->getCurrentLocale(); if ($locale->getCode() != $currentLocale) { $slug = Sluggable::makeSlug(sprintf('%s-%s', $categoryName, $locale->getCode())); } return $slug; }
[ "protected", "function", "getLocaleSlug", "(", "Locale", "$", "locale", ",", "$", "categoryName", ")", "{", "$", "slug", "=", "Sluggable", "::", "makeSlug", "(", "$", "categoryName", ")", ";", "$", "currentLocale", "=", "$", "this", "->", "getRequestHelper", "(", ")", "->", "getCurrentLocale", "(", ")", ";", "if", "(", "$", "locale", "->", "getCode", "(", ")", "!=", "$", "currentLocale", ")", "{", "$", "slug", "=", "Sluggable", "::", "makeSlug", "(", "sprintf", "(", "'%s-%s'", ",", "$", "categoryName", ",", "$", "locale", "->", "getCode", "(", ")", ")", ")", ";", "}", "return", "$", "slug", ";", "}" ]
Returns category slug @param Locale $locale @param string $categoryName @return mixed|string
[ "Returns", "category", "slug" ]
7a23ac678f91d15e86bdff624c4799be7b076e1a
https://github.com/WellCommerce/CategoryBundle/blob/7a23ac678f91d15e86bdff624c4799be7b076e1a/Manager/CategoryManager.php#L107-L116
train
Blipfoto/php-sdk
src/Blipfoto/Api/Response.php
Response.data
public function data($key = null) { $data = $this->body['data']; if ($key !== null) { foreach (explode('.', $key) as $part) { if (isset($data[$part])) { $data = $data[$part]; } else { $data = null; break; } } } return $data; }
php
public function data($key = null) { $data = $this->body['data']; if ($key !== null) { foreach (explode('.', $key) as $part) { if (isset($data[$part])) { $data = $data[$part]; } else { $data = null; break; } } } return $data; }
[ "public", "function", "data", "(", "$", "key", "=", "null", ")", "{", "$", "data", "=", "$", "this", "->", "body", "[", "'data'", "]", ";", "if", "(", "$", "key", "!==", "null", ")", "{", "foreach", "(", "explode", "(", "'.'", ",", "$", "key", ")", "as", "$", "part", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "part", "]", ")", ")", "{", "$", "data", "=", "$", "data", "[", "$", "part", "]", ";", "}", "else", "{", "$", "data", "=", "null", ";", "break", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
Return the response's data, a key from the data, or null if the data or key does not exist. @param string $key (optional) @return mixed
[ "Return", "the", "response", "s", "data", "a", "key", "from", "the", "data", "or", "null", "if", "the", "data", "or", "key", "does", "not", "exist", "." ]
04f770ac7427e79d15f97b993c787651079cdeb4
https://github.com/Blipfoto/php-sdk/blob/04f770ac7427e79d15f97b993c787651079cdeb4/src/Blipfoto/Api/Response.php#L76-L89
train
Blipfoto/php-sdk
src/Blipfoto/Api/Response.php
Response.rateLimit
public function rateLimit($key = null) { return $key ? (isset($this->rate_limit[$key]) ? $this->rate_limit[$key] : null) : $this->rate_limit; }
php
public function rateLimit($key = null) { return $key ? (isset($this->rate_limit[$key]) ? $this->rate_limit[$key] : null) : $this->rate_limit; }
[ "public", "function", "rateLimit", "(", "$", "key", "=", "null", ")", "{", "return", "$", "key", "?", "(", "isset", "(", "$", "this", "->", "rate_limit", "[", "$", "key", "]", ")", "?", "$", "this", "->", "rate_limit", "[", "$", "key", "]", ":", "null", ")", ":", "$", "this", "->", "rate_limit", ";", "}" ]
Return the response's rate limit info array, a key from the array, or null if the info or key does not exist. @param string $key (optional) @return mixed
[ "Return", "the", "response", "s", "rate", "limit", "info", "array", "a", "key", "from", "the", "array", "or", "null", "if", "the", "info", "or", "key", "does", "not", "exist", "." ]
04f770ac7427e79d15f97b993c787651079cdeb4
https://github.com/Blipfoto/php-sdk/blob/04f770ac7427e79d15f97b993c787651079cdeb4/src/Blipfoto/Api/Response.php#L97-L99
train
CalderaWP/caldera-interop
src/Traits/Rest/ProvidesHttpHeaders.php
ProvidesHttpHeaders.getHeader
public function getHeader(string $headerName) { return $this->hasHeader($headerName) ? $this->headers[ $headerName ] : null; }
php
public function getHeader(string $headerName) { return $this->hasHeader($headerName) ? $this->headers[ $headerName ] : null; }
[ "public", "function", "getHeader", "(", "string", "$", "headerName", ")", "{", "return", "$", "this", "->", "hasHeader", "(", "$", "headerName", ")", "?", "$", "this", "->", "headers", "[", "$", "headerName", "]", ":", "null", ";", "}" ]
Get header from request @param string $headerName @return string|null
[ "Get", "header", "from", "request" ]
d25c4bc930200b314fbd42d084080b5d85261c94
https://github.com/CalderaWP/caldera-interop/blob/d25c4bc930200b314fbd42d084080b5d85261c94/src/Traits/Rest/ProvidesHttpHeaders.php#L25-L28
train
CalderaWP/caldera-interop
src/Traits/Rest/ProvidesHttpHeaders.php
ProvidesHttpHeaders.setHeader
public function setHeader(string $headerName, $headerValue): HttpRequestContract { $this->headers[ $headerName ] = $headerValue; return $this; }
php
public function setHeader(string $headerName, $headerValue): HttpRequestContract { $this->headers[ $headerName ] = $headerValue; return $this; }
[ "public", "function", "setHeader", "(", "string", "$", "headerName", ",", "$", "headerValue", ")", ":", "HttpRequestContract", "{", "$", "this", "->", "headers", "[", "$", "headerName", "]", "=", "$", "headerValue", ";", "return", "$", "this", ";", "}" ]
Set header in request @param string $headerName @param mixed $headerValue @return HttpRequestContract
[ "Set", "header", "in", "request" ]
d25c4bc930200b314fbd42d084080b5d85261c94
https://github.com/CalderaWP/caldera-interop/blob/d25c4bc930200b314fbd42d084080b5d85261c94/src/Traits/Rest/ProvidesHttpHeaders.php#L53-L57
train
nails/module-blog
blog/controllers/_blog.php
NAILS_Blog_Controller.loadSkinAssets
protected function loadSkinAssets($aAssets, $aCssInline, $aJsInline, $sUrl) { $oAsset = Factory::service('Asset'); // CSS and JS if (!empty($aAssets) && is_array($aAssets)) { foreach ($aAssets as $asset) { if (is_string($asset)) { $oAsset->load($asset); } else { $oAsset->load($asset[0], $asset[1]); } } } // -------------------------------------------------------------------------- // CSS - Inline if (!empty($aCssInline) && is_array($aCssInline)) { foreach ($aCssInline as $asset) { $oAsset->inline($asset, 'CSS-INLINE'); } } // -------------------------------------------------------------------------- // JS - Inline if (!empty($aJsInline) && is_array($aJsInline)) { foreach ($aJsInline as $asset) { $oAsset->inline($asset, 'JS-INLINE'); } } }
php
protected function loadSkinAssets($aAssets, $aCssInline, $aJsInline, $sUrl) { $oAsset = Factory::service('Asset'); // CSS and JS if (!empty($aAssets) && is_array($aAssets)) { foreach ($aAssets as $asset) { if (is_string($asset)) { $oAsset->load($asset); } else { $oAsset->load($asset[0], $asset[1]); } } } // -------------------------------------------------------------------------- // CSS - Inline if (!empty($aCssInline) && is_array($aCssInline)) { foreach ($aCssInline as $asset) { $oAsset->inline($asset, 'CSS-INLINE'); } } // -------------------------------------------------------------------------- // JS - Inline if (!empty($aJsInline) && is_array($aJsInline)) { foreach ($aJsInline as $asset) { $oAsset->inline($asset, 'JS-INLINE'); } } }
[ "protected", "function", "loadSkinAssets", "(", "$", "aAssets", ",", "$", "aCssInline", ",", "$", "aJsInline", ",", "$", "sUrl", ")", "{", "$", "oAsset", "=", "Factory", "::", "service", "(", "'Asset'", ")", ";", "// CSS and JS", "if", "(", "!", "empty", "(", "$", "aAssets", ")", "&&", "is_array", "(", "$", "aAssets", ")", ")", "{", "foreach", "(", "$", "aAssets", "as", "$", "asset", ")", "{", "if", "(", "is_string", "(", "$", "asset", ")", ")", "{", "$", "oAsset", "->", "load", "(", "$", "asset", ")", ";", "}", "else", "{", "$", "oAsset", "->", "load", "(", "$", "asset", "[", "0", "]", ",", "$", "asset", "[", "1", "]", ")", ";", "}", "}", "}", "// --------------------------------------------------------------------------", "// CSS - Inline", "if", "(", "!", "empty", "(", "$", "aCssInline", ")", "&&", "is_array", "(", "$", "aCssInline", ")", ")", "{", "foreach", "(", "$", "aCssInline", "as", "$", "asset", ")", "{", "$", "oAsset", "->", "inline", "(", "$", "asset", ",", "'CSS-INLINE'", ")", ";", "}", "}", "// --------------------------------------------------------------------------", "// JS - Inline", "if", "(", "!", "empty", "(", "$", "aJsInline", ")", "&&", "is_array", "(", "$", "aJsInline", ")", ")", "{", "foreach", "(", "$", "aJsInline", "as", "$", "asset", ")", "{", "$", "oAsset", "->", "inline", "(", "$", "asset", ",", "'JS-INLINE'", ")", ";", "}", "}", "}" ]
Loads any assets required by the skin @param array $aAssets An array of skin assets @param array $aCssInline An array of inline CSS @param array $aJsInline An array of inline JS @param string $sUrl The URL to the skin's root directory @return void
[ "Loads", "any", "assets", "required", "by", "the", "skin" ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/controllers/_blog.php#L165-L199
train
swokit/utils
src/AsyncTimer.php
AsyncTimer.tick
public static function tick(float $ms, callable $callback, $params = null) { $tid = Timer::tick($ms, $callback, $params); // save meta info self::$timers[$tid] = [ 'type' => 'tick', 'ctime' => \time(), // add time. 'interval' => $ms, ]; return $tid; }
php
public static function tick(float $ms, callable $callback, $params = null) { $tid = Timer::tick($ms, $callback, $params); // save meta info self::$timers[$tid] = [ 'type' => 'tick', 'ctime' => \time(), // add time. 'interval' => $ms, ]; return $tid; }
[ "public", "static", "function", "tick", "(", "float", "$", "ms", ",", "callable", "$", "callback", ",", "$", "params", "=", "null", ")", "{", "$", "tid", "=", "Timer", "::", "tick", "(", "$", "ms", ",", "$", "callback", ",", "$", "params", ")", ";", "// save meta info", "self", "::", "$", "timers", "[", "$", "tid", "]", "=", "[", "'type'", "=>", "'tick'", ",", "'ctime'", "=>", "\\", "time", "(", ")", ",", "// add time.", "'interval'", "=>", "$", "ms", ",", "]", ";", "return", "$", "tid", ";", "}" ]
add a interval timer @param float $ms @param callable $callback @param mixed $params @return mixed
[ "add", "a", "interval", "timer" ]
a91688ee6970e33be14047bf4714da3299796f56
https://github.com/swokit/utils/blob/a91688ee6970e33be14047bf4714da3299796f56/src/AsyncTimer.php#L31-L43
train
fridge-project/dbal
src/Fridge/DBAL/Type/Type.php
Type.getType
public static function getType($type) { if (!isset(static::$mappedTypeInstances[$type])) { if (!static::hasType($type)) { throw TypeException::typeDoesNotExist($type); } static::$mappedTypeInstances[$type] = new static::$mappedTypeClasses[$type](); } return static::$mappedTypeInstances[$type]; }
php
public static function getType($type) { if (!isset(static::$mappedTypeInstances[$type])) { if (!static::hasType($type)) { throw TypeException::typeDoesNotExist($type); } static::$mappedTypeInstances[$type] = new static::$mappedTypeClasses[$type](); } return static::$mappedTypeInstances[$type]; }
[ "public", "static", "function", "getType", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "mappedTypeInstances", "[", "$", "type", "]", ")", ")", "{", "if", "(", "!", "static", "::", "hasType", "(", "$", "type", ")", ")", "{", "throw", "TypeException", "::", "typeDoesNotExist", "(", "$", "type", ")", ";", "}", "static", "::", "$", "mappedTypeInstances", "[", "$", "type", "]", "=", "new", "static", "::", "$", "mappedTypeClasses", "[", "$", "type", "]", "(", ")", ";", "}", "return", "static", "::", "$", "mappedTypeInstances", "[", "$", "type", "]", ";", "}" ]
Gets a type. @param string $type The type name. @throws \Fridge\DBAL\Exception\TypeException If the type does not exist. @return \Fridge\DBAL\Type\TypeInterface The type.
[ "Gets", "a", "type", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Type/Type.php#L108-L119
train
fridge-project/dbal
src/Fridge/DBAL/Type/Type.php
Type.overrideType
public static function overrideType($type, $class) { if (!static::hasType($type)) { throw TypeException::typeDoesNotExist($type); } if (!class_exists($class)) { throw TypeException::classNotFound($class); } if (!in_array('Fridge\DBAL\Type\TypeInterface', class_implements($class))) { throw TypeException::typeMustImplementTypeInterface($class); } if (isset(static::$mappedTypeInstances[$type])) { unset(static::$mappedTypeInstances[$type]); } static::$mappedTypeClasses[$type] = $class; }
php
public static function overrideType($type, $class) { if (!static::hasType($type)) { throw TypeException::typeDoesNotExist($type); } if (!class_exists($class)) { throw TypeException::classNotFound($class); } if (!in_array('Fridge\DBAL\Type\TypeInterface', class_implements($class))) { throw TypeException::typeMustImplementTypeInterface($class); } if (isset(static::$mappedTypeInstances[$type])) { unset(static::$mappedTypeInstances[$type]); } static::$mappedTypeClasses[$type] = $class; }
[ "public", "static", "function", "overrideType", "(", "$", "type", ",", "$", "class", ")", "{", "if", "(", "!", "static", "::", "hasType", "(", "$", "type", ")", ")", "{", "throw", "TypeException", "::", "typeDoesNotExist", "(", "$", "type", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "TypeException", "::", "classNotFound", "(", "$", "class", ")", ";", "}", "if", "(", "!", "in_array", "(", "'Fridge\\DBAL\\Type\\TypeInterface'", ",", "class_implements", "(", "$", "class", ")", ")", ")", "{", "throw", "TypeException", "::", "typeMustImplementTypeInterface", "(", "$", "class", ")", ";", "}", "if", "(", "isset", "(", "static", "::", "$", "mappedTypeInstances", "[", "$", "type", "]", ")", ")", "{", "unset", "(", "static", "::", "$", "mappedTypeInstances", "[", "$", "type", "]", ")", ";", "}", "static", "::", "$", "mappedTypeClasses", "[", "$", "type", "]", "=", "$", "class", ";", "}" ]
Overrides an existing type. @param string $type The type name. @param string $class The type class. @throws \Fridge\DBAL\Exception\TypeException If the type does not exist, if the class can not be found or if the class does not implement the TypeInterface.
[ "Overrides", "an", "existing", "type", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Type/Type.php#L156-L175
train
danielgp/common-lib
source/MySQLiByDanielGPnumbers.php
MySQLiByDanielGPnumbers.getFieldOutputEnumSetReadOnly
protected function getFieldOutputEnumSetReadOnly($val, $adnlThings) { $inputFeatures = [ 'name' => $val['COLUMN_NAME'] . $adnlThings['suffix'], 'id' => $val['COLUMN_NAME'], 'readonly' => 'readonly', 'class' => 'input_readonly', 'size' => 50, 'value' => $this->getFieldValue($val), ]; return $this->setStringIntoShortTag('input', $inputFeatures); }
php
protected function getFieldOutputEnumSetReadOnly($val, $adnlThings) { $inputFeatures = [ 'name' => $val['COLUMN_NAME'] . $adnlThings['suffix'], 'id' => $val['COLUMN_NAME'], 'readonly' => 'readonly', 'class' => 'input_readonly', 'size' => 50, 'value' => $this->getFieldValue($val), ]; return $this->setStringIntoShortTag('input', $inputFeatures); }
[ "protected", "function", "getFieldOutputEnumSetReadOnly", "(", "$", "val", ",", "$", "adnlThings", ")", "{", "$", "inputFeatures", "=", "[", "'name'", "=>", "$", "val", "[", "'COLUMN_NAME'", "]", ".", "$", "adnlThings", "[", "'suffix'", "]", ",", "'id'", "=>", "$", "val", "[", "'COLUMN_NAME'", "]", ",", "'readonly'", "=>", "'readonly'", ",", "'class'", "=>", "'input_readonly'", ",", "'size'", "=>", "50", ",", "'value'", "=>", "$", "this", "->", "getFieldValue", "(", "$", "val", ")", ",", "]", ";", "return", "$", "this", "->", "setStringIntoShortTag", "(", "'input'", ",", "$", "inputFeatures", ")", ";", "}" ]
Creates an input for ENUM or SET if marked Read-Only @param array $val @param array $adnlThings @return string
[ "Creates", "an", "input", "for", "ENUM", "or", "SET", "if", "marked", "Read", "-", "Only" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPnumbers.php#L48-L59
train
danielgp/common-lib
source/MySQLiByDanielGPnumbers.php
MySQLiByDanielGPnumbers.getFieldOutputTT
protected function getFieldOutputTT($value, $szN, $iar = []) { $inAdtnl = [ 'id' => $value['COLUMN_NAME'], 'maxlength' => $szN, 'name' => $value['COLUMN_NAME'], 'size' => $szN, 'type' => 'text', 'value' => $this->getFieldValue($value), ]; if ($iar !== []) { $inAdtnl = array_merge($inAdtnl, $iar); } return $this->setStringIntoShortTag('input', $inAdtnl); }
php
protected function getFieldOutputTT($value, $szN, $iar = []) { $inAdtnl = [ 'id' => $value['COLUMN_NAME'], 'maxlength' => $szN, 'name' => $value['COLUMN_NAME'], 'size' => $szN, 'type' => 'text', 'value' => $this->getFieldValue($value), ]; if ($iar !== []) { $inAdtnl = array_merge($inAdtnl, $iar); } return $this->setStringIntoShortTag('input', $inAdtnl); }
[ "protected", "function", "getFieldOutputTT", "(", "$", "value", ",", "$", "szN", ",", "$", "iar", "=", "[", "]", ")", "{", "$", "inAdtnl", "=", "[", "'id'", "=>", "$", "value", "[", "'COLUMN_NAME'", "]", ",", "'maxlength'", "=>", "$", "szN", ",", "'name'", "=>", "$", "value", "[", "'COLUMN_NAME'", "]", ",", "'size'", "=>", "$", "szN", ",", "'type'", "=>", "'text'", ",", "'value'", "=>", "$", "this", "->", "getFieldValue", "(", "$", "value", ")", ",", "]", ";", "if", "(", "$", "iar", "!==", "[", "]", ")", "{", "$", "inAdtnl", "=", "array_merge", "(", "$", "inAdtnl", ",", "$", "iar", ")", ";", "}", "return", "$", "this", "->", "setStringIntoShortTag", "(", "'input'", ",", "$", "inAdtnl", ")", ";", "}" ]
Builds output as text input type @param array $value @param integer $szN @param array $iar @return string
[ "Builds", "output", "as", "text", "input", "type" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPnumbers.php#L69-L83
train
danielgp/common-lib
source/MySQLiByDanielGPnumbers.php
MySQLiByDanielGPnumbers.getFieldValue
protected function getFieldValue($details) { $this->initializeSprGlbAndSession(); $rqCN = $this->tCmnRequest->request->get($details['COLUMN_NAME']); if (!is_null($rqCN)) { if (($details['IS_NULLABLE'] == 'YES') && ($rqCN == '')) { return 'NULL'; } return $rqCN; } return $this->getFieldValueWithoutUserInput($details); }
php
protected function getFieldValue($details) { $this->initializeSprGlbAndSession(); $rqCN = $this->tCmnRequest->request->get($details['COLUMN_NAME']); if (!is_null($rqCN)) { if (($details['IS_NULLABLE'] == 'YES') && ($rqCN == '')) { return 'NULL'; } return $rqCN; } return $this->getFieldValueWithoutUserInput($details); }
[ "protected", "function", "getFieldValue", "(", "$", "details", ")", "{", "$", "this", "->", "initializeSprGlbAndSession", "(", ")", ";", "$", "rqCN", "=", "$", "this", "->", "tCmnRequest", "->", "request", "->", "get", "(", "$", "details", "[", "'COLUMN_NAME'", "]", ")", ";", "if", "(", "!", "is_null", "(", "$", "rqCN", ")", ")", "{", "if", "(", "(", "$", "details", "[", "'IS_NULLABLE'", "]", "==", "'YES'", ")", "&&", "(", "$", "rqCN", "==", "''", ")", ")", "{", "return", "'NULL'", ";", "}", "return", "$", "rqCN", ";", "}", "return", "$", "this", "->", "getFieldValueWithoutUserInput", "(", "$", "details", ")", ";", "}" ]
Returns given value for a field from REQUEST global variable @param array $details @return string
[ "Returns", "given", "value", "for", "a", "field", "from", "REQUEST", "global", "variable" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPnumbers.php#L91-L102
train
danielgp/common-lib
source/MySQLiByDanielGPnumbers.php
MySQLiByDanielGPnumbers.setFieldLabel
protected function setFieldLabel($details, $features, $fieldLabel) { $aLabel = ['for' => $details['COLUMN_NAME'], 'id' => $details['COLUMN_NAME'] . '_label']; if (isset($features['disabled'])) { if (in_array($details['COLUMN_NAME'], $features['disabled'])) { $aLabel = array_merge($aLabel, ['style' => 'color: grey;']); } } return $this->setStringIntoTag($fieldLabel, 'label', $aLabel); }
php
protected function setFieldLabel($details, $features, $fieldLabel) { $aLabel = ['for' => $details['COLUMN_NAME'], 'id' => $details['COLUMN_NAME'] . '_label']; if (isset($features['disabled'])) { if (in_array($details['COLUMN_NAME'], $features['disabled'])) { $aLabel = array_merge($aLabel, ['style' => 'color: grey;']); } } return $this->setStringIntoTag($fieldLabel, 'label', $aLabel); }
[ "protected", "function", "setFieldLabel", "(", "$", "details", ",", "$", "features", ",", "$", "fieldLabel", ")", "{", "$", "aLabel", "=", "[", "'for'", "=>", "$", "details", "[", "'COLUMN_NAME'", "]", ",", "'id'", "=>", "$", "details", "[", "'COLUMN_NAME'", "]", ".", "'_label'", "]", ";", "if", "(", "isset", "(", "$", "features", "[", "'disabled'", "]", ")", ")", "{", "if", "(", "in_array", "(", "$", "details", "[", "'COLUMN_NAME'", "]", ",", "$", "features", "[", "'disabled'", "]", ")", ")", "{", "$", "aLabel", "=", "array_merge", "(", "$", "aLabel", ",", "[", "'style'", "=>", "'color: grey;'", "]", ")", ";", "}", "}", "return", "$", "this", "->", "setStringIntoTag", "(", "$", "fieldLabel", ",", "'label'", ",", "$", "aLabel", ")", ";", "}" ]
Prepares the label for inputs @param array $details @param array $features @param string $fieldLabel @return string
[ "Prepares", "the", "label", "for", "inputs" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPnumbers.php#L129-L138
train
danielgp/common-lib
source/MySQLiByDanielGPnumbers.php
MySQLiByDanielGPnumbers.setFieldNumbers
protected function setFieldNumbers($fieldDetails, $outputFormated = false) { $sRtrn = $this->setFieldSpecific($fieldDetails); if ($outputFormated) { foreach ($sRtrn as $key => $value) { $sRtrn[$key] = $this->setNumberFormat($value); } } return $sRtrn; }
php
protected function setFieldNumbers($fieldDetails, $outputFormated = false) { $sRtrn = $this->setFieldSpecific($fieldDetails); if ($outputFormated) { foreach ($sRtrn as $key => $value) { $sRtrn[$key] = $this->setNumberFormat($value); } } return $sRtrn; }
[ "protected", "function", "setFieldNumbers", "(", "$", "fieldDetails", ",", "$", "outputFormated", "=", "false", ")", "{", "$", "sRtrn", "=", "$", "this", "->", "setFieldSpecific", "(", "$", "fieldDetails", ")", ";", "if", "(", "$", "outputFormated", ")", "{", "foreach", "(", "$", "sRtrn", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "sRtrn", "[", "$", "key", "]", "=", "$", "this", "->", "setNumberFormat", "(", "$", "value", ")", ";", "}", "}", "return", "$", "sRtrn", ";", "}" ]
Returns maximum length for a given MySQL field @param array $fieldDetails @param boolean $outputFormated @return array
[ "Returns", "maximum", "length", "for", "a", "given", "MySQL", "field" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPnumbers.php#L147-L156
train
danielgp/common-lib
source/MySQLiByDanielGPnumbers.php
MySQLiByDanielGPnumbers.setFieldSpecific
private function setFieldSpecific($fieldDetails) { if (in_array($fieldDetails['DATA_TYPE'], ['char', 'varchar', 'tinytext', 'text', 'mediumtext', 'longtext'])) { return ['M' => $fieldDetails['CHARACTER_MAXIMUM_LENGTH']]; } elseif (in_array($fieldDetails['DATA_TYPE'], ['decimal', 'numeric'])) { return ['M' => $fieldDetails['NUMERIC_PRECISION'], 'd' => $fieldDetails['NUMERIC_SCALE']]; } elseif (in_array($fieldDetails['DATA_TYPE'], ['bigint', 'int', 'mediumint', 'smallint', 'tinyint'])) { return $this->setFldLmtsExact($fieldDetails['DATA_TYPE'], $fieldDetails['COLUMN_TYPE']); } return $this->setFieldSpecificElse($fieldDetails); }
php
private function setFieldSpecific($fieldDetails) { if (in_array($fieldDetails['DATA_TYPE'], ['char', 'varchar', 'tinytext', 'text', 'mediumtext', 'longtext'])) { return ['M' => $fieldDetails['CHARACTER_MAXIMUM_LENGTH']]; } elseif (in_array($fieldDetails['DATA_TYPE'], ['decimal', 'numeric'])) { return ['M' => $fieldDetails['NUMERIC_PRECISION'], 'd' => $fieldDetails['NUMERIC_SCALE']]; } elseif (in_array($fieldDetails['DATA_TYPE'], ['bigint', 'int', 'mediumint', 'smallint', 'tinyint'])) { return $this->setFldLmtsExact($fieldDetails['DATA_TYPE'], $fieldDetails['COLUMN_TYPE']); } return $this->setFieldSpecificElse($fieldDetails); }
[ "private", "function", "setFieldSpecific", "(", "$", "fieldDetails", ")", "{", "if", "(", "in_array", "(", "$", "fieldDetails", "[", "'DATA_TYPE'", "]", ",", "[", "'char'", ",", "'varchar'", ",", "'tinytext'", ",", "'text'", ",", "'mediumtext'", ",", "'longtext'", "]", ")", ")", "{", "return", "[", "'M'", "=>", "$", "fieldDetails", "[", "'CHARACTER_MAXIMUM_LENGTH'", "]", "]", ";", "}", "elseif", "(", "in_array", "(", "$", "fieldDetails", "[", "'DATA_TYPE'", "]", ",", "[", "'decimal'", ",", "'numeric'", "]", ")", ")", "{", "return", "[", "'M'", "=>", "$", "fieldDetails", "[", "'NUMERIC_PRECISION'", "]", ",", "'d'", "=>", "$", "fieldDetails", "[", "'NUMERIC_SCALE'", "]", "]", ";", "}", "elseif", "(", "in_array", "(", "$", "fieldDetails", "[", "'DATA_TYPE'", "]", ",", "[", "'bigint'", ",", "'int'", ",", "'mediumint'", ",", "'smallint'", ",", "'tinyint'", "]", ")", ")", "{", "return", "$", "this", "->", "setFldLmtsExact", "(", "$", "fieldDetails", "[", "'DATA_TYPE'", "]", ",", "$", "fieldDetails", "[", "'COLUMN_TYPE'", "]", ")", ";", "}", "return", "$", "this", "->", "setFieldSpecificElse", "(", "$", "fieldDetails", ")", ";", "}" ]
Establishes numbers of fields @param array $fieldDetails @return array
[ "Establishes", "numbers", "of", "fields" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPnumbers.php#L164-L174
train
danielgp/common-lib
source/MySQLiByDanielGPnumbers.php
MySQLiByDanielGPnumbers.setFormButtons
protected function setFormButtons($feat, $hiddenInfo = []) { $btn = []; $btn[] = '<input type="submit" id="submit" style="margin-left:220px;" value="' . $this->lclMsgCmn('i18n_Form_ButtonSave') . '" />'; if (isset($feat['insertAndUpdate'])) { $btn[] = '<input type="hidden" id="insertAndUpdate" name="insertAndUpdate" value="insertAndUpdate" />'; } if ($hiddenInfo != []) { foreach ($hiddenInfo as $key => $value) { $btn[] = '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />'; } } return '<div>' . implode('', $btn) . '</div>'; }
php
protected function setFormButtons($feat, $hiddenInfo = []) { $btn = []; $btn[] = '<input type="submit" id="submit" style="margin-left:220px;" value="' . $this->lclMsgCmn('i18n_Form_ButtonSave') . '" />'; if (isset($feat['insertAndUpdate'])) { $btn[] = '<input type="hidden" id="insertAndUpdate" name="insertAndUpdate" value="insertAndUpdate" />'; } if ($hiddenInfo != []) { foreach ($hiddenInfo as $key => $value) { $btn[] = '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />'; } } return '<div>' . implode('', $btn) . '</div>'; }
[ "protected", "function", "setFormButtons", "(", "$", "feat", ",", "$", "hiddenInfo", "=", "[", "]", ")", "{", "$", "btn", "=", "[", "]", ";", "$", "btn", "[", "]", "=", "'<input type=\"submit\" id=\"submit\" style=\"margin-left:220px;\" value=\"'", ".", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Form_ButtonSave'", ")", ".", "'\" />'", ";", "if", "(", "isset", "(", "$", "feat", "[", "'insertAndUpdate'", "]", ")", ")", "{", "$", "btn", "[", "]", "=", "'<input type=\"hidden\" id=\"insertAndUpdate\" name=\"insertAndUpdate\" value=\"insertAndUpdate\" />'", ";", "}", "if", "(", "$", "hiddenInfo", "!=", "[", "]", ")", "{", "foreach", "(", "$", "hiddenInfo", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "btn", "[", "]", "=", "'<input type=\"hidden\" id=\"'", ".", "$", "key", ".", "'\" name=\"'", ".", "$", "key", ".", "'\" value=\"'", ".", "$", "value", ".", "'\" />'", ";", "}", "}", "return", "'<div>'", ".", "implode", "(", "''", ",", "$", "btn", ")", ".", "'</div>'", ";", "}" ]
Form default buttons @param array $feat @param array $hiddenInfo @return string
[ "Form", "default", "buttons" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPnumbers.php#L216-L230
train
rawphp/RawMail
src/RawPHP/RawMail/Mail.php
Mail.init
public function init( $config = NULL ) { $this->mailer = new PHPMailer(); foreach ( $config as $key => $value ) { switch ( $key ) { case 'from_email': $this->mailer->From = $value; break; case 'from_name': $this->mailer->FromName = $value; break; case 'is_html': $this->mailer->isHTML( ( bool ) $value ); break; case 'smtp': if ( !empty( $value ) ) { // mark it as SMTP mail $this->mailer->isSMTP(); $this->mailer->Host = $value[ 'host' ]; $this->mailer->SMTPAuth = $value[ 'auth' ]; $this->mailer->Username = $value[ 'username' ]; $this->mailer->Password = $value[ 'password' ]; $this->mailer->SMTPSecure = $value[ 'security' ]; $this->mailer->Port = $value[ 'port' ]; } break; case 'reply_to': if ( !empty( $value ) ) { $this->mailer->addReplyTo( $value[ 'email' ], $value[ 'name' ] ); } break; default: // do nothing break; } } }
php
public function init( $config = NULL ) { $this->mailer = new PHPMailer(); foreach ( $config as $key => $value ) { switch ( $key ) { case 'from_email': $this->mailer->From = $value; break; case 'from_name': $this->mailer->FromName = $value; break; case 'is_html': $this->mailer->isHTML( ( bool ) $value ); break; case 'smtp': if ( !empty( $value ) ) { // mark it as SMTP mail $this->mailer->isSMTP(); $this->mailer->Host = $value[ 'host' ]; $this->mailer->SMTPAuth = $value[ 'auth' ]; $this->mailer->Username = $value[ 'username' ]; $this->mailer->Password = $value[ 'password' ]; $this->mailer->SMTPSecure = $value[ 'security' ]; $this->mailer->Port = $value[ 'port' ]; } break; case 'reply_to': if ( !empty( $value ) ) { $this->mailer->addReplyTo( $value[ 'email' ], $value[ 'name' ] ); } break; default: // do nothing break; } } }
[ "public", "function", "init", "(", "$", "config", "=", "NULL", ")", "{", "$", "this", "->", "mailer", "=", "new", "PHPMailer", "(", ")", ";", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'from_email'", ":", "$", "this", "->", "mailer", "->", "From", "=", "$", "value", ";", "break", ";", "case", "'from_name'", ":", "$", "this", "->", "mailer", "->", "FromName", "=", "$", "value", ";", "break", ";", "case", "'is_html'", ":", "$", "this", "->", "mailer", "->", "isHTML", "(", "(", "bool", ")", "$", "value", ")", ";", "break", ";", "case", "'smtp'", ":", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "// mark it as SMTP mail", "$", "this", "->", "mailer", "->", "isSMTP", "(", ")", ";", "$", "this", "->", "mailer", "->", "Host", "=", "$", "value", "[", "'host'", "]", ";", "$", "this", "->", "mailer", "->", "SMTPAuth", "=", "$", "value", "[", "'auth'", "]", ";", "$", "this", "->", "mailer", "->", "Username", "=", "$", "value", "[", "'username'", "]", ";", "$", "this", "->", "mailer", "->", "Password", "=", "$", "value", "[", "'password'", "]", ";", "$", "this", "->", "mailer", "->", "SMTPSecure", "=", "$", "value", "[", "'security'", "]", ";", "$", "this", "->", "mailer", "->", "Port", "=", "$", "value", "[", "'port'", "]", ";", "}", "break", ";", "case", "'reply_to'", ":", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "this", "->", "mailer", "->", "addReplyTo", "(", "$", "value", "[", "'email'", "]", ",", "$", "value", "[", "'name'", "]", ")", ";", "}", "break", ";", "default", ":", "// do nothing", "break", ";", "}", "}", "}" ]
Initialises the mailer. @param array $config configuration array @action ON_INIT_ACTION
[ "Initialises", "the", "mailer", "." ]
b84e7cc76b7e5db87ea8aabd77417f72162f47ab
https://github.com/rawphp/RawMail/blob/b84e7cc76b7e5db87ea8aabd77417f72162f47ab/src/RawPHP/RawMail/Mail.php#L87-L134
train
rawphp/RawMail
src/RawPHP/RawMail/Mail.php
Mail.addCC
public function addCC( $email ) { if ( is_array( $email ) ) { $this->mailer->addCC( $email[ 'email' ], $email[ 'name' ] ); } else { $this->mailer->addCC( $email ); } }
php
public function addCC( $email ) { if ( is_array( $email ) ) { $this->mailer->addCC( $email[ 'email' ], $email[ 'name' ] ); } else { $this->mailer->addCC( $email ); } }
[ "public", "function", "addCC", "(", "$", "email", ")", "{", "if", "(", "is_array", "(", "$", "email", ")", ")", "{", "$", "this", "->", "mailer", "->", "addCC", "(", "$", "email", "[", "'email'", "]", ",", "$", "email", "[", "'name'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "mailer", "->", "addCC", "(", "$", "email", ")", ";", "}", "}" ]
Adds a CC address to the email. @param mixed $email email string or email|name array array( 'name' => 'Information', 'email' => '[email protected]' ); @action ON_ADD_CC_ACTION
[ "Adds", "a", "CC", "address", "to", "the", "email", "." ]
b84e7cc76b7e5db87ea8aabd77417f72162f47ab
https://github.com/rawphp/RawMail/blob/b84e7cc76b7e5db87ea8aabd77417f72162f47ab/src/RawPHP/RawMail/Mail.php#L216-L226
train
rawphp/RawMail
src/RawPHP/RawMail/Mail.php
Mail.addBCC
public function addBCC( $email ) { if ( is_array( $email ) ) { $this->mailer->addBCC( $email[ 'email' ], $email[ 'name' ] ); } else { $this->mailer->addBCC( $email ); } }
php
public function addBCC( $email ) { if ( is_array( $email ) ) { $this->mailer->addBCC( $email[ 'email' ], $email[ 'name' ] ); } else { $this->mailer->addBCC( $email ); } }
[ "public", "function", "addBCC", "(", "$", "email", ")", "{", "if", "(", "is_array", "(", "$", "email", ")", ")", "{", "$", "this", "->", "mailer", "->", "addBCC", "(", "$", "email", "[", "'email'", "]", ",", "$", "email", "[", "'name'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "mailer", "->", "addBCC", "(", "$", "email", ")", ";", "}", "}" ]
Adds a BCC address to the email. @param mixed $email email string or email|name array array( 'name' => 'Information', 'email' => '[email protected]' ); @action ON_ADD_BCC_ACTION
[ "Adds", "a", "BCC", "address", "to", "the", "email", "." ]
b84e7cc76b7e5db87ea8aabd77417f72162f47ab
https://github.com/rawphp/RawMail/blob/b84e7cc76b7e5db87ea8aabd77417f72162f47ab/src/RawPHP/RawMail/Mail.php#L236-L246
train
lightwerk/SurfCaptain
Classes/Lightwerk/SurfCaptain/Domain/Model/Deployment.php
Deployment.getReferenceName
public function getReferenceName() { $options = $this->getOptions(); if (!empty($options['tag'])) { return 'Tag: ' . $options['tag']; } elseif (!empty($options['branch'])) { return 'Branch: ' . $options['branch']; } elseif (!empty($options['sha1'])) { return 'Sha1: ' . $options['sha1']; } return ''; }
php
public function getReferenceName() { $options = $this->getOptions(); if (!empty($options['tag'])) { return 'Tag: ' . $options['tag']; } elseif (!empty($options['branch'])) { return 'Branch: ' . $options['branch']; } elseif (!empty($options['sha1'])) { return 'Sha1: ' . $options['sha1']; } return ''; }
[ "public", "function", "getReferenceName", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'tag'", "]", ")", ")", "{", "return", "'Tag: '", ".", "$", "options", "[", "'tag'", "]", ";", "}", "elseif", "(", "!", "empty", "(", "$", "options", "[", "'branch'", "]", ")", ")", "{", "return", "'Branch: '", ".", "$", "options", "[", "'branch'", "]", ";", "}", "elseif", "(", "!", "empty", "(", "$", "options", "[", "'sha1'", "]", ")", ")", "{", "return", "'Sha1: '", ".", "$", "options", "[", "'sha1'", "]", ";", "}", "return", "''", ";", "}" ]
Since sha1 is always shipped with branch and tag configuration, we consider it for referenceName only if neither tag nor branch was set. @return string
[ "Since", "sha1", "is", "always", "shipped", "with", "branch", "and", "tag", "configuration", "we", "consider", "it", "for", "referenceName", "only", "if", "neither", "tag", "nor", "branch", "was", "set", "." ]
2865e963fd634504d8923902cf422873749a0940
https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Model/Deployment.php#L211-L222
train
ReindeerWeb/ClassHelper
src/ClassHelper.php
ClassHelper.singleton
public static function singleton($class = null) { if (!$class) { $class = get_called_class(); } if (!isset(self::$singletons[$class])) { self::$singletons[$class] = self::create($class); } return self::$singletons[$class]; }
php
public static function singleton($class = null) { if (!$class) { $class = get_called_class(); } if (!isset(self::$singletons[$class])) { self::$singletons[$class] = self::create($class); } return self::$singletons[$class]; }
[ "public", "static", "function", "singleton", "(", "$", "class", "=", "null", ")", "{", "if", "(", "!", "$", "class", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "singletons", "[", "$", "class", "]", ")", ")", "{", "self", "::", "$", "singletons", "[", "$", "class", "]", "=", "self", "::", "create", "(", "$", "class", ")", ";", "}", "return", "self", "::", "$", "singletons", "[", "$", "class", "]", ";", "}" ]
Creates a class instance by the "singleton" design pattern. It will always return the same instance for this class. @param string $class Optional classname to create, if the called class should not be used @return static The singleton instance
[ "Creates", "a", "class", "instance", "by", "the", "singleton", "design", "pattern", ".", "It", "will", "always", "return", "the", "same", "instance", "for", "this", "class", "." ]
5d53f884d5d4e790c659ac5c5a0c155076ac8c3a
https://github.com/ReindeerWeb/ClassHelper/blob/5d53f884d5d4e790c659ac5c5a0c155076ac8c3a/src/ClassHelper.php#L62-L73
train
climphp/Clim
Clim/App.php
App.handleException
protected function handleException(Exception $e) { // if ($e instanceof MethodNotAllowedException) { // $handler = 'notAllowedHandler'; // $params = [$e->getRequest(), $e->getResponse(), $e->getAllowedMethods()]; // } elseif ($e instanceof NotFoundException) { // $handler = 'notFoundHandler'; // $params = [$e->getRequest(), $e->getResponse(), $e]; // } elseif ($e instanceof SlimException) { // // This is a Stop exception and contains the response // return $e->getResponse(); // } else { // Other exception, use $request and $response params $handler = 'errorHandler'; $params = [$e]; // } if ($this->getContainer()->has($handler)) { $callable = $this->getContainer()->get($handler); // Call the registered handler return call_user_func_array($callable, $params); } // No handlers found, so just display simple error $this->displayError($e->getMessage()); exit($e->getCode() ?: 1); }
php
protected function handleException(Exception $e) { // if ($e instanceof MethodNotAllowedException) { // $handler = 'notAllowedHandler'; // $params = [$e->getRequest(), $e->getResponse(), $e->getAllowedMethods()]; // } elseif ($e instanceof NotFoundException) { // $handler = 'notFoundHandler'; // $params = [$e->getRequest(), $e->getResponse(), $e]; // } elseif ($e instanceof SlimException) { // // This is a Stop exception and contains the response // return $e->getResponse(); // } else { // Other exception, use $request and $response params $handler = 'errorHandler'; $params = [$e]; // } if ($this->getContainer()->has($handler)) { $callable = $this->getContainer()->get($handler); // Call the registered handler return call_user_func_array($callable, $params); } // No handlers found, so just display simple error $this->displayError($e->getMessage()); exit($e->getCode() ?: 1); }
[ "protected", "function", "handleException", "(", "Exception", "$", "e", ")", "{", "// if ($e instanceof MethodNotAllowedException) {", "// $handler = 'notAllowedHandler';", "// $params = [$e->getRequest(), $e->getResponse(), $e->getAllowedMethods()];", "// } elseif ($e instanceof NotFoundException) {", "// $handler = 'notFoundHandler';", "// $params = [$e->getRequest(), $e->getResponse(), $e];", "// } elseif ($e instanceof SlimException) {", "// // This is a Stop exception and contains the response", "// return $e->getResponse();", "// } else {", "// Other exception, use $request and $response params", "$", "handler", "=", "'errorHandler'", ";", "$", "params", "=", "[", "$", "e", "]", ";", "// }", "if", "(", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "$", "handler", ")", ")", "{", "$", "callable", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "$", "handler", ")", ";", "// Call the registered handler", "return", "call_user_func_array", "(", "$", "callable", ",", "$", "params", ")", ";", "}", "// No handlers found, so just display simple error", "$", "this", "->", "displayError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "exit", "(", "$", "e", "->", "getCode", "(", ")", "?", ":", "1", ")", ";", "}" ]
Call relevant handler from the Container if needed. If it doesn't exist, then just print error @param Exception $e @return Context
[ "Call", "relevant", "handler", "from", "the", "Container", "if", "needed", ".", "If", "it", "doesn", "t", "exist", "then", "just", "print", "error" ]
d2d09a82e1b7a0b8d454e585e6db421ff02ec8e4
https://github.com/climphp/Clim/blob/d2d09a82e1b7a0b8d454e585e6db421ff02ec8e4/Clim/App.php#L180-L206
train
Linkvalue-Interne/MajoraFrameworkExtraBundle
src/Majora/Framework/Loader/Bridge/Api/ApiLoaderTrait.php
ApiLoaderTrait.apiCall
private function apiCall( $method, array $query = array(), callable $onSuccess, $emptyValue = null ) { try { return $onSuccess( $this->restApiClient->$method($query) ); } catch (BadResponseException $e) { if (($response = $e->getResponse()) && $response->getStatusCode() == 404 ) { return $emptyValue; } throw $e; } }
php
private function apiCall( $method, array $query = array(), callable $onSuccess, $emptyValue = null ) { try { return $onSuccess( $this->restApiClient->$method($query) ); } catch (BadResponseException $e) { if (($response = $e->getResponse()) && $response->getStatusCode() == 404 ) { return $emptyValue; } throw $e; } }
[ "private", "function", "apiCall", "(", "$", "method", ",", "array", "$", "query", "=", "array", "(", ")", ",", "callable", "$", "onSuccess", ",", "$", "emptyValue", "=", "null", ")", "{", "try", "{", "return", "$", "onSuccess", "(", "$", "this", "->", "restApiClient", "->", "$", "method", "(", "$", "query", ")", ")", ";", "}", "catch", "(", "BadResponseException", "$", "e", ")", "{", "if", "(", "(", "$", "response", "=", "$", "e", "->", "getResponse", "(", ")", ")", "&&", "$", "response", "->", "getStatusCode", "(", ")", "==", "404", ")", "{", "return", "$", "emptyValue", ";", "}", "throw", "$", "e", ";", "}", "}" ]
Performs an Api call on given method. @param string $method @param array $query @param callable $onSuccess @param mixed $emptyValue
[ "Performs", "an", "Api", "call", "on", "given", "method", "." ]
6f368380cfc39d27fafb0844e9a53b4d86d7c034
https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Loader/Bridge/Api/ApiLoaderTrait.php#L68-L87
train
helsingborg-stad/better-post-UI
source/php/Components/PageAttributes.php
PageAttributes.hasKey
public function hasKey(string $needle, array $haystack) : bool { foreach ($haystack as $key => $value) { if ($key === $needle) { return true; } if (is_array($value)) { if ($x = $this->hasKey($needle, $value)) { return $x; } } } return false; }
php
public function hasKey(string $needle, array $haystack) : bool { foreach ($haystack as $key => $value) { if ($key === $needle) { return true; } if (is_array($value)) { if ($x = $this->hasKey($needle, $value)) { return $x; } } } return false; }
[ "public", "function", "hasKey", "(", "string", "$", "needle", ",", "array", "$", "haystack", ")", ":", "bool", "{", "foreach", "(", "$", "haystack", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "$", "needle", ")", "{", "return", "true", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "$", "x", "=", "$", "this", "->", "hasKey", "(", "$", "needle", ",", "$", "value", ")", ")", "{", "return", "$", "x", ";", "}", "}", "}", "return", "false", ";", "}" ]
Check if array has key recursivly @param string $needle Array key to find @param array $haystack Array to search @return boolean
[ "Check", "if", "array", "has", "key", "recursivly" ]
0454e8d6f42787244d02f0e976825ed8dca579f0
https://github.com/helsingborg-stad/better-post-UI/blob/0454e8d6f42787244d02f0e976825ed8dca579f0/source/php/Components/PageAttributes.php#L56-L71
train
PatrolServer/patrolsdk-php
lib/Bucket.php
Bucket.save
public function save() { $bucket = $this->_post('servers/' . $this->server_id . '/software_bucket/' . $this->key, $this->dirty_values); $this->mergeValues($bucket); }
php
public function save() { $bucket = $this->_post('servers/' . $this->server_id . '/software_bucket/' . $this->key, $this->dirty_values); $this->mergeValues($bucket); }
[ "public", "function", "save", "(", ")", "{", "$", "bucket", "=", "$", "this", "->", "_post", "(", "'servers/'", ".", "$", "this", "->", "server_id", ".", "'/software_bucket/'", ".", "$", "this", "->", "key", ",", "$", "this", "->", "dirty_values", ")", ";", "$", "this", "->", "mergeValues", "(", "$", "bucket", ")", ";", "}" ]
Saves a bucket, if the bucket does not exist, a new bucket will be created
[ "Saves", "a", "bucket", "if", "the", "bucket", "does", "not", "exist", "a", "new", "bucket", "will", "be", "created" ]
2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2
https://github.com/PatrolServer/patrolsdk-php/blob/2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2/lib/Bucket.php#L42-L45
train
stubbles/stubbles-webapp-session
src/main/php/id/NoneDurableSessionId.php
NoneDurableSessionId.name
public function name() { if (null === $this->sessionName) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $this->sessionName = ''; for ($i = 0; $i < 32; $i++) { $this->sessionName .= $characters[rand(0, strlen($characters) - 1)]; } } return $this->sessionName; }
php
public function name() { if (null === $this->sessionName) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $this->sessionName = ''; for ($i = 0; $i < 32; $i++) { $this->sessionName .= $characters[rand(0, strlen($characters) - 1)]; } } return $this->sessionName; }
[ "public", "function", "name", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "sessionName", ")", "{", "$", "characters", "=", "'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'", ";", "$", "this", "->", "sessionName", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "32", ";", "$", "i", "++", ")", "{", "$", "this", "->", "sessionName", ".=", "$", "characters", "[", "rand", "(", "0", ",", "strlen", "(", "$", "characters", ")", "-", "1", ")", "]", ";", "}", "}", "return", "$", "this", "->", "sessionName", ";", "}" ]
returns session name @return string
[ "returns", "session", "name" ]
2976fa28995bfb6ad00e3eac59ad689dd7892450
https://github.com/stubbles/stubbles-webapp-session/blob/2976fa28995bfb6ad00e3eac59ad689dd7892450/src/main/php/id/NoneDurableSessionId.php#L49-L60
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Map/C2PTableMap.php
C2PTableMap.doInsert
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(C2PTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from C2P object } // Set the correct dbName $query = C2PQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
php
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(C2PTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from C2P object } // Set the correct dbName $query = C2PQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
[ "public", "static", "function", "doInsert", "(", "$", "criteria", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getWriteConnection", "(", "C2PTableMap", "::", "DATABASE_NAME", ")", ";", "}", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "criteria", "=", "clone", "$", "criteria", ";", "// rename for clarity", "}", "else", "{", "$", "criteria", "=", "$", "criteria", "->", "buildCriteria", "(", ")", ";", "// build Criteria from C2P object", "}", "// Set the correct dbName", "$", "query", "=", "C2PQuery", "::", "create", "(", ")", "->", "mergeWith", "(", "$", "criteria", ")", ";", "// use transaction because $criteria could contain info", "// for more than one table (I guess, conceivably)", "return", "$", "con", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "con", ",", "$", "query", ")", "{", "return", "$", "query", "->", "doInsert", "(", "$", "con", ")", ";", "}", ")", ";", "}" ]
Performs an INSERT on the database, given a C2P or Criteria object. @param mixed $criteria Criteria or C2P object containing data that is used to create the INSERT statement. @param ConnectionInterface $con the ConnectionInterface connection to use @return mixed The new primary key. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "an", "INSERT", "on", "the", "database", "given", "a", "C2P", "or", "Criteria", "object", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Map/C2PTableMap.php#L464-L485
train
mullanaphy/variable
src/PHY/Variable.php
Variable.convertVariableTo
public static function convertVariableTo(\PHY\Variable\AVar $variable, $convertTo = 'Obj') { $method = 'to'.$convertTo; if (!is_callable([$variable, $method])) { throw new \PHY\Variable\Exception('Could not convert "'.$variable->getType().'" to "'.$convertTo.'"'); } $value = $variable->{$method}(); return static::create($convertTo, $value); }
php
public static function convertVariableTo(\PHY\Variable\AVar $variable, $convertTo = 'Obj') { $method = 'to'.$convertTo; if (!is_callable([$variable, $method])) { throw new \PHY\Variable\Exception('Could not convert "'.$variable->getType().'" to "'.$convertTo.'"'); } $value = $variable->{$method}(); return static::create($convertTo, $value); }
[ "public", "static", "function", "convertVariableTo", "(", "\\", "PHY", "\\", "Variable", "\\", "AVar", "$", "variable", ",", "$", "convertTo", "=", "'Obj'", ")", "{", "$", "method", "=", "'to'", ".", "$", "convertTo", ";", "if", "(", "!", "is_callable", "(", "[", "$", "variable", ",", "$", "method", "]", ")", ")", "{", "throw", "new", "\\", "PHY", "\\", "Variable", "\\", "Exception", "(", "'Could not convert \"'", ".", "$", "variable", "->", "getType", "(", ")", ".", "'\" to \"'", ".", "$", "convertTo", ".", "'\"'", ")", ";", "}", "$", "value", "=", "$", "variable", "->", "{", "$", "method", "}", "(", ")", ";", "return", "static", "::", "create", "(", "$", "convertTo", ",", "$", "value", ")", ";", "}" ]
Convert a variable to a different type. @param \PHY\Variable\AVar $variable @param string $convertTo @return \PHY\Variable\AVar
[ "Convert", "a", "variable", "to", "a", "different", "type", "." ]
e4eb274a1799a25e33e5e21cd260603c74628031
https://github.com/mullanaphy/variable/blob/e4eb274a1799a25e33e5e21cd260603c74628031/src/PHY/Variable.php#L50-L58
train
sourceboxio/sdk
src/Register/MicroService.php
MicroService.registerRoutes
protected function registerRoutes() { $http = Arr::get($this->triggers, 'http'); if (is_null($http)) { return; } // Validar try { Validator::validate($http, ['route' => 'required', 'methods' => 'required', 'function' => 'required']); } catch (ExceptionAttrs $e) { throw new \Exception($e->toMessageStr()); } // Validar função $function = $http['function']; if (! array_key_exists($function, $this->functions)) { throw new \Exception(sprintf('Function %s not found', $function)); } $class = $this->functions[$function]; $methods = explode(',', Arr::get($http, 'methods', 'get')); foreach ($methods as $method) { // Validar metodo if (! in_array($method, ['get', 'post', 'delete', 'put'])) { throw new \Exception(sprintf('Method %s invalid', $method)); } $args = []; $args['prefix'] = $this->getName(); $args['uses'] = sprintf('%s@execute', $class); $args['middleware'] = 'api'; call_user_func_array([router(), $method], [$http['route'], $args]); } }
php
protected function registerRoutes() { $http = Arr::get($this->triggers, 'http'); if (is_null($http)) { return; } // Validar try { Validator::validate($http, ['route' => 'required', 'methods' => 'required', 'function' => 'required']); } catch (ExceptionAttrs $e) { throw new \Exception($e->toMessageStr()); } // Validar função $function = $http['function']; if (! array_key_exists($function, $this->functions)) { throw new \Exception(sprintf('Function %s not found', $function)); } $class = $this->functions[$function]; $methods = explode(',', Arr::get($http, 'methods', 'get')); foreach ($methods as $method) { // Validar metodo if (! in_array($method, ['get', 'post', 'delete', 'put'])) { throw new \Exception(sprintf('Method %s invalid', $method)); } $args = []; $args['prefix'] = $this->getName(); $args['uses'] = sprintf('%s@execute', $class); $args['middleware'] = 'api'; call_user_func_array([router(), $method], [$http['route'], $args]); } }
[ "protected", "function", "registerRoutes", "(", ")", "{", "$", "http", "=", "Arr", "::", "get", "(", "$", "this", "->", "triggers", ",", "'http'", ")", ";", "if", "(", "is_null", "(", "$", "http", ")", ")", "{", "return", ";", "}", "// Validar", "try", "{", "Validator", "::", "validate", "(", "$", "http", ",", "[", "'route'", "=>", "'required'", ",", "'methods'", "=>", "'required'", ",", "'function'", "=>", "'required'", "]", ")", ";", "}", "catch", "(", "ExceptionAttrs", "$", "e", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "e", "->", "toMessageStr", "(", ")", ")", ";", "}", "// Validar função", "$", "function", "=", "$", "http", "[", "'function'", "]", ";", "if", "(", "!", "array_key_exists", "(", "$", "function", ",", "$", "this", "->", "functions", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Function %s not found'", ",", "$", "function", ")", ")", ";", "}", "$", "class", "=", "$", "this", "->", "functions", "[", "$", "function", "]", ";", "$", "methods", "=", "explode", "(", "','", ",", "Arr", "::", "get", "(", "$", "http", ",", "'methods'", ",", "'get'", ")", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "// Validar metodo", "if", "(", "!", "in_array", "(", "$", "method", ",", "[", "'get'", ",", "'post'", ",", "'delete'", ",", "'put'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Method %s invalid'", ",", "$", "method", ")", ")", ";", "}", "$", "args", "=", "[", "]", ";", "$", "args", "[", "'prefix'", "]", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "args", "[", "'uses'", "]", "=", "sprintf", "(", "'%s@execute'", ",", "$", "class", ")", ";", "$", "args", "[", "'middleware'", "]", "=", "'api'", ";", "call_user_func_array", "(", "[", "router", "(", ")", ",", "$", "method", "]", ",", "[", "$", "http", "[", "'route'", "]", ",", "$", "args", "]", ")", ";", "}", "}" ]
Registrar rotas.
[ "Registrar", "rotas", "." ]
e16e9e92580d48c2a348d119c2829a8d38528681
https://github.com/sourceboxio/sdk/blob/e16e9e92580d48c2a348d119c2829a8d38528681/src/Register/MicroService.php#L76-L111
train
Dhii/exception-helper-base
src/CreateRuntimeExceptionCapableTrait.php
CreateRuntimeExceptionCapableTrait._createRuntimeException
protected function _createRuntimeException($message = null, $code = null, $previous = null) { return new RuntimeException($message, $code, $previous); }
php
protected function _createRuntimeException($message = null, $code = null, $previous = null) { return new RuntimeException($message, $code, $previous); }
[ "protected", "function", "_createRuntimeException", "(", "$", "message", "=", "null", ",", "$", "code", "=", "null", ",", "$", "previous", "=", "null", ")", "{", "return", "new", "RuntimeException", "(", "$", "message", ",", "$", "code", ",", "$", "previous", ")", ";", "}" ]
Creates a new Runtime exception. @since [*next-version*] @param string|Stringable|int|float|bool|null $message The message, if any. @param int|float|string|Stringable|null $code The numeric error code, if any. @param RootException|null $previous The inner exception, if any. @return RuntimeException The new exception.
[ "Creates", "a", "new", "Runtime", "exception", "." ]
e97bfa6c0f79ea079e36b2f1d8f84d7566a3ccf5
https://github.com/Dhii/exception-helper-base/blob/e97bfa6c0f79ea079e36b2f1d8f84d7566a3ccf5/src/CreateRuntimeExceptionCapableTrait.php#L26-L29
train
jenskooij/cloudcontrol
src/storage/Repository.php
Repository.init
public function init($baseStorageDefaultPath, $baseStorageSqlPath) { $storageDefaultPath = realpath($baseStorageDefaultPath); $contentSqlPath = realpath($baseStorageSqlPath); $this->initConfigStorage($storageDefaultPath); $this->initContentDb($contentSqlPath); $this->save(); }
php
public function init($baseStorageDefaultPath, $baseStorageSqlPath) { $storageDefaultPath = realpath($baseStorageDefaultPath); $contentSqlPath = realpath($baseStorageSqlPath); $this->initConfigStorage($storageDefaultPath); $this->initContentDb($contentSqlPath); $this->save(); }
[ "public", "function", "init", "(", "$", "baseStorageDefaultPath", ",", "$", "baseStorageSqlPath", ")", "{", "$", "storageDefaultPath", "=", "realpath", "(", "$", "baseStorageDefaultPath", ")", ";", "$", "contentSqlPath", "=", "realpath", "(", "$", "baseStorageSqlPath", ")", ";", "$", "this", "->", "initConfigStorage", "(", "$", "storageDefaultPath", ")", ";", "$", "this", "->", "initContentDb", "(", "$", "contentSqlPath", ")", ";", "$", "this", "->", "save", "(", ")", ";", "}" ]
Initiates default storage @param $baseStorageDefaultPath @param $baseStorageSqlPath
[ "Initiates", "default", "storage" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/Repository.php#L107-L116
train
jenskooij/cloudcontrol
src/storage/Repository.php
Repository.save
public function save() { $host = $this; array_map(function ($value) use ($host) { $host->saveSubset($value); }, $this->fileBasedSubsets); }
php
public function save() { $host = $this; array_map(function ($value) use ($host) { $host->saveSubset($value); }, $this->fileBasedSubsets); }
[ "public", "function", "save", "(", ")", "{", "$", "host", "=", "$", "this", ";", "array_map", "(", "function", "(", "$", "value", ")", "use", "(", "$", "host", ")", "{", "$", "host", "->", "saveSubset", "(", "$", "value", ")", ";", "}", ",", "$", "this", "->", "fileBasedSubsets", ")", ";", "}" ]
Persist all subsets
[ "Persist", "all", "subsets" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/Repository.php#L163-L169
train
jenskooij/cloudcontrol
src/storage/Repository.php
Repository.saveSubset
public function saveSubset($subset) { $changes = $subset . 'Changes'; if ($this->$changes === true) { if (!defined('JSON_PRETTY_PRINT')) { $json = json_encode($this->$subset); } else { $json = json_encode($this->$subset, JSON_PRETTY_PRINT); } $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; file_put_contents($subsetStoragePath, $json); $this->$changes = false; } }
php
public function saveSubset($subset) { $changes = $subset . 'Changes'; if ($this->$changes === true) { if (!defined('JSON_PRETTY_PRINT')) { $json = json_encode($this->$subset); } else { $json = json_encode($this->$subset, JSON_PRETTY_PRINT); } $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; file_put_contents($subsetStoragePath, $json); $this->$changes = false; } }
[ "public", "function", "saveSubset", "(", "$", "subset", ")", "{", "$", "changes", "=", "$", "subset", ".", "'Changes'", ";", "if", "(", "$", "this", "->", "$", "changes", "===", "true", ")", "{", "if", "(", "!", "defined", "(", "'JSON_PRETTY_PRINT'", ")", ")", "{", "$", "json", "=", "json_encode", "(", "$", "this", "->", "$", "subset", ")", ";", "}", "else", "{", "$", "json", "=", "json_encode", "(", "$", "this", "->", "$", "subset", ",", "JSON_PRETTY_PRINT", ")", ";", "}", "$", "subsetStoragePath", "=", "$", "this", "->", "storagePath", ".", "DIRECTORY_SEPARATOR", ".", "$", "subset", ".", "'.json'", ";", "file_put_contents", "(", "$", "subsetStoragePath", ",", "$", "json", ")", ";", "$", "this", "->", "$", "changes", "=", "false", ";", "}", "}" ]
Persist subset to disk @param $subset
[ "Persist", "subset", "to", "disk" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/Repository.php#L175-L189
train
jenskooij/cloudcontrol
src/storage/Repository.php
Repository.loadSubset
protected function loadSubset($subset) { $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; $json = file_get_contents($subsetStoragePath); $json = json_decode($json); $this->$subset = $json; return $json; }
php
protected function loadSubset($subset) { $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; $json = file_get_contents($subsetStoragePath); $json = json_decode($json); $this->$subset = $json; return $json; }
[ "protected", "function", "loadSubset", "(", "$", "subset", ")", "{", "$", "subsetStoragePath", "=", "$", "this", "->", "storagePath", ".", "DIRECTORY_SEPARATOR", ".", "$", "subset", ".", "'.json'", ";", "$", "json", "=", "file_get_contents", "(", "$", "subsetStoragePath", ")", ";", "$", "json", "=", "json_decode", "(", "$", "json", ")", ";", "$", "this", "->", "$", "subset", "=", "$", "json", ";", "return", "$", "json", ";", "}" ]
Load subset from disk @param $subset @return mixed|string
[ "Load", "subset", "from", "disk" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/Repository.php#L196-L203
train
fabiopaiva/ZfcUserCrud
src/ZfcUserCrud/Entity/User.php
User.addRoles
public function addRoles(Collection $roles) { foreach($roles as $role){ $this->roles->add($role); } }
php
public function addRoles(Collection $roles) { foreach($roles as $role){ $this->roles->add($role); } }
[ "public", "function", "addRoles", "(", "Collection", "$", "roles", ")", "{", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "this", "->", "roles", "->", "add", "(", "$", "role", ")", ";", "}", "}" ]
Add a role to the user. @param Role $role @return void
[ "Add", "a", "role", "to", "the", "user", "." ]
8e93ab4e7b3594df5245ce8732fc0334ce4a3d40
https://github.com/fabiopaiva/ZfcUserCrud/blob/8e93ab4e7b3594df5245ce8732fc0334ce4a3d40/src/ZfcUserCrud/Entity/User.php#L244-L250
train
Torann/skosh-generator
src/Builder.php
Builder.registerTwigExtensions
private function registerTwigExtensions() { foreach ($this->app->getSetting('twig_extensions', []) as $extension) { $this->twig->addExtension(new $extension($this)); } }
php
private function registerTwigExtensions() { foreach ($this->app->getSetting('twig_extensions', []) as $extension) { $this->twig->addExtension(new $extension($this)); } }
[ "private", "function", "registerTwigExtensions", "(", ")", "{", "foreach", "(", "$", "this", "->", "app", "->", "getSetting", "(", "'twig_extensions'", ",", "[", "]", ")", "as", "$", "extension", ")", "{", "$", "this", "->", "twig", "->", "addExtension", "(", "new", "$", "extension", "(", "$", "this", ")", ")", ";", "}", "}" ]
Register custom twig extensions.
[ "Register", "custom", "twig", "extensions", "." ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L126-L131
train
Torann/skosh-generator
src/Builder.php
Builder.getUrl
public function getUrl($url) { if (!$url || starts_with($url, ['#', '//', 'mailto:', 'tel:', 'http'])) { return $url; } // Get URL root $root = $this->app->getSetting('url'); $url = trim($root, '/') . '/' . trim($url, '/'); // Force trailing slash if ($this->app->getSetting('url_trailing_slash', false) && ! strrchr(basename($url), '.') ) { $url = "{$url}/"; } return $url; }
php
public function getUrl($url) { if (!$url || starts_with($url, ['#', '//', 'mailto:', 'tel:', 'http'])) { return $url; } // Get URL root $root = $this->app->getSetting('url'); $url = trim($root, '/') . '/' . trim($url, '/'); // Force trailing slash if ($this->app->getSetting('url_trailing_slash', false) && ! strrchr(basename($url), '.') ) { $url = "{$url}/"; } return $url; }
[ "public", "function", "getUrl", "(", "$", "url", ")", "{", "if", "(", "!", "$", "url", "||", "starts_with", "(", "$", "url", ",", "[", "'#'", ",", "'//'", ",", "'mailto:'", ",", "'tel:'", ",", "'http'", "]", ")", ")", "{", "return", "$", "url", ";", "}", "// Get URL root", "$", "root", "=", "$", "this", "->", "app", "->", "getSetting", "(", "'url'", ")", ";", "$", "url", "=", "trim", "(", "$", "root", ",", "'/'", ")", ".", "'/'", ".", "trim", "(", "$", "url", ",", "'/'", ")", ";", "// Force trailing slash", "if", "(", "$", "this", "->", "app", "->", "getSetting", "(", "'url_trailing_slash'", ",", "false", ")", "&&", "!", "strrchr", "(", "basename", "(", "$", "url", ")", ",", "'.'", ")", ")", "{", "$", "url", "=", "\"{$url}/\"", ";", "}", "return", "$", "url", ";", "}" ]
Get the URL for the given page. @param string $url @return string
[ "Get", "the", "URL", "for", "the", "given", "page", "." ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L159-L178
train
Torann/skosh-generator
src/Builder.php
Builder.getAsset
public function getAsset($path) { // Absolute path will not be in manifest if ($path[0] === '/') { return $this->getUrl($path); } // Get manifest $asset = $this->manifest->get($path); return $this->getUrl('/assets/' . trim($asset, '/')); }
php
public function getAsset($path) { // Absolute path will not be in manifest if ($path[0] === '/') { return $this->getUrl($path); } // Get manifest $asset = $this->manifest->get($path); return $this->getUrl('/assets/' . trim($asset, '/')); }
[ "public", "function", "getAsset", "(", "$", "path", ")", "{", "// Absolute path will not be in manifest", "if", "(", "$", "path", "[", "0", "]", "===", "'/'", ")", "{", "return", "$", "this", "->", "getUrl", "(", "$", "path", ")", ";", "}", "// Get manifest", "$", "asset", "=", "$", "this", "->", "manifest", "->", "get", "(", "$", "path", ")", ";", "return", "$", "this", "->", "getUrl", "(", "'/assets/'", ".", "trim", "(", "$", "asset", ",", "'/'", ")", ")", ";", "}" ]
Check asset manifest for a file @param string $path @return string
[ "Check", "asset", "manifest", "for", "a", "file" ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L186-L197
train
Torann/skosh-generator
src/Builder.php
Builder.build
public function build() { $this->app->writeln("\n<comment>Adding root pages</comment>"); $this->addPages('\\Skosh\\Content\\Page'); $this->app->writeln("\n<comment>Adding posts</comment>"); $this->addPages('\\Skosh\\Content\\Post', 'path', '_posts'); $this->app->writeln("\n<comment>Adding docs</comment>"); $this->addPages('\\Skosh\\Content\\Doc', 'path', '_doc'); // Sort pages $this->sortPosts(); // Fire event Event::fire('pages.sorted', [$this]); $this->app->writeln("\n<comment>Rendering content</comment>"); foreach ($this->site->pages as $content) { $this->renderContent($content); } // Fire event Event::fire('pages.rendered', [$this]); }
php
public function build() { $this->app->writeln("\n<comment>Adding root pages</comment>"); $this->addPages('\\Skosh\\Content\\Page'); $this->app->writeln("\n<comment>Adding posts</comment>"); $this->addPages('\\Skosh\\Content\\Post', 'path', '_posts'); $this->app->writeln("\n<comment>Adding docs</comment>"); $this->addPages('\\Skosh\\Content\\Doc', 'path', '_doc'); // Sort pages $this->sortPosts(); // Fire event Event::fire('pages.sorted', [$this]); $this->app->writeln("\n<comment>Rendering content</comment>"); foreach ($this->site->pages as $content) { $this->renderContent($content); } // Fire event Event::fire('pages.rendered', [$this]); }
[ "public", "function", "build", "(", ")", "{", "$", "this", "->", "app", "->", "writeln", "(", "\"\\n<comment>Adding root pages</comment>\"", ")", ";", "$", "this", "->", "addPages", "(", "'\\\\Skosh\\\\Content\\\\Page'", ")", ";", "$", "this", "->", "app", "->", "writeln", "(", "\"\\n<comment>Adding posts</comment>\"", ")", ";", "$", "this", "->", "addPages", "(", "'\\\\Skosh\\\\Content\\\\Post'", ",", "'path'", ",", "'_posts'", ")", ";", "$", "this", "->", "app", "->", "writeln", "(", "\"\\n<comment>Adding docs</comment>\"", ")", ";", "$", "this", "->", "addPages", "(", "'\\\\Skosh\\\\Content\\\\Doc'", ",", "'path'", ",", "'_doc'", ")", ";", "// Sort pages", "$", "this", "->", "sortPosts", "(", ")", ";", "// Fire event", "Event", "::", "fire", "(", "'pages.sorted'", ",", "[", "$", "this", "]", ")", ";", "$", "this", "->", "app", "->", "writeln", "(", "\"\\n<comment>Rendering content</comment>\"", ")", ";", "foreach", "(", "$", "this", "->", "site", "->", "pages", "as", "$", "content", ")", "{", "$", "this", "->", "renderContent", "(", "$", "content", ")", ";", "}", "// Fire event", "Event", "::", "fire", "(", "'pages.rendered'", ",", "[", "$", "this", "]", ")", ";", "}" ]
Renders the site @return void
[ "Renders", "the", "site" ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L204-L229
train
Torann/skosh-generator
src/Builder.php
Builder.savePage
public function savePage($target, $html) { $fs = new Filesystem(); $fs->dumpFile($this->target . DIRECTORY_SEPARATOR . $target, $html); }
php
public function savePage($target, $html) { $fs = new Filesystem(); $fs->dumpFile($this->target . DIRECTORY_SEPARATOR . $target, $html); }
[ "public", "function", "savePage", "(", "$", "target", ",", "$", "html", ")", "{", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "$", "fs", "->", "dumpFile", "(", "$", "this", "->", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "target", ",", "$", "html", ")", ";", "}" ]
Save page to target file. @param string $html @param string $target
[ "Save", "page", "to", "target", "file", "." ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L271-L275
train
Torann/skosh-generator
src/Builder.php
Builder.getParent
public function getParent($parentId) { if ($parentId && isset($this->site->pages[$parentId])) { return $this->site->pages[$parentId]; } return []; }
php
public function getParent($parentId) { if ($parentId && isset($this->site->pages[$parentId])) { return $this->site->pages[$parentId]; } return []; }
[ "public", "function", "getParent", "(", "$", "parentId", ")", "{", "if", "(", "$", "parentId", "&&", "isset", "(", "$", "this", "->", "site", "->", "pages", "[", "$", "parentId", "]", ")", ")", "{", "return", "$", "this", "->", "site", "->", "pages", "[", "$", "parentId", "]", ";", "}", "return", "[", "]", ";", "}" ]
Get parent content. @param string $parentId @return array
[ "Get", "parent", "content", "." ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L283-L290
train
Torann/skosh-generator
src/Builder.php
Builder.getPosts
public function getPosts(Content $content) { if (isset($this->site->categories[$content->id])) { return $this->site->categories[$content->id]; } else { if (isset($content->category) && isset($this->site->categories[$content->category])) { return $this->site->categories[$content->category]; } } return []; }
php
public function getPosts(Content $content) { if (isset($this->site->categories[$content->id])) { return $this->site->categories[$content->id]; } else { if (isset($content->category) && isset($this->site->categories[$content->category])) { return $this->site->categories[$content->category]; } } return []; }
[ "public", "function", "getPosts", "(", "Content", "$", "content", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "site", "->", "categories", "[", "$", "content", "->", "id", "]", ")", ")", "{", "return", "$", "this", "->", "site", "->", "categories", "[", "$", "content", "->", "id", "]", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "content", "->", "category", ")", "&&", "isset", "(", "$", "this", "->", "site", "->", "categories", "[", "$", "content", "->", "category", "]", ")", ")", "{", "return", "$", "this", "->", "site", "->", "categories", "[", "$", "content", "->", "category", "]", ";", "}", "}", "return", "[", "]", ";", "}" ]
Get posts for given content. @param Content $content @return array
[ "Get", "posts", "for", "given", "content", "." ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L298-L310
train
Torann/skosh-generator
src/Builder.php
Builder.createServerConfig
public function createServerConfig() { // Load config $config = new Config($this->app->getEnvironment(), '.env'); // Save to protected file $config->export($this->target . DIRECTORY_SEPARATOR . '.env.php'); }
php
public function createServerConfig() { // Load config $config = new Config($this->app->getEnvironment(), '.env'); // Save to protected file $config->export($this->target . DIRECTORY_SEPARATOR . '.env.php'); }
[ "public", "function", "createServerConfig", "(", ")", "{", "// Load config", "$", "config", "=", "new", "Config", "(", "$", "this", "->", "app", "->", "getEnvironment", "(", ")", ",", "'.env'", ")", ";", "// Save to protected file", "$", "config", "->", "export", "(", "$", "this", "->", "target", ".", "DIRECTORY_SEPARATOR", ".", "'.env.php'", ")", ";", "}" ]
Create a server config file @return void
[ "Create", "a", "server", "config", "file" ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L317-L324
train
Torann/skosh-generator
src/Builder.php
Builder.copyStaticFiles
public function copyStaticFiles() { $exclude = ['js', 'javascripts', 'stylesheets', 'less', 'sass']; // Include the excludes from the config $exclude = array_merge($exclude, (array) $this->app->getSetting('exclude', [])); // Create pattern $pattern = '/\\.(' . implode("|", $exclude) . ')$/'; // Get list of files & directories to copy $to_copy = (array) $this->app->getSetting('copy', []); // Assets folder is hardcoded into copy $to_copy = array_merge(['assets'], $to_copy); $to_copy = array_unique($to_copy); // Initialize file system $filesystem = new Filesystem(); // Fire event if ($response = Event::fire('copy.before', [$this, $to_copy])) { $to_copy = $response[0]; } // Copy foreach ($to_copy as $location) { $fileInfo = new \SplFileInfo($this->source . DIRECTORY_SEPARATOR . $location); // Copy a complete directory if ($fileInfo->isDir()) { $finder = new Finder(); $finder->files() ->exclude($exclude) ->notName($pattern) ->in($this->source . DIRECTORY_SEPARATOR . $location); foreach ($finder as $file) { $path = $location . DIRECTORY_SEPARATOR . $file->getRelativePathname(); echo "$path\n"; $source = $file->getRealPath(); $target = $this->target . DIRECTORY_SEPARATOR . $path; $filesystem->copy($source, $target); $this->app->writeln("Copied: <info>$path</info>"); } } // Copy Single File else { $filesystem->copy($fileInfo->getRealPath(), $this->target . DIRECTORY_SEPARATOR . $location); $this->app->writeln("Copied: <info>$location</info>"); } } }
php
public function copyStaticFiles() { $exclude = ['js', 'javascripts', 'stylesheets', 'less', 'sass']; // Include the excludes from the config $exclude = array_merge($exclude, (array) $this->app->getSetting('exclude', [])); // Create pattern $pattern = '/\\.(' . implode("|", $exclude) . ')$/'; // Get list of files & directories to copy $to_copy = (array) $this->app->getSetting('copy', []); // Assets folder is hardcoded into copy $to_copy = array_merge(['assets'], $to_copy); $to_copy = array_unique($to_copy); // Initialize file system $filesystem = new Filesystem(); // Fire event if ($response = Event::fire('copy.before', [$this, $to_copy])) { $to_copy = $response[0]; } // Copy foreach ($to_copy as $location) { $fileInfo = new \SplFileInfo($this->source . DIRECTORY_SEPARATOR . $location); // Copy a complete directory if ($fileInfo->isDir()) { $finder = new Finder(); $finder->files() ->exclude($exclude) ->notName($pattern) ->in($this->source . DIRECTORY_SEPARATOR . $location); foreach ($finder as $file) { $path = $location . DIRECTORY_SEPARATOR . $file->getRelativePathname(); echo "$path\n"; $source = $file->getRealPath(); $target = $this->target . DIRECTORY_SEPARATOR . $path; $filesystem->copy($source, $target); $this->app->writeln("Copied: <info>$path</info>"); } } // Copy Single File else { $filesystem->copy($fileInfo->getRealPath(), $this->target . DIRECTORY_SEPARATOR . $location); $this->app->writeln("Copied: <info>$location</info>"); } } }
[ "public", "function", "copyStaticFiles", "(", ")", "{", "$", "exclude", "=", "[", "'js'", ",", "'javascripts'", ",", "'stylesheets'", ",", "'less'", ",", "'sass'", "]", ";", "// Include the excludes from the config", "$", "exclude", "=", "array_merge", "(", "$", "exclude", ",", "(", "array", ")", "$", "this", "->", "app", "->", "getSetting", "(", "'exclude'", ",", "[", "]", ")", ")", ";", "// Create pattern", "$", "pattern", "=", "'/\\\\.('", ".", "implode", "(", "\"|\"", ",", "$", "exclude", ")", ".", "')$/'", ";", "// Get list of files & directories to copy", "$", "to_copy", "=", "(", "array", ")", "$", "this", "->", "app", "->", "getSetting", "(", "'copy'", ",", "[", "]", ")", ";", "// Assets folder is hardcoded into copy", "$", "to_copy", "=", "array_merge", "(", "[", "'assets'", "]", ",", "$", "to_copy", ")", ";", "$", "to_copy", "=", "array_unique", "(", "$", "to_copy", ")", ";", "// Initialize file system", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "// Fire event", "if", "(", "$", "response", "=", "Event", "::", "fire", "(", "'copy.before'", ",", "[", "$", "this", ",", "$", "to_copy", "]", ")", ")", "{", "$", "to_copy", "=", "$", "response", "[", "0", "]", ";", "}", "// Copy", "foreach", "(", "$", "to_copy", "as", "$", "location", ")", "{", "$", "fileInfo", "=", "new", "\\", "SplFileInfo", "(", "$", "this", "->", "source", ".", "DIRECTORY_SEPARATOR", ".", "$", "location", ")", ";", "// Copy a complete directory", "if", "(", "$", "fileInfo", "->", "isDir", "(", ")", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(", ")", "->", "exclude", "(", "$", "exclude", ")", "->", "notName", "(", "$", "pattern", ")", "->", "in", "(", "$", "this", "->", "source", ".", "DIRECTORY_SEPARATOR", ".", "$", "location", ")", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "path", "=", "$", "location", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", "->", "getRelativePathname", "(", ")", ";", "echo", "\"$path\\n\"", ";", "$", "source", "=", "$", "file", "->", "getRealPath", "(", ")", ";", "$", "target", "=", "$", "this", "->", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "path", ";", "$", "filesystem", "->", "copy", "(", "$", "source", ",", "$", "target", ")", ";", "$", "this", "->", "app", "->", "writeln", "(", "\"Copied: <info>$path</info>\"", ")", ";", "}", "}", "// Copy Single File", "else", "{", "$", "filesystem", "->", "copy", "(", "$", "fileInfo", "->", "getRealPath", "(", ")", ",", "$", "this", "->", "target", ".", "DIRECTORY_SEPARATOR", ".", "$", "location", ")", ";", "$", "this", "->", "app", "->", "writeln", "(", "\"Copied: <info>$location</info>\"", ")", ";", "}", "}", "}" ]
Copy static files to target Ignoring JS, CSS & LESS - Gulp handles that @return void
[ "Copy", "static", "files", "to", "target", "Ignoring", "JS", "CSS", "&", "LESS", "-", "Gulp", "handles", "that" ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L332-L390
train
Torann/skosh-generator
src/Builder.php
Builder.cleanTarget
public function cleanTarget() { $filesystem = new Filesystem(); // Get files and directories to remove $files = array_diff(scandir($this->target), ['.', '..']); $files = preg_grep('/[^.gitignore]/i', $files); // Remove files foreach ($files as $file) { $filesystem->remove("$this->target/$file"); } // Fire event Event::fire('target.cleaned', [$this]); }
php
public function cleanTarget() { $filesystem = new Filesystem(); // Get files and directories to remove $files = array_diff(scandir($this->target), ['.', '..']); $files = preg_grep('/[^.gitignore]/i', $files); // Remove files foreach ($files as $file) { $filesystem->remove("$this->target/$file"); } // Fire event Event::fire('target.cleaned', [$this]); }
[ "public", "function", "cleanTarget", "(", ")", "{", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "// Get files and directories to remove", "$", "files", "=", "array_diff", "(", "scandir", "(", "$", "this", "->", "target", ")", ",", "[", "'.'", ",", "'..'", "]", ")", ";", "$", "files", "=", "preg_grep", "(", "'/[^.gitignore]/i'", ",", "$", "files", ")", ";", "// Remove files", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "filesystem", "->", "remove", "(", "\"$this->target/$file\"", ")", ";", "}", "// Fire event", "Event", "::", "fire", "(", "'target.cleaned'", ",", "[", "$", "this", "]", ")", ";", "}" ]
Clean target directory @return void
[ "Clean", "target", "directory" ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L397-L412
train
Torann/skosh-generator
src/Builder.php
Builder.addPages
private function addPages($class, $path = 'notPath', $filter = '_') { $finder = new Finder(); $finder->files() ->in($this->source) ->$path($filter) ->name('/\\.(md|textile|xml|twig)$/'); foreach ($finder as $file) { $page = new $class($file, $this); // Skip drafts in production if ($this->app->isProduction() && $page->status === 'draft') { $this->app->writeln("Skipping draft: <info>{$page->sourcePath}/{$page->filename}</info>"); continue; } $this->app->writeln("Adding: <info>{$page->sourcePath}/{$page->filename}</info>"); $this->site->addContent($page); } }
php
private function addPages($class, $path = 'notPath', $filter = '_') { $finder = new Finder(); $finder->files() ->in($this->source) ->$path($filter) ->name('/\\.(md|textile|xml|twig)$/'); foreach ($finder as $file) { $page = new $class($file, $this); // Skip drafts in production if ($this->app->isProduction() && $page->status === 'draft') { $this->app->writeln("Skipping draft: <info>{$page->sourcePath}/{$page->filename}</info>"); continue; } $this->app->writeln("Adding: <info>{$page->sourcePath}/{$page->filename}</info>"); $this->site->addContent($page); } }
[ "private", "function", "addPages", "(", "$", "class", ",", "$", "path", "=", "'notPath'", ",", "$", "filter", "=", "'_'", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(", ")", "->", "in", "(", "$", "this", "->", "source", ")", "->", "$", "path", "(", "$", "filter", ")", "->", "name", "(", "'/\\\\.(md|textile|xml|twig)$/'", ")", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "page", "=", "new", "$", "class", "(", "$", "file", ",", "$", "this", ")", ";", "// Skip drafts in production", "if", "(", "$", "this", "->", "app", "->", "isProduction", "(", ")", "&&", "$", "page", "->", "status", "===", "'draft'", ")", "{", "$", "this", "->", "app", "->", "writeln", "(", "\"Skipping draft: <info>{$page->sourcePath}/{$page->filename}</info>\"", ")", ";", "continue", ";", "}", "$", "this", "->", "app", "->", "writeln", "(", "\"Adding: <info>{$page->sourcePath}/{$page->filename}</info>\"", ")", ";", "$", "this", "->", "site", "->", "addContent", "(", "$", "page", ")", ";", "}", "}" ]
Add pages for rendering @param string $class @param string $path @param string $filter @return void
[ "Add", "pages", "for", "rendering" ]
ea60e037d92398d7c146eb2349735d5692e3c48c
https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Builder.php#L422-L443
train
gplcart/cli
controllers/commands/File.php
File.cmdGetFile
public function cmdGetFile() { $result = $this->getListFile(); $this->outputFormat($result); $this->outputFormatTableFile($result); $this->output(); }
php
public function cmdGetFile() { $result = $this->getListFile(); $this->outputFormat($result); $this->outputFormatTableFile($result); $this->output(); }
[ "public", "function", "cmdGetFile", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getListFile", "(", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "result", ")", ";", "$", "this", "->", "outputFormatTableFile", "(", "$", "result", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "file-get" command
[ "Callback", "for", "file", "-", "get", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/File.php#L40-L46
train
gplcart/cli
controllers/commands/File.php
File.cmdDeleteFile
public function cmdDeleteFile() { $id = $this->getParam(0); $all = $this->getParam('all'); if (empty($id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $options = null; if (isset($id)) { if ($this->getParam('type')) { $options = array('file_type' => $id); } else if ($this->getParam('mime')) { $options = array('mime_type' => $id); } else if ($this->getParam('entity')) { $options = array('entity' => $id); } } else if (!empty($all)) { $options = array(); } if (isset($options)) { $deleted = $count = 0; foreach ($this->file->getList($options) as $item) { $count++; $deleted += (int) $this->deleteFile($item); } $result = $count && $count == $deleted; } else { if (empty($id) || !is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->deleteFile($id); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
php
public function cmdDeleteFile() { $id = $this->getParam(0); $all = $this->getParam('all'); if (empty($id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $options = null; if (isset($id)) { if ($this->getParam('type')) { $options = array('file_type' => $id); } else if ($this->getParam('mime')) { $options = array('mime_type' => $id); } else if ($this->getParam('entity')) { $options = array('entity' => $id); } } else if (!empty($all)) { $options = array(); } if (isset($options)) { $deleted = $count = 0; foreach ($this->file->getList($options) as $item) { $count++; $deleted += (int) $this->deleteFile($item); } $result = $count && $count == $deleted; } else { if (empty($id) || !is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->deleteFile($id); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
[ "public", "function", "cmdDeleteFile", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "all", "=", "$", "this", "->", "getParam", "(", "'all'", ")", ";", "if", "(", "empty", "(", "$", "id", ")", "&&", "empty", "(", "$", "all", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "options", "=", "null", ";", "if", "(", "isset", "(", "$", "id", ")", ")", "{", "if", "(", "$", "this", "->", "getParam", "(", "'type'", ")", ")", "{", "$", "options", "=", "array", "(", "'file_type'", "=>", "$", "id", ")", ";", "}", "else", "if", "(", "$", "this", "->", "getParam", "(", "'mime'", ")", ")", "{", "$", "options", "=", "array", "(", "'mime_type'", "=>", "$", "id", ")", ";", "}", "else", "if", "(", "$", "this", "->", "getParam", "(", "'entity'", ")", ")", "{", "$", "options", "=", "array", "(", "'entity'", "=>", "$", "id", ")", ";", "}", "}", "else", "if", "(", "!", "empty", "(", "$", "all", ")", ")", "{", "$", "options", "=", "array", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "options", ")", ")", "{", "$", "deleted", "=", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "file", "->", "getList", "(", "$", "options", ")", "as", "$", "item", ")", "{", "$", "count", "++", ";", "$", "deleted", "+=", "(", "int", ")", "$", "this", "->", "deleteFile", "(", "$", "item", ")", ";", "}", "$", "result", "=", "$", "count", "&&", "$", "count", "==", "$", "deleted", ";", "}", "else", "{", "if", "(", "empty", "(", "$", "id", ")", "||", "!", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "result", "=", "$", "this", "->", "deleteFile", "(", "$", "id", ")", ";", "}", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "file-delete" command
[ "Callback", "for", "file", "-", "delete", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/File.php#L51-L100
train
gplcart/cli
controllers/commands/File.php
File.cmdUpdateFile
public function cmdUpdateFile() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmitted('update', $params[0]); $this->validateComponent('file'); $this->updateFile($params[0]); $this->output(); }
php
public function cmdUpdateFile() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmitted('update', $params[0]); $this->validateComponent('file'); $this->updateFile($params[0]); $this->output(); }
[ "public", "function", "cmdUpdateFile", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getParam", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "0", "]", ")", "||", "count", "(", "$", "params", ")", "<", "2", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "params", "[", "0", "]", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "params", ")", ";", "$", "this", "->", "setSubmitted", "(", "'update'", ",", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "validateComponent", "(", "'file'", ")", ";", "$", "this", "->", "updateFile", "(", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "file-update" command
[ "Callback", "for", "file", "-", "update", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/File.php#L137-L155
train
gplcart/cli
controllers/commands/File.php
File.addFile
protected function addFile() { if (!$this->isError()) { $id = $this->file->add($this->getSubmitted()); if (empty($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($id); } }
php
protected function addFile() { if (!$this->isError()) { $id = $this->file->add($this->getSubmitted()); if (empty($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($id); } }
[ "protected", "function", "addFile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isError", "(", ")", ")", "{", "$", "id", "=", "$", "this", "->", "file", "->", "add", "(", "$", "this", "->", "getSubmitted", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "line", "(", "$", "id", ")", ";", "}", "}" ]
Add a new file record
[ "Add", "a", "new", "file", "record" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/File.php#L228-L237
train
gplcart/cli
controllers/commands/File.php
File.updateFile
protected function updateFile($file_id) { if (!$this->isError() && !$this->file->update($file_id, $this->getSubmitted())) { $this->errorAndExit($this->text('Unexpected result')); } }
php
protected function updateFile($file_id) { if (!$this->isError() && !$this->file->update($file_id, $this->getSubmitted())) { $this->errorAndExit($this->text('Unexpected result')); } }
[ "protected", "function", "updateFile", "(", "$", "file_id", ")", "{", "if", "(", "!", "$", "this", "->", "isError", "(", ")", "&&", "!", "$", "this", "->", "file", "->", "update", "(", "$", "file_id", ",", "$", "this", "->", "getSubmitted", "(", ")", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "}" ]
Updates a file record @param string $file_id
[ "Updates", "a", "file", "record" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/File.php#L243-L248
train
gplcart/cli
controllers/commands/File.php
File.submitAddFile
protected function submitAddFile() { $this->setSubmitted(null, $this->getParam()); $this->validateComponent('file'); $this->addFile(); }
php
protected function submitAddFile() { $this->setSubmitted(null, $this->getParam()); $this->validateComponent('file'); $this->addFile(); }
[ "protected", "function", "submitAddFile", "(", ")", "{", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "this", "->", "getParam", "(", ")", ")", ";", "$", "this", "->", "validateComponent", "(", "'file'", ")", ";", "$", "this", "->", "addFile", "(", ")", ";", "}" ]
Add a new file record at once
[ "Add", "a", "new", "file", "record", "at", "once" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/File.php#L253-L258
train
gplcart/cli
controllers/commands/File.php
File.wizardAddFile
protected function wizardAddFile() { $this->validatePrompt('path', $this->text('Path'), 'file'); $this->validatePrompt('entity', $this->text('Entity'), 'file'); $this->validatePrompt('entity_id', $this->text('Entity ID'), 'file', 0); $this->validatePrompt('title', $this->text('Title'), 'file', ''); $this->validatePrompt('description', $this->text('Description'), 'file', ''); $this->validatePrompt('weight', $this->text('Weight'), 'file', 0); $this->validateComponent('file'); $this->addFile(); }
php
protected function wizardAddFile() { $this->validatePrompt('path', $this->text('Path'), 'file'); $this->validatePrompt('entity', $this->text('Entity'), 'file'); $this->validatePrompt('entity_id', $this->text('Entity ID'), 'file', 0); $this->validatePrompt('title', $this->text('Title'), 'file', ''); $this->validatePrompt('description', $this->text('Description'), 'file', ''); $this->validatePrompt('weight', $this->text('Weight'), 'file', 0); $this->validateComponent('file'); $this->addFile(); }
[ "protected", "function", "wizardAddFile", "(", ")", "{", "$", "this", "->", "validatePrompt", "(", "'path'", ",", "$", "this", "->", "text", "(", "'Path'", ")", ",", "'file'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'entity'", ",", "$", "this", "->", "text", "(", "'Entity'", ")", ",", "'file'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'entity_id'", ",", "$", "this", "->", "text", "(", "'Entity ID'", ")", ",", "'file'", ",", "0", ")", ";", "$", "this", "->", "validatePrompt", "(", "'title'", ",", "$", "this", "->", "text", "(", "'Title'", ")", ",", "'file'", ",", "''", ")", ";", "$", "this", "->", "validatePrompt", "(", "'description'", ",", "$", "this", "->", "text", "(", "'Description'", ")", ",", "'file'", ",", "''", ")", ";", "$", "this", "->", "validatePrompt", "(", "'weight'", ",", "$", "this", "->", "text", "(", "'Weight'", ")", ",", "'file'", ",", "0", ")", ";", "$", "this", "->", "validateComponent", "(", "'file'", ")", ";", "$", "this", "->", "addFile", "(", ")", ";", "}" ]
Add a new file record step by step
[ "Add", "a", "new", "file", "record", "step", "by", "step" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/File.php#L263-L274
train
agentmedia/phine-builtin
src/BuiltIn/Modules/Backend/RegisterConfirmForm.php
RegisterConfirmForm.SaveGroups
private function SaveGroups() { $assignedIDs = $this->AssignedGroupIDs(); $selectedIDs = Request::PostArray('Group'); $this->ClearMembergroups($selectedIDs); foreach ($selectedIDs as $selectedID) { if (!in_array($selectedID, $assignedIDs)) { $confirmGroup = new RegisterConfirmMembergroup(); $confirmGroup->SetConfirm($this->confirm); $confirmGroup->SetMemberGroup(Membergroup::Schema()->ByID($selectedID)); $confirmGroup->Save(); } } }
php
private function SaveGroups() { $assignedIDs = $this->AssignedGroupIDs(); $selectedIDs = Request::PostArray('Group'); $this->ClearMembergroups($selectedIDs); foreach ($selectedIDs as $selectedID) { if (!in_array($selectedID, $assignedIDs)) { $confirmGroup = new RegisterConfirmMembergroup(); $confirmGroup->SetConfirm($this->confirm); $confirmGroup->SetMemberGroup(Membergroup::Schema()->ByID($selectedID)); $confirmGroup->Save(); } } }
[ "private", "function", "SaveGroups", "(", ")", "{", "$", "assignedIDs", "=", "$", "this", "->", "AssignedGroupIDs", "(", ")", ";", "$", "selectedIDs", "=", "Request", "::", "PostArray", "(", "'Group'", ")", ";", "$", "this", "->", "ClearMembergroups", "(", "$", "selectedIDs", ")", ";", "foreach", "(", "$", "selectedIDs", "as", "$", "selectedID", ")", "{", "if", "(", "!", "in_array", "(", "$", "selectedID", ",", "$", "assignedIDs", ")", ")", "{", "$", "confirmGroup", "=", "new", "RegisterConfirmMembergroup", "(", ")", ";", "$", "confirmGroup", "->", "SetConfirm", "(", "$", "this", "->", "confirm", ")", ";", "$", "confirmGroup", "->", "SetMemberGroup", "(", "Membergroup", "::", "Schema", "(", ")", "->", "ByID", "(", "$", "selectedID", ")", ")", ";", "$", "confirmGroup", "->", "Save", "(", ")", ";", "}", "}", "}" ]
Saves the groups
[ "Saves", "the", "groups" ]
4dd05bc406a71e997bd4eaa16b12e23dbe62a456
https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Backend/RegisterConfirmForm.php#L146-L161
train
975L/ConfigBundle
Twig/ConfigParam.php
ConfigParam.configParam
public function configParam($parameter) { $value = $this->container->getParameter($parameter); return is_array($value) ? json_encode($value) : $value; }
php
public function configParam($parameter) { $value = $this->container->getParameter($parameter); return is_array($value) ? json_encode($value) : $value; }
[ "public", "function", "configParam", "(", "$", "parameter", ")", "{", "$", "value", "=", "$", "this", "->", "container", "->", "getParameter", "(", "$", "parameter", ")", ";", "return", "is_array", "(", "$", "value", ")", "?", "json_encode", "(", "$", "value", ")", ":", "$", "value", ";", "}" ]
Returns the specified container's parameter @return string
[ "Returns", "the", "specified", "container", "s", "parameter" ]
1f9a9e937dbb79ad06fe5d456e7536d58bd56e19
https://github.com/975L/ConfigBundle/blob/1f9a9e937dbb79ad06fe5d456e7536d58bd56e19/Twig/ConfigParam.php#L48-L53
train
net-tools/core
src/ExceptionHandlers/ExceptionHandler.php
ExceptionHandler._getException
protected function _getException(\Throwable $e, $h1) { try { return $this->_getFormatterStrategy()->format($e, $h1); } catch (\Throwable $e2) { return "Error '" . get_class($e2) . "' during processing of exception '" . get_class($e) . "' with message '{$e2->getMessage()}'."; } }
php
protected function _getException(\Throwable $e, $h1) { try { return $this->_getFormatterStrategy()->format($e, $h1); } catch (\Throwable $e2) { return "Error '" . get_class($e2) . "' during processing of exception '" . get_class($e) . "' with message '{$e2->getMessage()}'."; } }
[ "protected", "function", "_getException", "(", "\\", "Throwable", "$", "e", ",", "$", "h1", ")", "{", "try", "{", "return", "$", "this", "->", "_getFormatterStrategy", "(", ")", "->", "format", "(", "$", "e", ",", "$", "h1", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e2", ")", "{", "return", "\"Error '\"", ".", "get_class", "(", "$", "e2", ")", ".", "\"' during processing of exception '\"", ".", "get_class", "(", "$", "e", ")", ".", "\"' with message '{$e2->getMessage()}'.\"", ";", "}", "}" ]
Get exception stack trace as a string @param \Throwable $e Exception to handle @param string $h1 The title displayed on the error page @return string Exception stack trace as a string
[ "Get", "exception", "stack", "trace", "as", "a", "string" ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/ExceptionHandlers/ExceptionHandler.php#L29-L39
train
net-tools/core
src/ExceptionHandlers/ExceptionHandler.php
ExceptionHandler._handleXMLHTTPCommandException
protected function _handleXMLHTTPCommandException(\Throwable $e) { // send xmlhttp headers header("Content-Type: application/json; charset=utf-8"); // no cache header("Expires: Sat, 1 Jan 2005 00:00:00 GMT"); header("Last-Modified: ".gmdate( "D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); // get exception string (stack trace) $ex = $this->_getException($e, 'Error during async request'); echo json_encode(array('statut'=>false, 'message'=>'Error during async request', 'exception'=>$ex)); }
php
protected function _handleXMLHTTPCommandException(\Throwable $e) { // send xmlhttp headers header("Content-Type: application/json; charset=utf-8"); // no cache header("Expires: Sat, 1 Jan 2005 00:00:00 GMT"); header("Last-Modified: ".gmdate( "D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); // get exception string (stack trace) $ex = $this->_getException($e, 'Error during async request'); echo json_encode(array('statut'=>false, 'message'=>'Error during async request', 'exception'=>$ex)); }
[ "protected", "function", "_handleXMLHTTPCommandException", "(", "\\", "Throwable", "$", "e", ")", "{", "// send xmlhttp headers", "header", "(", "\"Content-Type: application/json; charset=utf-8\"", ")", ";", "// no cache", "header", "(", "\"Expires: Sat, 1 Jan 2005 00:00:00 GMT\"", ")", ";", "header", "(", "\"Last-Modified: \"", ".", "gmdate", "(", "\"D, d M Y H:i:s\"", ")", ".", "\" GMT\"", ")", ";", "header", "(", "\"Cache-Control: no-cache, must-revalidate\"", ")", ";", "header", "(", "\"Pragma: no-cache\"", ")", ";", "// get exception string (stack trace)", "$", "ex", "=", "$", "this", "->", "_getException", "(", "$", "e", ",", "'Error during async request'", ")", ";", "echo", "json_encode", "(", "array", "(", "'statut'", "=>", "false", ",", "'message'", "=>", "'Error during async request'", ",", "'exception'", "=>", "$", "ex", ")", ")", ";", "}" ]
Handle an exception during an XMLHTTP request. The XMLHTTP request JSON response will contain a 'exception' property with the exception data formatted as a human-readable string. The JSON formatted exception is outputed directly to standard output. @param \Throwable $e Exception
[ "Handle", "an", "exception", "during", "an", "XMLHTTP", "request", "." ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/ExceptionHandlers/ExceptionHandler.php#L174-L190
train
freddieannobil/doo-pagination
src/DooPagination.php
DooPagination.end
public function end() { # Calculate the Beginning + The maximum amount of results $calc = $this->start() + $this->max; # Only return this if it is not above the total otherwise return our maximum # example, 24 + 6 = 30, but with only 26 reselts it will display the total results istead (26) $r = ($calc > $this->total) ? $this->total : $calc; # return the result return $r; }
php
public function end() { # Calculate the Beginning + The maximum amount of results $calc = $this->start() + $this->max; # Only return this if it is not above the total otherwise return our maximum # example, 24 + 6 = 30, but with only 26 reselts it will display the total results istead (26) $r = ($calc > $this->total) ? $this->total : $calc; # return the result return $r; }
[ "public", "function", "end", "(", ")", "{", "# Calculate the Beginning + The maximum amount of results", "$", "calc", "=", "$", "this", "->", "start", "(", ")", "+", "$", "this", "->", "max", ";", "# Only return this if it is not above the total otherwise return our maximum", "# example, 24 + 6 = 30, but with only 26 reselts it will display the total results istead (26)", "$", "r", "=", "(", "$", "calc", ">", "$", "this", "->", "total", ")", "?", "$", "this", "->", "total", ":", "$", "calc", ";", "# return the result", "return", "$", "r", ";", "}" ]
This calculates the end of our result set, based on our current page @return int Final Calculation of where our result set should end
[ "This", "calculates", "the", "end", "of", "our", "result", "set", "based", "on", "our", "current", "page" ]
7f638c5647585386a71190610592249fd7f735de
https://github.com/freddieannobil/doo-pagination/blob/7f638c5647585386a71190610592249fd7f735de/src/DooPagination.php#L72-L83
train
freddieannobil/doo-pagination
src/DooPagination.php
DooPagination.info
public function info($html) { $tags = array('{total}', '{start}', '{end}', '{page}', '{pages}'); $code = array($this->total, $this->start() + 1, $this->end(), $this->get, $this->pages()); return str_replace($tags, $code, $html); }
php
public function info($html) { $tags = array('{total}', '{start}', '{end}', '{page}', '{pages}'); $code = array($this->total, $this->start() + 1, $this->end(), $this->get, $this->pages()); return str_replace($tags, $code, $html); }
[ "public", "function", "info", "(", "$", "html", ")", "{", "$", "tags", "=", "array", "(", "'{total}'", ",", "'{start}'", ",", "'{end}'", ",", "'{page}'", ",", "'{pages}'", ")", ";", "$", "code", "=", "array", "(", "$", "this", "->", "total", ",", "$", "this", "->", "start", "(", ")", "+", "1", ",", "$", "this", "->", "end", "(", ")", ",", "$", "this", "->", "get", ",", "$", "this", "->", "pages", "(", ")", ")", ";", "return", "str_replace", "(", "$", "tags", ",", "$", "code", ",", "$", "html", ")", ";", "}" ]
Based on which page you are this returns informations like, start result, end result, total results, current page, total pages @param string $html The HTML you wish to use to display the link @return mixed return information we may need to display
[ "Based", "on", "which", "page", "you", "are", "this", "returns", "informations", "like", "start", "result", "end", "result", "total", "results", "current", "page", "total", "pages" ]
7f638c5647585386a71190610592249fd7f735de
https://github.com/freddieannobil/doo-pagination/blob/7f638c5647585386a71190610592249fd7f735de/src/DooPagination.php#L99-L105
train
freddieannobil/doo-pagination
src/DooPagination.php
DooPagination.first
public function first($html, $html2 = '') { # Only show if you are not on page 1, otherwise show HTML2 $r = ($this->get != 1) ? str_replace('{nr}', 1, $html) : str_replace('{nr}', 1, $html2); return $r; }
php
public function first($html, $html2 = '') { # Only show if you are not on page 1, otherwise show HTML2 $r = ($this->get != 1) ? str_replace('{nr}', 1, $html) : str_replace('{nr}', 1, $html2); return $r; }
[ "public", "function", "first", "(", "$", "html", ",", "$", "html2", "=", "''", ")", "{", "# Only show if you are not on page 1, otherwise show HTML2", "$", "r", "=", "(", "$", "this", "->", "get", "!=", "1", ")", "?", "str_replace", "(", "'{nr}'", ",", "1", ",", "$", "html", ")", ":", "str_replace", "(", "'{nr}'", ",", "1", ",", "$", "html2", ")", ";", "return", "$", "r", ";", "}" ]
This shows the 'first' link with custom html @param string $html The HTML you wish to use to display the link @return string The Same HTML replaced the tags with the proper number
[ "This", "shows", "the", "first", "link", "with", "custom", "html" ]
7f638c5647585386a71190610592249fd7f735de
https://github.com/freddieannobil/doo-pagination/blob/7f638c5647585386a71190610592249fd7f735de/src/DooPagination.php#L112-L118
train
freddieannobil/doo-pagination
src/DooPagination.php
DooPagination.previous
public function previous($html, $html2 = '') { # Only show if you are not on page 1, otherwise show HTML2 $r = ($this->get != 1) ? str_replace('{nr}', $this->get - 1, $html) : str_replace('{nr}', $this->get - 1, $html2); return $r; }
php
public function previous($html, $html2 = '') { # Only show if you are not on page 1, otherwise show HTML2 $r = ($this->get != 1) ? str_replace('{nr}', $this->get - 1, $html) : str_replace('{nr}', $this->get - 1, $html2); return $r; }
[ "public", "function", "previous", "(", "$", "html", ",", "$", "html2", "=", "''", ")", "{", "# Only show if you are not on page 1, otherwise show HTML2", "$", "r", "=", "(", "$", "this", "->", "get", "!=", "1", ")", "?", "str_replace", "(", "'{nr}'", ",", "$", "this", "->", "get", "-", "1", ",", "$", "html", ")", ":", "str_replace", "(", "'{nr}'", ",", "$", "this", "->", "get", "-", "1", ",", "$", "html2", ")", ";", "return", "$", "r", ";", "}" ]
This shows the 'previous' link with custom html @param string $html The HTML you wish to use to display the link @return string The Same HTML replaced the tags with the proper number
[ "This", "shows", "the", "previous", "link", "with", "custom", "html" ]
7f638c5647585386a71190610592249fd7f735de
https://github.com/freddieannobil/doo-pagination/blob/7f638c5647585386a71190610592249fd7f735de/src/DooPagination.php#L125-L131
train
freddieannobil/doo-pagination
src/DooPagination.php
DooPagination.next
public function next($html, $html2 = '') { # Only show if you are not on the last page $r = ($this->get < $this->pages()) ? str_replace('{nr}', $this->get + 1, $html) : str_replace('{nr}', $this->get + 1, $html2); return $r; }
php
public function next($html, $html2 = '') { # Only show if you are not on the last page $r = ($this->get < $this->pages()) ? str_replace('{nr}', $this->get + 1, $html) : str_replace('{nr}', $this->get + 1, $html2); return $r; }
[ "public", "function", "next", "(", "$", "html", ",", "$", "html2", "=", "''", ")", "{", "# Only show if you are not on the last page", "$", "r", "=", "(", "$", "this", "->", "get", "<", "$", "this", "->", "pages", "(", ")", ")", "?", "str_replace", "(", "'{nr}'", ",", "$", "this", "->", "get", "+", "1", ",", "$", "html", ")", ":", "str_replace", "(", "'{nr}'", ",", "$", "this", "->", "get", "+", "1", ",", "$", "html2", ")", ";", "return", "$", "r", ";", "}" ]
This shows the 'next' link with custom html @param string $html The HTML you wish to use to display the link @return string The Same HTML replaced the tags with the proper number
[ "This", "shows", "the", "next", "link", "with", "custom", "html" ]
7f638c5647585386a71190610592249fd7f735de
https://github.com/freddieannobil/doo-pagination/blob/7f638c5647585386a71190610592249fd7f735de/src/DooPagination.php#L138-L144
train
freddieannobil/doo-pagination
src/DooPagination.php
DooPagination.last
public function last($html, $html2 = '') { # Only show if you are not on the last page $r = ($this->get < $this->pages()) ? str_replace('{nr}', $this->pages(), $html) : str_replace('{nr}', $this->pages(), $html2); return $r; }
php
public function last($html, $html2 = '') { # Only show if you are not on the last page $r = ($this->get < $this->pages()) ? str_replace('{nr}', $this->pages(), $html) : str_replace('{nr}', $this->pages(), $html2); return $r; }
[ "public", "function", "last", "(", "$", "html", ",", "$", "html2", "=", "''", ")", "{", "# Only show if you are not on the last page", "$", "r", "=", "(", "$", "this", "->", "get", "<", "$", "this", "->", "pages", "(", ")", ")", "?", "str_replace", "(", "'{nr}'", ",", "$", "this", "->", "pages", "(", ")", ",", "$", "html", ")", ":", "str_replace", "(", "'{nr}'", ",", "$", "this", "->", "pages", "(", ")", ",", "$", "html2", ")", ";", "return", "$", "r", ";", "}" ]
This shows the 'last' link with custom html @param string $html The HTML you wish to use to display the link @return string The Same HTML replaced the tags with the proper number
[ "This", "shows", "the", "last", "link", "with", "custom", "html" ]
7f638c5647585386a71190610592249fd7f735de
https://github.com/freddieannobil/doo-pagination/blob/7f638c5647585386a71190610592249fd7f735de/src/DooPagination.php#L151-L157
train
freddieannobil/doo-pagination
src/DooPagination.php
DooPagination.numbers
public function numbers($link, $current, $reversed = false) { $r = ''; $range = floor(($this->max_items - 1) / 2); if (!$this->max_items) { $page_nums = range(1, $this->pages()); } else { $lower_limit = max($this->get - $range, 1); $upper_limit = min($this->pages(), $this->get + $range); $page_nums = range($lower_limit, $upper_limit); } if ($reversed) { $page_nums = array_reverse($page_nums); } foreach ($page_nums as $i) { if ($this->get == $i) { $r .= str_replace('{nr}', $i, $current); } else { $r .= str_replace('{nr}', $i, $link); } } return $r; }
php
public function numbers($link, $current, $reversed = false) { $r = ''; $range = floor(($this->max_items - 1) / 2); if (!$this->max_items) { $page_nums = range(1, $this->pages()); } else { $lower_limit = max($this->get - $range, 1); $upper_limit = min($this->pages(), $this->get + $range); $page_nums = range($lower_limit, $upper_limit); } if ($reversed) { $page_nums = array_reverse($page_nums); } foreach ($page_nums as $i) { if ($this->get == $i) { $r .= str_replace('{nr}', $i, $current); } else { $r .= str_replace('{nr}', $i, $link); } } return $r; }
[ "public", "function", "numbers", "(", "$", "link", ",", "$", "current", ",", "$", "reversed", "=", "false", ")", "{", "$", "r", "=", "''", ";", "$", "range", "=", "floor", "(", "(", "$", "this", "->", "max_items", "-", "1", ")", "/", "2", ")", ";", "if", "(", "!", "$", "this", "->", "max_items", ")", "{", "$", "page_nums", "=", "range", "(", "1", ",", "$", "this", "->", "pages", "(", ")", ")", ";", "}", "else", "{", "$", "lower_limit", "=", "max", "(", "$", "this", "->", "get", "-", "$", "range", ",", "1", ")", ";", "$", "upper_limit", "=", "min", "(", "$", "this", "->", "pages", "(", ")", ",", "$", "this", "->", "get", "+", "$", "range", ")", ";", "$", "page_nums", "=", "range", "(", "$", "lower_limit", ",", "$", "upper_limit", ")", ";", "}", "if", "(", "$", "reversed", ")", "{", "$", "page_nums", "=", "array_reverse", "(", "$", "page_nums", ")", ";", "}", "foreach", "(", "$", "page_nums", "as", "$", "i", ")", "{", "if", "(", "$", "this", "->", "get", "==", "$", "i", ")", "{", "$", "r", ".=", "str_replace", "(", "'{nr}'", ",", "$", "i", ",", "$", "current", ")", ";", "}", "else", "{", "$", "r", ".=", "str_replace", "(", "'{nr}'", ",", "$", "i", ",", "$", "link", ")", ";", "}", "}", "return", "$", "r", ";", "}" ]
This shows an loop of 'numbers' with their appropriate link in custom html @param string $link The HTML to display a number with a link @param string $current The HTML to display a the current page number without a link @param string $reversed Optional Parameter, set to true if you want the numbers reversed (align to right for designs) @return string The Same HTML replaced the tags with the proper numbers and links
[ "This", "shows", "an", "loop", "of", "numbers", "with", "their", "appropriate", "link", "in", "custom", "html" ]
7f638c5647585386a71190610592249fd7f735de
https://github.com/freddieannobil/doo-pagination/blob/7f638c5647585386a71190610592249fd7f735de/src/DooPagination.php#L166-L190
train
tuanlq11/dbi18n
src/I18NDBTrait.php
I18NDBTrait.saveI18N
public function saveI18N() { if (empty($this->i18n_data)) return; $this->i18n_relation()->getQuery()->whereIn($this->getI18NCodeField(), array_keys($this->i18n_data))->delete(); foreach ($this->i18n_data as $locale => $data) { $obj = new $this->i18n_class(); $data[$this->i18n_primary] = $this->id; $data[$this->getI18NCodeField()] = $locale; $obj->create($data); } }
php
public function saveI18N() { if (empty($this->i18n_data)) return; $this->i18n_relation()->getQuery()->whereIn($this->getI18NCodeField(), array_keys($this->i18n_data))->delete(); foreach ($this->i18n_data as $locale => $data) { $obj = new $this->i18n_class(); $data[$this->i18n_primary] = $this->id; $data[$this->getI18NCodeField()] = $locale; $obj->create($data); } }
[ "public", "function", "saveI18N", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "i18n_data", ")", ")", "return", ";", "$", "this", "->", "i18n_relation", "(", ")", "->", "getQuery", "(", ")", "->", "whereIn", "(", "$", "this", "->", "getI18NCodeField", "(", ")", ",", "array_keys", "(", "$", "this", "->", "i18n_data", ")", ")", "->", "delete", "(", ")", ";", "foreach", "(", "$", "this", "->", "i18n_data", "as", "$", "locale", "=>", "$", "data", ")", "{", "$", "obj", "=", "new", "$", "this", "->", "i18n_class", "(", ")", ";", "$", "data", "[", "$", "this", "->", "i18n_primary", "]", "=", "$", "this", "->", "id", ";", "$", "data", "[", "$", "this", "->", "getI18NCodeField", "(", ")", "]", "=", "$", "locale", ";", "$", "obj", "->", "create", "(", "$", "data", ")", ";", "}", "}" ]
Store I18N to database
[ "Store", "I18N", "to", "database" ]
56d01eceae043f2770e01b92e7bcc7e52a5047e7
https://github.com/tuanlq11/dbi18n/blob/56d01eceae043f2770e01b92e7bcc7e52a5047e7/src/I18NDBTrait.php#L59-L69
train
tuanlq11/dbi18n
src/I18NDBTrait.php
I18NDBTrait.filterI18NColumn
public function filterI18NColumn() { $overrideData = array_only($this->attributes, $this->i18n_fillable); if (!empty($overrideData)) { $this->i18n_data[$this->i18n_default_locale] = $overrideData; foreach ($this->i18n_fillable as $key) { unset($this->$key); } } if (isset($this->attributes[$this->i18n_attribute_name])) { $this->i18n_data = $this->attributes[$this->i18n_attribute_name]; unset($this->attributes[$this->i18n_attribute_name]); } }
php
public function filterI18NColumn() { $overrideData = array_only($this->attributes, $this->i18n_fillable); if (!empty($overrideData)) { $this->i18n_data[$this->i18n_default_locale] = $overrideData; foreach ($this->i18n_fillable as $key) { unset($this->$key); } } if (isset($this->attributes[$this->i18n_attribute_name])) { $this->i18n_data = $this->attributes[$this->i18n_attribute_name]; unset($this->attributes[$this->i18n_attribute_name]); } }
[ "public", "function", "filterI18NColumn", "(", ")", "{", "$", "overrideData", "=", "array_only", "(", "$", "this", "->", "attributes", ",", "$", "this", "->", "i18n_fillable", ")", ";", "if", "(", "!", "empty", "(", "$", "overrideData", ")", ")", "{", "$", "this", "->", "i18n_data", "[", "$", "this", "->", "i18n_default_locale", "]", "=", "$", "overrideData", ";", "foreach", "(", "$", "this", "->", "i18n_fillable", "as", "$", "key", ")", "{", "unset", "(", "$", "this", "->", "$", "key", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "this", "->", "i18n_attribute_name", "]", ")", ")", "{", "$", "this", "->", "i18n_data", "=", "$", "this", "->", "attributes", "[", "$", "this", "->", "i18n_attribute_name", "]", ";", "unset", "(", "$", "this", "->", "attributes", "[", "$", "this", "->", "i18n_attribute_name", "]", ")", ";", "}", "}" ]
Filter & remove i18n column from attributes. Mean, is not save to model self.
[ "Filter", "&", "remove", "i18n", "column", "from", "attributes", ".", "Mean", "is", "not", "save", "to", "model", "self", "." ]
56d01eceae043f2770e01b92e7bcc7e52a5047e7
https://github.com/tuanlq11/dbi18n/blob/56d01eceae043f2770e01b92e7bcc7e52a5047e7/src/I18NDBTrait.php#L75-L89
train
tuanlq11/dbi18n
src/I18NDBTrait.php
I18NDBTrait.scopeI18N
public function scopeI18N($query, $locale = null) { $i18nTranAlias = "i18n_translation"; $i18nAlias = "i18n"; $primary = $this->primaryKey; $i18nPrimary = $this->i18n_primary; $table = $this->table; $i18n_table = (new $this->i18n_class())->getTable(); if ($locale) { $query->leftJoin(\DB::raw(" ( SELECT {$i18nTranAlias}.* FROM {$i18n_table} as {$i18nTranAlias} WHERE {$i18nTranAlias}.{$this->getI18NCodeField()} = '{$locale}' ) as {$i18nAlias}" ), function ($join) use ($i18nAlias, $primary, $i18nPrimary, $table) { $join->on("{$i18nAlias}.{$i18nPrimary}", "=", "{$table}.{$primary}"); }); } else { $query->leftJoin("{$i18n_table} as {$i18nAlias}", "{$i18nAlias}.{$i18nPrimary}", "=", "{$table}.{$primary}"); } return $query; }
php
public function scopeI18N($query, $locale = null) { $i18nTranAlias = "i18n_translation"; $i18nAlias = "i18n"; $primary = $this->primaryKey; $i18nPrimary = $this->i18n_primary; $table = $this->table; $i18n_table = (new $this->i18n_class())->getTable(); if ($locale) { $query->leftJoin(\DB::raw(" ( SELECT {$i18nTranAlias}.* FROM {$i18n_table} as {$i18nTranAlias} WHERE {$i18nTranAlias}.{$this->getI18NCodeField()} = '{$locale}' ) as {$i18nAlias}" ), function ($join) use ($i18nAlias, $primary, $i18nPrimary, $table) { $join->on("{$i18nAlias}.{$i18nPrimary}", "=", "{$table}.{$primary}"); }); } else { $query->leftJoin("{$i18n_table} as {$i18nAlias}", "{$i18nAlias}.{$i18nPrimary}", "=", "{$table}.{$primary}"); } return $query; }
[ "public", "function", "scopeI18N", "(", "$", "query", ",", "$", "locale", "=", "null", ")", "{", "$", "i18nTranAlias", "=", "\"i18n_translation\"", ";", "$", "i18nAlias", "=", "\"i18n\"", ";", "$", "primary", "=", "$", "this", "->", "primaryKey", ";", "$", "i18nPrimary", "=", "$", "this", "->", "i18n_primary", ";", "$", "table", "=", "$", "this", "->", "table", ";", "$", "i18n_table", "=", "(", "new", "$", "this", "->", "i18n_class", "(", ")", ")", "->", "getTable", "(", ")", ";", "if", "(", "$", "locale", ")", "{", "$", "query", "->", "leftJoin", "(", "\\", "DB", "::", "raw", "(", "\"\n (\n SELECT {$i18nTranAlias}.*\n FROM {$i18n_table} as {$i18nTranAlias}\n WHERE {$i18nTranAlias}.{$this->getI18NCodeField()} = '{$locale}'\n ) as {$i18nAlias}\"", ")", ",", "function", "(", "$", "join", ")", "use", "(", "$", "i18nAlias", ",", "$", "primary", ",", "$", "i18nPrimary", ",", "$", "table", ")", "{", "$", "join", "->", "on", "(", "\"{$i18nAlias}.{$i18nPrimary}\"", ",", "\"=\"", ",", "\"{$table}.{$primary}\"", ")", ";", "}", ")", ";", "}", "else", "{", "$", "query", "->", "leftJoin", "(", "\"{$i18n_table} as {$i18nAlias}\"", ",", "\"{$i18nAlias}.{$i18nPrimary}\"", ",", "\"=\"", ",", "\"{$table}.{$primary}\"", ")", ";", "}", "return", "$", "query", ";", "}" ]
Join I18N data to this @param $query Builder @param $locale string|null @return Builder
[ "Join", "I18N", "data", "to", "this" ]
56d01eceae043f2770e01b92e7bcc7e52a5047e7
https://github.com/tuanlq11/dbi18n/blob/56d01eceae043f2770e01b92e7bcc7e52a5047e7/src/I18NDBTrait.php#L123-L147
train
ARCANESOFT/Auth
src/Seeds/PermissionsSeeder.php
PermissionsSeeder.seed
public function seed(array $seeds) { foreach ($seeds as $seed) { /** @var \Arcanesoft\Auth\Models\PermissionsGroup $group */ $group = PermissionsGroup::create($seed['group']); $permissions = array_map(function ($permission) { return new Permission($permission); }, $seed['permissions']); $group->permissions()->saveMany($permissions); } }
php
public function seed(array $seeds) { foreach ($seeds as $seed) { /** @var \Arcanesoft\Auth\Models\PermissionsGroup $group */ $group = PermissionsGroup::create($seed['group']); $permissions = array_map(function ($permission) { return new Permission($permission); }, $seed['permissions']); $group->permissions()->saveMany($permissions); } }
[ "public", "function", "seed", "(", "array", "$", "seeds", ")", "{", "foreach", "(", "$", "seeds", "as", "$", "seed", ")", "{", "/** @var \\Arcanesoft\\Auth\\Models\\PermissionsGroup $group */", "$", "group", "=", "PermissionsGroup", "::", "create", "(", "$", "seed", "[", "'group'", "]", ")", ";", "$", "permissions", "=", "array_map", "(", "function", "(", "$", "permission", ")", "{", "return", "new", "Permission", "(", "$", "permission", ")", ";", "}", ",", "$", "seed", "[", "'permissions'", "]", ")", ";", "$", "group", "->", "permissions", "(", ")", "->", "saveMany", "(", "$", "permissions", ")", ";", "}", "}" ]
Seed permissions. @param array $seeds
[ "Seed", "permissions", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/Seeds/PermissionsSeeder.php#L25-L36
train
solid-framework/core
src/Config/Config.php
Config.get
public function get(string $settingsField = null, $default = null) { // if no settings field was given return all settings if (is_null($settingsField)) { return $this->settings; } $setting = $this->settings; foreach (explode('.', $settingsField) as $field) { if (is_array($setting) && array_key_exists($field, $setting)) { $setting = &$setting[$field]; } else { return $default; } } return $setting; }
php
public function get(string $settingsField = null, $default = null) { // if no settings field was given return all settings if (is_null($settingsField)) { return $this->settings; } $setting = $this->settings; foreach (explode('.', $settingsField) as $field) { if (is_array($setting) && array_key_exists($field, $setting)) { $setting = &$setting[$field]; } else { return $default; } } return $setting; }
[ "public", "function", "get", "(", "string", "$", "settingsField", "=", "null", ",", "$", "default", "=", "null", ")", "{", "// if no settings field was given return all settings", "if", "(", "is_null", "(", "$", "settingsField", ")", ")", "{", "return", "$", "this", "->", "settings", ";", "}", "$", "setting", "=", "$", "this", "->", "settings", ";", "foreach", "(", "explode", "(", "'.'", ",", "$", "settingsField", ")", "as", "$", "field", ")", "{", "if", "(", "is_array", "(", "$", "setting", ")", "&&", "array_key_exists", "(", "$", "field", ",", "$", "setting", ")", ")", "{", "$", "setting", "=", "&", "$", "setting", "[", "$", "field", "]", ";", "}", "else", "{", "return", "$", "default", ";", "}", "}", "return", "$", "setting", ";", "}" ]
Returns the given settings field if set or the default value Note: If no settings field is given all settings are returned. @api @since 0.1.0 @param string $settingsField The settings field to retrieve. @param mixed $default The default value to use. @return mixed
[ "Returns", "the", "given", "settings", "field", "if", "set", "or", "the", "default", "value" ]
418e78fc4c630c35a147832615adda0336271569
https://github.com/solid-framework/core/blob/418e78fc4c630c35a147832615adda0336271569/src/Config/Config.php#L79-L97
train
solid-framework/core
src/Config/Config.php
Config.merge
public function merge(array $settings, string $field = null, bool $mergeArrays = false) { $merged = self::mergeSettings($this->get($field), $settings, $mergeArrays); if (!is_null($field)) { $this->put($field, $merged); } else { $this->set($merged); } }
php
public function merge(array $settings, string $field = null, bool $mergeArrays = false) { $merged = self::mergeSettings($this->get($field), $settings, $mergeArrays); if (!is_null($field)) { $this->put($field, $merged); } else { $this->set($merged); } }
[ "public", "function", "merge", "(", "array", "$", "settings", ",", "string", "$", "field", "=", "null", ",", "bool", "$", "mergeArrays", "=", "false", ")", "{", "$", "merged", "=", "self", "::", "mergeSettings", "(", "$", "this", "->", "get", "(", "$", "field", ")", ",", "$", "settings", ",", "$", "mergeArrays", ")", ";", "if", "(", "!", "is_null", "(", "$", "field", ")", ")", "{", "$", "this", "->", "put", "(", "$", "field", ",", "$", "merged", ")", ";", "}", "else", "{", "$", "this", "->", "set", "(", "$", "merged", ")", ";", "}", "}" ]
Merges the given settings into the given field @api @since 0.1.0 @param array $settings The settings to merge into the given field. @param string|null $field The field to merge the given settings into. @param bool $mergeArrays Whether to merge indexed arrays. @return void
[ "Merges", "the", "given", "settings", "into", "the", "given", "field" ]
418e78fc4c630c35a147832615adda0336271569
https://github.com/solid-framework/core/blob/418e78fc4c630c35a147832615adda0336271569/src/Config/Config.php#L137-L146
train
solid-framework/core
src/Config/Config.php
Config.mergeSettings
private static function mergeSettings(array $a, array $b, $mergeArrays = false): array { foreach ($b as $key => $value) { if (array_key_exists($key, $a)) { if (self::isAssoc($a[$key]) && self::isAssoc($b[$key])) { $a[$key] = self::mergeSettings( $a[$key], $b[$key], $mergeArrays ); } elseif ($mergeArrays && is_array($a[$key]) && is_array($b[$key])) { $a[$key] = array_values(array_unique(array_merge($a[$key], $b[$key]))); } else { $a[$key] = $b[$key]; } } else { $a[$key] = $value; } } return $a; }
php
private static function mergeSettings(array $a, array $b, $mergeArrays = false): array { foreach ($b as $key => $value) { if (array_key_exists($key, $a)) { if (self::isAssoc($a[$key]) && self::isAssoc($b[$key])) { $a[$key] = self::mergeSettings( $a[$key], $b[$key], $mergeArrays ); } elseif ($mergeArrays && is_array($a[$key]) && is_array($b[$key])) { $a[$key] = array_values(array_unique(array_merge($a[$key], $b[$key]))); } else { $a[$key] = $b[$key]; } } else { $a[$key] = $value; } } return $a; }
[ "private", "static", "function", "mergeSettings", "(", "array", "$", "a", ",", "array", "$", "b", ",", "$", "mergeArrays", "=", "false", ")", ":", "array", "{", "foreach", "(", "$", "b", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "a", ")", ")", "{", "if", "(", "self", "::", "isAssoc", "(", "$", "a", "[", "$", "key", "]", ")", "&&", "self", "::", "isAssoc", "(", "$", "b", "[", "$", "key", "]", ")", ")", "{", "$", "a", "[", "$", "key", "]", "=", "self", "::", "mergeSettings", "(", "$", "a", "[", "$", "key", "]", ",", "$", "b", "[", "$", "key", "]", ",", "$", "mergeArrays", ")", ";", "}", "elseif", "(", "$", "mergeArrays", "&&", "is_array", "(", "$", "a", "[", "$", "key", "]", ")", "&&", "is_array", "(", "$", "b", "[", "$", "key", "]", ")", ")", "{", "$", "a", "[", "$", "key", "]", "=", "array_values", "(", "array_unique", "(", "array_merge", "(", "$", "a", "[", "$", "key", "]", ",", "$", "b", "[", "$", "key", "]", ")", ")", ")", ";", "}", "else", "{", "$", "a", "[", "$", "key", "]", "=", "$", "b", "[", "$", "key", "]", ";", "}", "}", "else", "{", "$", "a", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "a", ";", "}" ]
Recursively merges the two given arrays giving priority to the second @internal @since 0.1.0 @param array $a The array to merge in the second array into. @param array $b The array to merge into the first array. @param bool $mergeArrays Whether to merge indexed arrays. @return array
[ "Recursively", "merges", "the", "two", "given", "arrays", "giving", "priority", "to", "the", "second" ]
418e78fc4c630c35a147832615adda0336271569
https://github.com/solid-framework/core/blob/418e78fc4c630c35a147832615adda0336271569/src/Config/Config.php#L158-L179
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.load
public function load(DOMDocument $domDocument, $cachePath, $xmlSchemaFile = null) { $this->domDocument = $domDocument; $this->cachePath = $cachePath; if (isset($xmlSchemaFile)) { $this->xmlSchemaFile = $xmlSchemaFile; } $this->loadConfiguration(); }
php
public function load(DOMDocument $domDocument, $cachePath, $xmlSchemaFile = null) { $this->domDocument = $domDocument; $this->cachePath = $cachePath; if (isset($xmlSchemaFile)) { $this->xmlSchemaFile = $xmlSchemaFile; } $this->loadConfiguration(); }
[ "public", "function", "load", "(", "DOMDocument", "$", "domDocument", ",", "$", "cachePath", ",", "$", "xmlSchemaFile", "=", "null", ")", "{", "$", "this", "->", "domDocument", "=", "$", "domDocument", ";", "$", "this", "->", "cachePath", "=", "$", "cachePath", ";", "if", "(", "isset", "(", "$", "xmlSchemaFile", ")", ")", "{", "$", "this", "->", "xmlSchemaFile", "=", "$", "xmlSchemaFile", ";", "}", "$", "this", "->", "loadConfiguration", "(", ")", ";", "}" ]
Loads the XML configuration. @param DOMDocument $domDocument @param string $cachePath @param string|null $xmlSchemaFile
[ "Loads", "the", "XML", "configuration", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L88-L97
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.reload
public function reload() { $this->configuration = null; $this->load($this->domDocument, $this->cachePath, $this->xmlSchemaFile); }
php
public function reload() { $this->configuration = null; $this->load($this->domDocument, $this->cachePath, $this->xmlSchemaFile); }
[ "public", "function", "reload", "(", ")", "{", "$", "this", "->", "configuration", "=", "null", ";", "$", "this", "->", "load", "(", "$", "this", "->", "domDocument", ",", "$", "this", "->", "cachePath", ",", "$", "this", "->", "xmlSchemaFile", ")", ";", "}" ]
Reloads the configuration.
[ "Reloads", "the", "configuration", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L102-L107
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.hasField
public function hasField($objectName, $fieldName) { $field = $this->getField($objectName, $fieldName); return is_array($field); }
php
public function hasField($objectName, $fieldName) { $field = $this->getField($objectName, $fieldName); return is_array($field); }
[ "public", "function", "hasField", "(", "$", "objectName", ",", "$", "fieldName", ")", "{", "$", "field", "=", "$", "this", "->", "getField", "(", "$", "objectName", ",", "$", "fieldName", ")", ";", "return", "is_array", "(", "$", "field", ")", ";", "}" ]
Returns true when the configuration of an object contains the specified field name. @param string $objectName @param string $fieldName @return bool
[ "Returns", "true", "when", "the", "configuration", "of", "an", "object", "contains", "the", "specified", "field", "name", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L163-L168
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getObjectNames
public function getObjectNames() { $objectNames = array(); if (is_array($this->configuration)) { $objectNames = array_keys($this->configuration); } return $objectNames; }
php
public function getObjectNames() { $objectNames = array(); if (is_array($this->configuration)) { $objectNames = array_keys($this->configuration); } return $objectNames; }
[ "public", "function", "getObjectNames", "(", ")", "{", "$", "objectNames", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "configuration", ")", ")", "{", "$", "objectNames", "=", "array_keys", "(", "$", "this", "->", "configuration", ")", ";", "}", "return", "$", "objectNames", ";", "}" ]
Returns all configured object names. @return array
[ "Returns", "all", "configured", "object", "names", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L187-L195
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getModelConfiguration
public function getModelConfiguration($objectName) { if (isset($this->configuration[$objectName])) { $modelConfiguration = $this->configuration[$objectName]; $modelConfiguration['__object_name'] = $objectName; if (isset($modelConfiguration['fields']) === false) { $modelConfiguration['fields'] = array(); } return $modelConfiguration; } }
php
public function getModelConfiguration($objectName) { if (isset($this->configuration[$objectName])) { $modelConfiguration = $this->configuration[$objectName]; $modelConfiguration['__object_name'] = $objectName; if (isset($modelConfiguration['fields']) === false) { $modelConfiguration['fields'] = array(); } return $modelConfiguration; } }
[ "public", "function", "getModelConfiguration", "(", "$", "objectName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "configuration", "[", "$", "objectName", "]", ")", ")", "{", "$", "modelConfiguration", "=", "$", "this", "->", "configuration", "[", "$", "objectName", "]", ";", "$", "modelConfiguration", "[", "'__object_name'", "]", "=", "$", "objectName", ";", "if", "(", "isset", "(", "$", "modelConfiguration", "[", "'fields'", "]", ")", "===", "false", ")", "{", "$", "modelConfiguration", "[", "'fields'", "]", "=", "array", "(", ")", ";", "}", "return", "$", "modelConfiguration", ";", "}", "}" ]
Returns the model for the specified object. @param string $objectName @return array|null
[ "Returns", "the", "model", "for", "the", "specified", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L204-L215
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getFormConfiguration
public function getFormConfiguration($objectName, $formName) { $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['forms'][$formName])) { $formConfiguration = $modelConfiguration['forms'][$formName]; foreach ($formConfiguration['fields'] as $i => $formField) { $fieldConfiguration = $this->getField($objectName, $formField['name'], false); if (isset($fieldConfiguration['form_defaults'])) { $formConfiguration['fields'][$i] = array_replace_recursive($fieldConfiguration['form_defaults'], $formField); } } usort($formConfiguration['fields'], array($this, 'sortByLocation')); return $formConfiguration; } }
php
public function getFormConfiguration($objectName, $formName) { $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['forms'][$formName])) { $formConfiguration = $modelConfiguration['forms'][$formName]; foreach ($formConfiguration['fields'] as $i => $formField) { $fieldConfiguration = $this->getField($objectName, $formField['name'], false); if (isset($fieldConfiguration['form_defaults'])) { $formConfiguration['fields'][$i] = array_replace_recursive($fieldConfiguration['form_defaults'], $formField); } } usort($formConfiguration['fields'], array($this, 'sortByLocation')); return $formConfiguration; } }
[ "public", "function", "getFormConfiguration", "(", "$", "objectName", ",", "$", "formName", ")", "{", "$", "modelConfiguration", "=", "$", "this", "->", "getModelConfiguration", "(", "$", "objectName", ")", ";", "if", "(", "isset", "(", "$", "modelConfiguration", "[", "'forms'", "]", "[", "$", "formName", "]", ")", ")", "{", "$", "formConfiguration", "=", "$", "modelConfiguration", "[", "'forms'", "]", "[", "$", "formName", "]", ";", "foreach", "(", "$", "formConfiguration", "[", "'fields'", "]", "as", "$", "i", "=>", "$", "formField", ")", "{", "$", "fieldConfiguration", "=", "$", "this", "->", "getField", "(", "$", "objectName", ",", "$", "formField", "[", "'name'", "]", ",", "false", ")", ";", "if", "(", "isset", "(", "$", "fieldConfiguration", "[", "'form_defaults'", "]", ")", ")", "{", "$", "formConfiguration", "[", "'fields'", "]", "[", "$", "i", "]", "=", "array_replace_recursive", "(", "$", "fieldConfiguration", "[", "'form_defaults'", "]", ",", "$", "formField", ")", ";", "}", "}", "usort", "(", "$", "formConfiguration", "[", "'fields'", "]", ",", "array", "(", "$", "this", ",", "'sortByLocation'", ")", ")", ";", "return", "$", "formConfiguration", ";", "}", "}" ]
Returns field configuration of the specified form in the object. @param string $objectName @param string $formName @return array
[ "Returns", "field", "configuration", "of", "the", "specified", "form", "in", "the", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L225-L241
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getViewConfiguration
public function getViewConfiguration($objectName, $viewName) { $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['views'][$viewName])) { $viewConfiguration = $modelConfiguration['views'][$viewName]; if (isset($viewConfiguration['fields']) === false) { $viewConfiguration['fields'] = array(); } foreach ($viewConfiguration['fields'] as $i => $viewField) { $fieldConfiguration = $this->getField($objectName, $viewField['name'], false); if (is_array($fieldConfiguration)) { $viewConfiguration['fields'][$i] = array_replace_recursive($fieldConfiguration, $viewField); } } usort($viewConfiguration['fields'], array($this, 'sortByLocation')); return $viewConfiguration; } }
php
public function getViewConfiguration($objectName, $viewName) { $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['views'][$viewName])) { $viewConfiguration = $modelConfiguration['views'][$viewName]; if (isset($viewConfiguration['fields']) === false) { $viewConfiguration['fields'] = array(); } foreach ($viewConfiguration['fields'] as $i => $viewField) { $fieldConfiguration = $this->getField($objectName, $viewField['name'], false); if (is_array($fieldConfiguration)) { $viewConfiguration['fields'][$i] = array_replace_recursive($fieldConfiguration, $viewField); } } usort($viewConfiguration['fields'], array($this, 'sortByLocation')); return $viewConfiguration; } }
[ "public", "function", "getViewConfiguration", "(", "$", "objectName", ",", "$", "viewName", ")", "{", "$", "modelConfiguration", "=", "$", "this", "->", "getModelConfiguration", "(", "$", "objectName", ")", ";", "if", "(", "isset", "(", "$", "modelConfiguration", "[", "'views'", "]", "[", "$", "viewName", "]", ")", ")", "{", "$", "viewConfiguration", "=", "$", "modelConfiguration", "[", "'views'", "]", "[", "$", "viewName", "]", ";", "if", "(", "isset", "(", "$", "viewConfiguration", "[", "'fields'", "]", ")", "===", "false", ")", "{", "$", "viewConfiguration", "[", "'fields'", "]", "=", "array", "(", ")", ";", "}", "foreach", "(", "$", "viewConfiguration", "[", "'fields'", "]", "as", "$", "i", "=>", "$", "viewField", ")", "{", "$", "fieldConfiguration", "=", "$", "this", "->", "getField", "(", "$", "objectName", ",", "$", "viewField", "[", "'name'", "]", ",", "false", ")", ";", "if", "(", "is_array", "(", "$", "fieldConfiguration", ")", ")", "{", "$", "viewConfiguration", "[", "'fields'", "]", "[", "$", "i", "]", "=", "array_replace_recursive", "(", "$", "fieldConfiguration", ",", "$", "viewField", ")", ";", "}", "}", "usort", "(", "$", "viewConfiguration", "[", "'fields'", "]", ",", "array", "(", "$", "this", ",", "'sortByLocation'", ")", ")", ";", "return", "$", "viewConfiguration", ";", "}", "}" ]
Returns field configuration of the specified view in the object. @param string $objectName @param string $viewName @return array|null
[ "Returns", "field", "configuration", "of", "the", "specified", "view", "in", "the", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L251-L270
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getViewConfigurationsByViewgroupOfView
public function getViewConfigurationsByViewgroupOfView($objectName, $viewName) { $viewConfigurations = array(); $modelConfiguration = $this->getModelConfiguration($objectName); $viewConfiguration = $this->getViewConfiguration($objectName, $viewName); if (isset($viewConfiguration['viewgroup'])) { $viewgroup = $viewConfiguration['viewgroup']; foreach ($modelConfiguration['views'] as $viewName => $viewConfiguration) { if (isset($viewConfiguration['viewgroup']) && $viewConfiguration['viewgroup'] == $viewgroup) { $viewConfigurations[$viewName] = $this->getViewConfiguration($objectName, $viewName); } } } return $viewConfigurations; }
php
public function getViewConfigurationsByViewgroupOfView($objectName, $viewName) { $viewConfigurations = array(); $modelConfiguration = $this->getModelConfiguration($objectName); $viewConfiguration = $this->getViewConfiguration($objectName, $viewName); if (isset($viewConfiguration['viewgroup'])) { $viewgroup = $viewConfiguration['viewgroup']; foreach ($modelConfiguration['views'] as $viewName => $viewConfiguration) { if (isset($viewConfiguration['viewgroup']) && $viewConfiguration['viewgroup'] == $viewgroup) { $viewConfigurations[$viewName] = $this->getViewConfiguration($objectName, $viewName); } } } return $viewConfigurations; }
[ "public", "function", "getViewConfigurationsByViewgroupOfView", "(", "$", "objectName", ",", "$", "viewName", ")", "{", "$", "viewConfigurations", "=", "array", "(", ")", ";", "$", "modelConfiguration", "=", "$", "this", "->", "getModelConfiguration", "(", "$", "objectName", ")", ";", "$", "viewConfiguration", "=", "$", "this", "->", "getViewConfiguration", "(", "$", "objectName", ",", "$", "viewName", ")", ";", "if", "(", "isset", "(", "$", "viewConfiguration", "[", "'viewgroup'", "]", ")", ")", "{", "$", "viewgroup", "=", "$", "viewConfiguration", "[", "'viewgroup'", "]", ";", "foreach", "(", "$", "modelConfiguration", "[", "'views'", "]", "as", "$", "viewName", "=>", "$", "viewConfiguration", ")", "{", "if", "(", "isset", "(", "$", "viewConfiguration", "[", "'viewgroup'", "]", ")", "&&", "$", "viewConfiguration", "[", "'viewgroup'", "]", "==", "$", "viewgroup", ")", "{", "$", "viewConfigurations", "[", "$", "viewName", "]", "=", "$", "this", "->", "getViewConfiguration", "(", "$", "objectName", ",", "$", "viewName", ")", ";", "}", "}", "}", "return", "$", "viewConfigurations", ";", "}" ]
Returns all the field configurations of views in the viewgroup of the specified view name. @param string $objectName @param string $viewName @return array
[ "Returns", "all", "the", "field", "configurations", "of", "views", "in", "the", "viewgroup", "of", "the", "specified", "view", "name", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L280-L296
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getFieldNames
public function getFieldNames($objectName) { $fieldNames = array(); $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['__field_index'])) { $fieldNames = array_keys($modelConfiguration['__field_index']); } return $fieldNames; }
php
public function getFieldNames($objectName) { $fieldNames = array(); $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['__field_index'])) { $fieldNames = array_keys($modelConfiguration['__field_index']); } return $fieldNames; }
[ "public", "function", "getFieldNames", "(", "$", "objectName", ")", "{", "$", "fieldNames", "=", "array", "(", ")", ";", "$", "modelConfiguration", "=", "$", "this", "->", "getModelConfiguration", "(", "$", "objectName", ")", ";", "if", "(", "isset", "(", "$", "modelConfiguration", "[", "'__field_index'", "]", ")", ")", "{", "$", "fieldNames", "=", "array_keys", "(", "$", "modelConfiguration", "[", "'__field_index'", "]", ")", ";", "}", "return", "$", "fieldNames", ";", "}" ]
Returns the field names of the specified object. @return array
[ "Returns", "the", "field", "names", "of", "the", "specified", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L303-L312
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getFieldNamesByView
public function getFieldNamesByView($objectName, $viewName) { $fieldNames = array(); $fieldConfigurations = $this->getFieldsByView($objectName, $viewName); foreach ($fieldConfigurations as $fieldConfiguration) { array_push($fieldNames, $fieldConfiguration['name']); } return $fieldNames; }
php
public function getFieldNamesByView($objectName, $viewName) { $fieldNames = array(); $fieldConfigurations = $this->getFieldsByView($objectName, $viewName); foreach ($fieldConfigurations as $fieldConfiguration) { array_push($fieldNames, $fieldConfiguration['name']); } return $fieldNames; }
[ "public", "function", "getFieldNamesByView", "(", "$", "objectName", ",", "$", "viewName", ")", "{", "$", "fieldNames", "=", "array", "(", ")", ";", "$", "fieldConfigurations", "=", "$", "this", "->", "getFieldsByView", "(", "$", "objectName", ",", "$", "viewName", ")", ";", "foreach", "(", "$", "fieldConfigurations", "as", "$", "fieldConfiguration", ")", "{", "array_push", "(", "$", "fieldNames", ",", "$", "fieldConfiguration", "[", "'name'", "]", ")", ";", "}", "return", "$", "fieldNames", ";", "}" ]
Returns the field names of the specified view in the object. @param string $objectName @param string $viewName @return array
[ "Returns", "the", "field", "names", "of", "the", "specified", "view", "in", "the", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L322-L331
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getFields
public function getFields($objectName) { $fieldConfigurations = array(); $modelConfiguration = $this->getModelConfiguration($objectName); if (is_array($modelConfiguration)) { $fieldConfigurations = $modelConfiguration['fields']; } return $fieldConfigurations; }
php
public function getFields($objectName) { $fieldConfigurations = array(); $modelConfiguration = $this->getModelConfiguration($objectName); if (is_array($modelConfiguration)) { $fieldConfigurations = $modelConfiguration['fields']; } return $fieldConfigurations; }
[ "public", "function", "getFields", "(", "$", "objectName", ")", "{", "$", "fieldConfigurations", "=", "array", "(", ")", ";", "$", "modelConfiguration", "=", "$", "this", "->", "getModelConfiguration", "(", "$", "objectName", ")", ";", "if", "(", "is_array", "(", "$", "modelConfiguration", ")", ")", "{", "$", "fieldConfigurations", "=", "$", "modelConfiguration", "[", "'fields'", "]", ";", "}", "return", "$", "fieldConfigurations", ";", "}" ]
Returns all fields for the object. @param string $objectName @return array
[ "Returns", "all", "fields", "for", "the", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L340-L349
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getFieldsByDatatype
public function getFieldsByDatatype($objectName, $datatype) { $datatypeFieldConfigurations = array(); $fieldConfigurations = $this->getFields($objectName); foreach ($fieldConfigurations as $fieldConfiguration) { if ($fieldConfiguration['datatype'] == $datatype) { $datatypeFieldConfigurations[] = $fieldConfiguration; } } return $datatypeFieldConfigurations; }
php
public function getFieldsByDatatype($objectName, $datatype) { $datatypeFieldConfigurations = array(); $fieldConfigurations = $this->getFields($objectName); foreach ($fieldConfigurations as $fieldConfiguration) { if ($fieldConfiguration['datatype'] == $datatype) { $datatypeFieldConfigurations[] = $fieldConfiguration; } } return $datatypeFieldConfigurations; }
[ "public", "function", "getFieldsByDatatype", "(", "$", "objectName", ",", "$", "datatype", ")", "{", "$", "datatypeFieldConfigurations", "=", "array", "(", ")", ";", "$", "fieldConfigurations", "=", "$", "this", "->", "getFields", "(", "$", "objectName", ")", ";", "foreach", "(", "$", "fieldConfigurations", "as", "$", "fieldConfiguration", ")", "{", "if", "(", "$", "fieldConfiguration", "[", "'datatype'", "]", "==", "$", "datatype", ")", "{", "$", "datatypeFieldConfigurations", "[", "]", "=", "$", "fieldConfiguration", ";", "}", "}", "return", "$", "datatypeFieldConfigurations", ";", "}" ]
Returns all fields with the specified datatype for an object. @param string $objectName @param string $datatype @return array
[ "Returns", "all", "fields", "with", "the", "specified", "datatype", "for", "an", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L359-L371
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getFieldsByView
public function getFieldsByView($objectName, $viewName) { $fieldConfigurations = array(); $viewConfiguration = $this->getViewConfiguration($objectName, $viewName); if (is_array($viewConfiguration)) { $fieldConfigurations = $viewConfiguration["fields"]; foreach ($fieldConfigurations as $i => $fieldConfiguration) { $fieldConfigurations[$i] = array_replace_recursive($this->defaultFieldConfiguration, $fieldConfiguration); } } usort($fieldConfigurations, array($this, 'sortByLocation')); return $fieldConfigurations; }
php
public function getFieldsByView($objectName, $viewName) { $fieldConfigurations = array(); $viewConfiguration = $this->getViewConfiguration($objectName, $viewName); if (is_array($viewConfiguration)) { $fieldConfigurations = $viewConfiguration["fields"]; foreach ($fieldConfigurations as $i => $fieldConfiguration) { $fieldConfigurations[$i] = array_replace_recursive($this->defaultFieldConfiguration, $fieldConfiguration); } } usort($fieldConfigurations, array($this, 'sortByLocation')); return $fieldConfigurations; }
[ "public", "function", "getFieldsByView", "(", "$", "objectName", ",", "$", "viewName", ")", "{", "$", "fieldConfigurations", "=", "array", "(", ")", ";", "$", "viewConfiguration", "=", "$", "this", "->", "getViewConfiguration", "(", "$", "objectName", ",", "$", "viewName", ")", ";", "if", "(", "is_array", "(", "$", "viewConfiguration", ")", ")", "{", "$", "fieldConfigurations", "=", "$", "viewConfiguration", "[", "\"fields\"", "]", ";", "foreach", "(", "$", "fieldConfigurations", "as", "$", "i", "=>", "$", "fieldConfiguration", ")", "{", "$", "fieldConfigurations", "[", "$", "i", "]", "=", "array_replace_recursive", "(", "$", "this", "->", "defaultFieldConfiguration", ",", "$", "fieldConfiguration", ")", ";", "}", "}", "usort", "(", "$", "fieldConfigurations", ",", "array", "(", "$", "this", ",", "'sortByLocation'", ")", ")", ";", "return", "$", "fieldConfigurations", ";", "}" ]
Returns the fields in the object view. @param string $objectName @param string $viewName @return array
[ "Returns", "the", "fields", "in", "the", "object", "view", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L381-L395
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getField
public function getField($objectName, $fieldName, $excludeFormDefaults = true) { $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['__field_index'][$fieldName])) { $fieldConfiguration = array_replace_recursive($this->defaultFieldConfiguration, $modelConfiguration['fields'][$modelConfiguration['__field_index'][$fieldName]]); if ($excludeFormDefaults && isset($fieldConfiguration['form_defaults'])) { unset($fieldConfiguration["form_defaults"]); } return $fieldConfiguration; } }
php
public function getField($objectName, $fieldName, $excludeFormDefaults = true) { $modelConfiguration = $this->getModelConfiguration($objectName); if (isset($modelConfiguration['__field_index'][$fieldName])) { $fieldConfiguration = array_replace_recursive($this->defaultFieldConfiguration, $modelConfiguration['fields'][$modelConfiguration['__field_index'][$fieldName]]); if ($excludeFormDefaults && isset($fieldConfiguration['form_defaults'])) { unset($fieldConfiguration["form_defaults"]); } return $fieldConfiguration; } }
[ "public", "function", "getField", "(", "$", "objectName", ",", "$", "fieldName", ",", "$", "excludeFormDefaults", "=", "true", ")", "{", "$", "modelConfiguration", "=", "$", "this", "->", "getModelConfiguration", "(", "$", "objectName", ")", ";", "if", "(", "isset", "(", "$", "modelConfiguration", "[", "'__field_index'", "]", "[", "$", "fieldName", "]", ")", ")", "{", "$", "fieldConfiguration", "=", "array_replace_recursive", "(", "$", "this", "->", "defaultFieldConfiguration", ",", "$", "modelConfiguration", "[", "'fields'", "]", "[", "$", "modelConfiguration", "[", "'__field_index'", "]", "[", "$", "fieldName", "]", "]", ")", ";", "if", "(", "$", "excludeFormDefaults", "&&", "isset", "(", "$", "fieldConfiguration", "[", "'form_defaults'", "]", ")", ")", "{", "unset", "(", "$", "fieldConfiguration", "[", "\"form_defaults\"", "]", ")", ";", "}", "return", "$", "fieldConfiguration", ";", "}", "}" ]
Returns the configuration of a field in the specified object. @param string $objectName @param string $fieldName @return array|null
[ "Returns", "the", "configuration", "of", "a", "field", "in", "the", "specified", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L405-L416
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.getReferencedField
public function getReferencedField($objectName, $fieldName, array & $excludedFieldNameParts = array(), $objectReferencesOnly = true) { $foundFieldName = null; $fieldNameParts = explode('_', $fieldName); $excludedFieldNameParts = array(); $initial = false; while (count($fieldNameParts) > 0) { if ($initial === true) { array_unshift($excludedFieldNameParts, array_pop($fieldNameParts)); } $fieldName = implode("_", $fieldNameParts); if ($this->hasField($objectName, $fieldName)) { $foundFieldName = $fieldName; break; } $initial = true; } if (!empty($foundFieldName) && is_array($fieldConfiguration = $this->getField($objectName, $foundFieldName)) && ($objectReferencesOnly === false || $this->isObjectReference($fieldConfiguration['datatype']))) { return $fieldConfiguration; } }
php
public function getReferencedField($objectName, $fieldName, array & $excludedFieldNameParts = array(), $objectReferencesOnly = true) { $foundFieldName = null; $fieldNameParts = explode('_', $fieldName); $excludedFieldNameParts = array(); $initial = false; while (count($fieldNameParts) > 0) { if ($initial === true) { array_unshift($excludedFieldNameParts, array_pop($fieldNameParts)); } $fieldName = implode("_", $fieldNameParts); if ($this->hasField($objectName, $fieldName)) { $foundFieldName = $fieldName; break; } $initial = true; } if (!empty($foundFieldName) && is_array($fieldConfiguration = $this->getField($objectName, $foundFieldName)) && ($objectReferencesOnly === false || $this->isObjectReference($fieldConfiguration['datatype']))) { return $fieldConfiguration; } }
[ "public", "function", "getReferencedField", "(", "$", "objectName", ",", "$", "fieldName", ",", "array", "&", "$", "excludedFieldNameParts", "=", "array", "(", ")", ",", "$", "objectReferencesOnly", "=", "true", ")", "{", "$", "foundFieldName", "=", "null", ";", "$", "fieldNameParts", "=", "explode", "(", "'_'", ",", "$", "fieldName", ")", ";", "$", "excludedFieldNameParts", "=", "array", "(", ")", ";", "$", "initial", "=", "false", ";", "while", "(", "count", "(", "$", "fieldNameParts", ")", ">", "0", ")", "{", "if", "(", "$", "initial", "===", "true", ")", "{", "array_unshift", "(", "$", "excludedFieldNameParts", ",", "array_pop", "(", "$", "fieldNameParts", ")", ")", ";", "}", "$", "fieldName", "=", "implode", "(", "\"_\"", ",", "$", "fieldNameParts", ")", ";", "if", "(", "$", "this", "->", "hasField", "(", "$", "objectName", ",", "$", "fieldName", ")", ")", "{", "$", "foundFieldName", "=", "$", "fieldName", ";", "break", ";", "}", "$", "initial", "=", "true", ";", "}", "if", "(", "!", "empty", "(", "$", "foundFieldName", ")", "&&", "is_array", "(", "$", "fieldConfiguration", "=", "$", "this", "->", "getField", "(", "$", "objectName", ",", "$", "foundFieldName", ")", ")", "&&", "(", "$", "objectReferencesOnly", "===", "false", "||", "$", "this", "->", "isObjectReference", "(", "$", "fieldConfiguration", "[", "'datatype'", "]", ")", ")", ")", "{", "return", "$", "fieldConfiguration", ";", "}", "}" ]
Returns the field reference of the specified object. The returned excluded field name parts can be used to retrieve the field for the referenced object. @param string $objectName @param string $fieldName @param array $excludedFieldNameParts @param bool $objectReferencesOnly @return array|null
[ "Returns", "the", "field", "reference", "of", "the", "specified", "object", ".", "The", "returned", "excluded", "field", "name", "parts", "can", "be", "used", "to", "retrieve", "the", "field", "for", "the", "referenced", "object", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L429-L452
train
FlexModel/FlexModel
src/FlexModel.php
FlexModel.generateCacheFile
private function generateCacheFile() { $previousErrorSetting = libxml_use_internal_errors(true); libxml_clear_errors(); if (@$this->domDocument->schemaValidate($this->xmlSchemaFile)) { $this->domDocument->preserveWhiteSpace = false; // Reload the XML to strip whitespace from XIncluded XML. $this->domDocument->loadXML($this->domDocument->saveXML()); $xslDocument = new DOMDocument('1.0', 'UTF-8'); $xslDocument->load(__DIR__.'/Resources/xsl/flexmodel-cache.xsl'); $processor = new XSLTProcessor(); $processor->setParameter('', 'checksum', md5($this->domDocument->saveXML())); $processor->importStyleSheet($xslDocument); $processor->registerPHPFunctions(); $configuration = $processor->transformToXML($this->domDocument); file_put_contents($this->getCacheFile(), $configuration); $this->loadConfiguration(false); } else { $errors = libxml_get_errors(); foreach ($errors as $error) { trigger_error(sprintf('Line %s: %s in "%s"', $error->line, trim($error->message), $error->file), E_USER_WARNING); } libxml_clear_errors(); } libxml_use_internal_errors($previousErrorSetting); }
php
private function generateCacheFile() { $previousErrorSetting = libxml_use_internal_errors(true); libxml_clear_errors(); if (@$this->domDocument->schemaValidate($this->xmlSchemaFile)) { $this->domDocument->preserveWhiteSpace = false; // Reload the XML to strip whitespace from XIncluded XML. $this->domDocument->loadXML($this->domDocument->saveXML()); $xslDocument = new DOMDocument('1.0', 'UTF-8'); $xslDocument->load(__DIR__.'/Resources/xsl/flexmodel-cache.xsl'); $processor = new XSLTProcessor(); $processor->setParameter('', 'checksum', md5($this->domDocument->saveXML())); $processor->importStyleSheet($xslDocument); $processor->registerPHPFunctions(); $configuration = $processor->transformToXML($this->domDocument); file_put_contents($this->getCacheFile(), $configuration); $this->loadConfiguration(false); } else { $errors = libxml_get_errors(); foreach ($errors as $error) { trigger_error(sprintf('Line %s: %s in "%s"', $error->line, trim($error->message), $error->file), E_USER_WARNING); } libxml_clear_errors(); } libxml_use_internal_errors($previousErrorSetting); }
[ "private", "function", "generateCacheFile", "(", ")", "{", "$", "previousErrorSetting", "=", "libxml_use_internal_errors", "(", "true", ")", ";", "libxml_clear_errors", "(", ")", ";", "if", "(", "@", "$", "this", "->", "domDocument", "->", "schemaValidate", "(", "$", "this", "->", "xmlSchemaFile", ")", ")", "{", "$", "this", "->", "domDocument", "->", "preserveWhiteSpace", "=", "false", ";", "// Reload the XML to strip whitespace from XIncluded XML.", "$", "this", "->", "domDocument", "->", "loadXML", "(", "$", "this", "->", "domDocument", "->", "saveXML", "(", ")", ")", ";", "$", "xslDocument", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "xslDocument", "->", "load", "(", "__DIR__", ".", "'/Resources/xsl/flexmodel-cache.xsl'", ")", ";", "$", "processor", "=", "new", "XSLTProcessor", "(", ")", ";", "$", "processor", "->", "setParameter", "(", "''", ",", "'checksum'", ",", "md5", "(", "$", "this", "->", "domDocument", "->", "saveXML", "(", ")", ")", ")", ";", "$", "processor", "->", "importStyleSheet", "(", "$", "xslDocument", ")", ";", "$", "processor", "->", "registerPHPFunctions", "(", ")", ";", "$", "configuration", "=", "$", "processor", "->", "transformToXML", "(", "$", "this", "->", "domDocument", ")", ";", "file_put_contents", "(", "$", "this", "->", "getCacheFile", "(", ")", ",", "$", "configuration", ")", ";", "$", "this", "->", "loadConfiguration", "(", "false", ")", ";", "}", "else", "{", "$", "errors", "=", "libxml_get_errors", "(", ")", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "trigger_error", "(", "sprintf", "(", "'Line %s: %s in \"%s\"'", ",", "$", "error", "->", "line", ",", "trim", "(", "$", "error", "->", "message", ")", ",", "$", "error", "->", "file", ")", ",", "E_USER_WARNING", ")", ";", "}", "libxml_clear_errors", "(", ")", ";", "}", "libxml_use_internal_errors", "(", "$", "previousErrorSetting", ")", ";", "}" ]
Generates the cache file.
[ "Generates", "the", "cache", "file", "." ]
83368c13a7c8c2cf0ee95b36fe81d84a7129fee2
https://github.com/FlexModel/FlexModel/blob/83368c13a7c8c2cf0ee95b36fe81d84a7129fee2/src/FlexModel.php#L525-L554
train
romm/configuration_object
Classes/Service/Items/Cache/CacheService.php
CacheService.configurationObjectAfter
public function configurationObjectAfter(GetConfigurationObjectDTO $serviceDataTransferObject) { $this->delay( self::PRIORITY_SAVE_OBJECT_IN_CACHE, function (GetConfigurationObjectDTO $serviceDataTransferObject) { $cacheHash = $this->getConfigurationObjectCacheHash($serviceDataTransferObject); if (false === isset($this->configurationObjectsFetchedFromCache[$cacheHash])) { $this->getCacheInstance()->set($cacheHash, $serviceDataTransferObject->getResult()); } } ); }
php
public function configurationObjectAfter(GetConfigurationObjectDTO $serviceDataTransferObject) { $this->delay( self::PRIORITY_SAVE_OBJECT_IN_CACHE, function (GetConfigurationObjectDTO $serviceDataTransferObject) { $cacheHash = $this->getConfigurationObjectCacheHash($serviceDataTransferObject); if (false === isset($this->configurationObjectsFetchedFromCache[$cacheHash])) { $this->getCacheInstance()->set($cacheHash, $serviceDataTransferObject->getResult()); } } ); }
[ "public", "function", "configurationObjectAfter", "(", "GetConfigurationObjectDTO", "$", "serviceDataTransferObject", ")", "{", "$", "this", "->", "delay", "(", "self", "::", "PRIORITY_SAVE_OBJECT_IN_CACHE", ",", "function", "(", "GetConfigurationObjectDTO", "$", "serviceDataTransferObject", ")", "{", "$", "cacheHash", "=", "$", "this", "->", "getConfigurationObjectCacheHash", "(", "$", "serviceDataTransferObject", ")", ";", "if", "(", "false", "===", "isset", "(", "$", "this", "->", "configurationObjectsFetchedFromCache", "[", "$", "cacheHash", "]", ")", ")", "{", "$", "this", "->", "getCacheInstance", "(", ")", "->", "set", "(", "$", "cacheHash", ",", "$", "serviceDataTransferObject", "->", "getResult", "(", ")", ")", ";", "}", "}", ")", ";", "}" ]
After a configuration object has been built, it is stored in the cache. @param GetConfigurationObjectDTO $serviceDataTransferObject
[ "After", "a", "configuration", "object", "has", "been", "built", "it", "is", "stored", "in", "the", "cache", "." ]
d3a40903386c2e0766bd8279337fe6da45cf5ce3
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/Items/Cache/CacheService.php#L161-L173
train
libreworks/caridea-validate
src/Rule/Set.php
Set.add
public function add(\Caridea\Validate\Rule ...$rules): self { $this->rules = array_merge($this->rules, $rules); return $this; }
php
public function add(\Caridea\Validate\Rule ...$rules): self { $this->rules = array_merge($this->rules, $rules); return $this; }
[ "public", "function", "add", "(", "\\", "Caridea", "\\", "Validate", "\\", "Rule", "...", "$", "rules", ")", ":", "self", "{", "$", "this", "->", "rules", "=", "array_merge", "(", "$", "this", "->", "rules", ",", "$", "rules", ")", ";", "return", "$", "this", ";", "}" ]
Adds one or more `Rule`s into this `Set`. @param \Caridea\Validate\Rule ...$rules The rules to add @return $this Provides a fluent interface
[ "Adds", "one", "or", "more", "Rule", "s", "into", "this", "Set", "." ]
625835694d34591bfb1e3b2ce60c2cc28a28d006
https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Rule/Set.php#L59-L63
train
libreworks/caridea-validate
src/Rule/Set.php
Set.addAll
public function addAll(array $rules): self { try { return $this->add(...$rules); } catch (\TypeError $e) { throw new \InvalidArgumentException('Only Rule objects are allowed', 0, $e); } }
php
public function addAll(array $rules): self { try { return $this->add(...$rules); } catch (\TypeError $e) { throw new \InvalidArgumentException('Only Rule objects are allowed', 0, $e); } }
[ "public", "function", "addAll", "(", "array", "$", "rules", ")", ":", "self", "{", "try", "{", "return", "$", "this", "->", "add", "(", "...", "$", "rules", ")", ";", "}", "catch", "(", "\\", "TypeError", "$", "e", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Only Rule objects are allowed'", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Adds several `Rule`s into this `Set`. @param \Caridea\Validate\Rule[] $rules The rules to add @return $this Provides a fluent interface @throws \InvalidArgumentException if `$rules` contains invalid types
[ "Adds", "several", "Rule", "s", "into", "this", "Set", "." ]
625835694d34591bfb1e3b2ce60c2cc28a28d006
https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Rule/Set.php#L72-L79
train
libreworks/caridea-validate
src/Rule/Set.php
Set.merge
public function merge(Set $rules): self { $this->rules = array_merge($this->rules, $rules->rules); return $this; }
php
public function merge(Set $rules): self { $this->rules = array_merge($this->rules, $rules->rules); return $this; }
[ "public", "function", "merge", "(", "Set", "$", "rules", ")", ":", "self", "{", "$", "this", "->", "rules", "=", "array_merge", "(", "$", "this", "->", "rules", ",", "$", "rules", "->", "rules", ")", ";", "return", "$", "this", ";", "}" ]
Adds the entries from another `Set` into this one. @param \Caridea\Validate\Rule\Set $rules The rules to add @return $this Provides a fluent interface
[ "Adds", "the", "entries", "from", "another", "Set", "into", "this", "one", "." ]
625835694d34591bfb1e3b2ce60c2cc28a28d006
https://github.com/libreworks/caridea-validate/blob/625835694d34591bfb1e3b2ce60c2cc28a28d006/src/Rule/Set.php#L87-L91
train
vanilla/garden-daemon
src/Daemon.php
Daemon.initializeDaemon
protected function initializeDaemon() { declare (ticks = 100); // Install signal handlers pcntl_signal(SIGHUP, [$this, 'handleSignal']); pcntl_signal(SIGINT, [$this, 'handleSignal']); pcntl_signal(SIGTERM, [$this, 'handleSignal']); pcntl_signal(SIGCHLD, [$this, 'handleSignal']); pcntl_signal(SIGUSR1, [$this, 'handleSignal']); pcntl_signal(SIGUSR2, [$this, 'handleSignal']); }
php
protected function initializeDaemon() { declare (ticks = 100); // Install signal handlers pcntl_signal(SIGHUP, [$this, 'handleSignal']); pcntl_signal(SIGINT, [$this, 'handleSignal']); pcntl_signal(SIGTERM, [$this, 'handleSignal']); pcntl_signal(SIGCHLD, [$this, 'handleSignal']); pcntl_signal(SIGUSR1, [$this, 'handleSignal']); pcntl_signal(SIGUSR2, [$this, 'handleSignal']); }
[ "protected", "function", "initializeDaemon", "(", ")", "{", "declare", "(", "ticks", "=", "100", ")", ";", "// Install signal handlers", "pcntl_signal", "(", "SIGHUP", ",", "[", "$", "this", ",", "'handleSignal'", "]", ")", ";", "pcntl_signal", "(", "SIGINT", ",", "[", "$", "this", ",", "'handleSignal'", "]", ")", ";", "pcntl_signal", "(", "SIGTERM", ",", "[", "$", "this", ",", "'handleSignal'", "]", ")", ";", "pcntl_signal", "(", "SIGCHLD", ",", "[", "$", "this", ",", "'handleSignal'", "]", ")", ";", "pcntl_signal", "(", "SIGUSR1", ",", "[", "$", "this", ",", "'handleSignal'", "]", ")", ";", "pcntl_signal", "(", "SIGUSR2", ",", "[", "$", "this", ",", "'handleSignal'", "]", ")", ";", "}" ]
Post-daemonize initialization
[ "Post", "-", "daemonize", "initialization" ]
13a5cbbac08ab6473e4b11bf00179fe1e26235a6
https://github.com/vanilla/garden-daemon/blob/13a5cbbac08ab6473e4b11bf00179fe1e26235a6/src/Daemon.php#L474-L484
train
vanilla/garden-daemon
src/Daemon.php
Daemon.getPayloadInstance
protected function getPayloadInstance(): AppInterface { if (!($this->instance instanceof AppInterface)) { $appName = $this->get('appname', null); $appNamespace = $this->get('appnamespace', null); // Run App $appClassName = ucfirst($appName); if (!is_null($appNamespace)) { $appClassName = "\\{$appNamespace}\\{$appClassName}"; } $this->instance = $this->di->get($appClassName); } return $this->instance; }
php
protected function getPayloadInstance(): AppInterface { if (!($this->instance instanceof AppInterface)) { $appName = $this->get('appname', null); $appNamespace = $this->get('appnamespace', null); // Run App $appClassName = ucfirst($appName); if (!is_null($appNamespace)) { $appClassName = "\\{$appNamespace}\\{$appClassName}"; } $this->instance = $this->di->get($appClassName); } return $this->instance; }
[ "protected", "function", "getPayloadInstance", "(", ")", ":", "AppInterface", "{", "if", "(", "!", "(", "$", "this", "->", "instance", "instanceof", "AppInterface", ")", ")", "{", "$", "appName", "=", "$", "this", "->", "get", "(", "'appname'", ",", "null", ")", ";", "$", "appNamespace", "=", "$", "this", "->", "get", "(", "'appnamespace'", ",", "null", ")", ";", "// Run App", "$", "appClassName", "=", "ucfirst", "(", "$", "appName", ")", ";", "if", "(", "!", "is_null", "(", "$", "appNamespace", ")", ")", "{", "$", "appClassName", "=", "\"\\\\{$appNamespace}\\\\{$appClassName}\"", ";", "}", "$", "this", "->", "instance", "=", "$", "this", "->", "di", "->", "get", "(", "$", "appClassName", ")", ";", "}", "return", "$", "this", "->", "instance", ";", "}" ]
Get an instance of the app @return AppInterface
[ "Get", "an", "instance", "of", "the", "app" ]
13a5cbbac08ab6473e4b11bf00179fe1e26235a6
https://github.com/vanilla/garden-daemon/blob/13a5cbbac08ab6473e4b11bf00179fe1e26235a6/src/Daemon.php#L491-L505
train
vanilla/garden-daemon
src/Daemon.php
Daemon.payloadExec
protected function payloadExec($method, $args = []) { $this->getPayloadInstance(); if (method_exists($this->instance, $method)) { return $this->di->call([$this->instance, $method], $args); } return null; }
php
protected function payloadExec($method, $args = []) { $this->getPayloadInstance(); if (method_exists($this->instance, $method)) { return $this->di->call([$this->instance, $method], $args); } return null; }
[ "protected", "function", "payloadExec", "(", "$", "method", ",", "$", "args", "=", "[", "]", ")", "{", "$", "this", "->", "getPayloadInstance", "(", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "instance", ",", "$", "method", ")", ")", "{", "return", "$", "this", "->", "di", "->", "call", "(", "[", "$", "this", "->", "instance", ",", "$", "method", "]", ",", "$", "args", ")", ";", "}", "return", "null", ";", "}" ]
Execute callback on payload @param string $method @param mixed $args @return mixed
[ "Execute", "callback", "on", "payload" ]
13a5cbbac08ab6473e4b11bf00179fe1e26235a6
https://github.com/vanilla/garden-daemon/blob/13a5cbbac08ab6473e4b11bf00179fe1e26235a6/src/Daemon.php#L514-L520
train