id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
17,900
ClanCats/Core
src/classes/CCFinder.php
CCFinder.map
public static function map( $name, $path = null ) { if ( is_array( $name ) ) { static::$namespaces = array_merge( static::$namespaces, $name ); return; } static::$namespaces[$name] = $path; }
php
public static function map( $name, $path = null ) { if ( is_array( $name ) ) { static::$namespaces = array_merge( static::$namespaces, $name ); return; } static::$namespaces[$name] = $path; }
[ "public", "static", "function", "map", "(", "$", "name", ",", "$", "path", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "static", "::", "$", "namespaces", "=", "array_merge", "(", "static", "::", "$", "namespaces", ",", "$", "name", ")", ";", "return", ";", "}", "static", "::", "$", "namespaces", "[", "$", "name", "]", "=", "$", "path", ";", "}" ]
Add one or more maps A map is simply a class namepsace @param string|array $name @param path $path @return void
[ "Add", "one", "or", "more", "maps", "A", "map", "is", "simply", "a", "class", "namepsace" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFinder.php#L82-L89
17,901
ClanCats/Core
src/classes/CCFinder.php
CCFinder.shadow
public static function shadow( $name, $namespace, $path = null ) { static::$shadows[$name] = $class = $namespace."\\".$name; if ( !is_null( $path ) ) { static::bind( $name, $class ); } }
php
public static function shadow( $name, $namespace, $path = null ) { static::$shadows[$name] = $class = $namespace."\\".$name; if ( !is_null( $path ) ) { static::bind( $name, $class ); } }
[ "public", "static", "function", "shadow", "(", "$", "name", ",", "$", "namespace", ",", "$", "path", "=", "null", ")", "{", "static", "::", "$", "shadows", "[", "$", "name", "]", "=", "$", "class", "=", "$", "namespace", ".", "\"\\\\\"", ".", "$", "name", ";", "if", "(", "!", "is_null", "(", "$", "path", ")", ")", "{", "static", "::", "bind", "(", "$", "name", ",", "$", "class", ")", ";", "}", "}" ]
Add a shadow class A shadow class is a global class and gets liftet to the global namespace. \Some\Longer\Namespace\Foo::bar() -> Foo::bar() exmpale: CCFinder::shadow( 'Foo', 'Some\Longer\Namespace', 'myclasses/Foo.php' ); @param string $name The shadow @param string $namespace The real class namespace @param string $path The path of the real class @return void
[ "Add", "a", "shadow", "class", "A", "shadow", "class", "is", "a", "global", "class", "and", "gets", "liftet", "to", "the", "global", "namespace", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFinder.php#L105-L113
17,902
ClanCats/Core
src/classes/CCFinder.php
CCFinder.alias
public static function alias( $name, $path = null ) { if ( is_array( $name ) ) { static::$aliases = array_merge( static::$aliases, $name ); return; } static::$aliases[$name] = $path; }
php
public static function alias( $name, $path = null ) { if ( is_array( $name ) ) { static::$aliases = array_merge( static::$aliases, $name ); return; } static::$aliases[$name] = $path; }
[ "public", "static", "function", "alias", "(", "$", "name", ",", "$", "path", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "static", "::", "$", "aliases", "=", "array_merge", "(", "static", "::", "$", "aliases", ",", "$", "name", ")", ";", "return", ";", "}", "static", "::", "$", "aliases", "[", "$", "name", "]", "=", "$", "path", ";", "}" ]
Add one or more aliases An alias can overwrite an shadow. This way we can extend other classes. example: CCFinder::alias( 'Foo', '/path/to/my/Foo.php' ); @param string $name @param path $path @return void
[ "Add", "one", "or", "more", "aliases", "An", "alias", "can", "overwrite", "an", "shadow", ".", "This", "way", "we", "can", "extend", "other", "classes", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFinder.php#L126-L133
17,903
ClanCats/Core
src/classes/CCFinder.php
CCFinder.bind
public static function bind( $name, $path = null ) { if ( is_array( $name ) ) { static::$classes = array_merge( static::$classes, $name ); return; } static::$classes[$name] = $path; }
php
public static function bind( $name, $path = null ) { if ( is_array( $name ) ) { static::$classes = array_merge( static::$classes, $name ); return; } static::$classes[$name] = $path; }
[ "public", "static", "function", "bind", "(", "$", "name", ",", "$", "path", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "static", "::", "$", "classes", "=", "array_merge", "(", "static", "::", "$", "classes", ",", "$", "name", ")", ";", "return", ";", "}", "static", "::", "$", "classes", "[", "$", "name", "]", "=", "$", "path", ";", "}" ]
Add one or more class to the autoloader @param string $name @param path $path @return void
[ "Add", "one", "or", "more", "class", "to", "the", "autoloader" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFinder.php#L142-L149
17,904
ClanCats/Core
src/classes/CCFinder.php
CCFinder.package
public static function package( $dir, $classes ) { foreach( $classes as $name => $path ) { static::$classes[$name] = $dir.$path; } }
php
public static function package( $dir, $classes ) { foreach( $classes as $name => $path ) { static::$classes[$name] = $dir.$path; } }
[ "public", "static", "function", "package", "(", "$", "dir", ",", "$", "classes", ")", "{", "foreach", "(", "$", "classes", "as", "$", "name", "=>", "$", "path", ")", "{", "static", "::", "$", "classes", "[", "$", "name", "]", "=", "$", "dir", ".", "$", "path", ";", "}", "}" ]
This simply adds some classes with a prefix @param string $name @param path $path @return void
[ "This", "simply", "adds", "some", "classes", "with", "a", "prefix" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFinder.php#L159-L165
17,905
ClanCats/Core
src/classes/CCFinder.php
CCFinder.shadow_package
public static function shadow_package( $dir, $namespace, $shadows ) { foreach( $shadows as $name => $path ) { static::$shadows[$name] = $class = $namespace."\\".$name; static::$classes[$class] = $dir.$path; } }
php
public static function shadow_package( $dir, $namespace, $shadows ) { foreach( $shadows as $name => $path ) { static::$shadows[$name] = $class = $namespace."\\".$name; static::$classes[$class] = $dir.$path; } }
[ "public", "static", "function", "shadow_package", "(", "$", "dir", ",", "$", "namespace", ",", "$", "shadows", ")", "{", "foreach", "(", "$", "shadows", "as", "$", "name", "=>", "$", "path", ")", "{", "static", "::", "$", "shadows", "[", "$", "name", "]", "=", "$", "class", "=", "$", "namespace", ".", "\"\\\\\"", ".", "$", "name", ";", "static", "::", "$", "classes", "[", "$", "class", "]", "=", "$", "dir", ".", "$", "path", ";", "}", "}" ]
This simply adds some shadows with a prefix @param string $name @param path $path @return void
[ "This", "simply", "adds", "some", "shadows", "with", "a", "prefix" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFinder.php#L175-L182
17,906
Double-Opt-in/php-client-api
src/Client/Commands/LogCommand.php
LogCommand.setData
public function setData($data, $key = null) { if (is_array($data) && $key === null) { $this->data = $data; return $this; } if ($key === null) $key = 'data'; $this->data[$key] = $data; return $this; }
php
public function setData($data, $key = null) { if (is_array($data) && $key === null) { $this->data = $data; return $this; } if ($key === null) $key = 'data'; $this->data[$key] = $data; return $this; }
[ "public", "function", "setData", "(", "$", "data", ",", "$", "key", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", "&&", "$", "key", "===", "null", ")", "{", "$", "this", "->", "data", "=", "$", "data", ";", "return", "$", "this", ";", "}", "if", "(", "$", "key", "===", "null", ")", "$", "key", "=", "'data'", ";", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "data", ";", "return", "$", "this", ";", "}" ]
setting data to add for the logging action we suggest setting an array @param array|mixed $data @param null $key @return $this
[ "setting", "data", "to", "add", "for", "the", "logging", "action" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/LogCommand.php#L101-L115
17,907
Double-Opt-in/php-client-api
src/Client/Commands/LogCommand.php
LogCommand.body
public function body(CryptographyEngine $cryptographyEngine) { $body = array( 'hash' => $cryptographyEngine->hash($this->email), 'action' => $this->action, ); if ( ! empty($this->scope)) $body['scope'] = $this->scope; if ( ! empty($this->data)) $body['data'] = $cryptographyEngine->encrypt(json_encode($this->data), $this->email); // add overwriting data when possible if ( ! empty($this->ip)) $body['ip'] = $this->ip; if ( ! empty($this->useragent)) $body['useragent'] = $this->useragent; if ( ! empty($this->created_at)) $body['created_at'] = $this->created_at; return json_encode($body); }
php
public function body(CryptographyEngine $cryptographyEngine) { $body = array( 'hash' => $cryptographyEngine->hash($this->email), 'action' => $this->action, ); if ( ! empty($this->scope)) $body['scope'] = $this->scope; if ( ! empty($this->data)) $body['data'] = $cryptographyEngine->encrypt(json_encode($this->data), $this->email); // add overwriting data when possible if ( ! empty($this->ip)) $body['ip'] = $this->ip; if ( ! empty($this->useragent)) $body['useragent'] = $this->useragent; if ( ! empty($this->created_at)) $body['created_at'] = $this->created_at; return json_encode($body); }
[ "public", "function", "body", "(", "CryptographyEngine", "$", "cryptographyEngine", ")", "{", "$", "body", "=", "array", "(", "'hash'", "=>", "$", "cryptographyEngine", "->", "hash", "(", "$", "this", "->", "email", ")", ",", "'action'", "=>", "$", "this", "->", "action", ",", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "scope", ")", ")", "$", "body", "[", "'scope'", "]", "=", "$", "this", "->", "scope", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "data", ")", ")", "$", "body", "[", "'data'", "]", "=", "$", "cryptographyEngine", "->", "encrypt", "(", "json_encode", "(", "$", "this", "->", "data", ")", ",", "$", "this", "->", "email", ")", ";", "// add overwriting data when possible", "if", "(", "!", "empty", "(", "$", "this", "->", "ip", ")", ")", "$", "body", "[", "'ip'", "]", "=", "$", "this", "->", "ip", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "useragent", ")", ")", "$", "body", "[", "'useragent'", "]", "=", "$", "this", "->", "useragent", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "created_at", ")", ")", "$", "body", "[", "'created_at'", "]", "=", "$", "this", "->", "created_at", ";", "return", "json_encode", "(", "$", "body", ")", ";", "}" ]
returns the body hash: email will be hashed before requesting the server action: action will be transmitted in plain text scope: optional scope will be transmitted in plain text data: optional data will be encrypted before requesting the server @param CryptographyEngine $cryptographyEngine @return array|\Guzzle\Http\EntityBodyInterface|null|resource|string
[ "returns", "the", "body" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/LogCommand.php#L129-L153
17,908
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior.getPath
public function getPath($id) { $node = $this->getNode($id); if (!$node) { return []; } $left = $this->getConfig('leftField'); $right = $this->getConfig('rightField'); return $this->getRepository()->select() ->where($left, '<', $node[$left]) ->where($right, '>', $node[$right]) ->orderBy($left, 'asc') ->all(); }
php
public function getPath($id) { $node = $this->getNode($id); if (!$node) { return []; } $left = $this->getConfig('leftField'); $right = $this->getConfig('rightField'); return $this->getRepository()->select() ->where($left, '<', $node[$left]) ->where($right, '>', $node[$right]) ->orderBy($left, 'asc') ->all(); }
[ "public", "function", "getPath", "(", "$", "id", ")", "{", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "id", ")", ";", "if", "(", "!", "$", "node", ")", "{", "return", "[", "]", ";", "}", "$", "left", "=", "$", "this", "->", "getConfig", "(", "'leftField'", ")", ";", "$", "right", "=", "$", "this", "->", "getConfig", "(", "'rightField'", ")", ";", "return", "$", "this", "->", "getRepository", "(", ")", "->", "select", "(", ")", "->", "where", "(", "$", "left", ",", "'<'", ",", "$", "node", "[", "$", "left", "]", ")", "->", "where", "(", "$", "right", ",", "'>'", ",", "$", "node", "[", "$", "right", "]", ")", "->", "orderBy", "(", "$", "left", ",", "'asc'", ")", "->", "all", "(", ")", ";", "}" ]
Return the hierarchical path to the current node. @param int $id @return \Titon\Db\EntityCollection
[ "Return", "the", "hierarchical", "path", "to", "the", "current", "node", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L145-L160
17,909
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior.getTree
public function getTree($id = null) { $parent = $this->getConfig('parentField'); $left = $this->getConfig('leftField'); $right = $this->getConfig('rightField'); $query = $this->getRepository()->select()->orderBy($left, 'asc'); if ($id) { if ($parentNode = $this->getNode($id)) { $query->where($left, 'between', [$parentNode[$left], $parentNode[$right]]); } else { return []; } } $nodes = $query->all(); if ($nodes->isEmpty()) { return []; } $map = []; $stack = []; $pk = $this->getRepository()->getPrimaryKey(); foreach ($nodes as $node) { if ($node[$parent] && $node[$pk] != $id) { $map[$node[$parent]][] = $node; } else { $stack[] = $node; } } $results = $this->mapTree($stack, $map); if ($id) { return $results[0]; } return $results; }
php
public function getTree($id = null) { $parent = $this->getConfig('parentField'); $left = $this->getConfig('leftField'); $right = $this->getConfig('rightField'); $query = $this->getRepository()->select()->orderBy($left, 'asc'); if ($id) { if ($parentNode = $this->getNode($id)) { $query->where($left, 'between', [$parentNode[$left], $parentNode[$right]]); } else { return []; } } $nodes = $query->all(); if ($nodes->isEmpty()) { return []; } $map = []; $stack = []; $pk = $this->getRepository()->getPrimaryKey(); foreach ($nodes as $node) { if ($node[$parent] && $node[$pk] != $id) { $map[$node[$parent]][] = $node; } else { $stack[] = $node; } } $results = $this->mapTree($stack, $map); if ($id) { return $results[0]; } return $results; }
[ "public", "function", "getTree", "(", "$", "id", "=", "null", ")", "{", "$", "parent", "=", "$", "this", "->", "getConfig", "(", "'parentField'", ")", ";", "$", "left", "=", "$", "this", "->", "getConfig", "(", "'leftField'", ")", ";", "$", "right", "=", "$", "this", "->", "getConfig", "(", "'rightField'", ")", ";", "$", "query", "=", "$", "this", "->", "getRepository", "(", ")", "->", "select", "(", ")", "->", "orderBy", "(", "$", "left", ",", "'asc'", ")", ";", "if", "(", "$", "id", ")", "{", "if", "(", "$", "parentNode", "=", "$", "this", "->", "getNode", "(", "$", "id", ")", ")", "{", "$", "query", "->", "where", "(", "$", "left", ",", "'between'", ",", "[", "$", "parentNode", "[", "$", "left", "]", ",", "$", "parentNode", "[", "$", "right", "]", "]", ")", ";", "}", "else", "{", "return", "[", "]", ";", "}", "}", "$", "nodes", "=", "$", "query", "->", "all", "(", ")", ";", "if", "(", "$", "nodes", "->", "isEmpty", "(", ")", ")", "{", "return", "[", "]", ";", "}", "$", "map", "=", "[", "]", ";", "$", "stack", "=", "[", "]", ";", "$", "pk", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getPrimaryKey", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "[", "$", "parent", "]", "&&", "$", "node", "[", "$", "pk", "]", "!=", "$", "id", ")", "{", "$", "map", "[", "$", "node", "[", "$", "parent", "]", "]", "[", "]", "=", "$", "node", ";", "}", "else", "{", "$", "stack", "[", "]", "=", "$", "node", ";", "}", "}", "$", "results", "=", "$", "this", "->", "mapTree", "(", "$", "stack", ",", "$", "map", ")", ";", "if", "(", "$", "id", ")", "{", "return", "$", "results", "[", "0", "]", ";", "}", "return", "$", "results", ";", "}" ]
Return a tree of nested nodes. If no ID is provided, the top level root will be used. @param int $id @return array
[ "Return", "a", "tree", "of", "nested", "nodes", ".", "If", "no", "ID", "is", "provided", "the", "top", "level", "root", "will", "be", "used", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L168-L208
17,910
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior.mapList
public function mapList(array $nodes, $key, $value, $spacer) { $tree = []; $stack = []; $key = $key ?: $this->getRepository()->getPrimaryKey(); $value = $value ?: $this->getRepository()->getDisplayField(); $right = $this->getConfig('rightField'); foreach ($nodes as $node) { $count = count($stack); while ($count && $stack[$count - 1] < $node[$right]) { array_pop($stack); $count--; } $tree[$node[$key]] = str_repeat($spacer, $count) . $node[$value]; $stack[] = $node[$right]; } return $tree; }
php
public function mapList(array $nodes, $key, $value, $spacer) { $tree = []; $stack = []; $key = $key ?: $this->getRepository()->getPrimaryKey(); $value = $value ?: $this->getRepository()->getDisplayField(); $right = $this->getConfig('rightField'); foreach ($nodes as $node) { $count = count($stack); while ($count && $stack[$count - 1] < $node[$right]) { array_pop($stack); $count--; } $tree[$node[$key]] = str_repeat($spacer, $count) . $node[$value]; $stack[] = $node[$right]; } return $tree; }
[ "public", "function", "mapList", "(", "array", "$", "nodes", ",", "$", "key", ",", "$", "value", ",", "$", "spacer", ")", "{", "$", "tree", "=", "[", "]", ";", "$", "stack", "=", "[", "]", ";", "$", "key", "=", "$", "key", "?", ":", "$", "this", "->", "getRepository", "(", ")", "->", "getPrimaryKey", "(", ")", ";", "$", "value", "=", "$", "value", "?", ":", "$", "this", "->", "getRepository", "(", ")", "->", "getDisplayField", "(", ")", ";", "$", "right", "=", "$", "this", "->", "getConfig", "(", "'rightField'", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "count", "=", "count", "(", "$", "stack", ")", ";", "while", "(", "$", "count", "&&", "$", "stack", "[", "$", "count", "-", "1", "]", "<", "$", "node", "[", "$", "right", "]", ")", "{", "array_pop", "(", "$", "stack", ")", ";", "$", "count", "--", ";", "}", "$", "tree", "[", "$", "node", "[", "$", "key", "]", "]", "=", "str_repeat", "(", "$", "spacer", ",", "$", "count", ")", ".", "$", "node", "[", "$", "value", "]", ";", "$", "stack", "[", "]", "=", "$", "node", "[", "$", "right", "]", ";", "}", "return", "$", "tree", ";", "}" ]
Map a nested tree using the primary key and display field as the values to populate the list. Nested lists will be prepended with a spacer to indicate indentation. @param array $nodes @param string $key @param string $value @param string $spacer @return array
[ "Map", "a", "nested", "tree", "using", "the", "primary", "key", "and", "display", "field", "as", "the", "values", "to", "populate", "the", "list", ".", "Nested", "lists", "will", "be", "prepended", "with", "a", "spacer", "to", "indicate", "indentation", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L220-L241
17,911
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior.mapTree
public function mapTree(array $nodes, array $mappedNodes = []) { if (!$mappedNodes) { return $nodes; } $tree = []; $pk = $this->getRepository()->getPrimaryKey(); foreach ($nodes as $node) { $id = $node[$pk]; if (isset($mappedNodes[$id])) { $node[$this->getConfig('treeField') ?: 'Nodes'] = $this->mapTree($mappedNodes[$id], $mappedNodes); } $tree[] = $node; } return $tree; }
php
public function mapTree(array $nodes, array $mappedNodes = []) { if (!$mappedNodes) { return $nodes; } $tree = []; $pk = $this->getRepository()->getPrimaryKey(); foreach ($nodes as $node) { $id = $node[$pk]; if (isset($mappedNodes[$id])) { $node[$this->getConfig('treeField') ?: 'Nodes'] = $this->mapTree($mappedNodes[$id], $mappedNodes); } $tree[] = $node; } return $tree; }
[ "public", "function", "mapTree", "(", "array", "$", "nodes", ",", "array", "$", "mappedNodes", "=", "[", "]", ")", "{", "if", "(", "!", "$", "mappedNodes", ")", "{", "return", "$", "nodes", ";", "}", "$", "tree", "=", "[", "]", ";", "$", "pk", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getPrimaryKey", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "id", "=", "$", "node", "[", "$", "pk", "]", ";", "if", "(", "isset", "(", "$", "mappedNodes", "[", "$", "id", "]", ")", ")", "{", "$", "node", "[", "$", "this", "->", "getConfig", "(", "'treeField'", ")", "?", ":", "'Nodes'", "]", "=", "$", "this", "->", "mapTree", "(", "$", "mappedNodes", "[", "$", "id", "]", ",", "$", "mappedNodes", ")", ";", "}", "$", "tree", "[", "]", "=", "$", "node", ";", "}", "return", "$", "tree", ";", "}" ]
Map a nested tree of arrays using the parent node stack and the mapped nodes by parent ID. @param array $nodes @param array $mappedNodes @return array
[ "Map", "a", "nested", "tree", "of", "arrays", "using", "the", "parent", "node", "stack", "and", "the", "mapped", "nodes", "by", "parent", "ID", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L250-L269
17,912
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior.preDelete
public function preDelete(Event $event, Query $query, $id) { if (!$this->getConfig('onDelete')) { return true; } if ($node = $this->getNode($id)) { $count = $this->getRepository()->select() ->where($this->getConfig('parentField'), $id) ->count(); if ($count) { return false; } $this->_deleteIndex = $node[$this->getConfig('leftField')]; } return true; }
php
public function preDelete(Event $event, Query $query, $id) { if (!$this->getConfig('onDelete')) { return true; } if ($node = $this->getNode($id)) { $count = $this->getRepository()->select() ->where($this->getConfig('parentField'), $id) ->count(); if ($count) { return false; } $this->_deleteIndex = $node[$this->getConfig('leftField')]; } return true; }
[ "public", "function", "preDelete", "(", "Event", "$", "event", ",", "Query", "$", "query", ",", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "getConfig", "(", "'onDelete'", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "id", ")", ")", "{", "$", "count", "=", "$", "this", "->", "getRepository", "(", ")", "->", "select", "(", ")", "->", "where", "(", "$", "this", "->", "getConfig", "(", "'parentField'", ")", ",", "$", "id", ")", "->", "count", "(", ")", ";", "if", "(", "$", "count", ")", "{", "return", "false", ";", "}", "$", "this", "->", "_deleteIndex", "=", "$", "node", "[", "$", "this", "->", "getConfig", "(", "'leftField'", ")", "]", ";", "}", "return", "true", ";", "}" ]
Before a delete, fetch the node and save its left index. If a node has children, the delete will fail. @param \Titon\Event\Event $event @param \Titon\Db\Query $query @param int|int[] $id @return bool
[ "Before", "a", "delete", "fetch", "the", "node", "and", "save", "its", "left", "index", ".", "If", "a", "node", "has", "children", "the", "delete", "will", "fail", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L444-L462
17,913
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior.postDelete
public function postDelete(Event $event, $id, $count) { if (!$this->getConfig('onDelete') || !$this->_deleteIndex) { return; } $this->_removeNode($id, $this->_deleteIndex); $this->_deleteIndex = null; }
php
public function postDelete(Event $event, $id, $count) { if (!$this->getConfig('onDelete') || !$this->_deleteIndex) { return; } $this->_removeNode($id, $this->_deleteIndex); $this->_deleteIndex = null; }
[ "public", "function", "postDelete", "(", "Event", "$", "event", ",", "$", "id", ",", "$", "count", ")", "{", "if", "(", "!", "$", "this", "->", "getConfig", "(", "'onDelete'", ")", "||", "!", "$", "this", "->", "_deleteIndex", ")", "{", "return", ";", "}", "$", "this", "->", "_removeNode", "(", "$", "id", ",", "$", "this", "->", "_deleteIndex", ")", ";", "$", "this", "->", "_deleteIndex", "=", "null", ";", "}" ]
After a delete, shift all nodes up using the base index. @param \Titon\Event\Event $event @param int|int[] $id @param int $count
[ "After", "a", "delete", "shift", "all", "nodes", "up", "using", "the", "base", "index", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L471-L478
17,914
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior.postSave
public function postSave(Event $event, $id, $count) { if (!$this->getConfig('onSave') || !$this->_saveIndex) { return; } $this->_insertNode($id, $this->_saveIndex); $this->_saveIndex = null; }
php
public function postSave(Event $event, $id, $count) { if (!$this->getConfig('onSave') || !$this->_saveIndex) { return; } $this->_insertNode($id, $this->_saveIndex); $this->_saveIndex = null; }
[ "public", "function", "postSave", "(", "Event", "$", "event", ",", "$", "id", ",", "$", "count", ")", "{", "if", "(", "!", "$", "this", "->", "getConfig", "(", "'onSave'", ")", "||", "!", "$", "this", "->", "_saveIndex", ")", "{", "return", ";", "}", "$", "this", "->", "_insertNode", "(", "$", "id", ",", "$", "this", "->", "_saveIndex", ")", ";", "$", "this", "->", "_saveIndex", "=", "null", ";", "}" ]
After an insert, shift all nodes down using the base index. @param \Titon\Event\Event $event @param int|int[] $id @Param int $count
[ "After", "an", "insert", "shift", "all", "nodes", "down", "using", "the", "base", "index", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L545-L552
17,915
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior._moveNode
protected function _moveNode(Closure $callback, array $data) { return $this->getRepository()->updateMany($data, $callback, [ 'before' => false, 'after' => false ]); }
php
protected function _moveNode(Closure $callback, array $data) { return $this->getRepository()->updateMany($data, $callback, [ 'before' => false, 'after' => false ]); }
[ "protected", "function", "_moveNode", "(", "Closure", "$", "callback", ",", "array", "$", "data", ")", "{", "return", "$", "this", "->", "getRepository", "(", ")", "->", "updateMany", "(", "$", "data", ",", "$", "callback", ",", "[", "'before'", "=>", "false", ",", "'after'", "=>", "false", "]", ")", ";", "}" ]
Move a node, or nodes, by applying a where clause to an update query and saving data. Disable before and after callbacks to recursive events don't trigger. @param callable $callback @param array $data @return int
[ "Move", "a", "node", "or", "nodes", "by", "applying", "a", "where", "clause", "to", "an", "update", "query", "and", "saving", "data", ".", "Disable", "before", "and", "after", "callbacks", "to", "recursive", "events", "don", "t", "trigger", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L608-L613
17,916
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior._removeNode
protected function _removeNode($id, $index) { $pk = $this->getRepository()->getPrimaryKey(); foreach ([$this->getConfig('leftField'), $this->getConfig('rightField')] as $field) { $this->_moveNode(function(Query $query) use ($field, $index, $id, $pk) { $query->where($field, '>=', $index); if ($id) { $query->where($pk, '!=', $id); } }, [ $field => Query::expr($field, '-', 2) ]); } }
php
protected function _removeNode($id, $index) { $pk = $this->getRepository()->getPrimaryKey(); foreach ([$this->getConfig('leftField'), $this->getConfig('rightField')] as $field) { $this->_moveNode(function(Query $query) use ($field, $index, $id, $pk) { $query->where($field, '>=', $index); if ($id) { $query->where($pk, '!=', $id); } }, [ $field => Query::expr($field, '-', 2) ]); } }
[ "protected", "function", "_removeNode", "(", "$", "id", ",", "$", "index", ")", "{", "$", "pk", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getPrimaryKey", "(", ")", ";", "foreach", "(", "[", "$", "this", "->", "getConfig", "(", "'leftField'", ")", ",", "$", "this", "->", "getConfig", "(", "'rightField'", ")", "]", "as", "$", "field", ")", "{", "$", "this", "->", "_moveNode", "(", "function", "(", "Query", "$", "query", ")", "use", "(", "$", "field", ",", "$", "index", ",", "$", "id", ",", "$", "pk", ")", "{", "$", "query", "->", "where", "(", "$", "field", ",", "'>='", ",", "$", "index", ")", ";", "if", "(", "$", "id", ")", "{", "$", "query", "->", "where", "(", "$", "pk", ",", "'!='", ",", "$", "id", ")", ";", "}", "}", ",", "[", "$", "field", "=>", "Query", "::", "expr", "(", "$", "field", ",", "'-'", ",", "2", ")", "]", ")", ";", "}", "}" ]
Prepares a node for removal by moving all following nodes up. @param int $id @param int $index
[ "Prepares", "a", "node", "for", "removal", "by", "moving", "all", "following", "nodes", "up", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L621-L635
17,917
titon/db
src/Titon/Db/Behavior/HierarchyBehavior.php
HierarchyBehavior._reOrder
protected function _reOrder($parent_id, $left, array $order = []) { $parent = $this->getConfig('parentField'); $repo = $this->getRepository(); $pk = $repo->getPrimaryKey(); $right = $left + 1; // Get children and sort $children = $repo->select() ->where($parent, $parent_id) ->orderBy($order) ->all(); foreach ($children as $child) { $right = $this->_reOrder($child[$pk], $right, $order); } // Update parent node if ($parent_id) { $this->_moveNode(function(Query $query) use ($pk, $parent_id) { $query->where($pk, $parent_id); }, [ $this->getConfig('leftField') => $left, $this->getConfig('rightField') => $right ]); } return $right + 1; }
php
protected function _reOrder($parent_id, $left, array $order = []) { $parent = $this->getConfig('parentField'); $repo = $this->getRepository(); $pk = $repo->getPrimaryKey(); $right = $left + 1; // Get children and sort $children = $repo->select() ->where($parent, $parent_id) ->orderBy($order) ->all(); foreach ($children as $child) { $right = $this->_reOrder($child[$pk], $right, $order); } // Update parent node if ($parent_id) { $this->_moveNode(function(Query $query) use ($pk, $parent_id) { $query->where($pk, $parent_id); }, [ $this->getConfig('leftField') => $left, $this->getConfig('rightField') => $right ]); } return $right + 1; }
[ "protected", "function", "_reOrder", "(", "$", "parent_id", ",", "$", "left", ",", "array", "$", "order", "=", "[", "]", ")", "{", "$", "parent", "=", "$", "this", "->", "getConfig", "(", "'parentField'", ")", ";", "$", "repo", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "pk", "=", "$", "repo", "->", "getPrimaryKey", "(", ")", ";", "$", "right", "=", "$", "left", "+", "1", ";", "// Get children and sort", "$", "children", "=", "$", "repo", "->", "select", "(", ")", "->", "where", "(", "$", "parent", ",", "$", "parent_id", ")", "->", "orderBy", "(", "$", "order", ")", "->", "all", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "right", "=", "$", "this", "->", "_reOrder", "(", "$", "child", "[", "$", "pk", "]", ",", "$", "right", ",", "$", "order", ")", ";", "}", "// Update parent node", "if", "(", "$", "parent_id", ")", "{", "$", "this", "->", "_moveNode", "(", "function", "(", "Query", "$", "query", ")", "use", "(", "$", "pk", ",", "$", "parent_id", ")", "{", "$", "query", "->", "where", "(", "$", "pk", ",", "$", "parent_id", ")", ";", "}", ",", "[", "$", "this", "->", "getConfig", "(", "'leftField'", ")", "=>", "$", "left", ",", "$", "this", "->", "getConfig", "(", "'rightField'", ")", "=>", "$", "right", "]", ")", ";", "}", "return", "$", "right", "+", "1", ";", "}" ]
Re-order the tree by recursively looping through all parents and children, ordering the results, and generating the correct left and right indexes. @param int $parent_id @param int $left @param array $order @return int
[ "Re", "-", "order", "the", "tree", "by", "recursively", "looping", "through", "all", "parents", "and", "children", "ordering", "the", "results", "and", "generating", "the", "correct", "left", "and", "right", "indexes", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/HierarchyBehavior.php#L646-L673
17,918
webforge-labs/psc-cms
lib/Psc/Doctrine/NavigationNodeRepository.php
NavigationNodeRepository.getPath
public function getPath($node) { // ACTIVE ? $qb = $this->createQueryBuilder('node'); $qb ->where($qb->expr()->lte('node.lft', $node->getLft())) ->andWhere($qb->expr()->gte('node.rgt', $node->getRgt())) ->andWhere('node.context = :context') ->orderBy('node.lft', 'ASC') ; /* if (isset($config['root'])) { $rootId = $wrapped->getPropertyValue($config['root']); $qb->andWhere($rootId === null ? $qb->expr()->isNull('node.'.$config['root']) : $qb->expr()->eq('node.'.$config['root'], is_string($rootId) ? $qb->expr()->literal($rootId) : $rootId) ); } */ $query = $qb->getQuery()->setParameter('context', $node->getContext()); return $query->getResult(); }
php
public function getPath($node) { // ACTIVE ? $qb = $this->createQueryBuilder('node'); $qb ->where($qb->expr()->lte('node.lft', $node->getLft())) ->andWhere($qb->expr()->gte('node.rgt', $node->getRgt())) ->andWhere('node.context = :context') ->orderBy('node.lft', 'ASC') ; /* if (isset($config['root'])) { $rootId = $wrapped->getPropertyValue($config['root']); $qb->andWhere($rootId === null ? $qb->expr()->isNull('node.'.$config['root']) : $qb->expr()->eq('node.'.$config['root'], is_string($rootId) ? $qb->expr()->literal($rootId) : $rootId) ); } */ $query = $qb->getQuery()->setParameter('context', $node->getContext()); return $query->getResult(); }
[ "public", "function", "getPath", "(", "$", "node", ")", "{", "// ACTIVE ?", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'node'", ")", ";", "$", "qb", "->", "where", "(", "$", "qb", "->", "expr", "(", ")", "->", "lte", "(", "'node.lft'", ",", "$", "node", "->", "getLft", "(", ")", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "gte", "(", "'node.rgt'", ",", "$", "node", "->", "getRgt", "(", ")", ")", ")", "->", "andWhere", "(", "'node.context = :context'", ")", "->", "orderBy", "(", "'node.lft'", ",", "'ASC'", ")", ";", "/*\n if (isset($config['root'])) {\n $rootId = $wrapped->getPropertyValue($config['root']);\n $qb->andWhere($rootId === null ?\n $qb->expr()->isNull('node.'.$config['root']) :\n $qb->expr()->eq('node.'.$config['root'], is_string($rootId) ? $qb->expr()->literal($rootId) : $rootId)\n );\n }\n */", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", "->", "setParameter", "(", "'context'", ",", "$", "node", "->", "getContext", "(", ")", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Get the path of a node the path first element is the root node the last node is $node itself @param object $node @return array()
[ "Get", "the", "path", "of", "a", "node" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/NavigationNodeRepository.php#L310-L333
17,919
Kylob/Bootstrap
src/Navbar.php
Navbar.menu
public function menu(array $links, array $options = array()) { $align = (isset($options['pull'])) ? ' navbar-'.$options['pull'] : ''; unset($options['pull']); return "\n\t".'<ul class="nav navbar-nav'.$align.'">'.$this->links('li', $links, $options).'</ul>'; }
php
public function menu(array $links, array $options = array()) { $align = (isset($options['pull'])) ? ' navbar-'.$options['pull'] : ''; unset($options['pull']); return "\n\t".'<ul class="nav navbar-nav'.$align.'">'.$this->links('li', $links, $options).'</ul>'; }
[ "public", "function", "menu", "(", "array", "$", "links", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "align", "=", "(", "isset", "(", "$", "options", "[", "'pull'", "]", ")", ")", "?", "' navbar-'", ".", "$", "options", "[", "'pull'", "]", ":", "''", ";", "unset", "(", "$", "options", "[", "'pull'", "]", ")", ";", "return", "\"\\n\\t\"", ".", "'<ul class=\"nav navbar-nav'", ".", "$", "align", ".", "'\">'", ".", "$", "this", "->", "links", "(", "'li'", ",", "$", "links", ",", "$", "options", ")", ".", "'</ul>'", ";", "}" ]
Create a menu of links across your navbar. @param array $links An ``array($name => $href, ...)`` of links. If ``$href`` is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with buttons. @param array $options The options available here are: - '**active**' => **$name**, **$href**, '**url**', '**urlquery**', or an **integer** (starting from 1). - '**disabled**' => **$name**, **$href**, or an **integer** (starting from 1). - '**pull**' => '**left**' (default) or '**right**'. @return string @example ```php echo $bp->navbar->menu(array( 'Home' => '#', 'Work' => '#', 'Dropdown' => array( 'Action' => '#', 'More' => '#', ), ), array( 'active' => 'Home', )); ```
[ "Create", "a", "menu", "of", "links", "across", "your", "navbar", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Navbar.php#L87-L93
17,920
Kylob/Bootstrap
src/Navbar.php
Navbar.text
public function text($string, $pull = false) { $align = (in_array($pull, array('left', 'right'))) ? ' navbar-'.$pull : ''; return "\n\t".'<p class="navbar-text'.$align.'">'.$this->addClass($string, array('a' => 'navbar-link')).'</p>'; }
php
public function text($string, $pull = false) { $align = (in_array($pull, array('left', 'right'))) ? ' navbar-'.$pull : ''; return "\n\t".'<p class="navbar-text'.$align.'">'.$this->addClass($string, array('a' => 'navbar-link')).'</p>'; }
[ "public", "function", "text", "(", "$", "string", ",", "$", "pull", "=", "false", ")", "{", "$", "align", "=", "(", "in_array", "(", "$", "pull", ",", "array", "(", "'left'", ",", "'right'", ")", ")", ")", "?", "' navbar-'", ".", "$", "pull", ":", "''", ";", "return", "\"\\n\\t\"", ".", "'<p class=\"navbar-text'", ".", "$", "align", ".", "'\">'", ".", "$", "this", "->", "addClass", "(", "$", "string", ",", "array", "(", "'a'", "=>", "'navbar-link'", ")", ")", ".", "'</p>'", ";", "}" ]
Add a string of text to your navbar. @param string $string The message you would like to get across. It will be wrapped in a ``<p class="navbar-text">`` tag, and any ``<a>``'s will be classed with a '**navbar-link**'. @param string $pull Either '**left**' or '**right**'. @return string @example ```php echo $bp->navbar->text('You <a href="#">link</a> me'); ```
[ "Add", "a", "string", "of", "text", "to", "your", "navbar", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Navbar.php#L162-L167
17,921
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.assets
public function assets($type = 'css') { $output = []; $assets = $this->Assets->getAssets($type); foreach ($assets as $asset) { $output[] = $asset['output']; } return implode($this->eol, $output); }
php
public function assets($type = 'css') { $output = []; $assets = $this->Assets->getAssets($type); foreach ($assets as $asset) { $output[] = $asset['output']; } return implode($this->eol, $output); }
[ "public", "function", "assets", "(", "$", "type", "=", "'css'", ")", "{", "$", "output", "=", "[", "]", ";", "$", "assets", "=", "$", "this", "->", "Assets", "->", "getAssets", "(", "$", "type", ")", ";", "foreach", "(", "$", "assets", "as", "$", "asset", ")", "{", "$", "output", "[", "]", "=", "$", "asset", "[", "'output'", "]", ";", "}", "return", "implode", "(", "$", "this", "->", "eol", ",", "$", "output", ")", ";", "}" ]
Get assets fot layout render. @param string $type @return string
[ "Get", "assets", "fot", "layout", "render", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L118-L127
17,922
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.beforeLayout
public function beforeLayout(Event $event, $layoutFile) { $pluginEvent = Plugin::getData('Core', 'View.beforeLayout'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeLayout')) { call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $layoutFile]); } }
php
public function beforeLayout(Event $event, $layoutFile) { $pluginEvent = Plugin::getData('Core', 'View.beforeLayout'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeLayout')) { call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $layoutFile]); } }
[ "public", "function", "beforeLayout", "(", "Event", "$", "event", ",", "$", "layoutFile", ")", "{", "$", "pluginEvent", "=", "Plugin", "::", "getData", "(", "'Core'", ",", "'View.beforeLayout'", ")", ";", "if", "(", "is_callable", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ")", "&&", "Plugin", "::", "hasManifestEvent", "(", "'View.beforeLayout'", ")", ")", "{", "call_user_func_array", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ",", "[", "$", "this", "->", "_View", ",", "$", "event", ",", "$", "layoutFile", "]", ")", ";", "}", "}" ]
Is called before layout rendering starts. Receives the layout filename as an argument. @param Event $event @param string $layoutFile @return void @throws \JBZoo\Utils\Exception
[ "Is", "called", "before", "layout", "rendering", "starts", ".", "Receives", "the", "layout", "filename", "as", "an", "argument", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L138-L144
17,923
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.beforeRenderFile
public function beforeRenderFile(Event $event, $viewFile) { $pluginEvent = Plugin::getData('Core', 'View.beforeRenderFile'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeRenderFile')) { call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $viewFile]); } }
php
public function beforeRenderFile(Event $event, $viewFile) { $pluginEvent = Plugin::getData('Core', 'View.beforeRenderFile'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('View.beforeRenderFile')) { call_user_func_array($pluginEvent->find(0), [$this->_View, $event, $viewFile]); } }
[ "public", "function", "beforeRenderFile", "(", "Event", "$", "event", ",", "$", "viewFile", ")", "{", "$", "pluginEvent", "=", "Plugin", "::", "getData", "(", "'Core'", ",", "'View.beforeRenderFile'", ")", ";", "if", "(", "is_callable", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ")", "&&", "Plugin", "::", "hasManifestEvent", "(", "'View.beforeRenderFile'", ")", ")", "{", "call_user_func_array", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ",", "[", "$", "this", "->", "_View", ",", "$", "event", ",", "$", "viewFile", "]", ")", ";", "}", "}" ]
Is called before each view file is rendered. This includes elements, views, parent views and layouts. @param Event $event @param string $viewFile @return void @throws \JBZoo\Utils\Exception
[ "Is", "called", "before", "each", "view", "file", "is", "rendered", ".", "This", "includes", "elements", "views", "parent", "views", "and", "layouts", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L176-L182
17,924
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.getBodyClasses
public function getBodyClasses() { $prefix = ($this->request->getParam('prefix')) ? 'prefix-' . $this->request->getParam('prefix') : 'prefix-site'; $classes = [ $prefix, 'theme-' . Str::low($this->_View->theme), 'plugin-' . Str::low($this->_View->plugin), 'view-' . Str::low($this->_View->name), 'tmpl-' . Str::low($this->_View->template), 'layout-' . Str::low($this->_View->layout) ]; $pass = (array) $this->request->getParam('pass'); if (count($pass)) { $classes[] = 'item-id-' . array_shift($pass); } return implode(' ', $classes); }
php
public function getBodyClasses() { $prefix = ($this->request->getParam('prefix')) ? 'prefix-' . $this->request->getParam('prefix') : 'prefix-site'; $classes = [ $prefix, 'theme-' . Str::low($this->_View->theme), 'plugin-' . Str::low($this->_View->plugin), 'view-' . Str::low($this->_View->name), 'tmpl-' . Str::low($this->_View->template), 'layout-' . Str::low($this->_View->layout) ]; $pass = (array) $this->request->getParam('pass'); if (count($pass)) { $classes[] = 'item-id-' . array_shift($pass); } return implode(' ', $classes); }
[ "public", "function", "getBodyClasses", "(", ")", "{", "$", "prefix", "=", "(", "$", "this", "->", "request", "->", "getParam", "(", "'prefix'", ")", ")", "?", "'prefix-'", ".", "$", "this", "->", "request", "->", "getParam", "(", "'prefix'", ")", ":", "'prefix-site'", ";", "$", "classes", "=", "[", "$", "prefix", ",", "'theme-'", ".", "Str", "::", "low", "(", "$", "this", "->", "_View", "->", "theme", ")", ",", "'plugin-'", ".", "Str", "::", "low", "(", "$", "this", "->", "_View", "->", "plugin", ")", ",", "'view-'", ".", "Str", "::", "low", "(", "$", "this", "->", "_View", "->", "name", ")", ",", "'tmpl-'", ".", "Str", "::", "low", "(", "$", "this", "->", "_View", "->", "template", ")", ",", "'layout-'", ".", "Str", "::", "low", "(", "$", "this", "->", "_View", "->", "layout", ")", "]", ";", "$", "pass", "=", "(", "array", ")", "$", "this", "->", "request", "->", "getParam", "(", "'pass'", ")", ";", "if", "(", "count", "(", "$", "pass", ")", ")", "{", "$", "classes", "[", "]", "=", "'item-id-'", ".", "array_shift", "(", "$", "pass", ")", ";", "}", "return", "implode", "(", "' '", ",", "$", "classes", ")", ";", "}" ]
Get body classes by view data. @return string
[ "Get", "body", "classes", "by", "view", "data", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L189-L208
17,925
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.head
public function head() { $output = [ 'meta' => $this->_View->fetch('meta'), 'assets' => $this->assets('css'), 'fetch_css' => $this->_View->fetch('css'), 'fetch_css_bottom' => $this->_View->fetch('css_bottom'), ]; return implode('', $output); }
php
public function head() { $output = [ 'meta' => $this->_View->fetch('meta'), 'assets' => $this->assets('css'), 'fetch_css' => $this->_View->fetch('css'), 'fetch_css_bottom' => $this->_View->fetch('css_bottom'), ]; return implode('', $output); }
[ "public", "function", "head", "(", ")", "{", "$", "output", "=", "[", "'meta'", "=>", "$", "this", "->", "_View", "->", "fetch", "(", "'meta'", ")", ",", "'assets'", "=>", "$", "this", "->", "assets", "(", "'css'", ")", ",", "'fetch_css'", "=>", "$", "this", "->", "_View", "->", "fetch", "(", "'css'", ")", ",", "'fetch_css_bottom'", "=>", "$", "this", "->", "_View", "->", "fetch", "(", "'css_bottom'", ")", ",", "]", ";", "return", "implode", "(", "''", ",", "$", "output", ")", ";", "}" ]
Create head for layout. @return string
[ "Create", "head", "for", "layout", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L215-L225
17,926
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.lang
public function lang($isLang = true) { list($lang, $region) = explode('_', $this->locale); return ($isLang) ? Str::low($lang) : Str::low($region); }
php
public function lang($isLang = true) { list($lang, $region) = explode('_', $this->locale); return ($isLang) ? Str::low($lang) : Str::low($region); }
[ "public", "function", "lang", "(", "$", "isLang", "=", "true", ")", "{", "list", "(", "$", "lang", ",", "$", "region", ")", "=", "explode", "(", "'_'", ",", "$", "this", "->", "locale", ")", ";", "return", "(", "$", "isLang", ")", "?", "Str", "::", "low", "(", "$", "lang", ")", ":", "Str", "::", "low", "(", "$", "region", ")", ";", "}" ]
Site language. @param bool|true $isLang @return string @throws \Exception
[ "Site", "language", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L251-L255
17,927
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.meta
public function meta(array $rows, $block = null) { $output = []; foreach ($rows as $row) { $output[] = trim($row); } $output = implode($this->eol, $output) . $this->eol; if ($block !== null) { $this->_View->append($block, $output); return null; } return $output; }
php
public function meta(array $rows, $block = null) { $output = []; foreach ($rows as $row) { $output[] = trim($row); } $output = implode($this->eol, $output) . $this->eol; if ($block !== null) { $this->_View->append($block, $output); return null; } return $output; }
[ "public", "function", "meta", "(", "array", "$", "rows", ",", "$", "block", "=", "null", ")", "{", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "output", "[", "]", "=", "trim", "(", "$", "row", ")", ";", "}", "$", "output", "=", "implode", "(", "$", "this", "->", "eol", ",", "$", "output", ")", ".", "$", "this", "->", "eol", ";", "if", "(", "$", "block", "!==", "null", ")", "{", "$", "this", "->", "_View", "->", "append", "(", "$", "block", ",", "$", "output", ")", ";", "return", "null", ";", "}", "return", "$", "output", ";", "}" ]
Creates a link to an external resource and handles basic meta tags. @param array $rows @param null $block @return null|string
[ "Creates", "a", "link", "to", "an", "external", "resource", "and", "handles", "basic", "meta", "tags", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L264-L279
17,928
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper.type
public function type() { $lang = $this->lang(); $html = [ '<!doctype html>', '<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6" ' . 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->', '<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie7" ' . 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->', '<!--[if IE 8]><html class="no-js lt-ie9 ie8" ' . 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->', '<!--[if gt IE 8]><!--><html class="no-js" xmlns="http://www.w3.org/1999/xhtml" ' . 'lang="' . $lang . '" dir="' . $this->dir . '" ' . 'prefix="og: http://ogp.me/ns#" ' . '> <!--<![endif]-->', ]; return implode($this->eol, $html) . $this->eol; }
php
public function type() { $lang = $this->lang(); $html = [ '<!doctype html>', '<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6" ' . 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->', '<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie7" ' . 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->', '<!--[if IE 8]><html class="no-js lt-ie9 ie8" ' . 'lang="' . $lang . '" dir="' . $this->dir . '"> <![endif]-->', '<!--[if gt IE 8]><!--><html class="no-js" xmlns="http://www.w3.org/1999/xhtml" ' . 'lang="' . $lang . '" dir="' . $this->dir . '" ' . 'prefix="og: http://ogp.me/ns#" ' . '> <!--<![endif]-->', ]; return implode($this->eol, $html) . $this->eol; }
[ "public", "function", "type", "(", ")", "{", "$", "lang", "=", "$", "this", "->", "lang", "(", ")", ";", "$", "html", "=", "[", "'<!doctype html>'", ",", "'<!--[if lt IE 7]><html class=\"no-js lt-ie9 lt-ie8 lt-ie7 ie6\" '", ".", "'lang=\"'", ".", "$", "lang", ".", "'\" dir=\"'", ".", "$", "this", "->", "dir", ".", "'\"> <![endif]-->'", ",", "'<!--[if IE 7]><html class=\"no-js lt-ie9 lt-ie8 ie7\" '", ".", "'lang=\"'", ".", "$", "lang", ".", "'\" dir=\"'", ".", "$", "this", "->", "dir", ".", "'\"> <![endif]-->'", ",", "'<!--[if IE 8]><html class=\"no-js lt-ie9 ie8\" '", ".", "'lang=\"'", ".", "$", "lang", ".", "'\" dir=\"'", ".", "$", "this", "->", "dir", ".", "'\"> <![endif]-->'", ",", "'<!--[if gt IE 8]><!--><html class=\"no-js\" xmlns=\"http://www.w3.org/1999/xhtml\" '", ".", "'lang=\"'", ".", "$", "lang", ".", "'\" dir=\"'", ".", "$", "this", "->", "dir", ".", "'\" '", ".", "'prefix=\"og: http://ogp.me/ns#\" '", ".", "'> <!--<![endif]-->'", ",", "]", ";", "return", "implode", "(", "$", "this", "->", "eol", ",", "$", "html", ")", ".", "$", "this", "->", "eol", ";", "}" ]
Create html 5 document type. @return string @throws \Exception
[ "Create", "html", "5", "document", "type", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L288-L305
17,929
CakeCMS/Core
src/View/Helper/DocumentHelper.php
DocumentHelper._assignMeta
protected function _assignMeta($key) { if (Arr::key($key, $this->_View->viewVars)) { $this->_View->assign($key, $this->_View->viewVars[$key]); } return $this; }
php
protected function _assignMeta($key) { if (Arr::key($key, $this->_View->viewVars)) { $this->_View->assign($key, $this->_View->viewVars[$key]); } return $this; }
[ "protected", "function", "_assignMeta", "(", "$", "key", ")", "{", "if", "(", "Arr", "::", "key", "(", "$", "key", ",", "$", "this", "->", "_View", "->", "viewVars", ")", ")", "{", "$", "this", "->", "_View", "->", "assign", "(", "$", "key", ",", "$", "this", "->", "_View", "->", "viewVars", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Assign data from view vars. @param string $key @return $this
[ "Assign", "data", "from", "view", "vars", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/DocumentHelper.php#L313-L320
17,930
lode/fem
src/mysql.php
mysql.select
public static function select($type, $sql, $binds=null) { if (in_array($type, self::$types) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('unknown select type'); } $results = self::query($sql, $binds); return self::{'as_'.$type}($results); }
php
public static function select($type, $sql, $binds=null) { if (in_array($type, self::$types) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('unknown select type'); } $results = self::query($sql, $binds); return self::{'as_'.$type}($results); }
[ "public", "static", "function", "select", "(", "$", "type", ",", "$", "sql", ",", "$", "binds", "=", "null", ")", "{", "if", "(", "in_array", "(", "$", "type", ",", "self", "::", "$", "types", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'unknown select type'", ")", ";", "}", "$", "results", "=", "self", "::", "query", "(", "$", "sql", ",", "$", "binds", ")", ";", "return", "self", "::", "{", "'as_'", ".", "$", "type", "}", "(", "$", "results", ")", ";", "}" ]
executes a SELECT statement, and returns the result as array, row, or single field @param string $type one of the ::AS_* consts @param string $sql the base sql statement @param array $binds bind values for the given sql, @see ::merge() @return array result set
[ "executes", "a", "SELECT", "statement", "and", "returns", "the", "result", "as", "array", "row", "or", "single", "field" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L91-L99
17,931
lode/fem
src/mysql.php
mysql.query
public static function query($sql, $binds=null) { if (!empty($binds)) { $sql = self::merge($sql, $binds); } // secure against wild update/delete statements if (preg_match('{^(UPDATE|DELETE)\s}', $sql) && preg_match('{\s(WHERE|LIMIT)\s}', $sql) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('unsafe UPDATE/DELETE statement, use a WHERE/LIMIT clause'); } return self::raw($sql); }
php
public static function query($sql, $binds=null) { if (!empty($binds)) { $sql = self::merge($sql, $binds); } // secure against wild update/delete statements if (preg_match('{^(UPDATE|DELETE)\s}', $sql) && preg_match('{\s(WHERE|LIMIT)\s}', $sql) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('unsafe UPDATE/DELETE statement, use a WHERE/LIMIT clause'); } return self::raw($sql); }
[ "public", "static", "function", "query", "(", "$", "sql", ",", "$", "binds", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "binds", ")", ")", "{", "$", "sql", "=", "self", "::", "merge", "(", "$", "sql", ",", "$", "binds", ")", ";", "}", "// secure against wild update/delete statements", "if", "(", "preg_match", "(", "'{^(UPDATE|DELETE)\\s}'", ",", "$", "sql", ")", "&&", "preg_match", "(", "'{\\s(WHERE|LIMIT)\\s}'", ",", "$", "sql", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'unsafe UPDATE/DELETE statement, use a WHERE/LIMIT clause'", ")", ";", "}", "return", "self", "::", "raw", "(", "$", "sql", ")", ";", "}" ]
executes any query on the database protects against unsafe UPDATE or DELETE statements blocks when they don't contain a WHERE or LIMIT clause @param string $sql the base sql statement @param array $binds bind values for the given sql, @see ::merge() @return mysqli_result
[ "executes", "any", "query", "on", "the", "database" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L111-L123
17,932
lode/fem
src/mysql.php
mysql.merge
private static function merge($sql, $binds) { if (is_array($binds) == false) { $binds = (array)$binds; } if (is_null(self::$connection)) { $exception = bootstrap::get_library('exception'); $response = bootstrap::get_library('response'); throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE); } foreach ($binds as &$argument) { $argument = self::$connection->real_escape_string($argument); } return vsprintf($sql, $binds); }
php
private static function merge($sql, $binds) { if (is_array($binds) == false) { $binds = (array)$binds; } if (is_null(self::$connection)) { $exception = bootstrap::get_library('exception'); $response = bootstrap::get_library('response'); throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE); } foreach ($binds as &$argument) { $argument = self::$connection->real_escape_string($argument); } return vsprintf($sql, $binds); }
[ "private", "static", "function", "merge", "(", "$", "sql", ",", "$", "binds", ")", "{", "if", "(", "is_array", "(", "$", "binds", ")", "==", "false", ")", "{", "$", "binds", "=", "(", "array", ")", "$", "binds", ";", "}", "if", "(", "is_null", "(", "self", "::", "$", "connection", ")", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "$", "response", "=", "bootstrap", "::", "get_library", "(", "'response'", ")", ";", "throw", "new", "$", "exception", "(", "'no db connection'", ",", "$", "response", "::", "STATUS_SERVICE_UNAVAILABLE", ")", ";", "}", "foreach", "(", "$", "binds", "as", "&", "$", "argument", ")", "{", "$", "argument", "=", "self", "::", "$", "connection", "->", "real_escape_string", "(", "$", "argument", ")", ";", "}", "return", "vsprintf", "(", "$", "sql", ",", "$", "binds", ")", ";", "}" ]
merges bind values while escaping them $sql can contain printf conversion specifications, i.e.: - SELECT * WHERE `foo` = '%s'; - SELECT * WHERE `foo` > %d; @param string $sql the base sql statement @param array $binds bind values for the given sql @return string input sql merged with bind values
[ "merges", "bind", "values", "while", "escaping", "them" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/mysql.php#L213-L228
17,933
shi-yang/yii2-masonry
Masonry.php
Masonry.registerPlugin
protected function registerPlugin() { $id = $this->options['id']; //get the displayed view and register the needed assets $view = $this->getView(); MasonryAsset::register($view); ImagesLoadedAsset::register($view); $js = []; $js[] = "var mscontainer$id = $('#$id');"; $js[] = "mscontainer$id.imagesLoaded(function(){mscontainer$id.masonry()});"; $view->registerJs(implode("\n", $js),View::POS_END); }
php
protected function registerPlugin() { $id = $this->options['id']; //get the displayed view and register the needed assets $view = $this->getView(); MasonryAsset::register($view); ImagesLoadedAsset::register($view); $js = []; $js[] = "var mscontainer$id = $('#$id');"; $js[] = "mscontainer$id.imagesLoaded(function(){mscontainer$id.masonry()});"; $view->registerJs(implode("\n", $js),View::POS_END); }
[ "protected", "function", "registerPlugin", "(", ")", "{", "$", "id", "=", "$", "this", "->", "options", "[", "'id'", "]", ";", "//get the displayed view and register the needed assets", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "MasonryAsset", "::", "register", "(", "$", "view", ")", ";", "ImagesLoadedAsset", "::", "register", "(", "$", "view", ")", ";", "$", "js", "=", "[", "]", ";", "$", "js", "[", "]", "=", "\"var mscontainer$id = $('#$id');\"", ";", "$", "js", "[", "]", "=", "\"mscontainer$id.imagesLoaded(function(){mscontainer$id.masonry()});\"", ";", "$", "view", "->", "registerJs", "(", "implode", "(", "\"\\n\"", ",", "$", "js", ")", ",", "View", "::", "POS_END", ")", ";", "}" ]
Registers the widget and the related events
[ "Registers", "the", "widget", "and", "the", "related", "events" ]
7f50f65325af9d7e3a24eb20b99594ed4df14b44
https://github.com/shi-yang/yii2-masonry/blob/7f50f65325af9d7e3a24eb20b99594ed4df14b44/Masonry.php#L73-L87
17,934
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.getError
public static function getError($unset = false) { JLog::add('JError::getError() is deprecated.', JLog::WARNING, 'deprecated'); if (!isset(self::$stack[0])) { return false; } if ($unset) { $error = array_shift(self::$stack); } else { $error = &self::$stack[0]; } return $error; }
php
public static function getError($unset = false) { JLog::add('JError::getError() is deprecated.', JLog::WARNING, 'deprecated'); if (!isset(self::$stack[0])) { return false; } if ($unset) { $error = array_shift(self::$stack); } else { $error = &self::$stack[0]; } return $error; }
[ "public", "static", "function", "getError", "(", "$", "unset", "=", "false", ")", "{", "JLog", "::", "add", "(", "'JError::getError() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "stack", "[", "0", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "unset", ")", "{", "$", "error", "=", "array_shift", "(", "self", "::", "$", "stack", ")", ";", "}", "else", "{", "$", "error", "=", "&", "self", "::", "$", "stack", "[", "0", "]", ";", "}", "return", "$", "error", ";", "}" ]
Method for retrieving the last exception object in the error stack @param boolean $unset True to remove the error from the stack. @return JException|boolean Last JException object in the error stack or boolean false if none exist @deprecated 12.1 @since 11.1
[ "Method", "for", "retrieving", "the", "last", "exception", "object", "in", "the", "error", "stack" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L123-L142
17,935
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.addToStack
public static function addToStack(JException &$e) { JLog::add('JError::addToStack() is deprecated.', JLog::WARNING, 'deprecated'); self::$stack[] = &$e; }
php
public static function addToStack(JException &$e) { JLog::add('JError::addToStack() is deprecated.', JLog::WARNING, 'deprecated'); self::$stack[] = &$e; }
[ "public", "static", "function", "addToStack", "(", "JException", "&", "$", "e", ")", "{", "JLog", "::", "add", "(", "'JError::addToStack() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "self", "::", "$", "stack", "[", "]", "=", "&", "$", "e", ";", "}" ]
Method to add non-JError thrown JExceptions to the JError stack for debugging purposes @param JException &$e Add an exception to the stack. @return void @since 11.1 @deprecated 12.1
[ "Method", "to", "add", "non", "-", "JError", "thrown", "JExceptions", "to", "the", "JError", "stack", "for", "debugging", "purposes" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L169-L174
17,936
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.raise
public static function raise($level, $code, $msg, $info = null, $backtrace = false) { JLog::add('JError::raise() is deprecated.', JLog::WARNING, 'deprecated'); // Build error object $class = $code == 404 ? 'JExceptionNotFound' : 'JException'; $exception = new $class($msg, $code, $level, $info, $backtrace); return self::throwError($exception); }
php
public static function raise($level, $code, $msg, $info = null, $backtrace = false) { JLog::add('JError::raise() is deprecated.', JLog::WARNING, 'deprecated'); // Build error object $class = $code == 404 ? 'JExceptionNotFound' : 'JException'; $exception = new $class($msg, $code, $level, $info, $backtrace); return self::throwError($exception); }
[ "public", "static", "function", "raise", "(", "$", "level", ",", "$", "code", ",", "$", "msg", ",", "$", "info", "=", "null", ",", "$", "backtrace", "=", "false", ")", "{", "JLog", "::", "add", "(", "'JError::raise() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "// Build error object", "$", "class", "=", "$", "code", "==", "404", "?", "'JExceptionNotFound'", ":", "'JException'", ";", "$", "exception", "=", "new", "$", "class", "(", "$", "msg", ",", "$", "code", ",", "$", "level", ",", "$", "info", ",", "$", "backtrace", ")", ";", "return", "self", "::", "throwError", "(", "$", "exception", ")", ";", "}" ]
Create a new JException object given the passed arguments @param integer $level The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE. @param string $code The application-internal error code for this error @param string $msg The error message, which may also be shown the user if need be. @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). @param boolean $backtrace Add a stack backtrace to the exception. @return JException @since 11.1 @deprecated 12.1 Use PHP Exception @see JException
[ "Create", "a", "new", "JException", "object", "given", "the", "passed", "arguments" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L195-L204
17,937
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.setErrorHandling
public static function setErrorHandling($level, $mode, $options = null) { JLog::add('JError::setErrorHandling() is deprecated.', JLog::WARNING, 'deprecated'); $levels = self::$levels; $function = 'handle' . ucfirst($mode); if (!is_callable(array('JError', $function))) { return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_MODE, 'Error Handling mode is not known', 'Mode: ' . $mode . ' is not implemented.'); } foreach ($levels as $eLevel => $eTitle) { if (($level & $eLevel) != $eLevel) { continue; } // Set callback options if ($mode == 'callback') { if (!is_array($options)) { return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_OPTIONS, 'Options for callback not valid'); } if (!is_callable($options)) { $tmp = array('GLOBAL'); if (is_array($options)) { $tmp[0] = $options[0]; $tmp[1] = $options[1]; } else { $tmp[1] = $options; } return self::raiseError( E_ERROR, 'JError:' . JERROR_CALLBACK_NOT_CALLABLE, 'Function is not callable', 'Function:' . $tmp[1] . ' scope ' . $tmp[0] . '.' ); } } // Save settings self::$handlers[$eLevel] = array('mode' => $mode); if ($options != null) { self::$handlers[$eLevel]['options'] = $options; } } return true; }
php
public static function setErrorHandling($level, $mode, $options = null) { JLog::add('JError::setErrorHandling() is deprecated.', JLog::WARNING, 'deprecated'); $levels = self::$levels; $function = 'handle' . ucfirst($mode); if (!is_callable(array('JError', $function))) { return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_MODE, 'Error Handling mode is not known', 'Mode: ' . $mode . ' is not implemented.'); } foreach ($levels as $eLevel => $eTitle) { if (($level & $eLevel) != $eLevel) { continue; } // Set callback options if ($mode == 'callback') { if (!is_array($options)) { return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_OPTIONS, 'Options for callback not valid'); } if (!is_callable($options)) { $tmp = array('GLOBAL'); if (is_array($options)) { $tmp[0] = $options[0]; $tmp[1] = $options[1]; } else { $tmp[1] = $options; } return self::raiseError( E_ERROR, 'JError:' . JERROR_CALLBACK_NOT_CALLABLE, 'Function is not callable', 'Function:' . $tmp[1] . ' scope ' . $tmp[0] . '.' ); } } // Save settings self::$handlers[$eLevel] = array('mode' => $mode); if ($options != null) { self::$handlers[$eLevel]['options'] = $options; } } return true; }
[ "public", "static", "function", "setErrorHandling", "(", "$", "level", ",", "$", "mode", ",", "$", "options", "=", "null", ")", "{", "JLog", "::", "add", "(", "'JError::setErrorHandling() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "$", "levels", "=", "self", "::", "$", "levels", ";", "$", "function", "=", "'handle'", ".", "ucfirst", "(", "$", "mode", ")", ";", "if", "(", "!", "is_callable", "(", "array", "(", "'JError'", ",", "$", "function", ")", ")", ")", "{", "return", "self", "::", "raiseError", "(", "E_ERROR", ",", "'JError:'", ".", "JERROR_ILLEGAL_MODE", ",", "'Error Handling mode is not known'", ",", "'Mode: '", ".", "$", "mode", ".", "' is not implemented.'", ")", ";", "}", "foreach", "(", "$", "levels", "as", "$", "eLevel", "=>", "$", "eTitle", ")", "{", "if", "(", "(", "$", "level", "&", "$", "eLevel", ")", "!=", "$", "eLevel", ")", "{", "continue", ";", "}", "// Set callback options", "if", "(", "$", "mode", "==", "'callback'", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", ")", "{", "return", "self", "::", "raiseError", "(", "E_ERROR", ",", "'JError:'", ".", "JERROR_ILLEGAL_OPTIONS", ",", "'Options for callback not valid'", ")", ";", "}", "if", "(", "!", "is_callable", "(", "$", "options", ")", ")", "{", "$", "tmp", "=", "array", "(", "'GLOBAL'", ")", ";", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "tmp", "[", "0", "]", "=", "$", "options", "[", "0", "]", ";", "$", "tmp", "[", "1", "]", "=", "$", "options", "[", "1", "]", ";", "}", "else", "{", "$", "tmp", "[", "1", "]", "=", "$", "options", ";", "}", "return", "self", "::", "raiseError", "(", "E_ERROR", ",", "'JError:'", ".", "JERROR_CALLBACK_NOT_CALLABLE", ",", "'Function is not callable'", ",", "'Function:'", ".", "$", "tmp", "[", "1", "]", ".", "' scope '", ".", "$", "tmp", "[", "0", "]", ".", "'.'", ")", ";", "}", "}", "// Save settings", "self", "::", "$", "handlers", "[", "$", "eLevel", "]", "=", "array", "(", "'mode'", "=>", "$", "mode", ")", ";", "if", "(", "$", "options", "!=", "null", ")", "{", "self", "::", "$", "handlers", "[", "$", "eLevel", "]", "[", "'options'", "]", "=", "$", "options", ";", "}", "}", "return", "true", ";", "}" ]
Method to set the way the JError will handle different error levels. Use this if you want to override the default settings. Error handling modes: - ignore - echo - verbose - die - message - log - callback You may also set the error handling for several modes at once using PHP's bit operations. Examples: - E_ALL = Set the handling for all levels - E_ERROR | E_WARNING = Set the handling for errors and warnings - E_ALL ^ E_ERROR = Set the handling for all levels except errors @param integer $level The error level for which to set the error handling @param string $mode The mode to use for the error handling. @param mixed $options Optional: Any options needed for the given mode. @return boolean|JException True on success or a JException object if failed. @deprecated 12.1 Use PHP Exception @since 11.1
[ "Method", "to", "set", "the", "way", "the", "JError", "will", "handle", "different", "error", "levels", ".", "Use", "this", "if", "you", "want", "to", "override", "the", "default", "settings", "." ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L370-L431
17,938
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.registerErrorLevel
public static function registerErrorLevel($level, $name, $handler = 'ignore') { JLog::add('JError::registerErrorLevel() is deprecated.', JLog::WARNING, 'deprecated'); if (isset(self::$levels[$level])) { return false; } self::$levels[$level] = $name; self::setErrorHandling($level, $handler); return true; }
php
public static function registerErrorLevel($level, $name, $handler = 'ignore') { JLog::add('JError::registerErrorLevel() is deprecated.', JLog::WARNING, 'deprecated'); if (isset(self::$levels[$level])) { return false; } self::$levels[$level] = $name; self::setErrorHandling($level, $handler); return true; }
[ "public", "static", "function", "registerErrorLevel", "(", "$", "level", ",", "$", "name", ",", "$", "handler", "=", "'ignore'", ")", "{", "JLog", "::", "add", "(", "'JError::registerErrorLevel() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "levels", "[", "$", "level", "]", ")", ")", "{", "return", "false", ";", "}", "self", "::", "$", "levels", "[", "$", "level", "]", "=", "$", "name", ";", "self", "::", "setErrorHandling", "(", "$", "level", ",", "$", "handler", ")", ";", "return", "true", ";", "}" ]
Method to register a new error level for handling errors This allows you to add custom error levels to the built-in - E_NOTICE - E_WARNING - E_NOTICE @param integer $level Error level to register @param string $name Human readable name for the error level @param string $handler Error handler to set for the new error level [optional] @return boolean True on success; false if the level already has been registered @deprecated 12.1 @since 11.1
[ "Method", "to", "register", "a", "new", "error", "level", "for", "handling", "errors" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L482-L495
17,939
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.handleEcho
public static function handleEcho(&$error, $options) { JLog::add('JError::handleEcho() is deprecated.', JLog::WARNING, 'deprecated'); $level_human = self::translateErrorLevel($error->get('level')); // If system debug is set, then output some more information. if (JDEBUG) { $backtrace = $error->getTrace(); $trace = ''; for ($i = count($backtrace) - 1; $i >= 0; $i--) { if (isset($backtrace[$i]['class'])) { $trace .= sprintf("\n%s %s %s()", $backtrace[$i]['class'], $backtrace[$i]['type'], $backtrace[$i]['function']); } else { $trace .= sprintf("\n%s()", $backtrace[$i]['function']); } if (isset($backtrace[$i]['file'])) { $trace .= sprintf(' @ %s:%d', $backtrace[$i]['file'], $backtrace[$i]['line']); } } } if (isset($_SERVER['HTTP_HOST'])) { // Output as html echo "<br /><b>jos-$level_human</b>: " . $error->get('message') . "<br />\n" . (JDEBUG ? nl2br($trace) : ''); } else { // Output as simple text if (defined('STDERR')) { fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n"); if (JDEBUG) { fwrite(STDERR, $trace); } } else { echo "J$level_human: " . $error->get('message') . "\n"; if (JDEBUG) { echo $trace; } } } return $error; }
php
public static function handleEcho(&$error, $options) { JLog::add('JError::handleEcho() is deprecated.', JLog::WARNING, 'deprecated'); $level_human = self::translateErrorLevel($error->get('level')); // If system debug is set, then output some more information. if (JDEBUG) { $backtrace = $error->getTrace(); $trace = ''; for ($i = count($backtrace) - 1; $i >= 0; $i--) { if (isset($backtrace[$i]['class'])) { $trace .= sprintf("\n%s %s %s()", $backtrace[$i]['class'], $backtrace[$i]['type'], $backtrace[$i]['function']); } else { $trace .= sprintf("\n%s()", $backtrace[$i]['function']); } if (isset($backtrace[$i]['file'])) { $trace .= sprintf(' @ %s:%d', $backtrace[$i]['file'], $backtrace[$i]['line']); } } } if (isset($_SERVER['HTTP_HOST'])) { // Output as html echo "<br /><b>jos-$level_human</b>: " . $error->get('message') . "<br />\n" . (JDEBUG ? nl2br($trace) : ''); } else { // Output as simple text if (defined('STDERR')) { fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n"); if (JDEBUG) { fwrite(STDERR, $trace); } } else { echo "J$level_human: " . $error->get('message') . "\n"; if (JDEBUG) { echo $trace; } } } return $error; }
[ "public", "static", "function", "handleEcho", "(", "&", "$", "error", ",", "$", "options", ")", "{", "JLog", "::", "add", "(", "'JError::handleEcho() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "$", "level_human", "=", "self", "::", "translateErrorLevel", "(", "$", "error", "->", "get", "(", "'level'", ")", ")", ";", "// If system debug is set, then output some more information.", "if", "(", "JDEBUG", ")", "{", "$", "backtrace", "=", "$", "error", "->", "getTrace", "(", ")", ";", "$", "trace", "=", "''", ";", "for", "(", "$", "i", "=", "count", "(", "$", "backtrace", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "if", "(", "isset", "(", "$", "backtrace", "[", "$", "i", "]", "[", "'class'", "]", ")", ")", "{", "$", "trace", ".=", "sprintf", "(", "\"\\n%s %s %s()\"", ",", "$", "backtrace", "[", "$", "i", "]", "[", "'class'", "]", ",", "$", "backtrace", "[", "$", "i", "]", "[", "'type'", "]", ",", "$", "backtrace", "[", "$", "i", "]", "[", "'function'", "]", ")", ";", "}", "else", "{", "$", "trace", ".=", "sprintf", "(", "\"\\n%s()\"", ",", "$", "backtrace", "[", "$", "i", "]", "[", "'function'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "backtrace", "[", "$", "i", "]", "[", "'file'", "]", ")", ")", "{", "$", "trace", ".=", "sprintf", "(", "' @ %s:%d'", ",", "$", "backtrace", "[", "$", "i", "]", "[", "'file'", "]", ",", "$", "backtrace", "[", "$", "i", "]", "[", "'line'", "]", ")", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ")", ")", "{", "// Output as html", "echo", "\"<br /><b>jos-$level_human</b>: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"<br />\\n\"", ".", "(", "JDEBUG", "?", "nl2br", "(", "$", "trace", ")", ":", "''", ")", ";", "}", "else", "{", "// Output as simple text", "if", "(", "defined", "(", "'STDERR'", ")", ")", "{", "fwrite", "(", "STDERR", ",", "\"J$level_human: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"\\n\"", ")", ";", "if", "(", "JDEBUG", ")", "{", "fwrite", "(", "STDERR", ",", "$", "trace", ")", ";", "}", "}", "else", "{", "echo", "\"J$level_human: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"\\n\"", ";", "if", "(", "JDEBUG", ")", "{", "echo", "$", "trace", ";", "}", "}", "}", "return", "$", "error", ";", "}" ]
Echo error handler - Echos the error message to output @param JException &$error Exception object to handle @param array $options Handler options @return JException The exception object @deprecated 12.1 @see JError::raise() @since 11.1
[ "Echo", "error", "handler", "-", "Echos", "the", "error", "message", "to", "output" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L554-L615
17,940
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.handleVerbose
public static function handleVerbose(&$error, $options) { JLog::add('JError::handleVerbose() is deprecated.', JLog::WARNING, 'deprecated'); $level_human = self::translateErrorLevel($error->get('level')); $info = $error->get('info'); if (isset($_SERVER['HTTP_HOST'])) { // Output as html echo "<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n"; if ($info != null) { echo "&#160;&#160;&#160;" . $info . "<br />\n"; } echo $error->getBacktrace(true); } else { // Output as simple text echo "J$level_human: " . $error->get('message') . "\n"; if ($info != null) { echo "\t" . $info . "\n"; } } return $error; }
php
public static function handleVerbose(&$error, $options) { JLog::add('JError::handleVerbose() is deprecated.', JLog::WARNING, 'deprecated'); $level_human = self::translateErrorLevel($error->get('level')); $info = $error->get('info'); if (isset($_SERVER['HTTP_HOST'])) { // Output as html echo "<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n"; if ($info != null) { echo "&#160;&#160;&#160;" . $info . "<br />\n"; } echo $error->getBacktrace(true); } else { // Output as simple text echo "J$level_human: " . $error->get('message') . "\n"; if ($info != null) { echo "\t" . $info . "\n"; } } return $error; }
[ "public", "static", "function", "handleVerbose", "(", "&", "$", "error", ",", "$", "options", ")", "{", "JLog", "::", "add", "(", "'JError::handleVerbose() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "$", "level_human", "=", "self", "::", "translateErrorLevel", "(", "$", "error", "->", "get", "(", "'level'", ")", ")", ";", "$", "info", "=", "$", "error", "->", "get", "(", "'info'", ")", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ")", ")", "{", "// Output as html", "echo", "\"<br /><b>J$level_human</b>: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"<br />\\n\"", ";", "if", "(", "$", "info", "!=", "null", ")", "{", "echo", "\"&#160;&#160;&#160;\"", ".", "$", "info", ".", "\"<br />\\n\"", ";", "}", "echo", "$", "error", "->", "getBacktrace", "(", "true", ")", ";", "}", "else", "{", "// Output as simple text", "echo", "\"J$level_human: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"\\n\"", ";", "if", "(", "$", "info", "!=", "null", ")", "{", "echo", "\"\\t\"", ".", "$", "info", ".", "\"\\n\"", ";", "}", "}", "return", "$", "error", ";", "}" ]
Verbose error handler - Echos the error message to output as well as related info @param JException &$error Exception object to handle @param array $options Handler options @return JException The exception object @deprecated 12.1 @see JError::raise() @since 11.1
[ "Verbose", "error", "handler", "-", "Echos", "the", "error", "message", "to", "output", "as", "well", "as", "related", "info" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L630-L661
17,941
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.handleDie
public static function handleDie(&$error, $options) { JLog::add('JError::handleDie() is deprecated.', JLog::WARNING, 'deprecated'); $level_human = self::translateErrorLevel($error->get('level')); if (isset($_SERVER['HTTP_HOST'])) { // Output as html jexit("<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n"); } else { // Output as simple text if (defined('STDERR')) { fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n"); jexit(); } else { jexit("J$level_human: " . $error->get('message') . "\n"); } } return $error; }
php
public static function handleDie(&$error, $options) { JLog::add('JError::handleDie() is deprecated.', JLog::WARNING, 'deprecated'); $level_human = self::translateErrorLevel($error->get('level')); if (isset($_SERVER['HTTP_HOST'])) { // Output as html jexit("<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n"); } else { // Output as simple text if (defined('STDERR')) { fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n"); jexit(); } else { jexit("J$level_human: " . $error->get('message') . "\n"); } } return $error; }
[ "public", "static", "function", "handleDie", "(", "&", "$", "error", ",", "$", "options", ")", "{", "JLog", "::", "add", "(", "'JError::handleDie() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "$", "level_human", "=", "self", "::", "translateErrorLevel", "(", "$", "error", "->", "get", "(", "'level'", ")", ")", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ")", ")", "{", "// Output as html", "jexit", "(", "\"<br /><b>J$level_human</b>: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"<br />\\n\"", ")", ";", "}", "else", "{", "// Output as simple text", "if", "(", "defined", "(", "'STDERR'", ")", ")", "{", "fwrite", "(", "STDERR", ",", "\"J$level_human: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"\\n\"", ")", ";", "jexit", "(", ")", ";", "}", "else", "{", "jexit", "(", "\"J$level_human: \"", ".", "$", "error", "->", "get", "(", "'message'", ")", ".", "\"\\n\"", ")", ";", "}", "}", "return", "$", "error", ";", "}" ]
Die error handler - Echos the error message to output and then dies @param JException &$error Exception object to handle @param array $options Handler options @return void Calls die() @deprecated 12.1 @see JError::raise() @since 11.1
[ "Die", "error", "handler", "-", "Echos", "the", "error", "message", "to", "output", "and", "then", "dies" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L676-L702
17,942
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.handleMessage
public static function handleMessage(&$error, $options) { JLog::add('JError::hanleMessage() is deprecated.', JLog::WARNING, 'deprecated'); $appl = JFactory::getApplication(); $type = ($error->get('level') == E_NOTICE) ? 'notice' : 'error'; $appl->enqueueMessage($error->get('message'), $type); return $error; }
php
public static function handleMessage(&$error, $options) { JLog::add('JError::hanleMessage() is deprecated.', JLog::WARNING, 'deprecated'); $appl = JFactory::getApplication(); $type = ($error->get('level') == E_NOTICE) ? 'notice' : 'error'; $appl->enqueueMessage($error->get('message'), $type); return $error; }
[ "public", "static", "function", "handleMessage", "(", "&", "$", "error", ",", "$", "options", ")", "{", "JLog", "::", "add", "(", "'JError::hanleMessage() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "$", "appl", "=", "JFactory", "::", "getApplication", "(", ")", ";", "$", "type", "=", "(", "$", "error", "->", "get", "(", "'level'", ")", "==", "E_NOTICE", ")", "?", "'notice'", ":", "'error'", ";", "$", "appl", "->", "enqueueMessage", "(", "$", "error", "->", "get", "(", "'message'", ")", ",", "$", "type", ")", ";", "return", "$", "error", ";", "}" ]
Message error handler Enqueues the error message into the system queue @param JException &$error Exception object to handle @param array $options Handler options @return JException The exception object @deprecated 12.1 @see JError::raise() @since 11.1
[ "Message", "error", "handler", "Enqueues", "the", "error", "message", "into", "the", "system", "queue" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L717-L726
17,943
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.handleLog
public static function handleLog(&$error, $options) { JLog::add('JError::handleLog() is deprecated.', JLog::WARNING, 'deprecated'); static $log; if ($log == null) { $options['text_file'] = date('Y-m-d') . '.error.log'; $options['format'] = "{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}"; JLog::addLogger($options, JLog::ALL, array('error')); } $entry = new JLogEntry( str_replace(array("\r", "\n"), array('', '\\n'), $error->get('message')), $error->get('level'), 'error' ); $entry->code = $error->get('code'); JLog::add($entry); return $error; }
php
public static function handleLog(&$error, $options) { JLog::add('JError::handleLog() is deprecated.', JLog::WARNING, 'deprecated'); static $log; if ($log == null) { $options['text_file'] = date('Y-m-d') . '.error.log'; $options['format'] = "{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}"; JLog::addLogger($options, JLog::ALL, array('error')); } $entry = new JLogEntry( str_replace(array("\r", "\n"), array('', '\\n'), $error->get('message')), $error->get('level'), 'error' ); $entry->code = $error->get('code'); JLog::add($entry); return $error; }
[ "public", "static", "function", "handleLog", "(", "&", "$", "error", ",", "$", "options", ")", "{", "JLog", "::", "add", "(", "'JError::handleLog() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "static", "$", "log", ";", "if", "(", "$", "log", "==", "null", ")", "{", "$", "options", "[", "'text_file'", "]", "=", "date", "(", "'Y-m-d'", ")", ".", "'.error.log'", ";", "$", "options", "[", "'format'", "]", "=", "\"{DATE}\\t{TIME}\\t{LEVEL}\\t{CODE}\\t{MESSAGE}\"", ";", "JLog", "::", "addLogger", "(", "$", "options", ",", "JLog", "::", "ALL", ",", "array", "(", "'error'", ")", ")", ";", "}", "$", "entry", "=", "new", "JLogEntry", "(", "str_replace", "(", "array", "(", "\"\\r\"", ",", "\"\\n\"", ")", ",", "array", "(", "''", ",", "'\\\\n'", ")", ",", "$", "error", "->", "get", "(", "'message'", ")", ")", ",", "$", "error", "->", "get", "(", "'level'", ")", ",", "'error'", ")", ";", "$", "entry", "->", "code", "=", "$", "error", "->", "get", "(", "'code'", ")", ";", "JLog", "::", "add", "(", "$", "entry", ")", ";", "return", "$", "error", ";", "}" ]
Log error handler Logs the error message to a system log file @param JException &$error Exception object to handle @param array $options Handler options @return JException The exception object @deprecated 12.1 @see JError::raise() @since 11.1
[ "Log", "error", "handler", "Logs", "the", "error", "message", "to", "a", "system", "log", "file" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L741-L763
17,944
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.handleCallback
public static function handleCallback(&$error, $options) { JLog::add('JError::handleCallback() is deprecated.', JLog::WARNING, 'deprecated'); return call_user_func($options, $error); }
php
public static function handleCallback(&$error, $options) { JLog::add('JError::handleCallback() is deprecated.', JLog::WARNING, 'deprecated'); return call_user_func($options, $error); }
[ "public", "static", "function", "handleCallback", "(", "&", "$", "error", ",", "$", "options", ")", "{", "JLog", "::", "add", "(", "'JError::handleCallback() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "return", "call_user_func", "(", "$", "options", ",", "$", "error", ")", ";", "}" ]
Callback error handler - Send the error object to a callback method for error handling @param JException &$error Exception object to handle @param array $options Handler options @return JException The exception object @deprecated 12.1 @see JError::raise() @since 11.1
[ "Callback", "error", "handler", "-", "Send", "the", "error", "object", "to", "a", "callback", "method", "for", "error", "handling" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L778-L783
17,945
joomlatools/joomlatools-platform-legacy
code/error/error.php
JError.customErrorHandler
public static function customErrorHandler($level, $msg) { JLog::add('JError::customErrorHandler() is deprecated.', JLog::WARNING, 'deprecated'); self::raise($level, '', $msg); }
php
public static function customErrorHandler($level, $msg) { JLog::add('JError::customErrorHandler() is deprecated.', JLog::WARNING, 'deprecated'); self::raise($level, '', $msg); }
[ "public", "static", "function", "customErrorHandler", "(", "$", "level", ",", "$", "msg", ")", "{", "JLog", "::", "add", "(", "'JError::customErrorHandler() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "self", "::", "raise", "(", "$", "level", ",", "''", ",", "$", "msg", ")", ";", "}" ]
Display a message to the user @param integer $level The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE. @param string $msg Error message, shown to user if need be. @return void @deprecated 12.1 @since 11.1
[ "Display", "a", "message", "to", "the", "user" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/error/error.php#L815-L820
17,946
aedart/laravel-helpers
src/Traits/Filesystem/StorageTrait.php
StorageTrait.getDefaultStorage
public function getDefaultStorage(): ?Filesystem { // By default, the Storage Facade does not return the // any actual storage fisk, but rather an // instance of \Illuminate\Filesystem\FilesystemManager. // Therefore, we make sure only to obtain its // "disk", to make sure that its the correct // instance that we obtain. $manager = Storage::getFacadeRoot(); if (isset($manager)) { return $manager->disk(); } return $manager; }
php
public function getDefaultStorage(): ?Filesystem { // By default, the Storage Facade does not return the // any actual storage fisk, but rather an // instance of \Illuminate\Filesystem\FilesystemManager. // Therefore, we make sure only to obtain its // "disk", to make sure that its the correct // instance that we obtain. $manager = Storage::getFacadeRoot(); if (isset($manager)) { return $manager->disk(); } return $manager; }
[ "public", "function", "getDefaultStorage", "(", ")", ":", "?", "Filesystem", "{", "// By default, the Storage Facade does not return the", "// any actual storage fisk, but rather an", "// instance of \\Illuminate\\Filesystem\\FilesystemManager.", "// Therefore, we make sure only to obtain its", "// \"disk\", to make sure that its the correct", "// instance that we obtain.", "$", "manager", "=", "Storage", "::", "getFacadeRoot", "(", ")", ";", "if", "(", "isset", "(", "$", "manager", ")", ")", "{", "return", "$", "manager", "->", "disk", "(", ")", ";", "}", "return", "$", "manager", ";", "}" ]
Get a default storage value, if any is available @return Filesystem|null A default storage value or Null if no default value is available
[ "Get", "a", "default", "storage", "value", "if", "any", "is", "available" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Filesystem/StorageTrait.php#L76-L89
17,947
yuncms/framework
src/sms/gateways/YuntongxunGateway.php
YuntongxunGateway.buildEndpoint
protected function buildEndpoint($type, $resource, $datetime) { $accountType = $this->isSubAccount ? 'SubAccounts' : 'Accounts'; $sig = strtoupper(md5($this->accountSid . $this->accountToken . $datetime)); return sprintf(self::ENDPOINT_TEMPLATE, self::SERVER_IP, self::SERVER_PORT, self::SDK_VERSION, $accountType, $this->accountSid, $type, $resource, $sig); }
php
protected function buildEndpoint($type, $resource, $datetime) { $accountType = $this->isSubAccount ? 'SubAccounts' : 'Accounts'; $sig = strtoupper(md5($this->accountSid . $this->accountToken . $datetime)); return sprintf(self::ENDPOINT_TEMPLATE, self::SERVER_IP, self::SERVER_PORT, self::SDK_VERSION, $accountType, $this->accountSid, $type, $resource, $sig); }
[ "protected", "function", "buildEndpoint", "(", "$", "type", ",", "$", "resource", ",", "$", "datetime", ")", "{", "$", "accountType", "=", "$", "this", "->", "isSubAccount", "?", "'SubAccounts'", ":", "'Accounts'", ";", "$", "sig", "=", "strtoupper", "(", "md5", "(", "$", "this", "->", "accountSid", ".", "$", "this", "->", "accountToken", ".", "$", "datetime", ")", ")", ";", "return", "sprintf", "(", "self", "::", "ENDPOINT_TEMPLATE", ",", "self", "::", "SERVER_IP", ",", "self", "::", "SERVER_PORT", ",", "self", "::", "SDK_VERSION", ",", "$", "accountType", ",", "$", "this", "->", "accountSid", ",", "$", "type", ",", "$", "resource", ",", "$", "sig", ")", ";", "}" ]
Build endpoint url. @param string $type @param string $resource @param string $datetime @return string
[ "Build", "endpoint", "url", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/gateways/YuntongxunGateway.php#L121-L126
17,948
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.add
public function add($field, $op, $value) { $param = new Expr($field, $op, $value); $this->_params[] = $param; if ($param->useValue()) { $this->addBinding($field, $value); } return $this; }
php
public function add($field, $op, $value) { $param = new Expr($field, $op, $value); $this->_params[] = $param; if ($param->useValue()) { $this->addBinding($field, $value); } return $this; }
[ "public", "function", "add", "(", "$", "field", ",", "$", "op", ",", "$", "value", ")", "{", "$", "param", "=", "new", "Expr", "(", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "$", "this", "->", "_params", "[", "]", "=", "$", "param", ";", "if", "(", "$", "param", "->", "useValue", "(", ")", ")", "{", "$", "this", "->", "addBinding", "(", "$", "field", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Process a parameter before adding it to the list. Set the primary predicate type if it has not been set. @param string $field @param string $op @param mixed $value @return $this
[ "Process", "a", "parameter", "before", "adding", "it", "to", "the", "list", ".", "Set", "the", "primary", "predicate", "type", "if", "it", "has", "not", "been", "set", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L58-L68
17,949
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.also
public function also(Closure $callback) { $predicate = new Predicate(self::ALSO); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
php
public function also(Closure $callback) { $predicate = new Predicate(self::ALSO); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
[ "public", "function", "also", "(", "Closure", "$", "callback", ")", "{", "$", "predicate", "=", "new", "Predicate", "(", "self", "::", "ALSO", ")", ";", "$", "predicate", "->", "bindCallback", "(", "$", "callback", ")", ";", "$", "this", "->", "_params", "[", "]", "=", "$", "predicate", ";", "$", "this", "->", "addBinding", "(", "null", ",", "$", "predicate", ")", ";", "return", "$", "this", ";", "}" ]
Generate a new sub-grouped AND predicate. @param \Closure $callback @return $this
[ "Generate", "a", "new", "sub", "-", "grouped", "AND", "predicate", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L76-L85
17,950
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.between
public function between($field, $start, $end) { $this->add($field, Expr::BETWEEN, [$start, $end]); return $this; }
php
public function between($field, $start, $end) { $this->add($field, Expr::BETWEEN, [$start, $end]); return $this; }
[ "public", "function", "between", "(", "$", "field", ",", "$", "start", ",", "$", "end", ")", "{", "$", "this", "->", "add", "(", "$", "field", ",", "Expr", "::", "BETWEEN", ",", "[", "$", "start", ",", "$", "end", "]", ")", ";", "return", "$", "this", ";", "}" ]
Adds a between range "BETWEEN" expression. @param string $field @param int $start @param int $end @return $this
[ "Adds", "a", "between", "range", "BETWEEN", "expression", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L95-L99
17,951
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.bindCallback
public function bindCallback(Closure $callback, $query = null) { call_user_func_array($callback, [$this, $query]); return $this; }
php
public function bindCallback(Closure $callback, $query = null) { call_user_func_array($callback, [$this, $query]); return $this; }
[ "public", "function", "bindCallback", "(", "Closure", "$", "callback", ",", "$", "query", "=", "null", ")", "{", "call_user_func_array", "(", "$", "callback", ",", "[", "$", "this", ",", "$", "query", "]", ")", ";", "return", "$", "this", ";", "}" ]
Bind a Closure callback to this predicate and execute it. @param \Closure $callback @param \Titon\Db\Query $query @return $this
[ "Bind", "a", "Closure", "callback", "to", "this", "predicate", "and", "execute", "it", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L108-L112
17,952
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.either
public function either(Closure $callback) { $predicate = new Predicate(self::EITHER); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
php
public function either(Closure $callback) { $predicate = new Predicate(self::EITHER); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
[ "public", "function", "either", "(", "Closure", "$", "callback", ")", "{", "$", "predicate", "=", "new", "Predicate", "(", "self", "::", "EITHER", ")", ";", "$", "predicate", "->", "bindCallback", "(", "$", "callback", ")", ";", "$", "this", "->", "_params", "[", "]", "=", "$", "predicate", ";", "$", "this", "->", "addBinding", "(", "null", ",", "$", "predicate", ")", ";", "return", "$", "this", ";", "}" ]
Generate a new sub-grouped OR predicate. @param \Closure $callback @return $this
[ "Generate", "a", "new", "sub", "-", "grouped", "OR", "predicate", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L120-L129
17,953
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.eq
public function eq($field, $value) { if (is_array($value)) { $this->in($field, $value); } else if ($value === null) { $this->null($field); } else { $this->add($field, '=', $value); } return $this; }
php
public function eq($field, $value) { if (is_array($value)) { $this->in($field, $value); } else if ($value === null) { $this->null($field); } else { $this->add($field, '=', $value); } return $this; }
[ "public", "function", "eq", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "in", "(", "$", "field", ",", "$", "value", ")", ";", "}", "else", "if", "(", "$", "value", "===", "null", ")", "{", "$", "this", "->", "null", "(", "$", "field", ")", ";", "}", "else", "{", "$", "this", "->", "add", "(", "$", "field", ",", "'='", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds an equals "=" expression. @param string $field @param mixed $value @return $this
[ "Adds", "an", "equals", "=", "expression", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L138-L150
17,954
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.hasParam
public function hasParam($field) { foreach ($this->getParams() as $param) { if ($param instanceof Expr && $param->getField() === $field) { return true; } } return false; }
php
public function hasParam($field) { foreach ($this->getParams() as $param) { if ($param instanceof Expr && $param->getField() === $field) { return true; } } return false; }
[ "public", "function", "hasParam", "(", "$", "field", ")", "{", "foreach", "(", "$", "this", "->", "getParams", "(", ")", "as", "$", "param", ")", "{", "if", "(", "$", "param", "instanceof", "Expr", "&&", "$", "param", "->", "getField", "(", ")", "===", "$", "field", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Return true if a field has been used in a param. @param string $field @return bool
[ "Return", "true", "if", "a", "field", "has", "been", "used", "in", "a", "param", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L214-L222
17,955
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.like
public function like($field, $value) { $this->add($field, Expr::LIKE, $value); return $this; }
php
public function like($field, $value) { $this->add($field, Expr::LIKE, $value); return $this; }
[ "public", "function", "like", "(", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "add", "(", "$", "field", ",", "Expr", "::", "LIKE", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Adds a like wildcard "LIKE" expression. @param string $field @param mixed $value @return $this
[ "Adds", "a", "like", "wildcard", "LIKE", "expression", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L244-L248
17,956
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.maybe
public function maybe(Closure $callback) { $predicate = new Predicate(self::MAYBE); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
php
public function maybe(Closure $callback) { $predicate = new Predicate(self::MAYBE); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
[ "public", "function", "maybe", "(", "Closure", "$", "callback", ")", "{", "$", "predicate", "=", "new", "Predicate", "(", "self", "::", "MAYBE", ")", ";", "$", "predicate", "->", "bindCallback", "(", "$", "callback", ")", ";", "$", "this", "->", "_params", "[", "]", "=", "$", "predicate", ";", "$", "this", "->", "addBinding", "(", "null", ",", "$", "predicate", ")", ";", "return", "$", "this", ";", "}" ]
Generate a new sub-grouped XOR predicate. @param \Closure $callback @return $this
[ "Generate", "a", "new", "sub", "-", "grouped", "XOR", "predicate", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L282-L291
17,957
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.neither
public function neither(Closure $callback) { $predicate = new Predicate(self::NEITHER); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
php
public function neither(Closure $callback) { $predicate = new Predicate(self::NEITHER); $predicate->bindCallback($callback); $this->_params[] = $predicate; $this->addBinding(null, $predicate); return $this; }
[ "public", "function", "neither", "(", "Closure", "$", "callback", ")", "{", "$", "predicate", "=", "new", "Predicate", "(", "self", "::", "NEITHER", ")", ";", "$", "predicate", "->", "bindCallback", "(", "$", "callback", ")", ";", "$", "this", "->", "_params", "[", "]", "=", "$", "predicate", ";", "$", "this", "->", "addBinding", "(", "null", ",", "$", "predicate", ")", ";", "return", "$", "this", ";", "}" ]
Generate a new sub-grouped NOR predicate. @param \Closure $callback @return $this
[ "Generate", "a", "new", "sub", "-", "grouped", "NOR", "predicate", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L299-L308
17,958
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.notBetween
public function notBetween($field, $start, $end) { $this->add($field, Expr::NOT_BETWEEN, [$start, $end]); return $this; }
php
public function notBetween($field, $start, $end) { $this->add($field, Expr::NOT_BETWEEN, [$start, $end]); return $this; }
[ "public", "function", "notBetween", "(", "$", "field", ",", "$", "start", ",", "$", "end", ")", "{", "$", "this", "->", "add", "(", "$", "field", ",", "Expr", "::", "NOT_BETWEEN", ",", "[", "$", "start", ",", "$", "end", "]", ")", ";", "return", "$", "this", ";", "}" ]
Adds a not between range "NOT BETWEEN" expression. @param string $field @param int $start @param int $end @return $this
[ "Adds", "a", "not", "between", "range", "NOT", "BETWEEN", "expression", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L318-L322
17,959
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.notEq
public function notEq($field, $value) { if (is_array($value)) { $this->notIn($field, $value); } else if ($value === null) { $this->notNull($field); } else { $this->add($field, '!=', $value); } return $this; }
php
public function notEq($field, $value) { if (is_array($value)) { $this->notIn($field, $value); } else if ($value === null) { $this->notNull($field); } else { $this->add($field, '!=', $value); } return $this; }
[ "public", "function", "notEq", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "notIn", "(", "$", "field", ",", "$", "value", ")", ";", "}", "else", "if", "(", "$", "value", "===", "null", ")", "{", "$", "this", "->", "notNull", "(", "$", "field", ")", ";", "}", "else", "{", "$", "this", "->", "add", "(", "$", "field", ",", "'!='", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a not equals "!=" expression. @param string $field @param mixed $value @return $this
[ "Adds", "a", "not", "equals", "!", "=", "expression", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L331-L343
17,960
titon/db
src/Titon/Db/Query/Predicate.php
Predicate.notLike
public function notLike($field, $value) { $this->add($field, Expr::NOT_LIKE, $value); return $this; }
php
public function notLike($field, $value) { $this->add($field, Expr::NOT_LIKE, $value); return $this; }
[ "public", "function", "notLike", "(", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "add", "(", "$", "field", ",", "Expr", "::", "NOT_LIKE", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Adds a not like wildcard "LIKE" expression. @param string $field @param mixed $value @return $this
[ "Adds", "a", "not", "like", "wildcard", "LIKE", "expression", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Predicate.php#L365-L369
17,961
vorbind/influx-analytics
src/AnalyticsTrait.php
AnalyticsTrait.getTimezoneHourOffset
public function getTimezoneHourOffset($origin_tz = 'UTC', $format = 'h') { $remote_tz = 'UTC'; if ($origin_tz === 'UTC') { return 0 . 'h'; } $origin_dtz = new \DateTimeZone($origin_tz); $remote_dtz = new \DateTimeZone($remote_tz); $origin_dt = new \DateTime("now", $origin_dtz); $remote_dt = new \DateTime("now", $remote_dtz); $offset = $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt); return $offset / 3600 . $format; }
php
public function getTimezoneHourOffset($origin_tz = 'UTC', $format = 'h') { $remote_tz = 'UTC'; if ($origin_tz === 'UTC') { return 0 . 'h'; } $origin_dtz = new \DateTimeZone($origin_tz); $remote_dtz = new \DateTimeZone($remote_tz); $origin_dt = new \DateTime("now", $origin_dtz); $remote_dt = new \DateTime("now", $remote_dtz); $offset = $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt); return $offset / 3600 . $format; }
[ "public", "function", "getTimezoneHourOffset", "(", "$", "origin_tz", "=", "'UTC'", ",", "$", "format", "=", "'h'", ")", "{", "$", "remote_tz", "=", "'UTC'", ";", "if", "(", "$", "origin_tz", "===", "'UTC'", ")", "{", "return", "0", ".", "'h'", ";", "}", "$", "origin_dtz", "=", "new", "\\", "DateTimeZone", "(", "$", "origin_tz", ")", ";", "$", "remote_dtz", "=", "new", "\\", "DateTimeZone", "(", "$", "remote_tz", ")", ";", "$", "origin_dt", "=", "new", "\\", "DateTime", "(", "\"now\"", ",", "$", "origin_dtz", ")", ";", "$", "remote_dt", "=", "new", "\\", "DateTime", "(", "\"now\"", ",", "$", "remote_dtz", ")", ";", "$", "offset", "=", "$", "remote_dtz", "->", "getOffset", "(", "$", "remote_dt", ")", "-", "$", "origin_dtz", "->", "getOffset", "(", "$", "origin_dt", ")", ";", "return", "$", "offset", "/", "3600", ".", "$", "format", ";", "}" ]
Get timezone offset in hours @param string $origin_tz @param string $format @return int
[ "Get", "timezone", "offset", "in", "hours" ]
8c0c150351f045ccd3d57063f2b3b50a2c926e3e
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/AnalyticsTrait.php#L33-L45
17,962
vorbind/influx-analytics
src/AnalyticsTrait.php
AnalyticsTrait.arrayMultiSearch
public function arrayMultiSearch($needle, $haystack) { foreach ($haystack as $key => $data) { if (in_array($needle, $data)) { return $key; } } return false; }
php
public function arrayMultiSearch($needle, $haystack) { foreach ($haystack as $key => $data) { if (in_array($needle, $data)) { return $key; } } return false; }
[ "public", "function", "arrayMultiSearch", "(", "$", "needle", ",", "$", "haystack", ")", "{", "foreach", "(", "$", "haystack", "as", "$", "key", "=>", "$", "data", ")", "{", "if", "(", "in_array", "(", "$", "needle", ",", "$", "data", ")", ")", "{", "return", "$", "key", ";", "}", "}", "return", "false", ";", "}" ]
Find key by sub value @param string $needle @param array $haystack @return string
[ "Find", "key", "by", "sub", "value" ]
8c0c150351f045ccd3d57063f2b3b50a2c926e3e
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/AnalyticsTrait.php#L68-L75
17,963
opis/container
src/Container.php
Container.resolve
protected function resolve(string $abstract, array &$stack = []): Dependency { if (isset($this->aliases[$abstract])) { $alias = $this->aliases[$abstract]; if (in_array($alias, $stack)) { $stack[] = $alias; $error = implode(' => ', $stack); throw new BindingException("Circular reference detected: $error"); } else { $stack[] = $alias; return $this->resolve($alias, $stack); } } if (!isset($this->bindings[$abstract])) { $this->bind($abstract, null); } return $this->bindings[$abstract]; }
php
protected function resolve(string $abstract, array &$stack = []): Dependency { if (isset($this->aliases[$abstract])) { $alias = $this->aliases[$abstract]; if (in_array($alias, $stack)) { $stack[] = $alias; $error = implode(' => ', $stack); throw new BindingException("Circular reference detected: $error"); } else { $stack[] = $alias; return $this->resolve($alias, $stack); } } if (!isset($this->bindings[$abstract])) { $this->bind($abstract, null); } return $this->bindings[$abstract]; }
[ "protected", "function", "resolve", "(", "string", "$", "abstract", ",", "array", "&", "$", "stack", "=", "[", "]", ")", ":", "Dependency", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "abstract", "]", ")", ")", "{", "$", "alias", "=", "$", "this", "->", "aliases", "[", "$", "abstract", "]", ";", "if", "(", "in_array", "(", "$", "alias", ",", "$", "stack", ")", ")", "{", "$", "stack", "[", "]", "=", "$", "alias", ";", "$", "error", "=", "implode", "(", "' => '", ",", "$", "stack", ")", ";", "throw", "new", "BindingException", "(", "\"Circular reference detected: $error\"", ")", ";", "}", "else", "{", "$", "stack", "[", "]", "=", "$", "alias", ";", "return", "$", "this", "->", "resolve", "(", "$", "alias", ",", "$", "stack", ")", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "bindings", "[", "$", "abstract", "]", ")", ")", "{", "$", "this", "->", "bind", "(", "$", "abstract", ",", "null", ")", ";", "}", "return", "$", "this", "->", "bindings", "[", "$", "abstract", "]", ";", "}" ]
Resolves an abstract type @param string $abstract @param array $stack @return Dependency
[ "Resolves", "an", "abstract", "type" ]
3cc9da8392e912ad8854ba584f2899a077e067e7
https://github.com/opis/container/blob/3cc9da8392e912ad8854ba584f2899a077e067e7/src/Container.php#L179-L199
17,964
opis/container
src/Container.php
Container.build
protected function build($concrete, array $arguments = []) { if (is_callable($concrete)) { return $concrete($this, $arguments); } if (isset($this->reflectionClass[$concrete])) { $reflection = $this->reflectionClass[$concrete]; } else { try { $reflection = $this->reflectionClass[$concrete] = new ReflectionClass($concrete); } catch (\ReflectionException $e) { throw new BindingException('ReflectionException: ' . $e->getMessage()); } } if (!$reflection->isInstantiable()) { throw new BindingException("The '${concrete}' type is not instantiable"); } if (isset($this->reflectionMethod[$concrete])) { $constructor = $this->reflectionMethod[$concrete]; } else { $constructor = $this->reflectionMethod[$concrete] = $reflection->getConstructor(); } if (is_null($constructor)) { return new $concrete(); } // Resolve arguments $parameters = array_diff_key($constructor->getParameters(), $arguments); /** * @var int $key * @var \ReflectionParameter $parameter */ foreach ($parameters as $key => $parameter) { if (null === $class = $parameter->getClass()) { if ($parameter->isDefaultValueAvailable()) { $arguments[$key] = $parameter->getDefaultValue(); } else { throw new BindingException("Could not resolve [$parameter]"); } continue; } try { $class = $class->name; $arguments[$key] = isset($this->bindings[$class]) ? $this->make($class) : $this->build($class); } catch (BindingException $e) { if (!$parameter->isOptional()) { throw $e; } $arguments[$key] = $parameter->getDefaultValue(); } } ksort($arguments); return $reflection->newInstanceArgs($arguments); }
php
protected function build($concrete, array $arguments = []) { if (is_callable($concrete)) { return $concrete($this, $arguments); } if (isset($this->reflectionClass[$concrete])) { $reflection = $this->reflectionClass[$concrete]; } else { try { $reflection = $this->reflectionClass[$concrete] = new ReflectionClass($concrete); } catch (\ReflectionException $e) { throw new BindingException('ReflectionException: ' . $e->getMessage()); } } if (!$reflection->isInstantiable()) { throw new BindingException("The '${concrete}' type is not instantiable"); } if (isset($this->reflectionMethod[$concrete])) { $constructor = $this->reflectionMethod[$concrete]; } else { $constructor = $this->reflectionMethod[$concrete] = $reflection->getConstructor(); } if (is_null($constructor)) { return new $concrete(); } // Resolve arguments $parameters = array_diff_key($constructor->getParameters(), $arguments); /** * @var int $key * @var \ReflectionParameter $parameter */ foreach ($parameters as $key => $parameter) { if (null === $class = $parameter->getClass()) { if ($parameter->isDefaultValueAvailable()) { $arguments[$key] = $parameter->getDefaultValue(); } else { throw new BindingException("Could not resolve [$parameter]"); } continue; } try { $class = $class->name; $arguments[$key] = isset($this->bindings[$class]) ? $this->make($class) : $this->build($class); } catch (BindingException $e) { if (!$parameter->isOptional()) { throw $e; } $arguments[$key] = $parameter->getDefaultValue(); } } ksort($arguments); return $reflection->newInstanceArgs($arguments); }
[ "protected", "function", "build", "(", "$", "concrete", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "if", "(", "is_callable", "(", "$", "concrete", ")", ")", "{", "return", "$", "concrete", "(", "$", "this", ",", "$", "arguments", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "reflectionClass", "[", "$", "concrete", "]", ")", ")", "{", "$", "reflection", "=", "$", "this", "->", "reflectionClass", "[", "$", "concrete", "]", ";", "}", "else", "{", "try", "{", "$", "reflection", "=", "$", "this", "->", "reflectionClass", "[", "$", "concrete", "]", "=", "new", "ReflectionClass", "(", "$", "concrete", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "throw", "new", "BindingException", "(", "'ReflectionException: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "if", "(", "!", "$", "reflection", "->", "isInstantiable", "(", ")", ")", "{", "throw", "new", "BindingException", "(", "\"The '${concrete}' type is not instantiable\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "reflectionMethod", "[", "$", "concrete", "]", ")", ")", "{", "$", "constructor", "=", "$", "this", "->", "reflectionMethod", "[", "$", "concrete", "]", ";", "}", "else", "{", "$", "constructor", "=", "$", "this", "->", "reflectionMethod", "[", "$", "concrete", "]", "=", "$", "reflection", "->", "getConstructor", "(", ")", ";", "}", "if", "(", "is_null", "(", "$", "constructor", ")", ")", "{", "return", "new", "$", "concrete", "(", ")", ";", "}", "// Resolve arguments", "$", "parameters", "=", "array_diff_key", "(", "$", "constructor", "->", "getParameters", "(", ")", ",", "$", "arguments", ")", ";", "/**\n * @var int $key\n * @var \\ReflectionParameter $parameter\n */", "foreach", "(", "$", "parameters", "as", "$", "key", "=>", "$", "parameter", ")", "{", "if", "(", "null", "===", "$", "class", "=", "$", "parameter", "->", "getClass", "(", ")", ")", "{", "if", "(", "$", "parameter", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "arguments", "[", "$", "key", "]", "=", "$", "parameter", "->", "getDefaultValue", "(", ")", ";", "}", "else", "{", "throw", "new", "BindingException", "(", "\"Could not resolve [$parameter]\"", ")", ";", "}", "continue", ";", "}", "try", "{", "$", "class", "=", "$", "class", "->", "name", ";", "$", "arguments", "[", "$", "key", "]", "=", "isset", "(", "$", "this", "->", "bindings", "[", "$", "class", "]", ")", "?", "$", "this", "->", "make", "(", "$", "class", ")", ":", "$", "this", "->", "build", "(", "$", "class", ")", ";", "}", "catch", "(", "BindingException", "$", "e", ")", "{", "if", "(", "!", "$", "parameter", "->", "isOptional", "(", ")", ")", "{", "throw", "$", "e", ";", "}", "$", "arguments", "[", "$", "key", "]", "=", "$", "parameter", "->", "getDefaultValue", "(", ")", ";", "}", "}", "ksort", "(", "$", "arguments", ")", ";", "return", "$", "reflection", "->", "newInstanceArgs", "(", "$", "arguments", ")", ";", "}" ]
Builds an instance of a concrete type @param string|callable $concrete @param array $arguments @return object
[ "Builds", "an", "instance", "of", "a", "concrete", "type" ]
3cc9da8392e912ad8854ba584f2899a077e067e7
https://github.com/opis/container/blob/3cc9da8392e912ad8854ba584f2899a077e067e7/src/Container.php#L208-L269
17,965
arsengoian/viper-framework
src/Viper/Template/Viper.php
Viper.parse
public function parse() { /** @noinspection PhpParamsInspection */ return $this -> execute(Util::cache( $this -> file, $this -> raw, 'viper', function($data): NodeCollection { $tokens = $this -> tokenize($data); return $this -> formLogicalTree($tokens); } ), $this -> data); }
php
public function parse() { /** @noinspection PhpParamsInspection */ return $this -> execute(Util::cache( $this -> file, $this -> raw, 'viper', function($data): NodeCollection { $tokens = $this -> tokenize($data); return $this -> formLogicalTree($tokens); } ), $this -> data); }
[ "public", "function", "parse", "(", ")", "{", "/** @noinspection PhpParamsInspection */", "return", "$", "this", "->", "execute", "(", "Util", "::", "cache", "(", "$", "this", "->", "file", ",", "$", "this", "->", "raw", ",", "'viper'", ",", "function", "(", "$", "data", ")", ":", "NodeCollection", "{", "$", "tokens", "=", "$", "this", "->", "tokenize", "(", "$", "data", ")", ";", "return", "$", "this", "->", "formLogicalTree", "(", "$", "tokens", ")", ";", "}", ")", ",", "$", "this", "->", "data", ")", ";", "}" ]
Chief executive viper function
[ "Chief", "executive", "viper", "function" ]
22796c5cc219cae3ca0b4af370a347ba2acab0f2
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Template/Viper.php#L39-L50
17,966
xinix-technology/norm
src/Norm/Connection.php
Connection.factory
public function factory($collection) { if ($collection instanceof Collection) { $collectionName = $collection->getName(); } else { $collectionName = $collection; } if (!isset($this->collections[$collectionName])) { if (!($collection instanceof Collection)) { $collection = Norm::createCollection(array( 'name' => $collection, 'connection' => $this, )); $this->applyHook('norm.after.factory', $collection); } $this->collections[$collectionName] = $collection; } return $this->collections[$collectionName]; }
php
public function factory($collection) { if ($collection instanceof Collection) { $collectionName = $collection->getName(); } else { $collectionName = $collection; } if (!isset($this->collections[$collectionName])) { if (!($collection instanceof Collection)) { $collection = Norm::createCollection(array( 'name' => $collection, 'connection' => $this, )); $this->applyHook('norm.after.factory', $collection); } $this->collections[$collectionName] = $collection; } return $this->collections[$collectionName]; }
[ "public", "function", "factory", "(", "$", "collection", ")", "{", "if", "(", "$", "collection", "instanceof", "Collection", ")", "{", "$", "collectionName", "=", "$", "collection", "->", "getName", "(", ")", ";", "}", "else", "{", "$", "collectionName", "=", "$", "collection", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "collections", "[", "$", "collectionName", "]", ")", ")", "{", "if", "(", "!", "(", "$", "collection", "instanceof", "Collection", ")", ")", "{", "$", "collection", "=", "Norm", "::", "createCollection", "(", "array", "(", "'name'", "=>", "$", "collection", ",", "'connection'", "=>", "$", "this", ",", ")", ")", ";", "$", "this", "->", "applyHook", "(", "'norm.after.factory'", ",", "$", "collection", ")", ";", "}", "$", "this", "->", "collections", "[", "$", "collectionName", "]", "=", "$", "collection", ";", "}", "return", "$", "this", "->", "collections", "[", "$", "collectionName", "]", ";", "}" ]
Factory to create new collection by its name or instance @param string|Norm\Collection $collection Collection name or instance @return Norm\Collection Conllection created by factory
[ "Factory", "to", "create", "new", "collection", "by", "its", "name", "or", "instance" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection.php#L102-L124
17,967
xinix-technology/norm
src/Norm/Connection.php
Connection.unmarshall
public function unmarshall($object) { if (isset($object['id'])) { $object['$id'] = $object['id']; unset($object['id']); } foreach ($object as $key => $value) { if ($key[0] === '_') { $key[0] = '$'; $object[$key] = $value; } } return $object; }
php
public function unmarshall($object) { if (isset($object['id'])) { $object['$id'] = $object['id']; unset($object['id']); } foreach ($object as $key => $value) { if ($key[0] === '_') { $key[0] = '$'; $object[$key] = $value; } } return $object; }
[ "public", "function", "unmarshall", "(", "$", "object", ")", "{", "if", "(", "isset", "(", "$", "object", "[", "'id'", "]", ")", ")", "{", "$", "object", "[", "'$id'", "]", "=", "$", "object", "[", "'id'", "]", ";", "unset", "(", "$", "object", "[", "'id'", "]", ")", ";", "}", "foreach", "(", "$", "object", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "[", "0", "]", "===", "'_'", ")", "{", "$", "key", "[", "0", "]", "=", "'$'", ";", "$", "object", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "object", ";", "}" ]
Unmarshall single object from data source to associative array. The unmarshall process is necessary due to different data type provided by data source. Proper unmarshall will make sure data from data source that will be consumed by Norm in the accepted form of data. @see Norm\Connection::marshall() @param mixed $object Object from data source @return assoc Friendly norm data
[ "Unmarshall", "single", "object", "from", "data", "source", "to", "associative", "array", ".", "The", "unmarshall", "process", "is", "necessary", "due", "to", "different", "data", "type", "provided", "by", "data", "source", ".", "Proper", "unmarshall", "will", "make", "sure", "data", "from", "data", "source", "that", "will", "be", "consumed", "by", "Norm", "in", "the", "accepted", "form", "of", "data", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection.php#L138-L153
17,968
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Entry/Atom.php
Zend_Feed_Entry_Atom.delete
public function delete() { // Look for link rel="edit" in the entry object. $deleteUri = $this->link('edit'); if (!$deleteUri) { /** * @see Zend_Feed_Exception */ require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Cannot delete entry; no link rel="edit" is present.'); } // DELETE $client = Zend_Feed::getHttpClient(); do { $client->setUri($deleteUri); if (Zend_Feed::getHttpMethodOverride()) { $client->setHeader('X-HTTP-Method-Override', 'DELETE'); $response = $client->request('POST'); } else { $response = $client->request('DELETE'); } $httpStatus = $response->getStatus(); switch ((int) $httpStatus / 100) { // Success case 2: return true; // Redirect case 3: $deleteUri = $response->getHeader('Location'); continue; // Error default: /** * @see Zend_Feed_Exception */ require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("Expected response code 2xx, got $httpStatus"); } } while (true); }
php
public function delete() { // Look for link rel="edit" in the entry object. $deleteUri = $this->link('edit'); if (!$deleteUri) { /** * @see Zend_Feed_Exception */ require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Cannot delete entry; no link rel="edit" is present.'); } // DELETE $client = Zend_Feed::getHttpClient(); do { $client->setUri($deleteUri); if (Zend_Feed::getHttpMethodOverride()) { $client->setHeader('X-HTTP-Method-Override', 'DELETE'); $response = $client->request('POST'); } else { $response = $client->request('DELETE'); } $httpStatus = $response->getStatus(); switch ((int) $httpStatus / 100) { // Success case 2: return true; // Redirect case 3: $deleteUri = $response->getHeader('Location'); continue; // Error default: /** * @see Zend_Feed_Exception */ require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception("Expected response code 2xx, got $httpStatus"); } } while (true); }
[ "public", "function", "delete", "(", ")", "{", "// Look for link rel=\"edit\" in the entry object.", "$", "deleteUri", "=", "$", "this", "->", "link", "(", "'edit'", ")", ";", "if", "(", "!", "$", "deleteUri", ")", "{", "/**\n * @see Zend_Feed_Exception\n */", "require_once", "'Zend/Feed/Exception.php'", ";", "throw", "new", "Zend_Feed_Exception", "(", "'Cannot delete entry; no link rel=\"edit\" is present.'", ")", ";", "}", "// DELETE", "$", "client", "=", "Zend_Feed", "::", "getHttpClient", "(", ")", ";", "do", "{", "$", "client", "->", "setUri", "(", "$", "deleteUri", ")", ";", "if", "(", "Zend_Feed", "::", "getHttpMethodOverride", "(", ")", ")", "{", "$", "client", "->", "setHeader", "(", "'X-HTTP-Method-Override'", ",", "'DELETE'", ")", ";", "$", "response", "=", "$", "client", "->", "request", "(", "'POST'", ")", ";", "}", "else", "{", "$", "response", "=", "$", "client", "->", "request", "(", "'DELETE'", ")", ";", "}", "$", "httpStatus", "=", "$", "response", "->", "getStatus", "(", ")", ";", "switch", "(", "(", "int", ")", "$", "httpStatus", "/", "100", ")", "{", "// Success", "case", "2", ":", "return", "true", ";", "// Redirect", "case", "3", ":", "$", "deleteUri", "=", "$", "response", "->", "getHeader", "(", "'Location'", ")", ";", "continue", ";", "// Error", "default", ":", "/**\n * @see Zend_Feed_Exception\n */", "require_once", "'Zend/Feed/Exception.php'", ";", "throw", "new", "Zend_Feed_Exception", "(", "\"Expected response code 2xx, got $httpStatus\"", ")", ";", "}", "}", "while", "(", "true", ")", ";", "}" ]
Delete an atom entry. Delete tries to delete this entry from its feed. If the entry does not contain a link rel="edit", we throw an error (either the entry does not yet exist or this is not an editable feed). If we have a link rel="edit", we do the empty-body HTTP DELETE to that URI and check for a response of 2xx. Usually the response would be 204 No Content, but the Atom Publishing Protocol permits it to be 200 OK. @return void @throws Zend_Feed_Exception
[ "Delete", "an", "atom", "entry", "." ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Entry/Atom.php#L74-L114
17,969
2amigos/yiifoundation
widgets/Breadcrumbs.php
Breadcrumbs.initItems
public function initItems() { if (!empty($this->items)) { $links = array(); if ($this->homeLabel !== false) { $label = $this->homeLabel !== null ? $this->homeLabel : Icon::icon(Enum::ICON_HOME); $links[$label] = array('href' => $this->homeUrl !== null ? $this->homeUrl : \Yii::app()->homeUrl); } foreach ($this->items as $label => $options) { if (is_string($label)) { if ($this->encodeLabel) $label = \CHtml::encode($label); if (is_string($options)) $links[$label] = array('href' => \CHtml::normalizeUrl($options)); else { $url = ArrayHelper::removeValue($options, 'url', ''); $options['href'] = \CHtml::normalizeUrl($url); $links[$label] = $options; } } else $links[$options] = array('href' => '#'); } $this->items = $links; } }
php
public function initItems() { if (!empty($this->items)) { $links = array(); if ($this->homeLabel !== false) { $label = $this->homeLabel !== null ? $this->homeLabel : Icon::icon(Enum::ICON_HOME); $links[$label] = array('href' => $this->homeUrl !== null ? $this->homeUrl : \Yii::app()->homeUrl); } foreach ($this->items as $label => $options) { if (is_string($label)) { if ($this->encodeLabel) $label = \CHtml::encode($label); if (is_string($options)) $links[$label] = array('href' => \CHtml::normalizeUrl($options)); else { $url = ArrayHelper::removeValue($options, 'url', ''); $options['href'] = \CHtml::normalizeUrl($url); $links[$label] = $options; } } else $links[$options] = array('href' => '#'); } $this->items = $links; } }
[ "public", "function", "initItems", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "items", ")", ")", "{", "$", "links", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "homeLabel", "!==", "false", ")", "{", "$", "label", "=", "$", "this", "->", "homeLabel", "!==", "null", "?", "$", "this", "->", "homeLabel", ":", "Icon", "::", "icon", "(", "Enum", "::", "ICON_HOME", ")", ";", "$", "links", "[", "$", "label", "]", "=", "array", "(", "'href'", "=>", "$", "this", "->", "homeUrl", "!==", "null", "?", "$", "this", "->", "homeUrl", ":", "\\", "Yii", "::", "app", "(", ")", "->", "homeUrl", ")", ";", "}", "foreach", "(", "$", "this", "->", "items", "as", "$", "label", "=>", "$", "options", ")", "{", "if", "(", "is_string", "(", "$", "label", ")", ")", "{", "if", "(", "$", "this", "->", "encodeLabel", ")", "$", "label", "=", "\\", "CHtml", "::", "encode", "(", "$", "label", ")", ";", "if", "(", "is_string", "(", "$", "options", ")", ")", "$", "links", "[", "$", "label", "]", "=", "array", "(", "'href'", "=>", "\\", "CHtml", "::", "normalizeUrl", "(", "$", "options", ")", ")", ";", "else", "{", "$", "url", "=", "ArrayHelper", "::", "removeValue", "(", "$", "options", ",", "'url'", ",", "''", ")", ";", "$", "options", "[", "'href'", "]", "=", "\\", "CHtml", "::", "normalizeUrl", "(", "$", "url", ")", ";", "$", "links", "[", "$", "label", "]", "=", "$", "options", ";", "}", "}", "else", "$", "links", "[", "$", "options", "]", "=", "array", "(", "'href'", "=>", "'#'", ")", ";", "}", "$", "this", "->", "items", "=", "$", "links", ";", "}", "}" ]
Initializes menu items
[ "Initializes", "menu", "items" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Breadcrumbs.php#L71-L96
17,970
2amigos/yiifoundation
widgets/Breadcrumbs.php
Breadcrumbs.renderItem
public function renderItem($label, $options = array()) { if ($this->tagName === 'nav') { $url = ArrayHelper::removeValue($options, 'href', '#'); $htmlOptions = ArrayHelper::removeValue($options, 'options', array()); echo \CHtml::openTag('li', $htmlOptions); echo \CHtml::link($label, $url); echo \CHtml::closeTag('li'); } else { $htmlOptions = ArrayHelper::removeValue($options, 'options', array()); echo \CHtml::tag('a', array_merge($htmlOptions, $options), $label); } }
php
public function renderItem($label, $options = array()) { if ($this->tagName === 'nav') { $url = ArrayHelper::removeValue($options, 'href', '#'); $htmlOptions = ArrayHelper::removeValue($options, 'options', array()); echo \CHtml::openTag('li', $htmlOptions); echo \CHtml::link($label, $url); echo \CHtml::closeTag('li'); } else { $htmlOptions = ArrayHelper::removeValue($options, 'options', array()); echo \CHtml::tag('a', array_merge($htmlOptions, $options), $label); } }
[ "public", "function", "renderItem", "(", "$", "label", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "tagName", "===", "'nav'", ")", "{", "$", "url", "=", "ArrayHelper", "::", "removeValue", "(", "$", "options", ",", "'href'", ",", "'#'", ")", ";", "$", "htmlOptions", "=", "ArrayHelper", "::", "removeValue", "(", "$", "options", ",", "'options'", ",", "array", "(", ")", ")", ";", "echo", "\\", "CHtml", "::", "openTag", "(", "'li'", ",", "$", "htmlOptions", ")", ";", "echo", "\\", "CHtml", "::", "link", "(", "$", "label", ",", "$", "url", ")", ";", "echo", "\\", "CHtml", "::", "closeTag", "(", "'li'", ")", ";", "}", "else", "{", "$", "htmlOptions", "=", "ArrayHelper", "::", "removeValue", "(", "$", "options", ",", "'options'", ",", "array", "(", ")", ")", ";", "echo", "\\", "CHtml", "::", "tag", "(", "'a'", ",", "array_merge", "(", "$", "htmlOptions", ",", "$", "options", ")", ",", "$", "label", ")", ";", "}", "}" ]
Generates the rendering of a breadcrumb item @param string $label @param array $options
[ "Generates", "the", "rendering", "of", "a", "breadcrumb", "item" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Breadcrumbs.php#L120-L132
17,971
forxer/tao
src/Tao/Html/Modifiers.php
Modifiers.strToSlug
static public function strToSlug($string, $bWithSlashes = true) { switch ($GLOBALS['okt']->config->slug_type) { case 'utf8': return self::tidyURL($string, $bWithSlashes); case 'ascii': default: return self::strToLowerURL($string, $bWithSlashes); } }
php
static public function strToSlug($string, $bWithSlashes = true) { switch ($GLOBALS['okt']->config->slug_type) { case 'utf8': return self::tidyURL($string, $bWithSlashes); case 'ascii': default: return self::strToLowerURL($string, $bWithSlashes); } }
[ "static", "public", "function", "strToSlug", "(", "$", "string", ",", "$", "bWithSlashes", "=", "true", ")", "{", "switch", "(", "$", "GLOBALS", "[", "'okt'", "]", "->", "config", "->", "slug_type", ")", "{", "case", "'utf8'", ":", "return", "self", "::", "tidyURL", "(", "$", "string", ",", "$", "bWithSlashes", ")", ";", "case", "'ascii'", ":", "default", ":", "return", "self", "::", "strToLowerURL", "(", "$", "string", ",", "$", "bWithSlashes", ")", ";", "}", "}" ]
Transform a string in slug regarding to Okatea configuration. @param string $string String to transform @param boolean $bWithSlashes in URL @return string
[ "Transform", "a", "string", "in", "slug", "regarding", "to", "Okatea", "configuration", "." ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Html/Modifiers.php#L28-L39
17,972
forxer/tao
src/Tao/Html/Modifiers.php
Modifiers.strToUrl
public static function strToUrl($string, $bWithSlashes = true) { $string = self::deaccent($string); $string = preg_replace('/[^A-Za-z0-9_\s\'\:\/[\]-]/', '', $string); return self::tidyUrl($string, $bWithSlashes); }
php
public static function strToUrl($string, $bWithSlashes = true) { $string = self::deaccent($string); $string = preg_replace('/[^A-Za-z0-9_\s\'\:\/[\]-]/', '', $string); return self::tidyUrl($string, $bWithSlashes); }
[ "public", "static", "function", "strToUrl", "(", "$", "string", ",", "$", "bWithSlashes", "=", "true", ")", "{", "$", "string", "=", "self", "::", "deaccent", "(", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'/[^A-Za-z0-9_\\s\\'\\:\\/[\\]-]/'", ",", "''", ",", "$", "string", ")", ";", "return", "self", "::", "tidyUrl", "(", "$", "string", ",", "$", "bWithSlashes", ")", ";", "}" ]
String to URL Transforms a string to a proper URL. @copyright Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html @param string $string String to transform @param boolean $bWithSlashes in URL @return string
[ "String", "to", "URL" ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Html/Modifiers.php#L53-L59
17,973
forxer/tao
src/Tao/Html/Modifiers.php
Modifiers.strToCamelCase
static public function strToCamelCase($string) { $string = self::strToLowerUrl($string, false); $string = implode('', array_map('ucfirst', explode('_', $string))); $string = implode('', array_map('ucfirst', explode('-', $string))); return strtolower(substr($string, 0, 1)) . substr($string, 1); }
php
static public function strToCamelCase($string) { $string = self::strToLowerUrl($string, false); $string = implode('', array_map('ucfirst', explode('_', $string))); $string = implode('', array_map('ucfirst', explode('-', $string))); return strtolower(substr($string, 0, 1)) . substr($string, 1); }
[ "static", "public", "function", "strToCamelCase", "(", "$", "string", ")", "{", "$", "string", "=", "self", "::", "strToLowerUrl", "(", "$", "string", ",", "false", ")", ";", "$", "string", "=", "implode", "(", "''", ",", "array_map", "(", "'ucfirst'", ",", "explode", "(", "'_'", ",", "$", "string", ")", ")", ")", ";", "$", "string", "=", "implode", "(", "''", ",", "array_map", "(", "'ucfirst'", ",", "explode", "(", "'-'", ",", "$", "string", ")", ")", ")", ";", "return", "strtolower", "(", "substr", "(", "$", "string", ",", "0", ",", "1", ")", ")", ".", "substr", "(", "$", "string", ",", "1", ")", ";", "}" ]
Transform a string in a camelCase style. @param string $string @return string
[ "Transform", "a", "string", "in", "a", "camelCase", "style", "." ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Html/Modifiers.php#L81-L89
17,974
forxer/tao
src/Tao/Html/Modifiers.php
Modifiers.deaccent
public static function deaccent($string) { $pattern = []; $pattern['A'] = '\x{00C0}-\x{00C5}'; $pattern['AE'] = '\x{00C6}'; $pattern['C'] = '\x{00C7}'; $pattern['D'] = '\x{00D0}'; $pattern['E'] = '\x{00C8}-\x{00CB}'; $pattern['I'] = '\x{00CC}-\x{00CF}'; $pattern['N'] = '\x{00D1}'; $pattern['O'] = '\x{00D2}-\x{00D6}\x{00D8}'; $pattern['OE'] = '\x{0152}'; $pattern['S'] = '\x{0160}'; $pattern['U'] = '\x{00D9}-\x{00DC}'; $pattern['Y'] = '\x{00DD}'; $pattern['Z'] = '\x{017D}'; $pattern['a'] = '\x{00E0}-\x{00E5}'; $pattern['ae'] = '\x{00E6}'; $pattern['c'] = '\x{00E7}'; $pattern['d'] = '\x{00F0}'; $pattern['e'] = '\x{00E8}-\x{00EB}'; $pattern['i'] = '\x{00EC}-\x{00EF}'; $pattern['n'] = '\x{00F1}'; $pattern['o'] = '\x{00F2}-\x{00F6}\x{00F8}'; $pattern['oe'] = '\x{0153}'; $pattern['s'] = '\x{0161}'; $pattern['u'] = '\x{00F9}-\x{00FC}'; $pattern['y'] = '\x{00FD}\x{00FF}'; $pattern['z'] = '\x{017E}'; $pattern['ss'] = '\x{00DF}'; foreach ($pattern as $r => $p) { $string = preg_replace('/[' . $p . ']/u', $r, $string); } return $string; }
php
public static function deaccent($string) { $pattern = []; $pattern['A'] = '\x{00C0}-\x{00C5}'; $pattern['AE'] = '\x{00C6}'; $pattern['C'] = '\x{00C7}'; $pattern['D'] = '\x{00D0}'; $pattern['E'] = '\x{00C8}-\x{00CB}'; $pattern['I'] = '\x{00CC}-\x{00CF}'; $pattern['N'] = '\x{00D1}'; $pattern['O'] = '\x{00D2}-\x{00D6}\x{00D8}'; $pattern['OE'] = '\x{0152}'; $pattern['S'] = '\x{0160}'; $pattern['U'] = '\x{00D9}-\x{00DC}'; $pattern['Y'] = '\x{00DD}'; $pattern['Z'] = '\x{017D}'; $pattern['a'] = '\x{00E0}-\x{00E5}'; $pattern['ae'] = '\x{00E6}'; $pattern['c'] = '\x{00E7}'; $pattern['d'] = '\x{00F0}'; $pattern['e'] = '\x{00E8}-\x{00EB}'; $pattern['i'] = '\x{00EC}-\x{00EF}'; $pattern['n'] = '\x{00F1}'; $pattern['o'] = '\x{00F2}-\x{00F6}\x{00F8}'; $pattern['oe'] = '\x{0153}'; $pattern['s'] = '\x{0161}'; $pattern['u'] = '\x{00F9}-\x{00FC}'; $pattern['y'] = '\x{00FD}\x{00FF}'; $pattern['z'] = '\x{017E}'; $pattern['ss'] = '\x{00DF}'; foreach ($pattern as $r => $p) { $string = preg_replace('/[' . $p . ']/u', $r, $string); } return $string; }
[ "public", "static", "function", "deaccent", "(", "$", "string", ")", "{", "$", "pattern", "=", "[", "]", ";", "$", "pattern", "[", "'A'", "]", "=", "'\\x{00C0}-\\x{00C5}'", ";", "$", "pattern", "[", "'AE'", "]", "=", "'\\x{00C6}'", ";", "$", "pattern", "[", "'C'", "]", "=", "'\\x{00C7}'", ";", "$", "pattern", "[", "'D'", "]", "=", "'\\x{00D0}'", ";", "$", "pattern", "[", "'E'", "]", "=", "'\\x{00C8}-\\x{00CB}'", ";", "$", "pattern", "[", "'I'", "]", "=", "'\\x{00CC}-\\x{00CF}'", ";", "$", "pattern", "[", "'N'", "]", "=", "'\\x{00D1}'", ";", "$", "pattern", "[", "'O'", "]", "=", "'\\x{00D2}-\\x{00D6}\\x{00D8}'", ";", "$", "pattern", "[", "'OE'", "]", "=", "'\\x{0152}'", ";", "$", "pattern", "[", "'S'", "]", "=", "'\\x{0160}'", ";", "$", "pattern", "[", "'U'", "]", "=", "'\\x{00D9}-\\x{00DC}'", ";", "$", "pattern", "[", "'Y'", "]", "=", "'\\x{00DD}'", ";", "$", "pattern", "[", "'Z'", "]", "=", "'\\x{017D}'", ";", "$", "pattern", "[", "'a'", "]", "=", "'\\x{00E0}-\\x{00E5}'", ";", "$", "pattern", "[", "'ae'", "]", "=", "'\\x{00E6}'", ";", "$", "pattern", "[", "'c'", "]", "=", "'\\x{00E7}'", ";", "$", "pattern", "[", "'d'", "]", "=", "'\\x{00F0}'", ";", "$", "pattern", "[", "'e'", "]", "=", "'\\x{00E8}-\\x{00EB}'", ";", "$", "pattern", "[", "'i'", "]", "=", "'\\x{00EC}-\\x{00EF}'", ";", "$", "pattern", "[", "'n'", "]", "=", "'\\x{00F1}'", ";", "$", "pattern", "[", "'o'", "]", "=", "'\\x{00F2}-\\x{00F6}\\x{00F8}'", ";", "$", "pattern", "[", "'oe'", "]", "=", "'\\x{0153}'", ";", "$", "pattern", "[", "'s'", "]", "=", "'\\x{0161}'", ";", "$", "pattern", "[", "'u'", "]", "=", "'\\x{00F9}-\\x{00FC}'", ";", "$", "pattern", "[", "'y'", "]", "=", "'\\x{00FD}\\x{00FF}'", ";", "$", "pattern", "[", "'z'", "]", "=", "'\\x{017E}'", ";", "$", "pattern", "[", "'ss'", "]", "=", "'\\x{00DF}'", ";", "foreach", "(", "$", "pattern", "as", "$", "r", "=>", "$", "p", ")", "{", "$", "string", "=", "preg_replace", "(", "'/['", ".", "$", "p", ".", "']/u'", ",", "$", "r", ",", "$", "string", ")", ";", "}", "return", "$", "string", ";", "}" ]
Accents replacement. Replaces some occidental accentuated characters by their ASCII representation. @copyright Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html @param string $string deaccent @return string
[ "Accents", "replacement", "." ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Html/Modifiers.php#L117-L156
17,975
forxer/tao
src/Tao/Html/Modifiers.php
Modifiers.tidyUrl
public static function tidyUrl($string, $bKeepSlashes = true, $bKeepSpaces = false) { $string = strip_tags($string); $string = str_replace([ '?', '&', '#', '=', '+', '<', '>', '"', '%' ], '', $string); $string = str_replace("'", ' ', $string); $string = preg_replace('/[\s]+/u', ' ', trim($string)); if (!$bKeepSlashes) { $string = str_replace('/', '-', $string); } if (!$bKeepSpaces) { $string = str_replace(' ', '-', $string); } $string = preg_replace('/[-]+/', '-', $string); # Remove path changes in URL $string = preg_replace('%^/%', '', $string); $string = preg_replace('%\.+/%', '', $string); return $string; }
php
public static function tidyUrl($string, $bKeepSlashes = true, $bKeepSpaces = false) { $string = strip_tags($string); $string = str_replace([ '?', '&', '#', '=', '+', '<', '>', '"', '%' ], '', $string); $string = str_replace("'", ' ', $string); $string = preg_replace('/[\s]+/u', ' ', trim($string)); if (!$bKeepSlashes) { $string = str_replace('/', '-', $string); } if (!$bKeepSpaces) { $string = str_replace(' ', '-', $string); } $string = preg_replace('/[-]+/', '-', $string); # Remove path changes in URL $string = preg_replace('%^/%', '', $string); $string = preg_replace('%\.+/%', '', $string); return $string; }
[ "public", "static", "function", "tidyUrl", "(", "$", "string", ",", "$", "bKeepSlashes", "=", "true", ",", "$", "bKeepSpaces", "=", "false", ")", "{", "$", "string", "=", "strip_tags", "(", "$", "string", ")", ";", "$", "string", "=", "str_replace", "(", "[", "'?'", ",", "'&'", ",", "'#'", ",", "'='", ",", "'+'", ",", "'<'", ",", "'>'", ",", "'\"'", ",", "'%'", "]", ",", "''", ",", "$", "string", ")", ";", "$", "string", "=", "str_replace", "(", "\"'\"", ",", "' '", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'/[\\s]+/u'", ",", "' '", ",", "trim", "(", "$", "string", ")", ")", ";", "if", "(", "!", "$", "bKeepSlashes", ")", "{", "$", "string", "=", "str_replace", "(", "'/'", ",", "'-'", ",", "$", "string", ")", ";", "}", "if", "(", "!", "$", "bKeepSpaces", ")", "{", "$", "string", "=", "str_replace", "(", "' '", ",", "'-'", ",", "$", "string", ")", ";", "}", "$", "string", "=", "preg_replace", "(", "'/[-]+/'", ",", "'-'", ",", "$", "string", ")", ";", "# Remove path changes in URL", "$", "string", "=", "preg_replace", "(", "'%^/%'", ",", "''", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'%\\.+/%'", ",", "''", ",", "$", "string", ")", ";", "return", "$", "string", ";", "}" ]
URL cleanup. @copyright Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html @param string $string tidy @param boolean $bKeepSlashes in URL @param boolean $bKeepSpaces in URL @return string
[ "URL", "cleanup", "." ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Html/Modifiers.php#L172-L204
17,976
xinix-technology/norm
src/Norm/Norm.php
Norm.init
public static function init($config, $collectionConfig = array()) { $first = null; static::$collectionConfig = $collectionConfig; if (empty($config)) { return; } foreach ($config as $key => $value) { $value['name'] = $key; if (!isset($value['driver'])) { throw new Exception( '[Norm] Cannot instantiate connection "'.$key. '", Driver "'.@$value['driver'].'" not found!' ); } $Driver = $value['driver']; static::$connections[$key] = new $Driver($value); if (!static::$connections[$key] instanceof Connection) { throw new Exception('Norm connection ['.$key.'] should be instance of Connection'); } if (!$first) { $first = $key; } } if (!static::$defaultConnection) { static::$defaultConnection = $first; } }
php
public static function init($config, $collectionConfig = array()) { $first = null; static::$collectionConfig = $collectionConfig; if (empty($config)) { return; } foreach ($config as $key => $value) { $value['name'] = $key; if (!isset($value['driver'])) { throw new Exception( '[Norm] Cannot instantiate connection "'.$key. '", Driver "'.@$value['driver'].'" not found!' ); } $Driver = $value['driver']; static::$connections[$key] = new $Driver($value); if (!static::$connections[$key] instanceof Connection) { throw new Exception('Norm connection ['.$key.'] should be instance of Connection'); } if (!$first) { $first = $key; } } if (!static::$defaultConnection) { static::$defaultConnection = $first; } }
[ "public", "static", "function", "init", "(", "$", "config", ",", "$", "collectionConfig", "=", "array", "(", ")", ")", "{", "$", "first", "=", "null", ";", "static", "::", "$", "collectionConfig", "=", "$", "collectionConfig", ";", "if", "(", "empty", "(", "$", "config", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "value", "[", "'name'", "]", "=", "$", "key", ";", "if", "(", "!", "isset", "(", "$", "value", "[", "'driver'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'[Norm] Cannot instantiate connection \"'", ".", "$", "key", ".", "'\", Driver \"'", ".", "@", "$", "value", "[", "'driver'", "]", ".", "'\" not found!'", ")", ";", "}", "$", "Driver", "=", "$", "value", "[", "'driver'", "]", ";", "static", "::", "$", "connections", "[", "$", "key", "]", "=", "new", "$", "Driver", "(", "$", "value", ")", ";", "if", "(", "!", "static", "::", "$", "connections", "[", "$", "key", "]", "instanceof", "Connection", ")", "{", "throw", "new", "Exception", "(", "'Norm connection ['", ".", "$", "key", ".", "'] should be instance of Connection'", ")", ";", "}", "if", "(", "!", "$", "first", ")", "{", "$", "first", "=", "$", "key", ";", "}", "}", "if", "(", "!", "static", "::", "$", "defaultConnection", ")", "{", "static", "::", "$", "defaultConnection", "=", "$", "first", ";", "}", "}" ]
Initialize framework from configuration. First connection registered from config will be the default connection. @param array $config @param array $collectionConfig @return void
[ "Initialize", "framework", "from", "configuration", ".", "First", "connection", "registered", "from", "config", "will", "be", "the", "default", "connection", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Norm.php#L53-L89
17,977
xinix-technology/norm
src/Norm/Norm.php
Norm.options
public static function options($key, $value = ':get:') { if (is_array($key)) { foreach ($key as $k => $v) { static::$options($k, $v); } return; } if ($value === ':get:') { return isset(static::$options[$key]) ? static::$options[$key] : null; } static::$options[$key] = $value; }
php
public static function options($key, $value = ':get:') { if (is_array($key)) { foreach ($key as $k => $v) { static::$options($k, $v); } return; } if ($value === ':get:') { return isset(static::$options[$key]) ? static::$options[$key] : null; } static::$options[$key] = $value; }
[ "public", "static", "function", "options", "(", "$", "key", ",", "$", "value", "=", "':get:'", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "foreach", "(", "$", "key", "as", "$", "k", "=>", "$", "v", ")", "{", "static", "::", "$", "options", "(", "$", "k", ",", "$", "v", ")", ";", "}", "return", ";", "}", "if", "(", "$", "value", "===", "':get:'", ")", "{", "return", "isset", "(", "static", "::", "$", "options", "[", "$", "key", "]", ")", "?", "static", "::", "$", "options", "[", "$", "key", "]", ":", "null", ";", "}", "static", "::", "$", "options", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Get the option of Norm configuration. @method options @param string $key @param string $value @return mixed
[ "Get", "the", "option", "of", "Norm", "configuration", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Norm.php#L101-L116
17,978
xinix-technology/norm
src/Norm/Norm.php
Norm.createCollection
public static function createCollection($options) { $defaultConfig = isset(static::$collectionConfig['default']) ? static::$collectionConfig['default'] : array(); $config = null; if (isset(static::$collectionConfig['mapping'][$options['name']])) { $config =static::$collectionConfig['mapping'][$options['name']]; } else { if (isset(static::$collectionConfig['resolvers']) and is_array(static::$collectionConfig['resolvers'])) { foreach (static::$collectionConfig['resolvers'] as $resolver => $resolverOpts) { if (is_string($resolverOpts)) { $resolver = $resolverOpts; $resolverOpts = array(); } $resolver = new $resolver($resolverOpts); $config = $resolver->resolve($options); if (isset($config)) { break; } } } } if (!isset($config)) { $config = array(); } $config = array_merge_recursive($defaultConfig, $config); $options = array_merge_recursive($config, $options); if (isset($options['collection'])) { $Driver = $options['collection']; $collection = new $Driver($options); } else { $collection = new Collection($options); } return $collection; }
php
public static function createCollection($options) { $defaultConfig = isset(static::$collectionConfig['default']) ? static::$collectionConfig['default'] : array(); $config = null; if (isset(static::$collectionConfig['mapping'][$options['name']])) { $config =static::$collectionConfig['mapping'][$options['name']]; } else { if (isset(static::$collectionConfig['resolvers']) and is_array(static::$collectionConfig['resolvers'])) { foreach (static::$collectionConfig['resolvers'] as $resolver => $resolverOpts) { if (is_string($resolverOpts)) { $resolver = $resolverOpts; $resolverOpts = array(); } $resolver = new $resolver($resolverOpts); $config = $resolver->resolve($options); if (isset($config)) { break; } } } } if (!isset($config)) { $config = array(); } $config = array_merge_recursive($defaultConfig, $config); $options = array_merge_recursive($config, $options); if (isset($options['collection'])) { $Driver = $options['collection']; $collection = new $Driver($options); } else { $collection = new Collection($options); } return $collection; }
[ "public", "static", "function", "createCollection", "(", "$", "options", ")", "{", "$", "defaultConfig", "=", "isset", "(", "static", "::", "$", "collectionConfig", "[", "'default'", "]", ")", "?", "static", "::", "$", "collectionConfig", "[", "'default'", "]", ":", "array", "(", ")", ";", "$", "config", "=", "null", ";", "if", "(", "isset", "(", "static", "::", "$", "collectionConfig", "[", "'mapping'", "]", "[", "$", "options", "[", "'name'", "]", "]", ")", ")", "{", "$", "config", "=", "static", "::", "$", "collectionConfig", "[", "'mapping'", "]", "[", "$", "options", "[", "'name'", "]", "]", ";", "}", "else", "{", "if", "(", "isset", "(", "static", "::", "$", "collectionConfig", "[", "'resolvers'", "]", ")", "and", "is_array", "(", "static", "::", "$", "collectionConfig", "[", "'resolvers'", "]", ")", ")", "{", "foreach", "(", "static", "::", "$", "collectionConfig", "[", "'resolvers'", "]", "as", "$", "resolver", "=>", "$", "resolverOpts", ")", "{", "if", "(", "is_string", "(", "$", "resolverOpts", ")", ")", "{", "$", "resolver", "=", "$", "resolverOpts", ";", "$", "resolverOpts", "=", "array", "(", ")", ";", "}", "$", "resolver", "=", "new", "$", "resolver", "(", "$", "resolverOpts", ")", ";", "$", "config", "=", "$", "resolver", "->", "resolve", "(", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "config", ")", ")", "{", "break", ";", "}", "}", "}", "}", "if", "(", "!", "isset", "(", "$", "config", ")", ")", "{", "$", "config", "=", "array", "(", ")", ";", "}", "$", "config", "=", "array_merge_recursive", "(", "$", "defaultConfig", ",", "$", "config", ")", ";", "$", "options", "=", "array_merge_recursive", "(", "$", "config", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'collection'", "]", ")", ")", "{", "$", "Driver", "=", "$", "options", "[", "'collection'", "]", ";", "$", "collection", "=", "new", "$", "Driver", "(", "$", "options", ")", ";", "}", "else", "{", "$", "collection", "=", "new", "Collection", "(", "$", "options", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Create collection by configuration. @method createCollection @param array $options @return mixed|\Norm\Collection
[ "Create", "collection", "by", "configuration", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Norm.php#L142-L187
17,979
xinix-technology/norm
src/Norm/Norm.php
Norm.getConnection
public static function getConnection($connectionName = '') { if (!$connectionName) { $connectionName = static::$defaultConnection; } if (isset(static::$connections[$connectionName])) { return static::$connections[$connectionName]; } }
php
public static function getConnection($connectionName = '') { if (!$connectionName) { $connectionName = static::$defaultConnection; } if (isset(static::$connections[$connectionName])) { return static::$connections[$connectionName]; } }
[ "public", "static", "function", "getConnection", "(", "$", "connectionName", "=", "''", ")", "{", "if", "(", "!", "$", "connectionName", ")", "{", "$", "connectionName", "=", "static", "::", "$", "defaultConnection", ";", "}", "if", "(", "isset", "(", "static", "::", "$", "connections", "[", "$", "connectionName", "]", ")", ")", "{", "return", "static", "::", "$", "connections", "[", "$", "connectionName", "]", ";", "}", "}" ]
Get connection by its connection name, if no connection name provided then the function will return default connection. @param string $connectionName @return \Norm\Connection
[ "Get", "connection", "by", "its", "connection", "name", "if", "no", "connection", "name", "provided", "then", "the", "function", "will", "return", "default", "connection", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Norm.php#L196-L204
17,980
tableau-mkt/eggs-n-cereal
src/Utils/Data.php
Data.ensureArrayKeys
public static function ensureArrayKeys($key) { if (empty($key)) { return array(); } if (!is_array($key)) { if (strstr($key, '|')) { $key = str_replace('|', self::ARRAY_DELIMITER, $key); } $key = explode(self::ARRAY_DELIMITER, $key); } return $key; }
php
public static function ensureArrayKeys($key) { if (empty($key)) { return array(); } if (!is_array($key)) { if (strstr($key, '|')) { $key = str_replace('|', self::ARRAY_DELIMITER, $key); } $key = explode(self::ARRAY_DELIMITER, $key); } return $key; }
[ "public", "static", "function", "ensureArrayKeys", "(", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "key", ")", ")", "{", "if", "(", "strstr", "(", "$", "key", ",", "'|'", ")", ")", "{", "$", "key", "=", "str_replace", "(", "'|'", ",", "self", "::", "ARRAY_DELIMITER", ",", "$", "key", ")", ";", "}", "$", "key", "=", "explode", "(", "self", "::", "ARRAY_DELIMITER", ",", "$", "key", ")", ";", "}", "return", "$", "key", ";", "}" ]
Converts string keys to array keys. There are three conventions for data keys in use. This function accepts each and ensures an array of keys. @param array|string $key The key can be either be an array containing the keys of a nested array hierarchy path or a string with '][' or '|' as delimiter. @return array Array of keys.
[ "Converts", "string", "keys", "to", "array", "keys", "." ]
778b83ddae1dd687724a84545ce8afa1a31e4bcf
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/Data.php#L40-L51
17,981
tableau-mkt/eggs-n-cereal
src/Utils/Data.php
Data.flattenData
public static function flattenData(array $data, $prefix = NULL, $label = array()) { $flattened_data = array(); if (isset($data['#label'])) { $label[] = $data['#label']; } // Each element is either a text (has #text property defined) or has children, // not both. if (!empty($data['#text'])) { $flattened_data[$prefix] = $data; $flattened_data[$prefix]['#parent_label'] = $label; } else { $prefix = isset($prefix) ? $prefix . self::ARRAY_DELIMITER : ''; foreach (self::elementChildren($data) as $key) { $flattened_data += self::flattenData($data[$key], $prefix . $key, $label); } } return $flattened_data; }
php
public static function flattenData(array $data, $prefix = NULL, $label = array()) { $flattened_data = array(); if (isset($data['#label'])) { $label[] = $data['#label']; } // Each element is either a text (has #text property defined) or has children, // not both. if (!empty($data['#text'])) { $flattened_data[$prefix] = $data; $flattened_data[$prefix]['#parent_label'] = $label; } else { $prefix = isset($prefix) ? $prefix . self::ARRAY_DELIMITER : ''; foreach (self::elementChildren($data) as $key) { $flattened_data += self::flattenData($data[$key], $prefix . $key, $label); } } return $flattened_data; }
[ "public", "static", "function", "flattenData", "(", "array", "$", "data", ",", "$", "prefix", "=", "NULL", ",", "$", "label", "=", "array", "(", ")", ")", "{", "$", "flattened_data", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'#label'", "]", ")", ")", "{", "$", "label", "[", "]", "=", "$", "data", "[", "'#label'", "]", ";", "}", "// Each element is either a text (has #text property defined) or has children,", "// not both.", "if", "(", "!", "empty", "(", "$", "data", "[", "'#text'", "]", ")", ")", "{", "$", "flattened_data", "[", "$", "prefix", "]", "=", "$", "data", ";", "$", "flattened_data", "[", "$", "prefix", "]", "[", "'#parent_label'", "]", "=", "$", "label", ";", "}", "else", "{", "$", "prefix", "=", "isset", "(", "$", "prefix", ")", "?", "$", "prefix", ".", "self", "::", "ARRAY_DELIMITER", ":", "''", ";", "foreach", "(", "self", "::", "elementChildren", "(", "$", "data", ")", "as", "$", "key", ")", "{", "$", "flattened_data", "+=", "self", "::", "flattenData", "(", "$", "data", "[", "$", "key", "]", ",", "$", "prefix", ".", "$", "key", ",", "$", "label", ")", ";", "}", "}", "return", "$", "flattened_data", ";", "}" ]
Converts a nested data array into a flattened structure with a combined key. This function can be used by translators to help with the data conversion. Nested keys will be joined together using a colon, so for example $data['key1']['key2']['key3'] will be converted into $flattened_data['key1][key2][key3']. @param array $data The nested array structure that should be flattened. @param string $prefix Internal use only, indicates the current key prefix when recursing into the data array. @param array $label Internal use only. @return array The flattened data array. @see TableauXliffSerializer::unflattenData()
[ "Converts", "a", "nested", "data", "array", "into", "a", "flattened", "structure", "with", "a", "combined", "key", "." ]
778b83ddae1dd687724a84545ce8afa1a31e4bcf
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/Data.php#L77-L95
17,982
tableau-mkt/eggs-n-cereal
src/Utils/Data.php
Data.unflattenData
public static function unflattenData($flattened_data) { $data = array(); foreach ($flattened_data as $key => $flattened_data_entry) { self::arraySetNestedValue($data, explode(self::ARRAY_DELIMITER, $key), $flattened_data_entry); } return $data; }
php
public static function unflattenData($flattened_data) { $data = array(); foreach ($flattened_data as $key => $flattened_data_entry) { self::arraySetNestedValue($data, explode(self::ARRAY_DELIMITER, $key), $flattened_data_entry); } return $data; }
[ "public", "static", "function", "unflattenData", "(", "$", "flattened_data", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "flattened_data", "as", "$", "key", "=>", "$", "flattened_data_entry", ")", "{", "self", "::", "arraySetNestedValue", "(", "$", "data", ",", "explode", "(", "self", "::", "ARRAY_DELIMITER", ",", "$", "key", ")", ",", "$", "flattened_data_entry", ")", ";", "}", "return", "$", "data", ";", "}" ]
Converts a flattened data structure into a nested array. This function can be used by translators to help with the data conversion. Nested keys will be created based on the colon, so for example $flattened_data['key1][key2][key3'] will be converted into $data['key1']['key2']['key3']. @param array $flattened_data The flattened data array. @return array The nested data array. @see TableauXliffSerializer::flattenData()
[ "Converts", "a", "flattened", "data", "structure", "into", "a", "nested", "array", "." ]
778b83ddae1dd687724a84545ce8afa1a31e4bcf
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/Data.php#L114-L120
17,983
tableau-mkt/eggs-n-cereal
src/Utils/Data.php
Data.elementChildren
public static function elementChildren($elements) { // Filter out properties from the element, leaving only children. $children = array(); foreach ($elements as $key => $value) { if ($key === '' || $key[0] !== '#') { $children[$key] = $value; } } return array_keys($children); }
php
public static function elementChildren($elements) { // Filter out properties from the element, leaving only children. $children = array(); foreach ($elements as $key => $value) { if ($key === '' || $key[0] !== '#') { $children[$key] = $value; } } return array_keys($children); }
[ "public", "static", "function", "elementChildren", "(", "$", "elements", ")", "{", "// Filter out properties from the element, leaving only children.", "$", "children", "=", "array", "(", ")", ";", "foreach", "(", "$", "elements", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "''", "||", "$", "key", "[", "0", "]", "!==", "'#'", ")", "{", "$", "children", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "array_keys", "(", "$", "children", ")", ";", "}" ]
Identifies the children of an element array. The children of a element array are those key/value pairs whose key does not start with a '#'. @param array $elements The element array whose children are to be identified. @return array The array keys of the element's children.
[ "Identifies", "the", "children", "of", "an", "element", "array", "." ]
778b83ddae1dd687724a84545ce8afa1a31e4bcf
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/Data.php#L150-L159
17,984
wikimedia/CLDRPluralRuleParser
src/Evaluator.php
Evaluator.evaluate
public static function evaluate( $number, array $rules ) { $rules = self::compile( $rules ); return self::evaluateCompiled( $number, $rules ); }
php
public static function evaluate( $number, array $rules ) { $rules = self::compile( $rules ); return self::evaluateCompiled( $number, $rules ); }
[ "public", "static", "function", "evaluate", "(", "$", "number", ",", "array", "$", "rules", ")", "{", "$", "rules", "=", "self", "::", "compile", "(", "$", "rules", ")", ";", "return", "self", "::", "evaluateCompiled", "(", "$", "number", ",", "$", "rules", ")", ";", "}" ]
Evaluate a number against a set of plural rules. If a rule passes, return the index of plural rule. @param int $number The number to be evaluated against the rules @param array $rules The associative array of plural rules in pluralform => rule format. @return int The index of the plural form which passed the evaluation
[ "Evaluate", "a", "number", "against", "a", "set", "of", "plural", "rules", ".", "If", "a", "rule", "passes", "return", "the", "index", "of", "plural", "rule", "." ]
4c5d71a3fd62a75871da8562310ca2258647ee6d
https://github.com/wikimedia/CLDRPluralRuleParser/blob/4c5d71a3fd62a75871da8562310ca2258647ee6d/src/Evaluator.php#L26-L30
17,985
wikimedia/CLDRPluralRuleParser
src/Evaluator.php
Evaluator.compile
public static function compile( array $rules ) { // We can't use array_map() for this because it generates a warning if // there is an exception. foreach ( $rules as &$rule ) { $rule = Converter::convert( $rule ); } return $rules; }
php
public static function compile( array $rules ) { // We can't use array_map() for this because it generates a warning if // there is an exception. foreach ( $rules as &$rule ) { $rule = Converter::convert( $rule ); } return $rules; }
[ "public", "static", "function", "compile", "(", "array", "$", "rules", ")", "{", "// We can't use array_map() for this because it generates a warning if", "// there is an exception.", "foreach", "(", "$", "rules", "as", "&", "$", "rule", ")", "{", "$", "rule", "=", "Converter", "::", "convert", "(", "$", "rule", ")", ";", "}", "return", "$", "rules", ";", "}" ]
Convert a set of rules to a compiled form which is optimised for fast evaluation. The result will be an array of strings, and may be cached. @param array $rules The rules to compile @return array An array of compile rules.
[ "Convert", "a", "set", "of", "rules", "to", "a", "compiled", "form", "which", "is", "optimised", "for", "fast", "evaluation", ".", "The", "result", "will", "be", "an", "array", "of", "strings", "and", "may", "be", "cached", "." ]
4c5d71a3fd62a75871da8562310ca2258647ee6d
https://github.com/wikimedia/CLDRPluralRuleParser/blob/4c5d71a3fd62a75871da8562310ca2258647ee6d/src/Evaluator.php#L39-L47
17,986
wikimedia/CLDRPluralRuleParser
src/Evaluator.php
Evaluator.doOperation
private static function doOperation( $token, $left, $right ) { if ( in_array( $token, [ 'in', 'not-in', 'within', 'not-within' ] ) ) { if ( !$right instanceof Range ) { $right = new Range( $right ); } } switch ( $token ) { case 'or': return $left || $right; case 'and': return $left && $right; case 'is': return $left == $right; case 'is-not': return $left != $right; case 'in': return $right->isNumberIn( $left ); case 'not-in': return !$right->isNumberIn( $left ); case 'within': return $right->isNumberWithin( $left ); case 'not-within': return !$right->isNumberWithin( $left ); case 'mod': if ( is_int( $left ) ) { return (int)fmod( $left, $right ); } return fmod( $left, $right ); case ',': if ( $left instanceof Range ) { $range = $left; } else { $range = new Range( $left ); } $range->add( $right ); return $range; case '..': return new Range( $left, $right ); default: throw new Error( "Invalid RPN token" ); } }
php
private static function doOperation( $token, $left, $right ) { if ( in_array( $token, [ 'in', 'not-in', 'within', 'not-within' ] ) ) { if ( !$right instanceof Range ) { $right = new Range( $right ); } } switch ( $token ) { case 'or': return $left || $right; case 'and': return $left && $right; case 'is': return $left == $right; case 'is-not': return $left != $right; case 'in': return $right->isNumberIn( $left ); case 'not-in': return !$right->isNumberIn( $left ); case 'within': return $right->isNumberWithin( $left ); case 'not-within': return !$right->isNumberWithin( $left ); case 'mod': if ( is_int( $left ) ) { return (int)fmod( $left, $right ); } return fmod( $left, $right ); case ',': if ( $left instanceof Range ) { $range = $left; } else { $range = new Range( $left ); } $range->add( $right ); return $range; case '..': return new Range( $left, $right ); default: throw new Error( "Invalid RPN token" ); } }
[ "private", "static", "function", "doOperation", "(", "$", "token", ",", "$", "left", ",", "$", "right", ")", "{", "if", "(", "in_array", "(", "$", "token", ",", "[", "'in'", ",", "'not-in'", ",", "'within'", ",", "'not-within'", "]", ")", ")", "{", "if", "(", "!", "$", "right", "instanceof", "Range", ")", "{", "$", "right", "=", "new", "Range", "(", "$", "right", ")", ";", "}", "}", "switch", "(", "$", "token", ")", "{", "case", "'or'", ":", "return", "$", "left", "||", "$", "right", ";", "case", "'and'", ":", "return", "$", "left", "&&", "$", "right", ";", "case", "'is'", ":", "return", "$", "left", "==", "$", "right", ";", "case", "'is-not'", ":", "return", "$", "left", "!=", "$", "right", ";", "case", "'in'", ":", "return", "$", "right", "->", "isNumberIn", "(", "$", "left", ")", ";", "case", "'not-in'", ":", "return", "!", "$", "right", "->", "isNumberIn", "(", "$", "left", ")", ";", "case", "'within'", ":", "return", "$", "right", "->", "isNumberWithin", "(", "$", "left", ")", ";", "case", "'not-within'", ":", "return", "!", "$", "right", "->", "isNumberWithin", "(", "$", "left", ")", ";", "case", "'mod'", ":", "if", "(", "is_int", "(", "$", "left", ")", ")", "{", "return", "(", "int", ")", "fmod", "(", "$", "left", ",", "$", "right", ")", ";", "}", "return", "fmod", "(", "$", "left", ",", "$", "right", ")", ";", "case", "','", ":", "if", "(", "$", "left", "instanceof", "Range", ")", "{", "$", "range", "=", "$", "left", ";", "}", "else", "{", "$", "range", "=", "new", "Range", "(", "$", "left", ")", ";", "}", "$", "range", "->", "add", "(", "$", "right", ")", ";", "return", "$", "range", ";", "case", "'..'", ":", "return", "new", "Range", "(", "$", "left", ",", "$", "right", ")", ";", "default", ":", "throw", "new", "Error", "(", "\"Invalid RPN token\"", ")", ";", "}", "}" ]
Do a single operation @param string $token The token string @param mixed $left The left operand. If it is an object, its state may be destroyed. @param mixed $right The right operand @throws Error @return mixed The operation result
[ "Do", "a", "single", "operation" ]
4c5d71a3fd62a75871da8562310ca2258647ee6d
https://github.com/wikimedia/CLDRPluralRuleParser/blob/4c5d71a3fd62a75871da8562310ca2258647ee6d/src/Evaluator.php#L127-L170
17,987
praxisnetau/silverware-spam-guard
src/Fields/SimpleSpamGuardField.php
SimpleSpamGuardField.setForm
public function setForm($form) { // Associate Fields with Form: $this->honeypot->setForm($form); $this->timestamp->setForm($form); // Call Parent Method: return parent::setForm($form); }
php
public function setForm($form) { // Associate Fields with Form: $this->honeypot->setForm($form); $this->timestamp->setForm($form); // Call Parent Method: return parent::setForm($form); }
[ "public", "function", "setForm", "(", "$", "form", ")", "{", "// Associate Fields with Form:", "$", "this", "->", "honeypot", "->", "setForm", "(", "$", "form", ")", ";", "$", "this", "->", "timestamp", "->", "setForm", "(", "$", "form", ")", ";", "// Call Parent Method:", "return", "parent", "::", "setForm", "(", "$", "form", ")", ";", "}" ]
Defines the form instance for the receiver. @param Form $form @return $this
[ "Defines", "the", "form", "instance", "for", "the", "receiver", "." ]
c5f8836a09141bd675173892a1e3d8c8cc8c1886
https://github.com/praxisnetau/silverware-spam-guard/blob/c5f8836a09141bd675173892a1e3d8c8cc8c1886/src/Fields/SimpleSpamGuardField.php#L112-L122
17,988
praxisnetau/silverware-spam-guard
src/Fields/SimpleSpamGuardField.php
SimpleSpamGuardField.Field
public function Field($properties = []) { Requirements::customCSS('.field.simpleguard { display: none !important; }'); return DBField::create_field('HTMLFragment', $this->honeypot->Field() . $this->timestamp->Field()); }
php
public function Field($properties = []) { Requirements::customCSS('.field.simpleguard { display: none !important; }'); return DBField::create_field('HTMLFragment', $this->honeypot->Field() . $this->timestamp->Field()); }
[ "public", "function", "Field", "(", "$", "properties", "=", "[", "]", ")", "{", "Requirements", "::", "customCSS", "(", "'.field.simpleguard { display: none !important; }'", ")", ";", "return", "DBField", "::", "create_field", "(", "'HTMLFragment'", ",", "$", "this", "->", "honeypot", "->", "Field", "(", ")", ".", "$", "this", "->", "timestamp", "->", "Field", "(", ")", ")", ";", "}" ]
Renders the field for the template. @param array $properties @return DBHTMLText
[ "Renders", "the", "field", "for", "the", "template", "." ]
c5f8836a09141bd675173892a1e3d8c8cc8c1886
https://github.com/praxisnetau/silverware-spam-guard/blob/c5f8836a09141bd675173892a1e3d8c8cc8c1886/src/Fields/SimpleSpamGuardField.php#L161-L166
17,989
praxisnetau/silverware-spam-guard
src/Fields/SimpleSpamGuardField.php
SimpleSpamGuardField.setValue
public function setValue($value, $data = null) { // Check Value Type: if (is_array($value)) { // Define Field Values: $this->honeypot->setValue(isset($value['value']) ? $value['value'] : null); $this->timestamp->setValue(isset($value['timestamp']) ? $value['timestamp'] : null); // Define Self Value: $this->value = $this->honeypot->dataValue(); } // Answer Self: return $this; }
php
public function setValue($value, $data = null) { // Check Value Type: if (is_array($value)) { // Define Field Values: $this->honeypot->setValue(isset($value['value']) ? $value['value'] : null); $this->timestamp->setValue(isset($value['timestamp']) ? $value['timestamp'] : null); // Define Self Value: $this->value = $this->honeypot->dataValue(); } // Answer Self: return $this; }
[ "public", "function", "setValue", "(", "$", "value", ",", "$", "data", "=", "null", ")", "{", "// Check Value Type:", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "// Define Field Values:", "$", "this", "->", "honeypot", "->", "setValue", "(", "isset", "(", "$", "value", "[", "'value'", "]", ")", "?", "$", "value", "[", "'value'", "]", ":", "null", ")", ";", "$", "this", "->", "timestamp", "->", "setValue", "(", "isset", "(", "$", "value", "[", "'timestamp'", "]", ")", "?", "$", "value", "[", "'timestamp'", "]", ":", "null", ")", ";", "// Define Self Value:", "$", "this", "->", "value", "=", "$", "this", "->", "honeypot", "->", "dataValue", "(", ")", ";", "}", "// Answer Self:", "return", "$", "this", ";", "}" ]
Defines the field value. @param mixed $value @param array $data @return $this
[ "Defines", "the", "field", "value", "." ]
c5f8836a09141bd675173892a1e3d8c8cc8c1886
https://github.com/praxisnetau/silverware-spam-guard/blob/c5f8836a09141bd675173892a1e3d8c8cc8c1886/src/Fields/SimpleSpamGuardField.php#L176-L196
17,990
praxisnetau/silverware-spam-guard
src/Fields/SimpleSpamGuardField.php
SimpleSpamGuardField.validate
public function validate($validator) { // Check Value and Timestamp: if (!empty($this->value) || $this->tooSoon()) { // Define Validation Error: $validator->validationError( $this->name, _t( __CLASS__ . '.VALIDATIONERROR', 'Sorry, an error has occurred. Please try again later.' ), 'validation' ); // Answer Failure: return false; } // Answer Success: return true; }
php
public function validate($validator) { // Check Value and Timestamp: if (!empty($this->value) || $this->tooSoon()) { // Define Validation Error: $validator->validationError( $this->name, _t( __CLASS__ . '.VALIDATIONERROR', 'Sorry, an error has occurred. Please try again later.' ), 'validation' ); // Answer Failure: return false; } // Answer Success: return true; }
[ "public", "function", "validate", "(", "$", "validator", ")", "{", "// Check Value and Timestamp:", "if", "(", "!", "empty", "(", "$", "this", "->", "value", ")", "||", "$", "this", "->", "tooSoon", "(", ")", ")", "{", "// Define Validation Error:", "$", "validator", "->", "validationError", "(", "$", "this", "->", "name", ",", "_t", "(", "__CLASS__", ".", "'.VALIDATIONERROR'", ",", "'Sorry, an error has occurred. Please try again later.'", ")", ",", "'validation'", ")", ";", "// Answer Failure:", "return", "false", ";", "}", "// Answer Success:", "return", "true", ";", "}" ]
Answers true if the value is valid for the receiver. @param Validator $validator @return boolean
[ "Answers", "true", "if", "the", "value", "is", "valid", "for", "the", "receiver", "." ]
c5f8836a09141bd675173892a1e3d8c8cc8c1886
https://github.com/praxisnetau/silverware-spam-guard/blob/c5f8836a09141bd675173892a1e3d8c8cc8c1886/src/Fields/SimpleSpamGuardField.php#L215-L241
17,991
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent.getRequestVars
public function getRequestVars($name, $primaryKey = self::PRIMARY_KEY) { $name = Str::low(Inflector::singularize($name)); $requestIds = (array) $this->_request->getData($name); $action = $this->_request->getData('action'); $ids = $this->_getIds($requestIds, $primaryKey); return [$action, $ids]; }
php
public function getRequestVars($name, $primaryKey = self::PRIMARY_KEY) { $name = Str::low(Inflector::singularize($name)); $requestIds = (array) $this->_request->getData($name); $action = $this->_request->getData('action'); $ids = $this->_getIds($requestIds, $primaryKey); return [$action, $ids]; }
[ "public", "function", "getRequestVars", "(", "$", "name", ",", "$", "primaryKey", "=", "self", "::", "PRIMARY_KEY", ")", "{", "$", "name", "=", "Str", "::", "low", "(", "Inflector", "::", "singularize", "(", "$", "name", ")", ")", ";", "$", "requestIds", "=", "(", "array", ")", "$", "this", "->", "_request", "->", "getData", "(", "$", "name", ")", ";", "$", "action", "=", "$", "this", "->", "_request", "->", "getData", "(", "'action'", ")", ";", "$", "ids", "=", "$", "this", "->", "_getIds", "(", "$", "requestIds", ",", "$", "primaryKey", ")", ";", "return", "[", "$", "action", ",", "$", "ids", "]", ";", "}" ]
Get actual request vars for process. @param string $name @param string $primaryKey @return array
[ "Get", "actual", "request", "vars", "for", "process", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L56-L64
17,992
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent.make
public function make(Table $table, $action, array $ids = [], array $options = []) { $count = count($ids); $options = $this->_getOptions($options, $count); $redirectUrl = $options['redirect']; $messages = new JSON($options['messages']); $event = EventManager::trigger($this->_getEventName($action), $this->_controller, ['ids' => $ids]); $ids = (array) $event->getData('ids'); $count = count($ids); if (!$action) { $this->Flash->error($messages->get('no_action')); return $this->_controller->redirect($redirectUrl); } if ($count <= 0) { $this->Flash->error($messages->get('no_choose')); return $this->_controller->redirect($redirectUrl); } $this->_loadBehavior($table); if ($table->process($action, $ids)) { return $this->_process($action, $messages, $redirectUrl, $ids); } $this->Flash->error(__d('core', 'An error has occurred. Please try again.')); return $this->_controller->redirect($redirectUrl); }
php
public function make(Table $table, $action, array $ids = [], array $options = []) { $count = count($ids); $options = $this->_getOptions($options, $count); $redirectUrl = $options['redirect']; $messages = new JSON($options['messages']); $event = EventManager::trigger($this->_getEventName($action), $this->_controller, ['ids' => $ids]); $ids = (array) $event->getData('ids'); $count = count($ids); if (!$action) { $this->Flash->error($messages->get('no_action')); return $this->_controller->redirect($redirectUrl); } if ($count <= 0) { $this->Flash->error($messages->get('no_choose')); return $this->_controller->redirect($redirectUrl); } $this->_loadBehavior($table); if ($table->process($action, $ids)) { return $this->_process($action, $messages, $redirectUrl, $ids); } $this->Flash->error(__d('core', 'An error has occurred. Please try again.')); return $this->_controller->redirect($redirectUrl); }
[ "public", "function", "make", "(", "Table", "$", "table", ",", "$", "action", ",", "array", "$", "ids", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "count", "=", "count", "(", "$", "ids", ")", ";", "$", "options", "=", "$", "this", "->", "_getOptions", "(", "$", "options", ",", "$", "count", ")", ";", "$", "redirectUrl", "=", "$", "options", "[", "'redirect'", "]", ";", "$", "messages", "=", "new", "JSON", "(", "$", "options", "[", "'messages'", "]", ")", ";", "$", "event", "=", "EventManager", "::", "trigger", "(", "$", "this", "->", "_getEventName", "(", "$", "action", ")", ",", "$", "this", "->", "_controller", ",", "[", "'ids'", "=>", "$", "ids", "]", ")", ";", "$", "ids", "=", "(", "array", ")", "$", "event", "->", "getData", "(", "'ids'", ")", ";", "$", "count", "=", "count", "(", "$", "ids", ")", ";", "if", "(", "!", "$", "action", ")", "{", "$", "this", "->", "Flash", "->", "error", "(", "$", "messages", "->", "get", "(", "'no_action'", ")", ")", ";", "return", "$", "this", "->", "_controller", "->", "redirect", "(", "$", "redirectUrl", ")", ";", "}", "if", "(", "$", "count", "<=", "0", ")", "{", "$", "this", "->", "Flash", "->", "error", "(", "$", "messages", "->", "get", "(", "'no_choose'", ")", ")", ";", "return", "$", "this", "->", "_controller", "->", "redirect", "(", "$", "redirectUrl", ")", ";", "}", "$", "this", "->", "_loadBehavior", "(", "$", "table", ")", ";", "if", "(", "$", "table", "->", "process", "(", "$", "action", ",", "$", "ids", ")", ")", "{", "return", "$", "this", "->", "_process", "(", "$", "action", ",", "$", "messages", ",", "$", "redirectUrl", ",", "$", "ids", ")", ";", "}", "$", "this", "->", "Flash", "->", "error", "(", "__d", "(", "'core'", ",", "'An error has occurred. Please try again.'", ")", ")", ";", "return", "$", "this", "->", "_controller", "->", "redirect", "(", "$", "redirectUrl", ")", ";", "}" ]
Make process. @param Table $table @param string $action @param array $ids @param array $options @return \Cake\Http\Response|null @throws \Aura\Intl\Exception
[ "Make", "process", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L105-L133
17,993
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent._getDefaultMessages
protected function _getDefaultMessages($count) { $context = $this->_configRead('context'); $contextPlural = Inflector::pluralize($context); $countString = sprintf('<strong>%s</strong>', $count); return [ 'delete' => __dn( 'core', 'One ' . $context . ' success removed', '{0} ' . $contextPlural . ' success removed', $count, $countString ), 'publish' => __dn( 'core', 'One ' . $context . ' success publish', '{0} ' . $contextPlural . ' success published', $count, $countString ), 'unpublish' => __dn( 'core', 'One ' . $context . ' success unpublish', '{0} ' . $contextPlural . ' success unpublished', $count, $countString ), ]; }
php
protected function _getDefaultMessages($count) { $context = $this->_configRead('context'); $contextPlural = Inflector::pluralize($context); $countString = sprintf('<strong>%s</strong>', $count); return [ 'delete' => __dn( 'core', 'One ' . $context . ' success removed', '{0} ' . $contextPlural . ' success removed', $count, $countString ), 'publish' => __dn( 'core', 'One ' . $context . ' success publish', '{0} ' . $contextPlural . ' success published', $count, $countString ), 'unpublish' => __dn( 'core', 'One ' . $context . ' success unpublish', '{0} ' . $contextPlural . ' success unpublished', $count, $countString ), ]; }
[ "protected", "function", "_getDefaultMessages", "(", "$", "count", ")", "{", "$", "context", "=", "$", "this", "->", "_configRead", "(", "'context'", ")", ";", "$", "contextPlural", "=", "Inflector", "::", "pluralize", "(", "$", "context", ")", ";", "$", "countString", "=", "sprintf", "(", "'<strong>%s</strong>'", ",", "$", "count", ")", ";", "return", "[", "'delete'", "=>", "__dn", "(", "'core'", ",", "'One '", ".", "$", "context", ".", "' success removed'", ",", "'{0} '", ".", "$", "contextPlural", ".", "' success removed'", ",", "$", "count", ",", "$", "countString", ")", ",", "'publish'", "=>", "__dn", "(", "'core'", ",", "'One '", ".", "$", "context", ".", "' success publish'", ",", "'{0} '", ".", "$", "contextPlural", ".", "' success published'", ",", "$", "count", ",", "$", "countString", ")", ",", "'unpublish'", "=>", "__dn", "(", "'core'", ",", "'One '", ".", "$", "context", ".", "' success unpublish'", ",", "'{0} '", ".", "$", "contextPlural", ".", "' success unpublished'", ",", "$", "count", ",", "$", "countString", ")", ",", "]", ";", "}" ]
Setup default action messages. @param int $count @return array @throws \Aura\Intl\Exception
[ "Setup", "default", "action", "messages", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L143-L171
17,994
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent._getEventName
protected function _getEventName($action, $event = self::EVENT_NAME_BEFORE) { $details = []; if ($prefix = $this->_request->getParam('prefix')) { $details[] = ucfirst($prefix); } $details = Hash::merge($details, [ 'Controller', $this->_controller->getName(), $event . Inflector::camelize($action), 'Process', ]); return implode('.', $details); }
php
protected function _getEventName($action, $event = self::EVENT_NAME_BEFORE) { $details = []; if ($prefix = $this->_request->getParam('prefix')) { $details[] = ucfirst($prefix); } $details = Hash::merge($details, [ 'Controller', $this->_controller->getName(), $event . Inflector::camelize($action), 'Process', ]); return implode('.', $details); }
[ "protected", "function", "_getEventName", "(", "$", "action", ",", "$", "event", "=", "self", "::", "EVENT_NAME_BEFORE", ")", "{", "$", "details", "=", "[", "]", ";", "if", "(", "$", "prefix", "=", "$", "this", "->", "_request", "->", "getParam", "(", "'prefix'", ")", ")", "{", "$", "details", "[", "]", "=", "ucfirst", "(", "$", "prefix", ")", ";", "}", "$", "details", "=", "Hash", "::", "merge", "(", "$", "details", ",", "[", "'Controller'", ",", "$", "this", "->", "_controller", "->", "getName", "(", ")", ",", "$", "event", ".", "Inflector", "::", "camelize", "(", "$", "action", ")", ",", "'Process'", ",", "]", ")", ";", "return", "implode", "(", "'.'", ",", "$", "details", ")", ";", "}" ]
Get event name by data. @param string $action @param string $event @return string
[ "Get", "event", "name", "by", "data", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L180-L195
17,995
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent._getIds
protected function _getIds(array $ids, $primaryKey = self::PRIMARY_KEY) { $return = []; foreach ($ids as $id => $value) { if (is_array($value) && is_int($id) && (int) $value[$primaryKey] === 1) { $return[$id] = $id; } } return $return; }
php
protected function _getIds(array $ids, $primaryKey = self::PRIMARY_KEY) { $return = []; foreach ($ids as $id => $value) { if (is_array($value) && is_int($id) && (int) $value[$primaryKey] === 1) { $return[$id] = $id; } } return $return; }
[ "protected", "function", "_getIds", "(", "array", "$", "ids", ",", "$", "primaryKey", "=", "self", "::", "PRIMARY_KEY", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "ids", "as", "$", "id", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "is_int", "(", "$", "id", ")", "&&", "(", "int", ")", "$", "value", "[", "$", "primaryKey", "]", "===", "1", ")", "{", "$", "return", "[", "$", "id", "]", "=", "$", "id", ";", "}", "}", "return", "$", "return", ";", "}" ]
Get ids by request. @param array $ids @param string $primaryKey @return array
[ "Get", "ids", "by", "request", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L204-L214
17,996
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent._getOptions
protected function _getOptions(array $options, $count) { $options = Hash::merge($this->_config, $options); return Hash::merge(['messages' => $this->_getDefaultMessages($count)], $options); }
php
protected function _getOptions(array $options, $count) { $options = Hash::merge($this->_config, $options); return Hash::merge(['messages' => $this->_getDefaultMessages($count)], $options); }
[ "protected", "function", "_getOptions", "(", "array", "$", "options", ",", "$", "count", ")", "{", "$", "options", "=", "Hash", "::", "merge", "(", "$", "this", "->", "_config", ",", "$", "options", ")", ";", "return", "Hash", "::", "merge", "(", "[", "'messages'", "=>", "$", "this", "->", "_getDefaultMessages", "(", "$", "count", ")", "]", ",", "$", "options", ")", ";", "}" ]
Create and merge actual process options. @param array $options @param int|string $count @return array @throws \Aura\Intl\Exception
[ "Create", "and", "merge", "actual", "process", "options", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L225-L229
17,997
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent._loadBehavior
protected function _loadBehavior(Table $table) { $behaviors = $table->behaviors(); if (!Arr::in('Process', $behaviors->loaded())) { $behaviors->load('Core.Process'); } }
php
protected function _loadBehavior(Table $table) { $behaviors = $table->behaviors(); if (!Arr::in('Process', $behaviors->loaded())) { $behaviors->load('Core.Process'); } }
[ "protected", "function", "_loadBehavior", "(", "Table", "$", "table", ")", "{", "$", "behaviors", "=", "$", "table", "->", "behaviors", "(", ")", ";", "if", "(", "!", "Arr", "::", "in", "(", "'Process'", ",", "$", "behaviors", "->", "loaded", "(", ")", ")", ")", "{", "$", "behaviors", "->", "load", "(", "'Core.Process'", ")", ";", "}", "}" ]
Load process behavior. @param Table $table
[ "Load", "process", "behavior", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L236-L242
17,998
CakeCMS/Core
src/Controller/Component/ProcessComponent.php
ProcessComponent._process
protected function _process($action, Data $messages, array $redirect, array $ids) { $count = count($ids); $defaultMsg = __dn( 'core', 'One record success processed', '{0} records processed', $count, sprintf('<strong>%s</strong>', $count) ); EventManager::trigger($this->_getEventName($action, self::EVENT_NAME_AFTER), $this->_controller, [ 'ids' => $ids ]); $this->Flash->success($messages->get($action, $defaultMsg)); return $this->_controller->redirect($redirect); }
php
protected function _process($action, Data $messages, array $redirect, array $ids) { $count = count($ids); $defaultMsg = __dn( 'core', 'One record success processed', '{0} records processed', $count, sprintf('<strong>%s</strong>', $count) ); EventManager::trigger($this->_getEventName($action, self::EVENT_NAME_AFTER), $this->_controller, [ 'ids' => $ids ]); $this->Flash->success($messages->get($action, $defaultMsg)); return $this->_controller->redirect($redirect); }
[ "protected", "function", "_process", "(", "$", "action", ",", "Data", "$", "messages", ",", "array", "$", "redirect", ",", "array", "$", "ids", ")", "{", "$", "count", "=", "count", "(", "$", "ids", ")", ";", "$", "defaultMsg", "=", "__dn", "(", "'core'", ",", "'One record success processed'", ",", "'{0} records processed'", ",", "$", "count", ",", "sprintf", "(", "'<strong>%s</strong>'", ",", "$", "count", ")", ")", ";", "EventManager", "::", "trigger", "(", "$", "this", "->", "_getEventName", "(", "$", "action", ",", "self", "::", "EVENT_NAME_AFTER", ")", ",", "$", "this", "->", "_controller", ",", "[", "'ids'", "=>", "$", "ids", "]", ")", ";", "$", "this", "->", "Flash", "->", "success", "(", "$", "messages", "->", "get", "(", "$", "action", ",", "$", "defaultMsg", ")", ")", ";", "return", "$", "this", "->", "_controller", "->", "redirect", "(", "$", "redirect", ")", ";", "}" ]
Controller process. @param string $action @param Data $messages @param array $redirect @param array $ids @return \Cake\Http\Response|null @throws \Aura\Intl\Exception
[ "Controller", "process", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L255-L272
17,999
aedart/laravel-helpers
src/Traits/Queue/QueueMonitorTrait.php
QueueMonitorTrait.getQueueMonitor
public function getQueueMonitor(): ?Monitor { if (!$this->hasQueueMonitor()) { $this->setQueueMonitor($this->getDefaultQueueMonitor()); } return $this->queueMonitor; }
php
public function getQueueMonitor(): ?Monitor { if (!$this->hasQueueMonitor()) { $this->setQueueMonitor($this->getDefaultQueueMonitor()); } return $this->queueMonitor; }
[ "public", "function", "getQueueMonitor", "(", ")", ":", "?", "Monitor", "{", "if", "(", "!", "$", "this", "->", "hasQueueMonitor", "(", ")", ")", "{", "$", "this", "->", "setQueueMonitor", "(", "$", "this", "->", "getDefaultQueueMonitor", "(", ")", ")", ";", "}", "return", "$", "this", "->", "queueMonitor", ";", "}" ]
Get queue monitor If no queue monitor has been set, this method will set and return a default queue monitor, if any such value is available @see getDefaultQueueMonitor() @return Monitor|null queue monitor or null if none queue monitor has been set
[ "Get", "queue", "monitor" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Queue/QueueMonitorTrait.php#L53-L59