id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
241,100
vinala/kernel
src/MVC/Model/ORM.php
ORM.reset
private function reset() { $vars = get_object_vars($this); // foreach ($vars as $key => $value) { unset($this->$key); } }
php
private function reset() { $vars = get_object_vars($this); // foreach ($vars as $key => $value) { unset($this->$key); } }
[ "private", "function", "reset", "(", ")", "{", "$", "vars", "=", "get_object_vars", "(", "$", "this", ")", ";", "//", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "$", "key", ")", ";", "}", "}" ]
reset the current model if it's deleted. @return null
[ "reset", "the", "current", "model", "if", "it", "s", "deleted", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L774-L781
241,101
vinala/kernel
src/MVC/Model/ORM.php
ORM.restore
public function restore() { if ($this->_kept) { $this->bring(); // Query::table(static::$table) ->set('deleted_at', 'NULL', false) ->where($this->_keyName, '=', $this->_keyValue) ->update(); } }
php
public function restore() { if ($this->_kept) { $this->bring(); // Query::table(static::$table) ->set('deleted_at', 'NULL', false) ->where($this->_keyName, '=', $this->_keyValue) ->update(); } }
[ "public", "function", "restore", "(", ")", "{", "if", "(", "$", "this", "->", "_kept", ")", "{", "$", "this", "->", "bring", "(", ")", ";", "//", "Query", "::", "table", "(", "static", "::", "$", "table", ")", "->", "set", "(", "'deleted_at'", ",", "'NULL'", ",", "false", ")", "->", "where", "(", "$", "this", "->", "_keyName", ",", "'='", ",", "$", "this", "->", "_keyValue", ")", "->", "update", "(", ")", ";", "}", "}" ]
restore the model if it's kept deleted. @return bool
[ "restore", "the", "model", "if", "it", "s", "kept", "deleted", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L788-L798
241,102
vinala/kernel
src/MVC/Model/ORM.php
ORM.bring
private function bring() { foreach ($this->_keptData as $key => $value) { $this->$key = $value; } // $this->_keyValue = $this->_keptData[$this->_keyName]; // $this->_keptData = null; $this->_kept = false; }
php
private function bring() { foreach ($this->_keptData as $key => $value) { $this->$key = $value; } // $this->_keyValue = $this->_keptData[$this->_keyName]; // $this->_keptData = null; $this->_kept = false; }
[ "private", "function", "bring", "(", ")", "{", "foreach", "(", "$", "this", "->", "_keptData", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "$", "key", "=", "$", "value", ";", "}", "//", "$", "this", "->", "_keyValue", "=", "$", "this", "->", "_keptData", "[", "$", "this", "->", "_keyName", "]", ";", "//", "$", "this", "->", "_keptData", "=", "null", ";", "$", "this", "->", "_kept", "=", "false", ";", "}" ]
to extruct data from keptdata array to become properties. @return null
[ "to", "extruct", "data", "from", "keptdata", "array", "to", "become", "properties", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L805-L815
241,103
vinala/kernel
src/MVC/Model/ORM.php
ORM.all
public static function all() { $class = get_called_class(); $object = new $class(); $table = $object->_table; $key = $object->_keyName; // $data = Query::table($table)->select('*')->where("'true'", '=', 'true'); // if ($object->_canKept) { $data = $data->orGroup( 'and', Query::condition('deleted_at', '>', Time::current()), Query::condition('deleted_at', 'is', 'NULL', false)); } if ($object->_canStashed) { $data = $data->orGroup( 'and', Query::condition('appeared_at', '<=', Time::current()), Query::condition('appeared_at', 'is', 'NULL', false)); } // $data = $data->get(Query::GET_ARRAY); // return self::collect($data, $table, $key); }
php
public static function all() { $class = get_called_class(); $object = new $class(); $table = $object->_table; $key = $object->_keyName; // $data = Query::table($table)->select('*')->where("'true'", '=', 'true'); // if ($object->_canKept) { $data = $data->orGroup( 'and', Query::condition('deleted_at', '>', Time::current()), Query::condition('deleted_at', 'is', 'NULL', false)); } if ($object->_canStashed) { $data = $data->orGroup( 'and', Query::condition('appeared_at', '<=', Time::current()), Query::condition('appeared_at', 'is', 'NULL', false)); } // $data = $data->get(Query::GET_ARRAY); // return self::collect($data, $table, $key); }
[ "public", "static", "function", "all", "(", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "$", "object", "=", "new", "$", "class", "(", ")", ";", "$", "table", "=", "$", "object", "->", "_table", ";", "$", "key", "=", "$", "object", "->", "_keyName", ";", "//", "$", "data", "=", "Query", "::", "table", "(", "$", "table", ")", "->", "select", "(", "'*'", ")", "->", "where", "(", "\"'true'\"", ",", "'='", ",", "'true'", ")", ";", "//", "if", "(", "$", "object", "->", "_canKept", ")", "{", "$", "data", "=", "$", "data", "->", "orGroup", "(", "'and'", ",", "Query", "::", "condition", "(", "'deleted_at'", ",", "'>'", ",", "Time", "::", "current", "(", ")", ")", ",", "Query", "::", "condition", "(", "'deleted_at'", ",", "'is'", ",", "'NULL'", ",", "false", ")", ")", ";", "}", "if", "(", "$", "object", "->", "_canStashed", ")", "{", "$", "data", "=", "$", "data", "->", "orGroup", "(", "'and'", ",", "Query", "::", "condition", "(", "'appeared_at'", ",", "'<='", ",", "Time", "::", "current", "(", ")", ")", ",", "Query", "::", "condition", "(", "'appeared_at'", ",", "'is'", ",", "'NULL'", ",", "false", ")", ")", ";", "}", "//", "$", "data", "=", "$", "data", "->", "get", "(", "Query", "::", "GET_ARRAY", ")", ";", "//", "return", "self", "::", "collect", "(", "$", "data", ",", "$", "table", ",", "$", "key", ")", ";", "}" ]
get collection of all data of the model from data table. @return Collection
[ "get", "collection", "of", "all", "data", "of", "the", "model", "from", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L886-L912
241,104
vinala/kernel
src/MVC/Model/ORM.php
ORM.onlyTrash
public static function onlyTrash() { $class = get_called_class(); $object = new $class(); $table = $object->_table; $key = $object->_keyName; // $data = Query::table($table)->select('*'); // if ($object->_canKept) { $data = $data->where('deleted_at', '<=', Time::current()); } // $data = $data->get(Query::GET_ARRAY); // return self::collect($data, $table, $key); }
php
public static function onlyTrash() { $class = get_called_class(); $object = new $class(); $table = $object->_table; $key = $object->_keyName; // $data = Query::table($table)->select('*'); // if ($object->_canKept) { $data = $data->where('deleted_at', '<=', Time::current()); } // $data = $data->get(Query::GET_ARRAY); // return self::collect($data, $table, $key); }
[ "public", "static", "function", "onlyTrash", "(", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "$", "object", "=", "new", "$", "class", "(", ")", ";", "$", "table", "=", "$", "object", "->", "_table", ";", "$", "key", "=", "$", "object", "->", "_keyName", ";", "//", "$", "data", "=", "Query", "::", "table", "(", "$", "table", ")", "->", "select", "(", "'*'", ")", ";", "//", "if", "(", "$", "object", "->", "_canKept", ")", "{", "$", "data", "=", "$", "data", "->", "where", "(", "'deleted_at'", ",", "'<='", ",", "Time", "::", "current", "(", ")", ")", ";", "}", "//", "$", "data", "=", "$", "data", "->", "get", "(", "Query", "::", "GET_ARRAY", ")", ";", "//", "return", "self", "::", "collect", "(", "$", "data", ",", "$", "table", ",", "$", "key", ")", ";", "}" ]
get collection of all kept data of the model from data table. @return Collection
[ "get", "collection", "of", "all", "kept", "data", "of", "the", "model", "from", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L945-L961
241,105
vinala/kernel
src/MVC/Model/ORM.php
ORM.where
public static function where($column, $relation, $value) { $self = self::instance(); $key = $self->_keyName; $data = \Query::from($self->_table)->select($key)->where($column, $relation, $value)->get(); $rows = []; if (!is_null($data)) { foreach ($data as $item) { $rows[] = self::instance($item->$key); } } return $rows; }
php
public static function where($column, $relation, $value) { $self = self::instance(); $key = $self->_keyName; $data = \Query::from($self->_table)->select($key)->where($column, $relation, $value)->get(); $rows = []; if (!is_null($data)) { foreach ($data as $item) { $rows[] = self::instance($item->$key); } } return $rows; }
[ "public", "static", "function", "where", "(", "$", "column", ",", "$", "relation", ",", "$", "value", ")", "{", "$", "self", "=", "self", "::", "instance", "(", ")", ";", "$", "key", "=", "$", "self", "->", "_keyName", ";", "$", "data", "=", "\\", "Query", "::", "from", "(", "$", "self", "->", "_table", ")", "->", "select", "(", "$", "key", ")", "->", "where", "(", "$", "column", ",", "$", "relation", ",", "$", "value", ")", "->", "get", "(", ")", ";", "$", "rows", "=", "[", "]", ";", "if", "(", "!", "is_null", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "item", ")", "{", "$", "rows", "[", "]", "=", "self", "::", "instance", "(", "$", "item", "->", "$", "key", ")", ";", "}", "}", "return", "$", "rows", ";", "}" ]
get data by where clause. @param string $column @param string $relation @param string $value @return array
[ "get", "data", "by", "where", "clause", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L1054-L1068
241,106
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/parser/classes/view.php
View.forge
public static function forge($file = null, $data = null, $auto_encode = null) { $class = null; if ($file !== null) { $extension = pathinfo($file, PATHINFO_EXTENSION); $class = \Config::get('parser.extensions.'.$extension, null); } if ($class === null) { $class = get_called_class(); } // Only get rid of the extension if it is not an absolute file path if ($file !== null and $file[0] !== '/' and $file[1] !== ':') { $file = $extension ? preg_replace('/\.'.preg_quote($extension).'$/i', '', $file) : $file; } // Class can be an array config if (is_array($class)) { $class['extension'] and $extension = $class['extension']; $class = $class['class']; } // Include necessary files foreach ((array) \Config::get('parser.'.$class.'.include', array()) as $include) { if ( ! array_key_exists($include, static::$loaded_files)) { require $include; static::$loaded_files[$include] = true; } } // Instantiate the Parser class without auto-loading the view file if ($auto_encode === null) { $auto_encode = \Config::get('parser.'.$class.'.auto_encode', null); } $view = new $class(null, $data, $auto_encode); if ($file !== null) { // Set extension when given $extension and $view->extension = $extension; // Load the view file $view->set_filename($file); } return $view; }
php
public static function forge($file = null, $data = null, $auto_encode = null) { $class = null; if ($file !== null) { $extension = pathinfo($file, PATHINFO_EXTENSION); $class = \Config::get('parser.extensions.'.$extension, null); } if ($class === null) { $class = get_called_class(); } // Only get rid of the extension if it is not an absolute file path if ($file !== null and $file[0] !== '/' and $file[1] !== ':') { $file = $extension ? preg_replace('/\.'.preg_quote($extension).'$/i', '', $file) : $file; } // Class can be an array config if (is_array($class)) { $class['extension'] and $extension = $class['extension']; $class = $class['class']; } // Include necessary files foreach ((array) \Config::get('parser.'.$class.'.include', array()) as $include) { if ( ! array_key_exists($include, static::$loaded_files)) { require $include; static::$loaded_files[$include] = true; } } // Instantiate the Parser class without auto-loading the view file if ($auto_encode === null) { $auto_encode = \Config::get('parser.'.$class.'.auto_encode', null); } $view = new $class(null, $data, $auto_encode); if ($file !== null) { // Set extension when given $extension and $view->extension = $extension; // Load the view file $view->set_filename($file); } return $view; }
[ "public", "static", "function", "forge", "(", "$", "file", "=", "null", ",", "$", "data", "=", "null", ",", "$", "auto_encode", "=", "null", ")", "{", "$", "class", "=", "null", ";", "if", "(", "$", "file", "!==", "null", ")", "{", "$", "extension", "=", "pathinfo", "(", "$", "file", ",", "PATHINFO_EXTENSION", ")", ";", "$", "class", "=", "\\", "Config", "::", "get", "(", "'parser.extensions.'", ".", "$", "extension", ",", "null", ")", ";", "}", "if", "(", "$", "class", "===", "null", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "}", "// Only get rid of the extension if it is not an absolute file path", "if", "(", "$", "file", "!==", "null", "and", "$", "file", "[", "0", "]", "!==", "'/'", "and", "$", "file", "[", "1", "]", "!==", "':'", ")", "{", "$", "file", "=", "$", "extension", "?", "preg_replace", "(", "'/\\.'", ".", "preg_quote", "(", "$", "extension", ")", ".", "'$/i'", ",", "''", ",", "$", "file", ")", ":", "$", "file", ";", "}", "// Class can be an array config", "if", "(", "is_array", "(", "$", "class", ")", ")", "{", "$", "class", "[", "'extension'", "]", "and", "$", "extension", "=", "$", "class", "[", "'extension'", "]", ";", "$", "class", "=", "$", "class", "[", "'class'", "]", ";", "}", "// Include necessary files", "foreach", "(", "(", "array", ")", "\\", "Config", "::", "get", "(", "'parser.'", ".", "$", "class", ".", "'.include'", ",", "array", "(", ")", ")", "as", "$", "include", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "include", ",", "static", "::", "$", "loaded_files", ")", ")", "{", "require", "$", "include", ";", "static", "::", "$", "loaded_files", "[", "$", "include", "]", "=", "true", ";", "}", "}", "// Instantiate the Parser class without auto-loading the view file", "if", "(", "$", "auto_encode", "===", "null", ")", "{", "$", "auto_encode", "=", "\\", "Config", "::", "get", "(", "'parser.'", ".", "$", "class", ".", "'.auto_encode'", ",", "null", ")", ";", "}", "$", "view", "=", "new", "$", "class", "(", "null", ",", "$", "data", ",", "$", "auto_encode", ")", ";", "if", "(", "$", "file", "!==", "null", ")", "{", "// Set extension when given", "$", "extension", "and", "$", "view", "->", "extension", "=", "$", "extension", ";", "// Load the view file", "$", "view", "->", "set_filename", "(", "$", "file", ")", ";", "}", "return", "$", "view", ";", "}" ]
Forges a new View object based on the extension @param string $file view filename @param array $data view data @param bool $auto_encode auto encode boolean, null for default @return object a new view instance
[ "Forges", "a", "new", "View", "object", "based", "on", "the", "extension" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/parser/classes/view.php#L54-L111
241,107
friendsofaura/FOA.Responder_Bundle
src/Renderer/Smarty.php
Smarty.setTemplateExtension
public function setTemplateExtension($extension) { $extension = (string) $extension; $extension = trim($extension); if ('.' == $extension[0]) { $extension = substr($extension, 1); } $this->extension = $extension; }
php
public function setTemplateExtension($extension) { $extension = (string) $extension; $extension = trim($extension); if ('.' == $extension[0]) { $extension = substr($extension, 1); } $this->extension = $extension; }
[ "public", "function", "setTemplateExtension", "(", "$", "extension", ")", "{", "$", "extension", "=", "(", "string", ")", "$", "extension", ";", "$", "extension", "=", "trim", "(", "$", "extension", ")", ";", "if", "(", "'.'", "==", "$", "extension", "[", "0", "]", ")", "{", "$", "extension", "=", "substr", "(", "$", "extension", ",", "1", ")", ";", "}", "$", "this", "->", "extension", "=", "$", "extension", ";", "}" ]
Set Template Extension file @param string $extension
[ "Set", "Template", "Extension", "file" ]
1c5548a12aead69c775052878330161de4cf0e48
https://github.com/friendsofaura/FOA.Responder_Bundle/blob/1c5548a12aead69c775052878330161de4cf0e48/src/Renderer/Smarty.php#L46-L55
241,108
friendsofaura/FOA.Responder_Bundle
src/Renderer/Smarty.php
Smarty.setLayoutVariableName
public function setLayoutVariableName($name) { $name = (string) $name; $name = trim($name); if (! preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $name)) { throw new InvalidArgumentException('Invalid variable name'); } $this->layoutVariableName = $name; }
php
public function setLayoutVariableName($name) { $name = (string) $name; $name = trim($name); if (! preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $name)) { throw new InvalidArgumentException('Invalid variable name'); } $this->layoutVariableName = $name; }
[ "public", "function", "setLayoutVariableName", "(", "$", "name", ")", "{", "$", "name", "=", "(", "string", ")", "$", "name", ";", "$", "name", "=", "trim", "(", "$", "name", ")", ";", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/'", ",", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid variable name'", ")", ";", "}", "$", "this", "->", "layoutVariableName", "=", "$", "name", ";", "}" ]
Set Layout main variable name @param string $name
[ "Set", "Layout", "main", "variable", "name" ]
1c5548a12aead69c775052878330161de4cf0e48
https://github.com/friendsofaura/FOA.Responder_Bundle/blob/1c5548a12aead69c775052878330161de4cf0e48/src/Renderer/Smarty.php#L72-L80
241,109
uthando-cms/uthando-common
src/UthandoCommon/Model/NestedSet.php
NestedSet.hasChildren
public function hasChildren(): bool { $children = (($this->getRgt() - $this->getLft()) - 1) / 2; return (0 === $children) ? false : true; }
php
public function hasChildren(): bool { $children = (($this->getRgt() - $this->getLft()) - 1) / 2; return (0 === $children) ? false : true; }
[ "public", "function", "hasChildren", "(", ")", ":", "bool", "{", "$", "children", "=", "(", "(", "$", "this", "->", "getRgt", "(", ")", "-", "$", "this", "->", "getLft", "(", ")", ")", "-", "1", ")", "/", "2", ";", "return", "(", "0", "===", "$", "children", ")", "?", "false", ":", "true", ";", "}" ]
returns true if there are children @return bool
[ "returns", "true", "if", "there", "are", "children" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Model/NestedSet.php#L103-L107
241,110
amilna/yap
gii/crud/Generator.php
Generator.generateSearchRules
public function generateSearchRules() { if (($table = $this->getTableSchema()) === false) { return ["[['" . implode("', '", $this->getColumnNames()) . "'], 'safe']"]; } $types = []; foreach ($table->columns as $column) { switch ($column->type) { case Schema::TYPE_SMALLINT: case Schema::TYPE_INTEGER: case Schema::TYPE_BIGINT: $types['integer'][] = $column->name; break; case Schema::TYPE_BOOLEAN: $types['boolean'][] = $column->name; break; case Schema::TYPE_FLOAT: case Schema::TYPE_DECIMAL: case Schema::TYPE_MONEY: //$types['number'][] = $column->name; //break; case Schema::TYPE_DATE: case Schema::TYPE_TIME: case Schema::TYPE_DATETIME: case Schema::TYPE_TIMESTAMP: default: $types['safe'][] = $column->name; break; } } $rules = []; foreach ($types as $type => $columns) { $sf = ""; if ($type == "safe") { $tabs = $this->generateRelations(); foreach ($tabs as $tab) { if ($tab) { $sf .= ($sf == ""?"/*, '":", '").$tab."Id'"; } } $sf .= ($sf == ""?"":"*/"); } $rules[] = "[['" . implode("', '", $columns) . "'".$sf."], '$type']"; } return $rules; }
php
public function generateSearchRules() { if (($table = $this->getTableSchema()) === false) { return ["[['" . implode("', '", $this->getColumnNames()) . "'], 'safe']"]; } $types = []; foreach ($table->columns as $column) { switch ($column->type) { case Schema::TYPE_SMALLINT: case Schema::TYPE_INTEGER: case Schema::TYPE_BIGINT: $types['integer'][] = $column->name; break; case Schema::TYPE_BOOLEAN: $types['boolean'][] = $column->name; break; case Schema::TYPE_FLOAT: case Schema::TYPE_DECIMAL: case Schema::TYPE_MONEY: //$types['number'][] = $column->name; //break; case Schema::TYPE_DATE: case Schema::TYPE_TIME: case Schema::TYPE_DATETIME: case Schema::TYPE_TIMESTAMP: default: $types['safe'][] = $column->name; break; } } $rules = []; foreach ($types as $type => $columns) { $sf = ""; if ($type == "safe") { $tabs = $this->generateRelations(); foreach ($tabs as $tab) { if ($tab) { $sf .= ($sf == ""?"/*, '":", '").$tab."Id'"; } } $sf .= ($sf == ""?"":"*/"); } $rules[] = "[['" . implode("', '", $columns) . "'".$sf."], '$type']"; } return $rules; }
[ "public", "function", "generateSearchRules", "(", ")", "{", "if", "(", "(", "$", "table", "=", "$", "this", "->", "getTableSchema", "(", ")", ")", "===", "false", ")", "{", "return", "[", "\"[['\"", ".", "implode", "(", "\"', '\"", ",", "$", "this", "->", "getColumnNames", "(", ")", ")", ".", "\"'], 'safe']\"", "]", ";", "}", "$", "types", "=", "[", "]", ";", "foreach", "(", "$", "table", "->", "columns", "as", "$", "column", ")", "{", "switch", "(", "$", "column", "->", "type", ")", "{", "case", "Schema", "::", "TYPE_SMALLINT", ":", "case", "Schema", "::", "TYPE_INTEGER", ":", "case", "Schema", "::", "TYPE_BIGINT", ":", "$", "types", "[", "'integer'", "]", "[", "]", "=", "$", "column", "->", "name", ";", "break", ";", "case", "Schema", "::", "TYPE_BOOLEAN", ":", "$", "types", "[", "'boolean'", "]", "[", "]", "=", "$", "column", "->", "name", ";", "break", ";", "case", "Schema", "::", "TYPE_FLOAT", ":", "case", "Schema", "::", "TYPE_DECIMAL", ":", "case", "Schema", "::", "TYPE_MONEY", ":", "//$types['number'][] = $column->name;", "//break;", "case", "Schema", "::", "TYPE_DATE", ":", "case", "Schema", "::", "TYPE_TIME", ":", "case", "Schema", "::", "TYPE_DATETIME", ":", "case", "Schema", "::", "TYPE_TIMESTAMP", ":", "default", ":", "$", "types", "[", "'safe'", "]", "[", "]", "=", "$", "column", "->", "name", ";", "break", ";", "}", "}", "$", "rules", "=", "[", "]", ";", "foreach", "(", "$", "types", "as", "$", "type", "=>", "$", "columns", ")", "{", "$", "sf", "=", "\"\"", ";", "if", "(", "$", "type", "==", "\"safe\"", ")", "{", "$", "tabs", "=", "$", "this", "->", "generateRelations", "(", ")", ";", "foreach", "(", "$", "tabs", "as", "$", "tab", ")", "{", "if", "(", "$", "tab", ")", "{", "$", "sf", ".=", "(", "$", "sf", "==", "\"\"", "?", "\"/*, '\"", ":", "\", '\"", ")", ".", "$", "tab", ".", "\"Id'\"", ";", "}", "}", "$", "sf", ".=", "(", "$", "sf", "==", "\"\"", "?", "\"\"", ":", "\"*/\"", ")", ";", "}", "$", "rules", "[", "]", "=", "\"[['\"", ".", "implode", "(", "\"', '\"", ",", "$", "columns", ")", ".", "\"'\"", ".", "$", "sf", ".", "\"], '$type']\"", ";", "}", "return", "$", "rules", ";", "}" ]
Generates validation rules for the search model. @return array the generated validation rules
[ "Generates", "validation", "rules", "for", "the", "search", "model", "." ]
24a9e7115cb92055b4c5e78c63a4a7d4f962004a
https://github.com/amilna/yap/blob/24a9e7115cb92055b4c5e78c63a4a7d4f962004a/gii/crud/Generator.php#L313-L362
241,111
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/observer.php
Observer.instance
public static function instance($model_class) { $observer = get_called_class(); if (empty(static::$_instances[$observer][$model_class])) { static::$_instances[$observer][$model_class] = new static($model_class); } return static::$_instances[$observer][$model_class]; }
php
public static function instance($model_class) { $observer = get_called_class(); if (empty(static::$_instances[$observer][$model_class])) { static::$_instances[$observer][$model_class] = new static($model_class); } return static::$_instances[$observer][$model_class]; }
[ "public", "static", "function", "instance", "(", "$", "model_class", ")", "{", "$", "observer", "=", "get_called_class", "(", ")", ";", "if", "(", "empty", "(", "static", "::", "$", "_instances", "[", "$", "observer", "]", "[", "$", "model_class", "]", ")", ")", "{", "static", "::", "$", "_instances", "[", "$", "observer", "]", "[", "$", "model_class", "]", "=", "new", "static", "(", "$", "model_class", ")", ";", "}", "return", "static", "::", "$", "_instances", "[", "$", "observer", "]", "[", "$", "model_class", "]", ";", "}" ]
Create an instance of this observer @param string name of the model class
[ "Create", "an", "instance", "of", "this", "observer" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/observer.php#L47-L56
241,112
requtize/atline
src/Atline/Compiler.php
Compiler.compiledExists
public function compiledExists() { return $this->cached === false ? false : file_exists($this->cachePath.'/'.$this->getClassName().'.php'); }
php
public function compiledExists() { return $this->cached === false ? false : file_exists($this->cachePath.'/'.$this->getClassName().'.php'); }
[ "public", "function", "compiledExists", "(", ")", "{", "return", "$", "this", "->", "cached", "===", "false", "?", "false", ":", "file_exists", "(", "$", "this", "->", "cachePath", ".", "'/'", ".", "$", "this", "->", "getClassName", "(", ")", ".", "'.php'", ")", ";", "}" ]
Check if compiled view already exists. @return boolean
[ "Check", "if", "compiled", "view", "already", "exists", "." ]
9a1b5fe70485f701b3d300fe41d81e6eccc0f27d
https://github.com/requtize/atline/blob/9a1b5fe70485f701b3d300fe41d81e6eccc0f27d/src/Atline/Compiler.php#L175-L178
241,113
requtize/atline
src/Atline/Compiler.php
Compiler.compile
public function compile() { if($this->compiledExists() === false) { if(is_file($this->filepath) === false) { throw new \Exception('File "'.$this->filepath.'" does not exists.'); } $this->raw = file_get_contents($this->filepath); if($this->options['add-source-line-numbers']) $this->prepared = $this->addLinesNumbers($this->raw); else $this->prepared = $this->raw; $this->removeComments(); $this->resolveExtending(); $this->compileRenders(); $this->compileEchoes(); $this->compileConditions(); $this->compileLoops(); $this->compileSpecialStatements(); $this->prepareSections(); $this->findSections(); $this->replaceSections(); } }
php
public function compile() { if($this->compiledExists() === false) { if(is_file($this->filepath) === false) { throw new \Exception('File "'.$this->filepath.'" does not exists.'); } $this->raw = file_get_contents($this->filepath); if($this->options['add-source-line-numbers']) $this->prepared = $this->addLinesNumbers($this->raw); else $this->prepared = $this->raw; $this->removeComments(); $this->resolveExtending(); $this->compileRenders(); $this->compileEchoes(); $this->compileConditions(); $this->compileLoops(); $this->compileSpecialStatements(); $this->prepareSections(); $this->findSections(); $this->replaceSections(); } }
[ "public", "function", "compile", "(", ")", "{", "if", "(", "$", "this", "->", "compiledExists", "(", ")", "===", "false", ")", "{", "if", "(", "is_file", "(", "$", "this", "->", "filepath", ")", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "'File \"'", ".", "$", "this", "->", "filepath", ".", "'\" does not exists.'", ")", ";", "}", "$", "this", "->", "raw", "=", "file_get_contents", "(", "$", "this", "->", "filepath", ")", ";", "if", "(", "$", "this", "->", "options", "[", "'add-source-line-numbers'", "]", ")", "$", "this", "->", "prepared", "=", "$", "this", "->", "addLinesNumbers", "(", "$", "this", "->", "raw", ")", ";", "else", "$", "this", "->", "prepared", "=", "$", "this", "->", "raw", ";", "$", "this", "->", "removeComments", "(", ")", ";", "$", "this", "->", "resolveExtending", "(", ")", ";", "$", "this", "->", "compileRenders", "(", ")", ";", "$", "this", "->", "compileEchoes", "(", ")", ";", "$", "this", "->", "compileConditions", "(", ")", ";", "$", "this", "->", "compileLoops", "(", ")", ";", "$", "this", "->", "compileSpecialStatements", "(", ")", ";", "$", "this", "->", "prepareSections", "(", ")", ";", "$", "this", "->", "findSections", "(", ")", ";", "$", "this", "->", "replaceSections", "(", ")", ";", "}", "}" ]
Compile view, if compiled version doesn't exists in cache. @return void
[ "Compile", "view", "if", "compiled", "version", "doesn", "t", "exists", "in", "cache", "." ]
9a1b5fe70485f701b3d300fe41d81e6eccc0f27d
https://github.com/requtize/atline/blob/9a1b5fe70485f701b3d300fe41d81e6eccc0f27d/src/Atline/Compiler.php#L206-L233
241,114
requtize/atline
src/Atline/Compiler.php
Compiler.resolveExtending
public function resolveExtending() { /** * Extending of view. */ preg_match_all('/@extends\(\'([a-zA-Z0-9\.\-]+)\'\)/', $this->prepared, $matches); if(isset($matches[1][0])) { $this->extends = trim($matches[1][0]); $this->prepared = trim(str_replace($matches[0][0], '', $this->prepared)); } /** * Tag means that this view should not be extending. */ preg_match_all('/@no-extends/', $this->prepared, $matches); if(isset($matches[0][0]) && count($matches[0][0]) == 1) { $this->extends = false; $this->prepared = trim(str_replace($matches[0][0], '', $this->prepared)); } }
php
public function resolveExtending() { /** * Extending of view. */ preg_match_all('/@extends\(\'([a-zA-Z0-9\.\-]+)\'\)/', $this->prepared, $matches); if(isset($matches[1][0])) { $this->extends = trim($matches[1][0]); $this->prepared = trim(str_replace($matches[0][0], '', $this->prepared)); } /** * Tag means that this view should not be extending. */ preg_match_all('/@no-extends/', $this->prepared, $matches); if(isset($matches[0][0]) && count($matches[0][0]) == 1) { $this->extends = false; $this->prepared = trim(str_replace($matches[0][0], '', $this->prepared)); } }
[ "public", "function", "resolveExtending", "(", ")", "{", "/**\n * Extending of view.\n */", "preg_match_all", "(", "'/@extends\\(\\'([a-zA-Z0-9\\.\\-]+)\\'\\)/'", ",", "$", "this", "->", "prepared", ",", "$", "matches", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "1", "]", "[", "0", "]", ")", ")", "{", "$", "this", "->", "extends", "=", "trim", "(", "$", "matches", "[", "1", "]", "[", "0", "]", ")", ";", "$", "this", "->", "prepared", "=", "trim", "(", "str_replace", "(", "$", "matches", "[", "0", "]", "[", "0", "]", ",", "''", ",", "$", "this", "->", "prepared", ")", ")", ";", "}", "/**\n * Tag means that this view should not be extending.\n */", "preg_match_all", "(", "'/@no-extends/'", ",", "$", "this", "->", "prepared", ",", "$", "matches", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "0", "]", "[", "0", "]", ")", "&&", "count", "(", "$", "matches", "[", "0", "]", "[", "0", "]", ")", "==", "1", ")", "{", "$", "this", "->", "extends", "=", "false", ";", "$", "this", "->", "prepared", "=", "trim", "(", "str_replace", "(", "$", "matches", "[", "0", "]", "[", "0", "]", ",", "''", ",", "$", "this", "->", "prepared", ")", ")", ";", "}", "}" ]
Extending view. Examples: - Extends view by view named by definition: master.index @extends('master.index') - Tells that this view should not be extending. @no-extends
[ "Extending", "view", "." ]
9a1b5fe70485f701b3d300fe41d81e6eccc0f27d
https://github.com/requtize/atline/blob/9a1b5fe70485f701b3d300fe41d81e6eccc0f27d/src/Atline/Compiler.php#L429-L454
241,115
requtize/atline
src/Atline/Compiler.php
Compiler.compileSpecialStatements
public function compileSpecialStatements() { /** * Statemet that sets the variable value. */ preg_match_all('/@set\s?(.*)/', $this->prepared, $matches); foreach($matches[0] as $key => $val) { $exploded = explode(' ', $matches[1][$key]); $varName = substr(trim(array_shift($exploded)), 1); $value = trim(ltrim(trim(implode(' ', $exploded)), '=')); $this->prepared = str_replace($matches[0][$key], "<?php $$varName = $value; \$this->appendData(['$varName' => $$varName]); ?>", $this->prepared); } /** * @todo Make possible to definie owv statements and parsing it. */ /*foreach($this->specialStatements as $statement => $callback) { preg_match_all('/@'.$statement.'\s?(.*)/', $this->prepared, $matches); call_user_func_array($callback, [$this, $matches]); }*/ }
php
public function compileSpecialStatements() { /** * Statemet that sets the variable value. */ preg_match_all('/@set\s?(.*)/', $this->prepared, $matches); foreach($matches[0] as $key => $val) { $exploded = explode(' ', $matches[1][$key]); $varName = substr(trim(array_shift($exploded)), 1); $value = trim(ltrim(trim(implode(' ', $exploded)), '=')); $this->prepared = str_replace($matches[0][$key], "<?php $$varName = $value; \$this->appendData(['$varName' => $$varName]); ?>", $this->prepared); } /** * @todo Make possible to definie owv statements and parsing it. */ /*foreach($this->specialStatements as $statement => $callback) { preg_match_all('/@'.$statement.'\s?(.*)/', $this->prepared, $matches); call_user_func_array($callback, [$this, $matches]); }*/ }
[ "public", "function", "compileSpecialStatements", "(", ")", "{", "/**\n * Statemet that sets the variable value.\n */", "preg_match_all", "(", "'/@set\\s?(.*)/'", ",", "$", "this", "->", "prepared", ",", "$", "matches", ")", ";", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "exploded", "=", "explode", "(", "' '", ",", "$", "matches", "[", "1", "]", "[", "$", "key", "]", ")", ";", "$", "varName", "=", "substr", "(", "trim", "(", "array_shift", "(", "$", "exploded", ")", ")", ",", "1", ")", ";", "$", "value", "=", "trim", "(", "ltrim", "(", "trim", "(", "implode", "(", "' '", ",", "$", "exploded", ")", ")", ",", "'='", ")", ")", ";", "$", "this", "->", "prepared", "=", "str_replace", "(", "$", "matches", "[", "0", "]", "[", "$", "key", "]", ",", "\"<?php $$varName = $value; \\$this->appendData(['$varName' => $$varName]); ?>\"", ",", "$", "this", "->", "prepared", ")", ";", "}", "/**\n * @todo Make possible to definie owv statements and parsing it.\n */", "/*foreach($this->specialStatements as $statement => $callback)\n {\n preg_match_all('/@'.$statement.'\\s?(.*)/', $this->prepared, $matches);\n\n call_user_func_array($callback, [$this, $matches]);\n }*/", "}" ]
Compile special statements. Exaples: - Sets variable with value @set $variable 'value' @return void
[ "Compile", "special", "statements", "." ]
9a1b5fe70485f701b3d300fe41d81e6eccc0f27d
https://github.com/requtize/atline/blob/9a1b5fe70485f701b3d300fe41d81e6eccc0f27d/src/Atline/Compiler.php#L844-L869
241,116
requtize/atline
src/Atline/Compiler.php
Compiler.createFiltersMethods
public function createFiltersMethods(array $names, $variable) { if($names === array()) { return $variable; } $filter = array_shift($names); if($filter === 'raw') { $result = $this->createFiltersMethods($names, $variable); } else { $begin = ''; $end = ''; if(function_exists($filter)) { $begin = "{$filter}("; } else { $begin = "\$env->filter('{$filter}', "; } $result = $begin.$this->createFiltersMethods($names, $variable).')'; } return $result; }
php
public function createFiltersMethods(array $names, $variable) { if($names === array()) { return $variable; } $filter = array_shift($names); if($filter === 'raw') { $result = $this->createFiltersMethods($names, $variable); } else { $begin = ''; $end = ''; if(function_exists($filter)) { $begin = "{$filter}("; } else { $begin = "\$env->filter('{$filter}', "; } $result = $begin.$this->createFiltersMethods($names, $variable).')'; } return $result; }
[ "public", "function", "createFiltersMethods", "(", "array", "$", "names", ",", "$", "variable", ")", "{", "if", "(", "$", "names", "===", "array", "(", ")", ")", "{", "return", "$", "variable", ";", "}", "$", "filter", "=", "array_shift", "(", "$", "names", ")", ";", "if", "(", "$", "filter", "===", "'raw'", ")", "{", "$", "result", "=", "$", "this", "->", "createFiltersMethods", "(", "$", "names", ",", "$", "variable", ")", ";", "}", "else", "{", "$", "begin", "=", "''", ";", "$", "end", "=", "''", ";", "if", "(", "function_exists", "(", "$", "filter", ")", ")", "{", "$", "begin", "=", "\"{$filter}(\"", ";", "}", "else", "{", "$", "begin", "=", "\"\\$env->filter('{$filter}', \"", ";", "}", "$", "result", "=", "$", "begin", ".", "$", "this", "->", "createFiltersMethods", "(", "$", "names", ",", "$", "variable", ")", ".", "')'", ";", "}", "return", "$", "result", ";", "}" ]
Creates filters methods for varible. @param array $names Array of filters to apply. @param string $variable Variable name for filtering. @return string
[ "Creates", "filters", "methods", "for", "varible", "." ]
9a1b5fe70485f701b3d300fe41d81e6eccc0f27d
https://github.com/requtize/atline/blob/9a1b5fe70485f701b3d300fe41d81e6eccc0f27d/src/Atline/Compiler.php#L878-L909
241,117
coreplex/core
src/Session/Native.php
Native.get
public function get($key) { $session = $this->getSessionData(); return $this->has($key) ? $session[$key] : null; }
php
public function get($key) { $session = $this->getSessionData(); return $this->has($key) ? $session[$key] : null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "session", "=", "$", "this", "->", "getSessionData", "(", ")", ";", "return", "$", "this", "->", "has", "(", "$", "key", ")", "?", "$", "session", "[", "$", "key", "]", ":", "null", ";", "}" ]
Retrieve a property from the session by its key. @param $key @return mixed
[ "Retrieve", "a", "property", "from", "the", "session", "by", "its", "key", "." ]
82ce08268dc6291310bc7d1060cc65a17e78244c
https://github.com/coreplex/core/blob/82ce08268dc6291310bc7d1060cc65a17e78244c/src/Session/Native.php#L69-L74
241,118
coreplex/core
src/Session/Native.php
Native.getSessionData
protected function getSessionData() { $data = isset($_SESSION[$this->config['key']]) ? $_SESSION[$this->config['key']] : []; return array_merge($data, $this->flash); }
php
protected function getSessionData() { $data = isset($_SESSION[$this->config['key']]) ? $_SESSION[$this->config['key']] : []; return array_merge($data, $this->flash); }
[ "protected", "function", "getSessionData", "(", ")", "{", "$", "data", "=", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "config", "[", "'key'", "]", "]", ")", "?", "$", "_SESSION", "[", "$", "this", "->", "config", "[", "'key'", "]", "]", ":", "[", "]", ";", "return", "array_merge", "(", "$", "data", ",", "$", "this", "->", "flash", ")", ";", "}" ]
Merge all of the notifier session data and any flashed data. @return array
[ "Merge", "all", "of", "the", "notifier", "session", "data", "and", "any", "flashed", "data", "." ]
82ce08268dc6291310bc7d1060cc65a17e78244c
https://github.com/coreplex/core/blob/82ce08268dc6291310bc7d1060cc65a17e78244c/src/Session/Native.php#L123-L128
241,119
ExSituMarketing/EXS-LanderTrackingHouseBundle
Service/TrackingParameterAppender.php
TrackingParameterAppender.append
public function append($url, $formatterName = null) { $urlComponents = parse_url($url); $parameters = array(); if (isset($urlComponents['query'])) { parse_str($urlComponents['query'], $parameters); } $trackingParameters = $this->persister->getAllTrackingParameters(); if (null !== $formatterName) { $foundFormatter = $this->findFormatterByName($formatterName); if (null === $foundFormatter) { throw new InvalidConfigurationException(sprintf('Unknown formatter "%s".', $formatterName)); } $parameters = array_merge( $parameters, $this->formatters[$foundFormatter]->format($trackingParameters) ); $parameters = $this->formatters[$foundFormatter]->checkFormat($parameters); } /** Search for tracking parameters to replace in query's parameters. */ foreach ($parameters as $parameterName => $parameterValue) { if (!is_array($parameterValue) && preg_match('`^{\s?(?<parameter>[a-z0-9_]+)\s?}$`i', $parameterValue, $matches)) { $parameters[$parameterName] = $trackingParameters->get($matches['parameter'], null); } } /** Rebuild the query parameters string. */ $urlComponents['query'] = http_build_query($parameters, null, '&', PHP_QUERY_RFC3986); if (true === empty($urlComponents['query'])) { /* Force to null to avoid single "?" at the end of url */ $urlComponents['query'] = null; } return $this->buildUrl($urlComponents); }
php
public function append($url, $formatterName = null) { $urlComponents = parse_url($url); $parameters = array(); if (isset($urlComponents['query'])) { parse_str($urlComponents['query'], $parameters); } $trackingParameters = $this->persister->getAllTrackingParameters(); if (null !== $formatterName) { $foundFormatter = $this->findFormatterByName($formatterName); if (null === $foundFormatter) { throw new InvalidConfigurationException(sprintf('Unknown formatter "%s".', $formatterName)); } $parameters = array_merge( $parameters, $this->formatters[$foundFormatter]->format($trackingParameters) ); $parameters = $this->formatters[$foundFormatter]->checkFormat($parameters); } /** Search for tracking parameters to replace in query's parameters. */ foreach ($parameters as $parameterName => $parameterValue) { if (!is_array($parameterValue) && preg_match('`^{\s?(?<parameter>[a-z0-9_]+)\s?}$`i', $parameterValue, $matches)) { $parameters[$parameterName] = $trackingParameters->get($matches['parameter'], null); } } /** Rebuild the query parameters string. */ $urlComponents['query'] = http_build_query($parameters, null, '&', PHP_QUERY_RFC3986); if (true === empty($urlComponents['query'])) { /* Force to null to avoid single "?" at the end of url */ $urlComponents['query'] = null; } return $this->buildUrl($urlComponents); }
[ "public", "function", "append", "(", "$", "url", ",", "$", "formatterName", "=", "null", ")", "{", "$", "urlComponents", "=", "parse_url", "(", "$", "url", ")", ";", "$", "parameters", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "urlComponents", "[", "'query'", "]", ")", ")", "{", "parse_str", "(", "$", "urlComponents", "[", "'query'", "]", ",", "$", "parameters", ")", ";", "}", "$", "trackingParameters", "=", "$", "this", "->", "persister", "->", "getAllTrackingParameters", "(", ")", ";", "if", "(", "null", "!==", "$", "formatterName", ")", "{", "$", "foundFormatter", "=", "$", "this", "->", "findFormatterByName", "(", "$", "formatterName", ")", ";", "if", "(", "null", "===", "$", "foundFormatter", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'Unknown formatter \"%s\".'", ",", "$", "formatterName", ")", ")", ";", "}", "$", "parameters", "=", "array_merge", "(", "$", "parameters", ",", "$", "this", "->", "formatters", "[", "$", "foundFormatter", "]", "->", "format", "(", "$", "trackingParameters", ")", ")", ";", "$", "parameters", "=", "$", "this", "->", "formatters", "[", "$", "foundFormatter", "]", "->", "checkFormat", "(", "$", "parameters", ")", ";", "}", "/** Search for tracking parameters to replace in query's parameters. */", "foreach", "(", "$", "parameters", "as", "$", "parameterName", "=>", "$", "parameterValue", ")", "{", "if", "(", "!", "is_array", "(", "$", "parameterValue", ")", "&&", "preg_match", "(", "'`^{\\s?(?<parameter>[a-z0-9_]+)\\s?}$`i'", ",", "$", "parameterValue", ",", "$", "matches", ")", ")", "{", "$", "parameters", "[", "$", "parameterName", "]", "=", "$", "trackingParameters", "->", "get", "(", "$", "matches", "[", "'parameter'", "]", ",", "null", ")", ";", "}", "}", "/** Rebuild the query parameters string. */", "$", "urlComponents", "[", "'query'", "]", "=", "http_build_query", "(", "$", "parameters", ",", "null", ",", "'&'", ",", "PHP_QUERY_RFC3986", ")", ";", "if", "(", "true", "===", "empty", "(", "$", "urlComponents", "[", "'query'", "]", ")", ")", "{", "/* Force to null to avoid single \"?\" at the end of url */", "$", "urlComponents", "[", "'query'", "]", "=", "null", ";", "}", "return", "$", "this", "->", "buildUrl", "(", "$", "urlComponents", ")", ";", "}" ]
Appends the query parameters depending on domain's formatters defined in configuration. @param string $url @param string $formatterName @return string
[ "Appends", "the", "query", "parameters", "depending", "on", "domain", "s", "formatters", "defined", "in", "configuration", "." ]
404ce51ec1ee0bf5e669eb1f4cd04746e244f61a
https://github.com/ExSituMarketing/EXS-LanderTrackingHouseBundle/blob/404ce51ec1ee0bf5e669eb1f4cd04746e244f61a/Service/TrackingParameterAppender.php#L90-L131
241,120
SlabPHP/sequencer
src/CallQueue.php
CallQueue.execute
public function execute($objectContext) { if (!$this->ok) return; foreach ($this->entries as $entry) { if (!$this->ok) return; $entry->execute($objectContext); } }
php
public function execute($objectContext) { if (!$this->ok) return; foreach ($this->entries as $entry) { if (!$this->ok) return; $entry->execute($objectContext); } }
[ "public", "function", "execute", "(", "$", "objectContext", ")", "{", "if", "(", "!", "$", "this", "->", "ok", ")", "return", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "if", "(", "!", "$", "this", "->", "ok", ")", "return", ";", "$", "entry", "->", "execute", "(", "$", "objectContext", ")", ";", "}", "}" ]
Execute call queue @param $objectContext
[ "Execute", "call", "queue" ]
77fd738a4df741c8e789b9ccf4974efc47328346
https://github.com/SlabPHP/sequencer/blob/77fd738a4df741c8e789b9ccf4974efc47328346/src/CallQueue.php#L77-L87
241,121
znframework/package-console
Library.php
Library.classMethod
protected function classMethod(&$class = NULL, &$method = NULL, $command) { $commandEx = explode(':', $command); $class = $commandEx[0]; $method = $commandEx[1] ?? NULL; }
php
protected function classMethod(&$class = NULL, &$method = NULL, $command) { $commandEx = explode(':', $command); $class = $commandEx[0]; $method = $commandEx[1] ?? NULL; }
[ "protected", "function", "classMethod", "(", "&", "$", "class", "=", "NULL", ",", "&", "$", "method", "=", "NULL", ",", "$", "command", ")", "{", "$", "commandEx", "=", "explode", "(", "':'", ",", "$", "command", ")", ";", "$", "class", "=", "$", "commandEx", "[", "0", "]", ";", "$", "method", "=", "$", "commandEx", "[", "1", "]", "??", "NULL", ";", "}" ]
protected class method @param string &$class @param string &$method @return void
[ "protected", "class", "method" ]
fde428da8b9d926ea4256c235f542e6225c5d788
https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Library.php#L46-L51
241,122
jannisfink/config
src/loader/FileConfigurationLoader.php
FileConfigurationLoader.checkConfiguration
public final function checkConfiguration($deep = false) { if (!file_exists($this->filename) || !is_readable($this->filename)) { throw new ConfigurationNotFoundException("File $this->filename does not exist or is not readable"); } $fileExtension = pathinfo($this->filename, PATHINFO_EXTENSION); if (in_array($fileExtension, static::$supportedFileTypes)) { return true; } if (!$deep) { return false; } try { $this->parseAndCacheConfiguration(); return true; } catch (ParseException $e) { return false; } }
php
public final function checkConfiguration($deep = false) { if (!file_exists($this->filename) || !is_readable($this->filename)) { throw new ConfigurationNotFoundException("File $this->filename does not exist or is not readable"); } $fileExtension = pathinfo($this->filename, PATHINFO_EXTENSION); if (in_array($fileExtension, static::$supportedFileTypes)) { return true; } if (!$deep) { return false; } try { $this->parseAndCacheConfiguration(); return true; } catch (ParseException $e) { return false; } }
[ "public", "final", "function", "checkConfiguration", "(", "$", "deep", "=", "false", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "filename", ")", "||", "!", "is_readable", "(", "$", "this", "->", "filename", ")", ")", "{", "throw", "new", "ConfigurationNotFoundException", "(", "\"File $this->filename does not exist or is not readable\"", ")", ";", "}", "$", "fileExtension", "=", "pathinfo", "(", "$", "this", "->", "filename", ",", "PATHINFO_EXTENSION", ")", ";", "if", "(", "in_array", "(", "$", "fileExtension", ",", "static", "::", "$", "supportedFileTypes", ")", ")", "{", "return", "true", ";", "}", "if", "(", "!", "$", "deep", ")", "{", "return", "false", ";", "}", "try", "{", "$", "this", "->", "parseAndCacheConfiguration", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "ParseException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Checks, if a given file can be parsed by this configuration loader. If the file type is supported by this loader, this function will return true without further checking for correct syntax of the configuration file. If the deep parameter is set to true, this function will try to parse the file formats to test whether they can be parsed or not. @param $deep bool if set to true, this function will just look for the file extension @return bool true, if the given file can be parsed by this loader, false else @throws ConfigurationNotFoundException if the given accessor accesses no valid configuration
[ "Checks", "if", "a", "given", "file", "can", "be", "parsed", "by", "this", "configuration", "loader", ".", "If", "the", "file", "type", "is", "supported", "by", "this", "loader", "this", "function", "will", "return", "true", "without", "further", "checking", "for", "correct", "syntax", "of", "the", "configuration", "file", "." ]
54dc18c6125c971c46ded9f9484f6802112aab44
https://github.com/jannisfink/config/blob/54dc18c6125c971c46ded9f9484f6802112aab44/src/loader/FileConfigurationLoader.php#L70-L90
241,123
inceddy/ieu_http
src/ieu/Http/RedirectResponse.php
RedirectResponse.setTarget
public function setTarget($target) { if (!is_string($target) || $target == '') { throw new \InvalidArgumentException('No valid URL given.'); } $this->target = $target; // Set meta refresh content if header location is ignored $this->setContent( sprintf('<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta http-equiv="refresh" content="0; url=%1$s" /> </head> <body> <p>Redirecting to <a href="%1$s">%1$s</a>. </body> </html>', htmlspecialchars($target, ENT_QUOTES, 'UTF-8'))); // Set header location $this->setHeader('Location', $target); return $this; }
php
public function setTarget($target) { if (!is_string($target) || $target == '') { throw new \InvalidArgumentException('No valid URL given.'); } $this->target = $target; // Set meta refresh content if header location is ignored $this->setContent( sprintf('<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta http-equiv="refresh" content="0; url=%1$s" /> </head> <body> <p>Redirecting to <a href="%1$s">%1$s</a>. </body> </html>', htmlspecialchars($target, ENT_QUOTES, 'UTF-8'))); // Set header location $this->setHeader('Location', $target); return $this; }
[ "public", "function", "setTarget", "(", "$", "target", ")", "{", "if", "(", "!", "is_string", "(", "$", "target", ")", "||", "$", "target", "==", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'No valid URL given.'", ")", ";", "}", "$", "this", "->", "target", "=", "$", "target", ";", "// Set meta refresh content if header location is ignored\r", "$", "this", "->", "setContent", "(", "sprintf", "(", "'<!DOCTYPE html>\r\n<html>\r\n <head>\r\n <meta charset=\"UTF-8\" />\r\n <meta http-equiv=\"refresh\" content=\"0; url=%1$s\" />\r\n </head>\r\n <body>\r\n <p>Redirecting to <a href=\"%1$s\">%1$s</a>.\r\n </body>\r\n</html>'", ",", "htmlspecialchars", "(", "$", "target", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ")", ";", "// Set header location\r", "$", "this", "->", "setHeader", "(", "'Location'", ",", "$", "target", ")", ";", "return", "$", "this", ";", "}" ]
Sets the target URL where the redirections points to. @param string $target The target URL @return self
[ "Sets", "the", "target", "URL", "where", "the", "redirections", "points", "to", "." ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/RedirectResponse.php#L52-L77
241,124
nubs/sensible
src/Editor.php
Editor.editFile
public function editFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_editorCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
public function editFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_editorCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
[ "public", "function", "editFile", "(", "ProcessBuilder", "$", "processBuilder", ",", "$", "filePath", ")", "{", "$", "proc", "=", "$", "processBuilder", "->", "setPrefix", "(", "$", "this", "->", "_editorCommand", ")", "->", "setArguments", "(", "[", "$", "filePath", "]", ")", "->", "getProcess", "(", ")", ";", "$", "proc", "->", "setTty", "(", "true", ")", "->", "run", "(", ")", ";", "return", "$", "proc", ";", "}" ]
Edit the given file using the symfony process builder to build the symfony process to execute. @api @param \Symfony\Component\Process\ProcessBuilder $processBuilder The process builder. @param string $filePath The path to the file to edit. @return \Symfony\Component\Process\Process The already-executed process.
[ "Edit", "the", "given", "file", "using", "the", "symfony", "process", "builder", "to", "build", "the", "symfony", "process", "to", "execute", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Editor.php#L35-L41
241,125
nubs/sensible
src/Editor.php
Editor.editData
public function editData(ProcessBuilder $processBuilder, $data) { $filePath = tempnam(sys_get_temp_dir(), 'sensibleEditor'); file_put_contents($filePath, $data); $proc = $this->editFile($processBuilder, $filePath); if ($proc->isSuccessful()) { $data = file_get_contents($filePath); } unlink($filePath); return $data; }
php
public function editData(ProcessBuilder $processBuilder, $data) { $filePath = tempnam(sys_get_temp_dir(), 'sensibleEditor'); file_put_contents($filePath, $data); $proc = $this->editFile($processBuilder, $filePath); if ($proc->isSuccessful()) { $data = file_get_contents($filePath); } unlink($filePath); return $data; }
[ "public", "function", "editData", "(", "ProcessBuilder", "$", "processBuilder", ",", "$", "data", ")", "{", "$", "filePath", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "'sensibleEditor'", ")", ";", "file_put_contents", "(", "$", "filePath", ",", "$", "data", ")", ";", "$", "proc", "=", "$", "this", "->", "editFile", "(", "$", "processBuilder", ",", "$", "filePath", ")", ";", "if", "(", "$", "proc", "->", "isSuccessful", "(", ")", ")", "{", "$", "data", "=", "file_get_contents", "(", "$", "filePath", ")", ";", "}", "unlink", "(", "$", "filePath", ")", ";", "return", "$", "data", ";", "}" ]
Edit the given data using the symfony process builder to build the symfony process to execute. @api @param \Symfony\Component\Process\ProcessBuilder $processBuilder The process builder. @param string $data The data to edit. @return string The edited data (left alone if the editor returns a failure).
[ "Edit", "the", "given", "data", "using", "the", "symfony", "process", "builder", "to", "build", "the", "symfony", "process", "to", "execute", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Editor.php#L54-L67
241,126
arkanmgerges/multi-tier-architecture
src/MultiTierArchitecture/UseCase/Definition/BaseAbstract.php
BaseAbstract.execute
public function execute() { $repositoryResponse = []; $arrayOfObjects = []; $resultCount = 0; $responseStatus = ResponseAbstract::STATUS_SUCCESS; try { $this->executeDataGateway(); if ($this->repository != null) { $arrayOfObjects = $this->repository->getEntitiesFromResponse(); $repositoryResponse = $this->repository->getResponse(); $responseStatus = $this->repository->isResponseStatusSuccess() == true ? ResponseAbstract::STATUS_SUCCESS : ResponseAbstract::STATUS_FAIL; } else { $arrayOfObjects = []; $repositoryResponse = []; } $resultCount = $this->getTotalResultCount(); } catch (\Exception $e) { $responseStatus = ResponseAbstract::STATUS_FAIL; $this->response->setMessages(['No result was found']); } $this->response->setStatus($responseStatus); $this->response->setResult($arrayOfObjects); $this->response->setSourceResponse($repositoryResponse); $this->response->setTotalResultCount($resultCount); }
php
public function execute() { $repositoryResponse = []; $arrayOfObjects = []; $resultCount = 0; $responseStatus = ResponseAbstract::STATUS_SUCCESS; try { $this->executeDataGateway(); if ($this->repository != null) { $arrayOfObjects = $this->repository->getEntitiesFromResponse(); $repositoryResponse = $this->repository->getResponse(); $responseStatus = $this->repository->isResponseStatusSuccess() == true ? ResponseAbstract::STATUS_SUCCESS : ResponseAbstract::STATUS_FAIL; } else { $arrayOfObjects = []; $repositoryResponse = []; } $resultCount = $this->getTotalResultCount(); } catch (\Exception $e) { $responseStatus = ResponseAbstract::STATUS_FAIL; $this->response->setMessages(['No result was found']); } $this->response->setStatus($responseStatus); $this->response->setResult($arrayOfObjects); $this->response->setSourceResponse($repositoryResponse); $this->response->setTotalResultCount($resultCount); }
[ "public", "function", "execute", "(", ")", "{", "$", "repositoryResponse", "=", "[", "]", ";", "$", "arrayOfObjects", "=", "[", "]", ";", "$", "resultCount", "=", "0", ";", "$", "responseStatus", "=", "ResponseAbstract", "::", "STATUS_SUCCESS", ";", "try", "{", "$", "this", "->", "executeDataGateway", "(", ")", ";", "if", "(", "$", "this", "->", "repository", "!=", "null", ")", "{", "$", "arrayOfObjects", "=", "$", "this", "->", "repository", "->", "getEntitiesFromResponse", "(", ")", ";", "$", "repositoryResponse", "=", "$", "this", "->", "repository", "->", "getResponse", "(", ")", ";", "$", "responseStatus", "=", "$", "this", "->", "repository", "->", "isResponseStatusSuccess", "(", ")", "==", "true", "?", "ResponseAbstract", "::", "STATUS_SUCCESS", ":", "ResponseAbstract", "::", "STATUS_FAIL", ";", "}", "else", "{", "$", "arrayOfObjects", "=", "[", "]", ";", "$", "repositoryResponse", "=", "[", "]", ";", "}", "$", "resultCount", "=", "$", "this", "->", "getTotalResultCount", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "responseStatus", "=", "ResponseAbstract", "::", "STATUS_FAIL", ";", "$", "this", "->", "response", "->", "setMessages", "(", "[", "'No result was found'", "]", ")", ";", "}", "$", "this", "->", "response", "->", "setStatus", "(", "$", "responseStatus", ")", ";", "$", "this", "->", "response", "->", "setResult", "(", "$", "arrayOfObjects", ")", ";", "$", "this", "->", "response", "->", "setSourceResponse", "(", "$", "repositoryResponse", ")", ";", "$", "this", "->", "response", "->", "setTotalResultCount", "(", "$", "resultCount", ")", ";", "}" ]
Execute this use case @return void
[ "Execute", "this", "use", "case" ]
e8729841db66de7de0bdc9ed79ab73fe2bc262c0
https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/UseCase/Definition/BaseAbstract.php#L52-L84
241,127
dms-org/package.content
src/Cms/Definition/ContentPackageDefinition.php
ContentPackageDefinition.module
public function module(string $name, string $icon, callable $definitionCallback) { $definition = new ContentModuleDefinition($name, $icon, $this->config); $definitionCallback($definition); $this->customModules([ $name => function () use ($definition) { return $definition->loadModule( $this->iocContainer->get(IContentGroupRepository::class), $this->iocContainer->get(IAuthSystem::class), $this->iocContainer->get(IClock::class) ); }, ]); }
php
public function module(string $name, string $icon, callable $definitionCallback) { $definition = new ContentModuleDefinition($name, $icon, $this->config); $definitionCallback($definition); $this->customModules([ $name => function () use ($definition) { return $definition->loadModule( $this->iocContainer->get(IContentGroupRepository::class), $this->iocContainer->get(IAuthSystem::class), $this->iocContainer->get(IClock::class) ); }, ]); }
[ "public", "function", "module", "(", "string", "$", "name", ",", "string", "$", "icon", ",", "callable", "$", "definitionCallback", ")", "{", "$", "definition", "=", "new", "ContentModuleDefinition", "(", "$", "name", ",", "$", "icon", ",", "$", "this", "->", "config", ")", ";", "$", "definitionCallback", "(", "$", "definition", ")", ";", "$", "this", "->", "customModules", "(", "[", "$", "name", "=>", "function", "(", ")", "use", "(", "$", "definition", ")", "{", "return", "$", "definition", "->", "loadModule", "(", "$", "this", "->", "iocContainer", "->", "get", "(", "IContentGroupRepository", "::", "class", ")", ",", "$", "this", "->", "iocContainer", "->", "get", "(", "IAuthSystem", "::", "class", ")", ",", "$", "this", "->", "iocContainer", "->", "get", "(", "IClock", "::", "class", ")", ")", ";", "}", ",", "]", ")", ";", "}" ]
Defines a module within the content package. Example: <code> $content->module('pages', 'file-text', function (ContentModuleDefinition $content) { $content->group('template', 'Template') ->withImage('banner', 'Banner') ->withHtml('header', 'Header') ->withHtml('footer', 'Footer'); $content->page('home', 'Home') ->url(route('home')) ->withHtml('info', 'Info', '#info') ->withImage('banner', 'Banner') ->withMetadata('extra', 'Some Extra Metadata'); }); $content->module('emails', 'envelope', function (ContentModuleDefinition $content) { $content->email('home', 'Home') ->withHtml('info', 'Info'); }); </code> @param string $name @param string $icon @param callable $definitionCallback @throws InvalidOperationException
[ "Defines", "a", "module", "within", "the", "content", "package", "." ]
6511e805c5be586c1f3740e095b49adabd621f80
https://github.com/dms-org/package.content/blob/6511e805c5be586c1f3740e095b49adabd621f80/src/Cms/Definition/ContentPackageDefinition.php#L84-L98
241,128
bugotech/support
src/Num.php
Num.value
public static function value($str, $round = false) { if (is_string($str)) { $str = strtr($str, '.', ''); $str = strtr($str, ',', '.'); } $val = floatval($str); if ($round !== false) { $val = round($val, intval($round)); } return $val; }
php
public static function value($str, $round = false) { if (is_string($str)) { $str = strtr($str, '.', ''); $str = strtr($str, ',', '.'); } $val = floatval($str); if ($round !== false) { $val = round($val, intval($round)); } return $val; }
[ "public", "static", "function", "value", "(", "$", "str", ",", "$", "round", "=", "false", ")", "{", "if", "(", "is_string", "(", "$", "str", ")", ")", "{", "$", "str", "=", "strtr", "(", "$", "str", ",", "'.'", ",", "''", ")", ";", "$", "str", "=", "strtr", "(", "$", "str", ",", "','", ",", "'.'", ")", ";", "}", "$", "val", "=", "floatval", "(", "$", "str", ")", ";", "if", "(", "$", "round", "!==", "false", ")", "{", "$", "val", "=", "round", "(", "$", "val", ",", "intval", "(", "$", "round", ")", ")", ";", "}", "return", "$", "val", ";", "}" ]
Converte string em float. @param $str @param bool|int $round @return float
[ "Converte", "string", "em", "float", "." ]
8938b8c83bdc414ea46bd6e41d1911282782be6c
https://github.com/bugotech/support/blob/8938b8c83bdc414ea46bd6e41d1911282782be6c/src/Num.php#L60-L74
241,129
BuildrPHP/Test-Tools
src/DataSetLoader/XML/StaticType/SimpleXMLNodeTypedAttributeGetter.php
SimpleXMLNodeTypedAttributeGetter.getValue
public function getValue() { $type = (string) $this->element->attributes()->type; $type = (empty($type)) ? 'string' : $type; $value = (string) $this->element->attributes()->value; $casterClassName = $this->resolveCasterClassName($type); /** @type \BuildR\TestTools\Caster\CasterInterface $casterObject */ $casterObject = new $casterClassName($value); return $casterObject->cast(); }
php
public function getValue() { $type = (string) $this->element->attributes()->type; $type = (empty($type)) ? 'string' : $type; $value = (string) $this->element->attributes()->value; $casterClassName = $this->resolveCasterClassName($type); /** @type \BuildR\TestTools\Caster\CasterInterface $casterObject */ $casterObject = new $casterClassName($value); return $casterObject->cast(); }
[ "public", "function", "getValue", "(", ")", "{", "$", "type", "=", "(", "string", ")", "$", "this", "->", "element", "->", "attributes", "(", ")", "->", "type", ";", "$", "type", "=", "(", "empty", "(", "$", "type", ")", ")", "?", "'string'", ":", "$", "type", ";", "$", "value", "=", "(", "string", ")", "$", "this", "->", "element", "->", "attributes", "(", ")", "->", "value", ";", "$", "casterClassName", "=", "$", "this", "->", "resolveCasterClassName", "(", "$", "type", ")", ";", "/** @type \\BuildR\\TestTools\\Caster\\CasterInterface $casterObject */", "$", "casterObject", "=", "new", "$", "casterClassName", "(", "$", "value", ")", ";", "return", "$", "casterObject", "->", "cast", "(", ")", ";", "}" ]
Post-processing the node value by additionally specified type declaration. If no type is defined, values returned as string. @return bool|float|int|string
[ "Post", "-", "processing", "the", "node", "value", "by", "additionally", "specified", "type", "declaration", ".", "If", "no", "type", "is", "defined", "values", "returned", "as", "string", "." ]
55978eb4447d6f063cc9b85501349636ca3fa67a
https://github.com/BuildrPHP/Test-Tools/blob/55978eb4447d6f063cc9b85501349636ca3fa67a/src/DataSetLoader/XML/StaticType/SimpleXMLNodeTypedAttributeGetter.php#L62-L72
241,130
BuildrPHP/Test-Tools
src/DataSetLoader/XML/StaticType/SimpleXMLNodeTypedAttributeGetter.php
SimpleXMLNodeTypedAttributeGetter.resolveCasterClassName
private function resolveCasterClassName($type) { foreach($this->casters as $typeNames => $casterClass) { $names = explode('|', $typeNames); if(!in_array($type, $names)) { continue; } return $casterClass; } throw CasterException::unresolvableType($type); }
php
private function resolveCasterClassName($type) { foreach($this->casters as $typeNames => $casterClass) { $names = explode('|', $typeNames); if(!in_array($type, $names)) { continue; } return $casterClass; } throw CasterException::unresolvableType($type); }
[ "private", "function", "resolveCasterClassName", "(", "$", "type", ")", "{", "foreach", "(", "$", "this", "->", "casters", "as", "$", "typeNames", "=>", "$", "casterClass", ")", "{", "$", "names", "=", "explode", "(", "'|'", ",", "$", "typeNames", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "$", "names", ")", ")", "{", "continue", ";", "}", "return", "$", "casterClass", ";", "}", "throw", "CasterException", "::", "unresolvableType", "(", "$", "type", ")", ";", "}" ]
Resolve the correct caster class by defined type @param string $type @return string @throws \BuildR\TestTools\Exception\CasterException
[ "Resolve", "the", "correct", "caster", "class", "by", "defined", "type" ]
55978eb4447d6f063cc9b85501349636ca3fa67a
https://github.com/BuildrPHP/Test-Tools/blob/55978eb4447d6f063cc9b85501349636ca3fa67a/src/DataSetLoader/XML/StaticType/SimpleXMLNodeTypedAttributeGetter.php#L82-L94
241,131
avoo/FrameworkGeneratorBundle
Generator/Template/Form.php
Form.addFormDeclaration
private function addFormDeclaration($formTypeName) { $name = strtolower($this->model); $extension = $matches = preg_split('/(?=[A-Z])/', $this->bundle->getName(), -1, PREG_SPLIT_NO_EMPTY); $bundleName = $this->getBundlePrefix(); array_pop($extension); $path = $this->bundle->getPath() . '/Resources/config/forms.xml'; if (!file_exists($path)) { $this->renderFile('form/ServicesForms.xml.twig', $path, array()); $ref = 'protected $configFiles = array('; $this->dumpFile( $this->bundle->getPath() . '/DependencyInjection/' . implode('', $extension) . 'Extension.php', "\n 'forms',", $ref );die; } $this->addService($path, $bundleName, $name, $formTypeName); $this->addParameter($path, $bundleName, $name); }
php
private function addFormDeclaration($formTypeName) { $name = strtolower($this->model); $extension = $matches = preg_split('/(?=[A-Z])/', $this->bundle->getName(), -1, PREG_SPLIT_NO_EMPTY); $bundleName = $this->getBundlePrefix(); array_pop($extension); $path = $this->bundle->getPath() . '/Resources/config/forms.xml'; if (!file_exists($path)) { $this->renderFile('form/ServicesForms.xml.twig', $path, array()); $ref = 'protected $configFiles = array('; $this->dumpFile( $this->bundle->getPath() . '/DependencyInjection/' . implode('', $extension) . 'Extension.php', "\n 'forms',", $ref );die; } $this->addService($path, $bundleName, $name, $formTypeName); $this->addParameter($path, $bundleName, $name); }
[ "private", "function", "addFormDeclaration", "(", "$", "formTypeName", ")", "{", "$", "name", "=", "strtolower", "(", "$", "this", "->", "model", ")", ";", "$", "extension", "=", "$", "matches", "=", "preg_split", "(", "'/(?=[A-Z])/'", ",", "$", "this", "->", "bundle", "->", "getName", "(", ")", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "bundleName", "=", "$", "this", "->", "getBundlePrefix", "(", ")", ";", "array_pop", "(", "$", "extension", ")", ";", "$", "path", "=", "$", "this", "->", "bundle", "->", "getPath", "(", ")", ".", "'/Resources/config/forms.xml'", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "$", "this", "->", "renderFile", "(", "'form/ServicesForms.xml.twig'", ",", "$", "path", ",", "array", "(", ")", ")", ";", "$", "ref", "=", "'protected $configFiles = array('", ";", "$", "this", "->", "dumpFile", "(", "$", "this", "->", "bundle", "->", "getPath", "(", ")", ".", "'/DependencyInjection/'", ".", "implode", "(", "''", ",", "$", "extension", ")", ".", "'Extension.php'", ",", "\"\\n 'forms',\"", ",", "$", "ref", ")", ";", "die", ";", "}", "$", "this", "->", "addService", "(", "$", "path", ",", "$", "bundleName", ",", "$", "name", ",", "$", "formTypeName", ")", ";", "$", "this", "->", "addParameter", "(", "$", "path", ",", "$", "bundleName", ",", "$", "name", ")", ";", "}" ]
Add service form declaration @param string $formTypeName
[ "Add", "service", "form", "declaration" ]
3178268b9e58e6c60c27e0b9ea976944c1f61a48
https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Form.php#L121-L142
241,132
avoo/FrameworkGeneratorBundle
Generator/Template/Form.php
Form.addService
private function addService($path, $bundleName, $name, $formTypeName) { $ref = '<services>'; $replaceBefore = true; $group = $bundleName . '_' . $name; $declaration = <<<EOF <service id="$bundleName.form.type.$name" class="%$bundleName.form.type.$name.class%"> <argument>%$bundleName.model.$name.class%</argument> <argument type="collection"> <argument>$group</argument> </argument> <tag name="form.type" alias="$formTypeName" /> </service> EOF; if ($this->refExist($path, $declaration)) { return; } if (!$this->refExist($path, $ref)) { $ref = '</container>'; $replaceBefore = false; $declaration = <<<EOF <services> $declaration </services> EOF; } $this->dumpFile($path, "\n" . $declaration . "\n", $ref, $replaceBefore); }
php
private function addService($path, $bundleName, $name, $formTypeName) { $ref = '<services>'; $replaceBefore = true; $group = $bundleName . '_' . $name; $declaration = <<<EOF <service id="$bundleName.form.type.$name" class="%$bundleName.form.type.$name.class%"> <argument>%$bundleName.model.$name.class%</argument> <argument type="collection"> <argument>$group</argument> </argument> <tag name="form.type" alias="$formTypeName" /> </service> EOF; if ($this->refExist($path, $declaration)) { return; } if (!$this->refExist($path, $ref)) { $ref = '</container>'; $replaceBefore = false; $declaration = <<<EOF <services> $declaration </services> EOF; } $this->dumpFile($path, "\n" . $declaration . "\n", $ref, $replaceBefore); }
[ "private", "function", "addService", "(", "$", "path", ",", "$", "bundleName", ",", "$", "name", ",", "$", "formTypeName", ")", "{", "$", "ref", "=", "'<services>'", ";", "$", "replaceBefore", "=", "true", ";", "$", "group", "=", "$", "bundleName", ".", "'_'", ".", "$", "name", ";", "$", "declaration", "=", " <<<EOF\n <service id=\"$bundleName.form.type.$name\" class=\"%$bundleName.form.type.$name.class%\">\n <argument>%$bundleName.model.$name.class%</argument>\n <argument type=\"collection\">\n <argument>$group</argument>\n </argument>\n <tag name=\"form.type\" alias=\"$formTypeName\" />\n </service>\nEOF", ";", "if", "(", "$", "this", "->", "refExist", "(", "$", "path", ",", "$", "declaration", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "refExist", "(", "$", "path", ",", "$", "ref", ")", ")", "{", "$", "ref", "=", "'</container>'", ";", "$", "replaceBefore", "=", "false", ";", "$", "declaration", "=", " <<<EOF\n <services>\n$declaration\n </services>\nEOF", ";", "}", "$", "this", "->", "dumpFile", "(", "$", "path", ",", "\"\\n\"", ".", "$", "declaration", ".", "\"\\n\"", ",", "$", "ref", ",", "$", "replaceBefore", ")", ";", "}" ]
Add service node @param string $path @param string $bundleName @param string $name @param string $formTypeName
[ "Add", "service", "node" ]
3178268b9e58e6c60c27e0b9ea976944c1f61a48
https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Form.php#L196-L227
241,133
avoo/FrameworkGeneratorBundle
Generator/Template/Form.php
Form.addParameter
private function addParameter($path, $bundleName, $name) { $formPath = $this->configuration['namespace'] . '\\' . $this->model . 'Type'; $ref = '<parameters>'; $replaceBefore = true; $declaration = <<<EOF <parameter key="$bundleName.form.type.$name.class">$formPath</parameter> EOF; if ($this->refExist($path, $declaration)) { return; } if (!$this->refExist($path, $ref)) { $ref = ' <services>'; $replaceBefore = false; $declaration = <<<EOF <parameters> $declaration </parameters> EOF; } $this->dumpFile($path, "\n" . $declaration, $ref, $replaceBefore); }
php
private function addParameter($path, $bundleName, $name) { $formPath = $this->configuration['namespace'] . '\\' . $this->model . 'Type'; $ref = '<parameters>'; $replaceBefore = true; $declaration = <<<EOF <parameter key="$bundleName.form.type.$name.class">$formPath</parameter> EOF; if ($this->refExist($path, $declaration)) { return; } if (!$this->refExist($path, $ref)) { $ref = ' <services>'; $replaceBefore = false; $declaration = <<<EOF <parameters> $declaration </parameters> EOF; } $this->dumpFile($path, "\n" . $declaration, $ref, $replaceBefore); }
[ "private", "function", "addParameter", "(", "$", "path", ",", "$", "bundleName", ",", "$", "name", ")", "{", "$", "formPath", "=", "$", "this", "->", "configuration", "[", "'namespace'", "]", ".", "'\\\\'", ".", "$", "this", "->", "model", ".", "'Type'", ";", "$", "ref", "=", "'<parameters>'", ";", "$", "replaceBefore", "=", "true", ";", "$", "declaration", "=", " <<<EOF\n <parameter key=\"$bundleName.form.type.$name.class\">$formPath</parameter>\nEOF", ";", "if", "(", "$", "this", "->", "refExist", "(", "$", "path", ",", "$", "declaration", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "refExist", "(", "$", "path", ",", "$", "ref", ")", ")", "{", "$", "ref", "=", "' <services>'", ";", "$", "replaceBefore", "=", "false", ";", "$", "declaration", "=", " <<<EOF\n <parameters>\n$declaration\n </parameters>\n\nEOF", ";", "}", "$", "this", "->", "dumpFile", "(", "$", "path", ",", "\"\\n\"", ".", "$", "declaration", ",", "$", "ref", ",", "$", "replaceBefore", ")", ";", "}" ]
Add parameter node @param string $path @param string $bundleName @param string $name
[ "Add", "parameter", "node" ]
3178268b9e58e6c60c27e0b9ea976944c1f61a48
https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Form.php#L236-L262
241,134
novuso/novusopress
core/CommentWalker.php
CommentWalker.start_lvl
public function start_lvl(&$output, $depth = 0, $args = []) { $GLOBALS['comment_depth'] = $depth + 1; switch ($args['style']) { case 'div': break; case 'ol': $output .= '<ol class="children list-unstyled">'.PHP_EOL; break; case 'ul': default: $output .= '<ul class="children list-unstyled">'.PHP_EOL; break; } }
php
public function start_lvl(&$output, $depth = 0, $args = []) { $GLOBALS['comment_depth'] = $depth + 1; switch ($args['style']) { case 'div': break; case 'ol': $output .= '<ol class="children list-unstyled">'.PHP_EOL; break; case 'ul': default: $output .= '<ul class="children list-unstyled">'.PHP_EOL; break; } }
[ "public", "function", "start_lvl", "(", "&", "$", "output", ",", "$", "depth", "=", "0", ",", "$", "args", "=", "[", "]", ")", "{", "$", "GLOBALS", "[", "'comment_depth'", "]", "=", "$", "depth", "+", "1", ";", "switch", "(", "$", "args", "[", "'style'", "]", ")", "{", "case", "'div'", ":", "break", ";", "case", "'ol'", ":", "$", "output", ".=", "'<ol class=\"children list-unstyled\">'", ".", "PHP_EOL", ";", "break", ";", "case", "'ul'", ":", "default", ":", "$", "output", ".=", "'<ul class=\"children list-unstyled\">'", ".", "PHP_EOL", ";", "break", ";", "}", "}" ]
Start the list before the elements are added. @param string $output Passed by reference; used to append additional content @param integer $depth Depth of comment @param array $args Uses 'style' argument for type of HTML list
[ "Start", "the", "list", "before", "the", "elements", "are", "added", "." ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/CommentWalker.php#L24-L39
241,135
novuso/novusopress
core/CommentWalker.php
CommentWalker.end_lvl
public function end_lvl(&$output, $depth = 0, $args = []) { $tab = ' '; $indent = ($depth == 1) ? 8 + $depth : 7 + ($depth * 2); switch ($args['style']) { case 'div': break; case 'ol': case 'ul': default: $output .= str_repeat($tab, $indent); break; } parent::end_lvl($output, $depth, $args); }
php
public function end_lvl(&$output, $depth = 0, $args = []) { $tab = ' '; $indent = ($depth == 1) ? 8 + $depth : 7 + ($depth * 2); switch ($args['style']) { case 'div': break; case 'ol': case 'ul': default: $output .= str_repeat($tab, $indent); break; } parent::end_lvl($output, $depth, $args); }
[ "public", "function", "end_lvl", "(", "&", "$", "output", ",", "$", "depth", "=", "0", ",", "$", "args", "=", "[", "]", ")", "{", "$", "tab", "=", "' '", ";", "$", "indent", "=", "(", "$", "depth", "==", "1", ")", "?", "8", "+", "$", "depth", ":", "7", "+", "(", "$", "depth", "*", "2", ")", ";", "switch", "(", "$", "args", "[", "'style'", "]", ")", "{", "case", "'div'", ":", "break", ";", "case", "'ol'", ":", "case", "'ul'", ":", "default", ":", "$", "output", ".=", "str_repeat", "(", "$", "tab", ",", "$", "indent", ")", ";", "break", ";", "}", "parent", "::", "end_lvl", "(", "$", "output", ",", "$", "depth", ",", "$", "args", ")", ";", "}" ]
End the list of items after the elements are added. @param string $output Passed by reference; used to append additional content @param integer $depth Depth of comment @param array $args Will only append content if style argument value is 'ol' or 'ul'
[ "End", "the", "list", "of", "items", "after", "the", "elements", "are", "added", "." ]
e31a46b0afa4126788f5754f928552ce13f8531f
https://github.com/novuso/novusopress/blob/e31a46b0afa4126788f5754f928552ce13f8531f/core/CommentWalker.php#L48-L64
241,136
stubbles/stubbles-sequence
src/main/php/iterator/Generator.php
Generator.next
public function next() { $operation = $this->operation; $this->value = $operation($this->value); $this->elementsGenerated++; }
php
public function next() { $operation = $this->operation; $this->value = $operation($this->value); $this->elementsGenerated++; }
[ "public", "function", "next", "(", ")", "{", "$", "operation", "=", "$", "this", "->", "operation", ";", "$", "this", "->", "value", "=", "$", "operation", "(", "$", "this", "->", "value", ")", ";", "$", "this", "->", "elementsGenerated", "++", ";", "}" ]
generates next value
[ "generates", "next", "value" ]
258d2247f1cdd826818348fe15829d5a98a9de70
https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/iterator/Generator.php#L101-L106
241,137
xloit/xloit-exception
src/Exception.php
Exception.create
public static function create($message, $messageVariables = null, $code = null, PhpException $previous = null) { $messageFormat = [ 'message' => $message, 'messageVariables' => $messageVariables ]; return new static($messageFormat, $code, $previous); }
php
public static function create($message, $messageVariables = null, $code = null, PhpException $previous = null) { $messageFormat = [ 'message' => $message, 'messageVariables' => $messageVariables ]; return new static($messageFormat, $code, $previous); }
[ "public", "static", "function", "create", "(", "$", "message", ",", "$", "messageVariables", "=", "null", ",", "$", "code", "=", "null", ",", "PhpException", "$", "previous", "=", "null", ")", "{", "$", "messageFormat", "=", "[", "'message'", "=>", "$", "message", ",", "'messageVariables'", "=>", "$", "messageVariables", "]", ";", "return", "new", "static", "(", "$", "messageFormat", ",", "$", "code", ",", "$", "previous", ")", ";", "}" ]
Creates a new exception by the given arguments. @param string $message The message format. @param array $messageVariables The message variables. @param int|string $code The code of this exception. @param PhpException $previous The previous exception. @return Exception The new exception. @throws InvalidArgumentException
[ "Creates", "a", "new", "exception", "by", "the", "given", "arguments", "." ]
ba7cc942a9263c570b9b2325f93c75fb2e774714
https://github.com/xloit/xloit-exception/blob/ba7cc942a9263c570b9b2325f93c75fb2e774714/src/Exception.php#L141-L149
241,138
xloit/xloit-exception
src/Exception.php
Exception.setCode
public function setCode($code) { if (!is_scalar($code)) { throw new InvalidArgumentException( sprintf( 'Wrong parameters for %s([int|string $code]); %s given.', __METHOD__, is_object($code) ? get_class($code) : gettype($code) ), E_ERROR ); } $this->code = $code; return $this; }
php
public function setCode($code) { if (!is_scalar($code)) { throw new InvalidArgumentException( sprintf( 'Wrong parameters for %s([int|string $code]); %s given.', __METHOD__, is_object($code) ? get_class($code) : gettype($code) ), E_ERROR ); } $this->code = $code; return $this; }
[ "public", "function", "setCode", "(", "$", "code", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "code", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Wrong parameters for %s([int|string $code]); %s given.'", ",", "__METHOD__", ",", "is_object", "(", "$", "code", ")", "?", "get_class", "(", "$", "code", ")", ":", "gettype", "(", "$", "code", ")", ")", ",", "E_ERROR", ")", ";", "}", "$", "this", "->", "code", "=", "$", "code", ";", "return", "$", "this", ";", "}" ]
Sets the Exception code. @param int|string $code @return static @throws InvalidArgumentException
[ "Sets", "the", "Exception", "code", "." ]
ba7cc942a9263c570b9b2325f93c75fb2e774714
https://github.com/xloit/xloit-exception/blob/ba7cc942a9263c570b9b2325f93c75fb2e774714/src/Exception.php#L227-L243
241,139
xloit/xloit-exception
src/Exception.php
Exception.setMessage
public function setMessage($message) { $messageVariables = null; if (is_array($message)) { if (array_key_exists('messageVariables', $message)) { $messageVariables = $message['messageVariables']; } if (array_key_exists('message', $message)) { $message = $message['message']; } else { $messageVariables = $message; $message = $this->messageTemplate; } } if (!is_string($message)) { throw new InvalidArgumentException( sprintf( 'Wrong parameters for %s([array|string $message]); %s given.', __METHOD__, is_object($message) ? get_class($message) : gettype($message) ), E_ERROR ); } $this->message = $this->createMessage($message, $messageVariables); return $this; }
php
public function setMessage($message) { $messageVariables = null; if (is_array($message)) { if (array_key_exists('messageVariables', $message)) { $messageVariables = $message['messageVariables']; } if (array_key_exists('message', $message)) { $message = $message['message']; } else { $messageVariables = $message; $message = $this->messageTemplate; } } if (!is_string($message)) { throw new InvalidArgumentException( sprintf( 'Wrong parameters for %s([array|string $message]); %s given.', __METHOD__, is_object($message) ? get_class($message) : gettype($message) ), E_ERROR ); } $this->message = $this->createMessage($message, $messageVariables); return $this; }
[ "public", "function", "setMessage", "(", "$", "message", ")", "{", "$", "messageVariables", "=", "null", ";", "if", "(", "is_array", "(", "$", "message", ")", ")", "{", "if", "(", "array_key_exists", "(", "'messageVariables'", ",", "$", "message", ")", ")", "{", "$", "messageVariables", "=", "$", "message", "[", "'messageVariables'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'message'", ",", "$", "message", ")", ")", "{", "$", "message", "=", "$", "message", "[", "'message'", "]", ";", "}", "else", "{", "$", "messageVariables", "=", "$", "message", ";", "$", "message", "=", "$", "this", "->", "messageTemplate", ";", "}", "}", "if", "(", "!", "is_string", "(", "$", "message", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Wrong parameters for %s([array|string $message]); %s given.'", ",", "__METHOD__", ",", "is_object", "(", "$", "message", ")", "?", "get_class", "(", "$", "message", ")", ":", "gettype", "(", "$", "message", ")", ")", ",", "E_ERROR", ")", ";", "}", "$", "this", "->", "message", "=", "$", "this", "->", "createMessage", "(", "$", "message", ",", "$", "messageVariables", ")", ";", "return", "$", "this", ";", "}" ]
Sets the Exception generated message. @param array|string $message @return static @throws InvalidArgumentException
[ "Sets", "the", "Exception", "generated", "message", "." ]
ba7cc942a9263c570b9b2325f93c75fb2e774714
https://github.com/xloit/xloit-exception/blob/ba7cc942a9263c570b9b2325f93c75fb2e774714/src/Exception.php#L253-L284
241,140
xloit/xloit-exception
src/Exception.php
Exception.createMessage
protected function createMessage($message, $variables = null) { if (null !== $variables && is_array($variables)) { $variables = array_merge($this->getMessageVariables(), $variables); } else { $variables = $this->getMessageVariables(); } foreach ($variables as $variableKey => $variable) { if (is_array($variable) || ($variable instanceof Traversable)) { $variable = implode(', ', array_values($variable)); } if (!is_scalar($variable)) { $variable = $this->switchType($variable); } $message = str_replace("%$variableKey%", (string) $variable, $message); } return $message; }
php
protected function createMessage($message, $variables = null) { if (null !== $variables && is_array($variables)) { $variables = array_merge($this->getMessageVariables(), $variables); } else { $variables = $this->getMessageVariables(); } foreach ($variables as $variableKey => $variable) { if (is_array($variable) || ($variable instanceof Traversable)) { $variable = implode(', ', array_values($variable)); } if (!is_scalar($variable)) { $variable = $this->switchType($variable); } $message = str_replace("%$variableKey%", (string) $variable, $message); } return $message; }
[ "protected", "function", "createMessage", "(", "$", "message", ",", "$", "variables", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "variables", "&&", "is_array", "(", "$", "variables", ")", ")", "{", "$", "variables", "=", "array_merge", "(", "$", "this", "->", "getMessageVariables", "(", ")", ",", "$", "variables", ")", ";", "}", "else", "{", "$", "variables", "=", "$", "this", "->", "getMessageVariables", "(", ")", ";", "}", "foreach", "(", "$", "variables", "as", "$", "variableKey", "=>", "$", "variable", ")", "{", "if", "(", "is_array", "(", "$", "variable", ")", "||", "(", "$", "variable", "instanceof", "Traversable", ")", ")", "{", "$", "variable", "=", "implode", "(", "', '", ",", "array_values", "(", "$", "variable", ")", ")", ";", "}", "if", "(", "!", "is_scalar", "(", "$", "variable", ")", ")", "{", "$", "variable", "=", "$", "this", "->", "switchType", "(", "$", "variable", ")", ";", "}", "$", "message", "=", "str_replace", "(", "\"%$variableKey%\"", ",", "(", "string", ")", "$", "variable", ",", "$", "message", ")", ";", "}", "return", "$", "message", ";", "}" ]
Constructs and returns a exception message with the given message key and value. Returns null if and only if the given key does not correspond to an existing template. @param string $message @param array $variables @return string
[ "Constructs", "and", "returns", "a", "exception", "message", "with", "the", "given", "message", "key", "and", "value", ".", "Returns", "null", "if", "and", "only", "if", "the", "given", "key", "does", "not", "correspond", "to", "an", "existing", "template", "." ]
ba7cc942a9263c570b9b2325f93c75fb2e774714
https://github.com/xloit/xloit-exception/blob/ba7cc942a9263c570b9b2325f93c75fb2e774714/src/Exception.php#L322-L343
241,141
xloit/xloit-exception
src/Exception.php
Exception.getCauseMessage
public function getCauseMessage() { $causes = []; $current = [ 'class' => get_class($this), 'message' => $this->getMessage(), 'code' => $this->getCode(), 'file' => $this->getFile(), 'line' => $this->getLine() ]; $causes[] = $current; $previous = $this->getPrevious(); while ($previous !== null) { if ($previous instanceof Exception) { $prevCauses = $previous->getCauseMessage(); foreach ($prevCauses as $cause) { $causes[] = $cause; } } elseif ($previous instanceof PhpException) { $causes[] = [ 'class' => get_class($previous), 'message' => $previous->getMessage(), 'code' => $previous->getCode(), 'file' => $previous->getFile(), 'line' => $previous->getLine() ]; } $previous = $previous->getPrevious(); } return $causes; }
php
public function getCauseMessage() { $causes = []; $current = [ 'class' => get_class($this), 'message' => $this->getMessage(), 'code' => $this->getCode(), 'file' => $this->getFile(), 'line' => $this->getLine() ]; $causes[] = $current; $previous = $this->getPrevious(); while ($previous !== null) { if ($previous instanceof Exception) { $prevCauses = $previous->getCauseMessage(); foreach ($prevCauses as $cause) { $causes[] = $cause; } } elseif ($previous instanceof PhpException) { $causes[] = [ 'class' => get_class($previous), 'message' => $previous->getMessage(), 'code' => $previous->getCode(), 'file' => $previous->getFile(), 'line' => $previous->getLine() ]; } $previous = $previous->getPrevious(); } return $causes; }
[ "public", "function", "getCauseMessage", "(", ")", "{", "$", "causes", "=", "[", "]", ";", "$", "current", "=", "[", "'class'", "=>", "get_class", "(", "$", "this", ")", ",", "'message'", "=>", "$", "this", "->", "getMessage", "(", ")", ",", "'code'", "=>", "$", "this", "->", "getCode", "(", ")", ",", "'file'", "=>", "$", "this", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "this", "->", "getLine", "(", ")", "]", ";", "$", "causes", "[", "]", "=", "$", "current", ";", "$", "previous", "=", "$", "this", "->", "getPrevious", "(", ")", ";", "while", "(", "$", "previous", "!==", "null", ")", "{", "if", "(", "$", "previous", "instanceof", "Exception", ")", "{", "$", "prevCauses", "=", "$", "previous", "->", "getCauseMessage", "(", ")", ";", "foreach", "(", "$", "prevCauses", "as", "$", "cause", ")", "{", "$", "causes", "[", "]", "=", "$", "cause", ";", "}", "}", "elseif", "(", "$", "previous", "instanceof", "PhpException", ")", "{", "$", "causes", "[", "]", "=", "[", "'class'", "=>", "get_class", "(", "$", "previous", ")", ",", "'message'", "=>", "$", "previous", "->", "getMessage", "(", ")", ",", "'code'", "=>", "$", "previous", "->", "getCode", "(", ")", ",", "'file'", "=>", "$", "previous", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "previous", "->", "getLine", "(", ")", "]", ";", "}", "$", "previous", "=", "$", "previous", "->", "getPrevious", "(", ")", ";", "}", "return", "$", "causes", ";", "}" ]
Get the message of caused exceptions. @return array
[ "Get", "the", "message", "of", "caused", "exceptions", "." ]
ba7cc942a9263c570b9b2325f93c75fb2e774714
https://github.com/xloit/xloit-exception/blob/ba7cc942a9263c570b9b2325f93c75fb2e774714/src/Exception.php#L350-L385
241,142
xloit/xloit-exception
src/Exception.php
Exception.getTraceSaveAsString
public function getTraceSaveAsString() { $traces = $this->getTrace(); $messages = ['STACK TRACE DETAILS : ']; foreach ($traces as $index => $trace) { $message = sprintf('#%d ', $index + 1); /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['file'])) { if (!is_string($trace['file'])) { $message .= '[Unknown Function]: '; } else { $line = 0; /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['line']) && is_int($trace['line'])) { $line = $trace['line']; } $message .= sprintf('%s(%d): ', $trace['file'], $line); } } else { $message .= '[Internal Function]: '; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['class']) && is_string($trace['class'])) { $message .= $trace['class'] . ' '; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['type']) && is_string($trace['type'])) { $message .= $trace['type'] . ' '; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['function']) && is_string($trace['function'])) { $message .= $trace['function'] . '('; /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['args']) && count($trace['args']) > 0) { /** @var array $arguments */ $arguments = $trace['args']; $argVariables = []; foreach ($arguments as $argument) { $argVariables[] = $this->switchType($argument); } $message .= implode(', ', $argVariables); } $message .= ')'; } $messages[] = trim($message); } return implode("\n", $messages); }
php
public function getTraceSaveAsString() { $traces = $this->getTrace(); $messages = ['STACK TRACE DETAILS : ']; foreach ($traces as $index => $trace) { $message = sprintf('#%d ', $index + 1); /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['file'])) { if (!is_string($trace['file'])) { $message .= '[Unknown Function]: '; } else { $line = 0; /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['line']) && is_int($trace['line'])) { $line = $trace['line']; } $message .= sprintf('%s(%d): ', $trace['file'], $line); } } else { $message .= '[Internal Function]: '; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['class']) && is_string($trace['class'])) { $message .= $trace['class'] . ' '; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['type']) && is_string($trace['type'])) { $message .= $trace['type'] . ' '; } /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['function']) && is_string($trace['function'])) { $message .= $trace['function'] . '('; /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($trace['args']) && count($trace['args']) > 0) { /** @var array $arguments */ $arguments = $trace['args']; $argVariables = []; foreach ($arguments as $argument) { $argVariables[] = $this->switchType($argument); } $message .= implode(', ', $argVariables); } $message .= ')'; } $messages[] = trim($message); } return implode("\n", $messages); }
[ "public", "function", "getTraceSaveAsString", "(", ")", "{", "$", "traces", "=", "$", "this", "->", "getTrace", "(", ")", ";", "$", "messages", "=", "[", "'STACK TRACE DETAILS : '", "]", ";", "foreach", "(", "$", "traces", "as", "$", "index", "=>", "$", "trace", ")", "{", "$", "message", "=", "sprintf", "(", "'#%d '", ",", "$", "index", "+", "1", ")", ";", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "trace", "[", "'file'", "]", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "trace", "[", "'file'", "]", ")", ")", "{", "$", "message", ".=", "'[Unknown Function]: '", ";", "}", "else", "{", "$", "line", "=", "0", ";", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "trace", "[", "'line'", "]", ")", "&&", "is_int", "(", "$", "trace", "[", "'line'", "]", ")", ")", "{", "$", "line", "=", "$", "trace", "[", "'line'", "]", ";", "}", "$", "message", ".=", "sprintf", "(", "'%s(%d): '", ",", "$", "trace", "[", "'file'", "]", ",", "$", "line", ")", ";", "}", "}", "else", "{", "$", "message", ".=", "'[Internal Function]: '", ";", "}", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "trace", "[", "'class'", "]", ")", "&&", "is_string", "(", "$", "trace", "[", "'class'", "]", ")", ")", "{", "$", "message", ".=", "$", "trace", "[", "'class'", "]", ".", "' '", ";", "}", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "trace", "[", "'type'", "]", ")", "&&", "is_string", "(", "$", "trace", "[", "'type'", "]", ")", ")", "{", "$", "message", ".=", "$", "trace", "[", "'type'", "]", ".", "' '", ";", "}", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "trace", "[", "'function'", "]", ")", "&&", "is_string", "(", "$", "trace", "[", "'function'", "]", ")", ")", "{", "$", "message", ".=", "$", "trace", "[", "'function'", "]", ".", "'('", ";", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "trace", "[", "'args'", "]", ")", "&&", "count", "(", "$", "trace", "[", "'args'", "]", ")", ">", "0", ")", "{", "/** @var array $arguments */", "$", "arguments", "=", "$", "trace", "[", "'args'", "]", ";", "$", "argVariables", "=", "[", "]", ";", "foreach", "(", "$", "arguments", "as", "$", "argument", ")", "{", "$", "argVariables", "[", "]", "=", "$", "this", "->", "switchType", "(", "$", "argument", ")", ";", "}", "$", "message", ".=", "implode", "(", "', '", ",", "$", "argVariables", ")", ";", "}", "$", "message", ".=", "')'", ";", "}", "$", "messages", "[", "]", "=", "trim", "(", "$", "message", ")", ";", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "messages", ")", ";", "}" ]
Gets the stack trace as a string. @link http://php.net/manual/en/exception.gettraceasstring.php @return string
[ "Gets", "the", "stack", "trace", "as", "a", "string", "." ]
ba7cc942a9263c570b9b2325f93c75fb2e774714
https://github.com/xloit/xloit-exception/blob/ba7cc942a9263c570b9b2325f93c75fb2e774714/src/Exception.php#L394-L454
241,143
xloit/xloit-exception
src/Exception.php
Exception.switchType
protected function switchType($argument) { $stringType = null; $type = strtolower(gettype($argument)); switch ($type) { case 'boolean': $stringType = sprintf( '[%s "%s"]', ucwords($type), ((int) $argument === 1) ? 'True' : 'False' ); break; case 'integer': case 'double': case 'float': case 'string': $stringType = sprintf('[%s "%s"]', ucwords($type), $argument); break; case 'array': $stringType = sprintf( '[%s {value: %s}]', ucwords($type), var_export($argument, true) ); break; case 'object': $stringType = sprintf('[%s "%s"]', ucwords($type), get_class($argument)); break; case 'resource': $stringType = sprintf('[%s]', ucwords($type)); break; case 'null': $stringType = '[NULL]'; break; default; $stringType = '[Unknown Type]'; break; } return $stringType; }
php
protected function switchType($argument) { $stringType = null; $type = strtolower(gettype($argument)); switch ($type) { case 'boolean': $stringType = sprintf( '[%s "%s"]', ucwords($type), ((int) $argument === 1) ? 'True' : 'False' ); break; case 'integer': case 'double': case 'float': case 'string': $stringType = sprintf('[%s "%s"]', ucwords($type), $argument); break; case 'array': $stringType = sprintf( '[%s {value: %s}]', ucwords($type), var_export($argument, true) ); break; case 'object': $stringType = sprintf('[%s "%s"]', ucwords($type), get_class($argument)); break; case 'resource': $stringType = sprintf('[%s]', ucwords($type)); break; case 'null': $stringType = '[NULL]'; break; default; $stringType = '[Unknown Type]'; break; } return $stringType; }
[ "protected", "function", "switchType", "(", "$", "argument", ")", "{", "$", "stringType", "=", "null", ";", "$", "type", "=", "strtolower", "(", "gettype", "(", "$", "argument", ")", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'boolean'", ":", "$", "stringType", "=", "sprintf", "(", "'[%s \"%s\"]'", ",", "ucwords", "(", "$", "type", ")", ",", "(", "(", "int", ")", "$", "argument", "===", "1", ")", "?", "'True'", ":", "'False'", ")", ";", "break", ";", "case", "'integer'", ":", "case", "'double'", ":", "case", "'float'", ":", "case", "'string'", ":", "$", "stringType", "=", "sprintf", "(", "'[%s \"%s\"]'", ",", "ucwords", "(", "$", "type", ")", ",", "$", "argument", ")", ";", "break", ";", "case", "'array'", ":", "$", "stringType", "=", "sprintf", "(", "'[%s {value: %s}]'", ",", "ucwords", "(", "$", "type", ")", ",", "var_export", "(", "$", "argument", ",", "true", ")", ")", ";", "break", ";", "case", "'object'", ":", "$", "stringType", "=", "sprintf", "(", "'[%s \"%s\"]'", ",", "ucwords", "(", "$", "type", ")", ",", "get_class", "(", "$", "argument", ")", ")", ";", "break", ";", "case", "'resource'", ":", "$", "stringType", "=", "sprintf", "(", "'[%s]'", ",", "ucwords", "(", "$", "type", ")", ")", ";", "break", ";", "case", "'null'", ":", "$", "stringType", "=", "'[NULL]'", ";", "break", ";", "default", ";", "$", "stringType", "=", "'[Unknown Type]'", ";", "break", ";", "}", "return", "$", "stringType", ";", "}" ]
Convert type to string. @param mixed $argument @return string
[ "Convert", "type", "to", "string", "." ]
ba7cc942a9263c570b9b2325f93c75fb2e774714
https://github.com/xloit/xloit-exception/blob/ba7cc942a9263c570b9b2325f93c75fb2e774714/src/Exception.php#L463-L501
241,144
titon/db-mysql
src/Titon/Db/Mysql/MysqlDriver.php
MysqlDriver.initialize
public function initialize() { $this->setDialect(new MysqlDialect($this)); $flags = $this->getConfig('flags'); if ($timezone = $this->getConfig('timezone')) { if ($timezone === 'UTC') { $timezone = '+00:00'; } $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = sprintf('SET time_zone = "%s";', $timezone); } $this->setConfig('flags', $flags); }
php
public function initialize() { $this->setDialect(new MysqlDialect($this)); $flags = $this->getConfig('flags'); if ($timezone = $this->getConfig('timezone')) { if ($timezone === 'UTC') { $timezone = '+00:00'; } $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = sprintf('SET time_zone = "%s";', $timezone); } $this->setConfig('flags', $flags); }
[ "public", "function", "initialize", "(", ")", "{", "$", "this", "->", "setDialect", "(", "new", "MysqlDialect", "(", "$", "this", ")", ")", ";", "$", "flags", "=", "$", "this", "->", "getConfig", "(", "'flags'", ")", ";", "if", "(", "$", "timezone", "=", "$", "this", "->", "getConfig", "(", "'timezone'", ")", ")", "{", "if", "(", "$", "timezone", "===", "'UTC'", ")", "{", "$", "timezone", "=", "'+00:00'", ";", "}", "$", "flags", "[", "PDO", "::", "MYSQL_ATTR_INIT_COMMAND", "]", "=", "sprintf", "(", "'SET time_zone = \"%s\";'", ",", "$", "timezone", ")", ";", "}", "$", "this", "->", "setConfig", "(", "'flags'", ",", "$", "flags", ")", ";", "}" ]
Set the dialect and timezone being used.
[ "Set", "the", "dialect", "and", "timezone", "being", "used", "." ]
0b69db820f907b8cae4093417406a7435fdbf92f
https://github.com/titon/db-mysql/blob/0b69db820f907b8cae4093417406a7435fdbf92f/src/Titon/Db/Mysql/MysqlDriver.php#L34-L48
241,145
sebardo/ecommerce
EcommerceBundle/Controller/ProductController.php
ProductController.listJsonAction
public function listJsonAction() { $em = $this->getDoctrine()->getManager(); $adminManager = $this->get('admin_manager'); /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */ $jsonList = $this->get('json_list'); $jsonList->setRepository($em->getRepository('EcommerceBundle:Product')); $user = $this->container->get('security.token_storage')->getToken()->getUser(); if ($user->isGranted('ROLE_USER')) { $jsonList->setActor($user); } $response = $jsonList->get(); return new JsonResponse($response); }
php
public function listJsonAction() { $em = $this->getDoctrine()->getManager(); $adminManager = $this->get('admin_manager'); /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */ $jsonList = $this->get('json_list'); $jsonList->setRepository($em->getRepository('EcommerceBundle:Product')); $user = $this->container->get('security.token_storage')->getToken()->getUser(); if ($user->isGranted('ROLE_USER')) { $jsonList->setActor($user); } $response = $jsonList->get(); return new JsonResponse($response); }
[ "public", "function", "listJsonAction", "(", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "adminManager", "=", "$", "this", "->", "get", "(", "'admin_manager'", ")", ";", "/** @var \\AdminBundle\\Services\\DataTables\\JsonList $jsonList */", "$", "jsonList", "=", "$", "this", "->", "get", "(", "'json_list'", ")", ";", "$", "jsonList", "->", "setRepository", "(", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Product'", ")", ")", ";", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "->", "isGranted", "(", "'ROLE_USER'", ")", ")", "{", "$", "jsonList", "->", "setActor", "(", "$", "user", ")", ";", "}", "$", "response", "=", "$", "jsonList", "->", "get", "(", ")", ";", "return", "new", "JsonResponse", "(", "$", "response", ")", ";", "}" ]
Returns a list of Product entities in JSON format. @return JsonResponse @Route("/list.{_format}", requirements={ "_format" = "json" }, defaults={ "_format" = "json" }) @Method("GET")
[ "Returns", "a", "list", "of", "Product", "entities", "in", "JSON", "format", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ProductController.php#L51-L66
241,146
sebardo/ecommerce
EcommerceBundle/Controller/ProductController.php
ProductController.statsAction
public function statsAction($id, $from, $to) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('EcommerceBundle:Product')->find($id); /** @var FrontManager $frontManager */ $adminManager = $this->container->get('admin_manager'); $stats = $adminManager->getProductStats($entity, $from, $to); $label = array(); $visits = array(); foreach ($stats as $stat) { $label[] = $stat['day']; $visits[] = $stat['visits']; } $returnValues = new \stdClass(); $returnValues->count = count($stats); $returnValues->labels = implode(',', $label); $returnValues->visits = implode(',', $visits); return new JsonResponse($returnValues); }
php
public function statsAction($id, $from, $to) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('EcommerceBundle:Product')->find($id); /** @var FrontManager $frontManager */ $adminManager = $this->container->get('admin_manager'); $stats = $adminManager->getProductStats($entity, $from, $to); $label = array(); $visits = array(); foreach ($stats as $stat) { $label[] = $stat['day']; $visits[] = $stat['visits']; } $returnValues = new \stdClass(); $returnValues->count = count($stats); $returnValues->labels = implode(',', $label); $returnValues->visits = implode(',', $visits); return new JsonResponse($returnValues); }
[ "public", "function", "statsAction", "(", "$", "id", ",", "$", "from", ",", "$", "to", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Actor $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Product'", ")", "->", "find", "(", "$", "id", ")", ";", "/** @var FrontManager $frontManager */", "$", "adminManager", "=", "$", "this", "->", "container", "->", "get", "(", "'admin_manager'", ")", ";", "$", "stats", "=", "$", "adminManager", "->", "getProductStats", "(", "$", "entity", ",", "$", "from", ",", "$", "to", ")", ";", "$", "label", "=", "array", "(", ")", ";", "$", "visits", "=", "array", "(", ")", ";", "foreach", "(", "$", "stats", "as", "$", "stat", ")", "{", "$", "label", "[", "]", "=", "$", "stat", "[", "'day'", "]", ";", "$", "visits", "[", "]", "=", "$", "stat", "[", "'visits'", "]", ";", "}", "$", "returnValues", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "returnValues", "->", "count", "=", "count", "(", "$", "stats", ")", ";", "$", "returnValues", "->", "labels", "=", "implode", "(", "','", ",", "$", "label", ")", ";", "$", "returnValues", "->", "visits", "=", "implode", "(", "','", ",", "$", "visits", ")", ";", "return", "new", "JsonResponse", "(", "$", "returnValues", ")", ";", "}" ]
Returns a list of Actor entities in JSON format. @return JsonResponse @Route("/stats/{id}/{from}/{to}", requirements={ "_format" = "json" }, defaults={ "_format" = "json" }) @Method("GET")
[ "Returns", "a", "list", "of", "Actor", "entities", "in", "JSON", "format", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ProductController.php#L76-L100
241,147
sebardo/ecommerce
EcommerceBundle/Controller/ProductController.php
ProductController.editAction
public function editAction(Request $request, Product $product) { //access control $user = $this->container->get('security.token_storage')->getToken()->getUser(); if ($user->isGranted('ROLE_USER') && $product->getActor()->getId() != $user->getId()) { return $this->redirect($this->generateUrl('ecommerce_product_index')); } $formConfig = array(); if ($user->isGranted('ROLE_USER')) { $formConfig['actor'] = $user; } $deleteForm = $this->createDeleteForm($product); $editForm = $this->createForm('EcommerceBundle\Form\ProductType', $product, $formConfig); $attributesForm = $this->createForm('EcommerceBundle\Form\ProductAttributesType', $product, array('category' => $product->getCategory()->getId())); $featuresForm = $this->createForm('EcommerceBundle\Form\ProductFeaturesType', $product, array('category' => $product->getCategory()->getId())); $relatedProductsForm = $this->createForm('EcommerceBundle\Form\ProductRelatedType', $product); if($request->getMethod('POST')){ $redirectParams = array('id' => $product->getId()); if ($request->request->has('product_attributes')) { // attributes were submitted $editForm = $attributesForm; $redirectParams = array_merge($redirectParams, array('attributes' => 1)); } else if ($request->request->has('product_features')) { // features were submitted $editForm = $featuresForm; $redirectParams = array_merge($redirectParams, array('features' => 1)); } else if ($request->request->has('product_related')) { // related products were submitted $editForm = $relatedProductsForm; $redirectParams = array_merge($redirectParams, array('related' => 1)); } $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($product); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'product.edited'); return $this->redirectToRoute('ecommerce_product_show', $redirectParams); } } return array( 'entity' => $product, 'edit_form' => $editForm->createView(), 'attributes_form' => $attributesForm->createView(), 'features_form' => $featuresForm->createView(), 'related_form' => $relatedProductsForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function editAction(Request $request, Product $product) { //access control $user = $this->container->get('security.token_storage')->getToken()->getUser(); if ($user->isGranted('ROLE_USER') && $product->getActor()->getId() != $user->getId()) { return $this->redirect($this->generateUrl('ecommerce_product_index')); } $formConfig = array(); if ($user->isGranted('ROLE_USER')) { $formConfig['actor'] = $user; } $deleteForm = $this->createDeleteForm($product); $editForm = $this->createForm('EcommerceBundle\Form\ProductType', $product, $formConfig); $attributesForm = $this->createForm('EcommerceBundle\Form\ProductAttributesType', $product, array('category' => $product->getCategory()->getId())); $featuresForm = $this->createForm('EcommerceBundle\Form\ProductFeaturesType', $product, array('category' => $product->getCategory()->getId())); $relatedProductsForm = $this->createForm('EcommerceBundle\Form\ProductRelatedType', $product); if($request->getMethod('POST')){ $redirectParams = array('id' => $product->getId()); if ($request->request->has('product_attributes')) { // attributes were submitted $editForm = $attributesForm; $redirectParams = array_merge($redirectParams, array('attributes' => 1)); } else if ($request->request->has('product_features')) { // features were submitted $editForm = $featuresForm; $redirectParams = array_merge($redirectParams, array('features' => 1)); } else if ($request->request->has('product_related')) { // related products were submitted $editForm = $relatedProductsForm; $redirectParams = array_merge($redirectParams, array('related' => 1)); } $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($product); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'product.edited'); return $this->redirectToRoute('ecommerce_product_show', $redirectParams); } } return array( 'entity' => $product, 'edit_form' => $editForm->createView(), 'attributes_form' => $attributesForm->createView(), 'features_form' => $featuresForm->createView(), 'related_form' => $relatedProductsForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "Product", "$", "product", ")", "{", "//access control", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "->", "isGranted", "(", "'ROLE_USER'", ")", "&&", "$", "product", "->", "getActor", "(", ")", "->", "getId", "(", ")", "!=", "$", "user", "->", "getId", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_product_index'", ")", ")", ";", "}", "$", "formConfig", "=", "array", "(", ")", ";", "if", "(", "$", "user", "->", "isGranted", "(", "'ROLE_USER'", ")", ")", "{", "$", "formConfig", "[", "'actor'", "]", "=", "$", "user", ";", "}", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "product", ")", ";", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\ProductType'", ",", "$", "product", ",", "$", "formConfig", ")", ";", "$", "attributesForm", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\ProductAttributesType'", ",", "$", "product", ",", "array", "(", "'category'", "=>", "$", "product", "->", "getCategory", "(", ")", "->", "getId", "(", ")", ")", ")", ";", "$", "featuresForm", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\ProductFeaturesType'", ",", "$", "product", ",", "array", "(", "'category'", "=>", "$", "product", "->", "getCategory", "(", ")", "->", "getId", "(", ")", ")", ")", ";", "$", "relatedProductsForm", "=", "$", "this", "->", "createForm", "(", "'EcommerceBundle\\Form\\ProductRelatedType'", ",", "$", "product", ")", ";", "if", "(", "$", "request", "->", "getMethod", "(", "'POST'", ")", ")", "{", "$", "redirectParams", "=", "array", "(", "'id'", "=>", "$", "product", "->", "getId", "(", ")", ")", ";", "if", "(", "$", "request", "->", "request", "->", "has", "(", "'product_attributes'", ")", ")", "{", "// attributes were submitted", "$", "editForm", "=", "$", "attributesForm", ";", "$", "redirectParams", "=", "array_merge", "(", "$", "redirectParams", ",", "array", "(", "'attributes'", "=>", "1", ")", ")", ";", "}", "else", "if", "(", "$", "request", "->", "request", "->", "has", "(", "'product_features'", ")", ")", "{", "// features were submitted", "$", "editForm", "=", "$", "featuresForm", ";", "$", "redirectParams", "=", "array_merge", "(", "$", "redirectParams", ",", "array", "(", "'features'", "=>", "1", ")", ")", ";", "}", "else", "if", "(", "$", "request", "->", "request", "->", "has", "(", "'product_related'", ")", ")", "{", "// related products were submitted", "$", "editForm", "=", "$", "relatedProductsForm", ";", "$", "redirectParams", "=", "array_merge", "(", "$", "redirectParams", ",", "array", "(", "'related'", "=>", "1", ")", ")", ";", "}", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isSubmitted", "(", ")", "&&", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "product", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'product.edited'", ")", ";", "return", "$", "this", "->", "redirectToRoute", "(", "'ecommerce_product_show'", ",", "$", "redirectParams", ")", ";", "}", "}", "return", "array", "(", "'entity'", "=>", "$", "product", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'attributes_form'", "=>", "$", "attributesForm", "->", "createView", "(", ")", ",", "'features_form'", "=>", "$", "featuresForm", "->", "createView", "(", ")", ",", "'related_form'", "=>", "$", "relatedProductsForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to edit an existing Product entity. @Route("/{id}/edit") @Method({"GET", "POST"}) @Template()
[ "Displays", "a", "form", "to", "edit", "an", "existing", "Product", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ProductController.php#L185-L239
241,148
sebardo/ecommerce
EcommerceBundle/Controller/ProductController.php
ProductController.createDeleteForm
private function createDeleteForm(Product $product) { return $this->createFormBuilder() ->setAction($this->generateUrl('ecommerce_product_delete', array('id' => $product->getId()))) ->setMethod('DELETE') ->getForm() ; }
php
private function createDeleteForm(Product $product) { return $this->createFormBuilder() ->setAction($this->generateUrl('ecommerce_product_delete', array('id' => $product->getId()))) ->setMethod('DELETE') ->getForm() ; }
[ "private", "function", "createDeleteForm", "(", "Product", "$", "product", ")", "{", "return", "$", "this", "->", "createFormBuilder", "(", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_product_delete'", ",", "array", "(", "'id'", "=>", "$", "product", "->", "getId", "(", ")", ")", ")", ")", "->", "setMethod", "(", "'DELETE'", ")", "->", "getForm", "(", ")", ";", "}" ]
Creates a form to delete a Product entity. @param Product $product The Product entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "delete", "a", "Product", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ProductController.php#L304-L311
241,149
sebardo/ecommerce
EcommerceBundle/Controller/ProductController.php
ProductController.updateImage
public function updateImage(Request $request) { $fileName = $request->query->get('file'); $type = $request->query->get('type'); $value = $request->query->get('value'); /** @var Image $entity */ $qb = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image') ->createQueryBuilder('i'); $image = $qb->where($qb->expr()->like('i.path', ':path')) ->setParameter('path','%'.$fileName.'%') ->getQuery() ->getOneOrNullResult(); // $image = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')->findOneBy(array('path' => $fileName)); if (!$image) { throw new NotFoundHttpException('Unable to find Image entity.'); } if($type == 'title') $image->setTitle($value); if($type == 'alt') $image->setAlt($value); $this->getDoctrine()->getManager()->flush(); return new JsonResponse(array('success' => true)); }
php
public function updateImage(Request $request) { $fileName = $request->query->get('file'); $type = $request->query->get('type'); $value = $request->query->get('value'); /** @var Image $entity */ $qb = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image') ->createQueryBuilder('i'); $image = $qb->where($qb->expr()->like('i.path', ':path')) ->setParameter('path','%'.$fileName.'%') ->getQuery() ->getOneOrNullResult(); // $image = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')->findOneBy(array('path' => $fileName)); if (!$image) { throw new NotFoundHttpException('Unable to find Image entity.'); } if($type == 'title') $image->setTitle($value); if($type == 'alt') $image->setAlt($value); $this->getDoctrine()->getManager()->flush(); return new JsonResponse(array('success' => true)); }
[ "public", "function", "updateImage", "(", "Request", "$", "request", ")", "{", "$", "fileName", "=", "$", "request", "->", "query", "->", "get", "(", "'file'", ")", ";", "$", "type", "=", "$", "request", "->", "query", "->", "get", "(", "'type'", ")", ";", "$", "value", "=", "$", "request", "->", "query", "->", "get", "(", "'value'", ")", ";", "/** @var Image $entity */", "$", "qb", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "getRepository", "(", "'CoreBundle:Image'", ")", "->", "createQueryBuilder", "(", "'i'", ")", ";", "$", "image", "=", "$", "qb", "->", "where", "(", "$", "qb", "->", "expr", "(", ")", "->", "like", "(", "'i.path'", ",", "':path'", ")", ")", "->", "setParameter", "(", "'path'", ",", "'%'", ".", "$", "fileName", ".", "'%'", ")", "->", "getQuery", "(", ")", "->", "getOneOrNullResult", "(", ")", ";", "// $image = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')->findOneBy(array('path' => $fileName));", "if", "(", "!", "$", "image", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'Unable to find Image entity.'", ")", ";", "}", "if", "(", "$", "type", "==", "'title'", ")", "$", "image", "->", "setTitle", "(", "$", "value", ")", ";", "if", "(", "$", "type", "==", "'alt'", ")", "$", "image", "->", "setAlt", "(", "$", "value", ")", ";", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "flush", "(", ")", ";", "return", "new", "JsonResponse", "(", "array", "(", "'success'", "=>", "true", ")", ")", ";", "}" ]
Manages a product image @return array @Route("/update/image")
[ "Manages", "a", "product", "image" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/ProductController.php#L335-L363
241,150
bishopb/vanilla
plugins/VanillaStats/class.vanillastats.plugin.php
VanillaStatsPlugin.Gdn_Dispatcher_BeforeDispatch_Handler
public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender) { $Enabled = C('Garden.Analytics.Enabled', TRUE); if ($Enabled && !Gdn::PluginManager()->HasNewMethod('SettingsController', 'Index')) { Gdn::PluginManager()->RegisterNewMethod('VanillaStatsPlugin', 'StatsDashboard', 'SettingsController', 'Index'); } }
php
public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender) { $Enabled = C('Garden.Analytics.Enabled', TRUE); if ($Enabled && !Gdn::PluginManager()->HasNewMethod('SettingsController', 'Index')) { Gdn::PluginManager()->RegisterNewMethod('VanillaStatsPlugin', 'StatsDashboard', 'SettingsController', 'Index'); } }
[ "public", "function", "Gdn_Dispatcher_BeforeDispatch_Handler", "(", "$", "Sender", ")", "{", "$", "Enabled", "=", "C", "(", "'Garden.Analytics.Enabled'", ",", "TRUE", ")", ";", "if", "(", "$", "Enabled", "&&", "!", "Gdn", "::", "PluginManager", "(", ")", "->", "HasNewMethod", "(", "'SettingsController'", ",", "'Index'", ")", ")", "{", "Gdn", "::", "PluginManager", "(", ")", "->", "RegisterNewMethod", "(", "'VanillaStatsPlugin'", ",", "'StatsDashboard'", ",", "'SettingsController'", ",", "'Index'", ")", ";", "}", "}" ]
Override the default dashboard page with the new stats one.
[ "Override", "the", "default", "dashboard", "page", "with", "the", "new", "stats", "one", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/VanillaStats/class.vanillastats.plugin.php#L50-L56
241,151
bishopb/vanilla
plugins/VanillaStats/class.vanillastats.plugin.php
VanillaStatsPlugin.StatsDashboard
public function StatsDashboard($Sender) { $StatsUrl = $this->AnalyticsServer; if (!StringBeginsWith($StatsUrl, 'http:') && !StringBeginsWith($StatsUrl, 'https:')) $StatsUrl = Gdn::Request()->Scheme()."://{$StatsUrl}"; // Tell the page where to find the Vanilla Analytics provider $Sender->AddDefinition('VanillaStatsUrl', $StatsUrl); $Sender->SetData('VanillaStatsUrl', $StatsUrl); // Load javascript & css, check permissions, and load side menu for this page. $Sender->AddJsFile('settings.js'); $Sender->Title(T('Dashboard')); $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Add'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve'; $Sender->FireEvent('DefineAdminPermissions'); $Sender->Permission($Sender->RequiredAdminPermissions, '', FALSE); $Sender->AddSideMenu('dashboard/settings'); if (!Gdn_Statistics::CheckIsEnabled() && Gdn_Statistics::CheckIsLocalhost()) { $Sender->Render('dashboardlocalhost', '', 'plugins/VanillaStats'); } else { $Sender->AddJsFile('plugins/VanillaStats/js/vanillastats.js'); $Sender->AddJsFile('plugins/VanillaStats/js/picker.js'); $Sender->AddCSSFile('plugins/VanillaStats/design/picker.css'); $this->ConfigureRange($Sender); $VanillaID = Gdn::InstallationID(); $Sender->SetData('VanillaID', $VanillaID); $Sender->SetData('VanillaVersion', APPLICATION_VERSION); $Sender->SetData('SecurityToken', $this->SecurityToken()); // Render the custom dashboard view $Sender->Render('dashboard', '', 'plugins/VanillaStats'); } }
php
public function StatsDashboard($Sender) { $StatsUrl = $this->AnalyticsServer; if (!StringBeginsWith($StatsUrl, 'http:') && !StringBeginsWith($StatsUrl, 'https:')) $StatsUrl = Gdn::Request()->Scheme()."://{$StatsUrl}"; // Tell the page where to find the Vanilla Analytics provider $Sender->AddDefinition('VanillaStatsUrl', $StatsUrl); $Sender->SetData('VanillaStatsUrl', $StatsUrl); // Load javascript & css, check permissions, and load side menu for this page. $Sender->AddJsFile('settings.js'); $Sender->Title(T('Dashboard')); $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Add'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve'; $Sender->FireEvent('DefineAdminPermissions'); $Sender->Permission($Sender->RequiredAdminPermissions, '', FALSE); $Sender->AddSideMenu('dashboard/settings'); if (!Gdn_Statistics::CheckIsEnabled() && Gdn_Statistics::CheckIsLocalhost()) { $Sender->Render('dashboardlocalhost', '', 'plugins/VanillaStats'); } else { $Sender->AddJsFile('plugins/VanillaStats/js/vanillastats.js'); $Sender->AddJsFile('plugins/VanillaStats/js/picker.js'); $Sender->AddCSSFile('plugins/VanillaStats/design/picker.css'); $this->ConfigureRange($Sender); $VanillaID = Gdn::InstallationID(); $Sender->SetData('VanillaID', $VanillaID); $Sender->SetData('VanillaVersion', APPLICATION_VERSION); $Sender->SetData('SecurityToken', $this->SecurityToken()); // Render the custom dashboard view $Sender->Render('dashboard', '', 'plugins/VanillaStats'); } }
[ "public", "function", "StatsDashboard", "(", "$", "Sender", ")", "{", "$", "StatsUrl", "=", "$", "this", "->", "AnalyticsServer", ";", "if", "(", "!", "StringBeginsWith", "(", "$", "StatsUrl", ",", "'http:'", ")", "&&", "!", "StringBeginsWith", "(", "$", "StatsUrl", ",", "'https:'", ")", ")", "$", "StatsUrl", "=", "Gdn", "::", "Request", "(", ")", "->", "Scheme", "(", ")", ".", "\"://{$StatsUrl}\"", ";", "// Tell the page where to find the Vanilla Analytics provider\r", "$", "Sender", "->", "AddDefinition", "(", "'VanillaStatsUrl'", ",", "$", "StatsUrl", ")", ";", "$", "Sender", "->", "SetData", "(", "'VanillaStatsUrl'", ",", "$", "StatsUrl", ")", ";", "// Load javascript & css, check permissions, and load side menu for this page.\r", "$", "Sender", "->", "AddJsFile", "(", "'settings.js'", ")", ";", "$", "Sender", "->", "Title", "(", "T", "(", "'Dashboard'", ")", ")", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Settings.Manage'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Add'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Edit'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Delete'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Approve'", ";", "$", "Sender", "->", "FireEvent", "(", "'DefineAdminPermissions'", ")", ";", "$", "Sender", "->", "Permission", "(", "$", "Sender", "->", "RequiredAdminPermissions", ",", "''", ",", "FALSE", ")", ";", "$", "Sender", "->", "AddSideMenu", "(", "'dashboard/settings'", ")", ";", "if", "(", "!", "Gdn_Statistics", "::", "CheckIsEnabled", "(", ")", "&&", "Gdn_Statistics", "::", "CheckIsLocalhost", "(", ")", ")", "{", "$", "Sender", "->", "Render", "(", "'dashboardlocalhost'", ",", "''", ",", "'plugins/VanillaStats'", ")", ";", "}", "else", "{", "$", "Sender", "->", "AddJsFile", "(", "'plugins/VanillaStats/js/vanillastats.js'", ")", ";", "$", "Sender", "->", "AddJsFile", "(", "'plugins/VanillaStats/js/picker.js'", ")", ";", "$", "Sender", "->", "AddCSSFile", "(", "'plugins/VanillaStats/design/picker.css'", ")", ";", "$", "this", "->", "ConfigureRange", "(", "$", "Sender", ")", ";", "$", "VanillaID", "=", "Gdn", "::", "InstallationID", "(", ")", ";", "$", "Sender", "->", "SetData", "(", "'VanillaID'", ",", "$", "VanillaID", ")", ";", "$", "Sender", "->", "SetData", "(", "'VanillaVersion'", ",", "APPLICATION_VERSION", ")", ";", "$", "Sender", "->", "SetData", "(", "'SecurityToken'", ",", "$", "this", "->", "SecurityToken", "(", ")", ")", ";", "// Render the custom dashboard view\r", "$", "Sender", "->", "Render", "(", "'dashboard'", ",", "''", ",", "'plugins/VanillaStats'", ")", ";", "}", "}" ]
Override the default index method of the settings controller in the dashboard application to render new statistics.
[ "Override", "the", "default", "index", "method", "of", "the", "settings", "controller", "in", "the", "dashboard", "application", "to", "render", "new", "statistics", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/VanillaStats/class.vanillastats.plugin.php#L84-L122
241,152
bishopb/vanilla
plugins/VanillaStats/class.vanillastats.plugin.php
VanillaStatsPlugin.SettingsController_DashboardSummaries_Create
public function SettingsController_DashboardSummaries_Create($Sender) { // Load javascript & css, check permissions, and load side menu for this page. $Sender->AddJsFile('settings.js'); $Sender->Title(T('Dashboard Summaries')); $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Add'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve'; $Sender->FireEvent('DefineAdminPermissions'); $Sender->Permission($Sender->RequiredAdminPermissions, '', FALSE); $Sender->AddSideMenu('dashboard/settings'); $this->ConfigureRange($Sender); // Load the most active discussions during this date range $UserModel = new UserModel(); $Sender->SetData('DiscussionData', $UserModel->SQL ->Select('d.DiscussionID, d.Name, d.CountBookmarks, d.CountViews, d.CountComments') ->From('Discussion d') ->Where('d.DateLastComment >=', $Sender->DateStart) ->Where('d.DateLastComment <=', $Sender->DateEnd) ->OrderBy('d.CountViews', 'desc') ->OrderBy('d.CountComments', 'desc') ->OrderBy('d.CountBookmarks', 'desc') ->Limit(10, 0) ->Get() ); // Load the most active users during this date range $Sender->SetData('UserData', $UserModel->SQL ->Select('u.UserID, u.Name') ->Select('c.CommentID', 'count', 'CountComments') ->From('User u') ->Join('Comment c', 'u.UserID = c.InsertUserID', 'inner') ->GroupBy('u.UserID, u.Name') ->Where('c.DateInserted >=', $Sender->DateStart) ->Where('c.DateInserted <=', $Sender->DateEnd) ->OrderBy('CountComments', 'desc') ->Limit(10, 0) ->Get() ); // Render the custom dashboard view $Sender->Render('dashboardsummaries', '', 'plugins/VanillaStats'); }
php
public function SettingsController_DashboardSummaries_Create($Sender) { // Load javascript & css, check permissions, and load side menu for this page. $Sender->AddJsFile('settings.js'); $Sender->Title(T('Dashboard Summaries')); $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Add'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve'; $Sender->FireEvent('DefineAdminPermissions'); $Sender->Permission($Sender->RequiredAdminPermissions, '', FALSE); $Sender->AddSideMenu('dashboard/settings'); $this->ConfigureRange($Sender); // Load the most active discussions during this date range $UserModel = new UserModel(); $Sender->SetData('DiscussionData', $UserModel->SQL ->Select('d.DiscussionID, d.Name, d.CountBookmarks, d.CountViews, d.CountComments') ->From('Discussion d') ->Where('d.DateLastComment >=', $Sender->DateStart) ->Where('d.DateLastComment <=', $Sender->DateEnd) ->OrderBy('d.CountViews', 'desc') ->OrderBy('d.CountComments', 'desc') ->OrderBy('d.CountBookmarks', 'desc') ->Limit(10, 0) ->Get() ); // Load the most active users during this date range $Sender->SetData('UserData', $UserModel->SQL ->Select('u.UserID, u.Name') ->Select('c.CommentID', 'count', 'CountComments') ->From('User u') ->Join('Comment c', 'u.UserID = c.InsertUserID', 'inner') ->GroupBy('u.UserID, u.Name') ->Where('c.DateInserted >=', $Sender->DateStart) ->Where('c.DateInserted <=', $Sender->DateEnd) ->OrderBy('CountComments', 'desc') ->Limit(10, 0) ->Get() ); // Render the custom dashboard view $Sender->Render('dashboardsummaries', '', 'plugins/VanillaStats'); }
[ "public", "function", "SettingsController_DashboardSummaries_Create", "(", "$", "Sender", ")", "{", "// Load javascript & css, check permissions, and load side menu for this page.\r", "$", "Sender", "->", "AddJsFile", "(", "'settings.js'", ")", ";", "$", "Sender", "->", "Title", "(", "T", "(", "'Dashboard Summaries'", ")", ")", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Settings.Manage'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Add'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Edit'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Delete'", ";", "$", "Sender", "->", "RequiredAdminPermissions", "[", "]", "=", "'Garden.Users.Approve'", ";", "$", "Sender", "->", "FireEvent", "(", "'DefineAdminPermissions'", ")", ";", "$", "Sender", "->", "Permission", "(", "$", "Sender", "->", "RequiredAdminPermissions", ",", "''", ",", "FALSE", ")", ";", "$", "Sender", "->", "AddSideMenu", "(", "'dashboard/settings'", ")", ";", "$", "this", "->", "ConfigureRange", "(", "$", "Sender", ")", ";", "// Load the most active discussions during this date range\r", "$", "UserModel", "=", "new", "UserModel", "(", ")", ";", "$", "Sender", "->", "SetData", "(", "'DiscussionData'", ",", "$", "UserModel", "->", "SQL", "->", "Select", "(", "'d.DiscussionID, d.Name, d.CountBookmarks, d.CountViews, d.CountComments'", ")", "->", "From", "(", "'Discussion d'", ")", "->", "Where", "(", "'d.DateLastComment >='", ",", "$", "Sender", "->", "DateStart", ")", "->", "Where", "(", "'d.DateLastComment <='", ",", "$", "Sender", "->", "DateEnd", ")", "->", "OrderBy", "(", "'d.CountViews'", ",", "'desc'", ")", "->", "OrderBy", "(", "'d.CountComments'", ",", "'desc'", ")", "->", "OrderBy", "(", "'d.CountBookmarks'", ",", "'desc'", ")", "->", "Limit", "(", "10", ",", "0", ")", "->", "Get", "(", ")", ")", ";", "// Load the most active users during this date range\r", "$", "Sender", "->", "SetData", "(", "'UserData'", ",", "$", "UserModel", "->", "SQL", "->", "Select", "(", "'u.UserID, u.Name'", ")", "->", "Select", "(", "'c.CommentID'", ",", "'count'", ",", "'CountComments'", ")", "->", "From", "(", "'User u'", ")", "->", "Join", "(", "'Comment c'", ",", "'u.UserID = c.InsertUserID'", ",", "'inner'", ")", "->", "GroupBy", "(", "'u.UserID, u.Name'", ")", "->", "Where", "(", "'c.DateInserted >='", ",", "$", "Sender", "->", "DateStart", ")", "->", "Where", "(", "'c.DateInserted <='", ",", "$", "Sender", "->", "DateEnd", ")", "->", "OrderBy", "(", "'CountComments'", ",", "'desc'", ")", "->", "Limit", "(", "10", ",", "0", ")", "->", "Get", "(", ")", ")", ";", "// Render the custom dashboard view\r", "$", "Sender", "->", "Render", "(", "'dashboardsummaries'", ",", "''", ",", "'plugins/VanillaStats'", ")", ";", "}" ]
A view containing most active discussions & users during a specific time period. This gets ajaxed into the dashboard homepage as date ranges are defined.
[ "A", "view", "containing", "most", "active", "discussions", "&", "users", "during", "a", "specific", "time", "period", ".", "This", "gets", "ajaxed", "into", "the", "dashboard", "homepage", "as", "date", "ranges", "are", "defined", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/VanillaStats/class.vanillastats.plugin.php#L129-L174
241,153
cityware/city-wmi
src/Processors/Software.php
Software.get
public function get() { $keys = $this->registry ->setRoot(Registry::HKEY_LOCAL_MACHINE) ->setPath($this->path) ->get(); $software = []; foreach ($keys as $key) { // Set a new temporary path for the software key $path = $this->path.$key; // Retrieve the name of the software $name = $this->registry->setPath($path)->getValue('DisplayName'); // If the name exists, we'll retrieve the rest of the software information if ($name) { $software[] = new Application([ 'name' => $name, 'version' => $this->registry->getValue('DisplayVersion'), 'publisher' => $this->registry->getValue('Publisher'), 'install_date' => $this->registry->getValue('InstallDate'), ]); } } return $software; }
php
public function get() { $keys = $this->registry ->setRoot(Registry::HKEY_LOCAL_MACHINE) ->setPath($this->path) ->get(); $software = []; foreach ($keys as $key) { // Set a new temporary path for the software key $path = $this->path.$key; // Retrieve the name of the software $name = $this->registry->setPath($path)->getValue('DisplayName'); // If the name exists, we'll retrieve the rest of the software information if ($name) { $software[] = new Application([ 'name' => $name, 'version' => $this->registry->getValue('DisplayVersion'), 'publisher' => $this->registry->getValue('Publisher'), 'install_date' => $this->registry->getValue('InstallDate'), ]); } } return $software; }
[ "public", "function", "get", "(", ")", "{", "$", "keys", "=", "$", "this", "->", "registry", "->", "setRoot", "(", "Registry", "::", "HKEY_LOCAL_MACHINE", ")", "->", "setPath", "(", "$", "this", "->", "path", ")", "->", "get", "(", ")", ";", "$", "software", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "// Set a new temporary path for the software key", "$", "path", "=", "$", "this", "->", "path", ".", "$", "key", ";", "// Retrieve the name of the software", "$", "name", "=", "$", "this", "->", "registry", "->", "setPath", "(", "$", "path", ")", "->", "getValue", "(", "'DisplayName'", ")", ";", "// If the name exists, we'll retrieve the rest of the software information", "if", "(", "$", "name", ")", "{", "$", "software", "[", "]", "=", "new", "Application", "(", "[", "'name'", "=>", "$", "name", ",", "'version'", "=>", "$", "this", "->", "registry", "->", "getValue", "(", "'DisplayVersion'", ")", ",", "'publisher'", "=>", "$", "this", "->", "registry", "->", "getValue", "(", "'Publisher'", ")", ",", "'install_date'", "=>", "$", "this", "->", "registry", "->", "getValue", "(", "'InstallDate'", ")", ",", "]", ")", ";", "}", "}", "return", "$", "software", ";", "}" ]
Returns an array of software on the current computer. @return array
[ "Returns", "an", "array", "of", "software", "on", "the", "current", "computer", "." ]
c7296e6855b6719f537ff5c2dc19d521ce1415d8
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Processors/Software.php#L36-L64
241,154
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.getResultSet
protected function getResultSet() { if (!$this->resultSetPrototype instanceof HydratingResultSet) { $resultSetPrototype = new HydratingResultSet; $resultSetPrototype->setHydrator($this->getHydrator()); $resultSetPrototype->setObjectPrototype($this->getModel()); $this->resultSetPrototype = $resultSetPrototype; } return clone $this->resultSetPrototype; }
php
protected function getResultSet() { if (!$this->resultSetPrototype instanceof HydratingResultSet) { $resultSetPrototype = new HydratingResultSet; $resultSetPrototype->setHydrator($this->getHydrator()); $resultSetPrototype->setObjectPrototype($this->getModel()); $this->resultSetPrototype = $resultSetPrototype; } return clone $this->resultSetPrototype; }
[ "protected", "function", "getResultSet", "(", ")", "{", "if", "(", "!", "$", "this", "->", "resultSetPrototype", "instanceof", "HydratingResultSet", ")", "{", "$", "resultSetPrototype", "=", "new", "HydratingResultSet", ";", "$", "resultSetPrototype", "->", "setHydrator", "(", "$", "this", "->", "getHydrator", "(", ")", ")", ";", "$", "resultSetPrototype", "->", "setObjectPrototype", "(", "$", "this", "->", "getModel", "(", ")", ")", ";", "$", "this", "->", "resultSetPrototype", "=", "$", "resultSetPrototype", ";", "}", "return", "clone", "$", "this", "->", "resultSetPrototype", ";", "}" ]
gets the resultSet @return HydratingResultSet
[ "gets", "the", "resultSet" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L92-L102
241,155
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.getById
public function getById($id, $col = null) { $col = ($col) ?: $this->getPrimaryKey(); $select = $this->getSelect()->where([$col => $id]); $resultSet = $this->fetchResult($select); if ($resultSet->count() > 1) { $rowSet = []; foreach ($resultSet as $row) { $rowSet[] = $row; } } elseif ($resultSet->count() === 1) { $rowSet = $resultSet->current(); } else { $rowSet = $this->getModel(); } return $rowSet; }
php
public function getById($id, $col = null) { $col = ($col) ?: $this->getPrimaryKey(); $select = $this->getSelect()->where([$col => $id]); $resultSet = $this->fetchResult($select); if ($resultSet->count() > 1) { $rowSet = []; foreach ($resultSet as $row) { $rowSet[] = $row; } } elseif ($resultSet->count() === 1) { $rowSet = $resultSet->current(); } else { $rowSet = $this->getModel(); } return $rowSet; }
[ "public", "function", "getById", "(", "$", "id", ",", "$", "col", "=", "null", ")", "{", "$", "col", "=", "(", "$", "col", ")", "?", ":", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "$", "select", "=", "$", "this", "->", "getSelect", "(", ")", "->", "where", "(", "[", "$", "col", "=>", "$", "id", "]", ")", ";", "$", "resultSet", "=", "$", "this", "->", "fetchResult", "(", "$", "select", ")", ";", "if", "(", "$", "resultSet", "->", "count", "(", ")", ">", "1", ")", "{", "$", "rowSet", "=", "[", "]", ";", "foreach", "(", "$", "resultSet", "as", "$", "row", ")", "{", "$", "rowSet", "[", "]", "=", "$", "row", ";", "}", "}", "elseif", "(", "$", "resultSet", "->", "count", "(", ")", "===", "1", ")", "{", "$", "rowSet", "=", "$", "resultSet", "->", "current", "(", ")", ";", "}", "else", "{", "$", "rowSet", "=", "$", "this", "->", "getModel", "(", ")", ";", "}", "return", "$", "rowSet", ";", "}" ]
Gets one or more rows by its id @param $id @param null|string $col @return array|ModelInterface
[ "Gets", "one", "or", "more", "rows", "by", "its", "id" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L111-L129
241,156
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.fetchAll
public function fetchAll($sort = null) { $select = $this->getSelect(); $select = $this->setSortOrder($select, $sort); $resultSet = $this->fetchResult($select); return $resultSet; }
php
public function fetchAll($sort = null) { $select = $this->getSelect(); $select = $this->setSortOrder($select, $sort); $resultSet = $this->fetchResult($select); return $resultSet; }
[ "public", "function", "fetchAll", "(", "$", "sort", "=", "null", ")", "{", "$", "select", "=", "$", "this", "->", "getSelect", "(", ")", ";", "$", "select", "=", "$", "this", "->", "setSortOrder", "(", "$", "select", ",", "$", "sort", ")", ";", "$", "resultSet", "=", "$", "this", "->", "fetchResult", "(", "$", "select", ")", ";", "return", "$", "resultSet", ";", "}" ]
Fetches all rows from database table. @param null|string $sort @return HydratingResultSet|\Zend\Db\ResultSet\ResultSet|Paginator
[ "Fetches", "all", "rows", "from", "database", "table", "." ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L182-L190
241,157
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.search
public function search(array $search, $sort, $select = null) { $select = ($select) ?: $this->getSelect(); foreach ($search as $key => $value) { if (!$value['searchString'] == '') { if (substr($value['searchString'], 0, 1) == '=' && $key == 0) { $id = (int)substr($value['searchString'], 1); $select->where->equalTo($this->getPrimaryKey(), $id); } else { $where = $select->where->nest(); $c = 0; foreach ($value['columns'] as $column) { if ($c > 0) $where->or; $where->like($column, '%' . $value['searchString'] . '%'); $c++; } $where->unnest(); } } } $select = $this->setSortOrder($select, $sort); return $this->fetchResult($select); }
php
public function search(array $search, $sort, $select = null) { $select = ($select) ?: $this->getSelect(); foreach ($search as $key => $value) { if (!$value['searchString'] == '') { if (substr($value['searchString'], 0, 1) == '=' && $key == 0) { $id = (int)substr($value['searchString'], 1); $select->where->equalTo($this->getPrimaryKey(), $id); } else { $where = $select->where->nest(); $c = 0; foreach ($value['columns'] as $column) { if ($c > 0) $where->or; $where->like($column, '%' . $value['searchString'] . '%'); $c++; } $where->unnest(); } } } $select = $this->setSortOrder($select, $sort); return $this->fetchResult($select); }
[ "public", "function", "search", "(", "array", "$", "search", ",", "$", "sort", ",", "$", "select", "=", "null", ")", "{", "$", "select", "=", "(", "$", "select", ")", "?", ":", "$", "this", "->", "getSelect", "(", ")", ";", "foreach", "(", "$", "search", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "value", "[", "'searchString'", "]", "==", "''", ")", "{", "if", "(", "substr", "(", "$", "value", "[", "'searchString'", "]", ",", "0", ",", "1", ")", "==", "'='", "&&", "$", "key", "==", "0", ")", "{", "$", "id", "=", "(", "int", ")", "substr", "(", "$", "value", "[", "'searchString'", "]", ",", "1", ")", ";", "$", "select", "->", "where", "->", "equalTo", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ",", "$", "id", ")", ";", "}", "else", "{", "$", "where", "=", "$", "select", "->", "where", "->", "nest", "(", ")", ";", "$", "c", "=", "0", ";", "foreach", "(", "$", "value", "[", "'columns'", "]", "as", "$", "column", ")", "{", "if", "(", "$", "c", ">", "0", ")", "$", "where", "->", "or", ";", "$", "where", "->", "like", "(", "$", "column", ",", "'%'", ".", "$", "value", "[", "'searchString'", "]", ".", "'%'", ")", ";", "$", "c", "++", ";", "}", "$", "where", "->", "unnest", "(", ")", ";", "}", "}", "}", "$", "select", "=", "$", "this", "->", "setSortOrder", "(", "$", "select", ",", "$", "sort", ")", ";", "return", "$", "this", "->", "fetchResult", "(", "$", "select", ")", ";", "}" ]
basic search on table data @param array $search @param string $sort @param Select $select @return \Zend\Db\ResultSet\ResultSet|Paginator|HydratingResultSet
[ "basic", "search", "on", "table", "data" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L200-L227
241,158
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.insert
public function insert(array $data, $table = null) { $table = ($table) ?: $this->getTable(); $sql = $this->getSql(); $insert = $sql->insert($table); $insert->values($data); $statement = $sql->prepareStatementForSqlObject($insert); $result = $statement->execute(); return $result->getGeneratedValue(); }
php
public function insert(array $data, $table = null) { $table = ($table) ?: $this->getTable(); $sql = $this->getSql(); $insert = $sql->insert($table); $insert->values($data); $statement = $sql->prepareStatementForSqlObject($insert); $result = $statement->execute(); return $result->getGeneratedValue(); }
[ "public", "function", "insert", "(", "array", "$", "data", ",", "$", "table", "=", "null", ")", "{", "$", "table", "=", "(", "$", "table", ")", "?", ":", "$", "this", "->", "getTable", "(", ")", ";", "$", "sql", "=", "$", "this", "->", "getSql", "(", ")", ";", "$", "insert", "=", "$", "sql", "->", "insert", "(", "$", "table", ")", ";", "$", "insert", "->", "values", "(", "$", "data", ")", ";", "$", "statement", "=", "$", "sql", "->", "prepareStatementForSqlObject", "(", "$", "insert", ")", ";", "$", "result", "=", "$", "statement", "->", "execute", "(", ")", ";", "return", "$", "result", "->", "getGeneratedValue", "(", ")", ";", "}" ]
Inserts a new row into database returns insertId @param array $data @param string $table @return int|null
[ "Inserts", "a", "new", "row", "into", "database", "returns", "insertId" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L236-L248
241,159
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.paginate
public function paginate($select, $resultSet = null) { $resultSet = $resultSet ?: $this->getResultSet(); $adapter = new DbSelect($select, $this->getAdapter(), $resultSet); $paginator = new Paginator($adapter); $options = $this->getPaginatorOptions(); if (isset($options['limit'])) { $paginator->setItemCountPerPage($options['limit']); } if (isset($options['page'])) { $paginator->setCurrentPageNumber($options['page']); } $paginator->setPageRange(5); return $paginator; }
php
public function paginate($select, $resultSet = null) { $resultSet = $resultSet ?: $this->getResultSet(); $adapter = new DbSelect($select, $this->getAdapter(), $resultSet); $paginator = new Paginator($adapter); $options = $this->getPaginatorOptions(); if (isset($options['limit'])) { $paginator->setItemCountPerPage($options['limit']); } if (isset($options['page'])) { $paginator->setCurrentPageNumber($options['page']); } $paginator->setPageRange(5); return $paginator; }
[ "public", "function", "paginate", "(", "$", "select", ",", "$", "resultSet", "=", "null", ")", "{", "$", "resultSet", "=", "$", "resultSet", "?", ":", "$", "this", "->", "getResultSet", "(", ")", ";", "$", "adapter", "=", "new", "DbSelect", "(", "$", "select", ",", "$", "this", "->", "getAdapter", "(", ")", ",", "$", "resultSet", ")", ";", "$", "paginator", "=", "new", "Paginator", "(", "$", "adapter", ")", ";", "$", "options", "=", "$", "this", "->", "getPaginatorOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'limit'", "]", ")", ")", "{", "$", "paginator", "->", "setItemCountPerPage", "(", "$", "options", "[", "'limit'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'page'", "]", ")", ")", "{", "$", "paginator", "->", "setCurrentPageNumber", "(", "$", "options", "[", "'page'", "]", ")", ";", "}", "$", "paginator", "->", "setPageRange", "(", "5", ")", ";", "return", "$", "paginator", ";", "}" ]
Paginates the result set @param Select $select @param AbstractResultSet $resultSet @return Paginator
[ "Paginates", "the", "result", "set" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L338-L357
241,160
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.fetchResult
protected function fetchResult(Select $select, AbstractResultSet $resultSet = null) { $resultSet = $resultSet ?: $this->getResultSet(); $resultSet->buffer(); if ($this->usePaginator()) { $this->setUsePaginator(false); $resultSet = $this->paginate($select, $resultSet); } else { $statement = $this->getSql()->prepareStatementForSqlObject($select); $result = $statement->execute(); $resultSet->initialize($result); } return $resultSet; }
php
protected function fetchResult(Select $select, AbstractResultSet $resultSet = null) { $resultSet = $resultSet ?: $this->getResultSet(); $resultSet->buffer(); if ($this->usePaginator()) { $this->setUsePaginator(false); $resultSet = $this->paginate($select, $resultSet); } else { $statement = $this->getSql()->prepareStatementForSqlObject($select); $result = $statement->execute(); $resultSet->initialize($result); } return $resultSet; }
[ "protected", "function", "fetchResult", "(", "Select", "$", "select", ",", "AbstractResultSet", "$", "resultSet", "=", "null", ")", "{", "$", "resultSet", "=", "$", "resultSet", "?", ":", "$", "this", "->", "getResultSet", "(", ")", ";", "$", "resultSet", "->", "buffer", "(", ")", ";", "if", "(", "$", "this", "->", "usePaginator", "(", ")", ")", "{", "$", "this", "->", "setUsePaginator", "(", "false", ")", ";", "$", "resultSet", "=", "$", "this", "->", "paginate", "(", "$", "select", ",", "$", "resultSet", ")", ";", "}", "else", "{", "$", "statement", "=", "$", "this", "->", "getSql", "(", ")", "->", "prepareStatementForSqlObject", "(", "$", "select", ")", ";", "$", "result", "=", "$", "statement", "->", "execute", "(", ")", ";", "$", "resultSet", "->", "initialize", "(", "$", "result", ")", ";", "}", "return", "$", "resultSet", ";", "}" ]
Fetches the result of select from database @param Select $select @param AbstractResultSet $resultSet @return \Zend\Db\ResultSet\ResultSet|Paginator|HydratingResultSet
[ "Fetches", "the", "result", "of", "select", "from", "database" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L366-L381
241,161
uthando-cms/uthando-common
src/UthandoCommon/Mapper/AbstractDbMapper.php
AbstractDbMapper.setSortOrder
public function setSortOrder(Select $select, $sort) { if ($sort === '' || null === $sort || empty($sort)) { return $select; } $select->reset('order'); if (is_string($sort)) { $sort = explode(' ', $sort); } $order = []; foreach ($sort as $column) { if (strchr($column, '-')) { $column = substr($column, 1, strlen($column)); $direction = Select::ORDER_DESCENDING; } else { $direction = Select::ORDER_ASCENDING; } // COLLATE NOCASE // fix the sort order to make case insensitive for sqlite database. if ('sqlite' == $this->getAdapter()->getPlatform()->getName()) { $direction = 'COLLATE NOCASE ' . $direction; } $order[] = $column . ' ' . $direction; } return $select->order($order); }
php
public function setSortOrder(Select $select, $sort) { if ($sort === '' || null === $sort || empty($sort)) { return $select; } $select->reset('order'); if (is_string($sort)) { $sort = explode(' ', $sort); } $order = []; foreach ($sort as $column) { if (strchr($column, '-')) { $column = substr($column, 1, strlen($column)); $direction = Select::ORDER_DESCENDING; } else { $direction = Select::ORDER_ASCENDING; } // COLLATE NOCASE // fix the sort order to make case insensitive for sqlite database. if ('sqlite' == $this->getAdapter()->getPlatform()->getName()) { $direction = 'COLLATE NOCASE ' . $direction; } $order[] = $column . ' ' . $direction; } return $select->order($order); }
[ "public", "function", "setSortOrder", "(", "Select", "$", "select", ",", "$", "sort", ")", "{", "if", "(", "$", "sort", "===", "''", "||", "null", "===", "$", "sort", "||", "empty", "(", "$", "sort", ")", ")", "{", "return", "$", "select", ";", "}", "$", "select", "->", "reset", "(", "'order'", ")", ";", "if", "(", "is_string", "(", "$", "sort", ")", ")", "{", "$", "sort", "=", "explode", "(", "' '", ",", "$", "sort", ")", ";", "}", "$", "order", "=", "[", "]", ";", "foreach", "(", "$", "sort", "as", "$", "column", ")", "{", "if", "(", "strchr", "(", "$", "column", ",", "'-'", ")", ")", "{", "$", "column", "=", "substr", "(", "$", "column", ",", "1", ",", "strlen", "(", "$", "column", ")", ")", ";", "$", "direction", "=", "Select", "::", "ORDER_DESCENDING", ";", "}", "else", "{", "$", "direction", "=", "Select", "::", "ORDER_ASCENDING", ";", "}", "// COLLATE NOCASE", "// fix the sort order to make case insensitive for sqlite database.", "if", "(", "'sqlite'", "==", "$", "this", "->", "getAdapter", "(", ")", "->", "getPlatform", "(", ")", "->", "getName", "(", ")", ")", "{", "$", "direction", "=", "'COLLATE NOCASE '", ".", "$", "direction", ";", "}", "$", "order", "[", "]", "=", "$", "column", ".", "' '", ".", "$", "direction", ";", "}", "return", "$", "select", "->", "order", "(", "$", "order", ")", ";", "}" ]
Sets sort order of database query @param Select $select @param string|array $sort @return Select
[ "Sets", "sort", "order", "of", "database", "query" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Mapper/AbstractDbMapper.php#L408-L440
241,162
vinala/kernel
src/Foundation/Application.php
Application.run
public static function run($root = '../', $routes = true, $session = true) { self::setScreen(); self::setRoot($root); // self::setCaseVars(false, false); // call the connector and run it self::callBus(); // Connector::run('web',$session); Bus::run('web', $session); self::setVersion(); // set version cookie for Wappalyzer self::$version->cookie(); // self::setSHA(); // self::ini(); // self::fetcher($routes); // return true; }
php
public static function run($root = '../', $routes = true, $session = true) { self::setScreen(); self::setRoot($root); // self::setCaseVars(false, false); // call the connector and run it self::callBus(); // Connector::run('web',$session); Bus::run('web', $session); self::setVersion(); // set version cookie for Wappalyzer self::$version->cookie(); // self::setSHA(); // self::ini(); // self::fetcher($routes); // return true; }
[ "public", "static", "function", "run", "(", "$", "root", "=", "'../'", ",", "$", "routes", "=", "true", ",", "$", "session", "=", "true", ")", "{", "self", "::", "setScreen", "(", ")", ";", "self", "::", "setRoot", "(", "$", "root", ")", ";", "//", "self", "::", "setCaseVars", "(", "false", ",", "false", ")", ";", "// call the connector and run it", "self", "::", "callBus", "(", ")", ";", "// Connector::run('web',$session);", "Bus", "::", "run", "(", "'web'", ",", "$", "session", ")", ";", "self", "::", "setVersion", "(", ")", ";", "// set version cookie for Wappalyzer", "self", "::", "$", "version", "->", "cookie", "(", ")", ";", "//", "self", "::", "setSHA", "(", ")", ";", "//", "self", "::", "ini", "(", ")", ";", "//", "self", "::", "fetcher", "(", "$", "routes", ")", ";", "//", "return", "true", ";", "}" ]
Run the Framework.
[ "Run", "the", "Framework", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L127-L149
241,163
vinala/kernel
src/Foundation/Application.php
Application.console
public static function console($root = '', $session = true) { self::setCaseVars(true, false); // self::consoleServerVars(); // self::setScreen(); self::setRoot($root); // call the connector and run it self::consoleBus(); Bus::run('lumos'); self::setVersion(); // self::ini(false); // self::fetcher(false); // return true; }
php
public static function console($root = '', $session = true) { self::setCaseVars(true, false); // self::consoleServerVars(); // self::setScreen(); self::setRoot($root); // call the connector and run it self::consoleBus(); Bus::run('lumos'); self::setVersion(); // self::ini(false); // self::fetcher(false); // return true; }
[ "public", "static", "function", "console", "(", "$", "root", "=", "''", ",", "$", "session", "=", "true", ")", "{", "self", "::", "setCaseVars", "(", "true", ",", "false", ")", ";", "//", "self", "::", "consoleServerVars", "(", ")", ";", "//", "self", "::", "setScreen", "(", ")", ";", "self", "::", "setRoot", "(", "$", "root", ")", ";", "// call the connector and run it", "self", "::", "consoleBus", "(", ")", ";", "Bus", "::", "run", "(", "'lumos'", ")", ";", "self", "::", "setVersion", "(", ")", ";", "//", "self", "::", "ini", "(", "false", ")", ";", "//", "self", "::", "fetcher", "(", "false", ")", ";", "//", "return", "true", ";", "}" ]
Run the console.
[ "Run", "the", "console", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L160-L179
241,164
vinala/kernel
src/Foundation/Application.php
Application.ini
protected static function ini($database = true, $test = false) { Alias::ini(self::$root); Url::ini(); Path::ini(); Template::run(); if (Component::isOn('faker')) { Faker::ini(); } Link::ini(); Lang::ini($test); if ($database && Component::isOn('database')) { Database::ini(); Schema::ini(); } Auth::ini(); Plugins::ini(); }
php
protected static function ini($database = true, $test = false) { Alias::ini(self::$root); Url::ini(); Path::ini(); Template::run(); if (Component::isOn('faker')) { Faker::ini(); } Link::ini(); Lang::ini($test); if ($database && Component::isOn('database')) { Database::ini(); Schema::ini(); } Auth::ini(); Plugins::ini(); }
[ "protected", "static", "function", "ini", "(", "$", "database", "=", "true", ",", "$", "test", "=", "false", ")", "{", "Alias", "::", "ini", "(", "self", "::", "$", "root", ")", ";", "Url", "::", "ini", "(", ")", ";", "Path", "::", "ini", "(", ")", ";", "Template", "::", "run", "(", ")", ";", "if", "(", "Component", "::", "isOn", "(", "'faker'", ")", ")", "{", "Faker", "::", "ini", "(", ")", ";", "}", "Link", "::", "ini", "(", ")", ";", "Lang", "::", "ini", "(", "$", "test", ")", ";", "if", "(", "$", "database", "&&", "Component", "::", "isOn", "(", "'database'", ")", ")", "{", "Database", "::", "ini", "(", ")", ";", "Schema", "::", "ini", "(", ")", ";", "}", "Auth", "::", "ini", "(", ")", ";", "Plugins", "::", "ini", "(", ")", ";", "}" ]
Init Framework classes.
[ "Init", "Framework", "classes", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L209-L226
241,165
vinala/kernel
src/Foundation/Application.php
Application.vendor
public static function vendor() { self::checkVendor(); $path = is_null(self::$root) ? 'vendor/autoload.php' : self::$root.'vendor/autoload.php'; include_once $path; }
php
public static function vendor() { self::checkVendor(); $path = is_null(self::$root) ? 'vendor/autoload.php' : self::$root.'vendor/autoload.php'; include_once $path; }
[ "public", "static", "function", "vendor", "(", ")", "{", "self", "::", "checkVendor", "(", ")", ";", "$", "path", "=", "is_null", "(", "self", "::", "$", "root", ")", "?", "'vendor/autoload.php'", ":", "self", "::", "$", "root", ".", "'vendor/autoload.php'", ";", "include_once", "$", "path", ";", "}" ]
call vendor.
[ "call", "vendor", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L240-L245
241,166
lucidphp/mux
src/Routes.php
Routes.setRoutes
private function setRoutes(array $routes) { $this->routes = []; foreach ($routes as $name => $route) { $this->add($name, $route); } }
php
private function setRoutes(array $routes) { $this->routes = []; foreach ($routes as $name => $route) { $this->add($name, $route); } }
[ "private", "function", "setRoutes", "(", "array", "$", "routes", ")", "{", "$", "this", "->", "routes", "=", "[", "]", ";", "foreach", "(", "$", "routes", "as", "$", "name", "=>", "$", "route", ")", "{", "$", "this", "->", "add", "(", "$", "name", ",", "$", "route", ")", ";", "}", "}" ]
Sets the initial route collection. @param array $routes @return void
[ "Sets", "the", "initial", "route", "collection", "." ]
2d054ea01450bdad6a4af8198ca6f10705e1c327
https://github.com/lucidphp/mux/blob/2d054ea01450bdad6a4af8198ca6f10705e1c327/src/Routes.php#L142-L149
241,167
mikegibson/sentient
src/Data/RepositoryManager.php
RepositoryManager.registerRepository
public function registerRepository(ManagedRepositoryInterface $repository) { $name = $repository->getName(); if($this->hasRepository($name)) { throw new \LogicException(sprintf('Repository %s is already registered.', $name)); } $event = new ManagedRepositoryEvent($repository); $this->eventDispatcher->dispatch(ManagedRepositoryEvent::REGISTER, $event); $repository = $event->getRepository(); $this->repositories[$name] = $repository; $this->classMap[$repository->getClassName()] = $name; return $repository; }
php
public function registerRepository(ManagedRepositoryInterface $repository) { $name = $repository->getName(); if($this->hasRepository($name)) { throw new \LogicException(sprintf('Repository %s is already registered.', $name)); } $event = new ManagedRepositoryEvent($repository); $this->eventDispatcher->dispatch(ManagedRepositoryEvent::REGISTER, $event); $repository = $event->getRepository(); $this->repositories[$name] = $repository; $this->classMap[$repository->getClassName()] = $name; return $repository; }
[ "public", "function", "registerRepository", "(", "ManagedRepositoryInterface", "$", "repository", ")", "{", "$", "name", "=", "$", "repository", "->", "getName", "(", ")", ";", "if", "(", "$", "this", "->", "hasRepository", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Repository %s is already registered.'", ",", "$", "name", ")", ")", ";", "}", "$", "event", "=", "new", "ManagedRepositoryEvent", "(", "$", "repository", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "ManagedRepositoryEvent", "::", "REGISTER", ",", "$", "event", ")", ";", "$", "repository", "=", "$", "event", "->", "getRepository", "(", ")", ";", "$", "this", "->", "repositories", "[", "$", "name", "]", "=", "$", "repository", ";", "$", "this", "->", "classMap", "[", "$", "repository", "->", "getClassName", "(", ")", "]", "=", "$", "name", ";", "return", "$", "repository", ";", "}" ]
Register a repository @param ManagedRepositoryInterface $repository @return $this @throws \LogicException
[ "Register", "a", "repository" ]
05aaaa0cd8e649d2b526df52a59c9fb53c114338
https://github.com/mikegibson/sentient/blob/05aaaa0cd8e649d2b526df52a59c9fb53c114338/src/Data/RepositoryManager.php#L57-L70
241,168
CatLabInteractive/Neuron
src/Neuron/Filter/Parser.php
Parser.validate
public function validate ($object = null) { if (!isset ($this->context)) { throw new InvalidParameter ("You must set a context before validating or filtering."); } $result = $this->reduce ($this->context, $object); if ($result) { return true; } else { return false; } }
php
public function validate ($object = null) { if (!isset ($this->context)) { throw new InvalidParameter ("You must set a context before validating or filtering."); } $result = $this->reduce ($this->context, $object); if ($result) { return true; } else { return false; } }
[ "public", "function", "validate", "(", "$", "object", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "context", ")", ")", "{", "throw", "new", "InvalidParameter", "(", "\"You must set a context before validating or filtering.\"", ")", ";", "}", "$", "result", "=", "$", "this", "->", "reduce", "(", "$", "this", "->", "context", ",", "$", "object", ")", ";", "if", "(", "$", "result", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Validate a single object @param $object @throws \Neuron\Exceptions\InvalidParameter @return bool
[ "Validate", "a", "single", "object" ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Filter/Parser.php#L495-L512
241,169
rezonans/rezonans-core
Flow/Configurator.php
Configurator.loadEnv
public function loadEnv(string $path): Configurator { if (is_readable($path)) { $this->dotEnv->load($path); } return $this; }
php
public function loadEnv(string $path): Configurator { if (is_readable($path)) { $this->dotEnv->load($path); } return $this; }
[ "public", "function", "loadEnv", "(", "string", "$", "path", ")", ":", "Configurator", "{", "if", "(", "is_readable", "(", "$", "path", ")", ")", "{", "$", "this", "->", "dotEnv", "->", "load", "(", "$", "path", ")", ";", "}", "return", "$", "this", ";", "}" ]
Public environment from .env file @param string $path @return Configurator
[ "Public", "environment", "from", ".", "env", "file" ]
a1200a9473a38cc0c6cda854f254dac01905fb4f
https://github.com/rezonans/rezonans-core/blob/a1200a9473a38cc0c6cda854f254dac01905fb4f/Flow/Configurator.php#L30-L37
241,170
rezonans/rezonans-core
Flow/Configurator.php
Configurator.readConfigDir
public function readConfigDir(string $path): Configurator { if (!is_dir($path)) { throw new \InvalidArgumentException( sprintf("Config dir isn't a directory! %s given.", $path)); } $entitiesDir = new \DirectoryIterator($path); foreach ($entitiesDir as $fileInfo) { if (!$fileInfo->isFile() || ('php' !== $fileInfo->getExtension())) { continue; } require_once($fileInfo->getPathname()); } return $this; }
php
public function readConfigDir(string $path): Configurator { if (!is_dir($path)) { throw new \InvalidArgumentException( sprintf("Config dir isn't a directory! %s given.", $path)); } $entitiesDir = new \DirectoryIterator($path); foreach ($entitiesDir as $fileInfo) { if (!$fileInfo->isFile() || ('php' !== $fileInfo->getExtension())) { continue; } require_once($fileInfo->getPathname()); } return $this; }
[ "public", "function", "readConfigDir", "(", "string", "$", "path", ")", ":", "Configurator", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Config dir isn't a directory! %s given.\"", ",", "$", "path", ")", ")", ";", "}", "$", "entitiesDir", "=", "new", "\\", "DirectoryIterator", "(", "$", "path", ")", ";", "foreach", "(", "$", "entitiesDir", "as", "$", "fileInfo", ")", "{", "if", "(", "!", "$", "fileInfo", "->", "isFile", "(", ")", "||", "(", "'php'", "!==", "$", "fileInfo", "->", "getExtension", "(", ")", ")", ")", "{", "continue", ";", "}", "require_once", "(", "$", "fileInfo", "->", "getPathname", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Include all php scripts in the dir @param string $path @return Configurator
[ "Include", "all", "php", "scripts", "in", "the", "dir" ]
a1200a9473a38cc0c6cda854f254dac01905fb4f
https://github.com/rezonans/rezonans-core/blob/a1200a9473a38cc0c6cda854f254dac01905fb4f/Flow/Configurator.php#L44-L60
241,171
Silvestra/Silvestra
src/Silvestra/Bundle/TextBundle/Form/Handler/TextFormHandler.php
TextFormHandler.process
public function process(Request $request, FormInterface $form) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { /** @var TextInterface $text */ $text = $form->getData(); foreach ($text->getTranslations() as $translation) { $translation->setText($text); } $this->textManager->add($form->getData()); return true; } } return false; }
php
public function process(Request $request, FormInterface $form) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { /** @var TextInterface $text */ $text = $form->getData(); foreach ($text->getTranslations() as $translation) { $translation->setText($text); } $this->textManager->add($form->getData()); return true; } } return false; }
[ "public", "function", "process", "(", "Request", "$", "request", ",", "FormInterface", "$", "form", ")", "{", "if", "(", "$", "request", "->", "isMethod", "(", "'POST'", ")", ")", "{", "$", "form", "->", "submit", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "/** @var TextInterface $text */", "$", "text", "=", "$", "form", "->", "getData", "(", ")", ";", "foreach", "(", "$", "text", "->", "getTranslations", "(", ")", "as", "$", "translation", ")", "{", "$", "translation", "->", "setText", "(", "$", "text", ")", ";", "}", "$", "this", "->", "textManager", "->", "add", "(", "$", "form", "->", "getData", "(", ")", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Process text. @param Request $request @param FormInterface $form @return bool
[ "Process", "text", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/TextBundle/Form/Handler/TextFormHandler.php#L47-L64
241,172
jails/li3_access
extensions/adapter/security/access/Rules.php
Rules._init
protected function _init() { parent::_init(); $this->_rules += [ 'allowAll' => [ 'rule' => function() { return true; } ], 'denyAll' => [ 'rule' => function() { return false; } ], 'allowAnyUser' => [ 'message' => 'You must be logged in.', 'rule' => function($user) { return $user ? true : false; } ], 'allowIp' => [ 'message' => 'Your IP is not allowed to access this area.', 'rule' => function($user, $request, $options) { $options += ['ip' => false]; if (is_string($options['ip']) && strpos($options['ip'], '/') === 0) { return (boolean) preg_match($options['ip'], $request->env('REMOTE_ADDR')); } if (is_array($options['ip'])) { return in_array($request->env('REMOTE_ADDR'), $options['ip']); } return $request->env('REMOTE_ADDR') === $options['ip']; } ] ]; }
php
protected function _init() { parent::_init(); $this->_rules += [ 'allowAll' => [ 'rule' => function() { return true; } ], 'denyAll' => [ 'rule' => function() { return false; } ], 'allowAnyUser' => [ 'message' => 'You must be logged in.', 'rule' => function($user) { return $user ? true : false; } ], 'allowIp' => [ 'message' => 'Your IP is not allowed to access this area.', 'rule' => function($user, $request, $options) { $options += ['ip' => false]; if (is_string($options['ip']) && strpos($options['ip'], '/') === 0) { return (boolean) preg_match($options['ip'], $request->env('REMOTE_ADDR')); } if (is_array($options['ip'])) { return in_array($request->env('REMOTE_ADDR'), $options['ip']); } return $request->env('REMOTE_ADDR') === $options['ip']; } ] ]; }
[ "protected", "function", "_init", "(", ")", "{", "parent", "::", "_init", "(", ")", ";", "$", "this", "->", "_rules", "+=", "[", "'allowAll'", "=>", "[", "'rule'", "=>", "function", "(", ")", "{", "return", "true", ";", "}", "]", ",", "'denyAll'", "=>", "[", "'rule'", "=>", "function", "(", ")", "{", "return", "false", ";", "}", "]", ",", "'allowAnyUser'", "=>", "[", "'message'", "=>", "'You must be logged in.'", ",", "'rule'", "=>", "function", "(", "$", "user", ")", "{", "return", "$", "user", "?", "true", ":", "false", ";", "}", "]", ",", "'allowIp'", "=>", "[", "'message'", "=>", "'Your IP is not allowed to access this area.'", ",", "'rule'", "=>", "function", "(", "$", "user", ",", "$", "request", ",", "$", "options", ")", "{", "$", "options", "+=", "[", "'ip'", "=>", "false", "]", ";", "if", "(", "is_string", "(", "$", "options", "[", "'ip'", "]", ")", "&&", "strpos", "(", "$", "options", "[", "'ip'", "]", ",", "'/'", ")", "===", "0", ")", "{", "return", "(", "boolean", ")", "preg_match", "(", "$", "options", "[", "'ip'", "]", ",", "$", "request", "->", "env", "(", "'REMOTE_ADDR'", ")", ")", ";", "}", "if", "(", "is_array", "(", "$", "options", "[", "'ip'", "]", ")", ")", "{", "return", "in_array", "(", "$", "request", "->", "env", "(", "'REMOTE_ADDR'", ")", ",", "$", "options", "[", "'ip'", "]", ")", ";", "}", "return", "$", "request", "->", "env", "(", "'REMOTE_ADDR'", ")", "===", "$", "options", "[", "'ip'", "]", ";", "}", "]", "]", ";", "}" ]
Initializes default rules to use.
[ "Initializes", "default", "rules", "to", "use", "." ]
aded70dca872ea9237e3eb709099730348008321
https://github.com/jails/li3_access/blob/aded70dca872ea9237e3eb709099730348008321/extensions/adapter/security/access/Rules.php#L62-L95
241,173
jails/li3_access
extensions/adapter/security/access/Rules.php
Rules.check
public function check($user, $request, array $options = []) { $defaults = ['rules' => $this->_defaults, 'allowAny' => $this->_allowAny]; $options += $defaults; if (empty($options['rules'])) { throw new RuntimeException("Missing `'rules'` option."); } $rules = (array) $options['rules']; $this->_error = []; $params = array_diff_key($options, $defaults); if (!isset($user) && is_callable($this->_user)) { $user = $this->_user->__invoke(); } foreach ($rules as $name => $rule) { $result = $this->_check($user, $request, $name, $rule, $params); if ($result === false && !$options['allowAny']) { return false; } if ($result === true && $options['allowAny']) { return true; } } return !$options['allowAny']; }
php
public function check($user, $request, array $options = []) { $defaults = ['rules' => $this->_defaults, 'allowAny' => $this->_allowAny]; $options += $defaults; if (empty($options['rules'])) { throw new RuntimeException("Missing `'rules'` option."); } $rules = (array) $options['rules']; $this->_error = []; $params = array_diff_key($options, $defaults); if (!isset($user) && is_callable($this->_user)) { $user = $this->_user->__invoke(); } foreach ($rules as $name => $rule) { $result = $this->_check($user, $request, $name, $rule, $params); if ($result === false && !$options['allowAny']) { return false; } if ($result === true && $options['allowAny']) { return true; } } return !$options['allowAny']; }
[ "public", "function", "check", "(", "$", "user", ",", "$", "request", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'rules'", "=>", "$", "this", "->", "_defaults", ",", "'allowAny'", "=>", "$", "this", "->", "_allowAny", "]", ";", "$", "options", "+=", "$", "defaults", ";", "if", "(", "empty", "(", "$", "options", "[", "'rules'", "]", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Missing `'rules'` option.\"", ")", ";", "}", "$", "rules", "=", "(", "array", ")", "$", "options", "[", "'rules'", "]", ";", "$", "this", "->", "_error", "=", "[", "]", ";", "$", "params", "=", "array_diff_key", "(", "$", "options", ",", "$", "defaults", ")", ";", "if", "(", "!", "isset", "(", "$", "user", ")", "&&", "is_callable", "(", "$", "this", "->", "_user", ")", ")", "{", "$", "user", "=", "$", "this", "->", "_user", "->", "__invoke", "(", ")", ";", "}", "foreach", "(", "$", "rules", "as", "$", "name", "=>", "$", "rule", ")", "{", "$", "result", "=", "$", "this", "->", "_check", "(", "$", "user", ",", "$", "request", ",", "$", "name", ",", "$", "rule", ",", "$", "params", ")", ";", "if", "(", "$", "result", "===", "false", "&&", "!", "$", "options", "[", "'allowAny'", "]", ")", "{", "return", "false", ";", "}", "if", "(", "$", "result", "===", "true", "&&", "$", "options", "[", "'allowAny'", "]", ")", "{", "return", "true", ";", "}", "}", "return", "!", "$", "options", "[", "'allowAny'", "]", ";", "}" ]
The check method @param mixed $user The user data array that holds all necessary information about the user requesting access. If set to `null`, the default `Rules::_user()` will be used. @param object $request The requested object. @param array $options Options array to pass to the rule closure. @return boolean `true` if access is ok, `false` otherwise.
[ "The", "check", "method" ]
aded70dca872ea9237e3eb709099730348008321
https://github.com/jails/li3_access/blob/aded70dca872ea9237e3eb709099730348008321/extensions/adapter/security/access/Rules.php#L107-L135
241,174
cityware/city-snmp
src/SNMP.php
SNMP.realWalk
public function realWalk($oid, $suffixAsKey = false) { try { $return = $this->_lastResult = $this->_session->walk($oid, $suffixAsKey); } catch (Exception $exc) { $this->close(); throw new Exception("Erro '{$this->_session->getError()}' with execute WALK OID ({$oid}): " . $exc->getMessage()); } return $return; }
php
public function realWalk($oid, $suffixAsKey = false) { try { $return = $this->_lastResult = $this->_session->walk($oid, $suffixAsKey); } catch (Exception $exc) { $this->close(); throw new Exception("Erro '{$this->_session->getError()}' with execute WALK OID ({$oid}): " . $exc->getMessage()); } return $return; }
[ "public", "function", "realWalk", "(", "$", "oid", ",", "$", "suffixAsKey", "=", "false", ")", "{", "try", "{", "$", "return", "=", "$", "this", "->", "_lastResult", "=", "$", "this", "->", "_session", "->", "walk", "(", "$", "oid", ",", "$", "suffixAsKey", ")", ";", "}", "catch", "(", "Exception", "$", "exc", ")", "{", "$", "this", "->", "close", "(", ")", ";", "throw", "new", "Exception", "(", "\"Erro '{$this->_session->getError()}' with execute WALK OID ({$oid}): \"", ".", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "return", ";", "}" ]
Proxy to the snmp2_real_walk command @param string $oid The OID to walk @return array The results of the walk
[ "Proxy", "to", "the", "snmp2_real_walk", "command" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L204-L213
241,175
cityware/city-snmp
src/SNMP.php
SNMP.realWalkToArray
public function realWalkToArray($oid, $suffixAsKey = false) { $arrayData = $this->realWalk($oid, $suffixAsKey); foreach ($arrayData as $_oid => $value) { $this->_lastResult[$_oid] = $this->parseSnmpValue($value); } return $this->_lastResult; }
php
public function realWalkToArray($oid, $suffixAsKey = false) { $arrayData = $this->realWalk($oid, $suffixAsKey); foreach ($arrayData as $_oid => $value) { $this->_lastResult[$_oid] = $this->parseSnmpValue($value); } return $this->_lastResult; }
[ "public", "function", "realWalkToArray", "(", "$", "oid", ",", "$", "suffixAsKey", "=", "false", ")", "{", "$", "arrayData", "=", "$", "this", "->", "realWalk", "(", "$", "oid", ",", "$", "suffixAsKey", ")", ";", "foreach", "(", "$", "arrayData", "as", "$", "_oid", "=>", "$", "value", ")", "{", "$", "this", "->", "_lastResult", "[", "$", "_oid", "]", "=", "$", "this", "->", "parseSnmpValue", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "_lastResult", ";", "}" ]
Proxy to the snmp2_real_walk command return array @param string $oid The OID to walk @return array The results of the walk
[ "Proxy", "to", "the", "snmp2_real_walk", "command", "return", "array" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L221-L230
241,176
cityware/city-snmp
src/SNMP.php
SNMP.realWalk1d
public function realWalk1d($oid) { $arrayData = $this->realWalk($oid); $result = array(); foreach ($arrayData as $_oid => $value) { $oidPrefix = substr($_oid, 0, strrpos($_oid, '.')); if (!isset($result[$oidPrefix])) { $result[$oidPrefix] = Array(); } $aIndexOid = str_replace($oidPrefix . ".", "", $_oid); $result[$oidPrefix][$aIndexOid] = $this->parseSnmpValue($value); } return $result; }
php
public function realWalk1d($oid) { $arrayData = $this->realWalk($oid); $result = array(); foreach ($arrayData as $_oid => $value) { $oidPrefix = substr($_oid, 0, strrpos($_oid, '.')); if (!isset($result[$oidPrefix])) { $result[$oidPrefix] = Array(); } $aIndexOid = str_replace($oidPrefix . ".", "", $_oid); $result[$oidPrefix][$aIndexOid] = $this->parseSnmpValue($value); } return $result; }
[ "public", "function", "realWalk1d", "(", "$", "oid", ")", "{", "$", "arrayData", "=", "$", "this", "->", "realWalk", "(", "$", "oid", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "arrayData", "as", "$", "_oid", "=>", "$", "value", ")", "{", "$", "oidPrefix", "=", "substr", "(", "$", "_oid", ",", "0", ",", "strrpos", "(", "$", "_oid", ",", "'.'", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "result", "[", "$", "oidPrefix", "]", ")", ")", "{", "$", "result", "[", "$", "oidPrefix", "]", "=", "Array", "(", ")", ";", "}", "$", "aIndexOid", "=", "str_replace", "(", "$", "oidPrefix", ".", "\".\"", ",", "\"\"", ",", "$", "_oid", ")", ";", "$", "result", "[", "$", "oidPrefix", "]", "[", "$", "aIndexOid", "]", "=", "$", "this", "->", "parseSnmpValue", "(", "$", "value", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get indexed Real Walk return values @param string $oid @return array
[ "Get", "indexed", "Real", "Walk", "return", "values" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L237-L255
241,177
cityware/city-snmp
src/SNMP.php
SNMP.get
public function get($oid, $preserveKeys = false) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } try { $this->_lastResult = $this->_session->get($oid, $preserveKeys); } catch (Exception $exc) { $this->close(); throw new Exception("Erro '{$this->_session->getError()}' with execute GET OID ({$oid}): " . $exc->getMessage()); } if ($this->_lastResult === false) { $this->close(); throw new Exception('Could not perform walk for OID ' . $oid); } return $this->getCache()->save($oid, $this->parseSnmpValue($this->_lastResult)); }
php
public function get($oid, $preserveKeys = false) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } try { $this->_lastResult = $this->_session->get($oid, $preserveKeys); } catch (Exception $exc) { $this->close(); throw new Exception("Erro '{$this->_session->getError()}' with execute GET OID ({$oid}): " . $exc->getMessage()); } if ($this->_lastResult === false) { $this->close(); throw new Exception('Could not perform walk for OID ' . $oid); } return $this->getCache()->save($oid, $this->parseSnmpValue($this->_lastResult)); }
[ "public", "function", "get", "(", "$", "oid", ",", "$", "preserveKeys", "=", "false", ")", "{", "if", "(", "$", "this", "->", "cache", "(", ")", "&&", "(", "$", "rtn", "=", "$", "this", "->", "getCache", "(", ")", "->", "load", "(", "$", "oid", ")", ")", "!==", "null", ")", "{", "return", "$", "rtn", ";", "}", "try", "{", "$", "this", "->", "_lastResult", "=", "$", "this", "->", "_session", "->", "get", "(", "$", "oid", ",", "$", "preserveKeys", ")", ";", "}", "catch", "(", "Exception", "$", "exc", ")", "{", "$", "this", "->", "close", "(", ")", ";", "throw", "new", "Exception", "(", "\"Erro '{$this->_session->getError()}' with execute GET OID ({$oid}): \"", ".", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "_lastResult", "===", "false", ")", "{", "$", "this", "->", "close", "(", ")", ";", "throw", "new", "Exception", "(", "'Could not perform walk for OID '", ".", "$", "oid", ")", ";", "}", "return", "$", "this", "->", "getCache", "(", ")", "->", "save", "(", "$", "oid", ",", "$", "this", "->", "parseSnmpValue", "(", "$", "this", "->", "_lastResult", ")", ")", ";", "}" ]
Get a single SNMP value @throws \Cityware\SnmpException On *any* SNMP error, warnings are supressed and a generic exception is thrown @param string $oid The OID to get @return mixed The resultant value
[ "Get", "a", "single", "SNMP", "value" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L264-L282
241,178
cityware/city-snmp
src/SNMP.php
SNMP.subOidWalk
public function subOidWalk($oid, $position, $elements = 1) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { $this->close(); throw new Exception('Could not perform walk for OID ' . $oid); } $result = array(); foreach ($this->_lastResult as $_oid => $value) { $oids = explode('.', $_oid); $index = $oids[$position]; for ($pos = $position + 1; $pos < sizeof($oids) && ( $elements == -1 || $pos < $position + $elements ); $pos++) { $index .= '.' . $oids[$pos]; } $result[$index] = $this->parseSnmpValue($value); } return $this->getCache()->save($oid, $result); }
php
public function subOidWalk($oid, $position, $elements = 1) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { $this->close(); throw new Exception('Could not perform walk for OID ' . $oid); } $result = array(); foreach ($this->_lastResult as $_oid => $value) { $oids = explode('.', $_oid); $index = $oids[$position]; for ($pos = $position + 1; $pos < sizeof($oids) && ( $elements == -1 || $pos < $position + $elements ); $pos++) { $index .= '.' . $oids[$pos]; } $result[$index] = $this->parseSnmpValue($value); } return $this->getCache()->save($oid, $result); }
[ "public", "function", "subOidWalk", "(", "$", "oid", ",", "$", "position", ",", "$", "elements", "=", "1", ")", "{", "if", "(", "$", "this", "->", "cache", "(", ")", "&&", "(", "$", "rtn", "=", "$", "this", "->", "getCache", "(", ")", "->", "load", "(", "$", "oid", ")", ")", "!==", "null", ")", "{", "return", "$", "rtn", ";", "}", "$", "this", "->", "_lastResult", "=", "$", "this", "->", "realWalk", "(", "$", "oid", ")", ";", "if", "(", "$", "this", "->", "_lastResult", "===", "false", ")", "{", "$", "this", "->", "close", "(", ")", ";", "throw", "new", "Exception", "(", "'Could not perform walk for OID '", ".", "$", "oid", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_lastResult", "as", "$", "_oid", "=>", "$", "value", ")", "{", "$", "oids", "=", "explode", "(", "'.'", ",", "$", "_oid", ")", ";", "$", "index", "=", "$", "oids", "[", "$", "position", "]", ";", "for", "(", "$", "pos", "=", "$", "position", "+", "1", ";", "$", "pos", "<", "sizeof", "(", "$", "oids", ")", "&&", "(", "$", "elements", "==", "-", "1", "||", "$", "pos", "<", "$", "position", "+", "$", "elements", ")", ";", "$", "pos", "++", ")", "{", "$", "index", ".=", "'.'", ".", "$", "oids", "[", "$", "pos", "]", ";", "}", "$", "result", "[", "$", "index", "]", "=", "$", "this", "->", "parseSnmpValue", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "getCache", "(", ")", "->", "save", "(", "$", "oid", ",", "$", "result", ")", ";", "}" ]
Get indexed SNMP values where the array key is the given position of the OID I.e. the following query with sample results: subOidWalk( '.1.3.6.1.4.1.9.9.23.1.2.1.1.9', 15 ) .1.3.6.1.4.1.9.9.23.1.2.1.1.9.10101.5 = Hex-STRING: 00 00 00 01 .1.3.6.1.4.1.9.9.23.1.2.1.1.9.10105.2 = Hex-STRING: 00 00 00 01 .1.3.6.1.4.1.9.9.23.1.2.1.1.9.10108.4 = Hex-STRING: 00 00 00 01 would yield an array: 10101 => Hex-STRING: 00 00 00 01 10105 => Hex-STRING: 00 00 00 01 10108 => Hex-STRING: 00 00 00 01 subOidWalk( '.1.3.6.1.2.1.17.4.3.1.1', 15, -1 ) .1.3.6.1.2.1.17.4.3.1.1.0.0.136.54.152.12 = Hex-STRING: 00 00 75 33 4E 92 .1.3.6.1.2.1.17.4.3.1.1.8.3.134.58.182.16 = Hex-STRING: 00 00 75 33 4E 93 .1.3.6.1.2.1.17.4.3.1.1.0.4.121.22.55.8 = Hex-STRING: 00 00 75 33 4E 94 would yield an array: [54.152.12] => Hex-STRING: 00 00 75 33 4E 92 [58.182.16] => Hex-STRING: 00 00 75 33 4E 93 [22.55.8] => Hex-STRING: 00 00 75 33 4E 94 @throws \Cityware\SnmpException On *any* SNMP error, warnings are supressed and a generic exception is thrown @param string $oid The OID to walk @param int $position The position of the OID to use as the key @param int $elements Number of additional elements to include in the returned array keys after $position. This defaults to 1 meaning just the requested OID element (see examples above). With -1, retrieves ALL to the end. If there is less elements than $elements, return all availables (no error). @return array The resultant values
[ "Get", "indexed", "SNMP", "values", "where", "the", "array", "key", "is", "the", "given", "position", "of", "the", "OID" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L378-L404
241,179
cityware/city-snmp
src/SNMP.php
SNMP.walkIPv4
public function walkIPv4($oid) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { throw new Exception('Could not perform walk for OID ' . $oid); } $result = array(); foreach ($this->_lastResult as $_oid => $value) { $oids = explode('.', $_oid); $len = count($oids); $result[$oids[$len - 4] . '.' . $oids[$len - 3] . '.' . $oids[$len - 2] . '.' . $oids[$len - 1]] = $this->parseSnmpValue($value); } return $this->getCache()->save($oid, $result); }
php
public function walkIPv4($oid) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { throw new Exception('Could not perform walk for OID ' . $oid); } $result = array(); foreach ($this->_lastResult as $_oid => $value) { $oids = explode('.', $_oid); $len = count($oids); $result[$oids[$len - 4] . '.' . $oids[$len - 3] . '.' . $oids[$len - 2] . '.' . $oids[$len - 1]] = $this->parseSnmpValue($value); } return $this->getCache()->save($oid, $result); }
[ "public", "function", "walkIPv4", "(", "$", "oid", ")", "{", "if", "(", "$", "this", "->", "cache", "(", ")", "&&", "(", "$", "rtn", "=", "$", "this", "->", "getCache", "(", ")", "->", "load", "(", "$", "oid", ")", ")", "!==", "null", ")", "{", "return", "$", "rtn", ";", "}", "$", "this", "->", "_lastResult", "=", "$", "this", "->", "realWalk", "(", "$", "oid", ")", ";", "if", "(", "$", "this", "->", "_lastResult", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Could not perform walk for OID '", ".", "$", "oid", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_lastResult", "as", "$", "_oid", "=>", "$", "value", ")", "{", "$", "oids", "=", "explode", "(", "'.'", ",", "$", "_oid", ")", ";", "$", "len", "=", "count", "(", "$", "oids", ")", ";", "$", "result", "[", "$", "oids", "[", "$", "len", "-", "4", "]", ".", "'.'", ".", "$", "oids", "[", "$", "len", "-", "3", "]", ".", "'.'", ".", "$", "oids", "[", "$", "len", "-", "2", "]", ".", "'.'", ".", "$", "oids", "[", "$", "len", "-", "1", "]", "]", "=", "$", "this", "->", "parseSnmpValue", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "getCache", "(", ")", "->", "save", "(", "$", "oid", ",", "$", "result", ")", ";", "}" ]
Get indexed SNMP values where they are indexed by IPv4 addresses I.e. the following query with sample results: subOidWalk( '.1.3.6.1.2.1.15.3.1.1. ) .1.3.6.1.2.1.15.3.1.1.10.20.30.4 = IpAddress: 192.168.10.10 ... would yield an array: [10.20.30.4] => "192.168.10.10" .... @throws \Cityware\SnmpException On *any* SNMP error, warnings are supressed and a generic exception is thrown @param string $oid The OID to walk @return array The resultant values
[ "Get", "indexed", "SNMP", "values", "where", "they", "are", "indexed", "by", "IPv4", "addresses" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L426-L448
241,180
cityware/city-snmp
src/SNMP.php
SNMP.parseSnmpValue
public function parseSnmpValue($v) { // first, rule out an empty string if ($v == '""' || $v == '') { return ""; } $type = substr($v, 0, strpos($v, ':')); $value = trim(substr($v, strpos($v, ':') + 1)); switch ($type) { case 'STRING': if (substr($value, 0, 1) == '"') { $rtn = (string) trim(substr(substr($value, 1), 0, -1)); } else { $rtn = (string) $value; } break; case 'INTEGER': if (!is_numeric($value)) { // find the first digit and offset the string to that point // just in case there is some mib strangeness going on preg_match('/\d/', $value, $m, PREG_OFFSET_CAPTURE); $rtn = (int) substr($value, $m[0][1]); } else { $rtn = (int) $value; } break; case 'Counter32': $rtn = (int) $value; break; case 'Counter64': $rtn = (int) $value; break; case 'Gauge32': $rtn = (int) $value; break; case 'Hex-STRING': $rtn = (string) implode('', explode(' ', preg_replace('/[^A-Fa-f0-9]/', '', $value))); break; case 'IpAddress': $rtn = (string) $value; break; case 'OID': $rtn = (string) $value; break; case 'Timeticks': $rtn = (int) substr($value, 1, strrpos($value, ')') - 1); break; default: throw new Exception("ERR: Unhandled SNMP return type: $type\n"); } return $rtn; }
php
public function parseSnmpValue($v) { // first, rule out an empty string if ($v == '""' || $v == '') { return ""; } $type = substr($v, 0, strpos($v, ':')); $value = trim(substr($v, strpos($v, ':') + 1)); switch ($type) { case 'STRING': if (substr($value, 0, 1) == '"') { $rtn = (string) trim(substr(substr($value, 1), 0, -1)); } else { $rtn = (string) $value; } break; case 'INTEGER': if (!is_numeric($value)) { // find the first digit and offset the string to that point // just in case there is some mib strangeness going on preg_match('/\d/', $value, $m, PREG_OFFSET_CAPTURE); $rtn = (int) substr($value, $m[0][1]); } else { $rtn = (int) $value; } break; case 'Counter32': $rtn = (int) $value; break; case 'Counter64': $rtn = (int) $value; break; case 'Gauge32': $rtn = (int) $value; break; case 'Hex-STRING': $rtn = (string) implode('', explode(' ', preg_replace('/[^A-Fa-f0-9]/', '', $value))); break; case 'IpAddress': $rtn = (string) $value; break; case 'OID': $rtn = (string) $value; break; case 'Timeticks': $rtn = (int) substr($value, 1, strrpos($value, ')') - 1); break; default: throw new Exception("ERR: Unhandled SNMP return type: $type\n"); } return $rtn; }
[ "public", "function", "parseSnmpValue", "(", "$", "v", ")", "{", "// first, rule out an empty string", "if", "(", "$", "v", "==", "'\"\"'", "||", "$", "v", "==", "''", ")", "{", "return", "\"\"", ";", "}", "$", "type", "=", "substr", "(", "$", "v", ",", "0", ",", "strpos", "(", "$", "v", ",", "':'", ")", ")", ";", "$", "value", "=", "trim", "(", "substr", "(", "$", "v", ",", "strpos", "(", "$", "v", ",", "':'", ")", "+", "1", ")", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'STRING'", ":", "if", "(", "substr", "(", "$", "value", ",", "0", ",", "1", ")", "==", "'\"'", ")", "{", "$", "rtn", "=", "(", "string", ")", "trim", "(", "substr", "(", "substr", "(", "$", "value", ",", "1", ")", ",", "0", ",", "-", "1", ")", ")", ";", "}", "else", "{", "$", "rtn", "=", "(", "string", ")", "$", "value", ";", "}", "break", ";", "case", "'INTEGER'", ":", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "// find the first digit and offset the string to that point", "// just in case there is some mib strangeness going on", "preg_match", "(", "'/\\d/'", ",", "$", "value", ",", "$", "m", ",", "PREG_OFFSET_CAPTURE", ")", ";", "$", "rtn", "=", "(", "int", ")", "substr", "(", "$", "value", ",", "$", "m", "[", "0", "]", "[", "1", "]", ")", ";", "}", "else", "{", "$", "rtn", "=", "(", "int", ")", "$", "value", ";", "}", "break", ";", "case", "'Counter32'", ":", "$", "rtn", "=", "(", "int", ")", "$", "value", ";", "break", ";", "case", "'Counter64'", ":", "$", "rtn", "=", "(", "int", ")", "$", "value", ";", "break", ";", "case", "'Gauge32'", ":", "$", "rtn", "=", "(", "int", ")", "$", "value", ";", "break", ";", "case", "'Hex-STRING'", ":", "$", "rtn", "=", "(", "string", ")", "implode", "(", "''", ",", "explode", "(", "' '", ",", "preg_replace", "(", "'/[^A-Fa-f0-9]/'", ",", "''", ",", "$", "value", ")", ")", ")", ";", "break", ";", "case", "'IpAddress'", ":", "$", "rtn", "=", "(", "string", ")", "$", "value", ";", "break", ";", "case", "'OID'", ":", "$", "rtn", "=", "(", "string", ")", "$", "value", ";", "break", ";", "case", "'Timeticks'", ":", "$", "rtn", "=", "(", "int", ")", "substr", "(", "$", "value", ",", "1", ",", "strrpos", "(", "$", "value", ",", "')'", ")", "-", "1", ")", ";", "break", ";", "default", ":", "throw", "new", "Exception", "(", "\"ERR: Unhandled SNMP return type: $type\\n\"", ")", ";", "}", "return", "$", "rtn", ";", "}" ]
Parse the result of an SNMP query into a PHP type For example, [STRING: "blah"] is parsed to a PHP string containing: blah @param string $v The value to parse @return mixed The parsed value @throws Exception
[ "Parse", "the", "result", "of", "an", "SNMP", "query", "into", "a", "PHP", "type" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L459-L521
241,181
cityware/city-snmp
src/SNMP.php
SNMP.setHost
public function setHost($h) { $this->_host = $h; // clear the temporary result cache and last result $this->_lastResult = null; unset($this->_resultCache); $this->_resultCache = array(); return $this; }
php
public function setHost($h) { $this->_host = $h; // clear the temporary result cache and last result $this->_lastResult = null; unset($this->_resultCache); $this->_resultCache = array(); return $this; }
[ "public", "function", "setHost", "(", "$", "h", ")", "{", "$", "this", "->", "_host", "=", "$", "h", ";", "// clear the temporary result cache and last result", "$", "this", "->", "_lastResult", "=", "null", ";", "unset", "(", "$", "this", "->", "_resultCache", ")", ";", "$", "this", "->", "_resultCache", "=", "array", "(", ")", ";", "return", "$", "this", ";", "}" ]
Sets the target host for SNMP queries. @param string $h The target host for SNMP queries. @return \Cityware\Snmp\SNMP An instance of $this (for fluent interfaces)
[ "Sets", "the", "target", "host", "for", "SNMP", "queries", "." ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L722-L731
241,182
cityware/city-snmp
src/SNMP.php
SNMP.getCache
public function getCache() { if ($this->_cache === null) { $this->_cache = new \Cityware\Snmp\Cache\Basic(); } return $this->_cache; }
php
public function getCache() { if ($this->_cache === null) { $this->_cache = new \Cityware\Snmp\Cache\Basic(); } return $this->_cache; }
[ "public", "function", "getCache", "(", ")", "{", "if", "(", "$", "this", "->", "_cache", "===", "null", ")", "{", "$", "this", "->", "_cache", "=", "new", "\\", "Cityware", "\\", "Snmp", "\\", "Cache", "\\", "Basic", "(", ")", ";", "}", "return", "$", "this", "->", "_cache", ";", "}" ]
Get the cache in use (or create a Cache\Basic instance We kind of mandate the use of a cache as the code is written with a cache in mind. You are free to disable it via disableCache() but your machines may be hammered! We would suggest disableCache() / enableCache() used in pairs only when really needed. @return \Cityware\Snmp\Cache The cache object
[ "Get", "the", "cache", "in", "use", "(", "or", "create", "a", "Cache", "\\", "Basic", "instance" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L870-L875
241,183
cityware/city-snmp
src/SNMP.php
SNMP.useExtension
public function useExtension($mib, $args) { $mib = '\\Cityware\\Snmp\\MIBS\\' . str_replace('_', '\\', $mib); $m = new $mib(); $m->setSNMP($this); return $m; }
php
public function useExtension($mib, $args) { $mib = '\\Cityware\\Snmp\\MIBS\\' . str_replace('_', '\\', $mib); $m = new $mib(); $m->setSNMP($this); return $m; }
[ "public", "function", "useExtension", "(", "$", "mib", ",", "$", "args", ")", "{", "$", "mib", "=", "'\\\\Cityware\\\\Snmp\\\\MIBS\\\\'", ".", "str_replace", "(", "'_'", ",", "'\\\\'", ",", "$", "mib", ")", ";", "$", "m", "=", "new", "$", "mib", "(", ")", ";", "$", "m", "->", "setSNMP", "(", "$", "this", ")", ";", "return", "$", "m", ";", "}" ]
This is the MIB Extension magic Calling $this->useXXX_YYY_ZZZ()->fn() will instantiate an extension MIB class is the given name and this $this SNMP instance and then call fn(). See the examples for more information. @param string $mib The extension class to use @param array $args @return \Cityware\Snmp\MIBS
[ "This", "is", "the", "MIB", "Extension", "magic" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L905-L910
241,184
cityware/city-snmp
src/SNMP.php
SNMP.subOidWalkLong
public function subOidWalkLong($oid, $positionS, $positionE) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { throw new Exception('Could not perform walk for OID ' . $oid); } $result = array(); foreach ($this->_lastResult as $_oid => $value) { $oids = explode('.', $_oid); $oidKey = ''; for ($i = $positionS; $i <= $positionE; $i++) { $oidKey .= $oids[$i] . '.'; } $result[$oidKey] = $this->parseSnmpValue($value); } return $this->getCache()->save($oid, $result); }
php
public function subOidWalkLong($oid, $positionS, $positionE) { if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) { return $rtn; } $this->_lastResult = $this->realWalk($oid); if ($this->_lastResult === false) { throw new Exception('Could not perform walk for OID ' . $oid); } $result = array(); foreach ($this->_lastResult as $_oid => $value) { $oids = explode('.', $_oid); $oidKey = ''; for ($i = $positionS; $i <= $positionE; $i++) { $oidKey .= $oids[$i] . '.'; } $result[$oidKey] = $this->parseSnmpValue($value); } return $this->getCache()->save($oid, $result); }
[ "public", "function", "subOidWalkLong", "(", "$", "oid", ",", "$", "positionS", ",", "$", "positionE", ")", "{", "if", "(", "$", "this", "->", "cache", "(", ")", "&&", "(", "$", "rtn", "=", "$", "this", "->", "getCache", "(", ")", "->", "load", "(", "$", "oid", ")", ")", "!==", "null", ")", "{", "return", "$", "rtn", ";", "}", "$", "this", "->", "_lastResult", "=", "$", "this", "->", "realWalk", "(", "$", "oid", ")", ";", "if", "(", "$", "this", "->", "_lastResult", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Could not perform walk for OID '", ".", "$", "oid", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_lastResult", "as", "$", "_oid", "=>", "$", "value", ")", "{", "$", "oids", "=", "explode", "(", "'.'", ",", "$", "_oid", ")", ";", "$", "oidKey", "=", "''", ";", "for", "(", "$", "i", "=", "$", "positionS", ";", "$", "i", "<=", "$", "positionE", ";", "$", "i", "++", ")", "{", "$", "oidKey", ".=", "$", "oids", "[", "$", "i", "]", ".", "'.'", ";", "}", "$", "result", "[", "$", "oidKey", "]", "=", "$", "this", "->", "parseSnmpValue", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "getCache", "(", ")", "->", "save", "(", "$", "oid", ",", "$", "result", ")", ";", "}" ]
Get indexed SNMP values where the array key is spread over a number of OID positions @throws \Cityware\SnmpException On *any* SNMP error, warnings are supressed and a generic exception is thrown @param string $oid The OID to walk @param int $positionS The start position of the OID to use as the key @param int $positionE The end position of the OID to use as the key @return array The resultant values
[ "Get", "indexed", "SNMP", "values", "where", "the", "array", "key", "is", "spread", "over", "a", "number", "of", "OID", "positions" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/SNMP.php#L928-L953
241,185
vivait/ScrutinizerFormatter
src/Vivait/ScrutinizerFormatterExtension/Extension.php
Extension.addFormatter
protected function addFormatter(ServiceContainer $container, $name, $class) { $container->set( 'formatter.formatters.' . $name, function (ServiceContainer $c) use ($class) { $c->set('formatter.presenter', new StringPresenter($c->get('formatter.presenter.differ'))); /** @var ServiceContainer $c */ return new $class( $c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats') ); } ); }
php
protected function addFormatter(ServiceContainer $container, $name, $class) { $container->set( 'formatter.formatters.' . $name, function (ServiceContainer $c) use ($class) { $c->set('formatter.presenter', new StringPresenter($c->get('formatter.presenter.differ'))); /** @var ServiceContainer $c */ return new $class( $c->get('formatter.presenter'), $c->get('console.io'), $c->get('event_dispatcher.listeners.stats') ); } ); }
[ "protected", "function", "addFormatter", "(", "ServiceContainer", "$", "container", ",", "$", "name", ",", "$", "class", ")", "{", "$", "container", "->", "set", "(", "'formatter.formatters.'", ".", "$", "name", ",", "function", "(", "ServiceContainer", "$", "c", ")", "use", "(", "$", "class", ")", "{", "$", "c", "->", "set", "(", "'formatter.presenter'", ",", "new", "StringPresenter", "(", "$", "c", "->", "get", "(", "'formatter.presenter.differ'", ")", ")", ")", ";", "/** @var ServiceContainer $c */", "return", "new", "$", "class", "(", "$", "c", "->", "get", "(", "'formatter.presenter'", ")", ",", "$", "c", "->", "get", "(", "'console.io'", ")", ",", "$", "c", "->", "get", "(", "'event_dispatcher.listeners.stats'", ")", ")", ";", "}", ")", ";", "}" ]
Add a formatter to the service container @param ServiceContainer $container @param string $name @param string $class
[ "Add", "a", "formatter", "to", "the", "service", "container" ]
6e6de9c4351c350cc31938b43cc5efd512cef4b7
https://github.com/vivait/ScrutinizerFormatter/blob/6e6de9c4351c350cc31938b43cc5efd512cef4b7/src/Vivait/ScrutinizerFormatterExtension/Extension.php#L43-L58
241,186
NamelessCoder/gizzle-git-plugins
src/GizzlePlugins/PluginList.php
PluginList.getPluginClassNames
public function getPluginClassNames() { $plugins = array(); if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CheckoutPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CheckoutPlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PullPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PullPlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CommitPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CommitPlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PushPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PushPlugin'; } return $plugins; }
php
public function getPluginClassNames() { $plugins = array(); if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CheckoutPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CheckoutPlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PullPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PullPlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CommitPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\CommitPlugin'; } if (TRUE === $this->isEnabled('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PushPlugin')) { $plugins[] = 'NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\PushPlugin'; } return $plugins; }
[ "public", "function", "getPluginClassNames", "(", ")", "{", "$", "plugins", "=", "array", "(", ")", ";", "if", "(", "TRUE", "===", "$", "this", "->", "isEnabled", "(", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\ClonePlugin'", ")", ")", "{", "$", "plugins", "[", "]", "=", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\ClonePlugin'", ";", "}", "if", "(", "TRUE", "===", "$", "this", "->", "isEnabled", "(", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\CheckoutPlugin'", ")", ")", "{", "$", "plugins", "[", "]", "=", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\CheckoutPlugin'", ";", "}", "if", "(", "TRUE", "===", "$", "this", "->", "isEnabled", "(", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\PullPlugin'", ")", ")", "{", "$", "plugins", "[", "]", "=", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\PullPlugin'", ";", "}", "if", "(", "TRUE", "===", "$", "this", "->", "isEnabled", "(", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\CommitPlugin'", ")", ")", "{", "$", "plugins", "[", "]", "=", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\CommitPlugin'", ";", "}", "if", "(", "TRUE", "===", "$", "this", "->", "isEnabled", "(", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\PushPlugin'", ")", ")", "{", "$", "plugins", "[", "]", "=", "'NamelessCoder\\\\GizzleGitPlugins\\\\GizzlePlugins\\\\PushPlugin'", ";", "}", "return", "$", "plugins", ";", "}" ]
Get all class names of plugins delivered from implementer package. @return string[]
[ "Get", "all", "class", "names", "of", "plugins", "delivered", "from", "implementer", "package", "." ]
7c476db81b58bed7dc769866491b2adb6ddb19bb
https://github.com/NamelessCoder/gizzle-git-plugins/blob/7c476db81b58bed7dc769866491b2adb6ddb19bb/src/GizzlePlugins/PluginList.php#L41-L59
241,187
ushios/elasticsearch-bundle
DependencyInjection/UshiosElasticSearchExtension.php
UshiosElasticSearchExtension.clientSettings
protected function clientSettings(array $configs, ContainerBuilder $container) { foreach($configs as $key => $infos){ $clientDefinition = new Definition(); $clientDefinition->setClass($infos['class']); $hostsSettings = $this->hostSettings($infos); $logPathSettings = $this->logPathSettings($infos); $logLevelSettings = $this->logLevelSettings($infos); $options = array( 'hosts' => $hostsSettings, 'logPath' => $logPathSettings, 'logLevel' => $logLevelSettings ); $clientDefinition->setArguments(array($options)); $clientServiceId = 'ushios_elastic_search_client'; if ($key == 'default'){ $container->setDefinition($clientServiceId, $clientDefinition); $clientServiceId = $clientServiceId.'.default'; }else{ $clientServiceId = $clientServiceId.'.'.$key; } $container->setDefinition($clientServiceId, $clientDefinition); } }
php
protected function clientSettings(array $configs, ContainerBuilder $container) { foreach($configs as $key => $infos){ $clientDefinition = new Definition(); $clientDefinition->setClass($infos['class']); $hostsSettings = $this->hostSettings($infos); $logPathSettings = $this->logPathSettings($infos); $logLevelSettings = $this->logLevelSettings($infos); $options = array( 'hosts' => $hostsSettings, 'logPath' => $logPathSettings, 'logLevel' => $logLevelSettings ); $clientDefinition->setArguments(array($options)); $clientServiceId = 'ushios_elastic_search_client'; if ($key == 'default'){ $container->setDefinition($clientServiceId, $clientDefinition); $clientServiceId = $clientServiceId.'.default'; }else{ $clientServiceId = $clientServiceId.'.'.$key; } $container->setDefinition($clientServiceId, $clientDefinition); } }
[ "protected", "function", "clientSettings", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "foreach", "(", "$", "configs", "as", "$", "key", "=>", "$", "infos", ")", "{", "$", "clientDefinition", "=", "new", "Definition", "(", ")", ";", "$", "clientDefinition", "->", "setClass", "(", "$", "infos", "[", "'class'", "]", ")", ";", "$", "hostsSettings", "=", "$", "this", "->", "hostSettings", "(", "$", "infos", ")", ";", "$", "logPathSettings", "=", "$", "this", "->", "logPathSettings", "(", "$", "infos", ")", ";", "$", "logLevelSettings", "=", "$", "this", "->", "logLevelSettings", "(", "$", "infos", ")", ";", "$", "options", "=", "array", "(", "'hosts'", "=>", "$", "hostsSettings", ",", "'logPath'", "=>", "$", "logPathSettings", ",", "'logLevel'", "=>", "$", "logLevelSettings", ")", ";", "$", "clientDefinition", "->", "setArguments", "(", "array", "(", "$", "options", ")", ")", ";", "$", "clientServiceId", "=", "'ushios_elastic_search_client'", ";", "if", "(", "$", "key", "==", "'default'", ")", "{", "$", "container", "->", "setDefinition", "(", "$", "clientServiceId", ",", "$", "clientDefinition", ")", ";", "$", "clientServiceId", "=", "$", "clientServiceId", ".", "'.default'", ";", "}", "else", "{", "$", "clientServiceId", "=", "$", "clientServiceId", ".", "'.'", ".", "$", "key", ";", "}", "$", "container", "->", "setDefinition", "(", "$", "clientServiceId", ",", "$", "clientDefinition", ")", ";", "}", "}" ]
Reading the config.yml for aws-sdk client. @param array $configs @param ContainerBuilder $container
[ "Reading", "the", "config", ".", "yml", "for", "aws", "-", "sdk", "client", "." ]
4524370dc59c24b53636ca57f39f66ecdb93e89c
https://github.com/ushios/elasticsearch-bundle/blob/4524370dc59c24b53636ca57f39f66ecdb93e89c/DependencyInjection/UshiosElasticSearchExtension.php#L40-L68
241,188
marando/phpSOFA
src/Marando/IAU/iauApcg.php
iauApcg.Apcg
public static function Apcg($date1, $date2, array $ebpv, array $ehp, iauASTROM &$astrom) { /* Geocentric observer */ $pv = [ [ 0.0, 0.0, 0.0], [ 0.0, 0.0, 0.0]]; /* Compute the star-independent astrometry parameters. */ IAU::Apcs($date1, $date2, $pv, $ebpv, $ehp, $astrom); /* Finished. */ }
php
public static function Apcg($date1, $date2, array $ebpv, array $ehp, iauASTROM &$astrom) { /* Geocentric observer */ $pv = [ [ 0.0, 0.0, 0.0], [ 0.0, 0.0, 0.0]]; /* Compute the star-independent astrometry parameters. */ IAU::Apcs($date1, $date2, $pv, $ebpv, $ehp, $astrom); /* Finished. */ }
[ "public", "static", "function", "Apcg", "(", "$", "date1", ",", "$", "date2", ",", "array", "$", "ebpv", ",", "array", "$", "ehp", ",", "iauASTROM", "&", "$", "astrom", ")", "{", "/* Geocentric observer */", "$", "pv", "=", "[", "[", "0.0", ",", "0.0", ",", "0.0", "]", ",", "[", "0.0", ",", "0.0", ",", "0.0", "]", "]", ";", "/* Compute the star-independent astrometry parameters. */", "IAU", "::", "Apcs", "(", "$", "date1", ",", "$", "date2", ",", "$", "pv", ",", "$", "ebpv", ",", "$", "ehp", ",", "$", "astrom", ")", ";", "/* Finished. */", "}" ]
- - - - - - - - i a u A p c g - - - - - - - - For a geocentric observer, prepare star-independent astrometry parameters for transformations between ICRS and GCRS coordinates. The Earth ephemeris is supplied by the caller. The parameters produced by this function are required in the parallax, light deflection and aberration parts of the astrometric transformation chain. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: date1 double TDB as a 2-part... date2 double ...Julian Date (Note 1) ebpv double[2][3] Earth barycentric pos/vel (au, au/day) ehp double[3] Earth heliocentric position (au) Returned: astrom iauASTROM* star-independent astrometry parameters: pmt double PM time interval (SSB, Julian years) eb double[3] SSB to observer (vector, au) eh double[3] Sun to observer (unit vector) em double distance from Sun to observer (au) v double[3] barycentric observer velocity (vector, c) bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor bpn double[3][3] bias-precession-nutation matrix along double unchanged xpl double unchanged ypl double unchanged sphi double unchanged cphi double unchanged diurab double unchanged eral double unchanged refa double unchanged refb double unchanged Notes: 1) The TDB date date1+date2 is a Julian Date, apportioned in any convenient way between the two arguments. For example, JD(TDB)=2450123.7 could be expressed in any of these ways, among others: date1 date2 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable. The J2000 method is best matched to the way the argument is handled internally and will deliver the optimum resolution. The MJD method and the date & time methods are both good compromises between resolution and convenience. For most applications of this function the choice will not be at all critical. TT can be used instead of TDB without any significant impact on accuracy. 2) All the vectors are with respect to BCRS axes. 3) This is one of several functions that inserts into the astrom structure star-independent parameters needed for the chain of astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed. The various functions support different classes of observer and portions of the transformation chain: functions observer transformation iauApcg iauApcg13 geocentric ICRS <-> GCRS iauApci iauApci13 terrestrial ICRS <-> CIRS iauApco iauApco13 terrestrial ICRS <-> observed iauApcs iauApcs13 space ICRS <-> GCRS iauAper iauAper13 terrestrial update Earth rotation iauApio iauApio13 terrestrial CIRS <-> observed Those with names ending in "13" use contemporary SOFA models to compute the various ephemerides. The others accept ephemerides supplied by the caller. The transformation from ICRS to GCRS covers space motion, parallax, light deflection, and aberration. From GCRS to CIRS comprises frame bias and precession-nutation. From CIRS to observed takes account of Earth rotation, polar motion, diurnal aberration and parallax (unless subsumed into the ICRS <-> GCRS transformation), and atmospheric refraction. 4) The context structure astrom produced by this function is used by iauAtciq* and iauAticq*. Called: iauApcs astrometry parameters, ICRS-GCRS, space observer This revision: 2013 October 9 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "p", "c", "g", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauApcg.php#L117-L128
241,189
gossi/trixionary
src/domain/base/GroupDomainTrait.php
GroupDomainTrait.doRemoveSkills
protected function doRemoveSkills(Group $model, $data) { $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Skill'; } else { $related = SkillQuery::create()->findOneById($entry['id']); $model->removeSkill($related); } } if (count($errors) > 0) { return new ErrorsException($errors); } }
php
protected function doRemoveSkills(Group $model, $data) { $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Skill'; } else { $related = SkillQuery::create()->findOneById($entry['id']); $model->removeSkill($related); } } if (count($errors) > 0) { return new ErrorsException($errors); } }
[ "protected", "function", "doRemoveSkills", "(", "Group", "$", "model", ",", "$", "data", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "entry", ")", "{", "if", "(", "!", "isset", "(", "$", "entry", "[", "'id'", "]", ")", ")", "{", "$", "errors", "[", "]", "=", "'Missing id for Skill'", ";", "}", "else", "{", "$", "related", "=", "SkillQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "entry", "[", "'id'", "]", ")", ";", "$", "model", "->", "removeSkill", "(", "$", "related", ")", ";", "}", "}", "if", "(", "count", "(", "$", "errors", ")", ">", "0", ")", "{", "return", "new", "ErrorsException", "(", "$", "errors", ")", ";", "}", "}" ]
Interal mechanism to remove Skills from Group @param Group $model @param mixed $data
[ "Interal", "mechanism", "to", "remove", "Skills", "from", "Group" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/GroupDomainTrait.php#L430-L444
241,190
gossi/trixionary
src/domain/base/GroupDomainTrait.php
GroupDomainTrait.doUpdateSkills
protected function doUpdateSkills(Group $model, $data) { // remove all relationships before SkillGroupQuery::create()->filterByGroup($model)->delete(); // add them $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Skill'; } else { $related = SkillQuery::create()->findOneById($entry['id']); $model->addSkill($related); } } if (count($errors) > 0) { throw new ErrorsException($errors); } }
php
protected function doUpdateSkills(Group $model, $data) { // remove all relationships before SkillGroupQuery::create()->filterByGroup($model)->delete(); // add them $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Skill'; } else { $related = SkillQuery::create()->findOneById($entry['id']); $model->addSkill($related); } } if (count($errors) > 0) { throw new ErrorsException($errors); } }
[ "protected", "function", "doUpdateSkills", "(", "Group", "$", "model", ",", "$", "data", ")", "{", "// remove all relationships before", "SkillGroupQuery", "::", "create", "(", ")", "->", "filterByGroup", "(", "$", "model", ")", "->", "delete", "(", ")", ";", "// add them", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "entry", ")", "{", "if", "(", "!", "isset", "(", "$", "entry", "[", "'id'", "]", ")", ")", "{", "$", "errors", "[", "]", "=", "'Missing id for Skill'", ";", "}", "else", "{", "$", "related", "=", "SkillQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "entry", "[", "'id'", "]", ")", ";", "$", "model", "->", "addSkill", "(", "$", "related", ")", ";", "}", "}", "if", "(", "count", "(", "$", "errors", ")", ">", "0", ")", "{", "throw", "new", "ErrorsException", "(", "$", "errors", ")", ";", "}", "}" ]
Internal update mechanism of Skills on Group @param Group $model @param mixed $data
[ "Internal", "update", "mechanism", "of", "Skills", "on", "Group" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/GroupDomainTrait.php#L468-L486
241,191
crayner/symfony-form
Util/FormErrorsParser.php
FormErrorsParser.realParseErrors
private function realParseErrors(FormInterface $form, array &$results) { $errors = $form->getErrors(); if (count($errors) > 0) { $config = $form->getConfig(); $name = $form->getName(); $label = $config->getOption('label'); $translation = $this->getTranslationDomain($form); if (empty($label)) { $label = ucfirst(trim(strtolower(preg_replace(array('/([A-Z])/', '/[_\s]+/'), array('_$1', ' '), $name)))); } $results[] = array( 'name' => $name, 'label' => $label, 'errors' => $errors, 'translation' => $translation, ); } $children = $form->all(); if (count($children) > 0) { foreach ($children as $child) { if ($child instanceof FormInterface) { $this->realParseErrors($child, $results); } } } return $results; }
php
private function realParseErrors(FormInterface $form, array &$results) { $errors = $form->getErrors(); if (count($errors) > 0) { $config = $form->getConfig(); $name = $form->getName(); $label = $config->getOption('label'); $translation = $this->getTranslationDomain($form); if (empty($label)) { $label = ucfirst(trim(strtolower(preg_replace(array('/([A-Z])/', '/[_\s]+/'), array('_$1', ' '), $name)))); } $results[] = array( 'name' => $name, 'label' => $label, 'errors' => $errors, 'translation' => $translation, ); } $children = $form->all(); if (count($children) > 0) { foreach ($children as $child) { if ($child instanceof FormInterface) { $this->realParseErrors($child, $results); } } } return $results; }
[ "private", "function", "realParseErrors", "(", "FormInterface", "$", "form", ",", "array", "&", "$", "results", ")", "{", "$", "errors", "=", "$", "form", "->", "getErrors", "(", ")", ";", "if", "(", "count", "(", "$", "errors", ")", ">", "0", ")", "{", "$", "config", "=", "$", "form", "->", "getConfig", "(", ")", ";", "$", "name", "=", "$", "form", "->", "getName", "(", ")", ";", "$", "label", "=", "$", "config", "->", "getOption", "(", "'label'", ")", ";", "$", "translation", "=", "$", "this", "->", "getTranslationDomain", "(", "$", "form", ")", ";", "if", "(", "empty", "(", "$", "label", ")", ")", "{", "$", "label", "=", "ucfirst", "(", "trim", "(", "strtolower", "(", "preg_replace", "(", "array", "(", "'/([A-Z])/'", ",", "'/[_\\s]+/'", ")", ",", "array", "(", "'_$1'", ",", "' '", ")", ",", "$", "name", ")", ")", ")", ")", ";", "}", "$", "results", "[", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'label'", "=>", "$", "label", ",", "'errors'", "=>", "$", "errors", ",", "'translation'", "=>", "$", "translation", ",", ")", ";", "}", "$", "children", "=", "$", "form", "->", "all", "(", ")", ";", "if", "(", "count", "(", "$", "children", ")", ">", "0", ")", "{", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", "instanceof", "FormInterface", ")", "{", "$", "this", "->", "realParseErrors", "(", "$", "child", ",", "$", "results", ")", ";", "}", "}", "}", "return", "$", "results", ";", "}" ]
This does the actual job. Method travels through all levels of form recursively and gathers errors. @param FormInterface $form @param array &$results @return array
[ "This", "does", "the", "actual", "job", ".", "Method", "travels", "through", "all", "levels", "of", "form", "recursively", "and", "gathers", "errors", "." ]
d9fb4f01265ffbcbc74cf4e2adebf99da359c8c2
https://github.com/crayner/symfony-form/blob/d9fb4f01265ffbcbc74cf4e2adebf99da359c8c2/Util/FormErrorsParser.php#L51-L87
241,192
crayner/symfony-form
Util/FormErrorsParser.php
FormErrorsParser.getTranslationDomain
private function getTranslationDomain(FormInterface $form) { $translation = $form->getConfig()->getOption('translation_domain'); if (empty($translation)) { $parent = $form->getParent(); if (empty($parent)) $translation = 'messages'; while (empty($translation)) { $translation = $parent->getConfig()->getOption('translation_domain'); $parent = $parent->getParent(); if (! $parent instanceof FormInterface && empty($translation)) $translation = 'messages'; } } return $translation = $translation === 'messages' ? null : $translation; // Allow the Symfony Default setting to be used by returning null. }
php
private function getTranslationDomain(FormInterface $form) { $translation = $form->getConfig()->getOption('translation_domain'); if (empty($translation)) { $parent = $form->getParent(); if (empty($parent)) $translation = 'messages'; while (empty($translation)) { $translation = $parent->getConfig()->getOption('translation_domain'); $parent = $parent->getParent(); if (! $parent instanceof FormInterface && empty($translation)) $translation = 'messages'; } } return $translation = $translation === 'messages' ? null : $translation; // Allow the Symfony Default setting to be used by returning null. }
[ "private", "function", "getTranslationDomain", "(", "FormInterface", "$", "form", ")", "{", "$", "translation", "=", "$", "form", "->", "getConfig", "(", ")", "->", "getOption", "(", "'translation_domain'", ")", ";", "if", "(", "empty", "(", "$", "translation", ")", ")", "{", "$", "parent", "=", "$", "form", "->", "getParent", "(", ")", ";", "if", "(", "empty", "(", "$", "parent", ")", ")", "$", "translation", "=", "'messages'", ";", "while", "(", "empty", "(", "$", "translation", ")", ")", "{", "$", "translation", "=", "$", "parent", "->", "getConfig", "(", ")", "->", "getOption", "(", "'translation_domain'", ")", ";", "$", "parent", "=", "$", "parent", "->", "getParent", "(", ")", ";", "if", "(", "!", "$", "parent", "instanceof", "FormInterface", "&&", "empty", "(", "$", "translation", ")", ")", "$", "translation", "=", "'messages'", ";", "}", "}", "return", "$", "translation", "=", "$", "translation", "===", "'messages'", "?", "null", ":", "$", "translation", ";", "// Allow the Symfony Default setting to be used by returning null.", "}" ]
Find the Translation Domain. Needs to be done for each element as sub forms or elements could have different translation domains. @param FormInterface $form @return string
[ "Find", "the", "Translation", "Domain", "." ]
d9fb4f01265ffbcbc74cf4e2adebf99da359c8c2
https://github.com/crayner/symfony-form/blob/d9fb4f01265ffbcbc74cf4e2adebf99da359c8c2/Util/FormErrorsParser.php#L98-L118
241,193
eix/core
src/php/main/Eix/Services/Data/Entity.php
Entity.addFieldValidators
public function addFieldValidators(array $fieldValidators) { foreach ($fieldValidators as $fieldName => $validators) { $this->fieldValidators[$fieldName] = $validators; } }
php
public function addFieldValidators(array $fieldValidators) { foreach ($fieldValidators as $fieldName => $validators) { $this->fieldValidators[$fieldName] = $validators; } }
[ "public", "function", "addFieldValidators", "(", "array", "$", "fieldValidators", ")", "{", "foreach", "(", "$", "fieldValidators", "as", "$", "fieldName", "=>", "$", "validators", ")", "{", "$", "this", "->", "fieldValidators", "[", "$", "fieldName", "]", "=", "$", "validators", ";", "}", "}" ]
Adds field validators to the existing ones. @param array $fieldValidators the field validators as an array in the form: array(fieldName => array(validatorType1[, validatorType2]...))
[ "Adds", "field", "validators", "to", "the", "existing", "ones", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Data/Entity.php#L178-L183
241,194
eix/core
src/php/main/Eix/Services/Data/Entity.php
Entity.getFieldsData
public function getFieldsData() { $fieldsData = array(); foreach ($this->getFields() as $field) { $fieldData = $this->$field; // If the field is an Entity, decode it. if ($fieldData instanceof self) { $fieldData = $fieldData->getFieldsData(); } elseif (@reset($fieldData) instanceof Entity) { // If the field is an array of Entity, decode them all. $newFieldData = array(); foreach ($fieldData as $key => $entity) { $newFieldData[$key] = $entity->getFieldsData(); } $fieldData = $newFieldData; } $fieldsData[$field] = $fieldData; } return $fieldsData; }
php
public function getFieldsData() { $fieldsData = array(); foreach ($this->getFields() as $field) { $fieldData = $this->$field; // If the field is an Entity, decode it. if ($fieldData instanceof self) { $fieldData = $fieldData->getFieldsData(); } elseif (@reset($fieldData) instanceof Entity) { // If the field is an array of Entity, decode them all. $newFieldData = array(); foreach ($fieldData as $key => $entity) { $newFieldData[$key] = $entity->getFieldsData(); } $fieldData = $newFieldData; } $fieldsData[$field] = $fieldData; } return $fieldsData; }
[ "public", "function", "getFieldsData", "(", ")", "{", "$", "fieldsData", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "$", "fieldData", "=", "$", "this", "->", "$", "field", ";", "// If the field is an Entity, decode it.", "if", "(", "$", "fieldData", "instanceof", "self", ")", "{", "$", "fieldData", "=", "$", "fieldData", "->", "getFieldsData", "(", ")", ";", "}", "elseif", "(", "@", "reset", "(", "$", "fieldData", ")", "instanceof", "Entity", ")", "{", "// If the field is an array of Entity, decode them all.", "$", "newFieldData", "=", "array", "(", ")", ";", "foreach", "(", "$", "fieldData", "as", "$", "key", "=>", "$", "entity", ")", "{", "$", "newFieldData", "[", "$", "key", "]", "=", "$", "entity", "->", "getFieldsData", "(", ")", ";", "}", "$", "fieldData", "=", "$", "newFieldData", ";", "}", "$", "fieldsData", "[", "$", "field", "]", "=", "$", "fieldData", ";", "}", "return", "$", "fieldsData", ";", "}" ]
Returns an array composed of all the persistable fields. @return array
[ "Returns", "an", "array", "composed", "of", "all", "the", "persistable", "fields", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Data/Entity.php#L190-L211
241,195
eix/core
src/php/main/Eix/Services/Data/Entity.php
Entity.store
public function store() { // Check whether the object has ever been stored. if ($this->isNew) { Logger::get()->debug('Storing new entity ' . get_class($this) . '...'); // Create the record. Get an ID back. $this->id = $this->getDataSource()->create($this->getFieldsData()); // Store this object in the appropriate factory for further use. $this->getFactory()->registerEntity($this); } else { Logger::get()->debug('Updating entity ' . get_class($this) . ":{$this->id}..."); $this->getDataSource()->update($this->id, $this->getFieldsData()); } // Once stored, the entity is no longer new. $this->isNew = false; }
php
public function store() { // Check whether the object has ever been stored. if ($this->isNew) { Logger::get()->debug('Storing new entity ' . get_class($this) . '...'); // Create the record. Get an ID back. $this->id = $this->getDataSource()->create($this->getFieldsData()); // Store this object in the appropriate factory for further use. $this->getFactory()->registerEntity($this); } else { Logger::get()->debug('Updating entity ' . get_class($this) . ":{$this->id}..."); $this->getDataSource()->update($this->id, $this->getFieldsData()); } // Once stored, the entity is no longer new. $this->isNew = false; }
[ "public", "function", "store", "(", ")", "{", "// Check whether the object has ever been stored.", "if", "(", "$", "this", "->", "isNew", ")", "{", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'Storing new entity '", ".", "get_class", "(", "$", "this", ")", ".", "'...'", ")", ";", "// Create the record. Get an ID back.", "$", "this", "->", "id", "=", "$", "this", "->", "getDataSource", "(", ")", "->", "create", "(", "$", "this", "->", "getFieldsData", "(", ")", ")", ";", "// Store this object in the appropriate factory for further use.", "$", "this", "->", "getFactory", "(", ")", "->", "registerEntity", "(", "$", "this", ")", ";", "}", "else", "{", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'Updating entity '", ".", "get_class", "(", "$", "this", ")", ".", "\":{$this->id}...\"", ")", ";", "$", "this", "->", "getDataSource", "(", ")", "->", "update", "(", "$", "this", "->", "id", ",", "$", "this", "->", "getFieldsData", "(", ")", ")", ";", "}", "// Once stored, the entity is no longer new.", "$", "this", "->", "isNew", "=", "false", ";", "}" ]
Stores the object in the persistence layer.
[ "Stores", "the", "object", "in", "the", "persistence", "layer", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Data/Entity.php#L231-L247
241,196
eix/core
src/php/main/Eix/Services/Data/Entity.php
Entity.destroy
public function destroy() { // Delete from the persistence layer. $this->getDataSource()->destroy($this->id); // Remove from the registry. $this->getFactory()->unregisterEntity($this); // Done, garbage collection should do the rest. }
php
public function destroy() { // Delete from the persistence layer. $this->getDataSource()->destroy($this->id); // Remove from the registry. $this->getFactory()->unregisterEntity($this); // Done, garbage collection should do the rest. }
[ "public", "function", "destroy", "(", ")", "{", "// Delete from the persistence layer.", "$", "this", "->", "getDataSource", "(", ")", "->", "destroy", "(", "$", "this", "->", "id", ")", ";", "// Remove from the registry.", "$", "this", "->", "getFactory", "(", ")", "->", "unregisterEntity", "(", "$", "this", ")", ";", "// Done, garbage collection should do the rest.", "}" ]
Destroys all copies of the object, even the persisted ones.
[ "Destroys", "all", "copies", "of", "the", "object", "even", "the", "persisted", "ones", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Services/Data/Entity.php#L252-L259
241,197
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Compress.php
Compress.setOptions
public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an array or Traversable; received "%s"', __METHOD__, (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value) { if ($key == 'options') { $key = 'adapterOptions'; } $method = 'set' . ucfirst($key); if (method_exists($this, $method)) { $this->$method($value); } } return $this; }
php
public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an array or Traversable; received "%s"', __METHOD__, (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value) { if ($key == 'options') { $key = 'adapterOptions'; } $method = 'set' . ucfirst($key); if (method_exists($this, $method)) { $this->$method($value); } } return $this; }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", "&&", "!", "$", "options", "instanceof", "Traversable", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" expects an array or Traversable; received \"%s\"'", ",", "__METHOD__", ",", "(", "is_object", "(", "$", "options", ")", "?", "get_class", "(", "$", "options", ")", ":", "gettype", "(", "$", "options", ")", ")", ")", ")", ";", "}", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "==", "'options'", ")", "{", "$", "key", "=", "'adapterOptions'", ";", "}", "$", "method", "=", "'set'", ".", "ucfirst", "(", "$", "key", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "this", "->", "$", "method", "(", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set filter setate @param array $options @throws Exception\InvalidArgumentException if options is not an array or Traversable @return self
[ "Set", "filter", "setate" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Compress.php#L56-L76
241,198
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Compress.php
Compress.getAdapter
public function getAdapter() { if ($this->adapter instanceof Compress\CompressionAlgorithmInterface) { return $this->adapter; } $adapter = $this->adapter; $options = $this->getAdapterOptions(); if (!class_exists($adapter)) { $adapter = 'Zend\\Filter\\Compress\\' . ucfirst($adapter); if (!class_exists($adapter)) { throw new Exception\RuntimeException(sprintf( '%s unable to load adapter; class "%s" not found', __METHOD__, $this->adapter )); } } $this->adapter = new $adapter($options); if (!$this->adapter instanceof Compress\CompressionAlgorithmInterface) { throw new Exception\InvalidArgumentException("Compression adapter '" . $adapter . "' does not implement Zend\\Filter\\Compress\\CompressionAlgorithmInterface"); } return $this->adapter; }
php
public function getAdapter() { if ($this->adapter instanceof Compress\CompressionAlgorithmInterface) { return $this->adapter; } $adapter = $this->adapter; $options = $this->getAdapterOptions(); if (!class_exists($adapter)) { $adapter = 'Zend\\Filter\\Compress\\' . ucfirst($adapter); if (!class_exists($adapter)) { throw new Exception\RuntimeException(sprintf( '%s unable to load adapter; class "%s" not found', __METHOD__, $this->adapter )); } } $this->adapter = new $adapter($options); if (!$this->adapter instanceof Compress\CompressionAlgorithmInterface) { throw new Exception\InvalidArgumentException("Compression adapter '" . $adapter . "' does not implement Zend\\Filter\\Compress\\CompressionAlgorithmInterface"); } return $this->adapter; }
[ "public", "function", "getAdapter", "(", ")", "{", "if", "(", "$", "this", "->", "adapter", "instanceof", "Compress", "\\", "CompressionAlgorithmInterface", ")", "{", "return", "$", "this", "->", "adapter", ";", "}", "$", "adapter", "=", "$", "this", "->", "adapter", ";", "$", "options", "=", "$", "this", "->", "getAdapterOptions", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "adapter", ")", ")", "{", "$", "adapter", "=", "'Zend\\\\Filter\\\\Compress\\\\'", ".", "ucfirst", "(", "$", "adapter", ")", ";", "if", "(", "!", "class_exists", "(", "$", "adapter", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'%s unable to load adapter; class \"%s\" not found'", ",", "__METHOD__", ",", "$", "this", "->", "adapter", ")", ")", ";", "}", "}", "$", "this", "->", "adapter", "=", "new", "$", "adapter", "(", "$", "options", ")", ";", "if", "(", "!", "$", "this", "->", "adapter", "instanceof", "Compress", "\\", "CompressionAlgorithmInterface", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "\"Compression adapter '\"", ".", "$", "adapter", ".", "\"' does not implement Zend\\\\Filter\\\\Compress\\\\CompressionAlgorithmInterface\"", ")", ";", "}", "return", "$", "this", "->", "adapter", ";", "}" ]
Returns the current adapter, instantiating it if necessary @throws Exception\RuntimeException @throws Exception\InvalidArgumentException @return Compress\CompressionAlgorithmInterface
[ "Returns", "the", "current", "adapter", "instantiating", "it", "if", "necessary" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Compress.php#L85-L109
241,199
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Compress.php
Compress.setAdapter
public function setAdapter($adapter) { if ($adapter instanceof Compress\CompressionAlgorithmInterface) { $this->adapter = $adapter; return $this; } if (!is_string($adapter)) { throw new Exception\InvalidArgumentException('Invalid adapter provided; must be string or instance of Zend\\Filter\\Compress\\CompressionAlgorithmInterface'); } $this->adapter = $adapter; return $this; }
php
public function setAdapter($adapter) { if ($adapter instanceof Compress\CompressionAlgorithmInterface) { $this->adapter = $adapter; return $this; } if (!is_string($adapter)) { throw new Exception\InvalidArgumentException('Invalid adapter provided; must be string or instance of Zend\\Filter\\Compress\\CompressionAlgorithmInterface'); } $this->adapter = $adapter; return $this; }
[ "public", "function", "setAdapter", "(", "$", "adapter", ")", "{", "if", "(", "$", "adapter", "instanceof", "Compress", "\\", "CompressionAlgorithmInterface", ")", "{", "$", "this", "->", "adapter", "=", "$", "adapter", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", "adapter", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Invalid adapter provided; must be string or instance of Zend\\\\Filter\\\\Compress\\\\CompressionAlgorithmInterface'", ")", ";", "}", "$", "this", "->", "adapter", "=", "$", "adapter", ";", "return", "$", "this", ";", "}" ]
Sets compression adapter @param string|Compress\CompressionAlgorithmInterface $adapter Adapter to use @return self @throws Exception\InvalidArgumentException
[ "Sets", "compression", "adapter" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Compress.php#L128-L140