repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
vinala/kernel
src/MVC/Model/ORM.php
ORM.getTable
protected function getTable($data = null) { if (is_null($data)) { $this->_table = static::$table; $this->_prifixTable = (Config::get('database.prefixing') ? Config::get('database.prefixe') : '').static::$table; // if (!$this->checkTable()) { throw new TableNotFoundException(static::$table); } // return $this->_prifixTable; } else { $this->_prifixTable = $data['prifixTable']; $this->_table = static::$table; } }
php
protected function getTable($data = null) { if (is_null($data)) { $this->_table = static::$table; $this->_prifixTable = (Config::get('database.prefixing') ? Config::get('database.prefixe') : '').static::$table; // if (!$this->checkTable()) { throw new TableNotFoundException(static::$table); } // return $this->_prifixTable; } else { $this->_prifixTable = $data['prifixTable']; $this->_table = static::$table; } }
[ "protected", "function", "getTable", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "this", "->", "_table", "=", "static", "::", "$", "table", ";", "$", "this", "->", "_prifixTable", "=", "(", ...
get the model table name. @param $table @return null
[ "get", "the", "model", "table", "name", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L286-L301
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.checkTable
protected function checkTable() { $data = Query::from('information_schema.tables', false) ->select('*') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY); // return (Table::count($data) > 0) ? true : false; }
php
protected function checkTable() { $data = Query::from('information_schema.tables', false) ->select('*') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY); // return (Table::count($data) > 0) ? true : false; }
[ "protected", "function", "checkTable", "(", ")", "{", "$", "data", "=", "Query", "::", "from", "(", "'information_schema.tables'", ",", "false", ")", "->", "select", "(", "'*'", ")", "->", "where", "(", "'TABLE_SCHEMA'", ",", "'='", ",", "Config", "::", ...
Check if table exists in database. @param $table string @return bool
[ "Check", "if", "table", "exists", "in", "database", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L310-L319
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.columns
protected function columns($data = null) { if (is_null($data)) { $this->_columns = $this->extruct( Query::from('INFORMATION_SCHEMA.COLUMNS', false) ->select('COLUMN_NAME') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY) ); // return $this->_columns; } else { $this->_columns = $data['columns']; } }
php
protected function columns($data = null) { if (is_null($data)) { $this->_columns = $this->extruct( Query::from('INFORMATION_SCHEMA.COLUMNS', false) ->select('COLUMN_NAME') ->where('TABLE_SCHEMA', '=', Config::get('database.database')) ->andwhere('TABLE_NAME', '=', $this->_prifixTable) ->get(Query::GET_ARRAY) ); // return $this->_columns; } else { $this->_columns = $data['columns']; } }
[ "protected", "function", "columns", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "this", "->", "_columns", "=", "$", "this", "->", "extruct", "(", "Query", "::", "from", "(", "'INFORMATION_SCHEM...
to get and set all columns of data table. @return array
[ "to", "get", "and", "set", "all", "columns", "of", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L326-L341
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.key
protected function key($data = null) { if (is_null($data)) { $data = $this->getPK(); // if (Table::count($data) > 1) { throw new ManyPrimaryKeysException(); } elseif (Table::count($data) == 0) { throw new PrimaryKeyNotFoundException(static::$table); } // $this->_keyName = $data[0]['Column_name']; $this->_key['name'] = $data[0]['Column_name']; } else { $this->_keyName = $data['key']; $this->_key['name'] = $data['key']; } }
php
protected function key($data = null) { if (is_null($data)) { $data = $this->getPK(); // if (Table::count($data) > 1) { throw new ManyPrimaryKeysException(); } elseif (Table::count($data) == 0) { throw new PrimaryKeyNotFoundException(static::$table); } // $this->_keyName = $data[0]['Column_name']; $this->_key['name'] = $data[0]['Column_name']; } else { $this->_keyName = $data['key']; $this->_key['name'] = $data['key']; } }
[ "protected", "function", "key", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getPK", "(", ")", ";", "//", "if", "(", "Table", "::", "count", "(", "$", "d...
set primary key the framework doesn't support more the column to be the primary key otherwise exception will be thrown. @return null
[ "set", "primary", "key", "the", "framework", "doesn", "t", "support", "more", "the", "column", "to", "be", "the", "primary", "key", "otherwise", "exception", "will", "be", "thrown", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L446-L463
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.struct
protected function struct($key, $fail) { $data = $this->dig($key); // if (Table::count($data) == 1) { if ($this->_canKept && $this->keptAt($data)) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data)) { $this->_stashed = true; } // $this->convert($data); } elseif ($fail && Table::count($data) == 0) { throw new ModelNotFoundException($key, $this->_model); } }
php
protected function struct($key, $fail) { $data = $this->dig($key); // if (Table::count($data) == 1) { if ($this->_canKept && $this->keptAt($data)) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data)) { $this->_stashed = true; } // $this->convert($data); } elseif ($fail && Table::count($data) == 0) { throw new ModelNotFoundException($key, $this->_model); } }
[ "protected", "function", "struct", "(", "$", "key", ",", "$", "fail", ")", "{", "$", "data", "=", "$", "this", "->", "dig", "(", "$", "key", ")", ";", "//", "if", "(", "Table", "::", "count", "(", "$", "data", ")", "==", "1", ")", "{", "if", ...
get data from data table according to primary key value. @param int $key @return null
[ "get", "data", "from", "data", "table", "according", "to", "primary", "key", "value", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L472-L488
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.fill
protected function fill($data) { if ($this->_canKept && $this->keptAt($data['values'])) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data['values'])) { $this->_stashed = true; } // $this->convert($data['values']); }
php
protected function fill($data) { if ($this->_canKept && $this->keptAt($data['values'])) { $this->_kept = true; } if ($this->_canStashed && $this->stashedAt($data['values'])) { $this->_stashed = true; } // $this->convert($data['values']); }
[ "protected", "function", "fill", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "_canKept", "&&", "$", "this", "->", "keptAt", "(", "$", "data", "[", "'values'", "]", ")", ")", "{", "$", "this", "->", "_kept", "=", "true", ";", "}", ...
fill data from array. @param array $data @return null
[ "fill", "data", "from", "array", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L497-L507
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.dig
protected function dig($key) { return Query::from(static::$table) ->select('*') ->where($this->_keyName, '=', $key) ->get(Query::GET_ARRAY); }
php
protected function dig($key) { return Query::from(static::$table) ->select('*') ->where($this->_keyName, '=', $key) ->get(Query::GET_ARRAY); }
[ "protected", "function", "dig", "(", "$", "key", ")", "{", "return", "Query", "::", "from", "(", "static", "::", "$", "table", ")", "->", "select", "(", "'*'", ")", "->", "where", "(", "$", "this", "->", "_keyName", ",", "'='", ",", "$", "key", "...
search for data by Query Class according to primary key. @param int $key @return array
[ "search", "for", "data", "by", "Query", "Class", "according", "to", "primary", "key", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L516-L522
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.convert
protected function convert($data) { foreach ($data[0] as $key => $value) { if (!$this->_kept && !$this->_stashed) { $this->$key = $value; $this->setKey($key, $value); } else { if ($this->_kept) { $this->_keptData[$key] = $value; } if ($this->_stashed) { $this->_stashedData[$key] = $value; } } $this->data[$key] = $value; } }
php
protected function convert($data) { foreach ($data[0] as $key => $value) { if (!$this->_kept && !$this->_stashed) { $this->$key = $value; $this->setKey($key, $value); } else { if ($this->_kept) { $this->_keptData[$key] = $value; } if ($this->_stashed) { $this->_stashedData[$key] = $value; } } $this->data[$key] = $value; } }
[ "protected", "function", "convert", "(", "$", "data", ")", "{", "foreach", "(", "$", "data", "[", "0", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "_kept", "&&", "!", "$", "this", "->", "_stashed", ")...
make data array colmuns as property in case of hidden data property was true data will be stored in hidden data instead ofas property. @param array $data @return null
[ "make", "data", "array", "colmuns", "as", "property", "in", "case", "of", "hidden", "data", "property", "was", "true", "data", "will", "be", "stored", "in", "hidden", "data", "instead", "ofas", "property", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L566-L583
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.save
public function save() { if ($this->_state == CRUD::CREATE_STAT) { $this->add(); } elseif ($this->_state == CRUD::UPDATE_STAT) { $this->edit(); } }
php
public function save() { if ($this->_state == CRUD::CREATE_STAT) { $this->add(); } elseif ($this->_state == CRUD::UPDATE_STAT) { $this->edit(); } }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "_state", "==", "CRUD", "::", "CREATE_STAT", ")", "{", "$", "this", "->", "add", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "_state", "==", "CRUD", "::", "UPDAT...
Save the opertaion makes by user either creation or editing. @return bool
[ "Save", "the", "opertaion", "makes", "by", "user", "either", "creation", "or", "editing", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L640-L647
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.add
private function add() { $columns = []; $values = []; // if ($this->_tracked) { $this->created_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName && isset($this->$value) && !empty($this->$value)) { $columns[] = $value; $values[] = $this->$value; } } // return $this->insert($columns, $values); }
php
private function add() { $columns = []; $values = []; // if ($this->_tracked) { $this->created_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName && isset($this->$value) && !empty($this->$value)) { $columns[] = $value; $values[] = $this->$value; } } // return $this->insert($columns, $values); }
[ "private", "function", "add", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "$", "values", "=", "[", "]", ";", "//", "if", "(", "$", "this", "->", "_tracked", ")", "{", "$", "this", "->", "created_at", "=", "Time", "::", "current", "(", ")...
function to add data in data table. @return bool
[ "function", "to", "add", "data", "in", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L654-L671
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.insert
private function insert($columns, $values) { return Query::table(static::$table) ->column($columns) ->value($values) ->insert(); }
php
private function insert($columns, $values) { return Query::table(static::$table) ->column($columns) ->value($values) ->insert(); }
[ "private", "function", "insert", "(", "$", "columns", ",", "$", "values", ")", "{", "return", "Query", "::", "table", "(", "static", "::", "$", "table", ")", "->", "column", "(", "$", "columns", ")", "->", "value", "(", "$", "values", ")", "->", "i...
function to exexute insert data. @param array $columns @param array $values @return bool
[ "function", "to", "exexute", "insert", "data", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L681-L687
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.edit
private function edit() { $columns = []; $values = []; // if ($this->_tracked) { $this->edited_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName) { $columns[] = $value; $values[] = empty($this->$value) ? null : $this->$value; } } // return $this->update($columns, $values); }
php
private function edit() { $columns = []; $values = []; // if ($this->_tracked) { $this->edited_at = Time::current(); } // foreach ($this->_columns as $value) { if ($value != $this->_keyName) { $columns[] = $value; $values[] = empty($this->$value) ? null : $this->$value; } } // return $this->update($columns, $values); }
[ "private", "function", "edit", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "$", "values", "=", "[", "]", ";", "//", "if", "(", "$", "this", "->", "_tracked", ")", "{", "$", "this", "->", "edited_at", "=", "Time", "::", "current", "(", ")...
function to edit data in data table. @return bool
[ "function", "to", "edit", "data", "in", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L694-L711
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.update
private function update($columns, $values) { $query = Query::table(static::$table); // for ($i = 0; $i < Table::count($columns); $i++) { $query = !empty($values[$i]) ? $query->set($columns[$i], $values[$i]) : $query->set($columns[$i], 'null', false); } // $query->where($this->_keyName, '=', $this->_keyValue) ->update(); // return $query; }
php
private function update($columns, $values) { $query = Query::table(static::$table); // for ($i = 0; $i < Table::count($columns); $i++) { $query = !empty($values[$i]) ? $query->set($columns[$i], $values[$i]) : $query->set($columns[$i], 'null', false); } // $query->where($this->_keyName, '=', $this->_keyValue) ->update(); // return $query; }
[ "private", "function", "update", "(", "$", "columns", ",", "$", "values", ")", "{", "$", "query", "=", "Query", "::", "table", "(", "static", "::", "$", "table", ")", ";", "//", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "Table", "::",...
function to exexute update data. @param array $columns @param array $values @return bool
[ "function", "to", "exexute", "update", "data", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L721-L733
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.delete
public function delete() { if (!$this->_canKept) { $this->forceDelete(); } else { Query::table(static::$table) ->set('deleted_at', Time::current()) ->where($this->_keyName, '=', $this->_keyValue) ->update(); } }
php
public function delete() { if (!$this->_canKept) { $this->forceDelete(); } else { Query::table(static::$table) ->set('deleted_at', Time::current()) ->where($this->_keyName, '=', $this->_keyValue) ->update(); } }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_canKept", ")", "{", "$", "this", "->", "forceDelete", "(", ")", ";", "}", "else", "{", "Query", "::", "table", "(", "static", "::", "$", "table", ")", "->", "set"...
to delete the model from database in case of Kept deleted just hide it. @return bool
[ "to", "delete", "the", "model", "from", "database", "in", "case", "of", "Kept", "deleted", "just", "hide", "it", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L741-L751
train
vinala/kernel
src/MVC/Model/ORM.php
ORM.forceDelete
public function forceDelete() { $key = $this->_kept ? $this->_keptData[$this->_keyName] : $this->_keyValue; // Query::table(static::$table) ->where($this->_keyName, '=', $key) ->delete(); // $this->reset(); }
php
public function forceDelete() { $key = $this->_kept ? $this->_keptData[$this->_keyName] : $this->_keyValue; // Query::table(static::$table) ->where($this->_keyName, '=', $key) ->delete(); // $this->reset(); }
[ "public", "function", "forceDelete", "(", ")", "{", "$", "key", "=", "$", "this", "->", "_kept", "?", "$", "this", "->", "_keptData", "[", "$", "this", "->", "_keyName", "]", ":", "$", "this", "->", "_keyValue", ";", "//", "Query", "::", "table", "...
to force delete the model from database even if the model is Kept deleted. @return bool
[ "to", "force", "delete", "the", "model", "from", "database", "even", "if", "the", "model", "is", "Kept", "deleted", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Model/ORM.php#L758-L767
train
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
train
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'", ",...
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
train
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", "=", ...
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
train
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", "=", "$", "obje...
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
train
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", "=", "$", ...
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
train
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", "=", "\\"...
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
train
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", ")", "{", "$", "extensio...
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
train
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", "...
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
train
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...
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
train
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", "===", ...
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
train
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", ...
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
train
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", "]", ...
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
train
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", "(", ")", ".", "'.p...
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
train
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", "\\", "Exce...
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
train
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", "(",...
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
train
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", "(", "$", "ma...
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
train
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", "(", "$", "...
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
train
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
train
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'", "]", "]"...
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
train
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", "(", "$", "url...
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
train
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"...
Execute call queue @param $objectContext
[ "Execute", "call", "queue" ]
77fd738a4df741c8e789b9ccf4974efc47328346
https://github.com/SlabPHP/sequencer/blob/77fd738a4df741c8e789b9ccf4974efc47328346/src/CallQueue.php#L77-L87
train
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", "=", "$", ...
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
train
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",...
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",...
54dc18c6125c971c46ded9f9484f6802112aab44
https://github.com/jannisfink/config/blob/54dc18c6125c971c46ded9f9484f6802112aab44/src/loader/FileConfigurationLoader.php#L70-L90
train
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.'", ")", ";", "}...
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
train
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", "(", "[", "$", ...
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
train
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", ",", ...
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
train
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",...
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
train
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", ...
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
train
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...
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
train
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'", ":"...
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
train
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", ")", ...
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
train
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", ...
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
train
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", "."...
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
train
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'...
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
train
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", "[", ...
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
train
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", "+", "$", "de...
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
train
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
train
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'", "=>", "$", ...
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
train
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__...
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
train
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", ")", "...
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
train
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", "(", ...
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
train
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'"...
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
train
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", "=>", "$", ...
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
train
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'", ...
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
train
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", ...
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
train
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 \\AdminB...
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
train
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"...
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
train
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", "(", ")",...
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
train
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", "(", "'i...
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
train
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'", ")"...
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
train
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", "(", ")", "->...
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
train
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", "(", "$", ...
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
train
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", "->", "Titl...
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
train
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", "(", ")", ";", "$", "...
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
train
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", "->", "setHy...
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
train
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", "("...
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
train
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", ")", ";", "...
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
train
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", "(", "$", ...
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
train
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"...
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
train
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", "(", "$",...
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
train
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", ...
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
train
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", ";", "...
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
train
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", ")", ";", "//...
Run the Framework.
[ "Run", "the", "Framework", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L127-L149
train
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"...
Run the console.
[ "Run", "the", "console", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L160-L179
train
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", "(", ...
Init Framework classes.
[ "Init", "Framework", "classes", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L209-L226
train
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.ph...
call vendor.
[ "call", "vendor", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Foundation/Application.php#L240-L245
train
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"...
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
train
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", ")", ")", "{",...
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
train
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.\"", ")", ...
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
train
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
train
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!...
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
train
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",...
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
train
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'", ...
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
train
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", "->", "_a...
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
train
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", ",", "$", "suff...
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
train
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",...
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
train
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", "=>", ...
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
train
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",...
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
train
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", "(", ")", "->", "lo...
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
train
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", ")", "{...
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
train
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", "...
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
train
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", "->", "_resultCach...
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
train
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", ...
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
train
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", "(", ...
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
train
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", "...
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
train