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
semenovdv80/framework
src/Essential/Database/Model.php
Model.update
public function update($attributes) { try { self::init(); foreach ($attributes as $column => $value) { $columns[] = $column. ' = :'.$column; } $sql = 'UPDATE ' . self::$modelTable . ' SET ' . implode(', ', $columns) . ' WHERE id = ' . $this->id; $stm = self::$connect->prepare($sql); $stm->execute($attributes); $this->setAttributes($attributes); return $this; } catch (\Exception $exception) { var_dump($exception->getMessage()); } }
php
public function update($attributes) { try { self::init(); foreach ($attributes as $column => $value) { $columns[] = $column. ' = :'.$column; } $sql = 'UPDATE ' . self::$modelTable . ' SET ' . implode(', ', $columns) . ' WHERE id = ' . $this->id; $stm = self::$connect->prepare($sql); $stm->execute($attributes); $this->setAttributes($attributes); return $this; } catch (\Exception $exception) { var_dump($exception->getMessage()); } }
[ "public", "function", "update", "(", "$", "attributes", ")", "{", "try", "{", "self", "::", "init", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "columns", "[", "]", "=", "$", "column", ...
Update object record
[ "Update", "object", "record" ]
8810340becae2a8bed3c3342b94b8b6fd0707e0c
https://github.com/semenovdv80/framework/blob/8810340becae2a8bed3c3342b94b8b6fd0707e0c/src/Essential/Database/Model.php#L76-L91
train
semenovdv80/framework
src/Essential/Database/Model.php
Model.select
public static function select() { try { self::init(); $columns = func_get_args(); $query = 'SELECT ' . implode(', ', $columns) . ' FROM ' . self::$modelTable; return new QueryBuilder(self::$connect, $query); } catch (\Exception $exception) { var_dump($exception->getMessage()); } }
php
public static function select() { try { self::init(); $columns = func_get_args(); $query = 'SELECT ' . implode(', ', $columns) . ' FROM ' . self::$modelTable; return new QueryBuilder(self::$connect, $query); } catch (\Exception $exception) { var_dump($exception->getMessage()); } }
[ "public", "static", "function", "select", "(", ")", "{", "try", "{", "self", "::", "init", "(", ")", ";", "$", "columns", "=", "func_get_args", "(", ")", ";", "$", "query", "=", "'SELECT '", ".", "implode", "(", "', '", ",", "$", "columns", ")", "....
Select specified columns from table @return mixed
[ "Select", "specified", "columns", "from", "table" ]
8810340becae2a8bed3c3342b94b8b6fd0707e0c
https://github.com/semenovdv80/framework/blob/8810340becae2a8bed3c3342b94b8b6fd0707e0c/src/Essential/Database/Model.php#L98-L109
train
semenovdv80/framework
src/Essential/Database/Model.php
Model.find
public static function find($id) { self::init(); $query = 'SELECT * FROM ' . self::$modelTable . ' WHERE id = '.$id; $qb = new QueryBuilder(self::$connect, $query); $rows = $qb->get(); $collection = self::makeCollection($rows); return !empty($collection) ? array_shift($collection) : null; }
php
public static function find($id) { self::init(); $query = 'SELECT * FROM ' . self::$modelTable . ' WHERE id = '.$id; $qb = new QueryBuilder(self::$connect, $query); $rows = $qb->get(); $collection = self::makeCollection($rows); return !empty($collection) ? array_shift($collection) : null; }
[ "public", "static", "function", "find", "(", "$", "id", ")", "{", "self", "::", "init", "(", ")", ";", "$", "query", "=", "'SELECT * FROM '", ".", "self", "::", "$", "modelTable", ".", "' WHERE id = '", ".", "$", "id", ";", "$", "qb", "=", "new", "...
Get object of record
[ "Get", "object", "of", "record" ]
8810340becae2a8bed3c3342b94b8b6fd0707e0c
https://github.com/semenovdv80/framework/blob/8810340becae2a8bed3c3342b94b8b6fd0707e0c/src/Essential/Database/Model.php#L170-L178
train
semenovdv80/framework
src/Essential/Database/Model.php
Model.makeCollection
public static function makeCollection($rows) { $collection = []; foreach ($rows as $row) { $obj = new static; $collection[] = $obj->setAttributes(get_object_vars($row)); } return $collection; }
php
public static function makeCollection($rows) { $collection = []; foreach ($rows as $row) { $obj = new static; $collection[] = $obj->setAttributes(get_object_vars($row)); } return $collection; }
[ "public", "static", "function", "makeCollection", "(", "$", "rows", ")", "{", "$", "collection", "=", "[", "]", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "obj", "=", "new", "static", ";", "$", "collection", "[", "]", "=", ...
Mace collection of objects @param $rows @return array
[ "Mace", "collection", "of", "objects" ]
8810340becae2a8bed3c3342b94b8b6fd0707e0c
https://github.com/semenovdv80/framework/blob/8810340becae2a8bed3c3342b94b8b6fd0707e0c/src/Essential/Database/Model.php#L186-L195
train
lucifurious/kisma
src/Kisma/Core/Utility/FileSystem.php
FileSystem.fgets
public function fgets( $length = null ) { return $this->validHandle() ? fgets( $this->_fileHandle, $length ) : false; }
php
public function fgets( $length = null ) { return $this->validHandle() ? fgets( $this->_fileHandle, $length ) : false; }
[ "public", "function", "fgets", "(", "$", "length", "=", "null", ")", "{", "return", "$", "this", "->", "validHandle", "(", ")", "?", "fgets", "(", "$", "this", "->", "_fileHandle", ",", "$", "length", ")", ":", "false", ";", "}" ]
Retrieves a string from the current file @param int $length @return string|bool
[ "Retrieves", "a", "string", "from", "the", "current", "file" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/FileSystem.php#L156-L159
train
lucifurious/kisma
src/Kisma/Core/Utility/FileSystem.php
FileSystem.makePath
public static function makePath( $validate = true, $forceCreate = false ) { $_arguments = func_get_args(); $_validate = $_path = null; foreach ( $_arguments as $_part ) { if ( is_bool( $_part ) ) { $_validate = $_part; continue; } $_path .= DIRECTORY_SEPARATOR . trim( $_part, DIRECTORY_SEPARATOR . ' ' ); } if ( !is_dir( $_path = realpath( $_path ) ) ) { if ( $_validate && !$forceCreate ) { return false; } if ( $forceCreate ) { if ( false === @mkdir( $_path, 0, true ) ) { throw new UtilityException( 'The result path "' . $_path . '" could not be created.' ); } } } return $_path; }
php
public static function makePath( $validate = true, $forceCreate = false ) { $_arguments = func_get_args(); $_validate = $_path = null; foreach ( $_arguments as $_part ) { if ( is_bool( $_part ) ) { $_validate = $_part; continue; } $_path .= DIRECTORY_SEPARATOR . trim( $_part, DIRECTORY_SEPARATOR . ' ' ); } if ( !is_dir( $_path = realpath( $_path ) ) ) { if ( $_validate && !$forceCreate ) { return false; } if ( $forceCreate ) { if ( false === @mkdir( $_path, 0, true ) ) { throw new UtilityException( 'The result path "' . $_path . '" could not be created.' ); } } } return $_path; }
[ "public", "static", "function", "makePath", "(", "$", "validate", "=", "true", ",", "$", "forceCreate", "=", "false", ")", "{", "$", "_arguments", "=", "func_get_args", "(", ")", ";", "$", "_validate", "=", "$", "_path", "=", "null", ";", "foreach", "(...
Builds a path from arguments and validates existence. @param bool $validate If true, will check path with is_dir. @param bool $forceCreate If true, and result path doesn't exist, it will be created @throws UtilityException @return bool|null|string
[ "Builds", "a", "path", "from", "arguments", "and", "validates", "existence", "." ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/FileSystem.php#L186-L219
train
lucifurious/kisma
src/Kisma/Core/Utility/FileSystem.php
FileSystem.rmdir
public static function rmdir( $dirPath, $force = false ) { $_path = rtrim( $dirPath ) . DIRECTORY_SEPARATOR; if ( !$force ) { return rmdir( $_path ); } if ( !is_dir( $_path ) ) { throw new \InvalidArgumentException( '"' . $_path . '" is not a directory or bogus in some other way.' ); } $_files = glob( $_path . '*', GLOB_MARK ); foreach ( $_files as $_file ) { if ( is_dir( $_file ) ) { static::rmdir( $_file, true ); } else { unlink( $_file ); } } return rmdir( $_path ); }
php
public static function rmdir( $dirPath, $force = false ) { $_path = rtrim( $dirPath ) . DIRECTORY_SEPARATOR; if ( !$force ) { return rmdir( $_path ); } if ( !is_dir( $_path ) ) { throw new \InvalidArgumentException( '"' . $_path . '" is not a directory or bogus in some other way.' ); } $_files = glob( $_path . '*', GLOB_MARK ); foreach ( $_files as $_file ) { if ( is_dir( $_file ) ) { static::rmdir( $_file, true ); } else { unlink( $_file ); } } return rmdir( $_path ); }
[ "public", "static", "function", "rmdir", "(", "$", "dirPath", ",", "$", "force", "=", "false", ")", "{", "$", "_path", "=", "rtrim", "(", "$", "dirPath", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "$", "force", ")", "{", "return", "rmdir",...
rmdir function with force @param string $dirPath @param bool $force If true, non-empty directories will be deleted @return bool @throws \InvalidArgumentException
[ "rmdir", "function", "with", "force" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/FileSystem.php#L304-L333
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.FilterFields
function FilterFields($array, $operation = 'where') { if (!$array) return; $out = array(); foreach ($array as $field => $value) { if ($operation == 'where' && $this->source == 'internal' && preg_match('/^(.*) (.*)$/', $field, $matches)) { // special CI syntax in key e.g. 'status !=' => 'something' (only for 'where' operations) $key = $matches[1]; $cond = $matches[2]; $val = $value; } elseif ($operation == 'where' && $this->source == 'controller' && is_string($value) && preg_match('/^([\<\>]=?)(.*)$/', $value, $matches)) { // CI syntax in value e.g. '>=value' $key = $field; $cond = $matches[1]; $val = $matches[2]; } elseif ($operation == 'where' && $this->source == 'controller' && is_array($value) && preg_match('/^([\<\>]=?)(.*)$/', $value[0], $matches)) { // CI syntax in value via array (e.g. ['>=value', '<=value']) // Accept an array of where conditions - this works around the fact that PHP will always accept the LAST where condition in an URL // e.g. ?foo=>1&foo=<10 (foo will == '<10') // Use ?foo[]=>1&foo[]=<10 to work around this $key = $field; $cond = $matches[1]; $val = $matches[2]; array_shift($value); // Remove first element - which we've already taken care of foreach ($value as $valIndex => $valArray) { if (preg_match('/^([\<\>]=?)(.*)$/', $value[$valIndex], $matches)) $out[isset($matches[1]) && $matches[1] != '=' ? "$key {$matches[1]}" : $key] = $matches[2]; } } else { $key = $field; $cond = '='; $val = $value; } if (!isset($this->schema[$key])) // Field definition does not exist at all continue; if ( // Is read-only during a 'set' $operation == 'set' && isset($this->schema[$key]['allowset']) && !$this->schema[$key]['allowset'] ) continue; if ( // Is not filterable by $operation == 'where' && isset($this->schema[$key]['allowquery']) && !$this->schema[$key]['allowquery'] ) continue; // If we got this far its a valid field $out[$cond && $cond != '=' ? "$key $cond" : $key] = $val; } return $out; }
php
function FilterFields($array, $operation = 'where') { if (!$array) return; $out = array(); foreach ($array as $field => $value) { if ($operation == 'where' && $this->source == 'internal' && preg_match('/^(.*) (.*)$/', $field, $matches)) { // special CI syntax in key e.g. 'status !=' => 'something' (only for 'where' operations) $key = $matches[1]; $cond = $matches[2]; $val = $value; } elseif ($operation == 'where' && $this->source == 'controller' && is_string($value) && preg_match('/^([\<\>]=?)(.*)$/', $value, $matches)) { // CI syntax in value e.g. '>=value' $key = $field; $cond = $matches[1]; $val = $matches[2]; } elseif ($operation == 'where' && $this->source == 'controller' && is_array($value) && preg_match('/^([\<\>]=?)(.*)$/', $value[0], $matches)) { // CI syntax in value via array (e.g. ['>=value', '<=value']) // Accept an array of where conditions - this works around the fact that PHP will always accept the LAST where condition in an URL // e.g. ?foo=>1&foo=<10 (foo will == '<10') // Use ?foo[]=>1&foo[]=<10 to work around this $key = $field; $cond = $matches[1]; $val = $matches[2]; array_shift($value); // Remove first element - which we've already taken care of foreach ($value as $valIndex => $valArray) { if (preg_match('/^([\<\>]=?)(.*)$/', $value[$valIndex], $matches)) $out[isset($matches[1]) && $matches[1] != '=' ? "$key {$matches[1]}" : $key] = $matches[2]; } } else { $key = $field; $cond = '='; $val = $value; } if (!isset($this->schema[$key])) // Field definition does not exist at all continue; if ( // Is read-only during a 'set' $operation == 'set' && isset($this->schema[$key]['allowset']) && !$this->schema[$key]['allowset'] ) continue; if ( // Is not filterable by $operation == 'where' && isset($this->schema[$key]['allowquery']) && !$this->schema[$key]['allowquery'] ) continue; // If we got this far its a valid field $out[$cond && $cond != '=' ? "$key $cond" : $key] = $val; } return $out; }
[ "function", "FilterFields", "(", "$", "array", ",", "$", "operation", "=", "'where'", ")", "{", "if", "(", "!", "$", "array", ")", "return", ";", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "field", "=>", "$"...
Return an input array filtered by fields we are allowed to perform an operation on @param array $array The incomming hash of field values to filter @param string $operation The operation to perform. Can be: where, set, get
[ "Return", "an", "input", "array", "filtered", "by", "fields", "we", "are", "allowed", "to", "perform", "an", "operation", "on" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L292-L345
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.GetCache
function GetCache($type, $id) { if (!isset($this->cache[$type]) || !$this->cache[$type]) // Dont cache this type of call return FALSE; if (isset($this->_cache[$type][$id])) return $this->_cache[$type][$id]; return FALSE; }
php
function GetCache($type, $id) { if (!isset($this->cache[$type]) || !$this->cache[$type]) // Dont cache this type of call return FALSE; if (isset($this->_cache[$type][$id])) return $this->_cache[$type][$id]; return FALSE; }
[ "function", "GetCache", "(", "$", "type", ",", "$", "id", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cache", "[", "$", "type", "]", ")", "||", "!", "$", "this", "->", "cache", "[", "$", "type", "]", ")", "// Dont cache this type ...
Get the value of a cache entity @param string $type The operation (e.g. 'get', 'getall') @param mixed $id The ID of the row to cache @return mixed|null The cache contents if any
[ "Get", "the", "value", "of", "a", "cache", "entity" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L395-L401
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.SetCache
function SetCache($type, $id, $value) { if (!isset($this->cache[$type]) || !$this->cache[$type]) // Dont cache this type of call return $value; if ($value) { if (!isset($this->_cache[$type])) $this->_cache[$type] = array(); $this->_cache[$type][$id] = $value; return $this->_cache[$type][$id]; } elseif (isset($this->_cache[$type][$id])) { unset($this->_cache[$type][$id]); return null; } }
php
function SetCache($type, $id, $value) { if (!isset($this->cache[$type]) || !$this->cache[$type]) // Dont cache this type of call return $value; if ($value) { if (!isset($this->_cache[$type])) $this->_cache[$type] = array(); $this->_cache[$type][$id] = $value; return $this->_cache[$type][$id]; } elseif (isset($this->_cache[$type][$id])) { unset($this->_cache[$type][$id]); return null; } }
[ "function", "SetCache", "(", "$", "type", ",", "$", "id", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cache", "[", "$", "type", "]", ")", "||", "!", "$", "this", "->", "cache", "[", "$", "type", "]", ")", ...
Set a cache item @param string $type The operation (e.g. 'get', 'getall') @param mixed $id The ID of the row to cache @param mixed|null $value The value to cache (set to null to remove from cache) @return mixed|null The cache contents if any
[ "Set", "a", "cache", "item" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L410-L422
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.ClearCache
function ClearCache($type = null, $id = null) { if (!$type) { // Clear everything $this->_cache = array(); } elseif (!$id) { // Clear on section $this->_cache[$type] = array(); } else { // Clear a specific type/id combination $this->SetCache($type, $id, null); } }
php
function ClearCache($type = null, $id = null) { if (!$type) { // Clear everything $this->_cache = array(); } elseif (!$id) { // Clear on section $this->_cache[$type] = array(); } else { // Clear a specific type/id combination $this->SetCache($type, $id, null); } }
[ "function", "ClearCache", "(", "$", "type", "=", "null", ",", "$", "id", "=", "null", ")", "{", "if", "(", "!", "$", "type", ")", "{", "// Clear everything", "$", "this", "->", "_cache", "=", "array", "(", ")", ";", "}", "elseif", "(", "!", "$", ...
Clears the cache of a specific item, type or entirely @param string|null $type Either the type of cache item to clear or null (in which case the entire cache is cleared) @param string|null $id Either the ID of the item to clear or null (in which case all cached items for the given $type is cleared)
[ "Clears", "the", "cache", "of", "a", "specific", "item", "type", "or", "entirely" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L429-L437
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.Get
function Get($id) { $this->continue = TRUE; $this->LoadSchema(); if ($value = $this->GetCache('get', $id)) return $value; $this->ResetQuery(array( 'method' => 'get', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), 'limit' => 1, )); $this->db->from($this->query['table']); $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->limit(1); $row = $this->db->get()->row_array(); if ($row) $this->ApplyRow($row); if (!$this->continue) return FALSE; $this->Trigger('access', $this->query['where']); if (!$this->continue) return FALSE; $this->Trigger('pull', $this->query['where']); if (!$this->continue) return FALSE; return $this->SetCache('get', $id, $row); }
php
function Get($id) { $this->continue = TRUE; $this->LoadSchema(); if ($value = $this->GetCache('get', $id)) return $value; $this->ResetQuery(array( 'method' => 'get', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), 'limit' => 1, )); $this->db->from($this->query['table']); $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->limit(1); $row = $this->db->get()->row_array(); if ($row) $this->ApplyRow($row); if (!$this->continue) return FALSE; $this->Trigger('access', $this->query['where']); if (!$this->continue) return FALSE; $this->Trigger('pull', $this->query['where']); if (!$this->continue) return FALSE; return $this->SetCache('get', $id, $row); }
[ "function", "Get", "(", "$", "id", ")", "{", "$", "this", "->", "continue", "=", "TRUE", ";", "$", "this", "->", "LoadSchema", "(", ")", ";", "if", "(", "$", "value", "=", "$", "this", "->", "GetCache", "(", "'get'", ",", "$", "id", ")", ")", ...
Retrieve a single item by its ID Calls the 'get' trigger on the retrieved row @param mixed|null $id The ID (usually an Int) to retrieve the row by @return array The database row
[ "Retrieve", "a", "single", "item", "by", "its", "ID", "Calls", "the", "get", "trigger", "on", "the", "retrieved", "row" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L491-L524
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.GetAll
function GetAll($where = null, $orderby = null, $limit = null, $offset = null) { $this->LoadSchema(); if ($this->UseCache('getall')) { $params = func_get_args(); $cacheid = md5(json_encode($params)); if ($value = $this->GetCache('getall', $cacheid)) return $value; } $this->ResetQuery(array( 'method' => 'getall', 'table' => $this->table, 'where' => $where, 'orderby' => $orderby, 'limit' => $limit, 'offset' => $offset, )); $this->Trigger('access', $where); if (!$this->continue) return array(); $this->Trigger('pull', $where); if (!$this->continue) return array(); $this->Trigger('getall', $where, $orderby, $limit, $offset); if (!$this->continue) return array(); $this->db->from($this->table); if ($where = $this->FilterFields($where, 'where')) $this->db->where($where); if ($orderby) $this->db->order_by($orderby); if ($limit || $offset) $this->db->limit($limit,$offset); $out = array(); foreach ($this->db->get()->result_array() as $row) { $this->ApplyRow($row); if (!$this->continue) return array(); $out[] = $row; } $this->Trigger('rows', $out); if (!$this->continue) return array(); return isset($cacheid) ? $this->SetCache('getall', $cacheid, $out) : $out; }
php
function GetAll($where = null, $orderby = null, $limit = null, $offset = null) { $this->LoadSchema(); if ($this->UseCache('getall')) { $params = func_get_args(); $cacheid = md5(json_encode($params)); if ($value = $this->GetCache('getall', $cacheid)) return $value; } $this->ResetQuery(array( 'method' => 'getall', 'table' => $this->table, 'where' => $where, 'orderby' => $orderby, 'limit' => $limit, 'offset' => $offset, )); $this->Trigger('access', $where); if (!$this->continue) return array(); $this->Trigger('pull', $where); if (!$this->continue) return array(); $this->Trigger('getall', $where, $orderby, $limit, $offset); if (!$this->continue) return array(); $this->db->from($this->table); if ($where = $this->FilterFields($where, 'where')) $this->db->where($where); if ($orderby) $this->db->order_by($orderby); if ($limit || $offset) $this->db->limit($limit,$offset); $out = array(); foreach ($this->db->get()->result_array() as $row) { $this->ApplyRow($row); if (!$this->continue) return array(); $out[] = $row; } $this->Trigger('rows', $out); if (!$this->continue) return array(); return isset($cacheid) ? $this->SetCache('getall', $cacheid, $out) : $out; }
[ "function", "GetAll", "(", "$", "where", "=", "null", ",", "$", "orderby", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "this", "->", "LoadSchema", "(", ")", ";", "if", "(", "$", "this", "->", "Us...
Retrieves multiple items filtered by where conditions Calls the 'getall' trigger to apply additional filters Calls the 'get' trigger on each retrieved row @param array $where Additional where conditions to apply @param string $orderby The ordering criteria to use @param int $limit The limit of records to retrieve @param int $offset The offset of records to retrieve @return array All found database rows
[ "Retrieves", "multiple", "items", "filtered", "by", "where", "conditions", "Calls", "the", "getall", "trigger", "to", "apply", "additional", "filters", "Calls", "the", "get", "trigger", "on", "each", "retrieved", "row" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L614-L667
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.UnCastType
function UnCastType($type, $data, &$row = null) { switch ($type) { case 'json': return json_encode($data); case 'json-import': if (!is_array($data)) $data = array(); foreach ($row as $key => $val) { if (substr($key, 0, 1) == '_') // Skip meta fields continue; if (!isset($this->schema[$key])) { // This key is unrecognised - import into JSON blob $data[$key] = $val; unset($row[$key]); } } $data = json_encode($data); return $data; default: // No idea what this is or we dont care return $data; } }
php
function UnCastType($type, $data, &$row = null) { switch ($type) { case 'json': return json_encode($data); case 'json-import': if (!is_array($data)) $data = array(); foreach ($row as $key => $val) { if (substr($key, 0, 1) == '_') // Skip meta fields continue; if (!isset($this->schema[$key])) { // This key is unrecognised - import into JSON blob $data[$key] = $val; unset($row[$key]); } } $data = json_encode($data); return $data; default: // No idea what this is or we dont care return $data; } }
[ "function", "UnCastType", "(", "$", "type", ",", "$", "data", ",", "&", "$", "row", "=", "null", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'json'", ":", "return", "json_encode", "(", "$", "data", ")", ";", "case", "'json-import'", ":...
Converts a data type back into the DB format from the PHP object @see CastType @param string $type The type to cast from @param mixed $data The data to convert @param array $row Row to operate on if type requires access to its peers (e.g. 'json-import') @return mixed The DB compatible data type
[ "Converts", "a", "data", "type", "back", "into", "the", "DB", "format", "from", "the", "PHP", "object" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L785-L805
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.Create
function Create($data) { if (!$this->allowBlankCreate && !$data) return; $this->LoadSchema(); if ($this->enforceTypes) foreach ($this->schema as $key => $props) if (isset($data[$key]) || $props['type'] == 'json-import') $data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data); $this->ResetQuery(array( 'method' => 'create', 'table' => $this->table, 'data' => $data, )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; $this->Trigger('create', $data); if (! $data = $this->FilterFields($data, 'set')) // Nothing to save return FALSE; if (!$this->continue) return FALSE; $this->db->insert($this->table, $data); $id = $this->db->insert_id(); $this->Trigger('created', $id, $data); return $this->returnRow ? $this->Get($id) : $id; }
php
function Create($data) { if (!$this->allowBlankCreate && !$data) return; $this->LoadSchema(); if ($this->enforceTypes) foreach ($this->schema as $key => $props) if (isset($data[$key]) || $props['type'] == 'json-import') $data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data); $this->ResetQuery(array( 'method' => 'create', 'table' => $this->table, 'data' => $data, )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; $this->Trigger('create', $data); if (! $data = $this->FilterFields($data, 'set')) // Nothing to save return FALSE; if (!$this->continue) return FALSE; $this->db->insert($this->table, $data); $id = $this->db->insert_id(); $this->Trigger('created', $id, $data); return $this->returnRow ? $this->Get($id) : $id; }
[ "function", "Create", "(", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "allowBlankCreate", "&&", "!", "$", "data", ")", "return", ";", "$", "this", "->", "LoadSchema", "(", ")", ";", "if", "(", "$", "this", "->", "enforceTypes", ")", ...
Attempt to create a database record using the provided data Calls the 'create' trigger on the data before it is saved @param array $data A hash of data to attempt to store @return null|array If $returnRow is true this function will return the newly created object, if FALSE the ID of the newly created object
[ "Attempt", "to", "create", "a", "database", "record", "using", "the", "provided", "data", "Calls", "the", "create", "trigger", "on", "the", "data", "before", "it", "is", "saved" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L893-L928
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.Save
function Save($id, $data = null) { if (!$id) return; $this->LoadSchema(); if (is_array($id)) { $data = $id; if (!isset($data[$this->schema['_id']['field']])) // Incomming data has no ID to address by return; $id = $data[$this->schema['_id']['field']]; } else { $data[$this->schema['_id']['field']] = $id; } if (!$data) return; if ($this->enforceTypes) foreach ($this->schema as $key => $props) if (isset($data[$key]) || $props['type'] == 'json-import') $data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data); $this->ResetQuery(array( 'method' => 'save', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), 'data' => $data, )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; unset($data[$this->schema['_id']['field']]); // Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved) $this->trigger('save', $id, $data); if (!$this->continue) return FALSE; if (! $data = $this->FilterFields($data, 'set')) // Nothing to save return FALSE; if (!$this->continue) return FALSE; $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->update($this->table, $data); $this->Trigger('saved', $id, $save); $this->ClearCache('get', $id); // Wipe the cache so the next get() doesn't return cached data return $this->returnRow ? $this->Get($id) : $save; }
php
function Save($id, $data = null) { if (!$id) return; $this->LoadSchema(); if (is_array($id)) { $data = $id; if (!isset($data[$this->schema['_id']['field']])) // Incomming data has no ID to address by return; $id = $data[$this->schema['_id']['field']]; } else { $data[$this->schema['_id']['field']] = $id; } if (!$data) return; if ($this->enforceTypes) foreach ($this->schema as $key => $props) if (isset($data[$key]) || $props['type'] == 'json-import') $data[$key] = $this->UnCastType($props['type'], isset($data[$key]) ? $data[$key] : null, $data); $this->ResetQuery(array( 'method' => 'save', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), 'data' => $data, )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; unset($data[$this->schema['_id']['field']]); // Remove ID from saving data (it will only be removed during filtering anyway as PKs can never be saved) $this->trigger('save', $id, $data); if (!$this->continue) return FALSE; if (! $data = $this->FilterFields($data, 'set')) // Nothing to save return FALSE; if (!$this->continue) return FALSE; $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->update($this->table, $data); $this->Trigger('saved', $id, $save); $this->ClearCache('get', $id); // Wipe the cache so the next get() doesn't return cached data return $this->returnRow ? $this->Get($id) : $save; }
[ "function", "Save", "(", "$", "id", ",", "$", "data", "=", "null", ")", "{", "if", "(", "!", "$", "id", ")", "return", ";", "$", "this", "->", "LoadSchema", "(", ")", ";", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "$", "data", "...
Attempt to save a database record using the provided data Calls the 'save' trigger on the data before it is saved @param mixed|array $id The ID to use to identify the record to change or the full row to save (data will be ignored) @param array $data A hash of data to attempt to store (optional if ID is the full row) @return null|array If $returnRow is true this function will return the newly saved object, if FALSE the array of data saved
[ "Attempt", "to", "save", "a", "database", "record", "using", "the", "provided", "data", "Calls", "the", "save", "trigger", "on", "the", "data", "before", "it", "is", "saved" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L937-L995
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.Delete
function Delete($id) { $this->LoadSchema(); $data = array($this->schema['_id']['field'] => $id); $this->ResetQuery(array( 'method' => 'delete', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; $this->Trigger('delete', $id); if (!$id) return FALSE; if (!$this->continue) return FALSE; $this->db->from($this->table); $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->delete(); $this->Trigger('deleted', $id); return TRUE; }
php
function Delete($id) { $this->LoadSchema(); $data = array($this->schema['_id']['field'] => $id); $this->ResetQuery(array( 'method' => 'delete', 'table' => $this->table, 'where' => array( $this->schema['_id']['field'] => $id, ), )); $this->Trigger('access', $data); if (!$this->continue) return FALSE; $this->Trigger('push', $data); if (!$this->continue) return FALSE; $this->Trigger('delete', $id); if (!$id) return FALSE; if (!$this->continue) return FALSE; $this->db->from($this->table); $this->db->where("{$this->table}.{$this->schema['_id']['field']}", $id); $this->db->delete(); $this->Trigger('deleted', $id); return TRUE; }
[ "function", "Delete", "(", "$", "id", ")", "{", "$", "this", "->", "LoadSchema", "(", ")", ";", "$", "data", "=", "array", "(", "$", "this", "->", "schema", "[", "'_id'", "]", "[", "'field'", "]", "=>", "$", "id", ")", ";", "$", "this", "->", ...
Delete a single item by its ID Calls the 'delete' trigger on the retrieved row @param mixed|null $id The ID (usually an Int) to retrieve the row by @return bool The success of the delete operation
[ "Delete", "a", "single", "item", "by", "its", "ID", "Calls", "the", "delete", "trigger", "on", "the", "retrieved", "row" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L1003-L1036
train
hash-bang/Joyst
Joyst_Model.php
Joyst_Model.ResetQuery
function ResetQuery($query = null) { $this->db->ar_select = array(); $this->db->ar_distinct = FALSE; $this->db->ar_from = array(); $this->db->ar_join = array(); $this->db->ar_where = array(); $this->db->ar_like = array(); $this->db->ar_groupby = array(); $this->db->ar_having = array(); $this->db->ar_keys = array(); $this->db->ar_limit = FALSE; $this->db->ar_offset = FALSE; $this->db->ar_order = FALSE; $this->db->ar_orderby = array(); $this->db->ar_set = array(); $this->db->ar_wherein = array(); $this->db->ar_aliased_tables = array(); $this->db->ar_store_array = array(); $this->joystError = ''; $this->continue = TRUE; $this->query = $query; }
php
function ResetQuery($query = null) { $this->db->ar_select = array(); $this->db->ar_distinct = FALSE; $this->db->ar_from = array(); $this->db->ar_join = array(); $this->db->ar_where = array(); $this->db->ar_like = array(); $this->db->ar_groupby = array(); $this->db->ar_having = array(); $this->db->ar_keys = array(); $this->db->ar_limit = FALSE; $this->db->ar_offset = FALSE; $this->db->ar_order = FALSE; $this->db->ar_orderby = array(); $this->db->ar_set = array(); $this->db->ar_wherein = array(); $this->db->ar_aliased_tables = array(); $this->db->ar_store_array = array(); $this->joystError = ''; $this->continue = TRUE; $this->query = $query; }
[ "function", "ResetQuery", "(", "$", "query", "=", "null", ")", "{", "$", "this", "->", "db", "->", "ar_select", "=", "array", "(", ")", ";", "$", "this", "->", "db", "->", "ar_distinct", "=", "FALSE", ";", "$", "this", "->", "db", "->", "ar_from", ...
Force CI ActiveRecord + Joyst to discard any half formed AR queries @param array $query Optional query to reset Joysts internal query tracker to
[ "Force", "CI", "ActiveRecord", "+", "Joyst", "to", "discard", "any", "half", "formed", "AR", "queries" ]
f8bcf396120884c5c77e3e8f016b8472e2cc2fb0
https://github.com/hash-bang/Joyst/blob/f8bcf396120884c5c77e3e8f016b8472e2cc2fb0/Joyst_Model.php#L1087-L1109
train
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.configureAction
public function configureAction(Request $request) { if ($this->get('tenside.status')->isTensideConfigured()) { throw new NotAcceptableHttpException('Already configured.'); } $inputData = new JsonArray($request->getContent()); $secret = bin2hex(random_bytes(40)); if ($inputData->has('credentials/secret')) { $secret = $inputData->get('credentials/secret'); } // Add tenside configuration. $tensideConfig = $this->get('tenside.config'); $tensideConfig->set('secret', $secret); if ($inputData->has('configuration')) { $this->handleConfiguration($inputData->get('configuration', true)); } $user = $this->createUser($inputData->get('credentials/username'), $inputData->get('credentials/password')); return new JsonResponse( [ 'status' => 'OK', 'token' => $this->get('tenside.jwt_authenticator')->getTokenForData($user) ], JsonResponse::HTTP_CREATED ); }
php
public function configureAction(Request $request) { if ($this->get('tenside.status')->isTensideConfigured()) { throw new NotAcceptableHttpException('Already configured.'); } $inputData = new JsonArray($request->getContent()); $secret = bin2hex(random_bytes(40)); if ($inputData->has('credentials/secret')) { $secret = $inputData->get('credentials/secret'); } // Add tenside configuration. $tensideConfig = $this->get('tenside.config'); $tensideConfig->set('secret', $secret); if ($inputData->has('configuration')) { $this->handleConfiguration($inputData->get('configuration', true)); } $user = $this->createUser($inputData->get('credentials/username'), $inputData->get('credentials/password')); return new JsonResponse( [ 'status' => 'OK', 'token' => $this->get('tenside.jwt_authenticator')->getTokenForData($user) ], JsonResponse::HTTP_CREATED ); }
[ "public", "function", "configureAction", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "this", "->", "get", "(", "'tenside.status'", ")", "->", "isTensideConfigured", "(", ")", ")", "{", "throw", "new", "NotAcceptableHttpException", "(", "'Already ...
Configure tenside. NOTE: This method will become inaccessible after the first successful call. @param Request $request The request. @return JsonResponse @throws NotAcceptableHttpException When the configuration is already complete. @ApiDoc( section="install", statusCodes = { 201 = "When everything worked out ok", 406 = "When the configuration is already complete" } ) @ApiDescription( request={ "credentials" = { "description" = "The credentials of the admin user.", "children" = { "secret" = { "dataType" = "string", "description" = "The secret to use for encryption and signing.", "required" = true }, "username" = { "dataType" = "string", "description" = "The name of the admin user.", "required" = true }, "password" = { "dataType" = "string", "description" = "The password to use for the admin.", "required" = false } } }, "configuration" = { "description" = "The application configuration.", "children" = { "php_cli" = { "dataType" = "string", "description" = "The PHP interpreter to run on command line." }, "php_cli_arguments" = { "dataType" = "string", "description" = "Command line arguments to add." }, "github_oauth_token" = { "dataType" = "string", "description" = "Github OAuth token.", "required" = false } } } }, response={ "token" = { "dataType" = "string", "description" = "The API token for the created user" } } )
[ "Configure", "tenside", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L108-L136
train
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.getProjectVersionsAction
public function getProjectVersionsAction($vendor, $project) { $this->checkUninstalled(); $url = sprintf('https://packagist.org/packages/%s/%s.json', $vendor, $project); $rfs = new RemoteFilesystem($this->getInputOutput()); $results = $rfs->getContents($url, $url); $data = new JsonArray($results); $versions = []; foreach ($data->get('package/versions') as $information) { $version = [ 'name' => $information['name'], 'version' => $information['version'], 'version_normalized' => $information['version_normalized'], ]; $normalized = $information['version']; if ('dev-' === substr($normalized, 0, 4)) { if (isset($information['extra']['branch-alias'][$normalized])) { $version['version_normalized'] = $information['extra']['branch-alias'][$normalized]; } } if (isset($information['source']['reference'])) { $version['reference'] = $information['source']['reference']; } elseif (isset($information['dist']['reference'])) { $version['reference'] = $information['dist']['reference']; } $versions[] = $version; } return new JsonResponse( [ 'status' => 'OK', 'versions' => $versions ] ); }
php
public function getProjectVersionsAction($vendor, $project) { $this->checkUninstalled(); $url = sprintf('https://packagist.org/packages/%s/%s.json', $vendor, $project); $rfs = new RemoteFilesystem($this->getInputOutput()); $results = $rfs->getContents($url, $url); $data = new JsonArray($results); $versions = []; foreach ($data->get('package/versions') as $information) { $version = [ 'name' => $information['name'], 'version' => $information['version'], 'version_normalized' => $information['version_normalized'], ]; $normalized = $information['version']; if ('dev-' === substr($normalized, 0, 4)) { if (isset($information['extra']['branch-alias'][$normalized])) { $version['version_normalized'] = $information['extra']['branch-alias'][$normalized]; } } if (isset($information['source']['reference'])) { $version['reference'] = $information['source']['reference']; } elseif (isset($information['dist']['reference'])) { $version['reference'] = $information['dist']['reference']; } $versions[] = $version; } return new JsonResponse( [ 'status' => 'OK', 'versions' => $versions ] ); }
[ "public", "function", "getProjectVersionsAction", "(", "$", "vendor", ",", "$", "project", ")", "{", "$", "this", "->", "checkUninstalled", "(", ")", ";", "$", "url", "=", "sprintf", "(", "'https://packagist.org/packages/%s/%s.json'", ",", "$", "vendor", ",", ...
Retrieve the available versions of a package. NOTE: This method will become inaccessible as soon as the installation is complete. @param string $vendor The vendor name of the package. @param string $project The name of the package. @return JsonResponse @ApiDoc( section="install", statusCodes = { 201 = "When everything worked out ok", 406 = "When the installation is already complete" }, ) @ApiDescription( response={ "versions" = { "actualType" = "collection", "subType" = "object", "description" = "The list of versions", "children" = { "name" = { "dataType" = "string", "description" = "The name of the package" }, "version" = { "dataType" = "string", "description" = "The version of the package" }, "version_normalized" = { "dataType" = "string", "description" = "The normalized version of the package" }, "reference" = { "dataType" = "string", "description" = "The optional reference" } } } } )
[ "Retrieve", "the", "available", "versions", "of", "a", "package", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L357-L397
train
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.getInstallationStateAction
public function getInstallationStateAction() { $status = $this->get('tenside.status'); return new JsonResponse( [ 'state' => [ 'tenside_configured' => $status->isTensideConfigured(), 'project_created' => $status->isProjectPresent(), 'project_installed' => $status->isProjectInstalled(), ], 'status' => 'OK' ] ); }
php
public function getInstallationStateAction() { $status = $this->get('tenside.status'); return new JsonResponse( [ 'state' => [ 'tenside_configured' => $status->isTensideConfigured(), 'project_created' => $status->isProjectPresent(), 'project_installed' => $status->isProjectInstalled(), ], 'status' => 'OK' ] ); }
[ "public", "function", "getInstallationStateAction", "(", ")", "{", "$", "status", "=", "$", "this", "->", "get", "(", "'tenside.status'", ")", ";", "return", "new", "JsonResponse", "(", "[", "'state'", "=>", "[", "'tenside_configured'", "=>", "$", "status", ...
Check if installation is new, partial or complete. @return JsonResponse @ApiDoc( section="install", description="This method provides information about the installation.", statusCodes = { 201 = "When everything worked out ok", 406 = "When the installation is already complete" }, ) @ApiDescription( response={ "state" = { "children" = { "tenside_configured" = { "dataType" = "bool", "description" = "Flag if tenside has been completely configured." }, "project_created" = { "dataType" = "bool", "description" = "Flag determining if a composer.json is present." }, "project_installed" = { "dataType" = "bool", "description" = "Flag determining if the composer project has been installed (vendor present)." } } }, "status" = { "dataType" = "string", "description" = "Either OK or ERROR" }, "message" = { "dataType" = "string", "description" = "The API error message if any (only present when status is ERROR)" } } )
[ "Check", "if", "installation", "is", "new", "partial", "or", "complete", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L441-L455
train
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.createUser
private function createUser($username, $password) { $user = new UserInformation( [ 'username' => $username, 'acl' => UserInformationInterface::ROLE_ALL ] ); $user->set('password', $this->get('security.password_encoder')->encodePassword($user, $password)); $user = $this->get('tenside.user_provider')->addUser($user)->refreshUser($user); return $user; }
php
private function createUser($username, $password) { $user = new UserInformation( [ 'username' => $username, 'acl' => UserInformationInterface::ROLE_ALL ] ); $user->set('password', $this->get('security.password_encoder')->encodePassword($user, $password)); $user = $this->get('tenside.user_provider')->addUser($user)->refreshUser($user); return $user; }
[ "private", "function", "createUser", "(", "$", "username", ",", "$", "password", ")", "{", "$", "user", "=", "new", "UserInformation", "(", "[", "'username'", "=>", "$", "username", ",", "'acl'", "=>", "UserInformationInterface", "::", "ROLE_ALL", "]", ")", ...
Add an user to the database. @param string $username The username. @param string $password The password. @return UserInformation
[ "Add", "an", "user", "to", "the", "database", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L480-L494
train
tenside/core-bundle
src/Controller/InstallProjectController.php
InstallProjectController.handleConfiguration
private function handleConfiguration($configuration) { $tensideConfig = $this->get('tenside.config'); if (isset($configuration['php_cli'])) { $tensideConfig->setPhpCliBinary($configuration['php_cli']); } if (isset($configuration['php_cli_arguments'])) { $tensideConfig->setPhpCliArguments($configuration['php_cli_arguments']); } if (isset($configuration['php_cli_environment'])) { $tensideConfig->setPhpCliEnvironment($configuration['php_cli_environment']); } if (isset($configuration['php_force_background'])) { $tensideConfig->setForceToBackground($configuration['php_force_background']); } if (isset($configuration['php_can_fork'])) { $tensideConfig->setForkingAvailable($configuration['php_can_fork']); } if (isset($configuration['github_oauth_token'])) { $composerAuth = new AuthJson( $this->get('tenside.home')->tensideDataDir() . DIRECTORY_SEPARATOR . 'auth.json', null ); $composerAuth->setGithubOAuthToken($configuration['github_oauth_token']); } }
php
private function handleConfiguration($configuration) { $tensideConfig = $this->get('tenside.config'); if (isset($configuration['php_cli'])) { $tensideConfig->setPhpCliBinary($configuration['php_cli']); } if (isset($configuration['php_cli_arguments'])) { $tensideConfig->setPhpCliArguments($configuration['php_cli_arguments']); } if (isset($configuration['php_cli_environment'])) { $tensideConfig->setPhpCliEnvironment($configuration['php_cli_environment']); } if (isset($configuration['php_force_background'])) { $tensideConfig->setForceToBackground($configuration['php_force_background']); } if (isset($configuration['php_can_fork'])) { $tensideConfig->setForkingAvailable($configuration['php_can_fork']); } if (isset($configuration['github_oauth_token'])) { $composerAuth = new AuthJson( $this->get('tenside.home')->tensideDataDir() . DIRECTORY_SEPARATOR . 'auth.json', null ); $composerAuth->setGithubOAuthToken($configuration['github_oauth_token']); } }
[ "private", "function", "handleConfiguration", "(", "$", "configuration", ")", "{", "$", "tensideConfig", "=", "$", "this", "->", "get", "(", "'tenside.config'", ")", ";", "if", "(", "isset", "(", "$", "configuration", "[", "'php_cli'", "]", ")", ")", "{", ...
Absorb the passed configuration. @param array $configuration The configuration to absorb. @return void
[ "Absorb", "the", "passed", "configuration", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/InstallProjectController.php#L503-L535
train
99designs/ergo
classes/Ergo/Config/FileConfig.php
FileConfig.loadFile
function loadFile($file, $optional=false, $varname=false, $recursive=false) { if (!is_file($file)) { if ($optional) return $this; else throw new Exception("Failed to read config file '$file'"); } $newConfig = @include($file); if(!is_array($newConfig) && $varname) $newConfig = $$varname; if(!is_array($newConfig) && !$optional) throw new Exception("Config file '$file' doesn't contain a config"); else if(is_array($newConfig)) { if ($recursive) $this->_data = array_merge_recursive($this->_data, $newConfig); else $this->_data = array_merge($this->_data, $newConfig); } return $this; }
php
function loadFile($file, $optional=false, $varname=false, $recursive=false) { if (!is_file($file)) { if ($optional) return $this; else throw new Exception("Failed to read config file '$file'"); } $newConfig = @include($file); if(!is_array($newConfig) && $varname) $newConfig = $$varname; if(!is_array($newConfig) && !$optional) throw new Exception("Config file '$file' doesn't contain a config"); else if(is_array($newConfig)) { if ($recursive) $this->_data = array_merge_recursive($this->_data, $newConfig); else $this->_data = array_merge($this->_data, $newConfig); } return $this; }
[ "function", "loadFile", "(", "$", "file", ",", "$", "optional", "=", "false", ",", "$", "varname", "=", "false", ",", "$", "recursive", "=", "false", ")", "{", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "if", "(", "$", "optional"...
Loads a config file and merges its contents with the previously loaded settings @param string the name of the file to load @param bool whether the file is optional @param mixed the name of the variable to save as the data @param bool whether the config should merge recursively @chainable
[ "Loads", "a", "config", "file", "and", "merges", "its", "contents", "with", "the", "previously", "loaded", "settings" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Config/FileConfig.php#L65-L91
train
BlackBoxRepo/PandoContentBundle
Service/TemplateFinderService.php
TemplateFinderService.find
public function find(PageDocument $page) { $request = $this->requestStack->getCurrentRequest(); $template = $page->getDefault(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY); if ($template === null) { $defaults = []; /** @var RouteEnhancerInterface $enhancer */ foreach ($this->dynamicRouter->getRouteEnhancers() as $enhancer) { $defaults = array_merge($defaults, $enhancer->enhance(['_content' => $page], $request)); } if (array_key_exists(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY, $defaults)) { $template = $defaults[AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY]; } } return $template; }
php
public function find(PageDocument $page) { $request = $this->requestStack->getCurrentRequest(); $template = $page->getDefault(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY); if ($template === null) { $defaults = []; /** @var RouteEnhancerInterface $enhancer */ foreach ($this->dynamicRouter->getRouteEnhancers() as $enhancer) { $defaults = array_merge($defaults, $enhancer->enhance(['_content' => $page], $request)); } if (array_key_exists(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY, $defaults)) { $template = $defaults[AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY]; } } return $template; }
[ "public", "function", "find", "(", "PageDocument", "$", "page", ")", "{", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "$", "template", "=", "$", "page", "->", "getDefault", "(", "AbstractPhpcrDocument", ...
Returns the default template for a given page @param PageDocument $page @return string|null
[ "Returns", "the", "default", "template", "for", "a", "given", "page" ]
fa54d0c7542c1d359a5dbb4f32dab3e195e41007
https://github.com/BlackBoxRepo/PandoContentBundle/blob/fa54d0c7542c1d359a5dbb4f32dab3e195e41007/Service/TemplateFinderService.php#L51-L70
train
Nobiles2/pcc-3-deklaracja
PCC3/Deklaracja.php
Deklaracja.setPodmiot1
public function setPodmiot1(\KCH\PCC3\Deklaracja\Podmiot1AnonymousType $podmiot1) { $this->podmiot1 = $podmiot1; return $this; }
php
public function setPodmiot1(\KCH\PCC3\Deklaracja\Podmiot1AnonymousType $podmiot1) { $this->podmiot1 = $podmiot1; return $this; }
[ "public", "function", "setPodmiot1", "(", "\\", "KCH", "\\", "PCC3", "\\", "Deklaracja", "\\", "Podmiot1AnonymousType", "$", "podmiot1", ")", "{", "$", "this", "->", "podmiot1", "=", "$", "podmiot1", ";", "return", "$", "this", ";", "}" ]
Sets a new podmiot1 Dane podatnika dokonującego zapłaty lub zwolnionego z podatku na podstawie art. 9 pkt 10 lit. b ustawy @param \KCH\PCC3\Deklaracja\Podmiot1AnonymousType $podmiot1 @return self
[ "Sets", "a", "new", "podmiot1" ]
8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106
https://github.com/Nobiles2/pcc-3-deklaracja/blob/8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106/PCC3/Deklaracja.php#L99-L103
train
Nobiles2/pcc-3-deklaracja
PCC3/Deklaracja.php
Deklaracja.setZalaczniki
public function setZalaczniki(\KCH\PCC3\Deklaracja\ZalacznikiAnonymousType $zalaczniki) { $this->zalaczniki = $zalaczniki; return $this; }
php
public function setZalaczniki(\KCH\PCC3\Deklaracja\ZalacznikiAnonymousType $zalaczniki) { $this->zalaczniki = $zalaczniki; return $this; }
[ "public", "function", "setZalaczniki", "(", "\\", "KCH", "\\", "PCC3", "\\", "Deklaracja", "\\", "ZalacznikiAnonymousType", "$", "zalaczniki", ")", "{", "$", "this", "->", "zalaczniki", "=", "$", "zalaczniki", ";", "return", "$", "this", ";", "}" ]
Sets a new zalaczniki @param \KCH\PCC3\Deklaracja\ZalacznikiAnonymousType $zalaczniki @return self
[ "Sets", "a", "new", "zalaczniki" ]
8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106
https://github.com/Nobiles2/pcc-3-deklaracja/blob/8c36b2bc70f7ab0ebc8a0d68a0326f4c20e35106/PCC3/Deklaracja.php#L197-L201
train
spiritdead/resque
components/workers/base/ResqueWorkerBase.php
ResqueWorkerBase.restore
public function restore($workerInstance) { list($hostname, $pid, $queues) = explode(':', $workerInstance, 3); if (!is_array($queues)) { $queues = explode(',', $queues); } $this->queues = $queues; $this->pid = $pid; $this->id = $workerInstance; //regenerate worker $data = $this->resqueInstance->redis->get($this->workerName() . ':' . $workerInstance); if ($data !== false) { $data = json_decode($data, true); $this->currentJob = new ResqueJobBase($this->resqueInstance, $data['queue'], $data['payload'], true); } $workerPids = self::workerPids(); if (!in_array($pid, $workerPids)) { $this->unregisterWorker(); return false; } return true; }
php
public function restore($workerInstance) { list($hostname, $pid, $queues) = explode(':', $workerInstance, 3); if (!is_array($queues)) { $queues = explode(',', $queues); } $this->queues = $queues; $this->pid = $pid; $this->id = $workerInstance; //regenerate worker $data = $this->resqueInstance->redis->get($this->workerName() . ':' . $workerInstance); if ($data !== false) { $data = json_decode($data, true); $this->currentJob = new ResqueJobBase($this->resqueInstance, $data['queue'], $data['payload'], true); } $workerPids = self::workerPids(); if (!in_array($pid, $workerPids)) { $this->unregisterWorker(); return false; } return true; }
[ "public", "function", "restore", "(", "$", "workerInstance", ")", "{", "list", "(", "$", "hostname", ",", "$", "pid", ",", "$", "queues", ")", "=", "explode", "(", "':'", ",", "$", "workerInstance", ",", "3", ")", ";", "if", "(", "!", "is_array", "...
Method for regenerate worker from the current ID saved in the redis and the instance in the server @param $workerInstance @return boolean // Success or Fail
[ "Method", "for", "regenerate", "worker", "from", "the", "current", "ID", "saved", "in", "the", "redis", "and", "the", "instance", "in", "the", "server" ]
6d1f58c5a15a7f50a90ca08f882e64bc07488cc4
https://github.com/spiritdead/resque/blob/6d1f58c5a15a7f50a90ca08f882e64bc07488cc4/components/workers/base/ResqueWorkerBase.php#L114-L135
train
silinternational/psr3-adapters
src/LoggerBase.php
LoggerBase.interpolateString
private function interpolateString($message, array $context = []) { // Build a replacement array with braces around the context keys. $replace = []; foreach ($context as $key => $value) { // Check that the value can be cast to string. if (!is_array($value) && (!is_object($value) || method_exists($value, '__toString'))) { $replace['{' . $key . '}'] = $value; } } // Interpolate replacement values into the message. $result = strtr($message, $replace); if (is_string($result)) { return $result; } /* If something went wrong, return the original message (with a * warning). */ return sprintf( '%s (WARNING: Unable to interpolate the context values into the message. %s).', $message, var_export($replace, true) ); }
php
private function interpolateString($message, array $context = []) { // Build a replacement array with braces around the context keys. $replace = []; foreach ($context as $key => $value) { // Check that the value can be cast to string. if (!is_array($value) && (!is_object($value) || method_exists($value, '__toString'))) { $replace['{' . $key . '}'] = $value; } } // Interpolate replacement values into the message. $result = strtr($message, $replace); if (is_string($result)) { return $result; } /* If something went wrong, return the original message (with a * warning). */ return sprintf( '%s (WARNING: Unable to interpolate the context values into the message. %s).', $message, var_export($replace, true) ); }
[ "private", "function", "interpolateString", "(", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", "{", "// Build a replacement array with braces around the context keys.", "$", "replace", "=", "[", "]", ";", "foreach", "(", "$", "context", "as", ...
Interpolate context values into the given string. This is based heavily on the example implementation here: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message @param string $message The message (potentially with placeholders). @param array $context (Optional:) The array of values to insert into the corresponding placeholders. @return string The resulting string.
[ "Interpolate", "context", "values", "into", "the", "given", "string", "." ]
dd091be5b23f1f86fbb404dba2c4cf700e2ba9f9
https://github.com/silinternational/psr3-adapters/blob/dd091be5b23f1f86fbb404dba2c4cf700e2ba9f9/src/LoggerBase.php#L51-L76
train
rozaverta/cmf
core/Prop.php
Prop.file
public static function file( $name, & $exists = false ) { if( !defined("APP_DIR") ) { return []; } $file = APP_DIR . "config" . DIRECTORY_SEPARATOR . $name . '.php'; if( file_exists( $file ) ) { $data = Helper::includeImport($file); $exists = true; } if( ! isset( $data ) || ! is_array( $data ) ) { $data = []; } return $data; }
php
public static function file( $name, & $exists = false ) { if( !defined("APP_DIR") ) { return []; } $file = APP_DIR . "config" . DIRECTORY_SEPARATOR . $name . '.php'; if( file_exists( $file ) ) { $data = Helper::includeImport($file); $exists = true; } if( ! isset( $data ) || ! is_array( $data ) ) { $data = []; } return $data; }
[ "public", "static", "function", "file", "(", "$", "name", ",", "&", "$", "exists", "=", "false", ")", "{", "if", "(", "!", "defined", "(", "\"APP_DIR\"", ")", ")", "{", "return", "[", "]", ";", "}", "$", "file", "=", "APP_DIR", ".", "\"config\"", ...
Get array data from file @param $name @param bool $exists @return array
[ "Get", "array", "data", "from", "file" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L84-L104
train
rozaverta/cmf
core/Prop.php
Prop.cache
public static function cache( $name ) { static $cache = []; $name = (string) $name; if( ! isset($cache[$name]) ) { $cache[$name] = new self($name); } return $cache[$name]; }
php
public static function cache( $name ) { static $cache = []; $name = (string) $name; if( ! isset($cache[$name]) ) { $cache[$name] = new self($name); } return $cache[$name]; }
[ "public", "static", "function", "cache", "(", "$", "name", ")", "{", "static", "$", "cache", "=", "[", "]", ";", "$", "name", "=", "(", "string", ")", "$", "name", ";", "if", "(", "!", "isset", "(", "$", "cache", "[", "$", "name", "]", ")", "...
Get cache property from file @param $name @return Prop
[ "Get", "cache", "property", "from", "file" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L112-L124
train
rozaverta/cmf
core/Prop.php
Prop.group
public function group( $name ) { $name = rtrim($name, '.'); $pref = $name . '.'; $len = strlen($pref); $data = []; foreach( array_keys($this->items) as $key ) { if( $key === $name ) { $data['.'] = $this->items[$key]; } else if( strlen($key) > $len && substr($key, 0, $len) === $pref ) { $data[substr($key, $len)] = $this->items[$key]; } } return new self($data); }
php
public function group( $name ) { $name = rtrim($name, '.'); $pref = $name . '.'; $len = strlen($pref); $data = []; foreach( array_keys($this->items) as $key ) { if( $key === $name ) { $data['.'] = $this->items[$key]; } else if( strlen($key) > $len && substr($key, 0, $len) === $pref ) { $data[substr($key, $len)] = $this->items[$key]; } } return new self($data); }
[ "public", "function", "group", "(", "$", "name", ")", "{", "$", "name", "=", "rtrim", "(", "$", "name", ",", "'.'", ")", ";", "$", "pref", "=", "$", "name", ".", "'.'", ";", "$", "len", "=", "strlen", "(", "$", "pref", ")", ";", "$", "data", ...
Get new property group @param $name @return Prop
[ "Get", "new", "property", "group" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L210-L230
train
rozaverta/cmf
core/Prop.php
Prop.pathSet
public function pathSet( $path, $value ) { $path = $this->createPath($path); if( $path[0] == 1 ) { $this->offsetSet($path[1], $value); } else { $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( $i == $len ) { $array[$key] = $value; } else { if( !isset($array[$key]) || !is_array($array[$key]) ) { $array[$key] = []; } $array = & $array[$key]; } } } return $this; }
php
public function pathSet( $path, $value ) { $path = $this->createPath($path); if( $path[0] == 1 ) { $this->offsetSet($path[1], $value); } else { $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( $i == $len ) { $array[$key] = $value; } else { if( !isset($array[$key]) || !is_array($array[$key]) ) { $array[$key] = []; } $array = & $array[$key]; } } } return $this; }
[ "public", "function", "pathSet", "(", "$", "path", ",", "$", "value", ")", "{", "$", "path", "=", "$", "this", "->", "createPath", "(", "$", "path", ")", ";", "if", "(", "$", "path", "[", "0", "]", "==", "1", ")", "{", "$", "this", "->", "off...
Set value for path. @example $this->pathSet( 'a.b.c', $value ) => $this->items['a']['b']['c'] = $value; @param string $path @param mixed $value @return $this
[ "Set", "value", "for", "path", "." ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L252-L281
train
rozaverta/cmf
core/Prop.php
Prop.pathGetIs
public function pathGetIs( $path, $accessible = false ) { $path = $this->createPath($path); $array = & $this->items; $key = $path[1]; if( $path[0] > 1 ) { for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { return false; } if( $i < $len ) { if( is_array($array[$key]) ) { $array = & $array[$key]; } else { return false; } } } } else if( ! array_key_exists($key, $array) ) { return false; } if( $accessible ) { return is_array($array[$key]); } return true; }
php
public function pathGetIs( $path, $accessible = false ) { $path = $this->createPath($path); $array = & $this->items; $key = $path[1]; if( $path[0] > 1 ) { for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { return false; } if( $i < $len ) { if( is_array($array[$key]) ) { $array = & $array[$key]; } else { return false; } } } } else if( ! array_key_exists($key, $array) ) { return false; } if( $accessible ) { return is_array($array[$key]); } return true; }
[ "public", "function", "pathGetIs", "(", "$", "path", ",", "$", "accessible", "=", "false", ")", "{", "$", "path", "=", "$", "this", "->", "createPath", "(", "$", "path", ")", ";", "$", "array", "=", "&", "$", "this", "->", "items", ";", "$", "key...
Check value exists for path exist. @param string $path @param bool $accessible @return bool
[ "Check", "value", "exists", "for", "path", "exist", "." ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L290-L329
train
rozaverta/cmf
core/Prop.php
Prop.pathGetOr
public function pathGetOr( $path, $default ) { $path = $this->createPath($path); if( $path[0] == 1 ) { return $this->get($path[1]); } $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { break; } if( $i == $len ) { return $array[$key]; } if( !isset($array[$key]) || !is_array($array[$key]) ) { break; } $array = & $array[$key]; } return $default; }
php
public function pathGetOr( $path, $default ) { $path = $this->createPath($path); if( $path[0] == 1 ) { return $this->get($path[1]); } $array = & $this->items; for( $i = 1, $len = $path[0]; $i <= $len; $i++ ) { $key = $path[$i]; if( ! array_key_exists($key, $array) ) { break; } if( $i == $len ) { return $array[$key]; } if( !isset($array[$key]) || !is_array($array[$key]) ) { break; } $array = & $array[$key]; } return $default; }
[ "public", "function", "pathGetOr", "(", "$", "path", ",", "$", "default", ")", "{", "$", "path", "=", "$", "this", "->", "createPath", "(", "$", "path", ")", ";", "if", "(", "$", "path", "[", "0", "]", "==", "1", ")", "{", "return", "$", "this"...
Get value from path or get default value if not exists. @param string $path @param mixed $default @return mixed
[ "Get", "value", "from", "path", "or", "get", "default", "value", "if", "not", "exists", "." ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Prop.php#L349-L380
train
phn-io/compilation
spec/Phn/Compilation/LoopSpec.php
LoopSpec.it_provides_useful_information_about_iterations
function it_provides_useful_information_about_iterations() { $this->next('one'); $this->getIndex()->shouldBe(0); $this->getKey()->shouldBe('one'); $this->isFirst()->shouldBe(true); $this->isLast()->shouldBe(false); $this->next('two'); $this->getIndex()->shouldBe(1); $this->getKey()->shouldBe('two'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(false); $this->next('three'); $this->getIndex()->shouldBe(2); $this->getKey()->shouldBe('three'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(true); }
php
function it_provides_useful_information_about_iterations() { $this->next('one'); $this->getIndex()->shouldBe(0); $this->getKey()->shouldBe('one'); $this->isFirst()->shouldBe(true); $this->isLast()->shouldBe(false); $this->next('two'); $this->getIndex()->shouldBe(1); $this->getKey()->shouldBe('two'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(false); $this->next('three'); $this->getIndex()->shouldBe(2); $this->getKey()->shouldBe('three'); $this->isFirst()->shouldBe(false); $this->isLast()->shouldBe(true); }
[ "function", "it_provides_useful_information_about_iterations", "(", ")", "{", "$", "this", "->", "next", "(", "'one'", ")", ";", "$", "this", "->", "getIndex", "(", ")", "->", "shouldBe", "(", "0", ")", ";", "$", "this", "->", "getKey", "(", ")", "->", ...
It provides useful information about iterations.
[ "It", "provides", "useful", "information", "about", "iterations", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/spec/Phn/Compilation/LoopSpec.php#L41-L60
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.init
public static function init($config) { if (static::$initialized) { throw new \FuelException("You can't initialize Fuel more than once."); } // BC FIX FOR APPLICATIONS <= 1.6.1, makes Redis_Db available as Redis, // like it was in versions before 1.7 class_exists('Redis', false) or class_alias('Redis_Db', 'Redis'); static::$_paths = array(APPPATH, COREPATH); // Is Fuel running on the command line? static::$is_cli = (bool) defined('STDIN'); \Config::load($config); // Disable output compression if the client doesn't support it if (static::$is_cli or ! in_array('gzip', explode(', ', \Input::headers('Accept-Encoding', '')))) { \Config::set('ob_callback', null); } // Start up output buffering ob_start(\Config::get('ob_callback')); if (\Config::get('caching', false)) { \Finder::instance()->read_cache('FuelFileFinder'); } static::$profiling = \Config::get('profiling', false); static::$profiling and \Profiler::init(); // set a default timezone if one is defined try { static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get(); date_default_timezone_set(static::$timezone); } catch (\Exception $e) { date_default_timezone_set('UTC'); throw new \PHPErrorException($e->getMessage()); } static::$encoding = \Config::get('encoding', static::$encoding); MBSTRING and mb_internal_encoding(static::$encoding); static::$locale = \Config::get('locale', static::$locale); if ( ! static::$is_cli) { if (\Config::get('base_url') === null) { \Config::set('base_url', static::generate_base_url()); } } // Run Input Filtering \Security::clean_input(); \Event::register('fuel-shutdown', 'Fuel::finish'); // Always load classes, config & language set in always_load.php config static::always_load(); // Load in the routes \Config::load('routes', true); \Router::add(\Config::get('routes')); // Set locale, log warning when it fails if (static::$locale) { setlocale(LC_ALL, static::$locale) or logger(\Fuel::L_WARNING, 'The configured locale '.static::$locale.' is not installed on your system.', __METHOD__); } static::$initialized = true; // fire any app created events \Event::instance()->has_events('app_created') and \Event::instance()->trigger('app_created', '', 'none'); if (static::$profiling) { \Profiler::mark(__METHOD__.' End'); } }
php
public static function init($config) { if (static::$initialized) { throw new \FuelException("You can't initialize Fuel more than once."); } // BC FIX FOR APPLICATIONS <= 1.6.1, makes Redis_Db available as Redis, // like it was in versions before 1.7 class_exists('Redis', false) or class_alias('Redis_Db', 'Redis'); static::$_paths = array(APPPATH, COREPATH); // Is Fuel running on the command line? static::$is_cli = (bool) defined('STDIN'); \Config::load($config); // Disable output compression if the client doesn't support it if (static::$is_cli or ! in_array('gzip', explode(', ', \Input::headers('Accept-Encoding', '')))) { \Config::set('ob_callback', null); } // Start up output buffering ob_start(\Config::get('ob_callback')); if (\Config::get('caching', false)) { \Finder::instance()->read_cache('FuelFileFinder'); } static::$profiling = \Config::get('profiling', false); static::$profiling and \Profiler::init(); // set a default timezone if one is defined try { static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get(); date_default_timezone_set(static::$timezone); } catch (\Exception $e) { date_default_timezone_set('UTC'); throw new \PHPErrorException($e->getMessage()); } static::$encoding = \Config::get('encoding', static::$encoding); MBSTRING and mb_internal_encoding(static::$encoding); static::$locale = \Config::get('locale', static::$locale); if ( ! static::$is_cli) { if (\Config::get('base_url') === null) { \Config::set('base_url', static::generate_base_url()); } } // Run Input Filtering \Security::clean_input(); \Event::register('fuel-shutdown', 'Fuel::finish'); // Always load classes, config & language set in always_load.php config static::always_load(); // Load in the routes \Config::load('routes', true); \Router::add(\Config::get('routes')); // Set locale, log warning when it fails if (static::$locale) { setlocale(LC_ALL, static::$locale) or logger(\Fuel::L_WARNING, 'The configured locale '.static::$locale.' is not installed on your system.', __METHOD__); } static::$initialized = true; // fire any app created events \Event::instance()->has_events('app_created') and \Event::instance()->trigger('app_created', '', 'none'); if (static::$profiling) { \Profiler::mark(__METHOD__.' End'); } }
[ "public", "static", "function", "init", "(", "$", "config", ")", "{", "if", "(", "static", "::", "$", "initialized", ")", "{", "throw", "new", "\\", "FuelException", "(", "\"You can't initialize Fuel more than once.\"", ")", ";", "}", "// BC FIX FOR APPLICATIONS <...
Initializes the framework. This can only be called once. @access public @return void
[ "Initializes", "the", "framework", ".", "This", "can", "only", "be", "called", "once", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L123-L211
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.finish
public static function finish() { if (\Config::get('caching', false)) { \Finder::instance()->write_cache('FuelFileFinder'); } if (static::$profiling and ! static::$is_cli and ! \Input::is_ajax()) { // Grab the output buffer and flush it, we will rebuffer later $output = ob_get_clean(); $headers = headers_list(); $show = true; foreach ($headers as $header) { if (stripos($header, 'content-type') === 0 and stripos($header, 'text/html') === false) { $show = false; } } if ($show) { \Profiler::mark('End of Fuel Execution'); if (preg_match("|</body>.*?</html>|is", $output)) { $output = preg_replace("|</body>.*?</html>|is", '', $output); $output .= \Profiler::output(); $output .= '</body></html>'; } else { $output .= \Profiler::output(); } } // Restart the output buffer and send the new output ob_start(\Config::get('ob_callback')); echo $output; } }
php
public static function finish() { if (\Config::get('caching', false)) { \Finder::instance()->write_cache('FuelFileFinder'); } if (static::$profiling and ! static::$is_cli and ! \Input::is_ajax()) { // Grab the output buffer and flush it, we will rebuffer later $output = ob_get_clean(); $headers = headers_list(); $show = true; foreach ($headers as $header) { if (stripos($header, 'content-type') === 0 and stripos($header, 'text/html') === false) { $show = false; } } if ($show) { \Profiler::mark('End of Fuel Execution'); if (preg_match("|</body>.*?</html>|is", $output)) { $output = preg_replace("|</body>.*?</html>|is", '', $output); $output .= \Profiler::output(); $output .= '</body></html>'; } else { $output .= \Profiler::output(); } } // Restart the output buffer and send the new output ob_start(\Config::get('ob_callback')); echo $output; } }
[ "public", "static", "function", "finish", "(", ")", "{", "if", "(", "\\", "Config", "::", "get", "(", "'caching'", ",", "false", ")", ")", "{", "\\", "Finder", "::", "instance", "(", ")", "->", "write_cache", "(", "'FuelFileFinder'", ")", ";", "}", "...
Cleans up Fuel execution, ends the output buffering, and outputs the buffer contents. @access public @return void
[ "Cleans", "up", "Fuel", "execution", "ends", "the", "output", "buffering", "and", "outputs", "the", "buffer", "contents", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L220-L261
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.generate_base_url
protected static function generate_base_url() { $base_url = ''; if(\Input::server('http_host')) { $base_url .= \Input::protocol().'://'.\Input::server('http_host'); } if (\Input::server('script_name')) { $common = get_common_path(array(\Input::server('request_uri'), \Input::server('script_name'))); $base_url .= $common; } // Add a slash if it is missing and return it return rtrim($base_url, '/').'/'; }
php
protected static function generate_base_url() { $base_url = ''; if(\Input::server('http_host')) { $base_url .= \Input::protocol().'://'.\Input::server('http_host'); } if (\Input::server('script_name')) { $common = get_common_path(array(\Input::server('request_uri'), \Input::server('script_name'))); $base_url .= $common; } // Add a slash if it is missing and return it return rtrim($base_url, '/').'/'; }
[ "protected", "static", "function", "generate_base_url", "(", ")", "{", "$", "base_url", "=", "''", ";", "if", "(", "\\", "Input", "::", "server", "(", "'http_host'", ")", ")", "{", "$", "base_url", ".=", "\\", "Input", "::", "protocol", "(", ")", ".", ...
Generates a base url. @return string the base url
[ "Generates", "a", "base", "url", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L268-L283
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.always_load
public static function always_load($array = null) { is_null($array) and $array = \Config::get('always_load', array()); isset($array['packages']) and \Package::load($array['packages']); isset($array['modules']) and \Module::load($array['modules']); if (isset($array['classes'])) { foreach ($array['classes'] as $class) { if ( ! class_exists($class = \Str::ucwords($class))) { throw new \FuelException('Class '.$class.' defined in your "always_load" config could not be loaded.'); } } } /** * Config and Lang must be either just the filename, example: array(filename) * or the filename as key and the group as value, example: array(filename => some_group) */ if (isset($array['config'])) { foreach ($array['config'] as $config => $config_group) { \Config::load((is_int($config) ? $config_group : $config), (is_int($config) ? true : $config_group)); } } if (isset($array['language'])) { foreach ($array['language'] as $lang => $lang_group) { \Lang::load((is_int($lang) ? $lang_group : $lang), (is_int($lang) ? true : $lang_group)); } } }
php
public static function always_load($array = null) { is_null($array) and $array = \Config::get('always_load', array()); isset($array['packages']) and \Package::load($array['packages']); isset($array['modules']) and \Module::load($array['modules']); if (isset($array['classes'])) { foreach ($array['classes'] as $class) { if ( ! class_exists($class = \Str::ucwords($class))) { throw new \FuelException('Class '.$class.' defined in your "always_load" config could not be loaded.'); } } } /** * Config and Lang must be either just the filename, example: array(filename) * or the filename as key and the group as value, example: array(filename => some_group) */ if (isset($array['config'])) { foreach ($array['config'] as $config => $config_group) { \Config::load((is_int($config) ? $config_group : $config), (is_int($config) ? true : $config_group)); } } if (isset($array['language'])) { foreach ($array['language'] as $lang => $lang_group) { \Lang::load((is_int($lang) ? $lang_group : $lang), (is_int($lang) ? true : $lang_group)); } } }
[ "public", "static", "function", "always_load", "(", "$", "array", "=", "null", ")", "{", "is_null", "(", "$", "array", ")", "and", "$", "array", "=", "\\", "Config", "::", "get", "(", "'always_load'", ",", "array", "(", ")", ")", ";", "isset", "(", ...
Always load packages, modules, classes, config & language files set in always_load.php config @param array what to autoload
[ "Always", "load", "packages", "modules", "classes", "config", "&", "language", "files", "set", "in", "always_load", ".", "php", "config" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L301-L340
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/fuel.php
Fuel.clean_path
public static function clean_path($path) { static $search = array(APPPATH, COREPATH, PKGPATH, DOCROOT, '\\'); static $replace = array('APPPATH/', 'COREPATH/', 'PKGPATH/', 'DOCROOT/', '/'); return str_ireplace($search, $replace, $path); }
php
public static function clean_path($path) { static $search = array(APPPATH, COREPATH, PKGPATH, DOCROOT, '\\'); static $replace = array('APPPATH/', 'COREPATH/', 'PKGPATH/', 'DOCROOT/', '/'); return str_ireplace($search, $replace, $path); }
[ "public", "static", "function", "clean_path", "(", "$", "path", ")", "{", "static", "$", "search", "=", "array", "(", "APPPATH", ",", "COREPATH", ",", "PKGPATH", ",", "DOCROOT", ",", "'\\\\'", ")", ";", "static", "$", "replace", "=", "array", "(", "'AP...
Cleans a file path so that it does not contain absolute file paths. @param string the filepath @return string the clean path
[ "Cleans", "a", "file", "path", "so", "that", "it", "does", "not", "contain", "absolute", "file", "paths", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/fuel.php#L361-L366
train
chenwenzhang/initially-rpc
src/Initially/Rpc/Transport/Transport.php
Transport.send
public function send(Request $request) { $interface = $request->getInterface(); $service = ConfigFactory::getClient()->getService($interface); $url = $service->getUrl(); $requestRaw = Formatter::serialize($request); $responseRaw = $this->protocol->sendData($url, $requestRaw); $response = @Formatter::unserialize($responseRaw); if (!($response instanceof Response)) { LoggerProxy::getInstance()->error("illegal response", array($responseRaw)); throw new InitiallyRpcException("illegal response"); } elseif ($response->isHasException()) { $exception = $response->getException(); if (is_object($exception) && $exception instanceof Exception) { throw $exception; } else if (is_string($exception)) { if (class_exists($exception)) { throw new $exception($response->getExceptionMessage()); } else { throw new InitiallyRpcException($response->getExceptionMessage()); } } } return $response->getResult(); }
php
public function send(Request $request) { $interface = $request->getInterface(); $service = ConfigFactory::getClient()->getService($interface); $url = $service->getUrl(); $requestRaw = Formatter::serialize($request); $responseRaw = $this->protocol->sendData($url, $requestRaw); $response = @Formatter::unserialize($responseRaw); if (!($response instanceof Response)) { LoggerProxy::getInstance()->error("illegal response", array($responseRaw)); throw new InitiallyRpcException("illegal response"); } elseif ($response->isHasException()) { $exception = $response->getException(); if (is_object($exception) && $exception instanceof Exception) { throw $exception; } else if (is_string($exception)) { if (class_exists($exception)) { throw new $exception($response->getExceptionMessage()); } else { throw new InitiallyRpcException($response->getExceptionMessage()); } } } return $response->getResult(); }
[ "public", "function", "send", "(", "Request", "$", "request", ")", "{", "$", "interface", "=", "$", "request", "->", "getInterface", "(", ")", ";", "$", "service", "=", "ConfigFactory", "::", "getClient", "(", ")", "->", "getService", "(", "$", "interfac...
Send Rpc Request @param Request $request @return mixed @throws InitiallyRpcException
[ "Send", "Rpc", "Request" ]
43d56eb3749bedd3f4ee83e57676f7bb6b89e682
https://github.com/chenwenzhang/initially-rpc/blob/43d56eb3749bedd3f4ee83e57676f7bb6b89e682/src/Initially/Rpc/Transport/Transport.php#L62-L88
train
moaction/jsonrpc-client
src/Moaction/Jsonrpc/Client/ClientBasic.php
ClientBasic.send
protected function send($content) { $streamOptions = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => $content, ) ); $context = stream_context_create($streamOptions); $result = @file_get_contents($this->getServerUrl(), false, $context); if ($result === false) { throw new Exception('Unable to connect to server'); } return $result; }
php
protected function send($content) { $streamOptions = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => $content, ) ); $context = stream_context_create($streamOptions); $result = @file_get_contents($this->getServerUrl(), false, $context); if ($result === false) { throw new Exception('Unable to connect to server'); } return $result; }
[ "protected", "function", "send", "(", "$", "content", ")", "{", "$", "streamOptions", "=", "array", "(", "'http'", "=>", "array", "(", "'method'", "=>", "'POST'", ",", "'header'", "=>", "'Content-Type: application/json'", ",", "'content'", "=>", "$", "content"...
Send low level data by http @param string $content @return string @throws Exception
[ "Send", "low", "level", "data", "by", "http" ]
cbfb6caeae7dce838cb0f429ae4a60e4ead5ee0c
https://github.com/moaction/jsonrpc-client/blob/cbfb6caeae7dce838cb0f429ae4a60e4ead5ee0c/src/Moaction/Jsonrpc/Client/ClientBasic.php#L43-L61
train
CakeCMS/Community
src/Notify/Email.php
Email.sendActivationMessage
public function sendActivationMessage() { $macros = new Macros($this->_data); $message = $this->_params->get('msg_account_activate_msg'); $message = $macros->text($message); $subject = $this->_params->get('msg_account_activate_subject'); return $this->send($subject, $message, $this->_data->email, null, $this->_getFromMail()); }
php
public function sendActivationMessage() { $macros = new Macros($this->_data); $message = $this->_params->get('msg_account_activate_msg'); $message = $macros->text($message); $subject = $this->_params->get('msg_account_activate_subject'); return $this->send($subject, $message, $this->_data->email, null, $this->_getFromMail()); }
[ "public", "function", "sendActivationMessage", "(", ")", "{", "$", "macros", "=", "new", "Macros", "(", "$", "this", "->", "_data", ")", ";", "$", "message", "=", "$", "this", "->", "_params", "->", "get", "(", "'msg_account_activate_msg'", ")", ";", "$"...
Send user message when have success activation profile. @return array
[ "Send", "user", "message", "when", "have", "success", "activation", "profile", "." ]
cc2bdb596dd9617d42fd81f59e981024caa062e8
https://github.com/CakeCMS/Community/blob/cc2bdb596dd9617d42fd81f59e981024caa062e8/src/Notify/Email.php#L45-L53
train
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.addAuthor
public function addAuthor(string $name = null, string $email = null) { is_null($name) and $name = ''; is_null($email) and $email = ''; if (empty($name) and empty($email)) { throw new AuthorNoDataException(); } if (!empty($email)) { $author = trim(sprintf(self::FORMAT_AUTHOR, $name, $email)); } else { $author = trim($name); } $this->authors[] = $author; return $this; }
php
public function addAuthor(string $name = null, string $email = null) { is_null($name) and $name = ''; is_null($email) and $email = ''; if (empty($name) and empty($email)) { throw new AuthorNoDataException(); } if (!empty($email)) { $author = trim(sprintf(self::FORMAT_AUTHOR, $name, $email)); } else { $author = trim($name); } $this->authors[] = $author; return $this; }
[ "public", "function", "addAuthor", "(", "string", "$", "name", "=", "null", ",", "string", "$", "email", "=", "null", ")", "{", "is_null", "(", "$", "name", ")", "and", "$", "name", "=", "''", ";", "is_null", "(", "$", "email", ")", "and", "$", "...
Adds an author @param string $name @param string $email @return IntercessionClass @throws AuthorNoDataException
[ "Adds", "an", "author" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L216-L234
train
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.addInterface
public function addInterface(string $interfaceName, string $alias = null) { $this->interfaces[] = $this->addUse($interfaceName, $alias); }
php
public function addInterface(string $interfaceName, string $alias = null) { $this->interfaces[] = $this->addUse($interfaceName, $alias); }
[ "public", "function", "addInterface", "(", "string", "$", "interfaceName", ",", "string", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "interfaces", "[", "]", "=", "$", "this", "->", "addUse", "(", "$", "interfaceName", ",", "$", "alias", ")...
Adds an interface @param string $interfaceName @param string $alias @throws DuplicateUseWithAliasException
[ "Adds", "an", "interface" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L302-L305
train
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.addTrait
public function addTrait(string $traitName, string $alias = null) { $this->traits[] = $this->addUse($traitName, $alias); return $this; }
php
public function addTrait(string $traitName, string $alias = null) { $this->traits[] = $this->addUse($traitName, $alias); return $this; }
[ "public", "function", "addTrait", "(", "string", "$", "traitName", ",", "string", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "traits", "[", "]", "=", "$", "this", "->", "addUse", "(", "$", "traitName", ",", "$", "alias", ")", ";", "ret...
Adds a trait @param string $traitName @param string $alias @return IntercessionClass
[ "Adds", "a", "trait" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L325-L330
train
Thuata/IntercessionBundle
Intercession/IntercessionClass.php
IntercessionClass.extractClassNameFromUse
public function extractClassNameFromUse(string $use) { $matches = []; if (preg_match(self::USE_CLASS_EXTRACT_REGEXP, $use, $matches) === 0) { throw new InvalidNamespaceException($use); } $className = $matches['classname']; $namespace = array_key_exists('namespace', $matches) ? $matches['namespace'] : ''; if (substr($namespace, -1, 1) === '\\') { $namespace = substr($namespace, 0, -1); } return [ $className, $namespace ]; }
php
public function extractClassNameFromUse(string $use) { $matches = []; if (preg_match(self::USE_CLASS_EXTRACT_REGEXP, $use, $matches) === 0) { throw new InvalidNamespaceException($use); } $className = $matches['classname']; $namespace = array_key_exists('namespace', $matches) ? $matches['namespace'] : ''; if (substr($namespace, -1, 1) === '\\') { $namespace = substr($namespace, 0, -1); } return [ $className, $namespace ]; }
[ "public", "function", "extractClassNameFromUse", "(", "string", "$", "use", ")", "{", "$", "matches", "=", "[", "]", ";", "if", "(", "preg_match", "(", "self", "::", "USE_CLASS_EXTRACT_REGEXP", ",", "$", "use", ",", "$", "matches", ")", "===", "0", ")", ...
Extracts the class name from a used namespaced class @param string $use @return mixed @throws InvalidNamespaceException
[ "Extracts", "the", "class", "name", "from", "a", "used", "namespaced", "class" ]
5dc223e162e8ba491825e105f1e43fad7578841d
https://github.com/Thuata/IntercessionBundle/blob/5dc223e162e8ba491825e105f1e43fad7578841d/Intercession/IntercessionClass.php#L427-L446
train
Malwarebytes/AltamiraBundle
ScriptHandler.php
ScriptHandler.installJSDependencies
public static function installJSDependencies($event) { echo "Installing JS Library dependencies for the AltamiraBundle\n"; $dir = getcwd(); ScriptHandler::gitSubmodulesUpdate(); ScriptHandler::cleanPublicJSDir(); // discovered that assetic can minify all the code - all not necessary anymore. /* echo "Compiling jqplot\n"; chdir(static::getLibsDir().DIRECTORY_SEPARATOR."jqplot"); exec('ant clean min', $output, $status); if ($status) { die("Ant failed with $status (is ant installed?)\n"); } chdir($dir); echo "Compiling flot\n"; $flotLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot"; if (($files = scandir($flotLib)) ===false ) { die("failed to traverse through flot directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { exec(static::getYUIBin(). " ".escapeshellarg($flotLib.DIRECTORY_SEPARATOR.$file)." -o " .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); } } echo "Compiling flot bubbles\n"; $flotBubblesLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot-bubbles"; if (($files = scandir($flotBubblesLib)) ===false ) { die("failed to traverse through flot bubbles directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { // minification did not work out, so commented min code. // exec(static::getYUIBin(). " ".escapeshellarg($flotBubblesLib.DIRECTORY_SEPARATOR.$file) ." -o " // .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); // straight copy to min.js for compatibility with min setting in altamira copy($flotBubblesLib.DIRECTORY_SEPARATOR.$file,static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js"); } }*/ echo "Installing jqplot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."jqplot",0777,true); $source = static::getLibsDir().DIRECTORY_SEPARATOR."jqplot".DIRECTORY_SEPARATOR."src"; $dest= static::getJSDir().DIRECTORY_SEPARATOR."jqplot"; recursiveAssetsOnlyCopy($source,$dest); echo "Installing flot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot",static::getJSDir().DIRECTORY_SEPARATOR."flot"); echo "Installing flot-bubbles\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles",static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles"); }
php
public static function installJSDependencies($event) { echo "Installing JS Library dependencies for the AltamiraBundle\n"; $dir = getcwd(); ScriptHandler::gitSubmodulesUpdate(); ScriptHandler::cleanPublicJSDir(); // discovered that assetic can minify all the code - all not necessary anymore. /* echo "Compiling jqplot\n"; chdir(static::getLibsDir().DIRECTORY_SEPARATOR."jqplot"); exec('ant clean min', $output, $status); if ($status) { die("Ant failed with $status (is ant installed?)\n"); } chdir($dir); echo "Compiling flot\n"; $flotLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot"; if (($files = scandir($flotLib)) ===false ) { die("failed to traverse through flot directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { exec(static::getYUIBin(). " ".escapeshellarg($flotLib.DIRECTORY_SEPARATOR.$file)." -o " .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); } } echo "Compiling flot bubbles\n"; $flotBubblesLib=static::getLibsDir() .DIRECTORY_SEPARATOR."flot-bubbles"; if (($files = scandir($flotBubblesLib)) ===false ) { die("failed to traverse through flot bubbles directory"); } foreach ($files as $file) { if (substr($file,-3) == ".js") { // minification did not work out, so commented min code. // exec(static::getYUIBin(). " ".escapeshellarg($flotBubblesLib.DIRECTORY_SEPARATOR.$file) ." -o " // .escapeshellarg(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js")); // straight copy to min.js for compatibility with min setting in altamira copy($flotBubblesLib.DIRECTORY_SEPARATOR.$file,static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles".DIRECTORY_SEPARATOR.substr($file,0,-2)."min.js"); } }*/ echo "Installing jqplot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."jqplot",0777,true); $source = static::getLibsDir().DIRECTORY_SEPARATOR."jqplot".DIRECTORY_SEPARATOR."src"; $dest= static::getJSDir().DIRECTORY_SEPARATOR."jqplot"; recursiveAssetsOnlyCopy($source,$dest); echo "Installing flot\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot",static::getJSDir().DIRECTORY_SEPARATOR."flot"); echo "Installing flot-bubbles\n"; mkdir(static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles",0777,true); recursiveAssetsOnlyCopy(static::getLibsDir().DIRECTORY_SEPARATOR."flot-bubbles",static::getJSDir().DIRECTORY_SEPARATOR."flot-bubbles"); }
[ "public", "static", "function", "installJSDependencies", "(", "$", "event", ")", "{", "echo", "\"Installing JS Library dependencies for the AltamiraBundle\\n\"", ";", "$", "dir", "=", "getcwd", "(", ")", ";", "ScriptHandler", "::", "gitSubmodulesUpdate", "(", ")", ";"...
if this gets any bigger, break it up into separate methods
[ "if", "this", "gets", "any", "bigger", "break", "it", "up", "into", "separate", "methods" ]
f42a7c1b27b8d8f15ada10f20571f74b3f95f406
https://github.com/Malwarebytes/AltamiraBundle/blob/f42a7c1b27b8d8f15ada10f20571f74b3f95f406/ScriptHandler.php#L51-L114
train
tkhatibi/php-field
src/FieldFactory.php
FieldFactory.getInstance
public static function getInstance(array $config = []) { // If element has no name if (!isset($config['name'])){ throw new \Exception("You have to set the name of the field", 1); } if(!isset($config['class'])){ $config['class'] = Text::className(); } return parent::getInstance($config); }
php
public static function getInstance(array $config = []) { // If element has no name if (!isset($config['name'])){ throw new \Exception("You have to set the name of the field", 1); } if(!isset($config['class'])){ $config['class'] = Text::className(); } return parent::getInstance($config); }
[ "public", "static", "function", "getInstance", "(", "array", "$", "config", "=", "[", "]", ")", "{", "// If element has no name\r", "if", "(", "!", "isset", "(", "$", "config", "[", "'name'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", ...
Builds the field and returns it @param array $name field config @return Field instance @throws Exception if the name of the field not found in config array
[ "Builds", "the", "field", "and", "returns", "it" ]
629657a7f96353ab6caf11ca9319a17ede719b76
https://github.com/tkhatibi/php-field/blob/629657a7f96353ab6caf11ca9319a17ede719b76/src/FieldFactory.php#L28-L37
train
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.rewindFile
public function rewindFile() { $this->openFile(); if(!rewind($this->getFile())) { throw FileOperationException::createForFailedToRewindFile($this->getFilePath()); } return $this; }
php
public function rewindFile() { $this->openFile(); if(!rewind($this->getFile())) { throw FileOperationException::createForFailedToRewindFile($this->getFilePath()); } return $this; }
[ "public", "function", "rewindFile", "(", ")", "{", "$", "this", "->", "openFile", "(", ")", ";", "if", "(", "!", "rewind", "(", "$", "this", "->", "getFile", "(", ")", ")", ")", "{", "throw", "FileOperationException", "::", "createForFailedToRewindFile", ...
Rewind the file @return $this @throws AtomicFileException
[ "Rewind", "the", "file" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L65-L73
train
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.isFileEmpty
public function isFileEmpty() { $this->openFile(); $saved_pointer = $this->getFilePointer(); $this->rewindFile()->seekFileToEnd(); $size_pointer = $this->getFilePointer(); $this->seekFile($saved_pointer); return $size_pointer === 0; }
php
public function isFileEmpty() { $this->openFile(); $saved_pointer = $this->getFilePointer(); $this->rewindFile()->seekFileToEnd(); $size_pointer = $this->getFilePointer(); $this->seekFile($saved_pointer); return $size_pointer === 0; }
[ "public", "function", "isFileEmpty", "(", ")", "{", "$", "this", "->", "openFile", "(", ")", ";", "$", "saved_pointer", "=", "$", "this", "->", "getFilePointer", "(", ")", ";", "$", "this", "->", "rewindFile", "(", ")", "->", "seekFileToEnd", "(", ")",...
Find whether file is empty @return bool @throws AtomicFileException
[ "Find", "whether", "file", "is", "empty" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L142-L151
train
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.checkFile
protected function checkFile($writable = true) { if(!$this->fileExists()) throw NonExistentFileException::createForFileDoesNotExists($this->getFilePath()); if(!is_readable($this->file_path)) throw NotReadableFileException::createForNotReadable($this->getFilePath()); if($writable) { if(!is_writable($this->file_path)) throw NotWritableFileException::createForNotWritable($this->getFilePath()); } }
php
protected function checkFile($writable = true) { if(!$this->fileExists()) throw NonExistentFileException::createForFileDoesNotExists($this->getFilePath()); if(!is_readable($this->file_path)) throw NotReadableFileException::createForNotReadable($this->getFilePath()); if($writable) { if(!is_writable($this->file_path)) throw NotWritableFileException::createForNotWritable($this->getFilePath()); } }
[ "protected", "function", "checkFile", "(", "$", "writable", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "fileExists", "(", ")", ")", "throw", "NonExistentFileException", "::", "createForFileDoesNotExists", "(", "$", "this", "->", "getFilePath", ...
Checks the file whether exists and is readable or writable @param bool $writable @throws AtomicFileException
[ "Checks", "the", "file", "whether", "exists", "and", "is", "readable", "or", "writable" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L213-L221
train
PHPComponent/AtomicFile
src/AtomicFileHandler.php
AtomicFileHandler.fileExists
protected function fileExists() { $this->clearStatCache(true); return (file_exists($this->file_path) && is_file($this->file_path)); }
php
protected function fileExists() { $this->clearStatCache(true); return (file_exists($this->file_path) && is_file($this->file_path)); }
[ "protected", "function", "fileExists", "(", ")", "{", "$", "this", "->", "clearStatCache", "(", "true", ")", ";", "return", "(", "file_exists", "(", "$", "this", "->", "file_path", ")", "&&", "is_file", "(", "$", "this", "->", "file_path", ")", ")", ";...
Checks whether file exists @return bool
[ "Checks", "whether", "file", "exists" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileHandler.php#L227-L231
train
ojhaujjwal/UserRbac
src/Factory/IdentityRoleProviderFactory.php
IdentityRoleProviderFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $identityRoleProvider = new IdentityRoleProvider( $serviceLocator->get('UserRbac\UserRoleLinkerMapper'), $serviceLocator->get('UserRbac\ModuleOptions') ); if ($serviceLocator->get('zfcuser_auth_service')->hasIdentity()) { $identityRoleProvider->setDefaultIdentity( $serviceLocator->get('zfcuser_auth_service')->getIdentity() ); } return $identityRoleProvider; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $identityRoleProvider = new IdentityRoleProvider( $serviceLocator->get('UserRbac\UserRoleLinkerMapper'), $serviceLocator->get('UserRbac\ModuleOptions') ); if ($serviceLocator->get('zfcuser_auth_service')->hasIdentity()) { $identityRoleProvider->setDefaultIdentity( $serviceLocator->get('zfcuser_auth_service')->getIdentity() ); } return $identityRoleProvider; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "identityRoleProvider", "=", "new", "IdentityRoleProvider", "(", "$", "serviceLocator", "->", "get", "(", "'UserRbac\\UserRoleLinkerMapper'", ")", ",", "$", "s...
Gets identity role provider @param ServiceLocatorInterface $serviceLocator @return IdentityRoleProvider
[ "Gets", "identity", "role", "provider" ]
ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe
https://github.com/ojhaujjwal/UserRbac/blob/ebe1cdbcbc9956af5a3a90d9c4c0fc7c8cd4c5fe/src/Factory/IdentityRoleProviderFactory.php#L18-L31
train
monolyth-php/formulaic
src/Radio/Group.php
Group.setValue
public function setValue($value) { foreach ((array)$this as $element) { if ($value == $element->getElement()->getValue()) { $element->getElement()->check(); } else { $element->getElement()->check(false); } } }
php
public function setValue($value) { foreach ((array)$this as $element) { if ($value == $element->getElement()->getValue()) { $element->getElement()->check(); } else { $element->getElement()->check(false); } } }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "foreach", "(", "(", "array", ")", "$", "this", "as", "$", "element", ")", "{", "if", "(", "$", "value", "==", "$", "element", "->", "getElement", "(", ")", "->", "getValue", "(", ")", ...
Sets the element where the value matches to `checked`. @param mixed $value
[ "Sets", "the", "element", "where", "the", "value", "matches", "to", "checked", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio/Group.php#L90-L99
train
monolyth-php/formulaic
src/Radio/Group.php
Group.getValue
public function getValue() : ArrayObject { foreach ((array)$this as $element) { if ($element->getElement() instanceof Radio && $element->getElement()->checked() ) { return new class([$element->getElement()->getValue()]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; } } return new class([$this->value]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; }
php
public function getValue() : ArrayObject { foreach ((array)$this as $element) { if ($element->getElement() instanceof Radio && $element->getElement()->checked() ) { return new class([$element->getElement()->getValue()]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; } } return new class([$this->value]) extends ArrayObject { public function __toString() : string { return "{$this[0]}"; } }; }
[ "public", "function", "getValue", "(", ")", ":", "ArrayObject", "{", "foreach", "(", "(", "array", ")", "$", "this", "as", "$", "element", ")", "{", "if", "(", "$", "element", "->", "getElement", "(", ")", "instanceof", "Radio", "&&", "$", "element", ...
Gets the checked value in the group. @return array Array with a single entry (for compatibility with Element\Group, but obviously radio groups can only ever have one entry checked at a time).
[ "Gets", "the", "checked", "value", "in", "the", "group", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio/Group.php#L108-L128
train
monolyth-php/formulaic
src/Radio/Group.php
Group.isRequired
public function isRequired() : Group { foreach ((array)$this as $el) { if (!is_object($el)) { continue; } $el->getElement()->attribute('required', 1); } return $this->addTest('required', function ($value) { foreach ($value as $option) { if ($option->getElement() instanceof Radio && $option->getElement()->checked() ) { return true; } } return false; }); }
php
public function isRequired() : Group { foreach ((array)$this as $el) { if (!is_object($el)) { continue; } $el->getElement()->attribute('required', 1); } return $this->addTest('required', function ($value) { foreach ($value as $option) { if ($option->getElement() instanceof Radio && $option->getElement()->checked() ) { return true; } } return false; }); }
[ "public", "function", "isRequired", "(", ")", ":", "Group", "{", "foreach", "(", "(", "array", ")", "$", "this", "as", "$", "el", ")", "{", "if", "(", "!", "is_object", "(", "$", "el", ")", ")", "{", "continue", ";", "}", "$", "el", "->", "getE...
Marks the group as required. @return self
[ "Marks", "the", "group", "as", "required", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Radio/Group.php#L135-L153
train
extendsframework/extends-authorization
src/Permission/Permission.php
Permission.getSections
protected function getSections(): array { $sections = explode($this->getDivider(), $this->getNotation()); foreach ($sections as $index => $section) { $sections[$index] = explode($this->getSeparator(), $section); } return $sections; }
php
protected function getSections(): array { $sections = explode($this->getDivider(), $this->getNotation()); foreach ($sections as $index => $section) { $sections[$index] = explode($this->getSeparator(), $section); } return $sections; }
[ "protected", "function", "getSections", "(", ")", ":", "array", "{", "$", "sections", "=", "explode", "(", "$", "this", "->", "getDivider", "(", ")", ",", "$", "this", "->", "getNotation", "(", ")", ")", ";", "foreach", "(", "$", "sections", "as", "$...
Get exploded notation string. @return array
[ "Get", "exploded", "notation", "string", "." ]
f808ccdbfde07482fb77505a2eb7f7a8854ec828
https://github.com/extendsframework/extends-authorization/blob/f808ccdbfde07482fb77505a2eb7f7a8854ec828/src/Permission/Permission.php#L98-L106
train
tenside/core
src/Composer/Search/AbstractSearch.php
AbstractSearch.normalizeResultSet
protected function normalizeResultSet(array $resultSet) { $normalized = []; foreach ($resultSet as $result) { if (($normalizedResult = $this->normalizeResult($result)) === null) { continue; } $normalized[$normalizedResult] = $normalizedResult; } return array_keys($normalized); }
php
protected function normalizeResultSet(array $resultSet) { $normalized = []; foreach ($resultSet as $result) { if (($normalizedResult = $this->normalizeResult($result)) === null) { continue; } $normalized[$normalizedResult] = $normalizedResult; } return array_keys($normalized); }
[ "protected", "function", "normalizeResultSet", "(", "array", "$", "resultSet", ")", "{", "$", "normalized", "=", "[", "]", ";", "foreach", "(", "$", "resultSet", "as", "$", "result", ")", "{", "if", "(", "(", "$", "normalizedResult", "=", "$", "this", ...
Normalize a result set. @param array $resultSet The result set. @return string[]
[ "Normalize", "a", "result", "set", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Composer/Search/AbstractSearch.php#L73-L86
train
cube-group/myaf-utils
src/PageUtil.php
PageUtil.create
public static function create($totalPage, $pageSize = 10, $page = 1, $gets = []) { $p = new PageUtil(); if ($pageSize < 1) { $pageSize = 1; } $total = ceil($totalPage / $pageSize); if ($page < 1) { $page = 1; } else if ($page > $total) { $page = $total; } $p->page = $page; $p->gets = $gets; $p->total = $total; $p->pageSize = $pageSize; return $p; }
php
public static function create($totalPage, $pageSize = 10, $page = 1, $gets = []) { $p = new PageUtil(); if ($pageSize < 1) { $pageSize = 1; } $total = ceil($totalPage / $pageSize); if ($page < 1) { $page = 1; } else if ($page > $total) { $page = $total; } $p->page = $page; $p->gets = $gets; $p->total = $total; $p->pageSize = $pageSize; return $p; }
[ "public", "static", "function", "create", "(", "$", "totalPage", ",", "$", "pageSize", "=", "10", ",", "$", "page", "=", "1", ",", "$", "gets", "=", "[", "]", ")", "{", "$", "p", "=", "new", "PageUtil", "(", ")", ";", "if", "(", "$", "pageSize"...
Page constructor. @param $totalPage int 总条数 @param int $pageSize 每页显示条数 @param int $page 当前页码 @param array $gets url携带get参数数组 @return self
[ "Page", "constructor", "." ]
febc3e1936ebdf763cf5478647e5ba22b3fd2812
https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/PageUtil.php#L42-L62
train
phpzm/kernel
src/Kernel/Container.php
Container.make
public function make(string $alias) { if (array_key_exists($alias, $this->bindings)) { $classOrObject = $this->bindings[$alias]; if (is_object($classOrObject)) { return $classOrObject; } return $this->makeInstance($classOrObject); } if (class_exists($alias)) { return self::register($alias, $this->makeInstance($alias))->make($alias); } throw new SimplesRunTimeError("Class '{$alias}' not found"); }
php
public function make(string $alias) { if (array_key_exists($alias, $this->bindings)) { $classOrObject = $this->bindings[$alias]; if (is_object($classOrObject)) { return $classOrObject; } return $this->makeInstance($classOrObject); } if (class_exists($alias)) { return self::register($alias, $this->makeInstance($alias))->make($alias); } throw new SimplesRunTimeError("Class '{$alias}' not found"); }
[ "public", "function", "make", "(", "string", "$", "alias", ")", "{", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "bindings", ")", ")", "{", "$", "classOrObject", "=", "$", "this", "->", "bindings", "[", "$", "alias", "]"...
Resolves and created a new instance of a desired class. @param string $alias @return mixed @throws SimplesRunTimeError
[ "Resolves", "and", "created", "a", "new", "instance", "of", "a", "desired", "class", "." ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L124-L140
train
phpzm/kernel
src/Kernel/Container.php
Container.makeInstance
public function makeInstance($className) { // class reflection $reflection = new ReflectionClass($className); // get the class constructor $constructor = $reflection->getConstructor(); // if there is no constructor, just create and // return a new instance if (!$constructor) { return $reflection->newInstance(); } // created and returns the new instance passing the // resolved parameters return $reflection->newInstanceArgs($this->resolveParameters($constructor->getParameters(), [])); }
php
public function makeInstance($className) { // class reflection $reflection = new ReflectionClass($className); // get the class constructor $constructor = $reflection->getConstructor(); // if there is no constructor, just create and // return a new instance if (!$constructor) { return $reflection->newInstance(); } // created and returns the new instance passing the // resolved parameters return $reflection->newInstanceArgs($this->resolveParameters($constructor->getParameters(), [])); }
[ "public", "function", "makeInstance", "(", "$", "className", ")", "{", "// class reflection", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "// get the class constructor", "$", "constructor", "=", "$", "reflection", "->", "getC...
Created a instance of a desired class. @param $className @return mixed @throws SimplesRunTimeError
[ "Created", "a", "instance", "of", "a", "desired", "class", "." ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L149-L165
train
phpzm/kernel
src/Kernel/Container.php
Container.exists
public function exists($instance, string $method) { $reflection = new ReflectionClass(get_class($instance)); return $reflection->hasMethod($method); }
php
public function exists($instance, string $method) { $reflection = new ReflectionClass(get_class($instance)); return $reflection->hasMethod($method); }
[ "public", "function", "exists", "(", "$", "instance", ",", "string", "$", "method", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "get_class", "(", "$", "instance", ")", ")", ";", "return", "$", "reflection", "->", "hasMethod", "(", "$...
Checks whether a specific method is defined in a class @param mixed $instance @param string $method @return bool
[ "Checks", "whether", "a", "specific", "method", "is", "defined", "in", "a", "class" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L174-L179
train
phpzm/kernel
src/Kernel/Container.php
Container.invoke
public function invoke($instance, string $method, array $data) { // get the parameters $parameters = $this->resolveMethodParameters($instance, $method, $data, true); // get the reflection of method $reflection = new ReflectionMethod(get_class($instance), $method); // allow access $reflection->setAccessible(true); // execute the method return $reflection->invokeArgs($instance, $parameters); }
php
public function invoke($instance, string $method, array $data) { // get the parameters $parameters = $this->resolveMethodParameters($instance, $method, $data, true); // get the reflection of method $reflection = new ReflectionMethod(get_class($instance), $method); // allow access $reflection->setAccessible(true); // execute the method return $reflection->invokeArgs($instance, $parameters); }
[ "public", "function", "invoke", "(", "$", "instance", ",", "string", "$", "method", ",", "array", "$", "data", ")", "{", "// get the parameters", "$", "parameters", "=", "$", "this", "->", "resolveMethodParameters", "(", "$", "instance", ",", "$", "method", ...
Invoke a method of an instance of a class @param mixed $instance @param string $method @param array $data @return mixed @throws SimplesRunTimeError
[ "Invoke", "a", "method", "of", "an", "instance", "of", "a", "class" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L190-L203
train
phpzm/kernel
src/Kernel/Container.php
Container.resolveMethodParameters
public function resolveMethodParameters($instance, $method, $parameters, $labels = false) { // method reflection $reflectionMethod = new ReflectionMethod($instance, $method); // resolved array of parameters return $this->resolveParameters($reflectionMethod->getParameters(), $parameters, $labels); }
php
public function resolveMethodParameters($instance, $method, $parameters, $labels = false) { // method reflection $reflectionMethod = new ReflectionMethod($instance, $method); // resolved array of parameters return $this->resolveParameters($reflectionMethod->getParameters(), $parameters, $labels); }
[ "public", "function", "resolveMethodParameters", "(", "$", "instance", ",", "$", "method", ",", "$", "parameters", ",", "$", "labels", "=", "false", ")", "{", "// method reflection", "$", "reflectionMethod", "=", "new", "ReflectionMethod", "(", "$", "instance", ...
Generate a list of values to be used like parameters to one method @param $instance @param $method @param $parameters @param bool $labels @return array @throws SimplesRunTimeError
[ "Generate", "a", "list", "of", "values", "to", "be", "used", "like", "parameters", "to", "one", "method" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L215-L222
train
phpzm/kernel
src/Kernel/Container.php
Container.resolveFunctionParameters
public function resolveFunctionParameters($callable, $parameters, $labels = false) { // method reflection $reflectionFunction = new ReflectionFunction($callable); // resolved array of parameters return $this->resolveParameters($reflectionFunction->getParameters(), $parameters, $labels); }
php
public function resolveFunctionParameters($callable, $parameters, $labels = false) { // method reflection $reflectionFunction = new ReflectionFunction($callable); // resolved array of parameters return $this->resolveParameters($reflectionFunction->getParameters(), $parameters, $labels); }
[ "public", "function", "resolveFunctionParameters", "(", "$", "callable", ",", "$", "parameters", ",", "$", "labels", "=", "false", ")", "{", "// method reflection", "$", "reflectionFunction", "=", "new", "ReflectionFunction", "(", "$", "callable", ")", ";", "// ...
Generate a list of values to be used like parameters to one function @param $callable @param $parameters @param bool $labels @return array @throws SimplesRunTimeError
[ "Generate", "a", "list", "of", "values", "to", "be", "used", "like", "parameters", "to", "one", "function" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L233-L240
train
phpzm/kernel
src/Kernel/Container.php
Container.resolveParameters
private function resolveParameters($parameters, $data, $labels = false) { $resolved = []; /** @var ReflectionParameter $reflectionParameter */ foreach ($parameters as $reflectionParameter) { /** @noinspection PhpAssignmentInConditionInspection */ $parameter = $this->parseParameter($reflectionParameter, $data, $labels); if (!is_null($parameter)) { $resolved[] = $parameter; continue; } /** @noinspection PhpAssignmentInConditionInspection */ if ($parameterClassName = $this->extractClassName($reflectionParameter)) { $resolved[] = static::make($parameterClassName); continue; } $resolved[] = null; } return $resolved; }
php
private function resolveParameters($parameters, $data, $labels = false) { $resolved = []; /** @var ReflectionParameter $reflectionParameter */ foreach ($parameters as $reflectionParameter) { /** @noinspection PhpAssignmentInConditionInspection */ $parameter = $this->parseParameter($reflectionParameter, $data, $labels); if (!is_null($parameter)) { $resolved[] = $parameter; continue; } /** @noinspection PhpAssignmentInConditionInspection */ if ($parameterClassName = $this->extractClassName($reflectionParameter)) { $resolved[] = static::make($parameterClassName); continue; } $resolved[] = null; } return $resolved; }
[ "private", "function", "resolveParameters", "(", "$", "parameters", ",", "$", "data", ",", "$", "labels", "=", "false", ")", "{", "$", "resolved", "=", "[", "]", ";", "/** @var ReflectionParameter $reflectionParameter */", "foreach", "(", "$", "parameters", "as"...
Generate a list of values to be used like parameters to one method or function @param $parameters @param $data @param bool $labels @return array @throws SimplesRunTimeError
[ "Generate", "a", "list", "of", "values", "to", "be", "used", "like", "parameters", "to", "one", "method", "or", "function" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L251-L270
train
phpzm/kernel
src/Kernel/Container.php
Container.parseParameter
private function parseParameter(ReflectionParameter $reflectionParameter, &$data, $labels) { // get the principal properties $name = $reflectionParameter->getName(); $value = null; if ($reflectionParameter->isOptional()) { $value = $reflectionParameter->getDefaultValue(); } // parse data using labels if ($labels) { if (isset($data[$name])) { $value = off($data, $name, $value); unset($data[$name]); } return $value; } // parse data without labels if (isset($data[0])) { $value = $data[0]; array_shift($data); reset($data); } return $value; }
php
private function parseParameter(ReflectionParameter $reflectionParameter, &$data, $labels) { // get the principal properties $name = $reflectionParameter->getName(); $value = null; if ($reflectionParameter->isOptional()) { $value = $reflectionParameter->getDefaultValue(); } // parse data using labels if ($labels) { if (isset($data[$name])) { $value = off($data, $name, $value); unset($data[$name]); } return $value; } // parse data without labels if (isset($data[0])) { $value = $data[0]; array_shift($data); reset($data); } return $value; }
[ "private", "function", "parseParameter", "(", "ReflectionParameter", "$", "reflectionParameter", ",", "&", "$", "data", ",", "$", "labels", ")", "{", "// get the principal properties", "$", "name", "=", "$", "reflectionParameter", "->", "getName", "(", ")", ";", ...
Configure the beste resource to each parameter of one method or function @param ReflectionParameter $reflectionParameter @param array $data @param bool $labels @return mixed
[ "Configure", "the", "beste", "resource", "to", "each", "parameter", "of", "one", "method", "or", "function" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L280-L305
train
phpzm/kernel
src/Kernel/Container.php
Container.extractClassName
private function extractClassName(ReflectionParameter $reflectionParameter) { if (isset($reflectionParameter->getClass()->name)) { return $reflectionParameter->getClass()->name; } return ''; }
php
private function extractClassName(ReflectionParameter $reflectionParameter) { if (isset($reflectionParameter->getClass()->name)) { return $reflectionParameter->getClass()->name; } return ''; }
[ "private", "function", "extractClassName", "(", "ReflectionParameter", "$", "reflectionParameter", ")", "{", "if", "(", "isset", "(", "$", "reflectionParameter", "->", "getClass", "(", ")", "->", "name", ")", ")", "{", "return", "$", "reflectionParameter", "->",...
Get the name of class related to a list of parameters @param ReflectionParameter $reflectionParameter @return string
[ "Get", "the", "name", "of", "class", "related", "to", "a", "list", "of", "parameters" ]
e75da67a7815ddca56468dff75e50b614f823fad
https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/Container.php#L313-L319
train
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.execute
public function execute() { $DB = $this->getDBO(); //Run the Query; $resultId = $DB->exec(); //\Platform\Debugger::log($resultId); $this->setResultId($resultId)->setConnectionId($DB->getResourceId())->setAffectedRows($this->getAffectedRows()); $DB->resetRun(); return $this; }
php
public function execute() { $DB = $this->getDBO(); //Run the Query; $resultId = $DB->exec(); //\Platform\Debugger::log($resultId); $this->setResultId($resultId)->setConnectionId($DB->getResourceId())->setAffectedRows($this->getAffectedRows()); $DB->resetRun(); return $this; }
[ "public", "function", "execute", "(", ")", "{", "$", "DB", "=", "$", "this", "->", "getDBO", "(", ")", ";", "//Run the Query;", "$", "resultId", "=", "$", "DB", "->", "exec", "(", ")", ";", "//\\Platform\\Debugger::log($resultId);", "$", "this", "->", "s...
Executes the prepared Statement @return
[ "Executes", "the", "prepared", "Statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L41-L54
train
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.listColumns
public function listColumns() { $fieldNames = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $fieldNames[] = $field->name; } return $fieldNames; }
php
public function listColumns() { $fieldNames = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $fieldNames[] = $field->name; } return $fieldNames; }
[ "public", "function", "listColumns", "(", ")", "{", "$", "fieldNames", "=", "array", "(", ")", ";", "$", "field", "=", "NULL", ";", "while", "(", "$", "field", "=", "mysqli_fetch_field", "(", "$", "this", "->", "getResultId", "(", ")", ")", ")", "{",...
Lists all columns in a result row @return array
[ "Lists", "all", "columns", "in", "a", "result", "row" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L92-L101
train
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.getColumnMeta
public function getColumnMeta($name = '') { $retval = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $f = new stdClass(); $f->name = $field->name; $f->type = $field->type; $f->default = $field->def; $f->maxLength = $field->max_length; $f->primaryKey = $field->primary_key; $retval[] = $f; } return $retval; }
php
public function getColumnMeta($name = '') { $retval = array(); $field = NULL; while ($field = mysqli_fetch_field($this->getResultId())) { $f = new stdClass(); $f->name = $field->name; $f->type = $field->type; $f->default = $field->def; $f->maxLength = $field->max_length; $f->primaryKey = $field->primary_key; $retval[] = $f; } return $retval; }
[ "public", "function", "getColumnMeta", "(", "$", "name", "=", "''", ")", "{", "$", "retval", "=", "array", "(", ")", ";", "$", "field", "=", "NULL", ";", "while", "(", "$", "field", "=", "mysqli_fetch_field", "(", "$", "this", "->", "getResultId", "(...
Returns metadata for a column or all columns in a result set @return stdClass
[ "Returns", "metadata", "for", "a", "column", "or", "all", "columns", "in", "a", "result", "set" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L108-L125
train
budkit/budkit-framework
src/Budkit/Datastore/Drivers/MySQLi/Statement.php
Statement.freeResults
public function freeResults() { if (is_a($this->getResultId(), "mysqli_result")) { mysqli_free_result($this->getResultId()); $this->setResultId(FALSE); } }
php
public function freeResults() { if (is_a($this->getResultId(), "mysqli_result")) { mysqli_free_result($this->getResultId()); $this->setResultId(FALSE); } }
[ "public", "function", "freeResults", "(", ")", "{", "if", "(", "is_a", "(", "$", "this", "->", "getResultId", "(", ")", ",", "\"mysqli_result\"", ")", ")", "{", "mysqli_free_result", "(", "$", "this", "->", "getResultId", "(", ")", ")", ";", "$", "this...
Frees the result @return void
[ "Frees", "the", "result" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Drivers/MySQLi/Statement.php#L132-L138
train
jeromeklam/freefw
src/FreeFW/Core/ApiController.php
ApiController.createOne
public function createOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.createOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); if (!$data->isValid()) { $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(409, $data); } $data->create(); $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(201, $data); } else { return $this->createResponse(409); } }
php
public function createOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.createOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); if (!$data->isValid()) { $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(409, $data); } $data->create(); $this->logger->debug('FreeFW.ApiController.createOne.end'); return $this->createResponse(201, $data); } else { return $this->createResponse(409); } }
[ "public", "function", "createOne", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ServerRequestInterface", "$", "p_request", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'FreeFW.ApiController.createOne.start'", ")", ";", "$", "apiParams",...
Add new single element @param \Psr\Http\Message\ServerRequestInterface $p_request
[ "Add", "new", "single", "element" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Core/ApiController.php#L17-L37
train
jeromeklam/freefw
src/FreeFW/Core/ApiController.php
ApiController.removeOne
public function removeOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.removeOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); $data->remove(); $this->logger->debug('FreeFW.ApiController.removeOne.end'); return $this->createResponse(204); } else { return $this->createResponse(409); } }
php
public function removeOne(\Psr\Http\Message\ServerRequestInterface $p_request) { $this->logger->debug('FreeFW.ApiController.removeOne.start'); $apiParams = $p_request->getAttribute('api_params', false); // if ($apiParams->hasData()) { /** * @var \FreeFW\Core\StorageModel $data */ $data = $apiParams->getData(); $data->remove(); $this->logger->debug('FreeFW.ApiController.removeOne.end'); return $this->createResponse(204); } else { return $this->createResponse(409); } }
[ "public", "function", "removeOne", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ServerRequestInterface", "$", "p_request", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'FreeFW.ApiController.removeOne.start'", ")", ";", "$", "apiParams",...
Remove single element @param \Psr\Http\Message\ServerRequestInterface $p_request
[ "Remove", "single", "element" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Core/ApiController.php#L69-L85
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent.filter
public function filter(Query $query) { if (!empty($this->filterOptions['conditions'])) { $query->where($this->filterOptions['conditions']); } if (!empty($this->filterOptions['order'])) { $query->order($this->filterOptions['order']); } return $query; }
php
public function filter(Query $query) { if (!empty($this->filterOptions['conditions'])) { $query->where($this->filterOptions['conditions']); } if (!empty($this->filterOptions['order'])) { $query->order($this->filterOptions['order']); } return $query; }
[ "public", "function", "filter", "(", "Query", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "filterOptions", "[", "'conditions'", "]", ")", ")", "{", "$", "query", "->", "where", "(", "$", "this", "->", "filterOptions", "["...
Apply filter conditions and order options to the given query. @param Query $query @return Query
[ "Apply", "filter", "conditions", "and", "order", "options", "to", "the", "given", "query", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L243-L253
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent.getBacklink
public static function getBacklink($url, ServerRequest $request) { if (!isset($url['plugin'])) { $url['plugin'] = $request->getParam('plugin'); } if (!isset($url['controller'])) { $url['controller'] = $request->getParam('controller'); } $path = join('.', [ 'FILTER_' . ($url['plugin'] ? $url['plugin'] : ''), $url['controller'], $url['action'] ]); if (($filterOptions = $request->getSession()->read($path))) { if (isset($filterOptions['slug'])) { $url['sluggedFilter'] = $filterOptions['slug']; unset($filterOptions['slug']); } if (!empty($filterOptions)) { if (!isset($url['?'])) { $url['?'] = []; } $url['?'] = array_merge($url['?'], $filterOptions); } } return $url; }
php
public static function getBacklink($url, ServerRequest $request) { if (!isset($url['plugin'])) { $url['plugin'] = $request->getParam('plugin'); } if (!isset($url['controller'])) { $url['controller'] = $request->getParam('controller'); } $path = join('.', [ 'FILTER_' . ($url['plugin'] ? $url['plugin'] : ''), $url['controller'], $url['action'] ]); if (($filterOptions = $request->getSession()->read($path))) { if (isset($filterOptions['slug'])) { $url['sluggedFilter'] = $filterOptions['slug']; unset($filterOptions['slug']); } if (!empty($filterOptions)) { if (!isset($url['?'])) { $url['?'] = []; } $url['?'] = array_merge($url['?'], $filterOptions); } } return $url; }
[ "public", "static", "function", "getBacklink", "(", "$", "url", ",", "ServerRequest", "$", "request", ")", "{", "if", "(", "!", "isset", "(", "$", "url", "[", "'plugin'", "]", ")", ")", "{", "$", "url", "[", "'plugin'", "]", "=", "$", "request", "-...
Try to retrieve a filtered backlink from the session. @param array $url @param ServerRequest $request @return array
[ "Try", "to", "retrieve", "a", "filtered", "backlink", "from", "the", "session", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L411-L440
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._initFilterOptions
protected function _initFilterOptions() { if (!$this->_filterEnabled && !$this->_sortEnabled) { return; } $options = [ 'conditions' => [], 'order' => [] ]; // check filter params if (!empty($this->request->getData())) { foreach ($this->request->getData() as $field => $value) { if (!isset($this->filterFields[$field]) || $value === '') { continue; } $options = $this->_createFilterFieldOption($field, $value, $options); $this->activeFilters[$field] = $value; } } if (isset($this->sortFields[$this->request->getQuery('s')])) { $d = 'asc'; if ($this->request->getQuery('d')) { $dir = strtolower($this->request->getQuery('d')); if (in_array($dir, ['asc', 'desc'])) { $d = $dir; } } $field = $this->request->getQuery('s'); $options = $this->_createSortFieldOption($field, $d, $options); $this->activeSort[$field] = $d; } elseif (!empty($this->defaultSort)) { $options = $this->_createSortFieldOption($this->defaultSort['field'], $this->defaultSort['dir'], $options); $this->activeSort[$this->defaultSort['field']] = $this->defaultSort['dir']; } if ($this->request->getQuery('p')) { $this->page = $this->request->getQuery('p'); } $this->filterOptions = $options; }
php
protected function _initFilterOptions() { if (!$this->_filterEnabled && !$this->_sortEnabled) { return; } $options = [ 'conditions' => [], 'order' => [] ]; // check filter params if (!empty($this->request->getData())) { foreach ($this->request->getData() as $field => $value) { if (!isset($this->filterFields[$field]) || $value === '') { continue; } $options = $this->_createFilterFieldOption($field, $value, $options); $this->activeFilters[$field] = $value; } } if (isset($this->sortFields[$this->request->getQuery('s')])) { $d = 'asc'; if ($this->request->getQuery('d')) { $dir = strtolower($this->request->getQuery('d')); if (in_array($dir, ['asc', 'desc'])) { $d = $dir; } } $field = $this->request->getQuery('s'); $options = $this->_createSortFieldOption($field, $d, $options); $this->activeSort[$field] = $d; } elseif (!empty($this->defaultSort)) { $options = $this->_createSortFieldOption($this->defaultSort['field'], $this->defaultSort['dir'], $options); $this->activeSort[$this->defaultSort['field']] = $this->defaultSort['dir']; } if ($this->request->getQuery('p')) { $this->page = $this->request->getQuery('p'); } $this->filterOptions = $options; }
[ "protected", "function", "_initFilterOptions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_filterEnabled", "&&", "!", "$", "this", "->", "_sortEnabled", ")", "{", "return", ";", "}", "$", "options", "=", "[", "'conditions'", "=>", "[", "]", ","...
Create the filter options that can be used for model find calls in the controller. @return void
[ "Create", "the", "filter", "options", "that", "can", "be", "used", "for", "model", "find", "calls", "in", "the", "controller", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L449-L494
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isSortEnabled
protected function _isSortEnabled() { if (!isset($this->controller->sortFields)) { return false; } foreach ($this->controller->sortFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
php
protected function _isSortEnabled() { if (!isset($this->controller->sortFields)) { return false; } foreach ($this->controller->sortFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
[ "protected", "function", "_isSortEnabled", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "controller", "->", "sortFields", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "controller", "->", "sortFields", ...
Check if sorting for the current controller action is enabled. @return boolean
[ "Check", "if", "sorting", "for", "the", "current", "controller", "action", "is", "enabled", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L501-L517
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isFilterEnabled
protected function _isFilterEnabled() { if (!isset($this->controller->filterFields)) { return false; } foreach ($this->controller->filterFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
php
protected function _isFilterEnabled() { if (!isset($this->controller->filterFields)) { return false; } foreach ($this->controller->filterFields as $field) { if (isset($field['actions']) && is_array($field['actions']) && in_array($this->action, $field['actions']) ) { return true; } } return false; }
[ "protected", "function", "_isFilterEnabled", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "controller", "->", "filterFields", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "controller", "->", "filterFie...
Check if filtering for the current controller action is enabled. @return boolean
[ "Check", "if", "filtering", "for", "the", "current", "controller", "action", "is", "enabled", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L524-L540
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isPaginationEnabled
protected function _isPaginationEnabled() { if (!isset($this->controller->limits) || !isset($this->controller->limits[$this->action]) || !isset($this->controller->limits[$this->action]['default']) || !isset($this->controller->limits[$this->action]['limits']) ) { return false; } return true; }
php
protected function _isPaginationEnabled() { if (!isset($this->controller->limits) || !isset($this->controller->limits[$this->action]) || !isset($this->controller->limits[$this->action]['default']) || !isset($this->controller->limits[$this->action]['limits']) ) { return false; } return true; }
[ "protected", "function", "_isPaginationEnabled", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "controller", "->", "limits", ")", "||", "!", "isset", "(", "$", "this", "->", "controller", "->", "limits", "[", "$", "this", "->", "actio...
Check if pagination is enabled for the current controller action. @return boolean
[ "Check", "if", "pagination", "is", "enabled", "for", "the", "current", "controller", "action", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L547-L558
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._getSortFields
protected function _getSortFields() { $sortFields = []; foreach ($this->controller->sortFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $sortFields[$field] = $options; } } return $sortFields; }
php
protected function _getSortFields() { $sortFields = []; foreach ($this->controller->sortFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $sortFields[$field] = $options; } } return $sortFields; }
[ "protected", "function", "_getSortFields", "(", ")", "{", "$", "sortFields", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "controller", "->", "sortFields", "as", "$", "field", "=>", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "o...
Get all available sort fields for the current controller action. @return array
[ "Get", "all", "available", "sort", "fields", "for", "the", "current", "controller", "action", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L565-L579
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._getFilterFields
protected function _getFilterFields() { $filterFields = []; foreach ($this->controller->filterFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $filterFields[$field] = $options; } } return $filterFields; }
php
protected function _getFilterFields() { $filterFields = []; foreach ($this->controller->filterFields as $field => $options) { if (isset($options['actions']) && is_array($options['actions']) && in_array($this->action, $options['actions']) ) { $filterFields[$field] = $options; } } return $filterFields; }
[ "protected", "function", "_getFilterFields", "(", ")", "{", "$", "filterFields", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "controller", "->", "filterFields", "as", "$", "field", "=>", "$", "options", ")", "{", "if", "(", "isset", "(", "$"...
Get all available filter fields for the current controller action. @return array
[ "Get", "all", "available", "filter", "fields", "for", "the", "current", "controller", "action", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L586-L600
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._createSortFieldOption
protected function _createSortFieldOption($field, $dir, $options) { $sortField = $this->sortFields[$field]; if (isset($sortField['custom'])) { if (!is_array($sortField['custom'])) { $sortField['custom'] = [$sortField['custom']]; } foreach ($sortField['custom'] as $sortEntry) { $options['order'][] = preg_replace('/:dir/', $dir, $sortEntry); } } else { $options['order'][] = $sortField['modelField'] . ' ' . $dir; } return $options; }
php
protected function _createSortFieldOption($field, $dir, $options) { $sortField = $this->sortFields[$field]; if (isset($sortField['custom'])) { if (!is_array($sortField['custom'])) { $sortField['custom'] = [$sortField['custom']]; } foreach ($sortField['custom'] as $sortEntry) { $options['order'][] = preg_replace('/:dir/', $dir, $sortEntry); } } else { $options['order'][] = $sortField['modelField'] . ' ' . $dir; } return $options; }
[ "protected", "function", "_createSortFieldOption", "(", "$", "field", ",", "$", "dir", ",", "$", "options", ")", "{", "$", "sortField", "=", "$", "this", "->", "sortFields", "[", "$", "field", "]", ";", "if", "(", "isset", "(", "$", "sortField", "[", ...
Create the 'order' find condition part for a sorted field. @param string $field The field name to sort @param string $dir The sort direction (asc, desc) @param array $options The current find options where the sorting should be added. @return mixed
[ "Create", "the", "order", "find", "condition", "part", "for", "a", "sorted", "field", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L610-L625
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._extractPassParams
protected function _extractPassParams() { if (!empty($this->controller->filterPassParams[$this->action])) { foreach ($this->controller->filterPassParams[$this->action] as $key) { if (!empty($this->request->getParam($key))) { $this->_passParams[$key] = $this->request->getParam($key); } } } }
php
protected function _extractPassParams() { if (!empty($this->controller->filterPassParams[$this->action])) { foreach ($this->controller->filterPassParams[$this->action] as $key) { if (!empty($this->request->getParam($key))) { $this->_passParams[$key] = $this->request->getParam($key); } } } }
[ "protected", "function", "_extractPassParams", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "controller", "->", "filterPassParams", "[", "$", "this", "->", "action", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "controller", ...
Puts the values in the passParams array
[ "Puts", "the", "values", "in", "the", "passParams", "array" ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L703-L712
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._getFilterData
protected function _getFilterData() { $rawFilterData = $this->request->getData(); $filterData = []; foreach ($this->filterFields as $filterField => $options) { if (isset($rawFilterData[$filterField]) && $rawFilterData[$filterField] !== '') { $filterData[$filterField] = $rawFilterData[$filterField]; } } return $filterData; }
php
protected function _getFilterData() { $rawFilterData = $this->request->getData(); $filterData = []; foreach ($this->filterFields as $filterField => $options) { if (isset($rawFilterData[$filterField]) && $rawFilterData[$filterField] !== '') { $filterData[$filterField] = $rawFilterData[$filterField]; } } return $filterData; }
[ "protected", "function", "_getFilterData", "(", ")", "{", "$", "rawFilterData", "=", "$", "this", "->", "request", "->", "getData", "(", ")", ";", "$", "filterData", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "filterFields", "as", "$", "fil...
Get the filter data. @return array
[ "Get", "the", "filter", "data", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L719-L730
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._setupSort
protected function _setupSort() { if (!($this->_sortEnabled = $this->_isSortEnabled())) { return; } $this->sortFields = $this->_getSortFields(); foreach ($this->sortFields as $field => $options) { if (!isset($options['default'])) { continue; } $dir = strtolower($options['default']); if (in_array($dir, ['asc', 'desc'])) { $this->defaultSort = [ 'field' => $field, 'dir' => $dir ]; } } }
php
protected function _setupSort() { if (!($this->_sortEnabled = $this->_isSortEnabled())) { return; } $this->sortFields = $this->_getSortFields(); foreach ($this->sortFields as $field => $options) { if (!isset($options['default'])) { continue; } $dir = strtolower($options['default']); if (in_array($dir, ['asc', 'desc'])) { $this->defaultSort = [ 'field' => $field, 'dir' => $dir ]; } } }
[ "protected", "function", "_setupSort", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "_sortEnabled", "=", "$", "this", "->", "_isSortEnabled", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "sortFields", "=", "$", "this", ...
Setup default sort options. @return void
[ "Setup", "default", "sort", "options", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L737-L757
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._setupFilters
protected function _setupFilters() { if (!($this->_filterEnabled = $this->_isFilterEnabled())) { return; } $this->filterFields = $this->_getFilterFields(); $sluggedFilter = $this->request->getParam('sluggedFilter', ''); if ($sluggedFilter === '') { return; } $filterData = $this->Filters->find('filterDataBySlug', ['request' => $this->request]); if (empty($filterData)) { return; } $data = array_merge($this->request->getData(), $filterData); foreach ($data as $key => $value) { $this->request = $this->request->withData($key, $value); } $this->slug = $sluggedFilter; }
php
protected function _setupFilters() { if (!($this->_filterEnabled = $this->_isFilterEnabled())) { return; } $this->filterFields = $this->_getFilterFields(); $sluggedFilter = $this->request->getParam('sluggedFilter', ''); if ($sluggedFilter === '') { return; } $filterData = $this->Filters->find('filterDataBySlug', ['request' => $this->request]); if (empty($filterData)) { return; } $data = array_merge($this->request->getData(), $filterData); foreach ($data as $key => $value) { $this->request = $this->request->withData($key, $value); } $this->slug = $sluggedFilter; }
[ "protected", "function", "_setupFilters", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "_filterEnabled", "=", "$", "this", "->", "_isFilterEnabled", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "filterFields", "=", "$", "...
Setup the filter field options. If the current request is provided with the sluggedFilter param, then the corresponding filter data will be fetched and set on the request data. @return void
[ "Setup", "the", "filter", "field", "options", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L767-L791
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._setupPagination
protected function _setupPagination() { if (!($this->_paginationEnabled = $this->_isPaginationEnabled())) { return; } $this->defaultLimit = $this->controller->limits[$this->action]['default']; $this->limits = $this->controller->limits[$this->action]['limits']; }
php
protected function _setupPagination() { if (!($this->_paginationEnabled = $this->_isPaginationEnabled())) { return; } $this->defaultLimit = $this->controller->limits[$this->action]['default']; $this->limits = $this->controller->limits[$this->action]['limits']; }
[ "protected", "function", "_setupPagination", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "_paginationEnabled", "=", "$", "this", "->", "_isPaginationEnabled", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "defaultLimit", "=",...
Setup the default pagination params. @return void
[ "Setup", "the", "default", "pagination", "params", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L798-L806
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._isFilterRequest
protected function _isFilterRequest() { return ( $this->controller !== null && $this->request !== null && $this->action !== null && $this->_filterEnabled ); }
php
protected function _isFilterRequest() { return ( $this->controller !== null && $this->request !== null && $this->action !== null && $this->_filterEnabled ); }
[ "protected", "function", "_isFilterRequest", "(", ")", "{", "return", "(", "$", "this", "->", "controller", "!==", "null", "&&", "$", "this", "->", "request", "!==", "null", "&&", "$", "this", "->", "action", "!==", "null", "&&", "$", "this", "->", "_f...
Check if the current request is a filter request. @return bool
[ "Check", "if", "the", "current", "request", "is", "a", "filter", "request", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L813-L821
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._createFilterSlug
protected function _createFilterSlug(array $filterData) { /** @var Filter $existingFilter */ $existingFilter = $this->Filters->find('slugForFilterData', [ 'request' => $this->request, 'filterData' => $filterData ])->first(); if ($existingFilter) { return $existingFilter->slug; } return $this->Filters->createFilterForFilterData($this->request, $filterData); }
php
protected function _createFilterSlug(array $filterData) { /** @var Filter $existingFilter */ $existingFilter = $this->Filters->find('slugForFilterData', [ 'request' => $this->request, 'filterData' => $filterData ])->first(); if ($existingFilter) { return $existingFilter->slug; } return $this->Filters->createFilterForFilterData($this->request, $filterData); }
[ "protected", "function", "_createFilterSlug", "(", "array", "$", "filterData", ")", "{", "/** @var Filter $existingFilter */", "$", "existingFilter", "=", "$", "this", "->", "Filters", "->", "find", "(", "'slugForFilterData'", ",", "[", "'request'", "=>", "$", "th...
Create a filter slug for the given filter data. @param array $filterData @return string The slug.
[ "Create", "a", "filter", "slug", "for", "the", "given", "filter", "data", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L829-L842
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._applyFilterData
protected function _applyFilterData($url) { $filterData = $this->_getFilterData(); if (empty($filterData)) { return $url; } return $url + [ 'sluggedFilter' => $this->_createFilterSlug($filterData), '?' => $this->request->getQuery() ]; }
php
protected function _applyFilterData($url) { $filterData = $this->_getFilterData(); if (empty($filterData)) { return $url; } return $url + [ 'sluggedFilter' => $this->_createFilterSlug($filterData), '?' => $this->request->getQuery() ]; }
[ "protected", "function", "_applyFilterData", "(", "$", "url", ")", "{", "$", "filterData", "=", "$", "this", "->", "_getFilterData", "(", ")", ";", "if", "(", "empty", "(", "$", "filterData", ")", ")", "{", "return", "$", "url", ";", "}", "return", "...
Apply filter data to the given url. @param $url @return array modified url array
[ "Apply", "filter", "data", "to", "the", "given", "url", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L850-L861
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._applyPassedParams
protected function _applyPassedParams($url) { if (empty($this->_passParams)) { return $url; } return array_merge($url, $this->_passParams); }
php
protected function _applyPassedParams($url) { if (empty($this->_passParams)) { return $url; } return array_merge($url, $this->_passParams); }
[ "protected", "function", "_applyPassedParams", "(", "$", "url", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_passParams", ")", ")", "{", "return", "$", "url", ";", "}", "return", "array_merge", "(", "$", "url", ",", "$", "this", "->", "_pa...
Apply configured pass params to the url array. @param array $url @return array modified url array
[ "Apply", "configured", "pass", "params", "to", "the", "url", "array", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L869-L876
train
frankfoerster/cakephp-filter
src/Controller/Component/FilterComponent.php
FilterComponent._applySort
protected function _applySort($url) { if (!$this->_sortEnabled) { return $url; } if (!empty($this->request->getQuery('s'))) { $url['?']['s'] = $this->request->getQuery('s'); } if (!empty($this->request->getQuery('d'))) { $url['?']['d'] = $this->request->getQuery('d'); } return $url; }
php
protected function _applySort($url) { if (!$this->_sortEnabled) { return $url; } if (!empty($this->request->getQuery('s'))) { $url['?']['s'] = $this->request->getQuery('s'); } if (!empty($this->request->getQuery('d'))) { $url['?']['d'] = $this->request->getQuery('d'); } return $url; }
[ "protected", "function", "_applySort", "(", "$", "url", ")", "{", "if", "(", "!", "$", "this", "->", "_sortEnabled", ")", "{", "return", "$", "url", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'s'",...
Pass sort options through to the filtered url. @param array $url @return array modified url array
[ "Pass", "sort", "options", "through", "to", "the", "filtered", "url", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Controller/Component/FilterComponent.php#L884-L899
train
canis-io/yii2-canis-lib
lib/web/Response.php
Response.getIsInstructable
public function getIsInstructable() { $isAjax = (isset(Yii::$app->request->isAjax) && Yii::$app->request->isAjax); if (isset($_GET['_instruct'])) { if (!empty($_GET['_instruct'])) { $this->forceInstructions = true; $this->disableInstructions = false; } else { $this->forceInstructions = false; $this->disableInstructions = true; } } return (is_array($this->data) || $this->forceInstructions || $isAjax) && !$this->disableInstructions; }
php
public function getIsInstructable() { $isAjax = (isset(Yii::$app->request->isAjax) && Yii::$app->request->isAjax); if (isset($_GET['_instruct'])) { if (!empty($_GET['_instruct'])) { $this->forceInstructions = true; $this->disableInstructions = false; } else { $this->forceInstructions = false; $this->disableInstructions = true; } } return (is_array($this->data) || $this->forceInstructions || $isAjax) && !$this->disableInstructions; }
[ "public", "function", "getIsInstructable", "(", ")", "{", "$", "isAjax", "=", "(", "isset", "(", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", ")", "&&", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", ")", ";", "if", "(", "is...
Get is instructable. @return [[@doctodo return_type:getIsInstructable]] [[@doctodo return_description:getIsInstructable]]
[ "Get", "is", "instructable", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/Response.php#L139-L153
train
mtils/collection
src/Collection/Support/FindsCallableByInheritance.php
FindsCallableByInheritance.classInheritance
public static function classInheritance($object){ $class = new ReflectionClass($object); $classNames = [$class->getName()]; while($class = $class->getParentClass()){ $classNames[] = $class->getName(); } return $classNames; }
php
public static function classInheritance($object){ $class = new ReflectionClass($object); $classNames = [$class->getName()]; while($class = $class->getParentClass()){ $classNames[] = $class->getName(); } return $classNames; }
[ "public", "static", "function", "classInheritance", "(", "$", "object", ")", "{", "$", "class", "=", "new", "ReflectionClass", "(", "$", "object", ")", ";", "$", "classNames", "=", "[", "$", "class", "->", "getName", "(", ")", "]", ";", "while", "(", ...
Returns an array of the classname and all parent class names of the passed class or object @param object|string $object @return array
[ "Returns", "an", "array", "of", "the", "classname", "and", "all", "parent", "class", "names", "of", "the", "passed", "class", "or", "object" ]
186f8a6cc68fef1babc486438aa6d6c643186cc8
https://github.com/mtils/collection/blob/186f8a6cc68fef1babc486438aa6d6c643186cc8/src/Collection/Support/FindsCallableByInheritance.php#L154-L165
train
arvici/framework
src/Arvici/Heart/App/AppManager.php
AppManager.initApps
public function initApps() { if (count($this->apps) > 0) { throw new AlreadyInitiatedException('The apps are already loaded!'); } foreach ($this->appList as $className) { $instance = new $className($this); $this->apps->append($instance); } // Let the apps configure itself. foreach ($this->apps as $app) { $app->load(); } // Let the apps register it parts. foreach ($this->apps as $app) { $app->registerRoutes(Router::getInstance()); } }
php
public function initApps() { if (count($this->apps) > 0) { throw new AlreadyInitiatedException('The apps are already loaded!'); } foreach ($this->appList as $className) { $instance = new $className($this); $this->apps->append($instance); } // Let the apps configure itself. foreach ($this->apps as $app) { $app->load(); } // Let the apps register it parts. foreach ($this->apps as $app) { $app->registerRoutes(Router::getInstance()); } }
[ "public", "function", "initApps", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "apps", ")", ">", "0", ")", "{", "throw", "new", "AlreadyInitiatedException", "(", "'The apps are already loaded!'", ")", ";", "}", "foreach", "(", "$", "this", ...
Load and initiate all apps. @codeCoverageIgnore
[ "Load", "and", "initiate", "all", "apps", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/App/AppManager.php#L68-L88
train
indigophp-archive/supervisor-configuration
src/Configuration/Parser/Base.php
Base.findSection
public function findSection($section) { if (!isset($this->sectionMap[$section])) { throw new UnknownSection($section); } return $this->sectionMap[$section]; }
php
public function findSection($section) { if (!isset($this->sectionMap[$section])) { throw new UnknownSection($section); } return $this->sectionMap[$section]; }
[ "public", "function", "findSection", "(", "$", "section", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "sectionMap", "[", "$", "section", "]", ")", ")", "{", "throw", "new", "UnknownSection", "(", "$", "section", ")", ";", "}", "return"...
Finds a section class by name @param string $section @return string @throws UnknownException If section is not found in the section map
[ "Finds", "a", "section", "class", "by", "name" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Parser/Base.php#L63-L70
train
indigophp-archive/supervisor-configuration
src/Configuration/Parser/Base.php
Base.parseArray
public function parseArray(array $ini) { $sections = []; foreach ($ini as $name => $section) { $section = $this->parseSection($name, $section); $sections[] = $section; } return $sections; }
php
public function parseArray(array $ini) { $sections = []; foreach ($ini as $name => $section) { $section = $this->parseSection($name, $section); $sections[] = $section; } return $sections; }
[ "public", "function", "parseArray", "(", "array", "$", "ini", ")", "{", "$", "sections", "=", "[", "]", ";", "foreach", "(", "$", "ini", "as", "$", "name", "=>", "$", "section", ")", "{", "$", "section", "=", "$", "this", "->", "parseSection", "(",...
Parses an INI array Sections must be included @param array $ini @return Section[]
[ "Parses", "an", "INI", "array" ]
7c5fca2e305be004ad91f8e2b4859ece1d484813
https://github.com/indigophp-archive/supervisor-configuration/blob/7c5fca2e305be004ad91f8e2b4859ece1d484813/src/Configuration/Parser/Base.php#L81-L91
train