repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
UnionOfRAD/lithium
data/Model.php
Model.relations
public static function relations($type = null) { $self = static::_object(); if ($type === null) { return static::_relations(); } if (isset($self->_relationFieldNames[$type])) { $type = $self->_relationFieldNames[$type]; } if (isset($self->_relations[$type])) { return $self->_relations[$type]; }...
php
public static function relations($type = null) { $self = static::_object(); if ($type === null) { return static::_relations(); } if (isset($self->_relationFieldNames[$type])) { $type = $self->_relationFieldNames[$type]; } if (isset($self->_relations[$type])) { return $self->_relations[$type]; }...
[ "public", "static", "function", "relations", "(", "$", "type", "=", "null", ")", "{", "$", "self", "=", "static", "::", "_object", "(", ")", ";", "if", "(", "$", "type", "===", "null", ")", "{", "return", "static", "::", "_relations", "(", ")", ";"...
Returns a list of models related to `Model`, or a list of models related to this model, but of a certain type. @param string $type A type of model relation. @return array|object|void An array of relation instances or an instance of relation.
[ "Returns", "a", "list", "of", "models", "related", "to", "Model", "or", "a", "list", "of", "models", "related", "to", "this", "model", "but", "of", "a", "certain", "type", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L941-L960
UnionOfRAD/lithium
data/Model.php
Model._relations
protected static function _relations($type = null, $name = null) { $self = static::_object(); if ($name) { if (isset($self->_relationsToLoad[$name])) { $t = $self->_relationsToLoad[$name]; unset($self->_relationsToLoad[$name]); return static::bind($t, $name, (array) $self->{$t}[$name]); } retu...
php
protected static function _relations($type = null, $name = null) { $self = static::_object(); if ($name) { if (isset($self->_relationsToLoad[$name])) { $t = $self->_relationsToLoad[$name]; unset($self->_relationsToLoad[$name]); return static::bind($t, $name, (array) $self->{$t}[$name]); } retu...
[ "protected", "static", "function", "_relations", "(", "$", "type", "=", "null", ",", "$", "name", "=", "null", ")", "{", "$", "self", "=", "static", "::", "_object", "(", ")", ";", "if", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", ...
This method automagically bind in the fly unloaded relations. @see lithium\data\Model::relations() @param $type A type of model relation. @param $name A relation name. @return An array of relation instances or an instance of relation.
[ "This", "method", "automagically", "bind", "in", "the", "fly", "unloaded", "relations", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L970-L997
UnionOfRAD/lithium
data/Model.php
Model.bind
public static function bind($type, $name, array $config = []) { $self = static::_object(); if (!isset($config['fieldName'])) { $config['fieldName'] = $self->_relationFieldName($type, $name); } if (!in_array($type, $self->_relationTypes)) { throw new ConfigException("Invalid relationship type `{$type}` sp...
php
public static function bind($type, $name, array $config = []) { $self = static::_object(); if (!isset($config['fieldName'])) { $config['fieldName'] = $self->_relationFieldName($type, $name); } if (!in_array($type, $self->_relationTypes)) { throw new ConfigException("Invalid relationship type `{$type}` sp...
[ "public", "static", "function", "bind", "(", "$", "type", ",", "$", "name", ",", "array", "$", "config", "=", "[", "]", ")", "{", "$", "self", "=", "static", "::", "_object", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'fi...
Creates a relationship binding between this model and another. @see lithium\data\model\Relationship @param string $type The type of relationship to create. Must be one of `'hasOne'`, `'hasMany'` or `'belongsTo'`. @param string $name The name of the relationship. If this is also the name of the model, the model must be...
[ "Creates", "a", "relationship", "binding", "between", "this", "model", "and", "another", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1012-L1024
UnionOfRAD/lithium
data/Model.php
Model.schema
public static function schema($field = null) { $self = static::_object(); if (!is_object($self->_schema)) { $self->_schema = static::connection()->describe( $self::meta('source'), $self->_schema, $self->_meta ); if (!is_object($self->_schema)) { $class = get_called_class(); throw new ConfigExc...
php
public static function schema($field = null) { $self = static::_object(); if (!is_object($self->_schema)) { $self->_schema = static::connection()->describe( $self::meta('source'), $self->_schema, $self->_meta ); if (!is_object($self->_schema)) { $class = get_called_class(); throw new ConfigExc...
[ "public", "static", "function", "schema", "(", "$", "field", "=", "null", ")", "{", "$", "self", "=", "static", "::", "_object", "(", ")", ";", "if", "(", "!", "is_object", "(", "$", "self", "->", "_schema", ")", ")", "{", "$", "self", "->", "_sc...
Lazy-initialize the schema for this Model object, if it is not already manually set in the object. You can declare `protected $_schema = [...]` to define the schema manually. @param mixed $field Optional. You may pass a field name to get schema information for just one field. Otherwise, an array containing all fields ...
[ "Lazy", "-", "initialize", "the", "schema", "for", "this", "Model", "object", "if", "it", "is", "not", "already", "manually", "set", "in", "the", "object", ".", "You", "can", "declare", "protected", "$_schema", "=", "[", "...", "]", "to", "define", "the"...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1036-L1060
UnionOfRAD/lithium
data/Model.php
Model.hasField
public static function hasField($field) { if (!is_array($field)) { return static::schema()->fields($field); } foreach ($field as $f) { if (static::hasField($f)) { return $f; } } return false; }
php
public static function hasField($field) { if (!is_array($field)) { return static::schema()->fields($field); } foreach ($field as $f) { if (static::hasField($f)) { return $f; } } return false; }
[ "public", "static", "function", "hasField", "(", "$", "field", ")", "{", "if", "(", "!", "is_array", "(", "$", "field", ")", ")", "{", "return", "static", "::", "schema", "(", ")", "->", "fields", "(", "$", "field", ")", ";", "}", "foreach", "(", ...
Checks to see if a particular field exists in a model's schema. Can check a single field, or return the first field found in an array of multiple options. @param mixed $field A single field (string) or list of fields (array) to check the existence of. @return mixed If `$field` is a string, returns a boolean indicating...
[ "Checks", "to", "see", "if", "a", "particular", "field", "exists", "in", "a", "model", "s", "schema", ".", "Can", "check", "a", "single", "field", "or", "return", "the", "first", "field", "found", "in", "an", "array", "of", "multiple", "options", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1072-L1082
UnionOfRAD/lithium
data/Model.php
Model.create
public static function create(array $data = [], array $options = []) { $defaults = ['defaults' => true, 'class' => 'entity']; $options += $defaults; $params = compact('data', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $class = $params['options']['class'];...
php
public static function create(array $data = [], array $options = []) { $defaults = ['defaults' => true, 'class' => 'entity']; $options += $defaults; $params = compact('data', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $class = $params['options']['class'];...
[ "public", "static", "function", "create", "(", "array", "$", "data", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'defaults'", "=>", "true", ",", "'class'", "=>", "'entity'", "]", ";", "$", "opti...
Instantiates a new record or document object, initialized with any data passed in. For example: ``` $post = Posts::create(['title' => 'New post']); echo $post->title; // echoes 'New post' $success = $post->save(); ``` Note that while this method creates a new object, there is no effect on the database until the `save...
[ "Instantiates", "a", "new", "record", "or", "document", "object", "initialized", "with", "any", "data", "passed", "in", ".", "For", "example", ":" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1116-L1135
UnionOfRAD/lithium
data/Model.php
Model.instanceMethods
public static function instanceMethods(array $methods = null) { $class = get_called_class(); if (!isset(static::$_instanceMethods[$class])) { static::$_instanceMethods[$class] = []; } if ($methods === []) { return static::$_instanceMethods[$class] = []; } if ($methods !== null) { static::$_instanc...
php
public static function instanceMethods(array $methods = null) { $class = get_called_class(); if (!isset(static::$_instanceMethods[$class])) { static::$_instanceMethods[$class] = []; } if ($methods === []) { return static::$_instanceMethods[$class] = []; } if ($methods !== null) { static::$_instanc...
[ "public", "static", "function", "instanceMethods", "(", "array", "$", "methods", "=", "null", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "_instanceMethods", "[", "$", "class", "]", ...
Getter and setter for custom instance methods. This is used in `Entity::__call()`. ``` Model::instanceMethods([ 'methodName' => ['Class', 'method'], 'anotherMethod' => [$object, 'method'], 'closureCallback' => function($entity) {} ]); ``` @see lithium\data\Entity::__call() @param array $methods @return array
[ "Getter", "and", "setter", "for", "custom", "instance", "methods", ".", "This", "is", "used", "in", "Entity", "::", "__call", "()", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1152-L1165
UnionOfRAD/lithium
data/Model.php
Model.save
public function save($entity, $data = null, array $options = []) { $self = static::_object(); $_meta = ['model' => get_called_class()] + $self->_meta; $_schema = $self->schema(); $defaults = [ 'validate' => true, 'events' => $entity->exists() ? 'update' : 'create', 'whitelist' => null, 'callbacks' ...
php
public function save($entity, $data = null, array $options = []) { $self = static::_object(); $_meta = ['model' => get_called_class()] + $self->_meta; $_schema = $self->schema(); $defaults = [ 'validate' => true, 'events' => $entity->exists() ? 'update' : 'create', 'whitelist' => null, 'callbacks' ...
[ "public", "function", "save", "(", "$", "entity", ",", "$", "data", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "self", "=", "static", "::", "_object", "(", ")", ";", "$", "_meta", "=", "[", "'model'", "=>", "get_call...
An instance method (called on record and document objects) to create or update the record or document in the database that corresponds to `$entity`. For example, to create a new record or document: ``` $post = Posts::create(); // Creates a new object, which doesn't exist in the database yet $post->title = "My post"; $...
[ "An", "instance", "method", "(", "called", "on", "record", "and", "document", "objects", ")", "to", "create", "or", "update", "the", "record", "or", "document", "in", "the", "database", "that", "corresponds", "to", "$entity", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1234-L1282
UnionOfRAD/lithium
data/Model.php
Model.validates
public function validates($entity, array $options = []) { $defaults = [ 'rules' => $this->validates, 'events' => $entity->exists() ? 'update' : 'create', 'model' => get_called_class(), 'required' => null, 'whitelist' => null ]; $options += $defaults; if ($options['required'] === null) { $opti...
php
public function validates($entity, array $options = []) { $defaults = [ 'rules' => $this->validates, 'events' => $entity->exists() ? 'update' : 'create', 'model' => get_called_class(), 'required' => null, 'whitelist' => null ]; $options += $defaults; if ($options['required'] === null) { $opti...
[ "public", "function", "validates", "(", "$", "entity", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'rules'", "=>", "$", "this", "->", "validates", ",", "'events'", "=>", "$", "entity", "->", "exists", "(", ")", ...
An important part of describing the business logic of a model class is defining the validation rules. In Lithium models, rules are defined through the `$validates` class property, and are used by this method before saving to verify the correctness of the data being sent to the backend data source. Note that these are ...
[ "An", "important", "part", "of", "describing", "the", "business", "logic", "of", "a", "model", "class", "is", "defining", "the", "validation", "rules", ".", "In", "Lithium", "models", "rules", "are", "defined", "through", "the", "$validates", "class", "propert...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1335-L1369
UnionOfRAD/lithium
data/Model.php
Model.delete
public function delete($entity, array $options = []) { $params = compact('entity', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $options = $params + $params['options'] + [ 'model' => get_called_class(), 'type' => 'delete' ]; unset($options['options...
php
public function delete($entity, array $options = []) { $params = compact('entity', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $options = $params + $params['options'] + [ 'model' => get_called_class(), 'type' => 'delete' ]; unset($options['options...
[ "public", "function", "delete", "(", "$", "entity", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "compact", "(", "'entity'", ",", "'options'", ")", ";", "return", "Filters", "::", "run", "(", "get_called_class", "(", ")", ...
Deletes the data associated with the current `Model`. @param object $entity Entity to delete. @param array $options Options. @return boolean Success. @filter Good for executing logic for i.e. invalidating cached results.
[ "Deletes", "the", "data", "associated", "with", "the", "current", "Model", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1379-L1392
UnionOfRAD/lithium
data/Model.php
Model.update
public static function update($data, $conditions = [], array $options = []) { $params = compact('data', 'conditions', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $options = $params + $params['options'] + [ 'model' => get_called_class(), 'type' => 'updat...
php
public static function update($data, $conditions = [], array $options = []) { $params = compact('data', 'conditions', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $options = $params + $params['options'] + [ 'model' => get_called_class(), 'type' => 'updat...
[ "public", "static", "function", "update", "(", "$", "data", ",", "$", "conditions", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "compact", "(", "'data'", ",", "'conditions'", ",", "'options'", ")", ";", ...
Update multiple records or documents with the given data, restricted by the given set of criteria (optional). @param mixed $data Typically an array of key/value pairs that specify the new data with which the records will be updated. For SQL databases, this can optionally be an SQL fragment representing the `SET` claus...
[ "Update", "multiple", "records", "or", "documents", "with", "the", "given", "data", "restricted", "by", "the", "given", "set", "of", "criteria", "(", "optional", ")", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1409-L1422
UnionOfRAD/lithium
data/Model.php
Model.remove
public static function remove($conditions = [], array $options = []) { $params = compact('conditions', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $options = $params['options'] + $params + [ 'model' => get_called_class(), 'type' => 'delete' ]; uns...
php
public static function remove($conditions = [], array $options = []) { $params = compact('conditions', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $options = $params['options'] + $params + [ 'model' => get_called_class(), 'type' => 'delete' ]; uns...
[ "public", "static", "function", "remove", "(", "$", "conditions", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "compact", "(", "'conditions'", ",", "'options'", ")", ";", "return", "Filters", "::", "run", ...
Remove multiple documents or records based on a given set of criteria. **WARNING**: If no criteria are specified, or if the criteria (`$conditions`) is an empty value (i.e. an empty array or `null`), all the data in the backend data source (i.e. table or collection) _will_ be deleted. @param mixed $conditions An array...
[ "Remove", "multiple", "documents", "or", "records", "based", "on", "a", "given", "set", "of", "criteria", ".", "**", "WARNING", "**", ":", "If", "no", "criteria", "are", "specified", "or", "if", "the", "criteria", "(", "$conditions", ")", "is", "an", "em...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1438-L1451
UnionOfRAD/lithium
data/Model.php
Model.&
public static function &connection() { $self = static::_object(); $connections = $self->_classes['connections']; $name = isset($self->_meta['connection']) ? $self->_meta['connection'] : null; if ($conn = $connections::get($name)) { return $conn; } $class = get_called_class(); $msg = "The data connecti...
php
public static function &connection() { $self = static::_object(); $connections = $self->_classes['connections']; $name = isset($self->_meta['connection']) ? $self->_meta['connection'] : null; if ($conn = $connections::get($name)) { return $conn; } $class = get_called_class(); $msg = "The data connecti...
[ "public", "static", "function", "&", "connection", "(", ")", "{", "$", "self", "=", "static", "::", "_object", "(", ")", ";", "$", "connections", "=", "$", "self", "->", "_classes", "[", "'connections'", "]", ";", "$", "name", "=", "isset", "(", "$",...
Gets the connection object to which this model is bound. Throws exceptions if a connection isn't set, or if the connection named isn't configured. @return object Returns an instance of `lithium\data\Source` from the connection configuration to which this model is bound.
[ "Gets", "the", "connection", "object", "to", "which", "this", "model", "is", "bound", ".", "Throws", "exceptions", "if", "a", "connection", "isn", "t", "set", "or", "if", "the", "connection", "named", "isn", "t", "configured", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1460-L1471
UnionOfRAD/lithium
data/Model.php
Model._relationsToLoad
protected static function _relationsToLoad() { try { if (!$connection = static::connection()) { return; } } catch (ConfigException $e) { return; } if (!$connection::enabled('relationships')) { return; } $self = static::_object(); foreach ($self->_relationTypes as $type) { $self->$typ...
php
protected static function _relationsToLoad() { try { if (!$connection = static::connection()) { return; } } catch (ConfigException $e) { return; } if (!$connection::enabled('relationships')) { return; } $self = static::_object(); foreach ($self->_relationTypes as $type) { $self->$typ...
[ "protected", "static", "function", "_relationsToLoad", "(", ")", "{", "try", "{", "if", "(", "!", "$", "connection", "=", "static", "::", "connection", "(", ")", ")", "{", "return", ";", "}", "}", "catch", "(", "ConfigException", "$", "e", ")", "{", ...
Iterates through relationship types to construct relation map. @todo See if this can be rewritten to be lazy. @return void
[ "Iterates", "through", "relationship", "types", "to", "construct", "relation", "map", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Model.php#L1490-L1513
UnionOfRAD/lithium
console/command/create/View.php
View._save
protected function _save(array $params = []) { $params['path'] = Inflector::underscore($this->request->action); $params['file'] = $this->request->args(0); $contents = $this->_template(); $result = Text::insert($contents, $params); if (!empty($this->_library['path'])) { $path = $this->_library['path'] . "...
php
protected function _save(array $params = []) { $params['path'] = Inflector::underscore($this->request->action); $params['file'] = $this->request->args(0); $contents = $this->_template(); $result = Text::insert($contents, $params); if (!empty($this->_library['path'])) { $path = $this->_library['path'] . "...
[ "protected", "function", "_save", "(", "array", "$", "params", "=", "[", "]", ")", "{", "$", "params", "[", "'path'", "]", "=", "Inflector", "::", "underscore", "(", "$", "this", "->", "request", "->", "action", ")", ";", "$", "params", "[", "'file'"...
Override the save method to handle view specific params. @param array $params @return mixed
[ "Override", "the", "save", "method", "to", "handle", "view", "specific", "params", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/create/View.php#L60-L90
UnionOfRAD/lithium
data/collection/DocumentSet.php
DocumentSet.modified
public function modified() { if (count($this->_original) !== count($this->_data)) { return true; } foreach ($this->_original as $key => $doc) { $updated = $this->_data[$key]; if (!isset($updated)) { return true; } if ($doc !== $updated) { return true; } if (!is_object($updated) || !me...
php
public function modified() { if (count($this->_original) !== count($this->_data)) { return true; } foreach ($this->_original as $key => $doc) { $updated = $this->_data[$key]; if (!isset($updated)) { return true; } if ($doc !== $updated) { return true; } if (!is_object($updated) || !me...
[ "public", "function", "modified", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "_original", ")", "!==", "count", "(", "$", "this", "->", "_data", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "_original...
Determines if the `DocumentSet` has been modified since it was last saved @return boolean
[ "Determines", "if", "the", "DocumentSet", "has", "been", "modified", "since", "it", "was", "last", "saved" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/DocumentSet.php#L50-L72
UnionOfRAD/lithium
data/collection/DocumentSet.php
DocumentSet.to
public function to($format, array $options = []) { $this->offsetGet(null); return parent::to($format, $options); }
php
public function to($format, array $options = []) { $this->offsetGet(null); return parent::to($format, $options); }
[ "public", "function", "to", "(", "$", "format", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "offsetGet", "(", "null", ")", ";", "return", "parent", "::", "to", "(", "$", "format", ",", "$", "options", ")", ";", "}" ]
Adds conversions checks to ensure certain class types and embedded values are properly cast. @param string $format Currently only `array` is supported. @param array $options @return mixed
[ "Adds", "conversions", "checks", "to", "ensure", "certain", "class", "types", "and", "embedded", "values", "are", "properly", "cast", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/DocumentSet.php#L81-L84
UnionOfRAD/lithium
data/collection/DocumentSet.php
DocumentSet._populate
protected function _populate() { if ($this->closed() || !$this->_result->valid()) { return; } $data = $this->_result->current(); $result = $this->_set($data, null, ['exists' => true, 'original' => true]); $this->_result->next(); return $result; }
php
protected function _populate() { if ($this->closed() || !$this->_result->valid()) { return; } $data = $this->_result->current(); $result = $this->_set($data, null, ['exists' => true, 'original' => true]); $this->_result->next(); return $result; }
[ "protected", "function", "_populate", "(", ")", "{", "if", "(", "$", "this", "->", "closed", "(", ")", "||", "!", "$", "this", "->", "_result", "->", "valid", "(", ")", ")", "{", "return", ";", "}", "$", "data", "=", "$", "this", "->", "_result",...
Extract the next item from the result ressource and wraps it into a `Document` object. @return mixed Returns the next `Document` if exists. Returns `null` otherwise
[ "Extract", "the", "next", "item", "from", "the", "result", "ressource", "and", "wraps", "it", "into", "a", "Document", "object", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/DocumentSet.php#L101-L110
UnionOfRAD/lithium
data/collection/DocumentSet.php
DocumentSet._set
protected function _set($data = null, $offset = null, $options = []) { if ($schema = $this->schema()) { $model = $this->_model; $pathKey = $this->_pathKey; $options = compact('model', 'pathKey') + $options; $data = !is_object($data) ? $schema->cast($this, $offset, $data, $options) : $data; $key = $mod...
php
protected function _set($data = null, $offset = null, $options = []) { if ($schema = $this->schema()) { $model = $this->_model; $pathKey = $this->_pathKey; $options = compact('model', 'pathKey') + $options; $data = !is_object($data) ? $schema->cast($this, $offset, $data, $options) : $data; $key = $mod...
[ "protected", "function", "_set", "(", "$", "data", "=", "null", ",", "$", "offset", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "schema", "=", "$", "this", "->", "schema", "(", ")", ")", "{", "$", "model", "=", ...
Helper method to normalize and set data. @param mixed $data @param null|integer|string $offset @param array $options @return mixed The (potentially) cast data.
[ "Helper", "method", "to", "normalize", "and", "set", "data", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/DocumentSet.php#L120-L144
UnionOfRAD/lithium
data/Connections.php
Connections.add
public static function add($name, array $config = []) { $defaults = [ 'type' => null, 'adapter' => null ]; return static::$_configurations[$name] = $config + $defaults; }
php
public static function add($name, array $config = []) { $defaults = [ 'type' => null, 'adapter' => null ]; return static::$_configurations[$name] = $config + $defaults; }
[ "public", "static", "function", "add", "(", "$", "name", ",", "array", "$", "config", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'type'", "=>", "null", ",", "'adapter'", "=>", "null", "]", ";", "return", "static", "::", "$", "_configuration...
Add connection configurations to your app in `config/bootstrap/connections.php` For example: ``` Connections::add('default', [ 'type' => 'database', 'adapter' => 'MySql', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'database' => 'my_blog' ]); ``` or ``` Connections::add('couch', [ 'type' => 'http', '...
[ "Add", "connection", "configurations", "to", "your", "app", "in", "config", "/", "bootstrap", "/", "connections", ".", "php" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Connections.php#L102-L108
UnionOfRAD/lithium
data/Connections.php
Connections.get
public static function get($name = null, array $options = []) { static $mockAdapter; $defaults = ['config' => false, 'autoCreate' => true]; $options += $defaults; if ($name === false) { if (!$mockAdapter) { $class = Libraries::locate('data.source', 'Mock'); $mockAdapter = new $class(); } retu...
php
public static function get($name = null, array $options = []) { static $mockAdapter; $defaults = ['config' => false, 'autoCreate' => true]; $options += $defaults; if ($name === false) { if (!$mockAdapter) { $class = Libraries::locate('data.source', 'Mock'); $mockAdapter = new $class(); } retu...
[ "public", "static", "function", "get", "(", "$", "name", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "static", "$", "mockAdapter", ";", "$", "defaults", "=", "[", "'config'", "=>", "false", ",", "'autoCreate'", "=>", "true", "...
Read the configuration or access the connections you have set up. Usage: ``` // Gets the names of all available configurations $configurations = Connections::get(); // Gets the configuration array for the connection named 'db' $config = Connections::get('db', ['config' => true]); // Gets the instance of the connecti...
[ "Read", "the", "configuration", "or", "access", "the", "connections", "you", "have", "set", "up", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Connections.php#L148-L178
UnionOfRAD/lithium
data/Connections.php
Connections._class
protected static function _class($config, $paths = []) { if (!$config['adapter']) { $config['adapter'] = $config['type']; } else { $paths = array_merge(["adapter.data.source.{$config['type']}"], (array) $paths); } return parent::_class($config, $paths); }
php
protected static function _class($config, $paths = []) { if (!$config['adapter']) { $config['adapter'] = $config['type']; } else { $paths = array_merge(["adapter.data.source.{$config['type']}"], (array) $paths); } return parent::_class($config, $paths); }
[ "protected", "static", "function", "_class", "(", "$", "config", ",", "$", "paths", "=", "[", "]", ")", "{", "if", "(", "!", "$", "config", "[", "'adapter'", "]", ")", "{", "$", "config", "[", "'adapter'", "]", "=", "$", "config", "[", "'type'", ...
Constructs a data source or adapter object instance from a configuration array. @param array $config @param array $paths @return object
[ "Constructs", "a", "data", "source", "or", "adapter", "object", "instance", "from", "a", "configuration", "array", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Connections.php#L187-L194
UnionOfRAD/lithium
console/Response.php
Response.output
public function output($output) { return fwrite($this->output, Text::insert($output, $this->styles())); }
php
public function output($output) { return fwrite($this->output, Text::insert($output, $this->styles())); }
[ "public", "function", "output", "(", "$", "output", ")", "{", "return", "fwrite", "(", "$", "this", "->", "output", ",", "Text", "::", "insert", "(", "$", "output", ",", "$", "this", "->", "styles", "(", ")", ")", ")", ";", "}" ]
Writes string to output stream @param string $output @return mixed
[ "Writes", "string", "to", "output", "stream" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/Response.php#L90-L92
UnionOfRAD/lithium
console/Response.php
Response.error
public function error($error) { return fwrite($this->error, Text::insert($error, $this->styles())); }
php
public function error($error) { return fwrite($this->error, Text::insert($error, $this->styles())); }
[ "public", "function", "error", "(", "$", "error", ")", "{", "return", "fwrite", "(", "$", "this", "->", "error", ",", "Text", "::", "insert", "(", "$", "error", ",", "$", "this", "->", "styles", "(", ")", ")", ")", ";", "}" ]
Writes string to error stream @param string $error @return mixed
[ "Writes", "string", "to", "error", "stream" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/Response.php#L100-L102
UnionOfRAD/lithium
console/Response.php
Response.styles
public function styles($styles = []) { $defaults = [ 'end' => "\033[0m", 'black' => "\033[0;30m", 'red' => "\033[0;31m", 'green' => "\033[0;32m", 'yellow' => "\033[0;33m", 'blue' => "\033[0;34m", 'purple' => "\033[0;35m", 'cyan' => "\033[0;36m", 'white' => "\033[0;37m", 'hea...
php
public function styles($styles = []) { $defaults = [ 'end' => "\033[0m", 'black' => "\033[0;30m", 'red' => "\033[0;31m", 'green' => "\033[0;32m", 'yellow' => "\033[0;33m", 'blue' => "\033[0;34m", 'purple' => "\033[0;35m", 'cyan' => "\033[0;36m", 'white' => "\033[0;37m", 'hea...
[ "public", "function", "styles", "(", "$", "styles", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'end'", "=>", "\"\\033[0m\"", ",", "'black'", "=>", "\"\\033[0;30m\"", ",", "'red'", "=>", "\"\\033[0;31m\"", ",", "'green'", "=>", "\"\\033[0;32m\"", ...
Handles styling output. Uses ANSI escape sequences for colorization. These may not always be supported (i.e. on Windows). @param array|boolean $styles @return array
[ "Handles", "styling", "output", ".", "Uses", "ANSI", "escape", "sequences", "for", "colorization", ".", "These", "may", "not", "always", "be", "supported", "(", "i", ".", "e", ".", "on", "Windows", ")", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/Response.php#L125-L147
UnionOfRAD/lithium
data/DocumentSchema.php
DocumentSchema._castType
protected function _castType($value, $field) { if ($this->is('null', $field) && ($value === null || $value === "")) { return null; } if (!is_scalar($value)) { return $value; } $type = $this->type($field); return isset($this->_handlers[$type]) ? $this->_handlers[$type]($value) : $value; }
php
protected function _castType($value, $field) { if ($this->is('null', $field) && ($value === null || $value === "")) { return null; } if (!is_scalar($value)) { return $value; } $type = $this->type($field); return isset($this->_handlers[$type]) ? $this->_handlers[$type]($value) : $value; }
[ "protected", "function", "_castType", "(", "$", "value", ",", "$", "field", ")", "{", "if", "(", "$", "this", "->", "is", "(", "'null'", ",", "$", "field", ")", "&&", "(", "$", "value", "===", "null", "||", "$", "value", "===", "\"\"", ")", ")", ...
Casts a scalar (non-object/array) value to its corresponding database-native value or custom value object based on a handler assigned to `$field`'s data type. @param mixed $value The value to be cast. @param string $field The name of the field that `$value` is or will be stored in. If it is a nested field, `$field` sh...
[ "Casts", "a", "scalar", "(", "non", "-", "object", "/", "array", ")", "value", "to", "its", "corresponding", "database", "-", "native", "value", "or", "custom", "value", "object", "based", "on", "a", "handler", "assigned", "to", "$field", "s", "data", "t...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/DocumentSchema.php#L117-L126
UnionOfRAD/lithium
core/StaticObject.php
StaticObject.invokeMethod
public static function invokeMethod($method, $params = []) { switch (count($params)) { case 0: return static::$method(); case 1: return static::$method($params[0]); case 2: return static::$method($params[0], $params[1]); case 3: return static::$method($params[0], $params[1], $params[2]); ...
php
public static function invokeMethod($method, $params = []) { switch (count($params)) { case 0: return static::$method(); case 1: return static::$method($params[0]); case 2: return static::$method($params[0], $params[1]); case 3: return static::$method($params[0], $params[1], $params[2]); ...
[ "public", "static", "function", "invokeMethod", "(", "$", "method", ",", "$", "params", "=", "[", "]", ")", "{", "switch", "(", "count", "(", "$", "params", ")", ")", "{", "case", "0", ":", "return", "static", "::", "$", "method", "(", ")", ";", ...
Calls a method on this object with the given parameters. Provides an OO wrapper for `forward_static_call_array()`, and improves performance by using straight method calls in most cases. @param string $method Name of the method to call. @param array $params Parameter list to use when calling `$method`. @return mixed Re...
[ "Calls", "a", "method", "on", "this", "object", "with", "the", "given", "parameters", ".", "Provides", "an", "OO", "wrapper", "for", "forward_static_call_array", "()", "and", "improves", "performance", "by", "using", "straight", "method", "calls", "in", "most", ...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/core/StaticObject.php#L40-L57
UnionOfRAD/lithium
core/StaticObject.php
StaticObject._instance
protected static function _instance($name, array $options = []) { if (is_string($name) && isset(static::$_classes[$name])) { $name = static::$_classes[$name]; } return Libraries::instance(null, $name, $options); }
php
protected static function _instance($name, array $options = []) { if (is_string($name) && isset(static::$_classes[$name])) { $name = static::$_classes[$name]; } return Libraries::instance(null, $name, $options); }
[ "protected", "static", "function", "_instance", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "name", ")", "&&", "isset", "(", "static", "::", "$", "_classes", "[", "$", "name", "]", ")",...
Returns an instance of a class with given `config`. The `name` could be a key from the `classes` array, a fully namespaced class name, or an object. Typically this method is used in `_init` to create the dependencies used in the current class. @param string|object $name A `classes` key or fully-namespaced class name. ...
[ "Returns", "an", "instance", "of", "a", "class", "with", "given", "config", ".", "The", "name", "could", "be", "a", "key", "from", "the", "classes", "array", "a", "fully", "namespaced", "class", "name", "or", "an", "object", ".", "Typically", "this", "me...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/core/StaticObject.php#L81-L86
UnionOfRAD/lithium
util/Inflector.php
Inflector.reset
public static function reset() { static::$_singularized = static::$_pluralized = []; static::$_camelized = static::$_underscored = []; static::$_humanized = []; static::$_plural['regexUninflected'] = static::$_singular['regexUninflected'] = null; static::$_plural['regexIrregular'] = static::$_singular['regex...
php
public static function reset() { static::$_singularized = static::$_pluralized = []; static::$_camelized = static::$_underscored = []; static::$_humanized = []; static::$_plural['regexUninflected'] = static::$_singular['regexUninflected'] = null; static::$_plural['regexIrregular'] = static::$_singular['regex...
[ "public", "static", "function", "reset", "(", ")", "{", "static", "::", "$", "_singularized", "=", "static", "::", "$", "_pluralized", "=", "[", "]", ";", "static", "::", "$", "_camelized", "=", "static", "::", "$", "_underscored", "=", "[", "]", ";", ...
Clears local in-memory caches. Can be used to force a full-cache clear when updating inflection rules mid-way through request execution.
[ "Clears", "local", "in", "-", "memory", "caches", ".", "Can", "be", "used", "to", "force", "a", "full", "-", "cache", "clear", "when", "updating", "inflection", "rules", "mid", "-", "way", "through", "request", "execution", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/util/Inflector.php#L230-L261
UnionOfRAD/lithium
util/Inflector.php
Inflector.singularize
public static function singularize($word) { if (isset(static::$_singularized[$word])) { return static::$_singularized[$word]; } if (empty(static::$_singular['irregular'])) { static::$_singular['irregular'] = array_flip(static::$_plural['irregular']); } extract(static::$_singular); if (!isset($regexUn...
php
public static function singularize($word) { if (isset(static::$_singularized[$word])) { return static::$_singularized[$word]; } if (empty(static::$_singular['irregular'])) { static::$_singular['irregular'] = array_flip(static::$_plural['irregular']); } extract(static::$_singular); if (!isset($regexUn...
[ "public", "static", "function", "singularize", "(", "$", "word", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "_singularized", "[", "$", "word", "]", ")", ")", "{", "return", "static", "::", "$", "_singularized", "[", "$", "word", "]", ";"...
Changes the form of a word from plural to singular. @param string $word Word in plural form. @return string Word in singular form.
[ "Changes", "the", "form", "of", "a", "word", "from", "plural", "to", "singular", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/util/Inflector.php#L361-L388
UnionOfRAD/lithium
util/Inflector.php
Inflector.camelize
public static function camelize($word, $cased = true) { $_word = $word; if (isset(static::$_camelized[$_word]) && $cased) { return static::$_camelized[$_word]; } $word = str_replace(" ", "", ucwords(str_replace(["_", '-'], " ", $word))); if (!$cased) { return lcfirst($word); } return static::$_cam...
php
public static function camelize($word, $cased = true) { $_word = $word; if (isset(static::$_camelized[$_word]) && $cased) { return static::$_camelized[$_word]; } $word = str_replace(" ", "", ucwords(str_replace(["_", '-'], " ", $word))); if (!$cased) { return lcfirst($word); } return static::$_cam...
[ "public", "static", "function", "camelize", "(", "$", "word", ",", "$", "cased", "=", "true", ")", "{", "$", "_word", "=", "$", "word", ";", "if", "(", "isset", "(", "static", "::", "$", "_camelized", "[", "$", "_word", "]", ")", "&&", "$", "case...
Takes a under_scored word and turns it into a CamelCased or camelBack word @param string $word An under_scored or slugged word (i.e. `'red_bike'` or `'red-bike'`). @param boolean $cased If false, first character is not upper cased @return string CamelCased version of the word (i.e. `'RedBike'`).
[ "Takes", "a", "under_scored", "word", "and", "turns", "it", "into", "a", "CamelCased", "or", "camelBack", "word" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/util/Inflector.php#L397-L409
UnionOfRAD/lithium
util/Inflector.php
Inflector.underscore
public static function underscore($word) { if (isset(static::$_underscored[$word])) { return static::$_underscored[$word]; } return static::$_underscored[$word] = strtolower(static::slug($word, '_')); }
php
public static function underscore($word) { if (isset(static::$_underscored[$word])) { return static::$_underscored[$word]; } return static::$_underscored[$word] = strtolower(static::slug($word, '_')); }
[ "public", "static", "function", "underscore", "(", "$", "word", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "_underscored", "[", "$", "word", "]", ")", ")", "{", "return", "static", "::", "$", "_underscored", "[", "$", "word", "]", ";", ...
Takes a CamelCased version of a word and turns it into an under_scored one. @param string $word CamelCased version of a word (i.e. `'RedBike'`). @return string Under_scored version of the workd (i.e. `'red_bike'`).
[ "Takes", "a", "CamelCased", "version", "of", "a", "word", "and", "turns", "it", "into", "an", "under_scored", "one", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/util/Inflector.php#L417-L422
UnionOfRAD/lithium
util/Inflector.php
Inflector.humanize
public static function humanize($word, $separator = '_') { if (isset(static::$_humanized[$key = $word . ':' . $separator])) { return static::$_humanized[$key]; } return static::$_humanized[$key] = ucwords(str_replace($separator, " ", $word)); }
php
public static function humanize($word, $separator = '_') { if (isset(static::$_humanized[$key = $word . ':' . $separator])) { return static::$_humanized[$key]; } return static::$_humanized[$key] = ucwords(str_replace($separator, " ", $word)); }
[ "public", "static", "function", "humanize", "(", "$", "word", ",", "$", "separator", "=", "'_'", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "_humanized", "[", "$", "key", "=", "$", "word", ".", "':'", ".", "$", "separator", "]", ")", ...
Takes an under_scored version of a word and turns it into an human- readable form by replacing underscores with a space, and by upper casing the initial character. @param string $word Under_scored version of a word (i.e. `'red_bike'`). @param string $separator The separator character used in the initial string. @retur...
[ "Takes", "an", "under_scored", "version", "of", "a", "word", "and", "turns", "it", "into", "an", "human", "-", "readable", "form", "by", "replacing", "underscores", "with", "a", "space", "and", "by", "upper", "casing", "the", "initial", "character", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/util/Inflector.php#L452-L457
UnionOfRAD/lithium
g11n/catalog/adapter/Memory.php
Memory.read
public function read($category, $locale, $scope) { $scope = $scope ?: 'default'; if (isset($this->_data[$scope][$category][$locale])) { return $this->_data[$scope][$category][$locale]; } }
php
public function read($category, $locale, $scope) { $scope = $scope ?: 'default'; if (isset($this->_data[$scope][$category][$locale])) { return $this->_data[$scope][$category][$locale]; } }
[ "public", "function", "read", "(", "$", "category", ",", "$", "locale", ",", "$", "scope", ")", "{", "$", "scope", "=", "$", "scope", "?", ":", "'default'", ";", "if", "(", "isset", "(", "$", "this", "->", "_data", "[", "$", "scope", "]", "[", ...
Reads data. @param string $category A category. @param string $locale A locale identifier. @param string $scope The scope for the current operation. @return array
[ "Reads", "data", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/catalog/adapter/Memory.php#L35-L41
UnionOfRAD/lithium
g11n/catalog/adapter/Memory.php
Memory.write
public function write($category, $locale, $scope, array $data) { $scope = $scope ?: 'default'; if (!isset($this->_data[$scope][$category][$locale])) { $this->_data[$scope][$category][$locale] = []; } foreach ($data as $item) { $this->_data[$scope][$category][$locale] = $this->_merge( $this->_data[$sc...
php
public function write($category, $locale, $scope, array $data) { $scope = $scope ?: 'default'; if (!isset($this->_data[$scope][$category][$locale])) { $this->_data[$scope][$category][$locale] = []; } foreach ($data as $item) { $this->_data[$scope][$category][$locale] = $this->_merge( $this->_data[$sc...
[ "public", "function", "write", "(", "$", "category", ",", "$", "locale", ",", "$", "scope", ",", "array", "$", "data", ")", "{", "$", "scope", "=", "$", "scope", "?", ":", "'default'", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_data"...
Writes data. @param string $category A category. @param string $locale A locale identifier. @param string $scope The scope for the current operation. @param array $data The data to write. @return boolean
[ "Writes", "data", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/catalog/adapter/Memory.php#L52-L65
UnionOfRAD/lithium
net/http/Router.php
Router.config
public static function config($config = []) { if (!$config) { return ['classes' => static::$_classes, 'unicode' => static::$_unicode]; } if (isset($config['classes'])) { static::$_classes = $config['classes'] + static::$_classes; } if (isset($config['unicode'])) { static::$_unicode = $config['unicode...
php
public static function config($config = []) { if (!$config) { return ['classes' => static::$_classes, 'unicode' => static::$_unicode]; } if (isset($config['classes'])) { static::$_classes = $config['classes'] + static::$_classes; } if (isset($config['unicode'])) { static::$_unicode = $config['unicode...
[ "public", "static", "function", "config", "(", "$", "config", "=", "[", "]", ")", "{", "if", "(", "!", "$", "config", ")", "{", "return", "[", "'classes'", "=>", "static", "::", "$", "_classes", ",", "'unicode'", "=>", "static", "::", "$", "_unicode"...
Modify `Router` configuration settings and dependencies. @param array $config Optional array to override configuration. Acceptable keys are `'classes'` and `'unicode'`. @return array Returns the current configuration settings.
[ "Modify", "Router", "configuration", "settings", "and", "dependencies", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L126-L136
UnionOfRAD/lithium
net/http/Router.php
Router.connect
public static function connect($template, $params = [], $options = []) { if (is_array($options) && isset($options['scope'])) { $name = $options['scope']; } else { $name = static::$_scope; } if (is_object($template)) { return (static::$_configurations[$name][] = $template); } if (is_string($params))...
php
public static function connect($template, $params = [], $options = []) { if (is_array($options) && isset($options['scope'])) { $name = $options['scope']; } else { $name = static::$_scope; } if (is_object($template)) { return (static::$_configurations[$name][] = $template); } if (is_string($params))...
[ "public", "static", "function", "connect", "(", "$", "template", ",", "$", "params", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", "&&", "isset", "(", "$", "options", "[", "'scope'", ...
Connects a new route and returns the current routes array. This method creates a new `Route` object and registers it with the `Router`. The order in which routes are connected matters, since the order of precedence is taken into account in parsing and matching operations. A callable can be passed in place of `$options...
[ "Connects", "a", "new", "route", "and", "returns", "the", "current", "routes", "array", ".", "This", "method", "creates", "a", "new", "Route", "object", "and", "registers", "it", "with", "the", "Router", ".", "The", "order", "in", "which", "routes", "are",...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L172-L198
UnionOfRAD/lithium
net/http/Router.php
Router.modifiers
public static function modifiers(array $modifiers = []) { if (!static::$_modifiers) { static::$_modifiers = [ 'args' => function($value) { return explode('/', $value); }, 'controller' => function($value) { return Inflector::camelize($value); } ]; } if ($modifiers) { static::$_mo...
php
public static function modifiers(array $modifiers = []) { if (!static::$_modifiers) { static::$_modifiers = [ 'args' => function($value) { return explode('/', $value); }, 'controller' => function($value) { return Inflector::camelize($value); } ]; } if ($modifiers) { static::$_mo...
[ "public", "static", "function", "modifiers", "(", "array", "$", "modifiers", "=", "[", "]", ")", "{", "if", "(", "!", "static", "::", "$", "_modifiers", ")", "{", "static", "::", "$", "_modifiers", "=", "[", "'args'", "=>", "function", "(", "$", "val...
Used to get or set an array of named formatter closures, which are used to format route parameters when parsing URLs. For example, the following would match a `posts/index` url to a `PostsController::indexAction()` method. ``` use lithium\util\Inflector; Router::modifiers([ 'controller' => function($value) { return I...
[ "Used", "to", "get", "or", "set", "an", "array", "of", "named", "formatter", "closures", "which", "are", "used", "to", "format", "route", "parameters", "when", "parsing", "URLs", ".", "For", "example", "the", "following", "would", "match", "a", "posts", "/...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L239-L254
UnionOfRAD/lithium
net/http/Router.php
Router.formatters
public static function formatters(array $formatters = []) { if (!static::$_formatters) { static::$_formatters = [ 'args' => function($value) { return is_array($value) ? join('/', $value) : $value; }, 'controller' => function($value) { if (strpos($value, '\\')) { $value = explode('\\', $...
php
public static function formatters(array $formatters = []) { if (!static::$_formatters) { static::$_formatters = [ 'args' => function($value) { return is_array($value) ? join('/', $value) : $value; }, 'controller' => function($value) { if (strpos($value, '\\')) { $value = explode('\\', $...
[ "public", "static", "function", "formatters", "(", "array", "$", "formatters", "=", "[", "]", ")", "{", "if", "(", "!", "static", "::", "$", "_formatters", ")", "{", "static", "::", "$", "_formatters", "=", "[", "'args'", "=>", "function", "(", "$", ...
Used to get or set an array of named formatter closures, which are used to format route parameters when generating URLs. For example, for controller/action parameters to be dashed instead of underscored or camelBacked, you could do the following: ``` use lithium\util\Inflector; Router::formatters([ 'controller' => fu...
[ "Used", "to", "get", "or", "set", "an", "array", "of", "named", "formatter", "closures", "which", "are", "used", "to", "format", "route", "parameters", "when", "generating", "URLs", ".", "For", "example", "for", "controller", "/", "action", "parameters", "to...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L277-L296
UnionOfRAD/lithium
net/http/Router.php
Router.parse
public static function parse($request) { foreach (static::$_configurations as $name => $value) { $original = $request->params; $name = is_int($name) ? false : $name; if (!$url = static::_parseScope($name, $request)) { continue; } foreach (static::$_configurations[$name] as $route) { if (!$mat...
php
public static function parse($request) { foreach (static::$_configurations as $name => $value) { $original = $request->params; $name = is_int($name) ? false : $name; if (!$url = static::_parseScope($name, $request)) { continue; } foreach (static::$_configurations[$name] as $route) { if (!$mat...
[ "public", "static", "function", "parse", "(", "$", "request", ")", "{", "foreach", "(", "static", "::", "$", "_configurations", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "original", "=", "$", "request", "->", "params", ";", "$", "name", "...
Accepts an instance of `lithium\action\Request` (or a subclass) and matches it against each route, in the order that the routes are connected. If a route match the request, `lithium\net\http\Router::_scope` will be updated according the scope membership of the route @see lithium\action\Request @see lithium\net\http\R...
[ "Accepts", "an", "instance", "of", "lithium", "\\", "action", "\\", "Request", "(", "or", "a", "subclass", ")", "and", "matches", "it", "against", "each", "route", "in", "the", "order", "that", "the", "routes", "are", "connected", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L312-L339
UnionOfRAD/lithium
net/http/Router.php
Router.match
public static function match($url = [], $context = null, array $options = []) { $options = static::_matchOptions($url, $context, $options); if (is_string($url = static::_prepareParams($url, $context, $options))) { return $url; } $base = $options['base']; $url += ['action' => 'index']; $stack = []; $...
php
public static function match($url = [], $context = null, array $options = []) { $options = static::_matchOptions($url, $context, $options); if (is_string($url = static::_prepareParams($url, $context, $options))) { return $url; } $base = $options['base']; $url += ['action' => 'index']; $stack = []; $...
[ "public", "static", "function", "match", "(", "$", "url", "=", "[", "]", ",", "$", "context", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "static", "::", "_matchOptions", "(", "$", "url", ",", "$", "co...
Attempts to match an array of route parameters (i.e. `'controller'`, `'action'`, etc.) against a connected `Route` object. For example, given the following route: ``` Router::connect('/login', ['controller' => 'users', 'action' => 'login']); ``` This will match: ``` $url = Router::match(['controller' => 'users', 'act...
[ "Attempts", "to", "match", "an", "array", "of", "route", "parameters", "(", "i", ".", "e", ".", "controller", "action", "etc", ".", ")", "against", "a", "connected", "Route", "object", ".", "For", "example", "given", "the", "following", "route", ":" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L403-L444
UnionOfRAD/lithium
net/http/Router.php
Router._matchOptions
protected static function _matchOptions(&$url, $context, $options) { $defaults = [ 'scheme' => null, 'host' => null, 'absolute' => false, 'base' => '' ]; if ($context) { $defaults = [ 'base' => $context->env('base'), 'host' => $context->host, 'scheme' => $context->scheme . ($context->sc...
php
protected static function _matchOptions(&$url, $context, $options) { $defaults = [ 'scheme' => null, 'host' => null, 'absolute' => false, 'base' => '' ]; if ($context) { $defaults = [ 'base' => $context->env('base'), 'host' => $context->host, 'scheme' => $context->scheme . ($context->sc...
[ "protected", "static", "function", "_matchOptions", "(", "&", "$", "url", ",", "$", "context", ",", "$", "options", ")", "{", "$", "defaults", "=", "[", "'scheme'", "=>", "null", ",", "'host'", "=>", "null", ",", "'absolute'", "=>", "false", ",", "'bas...
Initialize options for `Router::match()`. @param string|array $url Options to match to a URL. Optionally, this can be a string containing a manually generated URL. @param \lithium\action\Request $context @param array $options Options for the generation of the matched URL. @return array The initialized options.
[ "Initialize", "options", "for", "Router", "::", "match", "()", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L455-L502
UnionOfRAD/lithium
net/http/Router.php
Router._prepareParams
protected static function _prepareParams($url, $context, array $options) { if (is_string($url)) { if (strpos($url, '://') !== false) { return $url; } if (preg_match('%^((#|//)|(mailto|tel|sms|javascript):)%', $url)) { return $url; } if (is_string($url = static::_parseString($url, $context, $opt...
php
protected static function _prepareParams($url, $context, array $options) { if (is_string($url)) { if (strpos($url, '://') !== false) { return $url; } if (preg_match('%^((#|//)|(mailto|tel|sms|javascript):)%', $url)) { return $url; } if (is_string($url = static::_parseString($url, $context, $opt...
[ "protected", "static", "function", "_prepareParams", "(", "$", "url", ",", "$", "context", ",", "array", "$", "options", ")", "{", "if", "(", "is_string", "(", "$", "url", ")", ")", "{", "if", "(", "strpos", "(", "$", "url", ",", "'://'", ")", "!==...
Prepares URL parameters for matching. Detects and Passes through un-routed URL strings, leaving them untouched. Will not attempt to parse strings as shorthand parameters but instead interpret them as normal, non-routed URLs when they are prefixed with a known scheme. @param array|string $url An array of parameters, s...
[ "Prepares", "URL", "parameters", "for", "matching", ".", "Detects", "and", "Passes", "through", "un", "-", "routed", "URL", "strings", "leaving", "them", "untouched", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L546-L567
UnionOfRAD/lithium
net/http/Router.php
Router._prefix
protected static function _prefix($path, $context = null, array $options = []) { $defaults = ['scheme' => null, 'host' => null, 'absolute' => false]; $options += $defaults; return ($options['absolute']) ? "{$options['scheme']}{$options['host']}{$path}" : $path; }
php
protected static function _prefix($path, $context = null, array $options = []) { $defaults = ['scheme' => null, 'host' => null, 'absolute' => false]; $options += $defaults; return ($options['absolute']) ? "{$options['scheme']}{$options['host']}{$path}" : $path; }
[ "protected", "static", "function", "_prefix", "(", "$", "path", ",", "$", "context", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'scheme'", "=>", "null", ",", "'host'", "=>", "null", ",", "'absolute...
Returns the prefix (scheme + hostname) for a URL based on the passed `$options` and the `$context`. @param string $path The URL to be prefixed. @param object $context The request context. @param array $options Options for generating the proper prefix. Currently accepted values are: `'absolute' => true|false`, `'host' ...
[ "Returns", "the", "prefix", "(", "scheme", "+", "hostname", ")", "for", "a", "URL", "based", "on", "the", "passed", "$options", "and", "the", "$context", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L579-L583
UnionOfRAD/lithium
net/http/Router.php
Router._persist
protected static function _persist($url, $context) { if (!$context || !isset($context->persist)) { return $url; } foreach ($context->persist as $key) { $url += [$key => $context->params[$key]]; if ($url[$key] === null) { unset($url[$key]); } } return $url; }
php
protected static function _persist($url, $context) { if (!$context || !isset($context->persist)) { return $url; } foreach ($context->persist as $key) { $url += [$key => $context->params[$key]]; if ($url[$key] === null) { unset($url[$key]); } } return $url; }
[ "protected", "static", "function", "_persist", "(", "$", "url", ",", "$", "context", ")", "{", "if", "(", "!", "$", "context", "||", "!", "isset", "(", "$", "context", "->", "persist", ")", ")", "{", "return", "$", "url", ";", "}", "foreach", "(", ...
Copies persistent parameters (parameters in the request which have been designated to persist) to the current URL, unless the parameter has been explicitly disabled from persisting by setting the value in the URL to `null`, or by assigning some other value. For example: ``` Router::connect('/{:controller}/{:action}/{:...
[ "Copies", "persistent", "parameters", "(", "parameters", "in", "the", "request", "which", "have", "been", "designated", "to", "persist", ")", "to", "the", "current", "URL", "unless", "the", "parameter", "has", "been", "explicitly", "disabled", "from", "persistin...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L611-L623
UnionOfRAD/lithium
net/http/Router.php
Router.get
public static function get($route = null, $scope = null) { if ($route === null && $scope === null) { return static::$_configurations; } if ($scope === true) { $scope = static::$_scope; } if ($route === null && $scope !== null) { if (isset(static::$_configurations[$scope])) { return static::$_co...
php
public static function get($route = null, $scope = null) { if ($route === null && $scope === null) { return static::$_configurations; } if ($scope === true) { $scope = static::$_scope; } if ($route === null && $scope !== null) { if (isset(static::$_configurations[$scope])) { return static::$_co...
[ "public", "static", "function", "get", "(", "$", "route", "=", "null", ",", "$", "scope", "=", "null", ")", "{", "if", "(", "$", "route", "===", "null", "&&", "$", "scope", "===", "null", ")", "{", "return", "static", "::", "$", "_configurations", ...
Returns one or multiple connected routes. A specific route can be retrived by providing its index. All connected routes inside all scopes may be retrieved by providing `null` instead of the route index. To retrieve all routes for the current scope only, pass `true` for the `$scope` parameter. @param integer $route In...
[ "Returns", "one", "or", "multiple", "connected", "routes", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L639-L659
UnionOfRAD/lithium
net/http/Router.php
Router._parseString
protected static function _parseString($path, $context, array $options = []) { if (!preg_match('/^[A-Za-z0-9._\\\\]+::[A-Za-z0-9_]+$/', $path)) { $base = rtrim($options['base'], '/'); if ((!$path || $path[0] != '/') && $context && isset($context->controller)) { $formatters = static::formatters(); $base ...
php
protected static function _parseString($path, $context, array $options = []) { if (!preg_match('/^[A-Za-z0-9._\\\\]+::[A-Za-z0-9_]+$/', $path)) { $base = rtrim($options['base'], '/'); if ((!$path || $path[0] != '/') && $context && isset($context->controller)) { $formatters = static::formatters(); $base ...
[ "protected", "static", "function", "_parseString", "(", "$", "path", ",", "$", "context", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "preg_match", "(", "'/^[A-Za-z0-9._\\\\\\\\]+::[A-Za-z0-9_]+$/'", ",", "$", "path", ")", ")", "...
Helper function for taking a path string and parsing it into a controller and action array. @param string $path Path string to parse i.e. `li3_bot.Logs::index` or `Posts::index`. @param boolean $context @return array
[ "Helper", "function", "for", "taking", "a", "path", "string", "and", "parsing", "it", "into", "a", "controller", "and", "action", "array", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L679-L691
UnionOfRAD/lithium
net/http/Router.php
Router.attach
public static function attach($name, $config = null, array $vars = []) { if ($name === false) { return null; } if (!isset(static::$_scopes)) { static::_initScopes(); } if ($config === null) { if ($vars && ($config = static::$_scopes->get($name))) { $config['values'] = $vars; static::$_scope...
php
public static function attach($name, $config = null, array $vars = []) { if ($name === false) { return null; } if (!isset(static::$_scopes)) { static::_initScopes(); } if ($config === null) { if ($vars && ($config = static::$_scopes->get($name))) { $config['values'] = $vars; static::$_scope...
[ "public", "static", "function", "attach", "(", "$", "name", ",", "$", "config", "=", "null", ",", "array", "$", "vars", "=", "[", "]", ")", "{", "if", "(", "$", "name", "===", "false", ")", "{", "return", "null", ";", "}", "if", "(", "!", "isse...
Defines a scope and attaches it to a mount point. Example 1: ``` Router::attach('app', [ 'absolute' => true, 'host' => 'localhost', 'scheme' => 'http://', 'prefix' => 'web/tests' ]); ``` Example 2: ``` Router::attach('app', [ 'absolute' => true, 'host' => '{:subdomain:[a-z]+}.{:hostname}.{:tld}', 'scheme' => '{:schem...
[ "Defines", "a", "scope", "and", "attaches", "it", "to", "a", "mount", "point", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L776-L796
UnionOfRAD/lithium
net/http/Router.php
Router.attached
public static function attached($name = null, array $vars = []) { if ($name === false) { return null; } if (!isset(static::$_scopes)) { static::_initScopes(); } if ($name === null) { return static::$_scopes->get(); } elseif (!$config = static::$_scopes->get($name)) { static::$_scopes->set($nam...
php
public static function attached($name = null, array $vars = []) { if ($name === false) { return null; } if (!isset(static::$_scopes)) { static::_initScopes(); } if ($name === null) { return static::$_scopes->get(); } elseif (!$config = static::$_scopes->get($name)) { static::$_scopes->set($nam...
[ "public", "static", "function", "attached", "(", "$", "name", "=", "null", ",", "array", "$", "vars", "=", "[", "]", ")", "{", "if", "(", "$", "name", "===", "false", ")", "{", "return", "null", ";", "}", "if", "(", "!", "isset", "(", "static", ...
Returns an attached mount point configuration. ``` Router::attach('app', [ 'absolute' => true, 'host' => '{:subdomain:[a-z]+}.{:hostname}.{:tld}', 'scheme' => '{:scheme:https://}', 'prefix' => '' ]); $result = Router::attached('app', [ 'subdomain' => 'app', 'hostname' => 'blog', 'tld' => 'co.uk' ]); // $result is: /...
[ "Returns", "an", "attached", "mount", "point", "configuration", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L830-L864
UnionOfRAD/lithium
net/http/Router.php
Router._initScopes
protected static function _initScopes() { static::$_scopes = static::_instance('configuration'); static::$_scopes->initConfig = function($name, $config) { $defaults = [ 'absolute' => false, 'host' => null, 'scheme' => null, 'base' => null, 'prefix' => '', 'pattern' => '', 'values' =>...
php
protected static function _initScopes() { static::$_scopes = static::_instance('configuration'); static::$_scopes->initConfig = function($name, $config) { $defaults = [ 'absolute' => false, 'host' => null, 'scheme' => null, 'base' => null, 'prefix' => '', 'pattern' => '', 'values' =>...
[ "protected", "static", "function", "_initScopes", "(", ")", "{", "static", "::", "$", "_scopes", "=", "static", "::", "_instance", "(", "'configuration'", ")", ";", "static", "::", "$", "_scopes", "->", "initConfig", "=", "function", "(", "$", "name", ",",...
Initialize `static::$_scopes` with a `lithium\core\Configuration` instance.
[ "Initialize", "static", "::", "$_scopes", "with", "a", "lithium", "\\", "core", "\\", "Configuration", "instance", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L869-L892
UnionOfRAD/lithium
net/http/Router.php
Router._compileScope
protected static function _compileScope(array $config) { $defaults = [ 'absolute' => false, 'host' => null, 'scheme' => null, 'base' => null, 'prefix' => '', 'pattern' => '', 'params' => [] ]; $config += $defaults; $config['prefix'] = trim($config['prefix'], '/'); $prefix = '/' . ($conf...
php
protected static function _compileScope(array $config) { $defaults = [ 'absolute' => false, 'host' => null, 'scheme' => null, 'base' => null, 'prefix' => '', 'pattern' => '', 'params' => [] ]; $config += $defaults; $config['prefix'] = trim($config['prefix'], '/'); $prefix = '/' . ($conf...
[ "protected", "static", "function", "_compileScope", "(", "array", "$", "config", ")", "{", "$", "defaults", "=", "[", "'absolute'", "=>", "false", ",", "'host'", "=>", "null", ",", "'scheme'", "=>", "null", ",", "'base'", "=>", "null", ",", "'prefix'", "...
Compiles the scope into regular expression patterns for matching against request URLs @param array $config Array of settings. @return array Returns the complied settings.
[ "Compiles", "the", "scope", "into", "regular", "expression", "patterns", "for", "matching", "against", "request", "URLs" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L900-L944
UnionOfRAD/lithium
net/http/Router.php
Router._parseScope
protected static function _parseScope($name, $request) { $url = trim($request->url, '/'); $url = $url ? '/' . $url . '/' : '/'; if (!$config = static::attached($name)) { return $url; } $scheme = $request->scheme . ($request->scheme ? '://' : '//'); $host = $request->host; if ($config['absolute']) { ...
php
protected static function _parseScope($name, $request) { $url = trim($request->url, '/'); $url = $url ? '/' . $url . '/' : '/'; if (!$config = static::attached($name)) { return $url; } $scheme = $request->scheme . ($request->scheme ? '://' : '//'); $host = $request->host; if ($config['absolute']) { ...
[ "protected", "static", "function", "_parseScope", "(", "$", "name", ",", "$", "request", ")", "{", "$", "url", "=", "trim", "(", "$", "request", "->", "url", ",", "'/'", ")", ";", "$", "url", "=", "$", "url", "?", "'/'", ".", "$", "url", ".", "...
Return the unscoped url to route. @param string $name Scope name. @param string $request A `lithium\action\Request` instance . @return mixed The url to route, or `false` if the request doesn't match the scope.
[ "Return", "the", "unscoped", "url", "to", "route", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Router.php#L953-L983
UnionOfRAD/lithium
storage/cache/adapter/File.php
File.write
public function write(array $keys, $expiry = null) { $expiry = $expiry || $expiry === Cache::PERSIST ? $expiry : $this->_config['expiry']; if (!$expiry || $expiry === Cache::PERSIST) { $expires = 0; } elseif (is_int($expiry)) { $expires = $expiry + time(); } else { $expires = strtotime($expiry); } ...
php
public function write(array $keys, $expiry = null) { $expiry = $expiry || $expiry === Cache::PERSIST ? $expiry : $this->_config['expiry']; if (!$expiry || $expiry === Cache::PERSIST) { $expires = 0; } elseif (is_int($expiry)) { $expires = $expiry + time(); } else { $expires = strtotime($expiry); } ...
[ "public", "function", "write", "(", "array", "$", "keys", ",", "$", "expiry", "=", "null", ")", "{", "$", "expiry", "=", "$", "expiry", "||", "$", "expiry", "===", "Cache", "::", "PERSIST", "?", "$", "expiry", ":", "$", "this", "->", "_config", "["...
Write values to the cache. All items to be cached will receive an expiration time of `$expiry`. @param array $keys Key/value pairs with keys to uniquely identify the to-be-cached item. @param string|integer $expiry A `strtotime()` compatible cache time or TTL in seconds. To persist an item use `\lithium\storage\Cache:...
[ "Write", "values", "to", "the", "cache", ".", "All", "items", "to", "be", "cached", "will", "receive", "an", "expiration", "time", "of", "$expiry", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/adapter/File.php#L95-L114
UnionOfRAD/lithium
storage/cache/adapter/File.php
File.read
public function read(array $keys) { if ($this->_config['scope']) { $keys = $this->_addScopePrefix($this->_config['scope'], $keys, '_'); } $results = []; foreach ($keys as $key) { if (!$item = $this->_read($key, $this->_config['streams'])) { continue; } if ($item['expiry'] < time() && $item['exp...
php
public function read(array $keys) { if ($this->_config['scope']) { $keys = $this->_addScopePrefix($this->_config['scope'], $keys, '_'); } $results = []; foreach ($keys as $key) { if (!$item = $this->_read($key, $this->_config['streams'])) { continue; } if ($item['expiry'] < time() && $item['exp...
[ "public", "function", "read", "(", "array", "$", "keys", ")", "{", "if", "(", "$", "this", "->", "_config", "[", "'scope'", "]", ")", "{", "$", "keys", "=", "$", "this", "->", "_addScopePrefix", "(", "$", "this", "->", "_config", "[", "'scope'", "]...
Read values from the cache. Will attempt to return an array of data containing key/value pairs of the requested data. Invalidates and cleans up expired items on-the-fly when found. @param array $keys Keys to uniquely identify the cached items. @return array Cached values keyed by cache keys on successful read, keys w...
[ "Read", "values", "from", "the", "cache", ".", "Will", "attempt", "to", "return", "an", "array", "of", "data", "containing", "key", "/", "value", "pairs", "of", "the", "requested", "data", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/adapter/File.php#L127-L147
UnionOfRAD/lithium
storage/cache/adapter/File.php
File.decrement
public function decrement($key, $offset = 1) { if ($this->_config['scope']) { $key = "{$this->_config['scope']}_{$key}"; } if (!$result = $this->_read($key)) { return false; } if (!$this->_write($key, $result['value'] -= $offset, $result['expiry'])) { return false; } return $result['value']; }
php
public function decrement($key, $offset = 1) { if ($this->_config['scope']) { $key = "{$this->_config['scope']}_{$key}"; } if (!$result = $this->_read($key)) { return false; } if (!$this->_write($key, $result['value'] -= $offset, $result['expiry'])) { return false; } return $result['value']; }
[ "public", "function", "decrement", "(", "$", "key", ",", "$", "offset", "=", "1", ")", "{", "if", "(", "$", "this", "->", "_config", "[", "'scope'", "]", ")", "{", "$", "key", "=", "\"{$this->_config['scope']}_{$key}\"", ";", "}", "if", "(", "!", "$"...
Performs a decrement operation on a specified numeric cache item. @param string $key Key of numeric cache item to decrement. @param integer $offset Offset to decrement - defaults to `1`. @return integer|boolean The item's new value on successful decrement, else `false`.
[ "Performs", "a", "decrement", "operation", "on", "a", "specified", "numeric", "cache", "item", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/adapter/File.php#L174-L185
UnionOfRAD/lithium
storage/cache/adapter/File.php
File.clear
public function clear() { $result = true; foreach (new DirectoryIterator($this->_config['path']) as $file) { if (!$file->isFile()) { continue; } $result = $this->_delete($file->getBasename()) && $result; } return $result; }
php
public function clear() { $result = true; foreach (new DirectoryIterator($this->_config['path']) as $file) { if (!$file->isFile()) { continue; } $result = $this->_delete($file->getBasename()) && $result; } return $result; }
[ "public", "function", "clear", "(", ")", "{", "$", "result", "=", "true", ";", "foreach", "(", "new", "DirectoryIterator", "(", "$", "this", "->", "_config", "[", "'path'", "]", ")", "as", "$", "file", ")", "{", "if", "(", "!", "$", "file", "->", ...
Clears entire cache by flushing it. Please note that a scope - in case one is set - is *not* honored. The operation will continue to remove keys even if removing one single key fails, clearing thoroughly as possible. @return boolean `true` on successful clearing, `false` if failed partially or entirely.
[ "Clears", "entire", "cache", "by", "flushing", "it", ".", "Please", "note", "that", "a", "scope", "-", "in", "case", "one", "is", "set", "-", "is", "*", "not", "*", "honored", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/adapter/File.php#L216-L225
UnionOfRAD/lithium
storage/cache/adapter/File.php
File.clean
public function clean() { $result = true; foreach (new DirectoryIterator($this->_config['path']) as $file) { if (!$file->isFile()) { continue; } if (!$item = $this->_read($key = $file->getBasename())) { continue; } if ($item['expiry'] > time()) { continue; } $result = $this->_delete...
php
public function clean() { $result = true; foreach (new DirectoryIterator($this->_config['path']) as $file) { if (!$file->isFile()) { continue; } if (!$item = $this->_read($key = $file->getBasename())) { continue; } if ($item['expiry'] > time()) { continue; } $result = $this->_delete...
[ "public", "function", "clean", "(", ")", "{", "$", "result", "=", "true", ";", "foreach", "(", "new", "DirectoryIterator", "(", "$", "this", "->", "_config", "[", "'path'", "]", ")", "as", "$", "file", ")", "{", "if", "(", "!", "$", "file", "->", ...
Cleans entire cache running garbage collection on it. Please note that a scope - in case one is set - is *not* honored. The operation will continue to remove keys even if removing one single key fails, cleaning thoroughly as possible. @return boolean `true` on successful cleaning, `false` if failed partially or entir...
[ "Cleans", "entire", "cache", "running", "garbage", "collection", "on", "it", ".", "Please", "note", "that", "a", "scope", "-", "in", "case", "one", "is", "set", "-", "is", "*", "not", "*", "honored", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/adapter/File.php#L236-L251
UnionOfRAD/lithium
storage/cache/adapter/File.php
File._write
protected function _write($key, $value, $expires) { $path = "{$this->_config['path']}/{$key}"; if (!$stream = fopen($path, 'wb')) { return false; } fwrite($stream, "{:expiry:{$expires}}\n"); if (is_resource($value)) { stream_copy_to_stream($value, $stream); } else { fwrite($stream, $value); } ...
php
protected function _write($key, $value, $expires) { $path = "{$this->_config['path']}/{$key}"; if (!$stream = fopen($path, 'wb')) { return false; } fwrite($stream, "{:expiry:{$expires}}\n"); if (is_resource($value)) { stream_copy_to_stream($value, $stream); } else { fwrite($stream, $value); } ...
[ "protected", "function", "_write", "(", "$", "key", ",", "$", "value", ",", "$", "expires", ")", "{", "$", "path", "=", "\"{$this->_config['path']}/{$key}\"", ";", "if", "(", "!", "$", "stream", "=", "fopen", "(", "$", "path", ",", "'wb'", ")", ")", ...
Compiles value to format and writes file. @see lithium\storage\cache\adapter\File::write() @param string $key Key to uniquely identify the cached item. @param mixed $value Value or resource with value to store under given key. @param integer $expires UNIX timestamp after which the item is invalid. @return boolean `tru...
[ "Compiles", "value", "to", "format", "and", "writes", "file", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/adapter/File.php#L262-L276
UnionOfRAD/lithium
storage/cache/adapter/File.php
File._read
protected function _read($key, $streams = false) { $path = "{$this->_config['path']}/{$key}"; if (!is_file($path) || !is_readable($path)) { return false; } if (!$stream = fopen($path, 'rb')) { return false; } $header = stream_get_line($stream, static::MAX_HEADER_LENGTH, "\n"); if (!preg_match('/^\...
php
protected function _read($key, $streams = false) { $path = "{$this->_config['path']}/{$key}"; if (!is_file($path) || !is_readable($path)) { return false; } if (!$stream = fopen($path, 'rb')) { return false; } $header = stream_get_line($stream, static::MAX_HEADER_LENGTH, "\n"); if (!preg_match('/^\...
[ "protected", "function", "_read", "(", "$", "key", ",", "$", "streams", "=", "false", ")", "{", "$", "path", "=", "\"{$this->_config['path']}/{$key}\"", ";", "if", "(", "!", "is_file", "(", "$", "path", ")", "||", "!", "is_readable", "(", "$", "path", ...
Reads from file, parses its format and returns its expiry and value. @see lithium\storage\cache\adapter\File::read() @param string $key Key to uniquely identify the cached item. @param boolean $streams When `true` will return stream handle instead of value. @return array|boolean Array with `expiry` and `value` or `fal...
[ "Reads", "from", "file", "parses", "its", "format", "and", "returns", "its", "expiry", "and", "value", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/adapter/File.php#L286-L311
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.respondsTo
public function respondsTo($method, $internal = false) { $parentRespondsTo = parent::respondsTo($method, $internal); return $parentRespondsTo || is_callable([$this->connection, $method]); }
php
public function respondsTo($method, $internal = false) { $parentRespondsTo = parent::respondsTo($method, $internal); return $parentRespondsTo || is_callable([$this->connection, $method]); }
[ "public", "function", "respondsTo", "(", "$", "method", ",", "$", "internal", "=", "false", ")", "{", "$", "parentRespondsTo", "=", "parent", "::", "respondsTo", "(", "$", "method", ",", "$", "internal", ")", ";", "return", "$", "parentRespondsTo", "||", ...
Determines if a given method can be called. @param string $method Name of the method. @param boolean $internal Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`. @return boolean Returns `true` if the method can be called, `false` otherwise...
[ "Determines", "if", "a", "given", "method", "can", "be", "called", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L134-L137
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.describe
public function describe($entity, $schema = [], array $meta = []) { $database = $this->_config['database']; if (!$this->_db) { $result = $this->get($database); if (isset($result->db_name)) { $this->_db = true; } if (!$this->_db) { if (isset($result->error)) { if ($result->error === 'not_f...
php
public function describe($entity, $schema = [], array $meta = []) { $database = $this->_config['database']; if (!$this->_db) { $result = $this->get($database); if (isset($result->db_name)) { $this->_db = true; } if (!$this->_db) { if (isset($result->error)) { if ($result->error === 'not_f...
[ "public", "function", "describe", "(", "$", "entity", ",", "$", "schema", "=", "[", "]", ",", "array", "$", "meta", "=", "[", "]", ")", "{", "$", "database", "=", "$", "this", "->", "_config", "[", "'database'", "]", ";", "if", "(", "!", "$", "...
Describe database, create if it does not exist. @throws ConfigException @param string $entity @param array $schema Any schema data pre-defined by the model. @param array $meta @return lithium\data\Schema
[ "Describe", "database", "create", "if", "it", "does", "not", "exist", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L156-L180
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.create
public function create($query, array $options = []) { $defaults = ['model' => $query->model()]; $options += $defaults; $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $request = ['type' => 'json']; $query = $params['query']; $options = $para...
php
public function create($query, array $options = []) { $defaults = ['model' => $query->model()]; $options += $defaults; $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $request = ['type' => 'json']; $query = $params['query']; $options = $para...
[ "public", "function", "create", "(", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'model'", "=>", "$", "query", "->", "model", "(", ")", "]", ";", "$", "options", "+=", "$", "defaults", ";", "$"...
Create new document. @param string $query @param array $options @return boolean @filter
[ "Create", "new", "document", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L202-L233
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.read
public function read($query, array $options = []) { $defaults = ['return' => 'resource', 'model' => $query->model()]; $options += $defaults; $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $query = $params['query']; $params = $query->export($th...
php
public function read($query, array $options = []) { $defaults = ['return' => 'resource', 'model' => $query->model()]; $options += $defaults; $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $query = $params['query']; $params = $query->export($th...
[ "public", "function", "read", "(", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'return'", "=>", "'resource'", ",", "'model'", "=>", "$", "query", "->", "model", "(", ")", "]", ";", "$", "options"...
Read from document. @param string $query @param array $options @return object @filter
[ "Read", "from", "document", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L243-L281
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.update
public function update($query, array $options = []) { $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $query = $params['query']; $options = $params['options']; $params = $query->export($this); list($_path, $conditions) = (array) $params['con...
php
public function update($query, array $options = []) { $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $query = $params['query']; $options = $params['options']; $params = $query->export($this); list($_path, $conditions) = (array) $params['con...
[ "public", "function", "update", "(", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "compact", "(", "'query'", ",", "'options'", ")", ";", "return", "Filters", "::", "run", "(", "$", "this", ",", "__FUNCTION_...
Update document. @param string $query @param array $options @return boolean @filter
[ "Update", "document", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L291-L329
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb._autoBuild
protected function _autoBuild($result) { $hasError = ( isset($result['error']) && isset($result['reason']) && $result['reason'] === "no_db_file" ); if ($hasError) { $this->connection->put($this->_config['database']); return true; } return false; }
php
protected function _autoBuild($result) { $hasError = ( isset($result['error']) && isset($result['reason']) && $result['reason'] === "no_db_file" ); if ($hasError) { $this->connection->put($this->_config['database']); return true; } return false; }
[ "protected", "function", "_autoBuild", "(", "$", "result", ")", "{", "$", "hasError", "=", "(", "isset", "(", "$", "result", "[", "'error'", "]", ")", "&&", "isset", "(", "$", "result", "[", "'reason'", "]", ")", "&&", "$", "result", "[", "'reason'",...
Helper used for auto building a CouchDB database. @param string $result A query result.
[ "Helper", "used", "for", "auto", "building", "a", "CouchDB", "database", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L336-L347
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.delete
public function delete($query, array $options = []) { $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $query = $params['query']; $params = $query->export($this); list($_path, $conditions) = $params['conditions']; $data = $query->data(); i...
php
public function delete($query, array $options = []) { $params = compact('query', 'options'); return Filters::run($this, __FUNCTION__, $params, function($params) { $query = $params['query']; $params = $query->export($this); list($_path, $conditions) = $params['conditions']; $data = $query->data(); i...
[ "public", "function", "delete", "(", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "compact", "(", "'query'", ",", "'options'", ")", ";", "return", "Filters", "::", "run", "(", "$", "this", ",", "__FUNCTION_...
Delete document. @param string $query @param array $options @return boolean @filter
[ "Delete", "document", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L357-L381
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.calculation
public function calculation($type, $query, array $options = []) { switch ($type) { case 'count': return (integer) $this->read($query, $options)->stats('total_rows'); default: return null; } }
php
public function calculation($type, $query, array $options = []) { switch ($type) { case 'count': return (integer) $this->read($query, $options)->stats('total_rows'); default: return null; } }
[ "public", "function", "calculation", "(", "$", "type", ",", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'count'", ":", "return", "(", "integer", ")", "$", "this", "->", "read",...
Executes calculation-related queries, such as those required for `count`. @param string $type Only accepts `count`. @param mixed $query The query to be executed. @param array $options Optional arguments for the `read()` query that will be executed to obtain the calculation result. @return integer Result of the calcula...
[ "Executes", "calculation", "-", "related", "queries", "such", "as", "those", "required", "for", "count", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L392-L399
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.item
public function item($model, array $data = [], array $options = []) { $defaults = ['class' => 'entity']; $options += $defaults; if ($options['class'] === 'entity') { return $model::create($this->_format($data), $options); } foreach ($data as $key => $value) { if (isset($value['doc'])) { $value = $...
php
public function item($model, array $data = [], array $options = []) { $defaults = ['class' => 'entity']; $options += $defaults; if ($options['class'] === 'entity') { return $model::create($this->_format($data), $options); } foreach ($data as $key => $value) { if (isset($value['doc'])) { $value = $...
[ "public", "function", "item", "(", "$", "model", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'class'", "=>", "'entity'", "]", ";", "$", "options", "+=", "$", "defaul...
Returns a newly-created `Document` object, bound to a model and populated with default data and options. @param string $model A fully-namespaced class name representing the model class to which the `Document` object will be bound. @param array $data The default data with which the new `Document` should be populated. @...
[ "Returns", "a", "newly", "-", "created", "Document", "object", "bound", "to", "a", "model", "and", "populated", "with", "default", "data", "and", "options", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L412-L430
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb.conditions
public function conditions($conditions, $context) { $path = null; if (isset($conditions['design'])) { $paths = ['design', 'view']; foreach ($paths as $element) { if (isset($conditions[$element])) { $path .= "_{$element}/{$conditions[$element]}/"; unset($conditions[$element]); } } } if...
php
public function conditions($conditions, $context) { $path = null; if (isset($conditions['design'])) { $paths = ['design', 'view']; foreach ($paths as $element) { if (isset($conditions[$element])) { $path .= "_{$element}/{$conditions[$element]}/"; unset($conditions[$element]); } } } if...
[ "public", "function", "conditions", "(", "$", "conditions", ",", "$", "context", ")", "{", "$", "path", "=", "null", ";", "if", "(", "isset", "(", "$", "conditions", "[", "'design'", "]", ")", ")", "{", "$", "paths", "=", "[", "'design'", ",", "'vi...
Handle conditions. @param string $conditions @param string $context @return array
[ "Handle", "conditions", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L439-L459
UnionOfRAD/lithium
data/source/http/adapter/CouchDb.php
CouchDb._format
protected function _format(array $data) { foreach (['id', 'rev'] as $key) { if (isset($data["_{$key}"])) { $data[$key] = $data["_{$key}"]; unset($data["_{$key}"]); } } return $data; }
php
protected function _format(array $data) { foreach (['id', 'rev'] as $key) { if (isset($data["_{$key}"])) { $data[$key] = $data["_{$key}"]; unset($data["_{$key}"]); } } return $data; }
[ "protected", "function", "_format", "(", "array", "$", "data", ")", "{", "foreach", "(", "[", "'id'", ",", "'rev'", "]", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "\"_{$key}\"", "]", ")", ")", "{", "$", "data", "[", ...
Formats a CouchDb result set into a standard result to be passed to item. @param array $data data returned from query @return array
[ "Formats", "a", "CouchDb", "result", "set", "into", "a", "standard", "result", "to", "be", "passed", "to", "item", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/http/adapter/CouchDb.php#L524-L532
UnionOfRAD/lithium
g11n/Message.php
Message.translate
public static function translate($id, array $options = []) { $defaults = [ 'count' => 1, 'locale' => Environment::get('locale'), 'scope' => null, 'context' => null, 'default' => null, 'noop' => false ]; $options += $defaults; if ($options['noop']) { $result = null; } else { $result = ...
php
public static function translate($id, array $options = []) { $defaults = [ 'count' => 1, 'locale' => Environment::get('locale'), 'scope' => null, 'context' => null, 'default' => null, 'noop' => false ]; $options += $defaults; if ($options['noop']) { $result = null; } else { $result = ...
[ "public", "static", "function", "translate", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'count'", "=>", "1", ",", "'locale'", "=>", "Environment", "::", "get", "(", "'locale'", ")", ",", "'scope...
Translates a message according to the current or provided locale and into its correct plural form. Usage: ``` Message::translate('Mind the gap.'); Message::translate('house', ['count' => 23]); ``` `Text::insert()`-style placeholders may be used within the message and replacements provided directly within the `options...
[ "Translates", "a", "message", "according", "to", "the", "current", "or", "provided", "locale", "and", "into", "its", "correct", "plural", "form", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Message.php#L100-L123
UnionOfRAD/lithium
g11n/Message.php
Message.aliases
public static function aliases() { $t = function($message, array $options = []) { return Message::translate($message, $options + ['default' => $message]); }; $tn = function($message1, $message2, $count, array $options = []) { return Message::translate($message1, $options + compact('count') + [ 'default'...
php
public static function aliases() { $t = function($message, array $options = []) { return Message::translate($message, $options + ['default' => $message]); }; $tn = function($message1, $message2, $count, array $options = []) { return Message::translate($message1, $options + compact('count') + [ 'default'...
[ "public", "static", "function", "aliases", "(", ")", "{", "$", "t", "=", "function", "(", "$", "message", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "Message", "::", "translate", "(", "$", "message", ",", "$", "options", "+", ...
Returns an array containing named closures which are aliases for `translate()`. They can be embedded as content filters in the template layer using a filter for `Media::_handle()` or be used in other places where needed. Usage: ``` $t('bike'); $tn('bike', 'bikes', 3); ``` Using in a method: ``` public function index(...
[ "Returns", "an", "array", "containing", "named", "closures", "which", "are", "aliases", "for", "translate", "()", ".", "They", "can", "be", "embedded", "as", "content", "filters", "in", "the", "template", "layer", "using", "a", "filter", "for", "Media", "::"...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Message.php#L147-L157
UnionOfRAD/lithium
g11n/Message.php
Message.cache
public static function cache($cache = null) { if ($cache === false) { static::$_cachedPages = []; } if (is_array($cache)) { static::$_cachedPages += $cache; } return static::$_cachedPages; }
php
public static function cache($cache = null) { if ($cache === false) { static::$_cachedPages = []; } if (is_array($cache)) { static::$_cachedPages += $cache; } return static::$_cachedPages; }
[ "public", "static", "function", "cache", "(", "$", "cache", "=", "null", ")", "{", "if", "(", "$", "cache", "===", "false", ")", "{", "static", "::", "$", "_cachedPages", "=", "[", "]", ";", "}", "if", "(", "is_array", "(", "$", "cache", ")", ")"...
Returns or sets the page cache used for mapping message ids to translations. @param array $cache A multidimensional array to use when pre-populating the cache. The structure of the array is `scope/locale/id`. If `false`, the cache is cleared. @return array Returns an array of cached pages, formatted per the descriptio...
[ "Returns", "or", "sets", "the", "page", "cache", "used", "for", "mapping", "message", "ids", "to", "translations", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Message.php#L166-L174
UnionOfRAD/lithium
g11n/Message.php
Message._translated
protected static function _translated($id, $count, $locale, array $options = []) { $params = compact('id', 'count', 'locale', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { extract($params); if (isset($options['context']) && $options['context'] !== null) { ...
php
protected static function _translated($id, $count, $locale, array $options = []) { $params = compact('id', 'count', 'locale', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { extract($params); if (isset($options['context']) && $options['context'] !== null) { ...
[ "protected", "static", "function", "_translated", "(", "$", "id", ",", "$", "count", ",", "$", "locale", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "compact", "(", "'id'", ",", "'count'", ",", "'locale'", ",", "'option...
Retrieves translations through the `Catalog` class by using `$id` as the lookup key and taking the current or - if specified - the provided locale as well as the scope into account. Hereupon the correct plural form is determined by passing the value of the `'count'` option to a closure. @see lithium\g11n\Catalog @par...
[ "Retrieves", "translations", "through", "the", "Catalog", "class", "by", "using", "$id", "as", "the", "lookup", "key", "and", "taking", "the", "current", "or", "-", "if", "specified", "-", "the", "provided", "locale", "as", "well", "as", "the", "scope", "i...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Message.php#L193-L227
UnionOfRAD/lithium
net/http/Media.php
Media.type
public static function type($type, $content = null, array $options = []) { $defaults = [ 'view' => false, 'paths' => [ 'template' => '{:library}/views/{:controller}/{:template}.{:type}.php', 'layout' => '{:library}/views/layouts/{:layout}.{:type}.php', 'element' => '{:library}/views/elements/{:te...
php
public static function type($type, $content = null, array $options = []) { $defaults = [ 'view' => false, 'paths' => [ 'template' => '{:library}/views/{:controller}/{:template}.{:type}.php', 'layout' => '{:library}/views/layouts/{:layout}.{:type}.php', 'element' => '{:library}/views/elements/{:te...
[ "public", "static", "function", "type", "(", "$", "type", ",", "$", "content", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'view'", "=>", "false", ",", "'paths'", "=>", "[", "'template'", "=>", "'...
Maps a type name to a particular content-type (or multiple types) with a set of options, or retrieves information about a type that has been defined. Examples: ``` embed:lithium\tests\cases\net\http\MediaTest::testMediaTypes(1-2) ``` ``` embed:lithium\tests\cases\net\http\MediaTest::testMediaTypes(19-23) ``` ``` emb...
[ "Maps", "a", "type", "name", "to", "a", "particular", "content", "-", "type", "(", "or", "multiple", "types", ")", "with", "a", "set", "of", "options", "or", "retrieves", "information", "about", "a", "type", "that", "has", "been", "defined", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L244-L277
UnionOfRAD/lithium
net/http/Media.php
Media.negotiate
public static function negotiate($request) { $match = function($name) use ($request) { if (($cfg = static::type($name)) && static::match($request, compact('name') + $cfg)) { return true; } return false; }; if (($type = $request->type) && $match($type)) { return $type; } foreach ($request->ac...
php
public static function negotiate($request) { $match = function($name) use ($request) { if (($cfg = static::type($name)) && static::match($request, compact('name') + $cfg)) { return true; } return false; }; if (($type = $request->type) && $match($type)) { return $type; } foreach ($request->ac...
[ "public", "static", "function", "negotiate", "(", "$", "request", ")", "{", "$", "match", "=", "function", "(", "$", "name", ")", "use", "(", "$", "request", ")", "{", "if", "(", "(", "$", "cfg", "=", "static", "::", "type", "(", "$", "name", ")"...
Performs content-type negotiation on a `Request` object, by iterating over the accepted types in sequence, from most preferred to least, and attempting to match each one against a content type defined by `Media::type()`, until a match is found. If more than one defined type matches for a given content type, they will b...
[ "Performs", "content", "-", "type", "negotiation", "on", "a", "Request", "object", "by", "iterating", "over", "the", "accepted", "types", "in", "sequence", "from", "most", "preferred", "to", "least", "and", "attempting", "to", "match", "each", "one", "against"...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L295-L318
UnionOfRAD/lithium
net/http/Media.php
Media.match
public static function match($request, array $config) { if (!isset($config['options']['conditions'])) { return true; } $conditions = $config['options']['conditions']; foreach ($conditions as $key => $value) { switch (true) { case $key === 'type': if ($value !== ($request->type === $config['name'...
php
public static function match($request, array $config) { if (!isset($config['options']['conditions'])) { return true; } $conditions = $config['options']['conditions']; foreach ($conditions as $key => $value) { switch (true) { case $key === 'type': if ($value !== ($request->type === $config['name'...
[ "public", "static", "function", "match", "(", "$", "request", ",", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'options'", "]", "[", "'conditions'", "]", ")", ")", "{", "return", "true", ";", "}", "$", "cond...
Assists `Media::negotiate()` in processing the negotiation conditions of a content type, by iterating through the conditions and checking each one against the `Request` object. @see lithium\net\http\Media::negotiate() @see lithium\net\http\Media::type() @see lithium\action\Request @param \lithium\action\Request $reque...
[ "Assists", "Media", "::", "negotiate", "()", "in", "processing", "the", "negotiation", "conditions", "of", "a", "content", "type", "by", "iterating", "through", "the", "conditions", "and", "checking", "each", "one", "against", "the", "Request", "object", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L341-L365
UnionOfRAD/lithium
net/http/Media.php
Media.assets
public static function assets($type = null, $options = []) { $defaults = ['suffix' => null, 'filter' => null, 'paths' => []]; if (!$type) { return static::_assets(); } if ($options === false) { unset(static::$_assets[$type]); } if (!$options) { return static::_assets($type); } $options = (arra...
php
public static function assets($type = null, $options = []) { $defaults = ['suffix' => null, 'filter' => null, 'paths' => []]; if (!$type) { return static::_assets(); } if ($options === false) { unset(static::$_assets[$type]); } if (!$options) { return static::_assets($type); } $options = (arra...
[ "public", "static", "function", "assets", "(", "$", "type", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'suffix'", "=>", "null", ",", "'filter'", "=>", "null", ",", "'paths'", "=>", "[", "]", "]", ";", "...
Gets or sets options for various asset types. @see lithium\util\Text::insert() @param string $type The name of the asset type, i.e. `'js'` or `'css'`. @param array $options If registering a new asset type or modifying an existing asset type, contains settings for the asset type, where the available keys are as follows...
[ "Gets", "or", "sets", "options", "for", "various", "asset", "types", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L386-L404
UnionOfRAD/lithium
net/http/Media.php
Media.asset
public static function asset($path, $type, array $options = []) { $options = static::_assetOptions($path, $type, $options); $params = compact('path', 'type', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $path = $params['path']; $type = $params['type']; $...
php
public static function asset($path, $type, array $options = []) { $options = static::_assetOptions($path, $type, $options); $params = compact('path', 'type', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $path = $params['path']; $type = $params['type']; $...
[ "public", "static", "function", "asset", "(", "$", "path", ",", "$", "type", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "static", "::", "_assetOptions", "(", "$", "path", ",", "$", "type", ",", "$", "options", ")", ...
Calculates the web-accessible path to a static asset, usually a JavaScript, CSS or image file. @see lithium\net\http\Media::$_assets @see lithium\action\Request::env() @param string $path The path to the asset, relative to the given `$type`s path and without a suffix. If the path contains a URI Scheme (eg. `http://`),...
[ "Calculates", "the", "web", "-", "accessible", "path", "to", "a", "static", "asset", "usually", "a", "JavaScript", "CSS", "or", "image", "file", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L437-L460
UnionOfRAD/lithium
net/http/Media.php
Media._assetOptions
protected static function _assetOptions($path, $type, $options) { $defaults = [ 'base' => null, 'timestamp' => false, 'filter' => null, 'paths' => [], 'suffix' => null, 'check' => false, 'library' => true ]; $base = isset($options['base']) ? rtrim($options['base'], '/') : ''; $options += [...
php
protected static function _assetOptions($path, $type, $options) { $defaults = [ 'base' => null, 'timestamp' => false, 'filter' => null, 'paths' => [], 'suffix' => null, 'check' => false, 'library' => true ]; $base = isset($options['base']) ? rtrim($options['base'], '/') : ''; $options += [...
[ "protected", "static", "function", "_assetOptions", "(", "$", "path", ",", "$", "type", ",", "$", "options", ")", "{", "$", "defaults", "=", "[", "'base'", "=>", "null", ",", "'timestamp'", "=>", "false", ",", "'filter'", "=>", "null", ",", "'paths'", ...
Initialize options for `Media::asset()`. @param string $path The path to the asset. @param string $type The asset type. @param array $options Contains setting for finding and handling the path. @return array The initialized options.
[ "Initialize", "options", "for", "Media", "::", "asset", "()", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L470-L522
UnionOfRAD/lithium
net/http/Media.php
Media.filterAssetPath
public static function filterAssetPath($asset, $path, array $config, array $options = []) { $config += ['assets' => null]; if ($options['check'] || $options['timestamp']) { $file = static::path($asset, $options['type'], $options); } if ($options['check'] && !is_file($file)) { return false; } $isAbsol...
php
public static function filterAssetPath($asset, $path, array $config, array $options = []) { $config += ['assets' => null]; if ($options['check'] || $options['timestamp']) { $file = static::path($asset, $options['type'], $options); } if ($options['check'] && !is_file($file)) { return false; } $isAbsol...
[ "public", "static", "function", "filterAssetPath", "(", "$", "asset", ",", "$", "path", ",", "array", "$", "config", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "config", "+=", "[", "'assets'", "=>", "null", "]", ";", "if", "(", "$"...
Performs checks and applies transformations to asset paths, including verifying that the virtual path exists on the filesystem, appending a timestamp, prepending an asset host, or applying a user-defined filter. @see lithium\net\http\Media::asset() @param string $asset A full asset path, relative to the public web pat...
[ "Performs", "checks", "and", "applies", "transformations", "to", "asset", "paths", "including", "verifying", "that", "the", "virtual", "path", "exists", "on", "the", "filesystem", "appending", "a", "timestamp", "prepending", "an", "asset", "host", "or", "applying"...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L538-L576
UnionOfRAD/lithium
net/http/Media.php
Media.webroot
public static function webroot($library = true, $scope = null) { if ($scope) { if ($config = static::attached($scope)) { return $config['path']; } return null; } if (!$config = Libraries::get($library)) { return null; } if (isset($config['webroot'])) { return $config['webroot']; } if (i...
php
public static function webroot($library = true, $scope = null) { if ($scope) { if ($config = static::attached($scope)) { return $config['path']; } return null; } if (!$config = Libraries::get($library)) { return null; } if (isset($config['webroot'])) { return $config['webroot']; } if (i...
[ "public", "static", "function", "webroot", "(", "$", "library", "=", "true", ",", "$", "scope", "=", "null", ")", "{", "if", "(", "$", "scope", ")", "{", "if", "(", "$", "config", "=", "static", "::", "attached", "(", "$", "scope", ")", ")", "{",...
Gets the physical path to the web assets (i.e. `/webroot`) directory of a library. @param string|boolean $library The name of the library for which to find the path, or `true` for the default library. @param string|boolean $scope The name of the to use to find the path. @return string Returns the physical path to the ...
[ "Gets", "the", "physical", "path", "to", "the", "web", "assets", "(", "i", ".", "e", ".", "/", "webroot", ")", "directory", "of", "a", "library", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L586-L602
UnionOfRAD/lithium
net/http/Media.php
Media.path
public static function path($path, $type, array $options = []) { $defaults = [ 'base' => null, 'paths' => [], 'suffix' => null, 'library' => true, 'scope' => false ]; if (!$base = static::_assets($type)) { $base = static::_assets('generic'); } $options += ($base + $defaults); $paths = $opt...
php
public static function path($path, $type, array $options = []) { $defaults = [ 'base' => null, 'paths' => [], 'suffix' => null, 'library' => true, 'scope' => false ]; if (!$base = static::_assets($type)) { $base = static::_assets('generic'); } $options += ($base + $defaults); $paths = $opt...
[ "public", "static", "function", "path", "(", "$", "path", ",", "$", "type", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'base'", "=>", "null", ",", "'paths'", "=>", "[", "]", ",", "'suffix'", "=>", "null", "...
Returns the physical path to an asset in the `/webroot` directory of an application or plugin. @param string $paths The path to a web asset, relative to the root path for its type. For example, for a JavaScript file in `/webroot/js/subpath/file.js`, the correct value for `$path` would be `'subpath/file.js'`. @param st...
[ "Returns", "the", "physical", "path", "to", "an", "asset", "in", "the", "/", "webroot", "directory", "of", "an", "application", "or", "plugin", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L616-L649
UnionOfRAD/lithium
net/http/Media.php
Media.render
public static function render($response, $data = null, array $options = []) { $params = compact('response', 'data', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $types = static::_types(); $handlers = static::handlers(); $defaults = ['encode' => null, 'tem...
php
public static function render($response, $data = null, array $options = []) { $params = compact('response', 'data', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $types = static::_types(); $handlers = static::handlers(); $defaults = ['encode' => null, 'tem...
[ "public", "static", "function", "render", "(", "$", "response", ",", "$", "data", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "compact", "(", "'response'", ",", "'data'", ",", "'options'", ")", ";", "return...
Renders data (usually the result of a controller action) and generates a string representation of it, based on the type of expected output. @param object $response A Response object into which the operation will be rendered. The content of the render operation will be assigned to the `$body` property of the object, th...
[ "Renders", "data", "(", "usually", "the", "result", "of", "a", "controller", "action", ")", "and", "generates", "a", "string", "representation", "of", "it", "based", "on", "the", "type", "of", "expected", "output", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L666-L699
UnionOfRAD/lithium
net/http/Media.php
Media.view
public static function view($handler, $data, &$response = null, array $options = []) { $params = ['response' => &$response] + compact('handler', 'data', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $handler = $params['handler']; $response =& $params['response...
php
public static function view($handler, $data, &$response = null, array $options = []) { $params = ['response' => &$response] + compact('handler', 'data', 'options'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $handler = $params['handler']; $response =& $params['response...
[ "public", "static", "function", "view", "(", "$", "handler", ",", "$", "data", ",", "&", "$", "response", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "[", "'response'", "=>", "&", "$", "response", "]", ...
Configures a template object instance, based on a media handler configuration. @see lithium\net\http\Media::type() @see lithium\template\View::render() @see lithium\action\Response @param mixed $handler Either a string specifying the name of a media type for which a handler is defined, or an array representing a handl...
[ "Configures", "a", "template", "object", "instance", "based", "on", "a", "media", "handler", "configuration", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L718-L732
UnionOfRAD/lithium
net/http/Media.php
Media.encode
public static function encode($handler, $data, &$response = null) { $params = ['response' => &$response] + compact('handler', 'data'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $data = $params['data']; $handler = $params['handler']; $response =& $params['response']...
php
public static function encode($handler, $data, &$response = null) { $params = ['response' => &$response] + compact('handler', 'data'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $data = $params['data']; $handler = $params['handler']; $response =& $params['response']...
[ "public", "static", "function", "encode", "(", "$", "handler", ",", "$", "data", ",", "&", "$", "response", "=", "null", ")", "{", "$", "params", "=", "[", "'response'", "=>", "&", "$", "response", "]", "+", "compact", "(", "'handler'", ",", "'data'"...
For media types registered in `$_handlers` which include an `'encode'` setting, encodes data according to the specified media type. @see lithium\net\http\Media::type() @param mixed $handler Specifies the media type into which `$data` will be encoded. This media type must have an `'encode'` setting specified in `Media:...
[ "For", "media", "types", "registered", "in", "$_handlers", "which", "include", "an", "encode", "setting", "encodes", "data", "according", "to", "the", "specified", "media", "type", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L751-L778
UnionOfRAD/lithium
net/http/Media.php
Media.decode
public static function decode($type, $data, array $options = []) { if ((!$handler = static::handlers($type)) || empty($handler['decode'])) { return null; } $method = $handler['decode']; return is_string($method) ? $method($data) : $method($data, $handler + $options); }
php
public static function decode($type, $data, array $options = []) { if ((!$handler = static::handlers($type)) || empty($handler['decode'])) { return null; } $method = $handler['decode']; return is_string($method) ? $method($data) : $method($data, $handler + $options); }
[ "public", "static", "function", "decode", "(", "$", "type", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "(", "!", "$", "handler", "=", "static", "::", "handlers", "(", "$", "type", ")", ")", "||", "empty", ...
For media types registered in `$_handlers` which include an `'decode'` setting, decodes data according to the specified media type. @param string $type Specifies the media type into which `$data` will be encoded. This media type must have an `'encode'` setting specified in `Media::$_handlers`. @param mixed $data Arbit...
[ "For", "media", "types", "registered", "in", "$_handlers", "which", "include", "an", "decode", "setting", "decodes", "data", "according", "to", "the", "specified", "media", "type", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L791-L797
UnionOfRAD/lithium
net/http/Media.php
Media._handle
protected static function _handle($handler, $data, &$response) { $params = ['response' => &$response] + compact('handler', 'data'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $response = $params['response']; $handler = $params['handler']; $data = $params['data']; ...
php
protected static function _handle($handler, $data, &$response) { $params = ['response' => &$response] + compact('handler', 'data'); return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) { $response = $params['response']; $handler = $params['handler']; $data = $params['data']; ...
[ "protected", "static", "function", "_handle", "(", "$", "handler", ",", "$", "data", ",", "&", "$", "response", ")", "{", "$", "params", "=", "[", "'response'", "=>", "&", "$", "response", "]", "+", "compact", "(", "'handler'", ",", "'data'", ")", ";...
Called by `Media::render()` to render response content. Given a content handler and data, calls the content handler and passes in the data, receiving back a rendered content string. @see lithium\action\Response @param array $handler @param array $data @param object $response A reference to the `Response` object for th...
[ "Called", "by", "Media", "::", "render", "()", "to", "render", "response", "content", ".", "Given", "a", "content", "handler", "and", "data", "calls", "the", "content", "handler", "and", "passes", "in", "the", "data", "receiving", "back", "a", "rendered", ...
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L823-L850
UnionOfRAD/lithium
net/http/Media.php
Media._types
protected static function _types($type = null) { $types = static::$_types + [ 'html' => ['text/html', 'application/xhtml+xml', '*/*'], 'htm' => ['alias' => 'html'], 'form' => ['application/x-www-form-urlencoded', 'multipart/form-data'], 'json' => ['application/json'], '...
php
protected static function _types($type = null) { $types = static::$_types + [ 'html' => ['text/html', 'application/xhtml+xml', '*/*'], 'htm' => ['alias' => 'html'], 'form' => ['application/x-www-form-urlencoded', 'multipart/form-data'], 'json' => ['application/json'], '...
[ "protected", "static", "function", "_types", "(", "$", "type", "=", "null", ")", "{", "$", "types", "=", "static", "::", "$", "_types", "+", "[", "'html'", "=>", "[", "'text/html'", ",", "'application/xhtml+xml'", ",", "'*/*'", "]", ",", "'htm'", "=>", ...
Helper method for listing registered media types. Returns all types, or a single content type if a specific type is specified. @todo Use fnmatch() to support wildcards. @param string $type Type to return. @return mixed Array of types, or single type requested.
[ "Helper", "method", "for", "listing", "registered", "media", "types", ".", "Returns", "all", "types", "or", "a", "single", "content", "type", "if", "a", "specific", "type", "is", "specified", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L860-L895
UnionOfRAD/lithium
net/http/Media.php
Media.handlers
public static function handlers($type = null) { $handlers = static::$_handlers + [ 'default' => [ 'view' => 'lithium\template\View', 'encode' => false, 'decode' => false, 'cast' => false, 'paths' => [ 'template' => '{:library}/views/{:controller}/{:template}.{:type}.php', ...
php
public static function handlers($type = null) { $handlers = static::$_handlers + [ 'default' => [ 'view' => 'lithium\template\View', 'encode' => false, 'decode' => false, 'cast' => false, 'paths' => [ 'template' => '{:library}/views/{:controller}/{:template}.{:type}.php', ...
[ "public", "static", "function", "handlers", "(", "$", "type", "=", "null", ")", "{", "$", "handlers", "=", "static", "::", "$", "_handlers", "+", "[", "'default'", "=>", "[", "'view'", "=>", "'lithium\\template\\View'", ",", "'encode'", "=>", "false", ",",...
Helper method for listing registered type handlers. Returns all handlers, or the handler for a specific media type, if requested. @param string $type The type of handler to return. @return mixed Array of all handlers, or the handler for a specific type.
[ "Helper", "method", "for", "listing", "registered", "type", "handlers", ".", "Returns", "all", "handlers", "or", "the", "handler", "for", "a", "specific", "media", "type", "if", "requested", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L904-L941
UnionOfRAD/lithium
net/http/Media.php
Media._assets
protected static function _assets($type = null) { $assets = static::$_assets + [ 'js' => ['suffix' => '.js', 'filter' => null, 'paths' => [ '{:base}/{:library}/js/{:path}' => ['base', 'library', 'path'], '{:base}/js/{:path}' => ['base', 'path'] ]], 'css' => ['suffix' => '.css', 'filter' => null, 'pat...
php
protected static function _assets($type = null) { $assets = static::$_assets + [ 'js' => ['suffix' => '.js', 'filter' => null, 'paths' => [ '{:base}/{:library}/js/{:path}' => ['base', 'library', 'path'], '{:base}/js/{:path}' => ['base', 'path'] ]], 'css' => ['suffix' => '.css', 'filter' => null, 'pat...
[ "protected", "static", "function", "_assets", "(", "$", "type", "=", "null", ")", "{", "$", "assets", "=", "static", "::", "$", "_assets", "+", "[", "'js'", "=>", "[", "'suffix'", "=>", "'.js'", ",", "'filter'", "=>", "null", ",", "'paths'", "=>", "[...
Helper method to list all asset paths, or the path for a single type. @param string $type The type you wish to get paths for. @return mixed An array of all paths, or a single array of paths for the given type.
[ "Helper", "method", "to", "list", "all", "asset", "paths", "or", "the", "path", "for", "a", "single", "type", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L950-L973
UnionOfRAD/lithium
net/http/Media.php
Media.scope
public static function scope($name = null, Closure $closure = null) { if ($name === null) { return static::$_scope; } if ($closure === null) { $former = static::$_scope; static::$_scope = $name; return $former; } $former = static::$_scope; static::$_scope = $name; call_user_func($closure); ...
php
public static function scope($name = null, Closure $closure = null) { if ($name === null) { return static::$_scope; } if ($closure === null) { $former = static::$_scope; static::$_scope = $name; return $former; } $former = static::$_scope; static::$_scope = $name; call_user_func($closure); ...
[ "public", "static", "function", "scope", "(", "$", "name", "=", "null", ",", "Closure", "$", "closure", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "return", "static", "::", "$", "_scope", ";", "}", "if", "(", "$", "cl...
Scope getter/setter. Special use case: If `$closure` is not null executing the closure inside the specified scope. @param string $name Name of the scope to use. @param \Closure $closure A closure to execute inside the scope. @return mixed Returns the previous scope if if `$name` is not null and `$closure` is null, re...
[ "Scope", "getter", "/", "setter", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L986-L1001
UnionOfRAD/lithium
net/http/Media.php
Media.attach
public static function attach($name, $config = null) { if (!isset(static::$_scopes)) { static::_initScopes(); } if ($name === false) { $name = '__defaultScope__'; } if (is_array($config) || $config === false) { static::$_scopes->set($name, $config); } }
php
public static function attach($name, $config = null) { if (!isset(static::$_scopes)) { static::_initScopes(); } if ($name === false) { $name = '__defaultScope__'; } if (is_array($config) || $config === false) { static::$_scopes->set($name, $config); } }
[ "public", "static", "function", "attach", "(", "$", "name", ",", "$", "config", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "_scopes", ")", ")", "{", "static", "::", "_initScopes", "(", ")", ";", "}", "if", "(", "$",...
Attach a scope to a mount point. Example: ``` Media::attach('app', [ 'path' => '/var/www/website/app/webroot/extradir', 'prefix' => 'extradir' ]); ``` ``` Media::attach('cdn', [ 'absolute' => true, 'path' => null, 'host' => 'http://my.cdn.com', 'prefix' => 'project1/assets' ]); ``` ``` Media::attach('cdn', [ 'absolu...
[ "Attach", "a", "scope", "to", "a", "mount", "point", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L1055-L1065
UnionOfRAD/lithium
net/http/Media.php
Media.attached
public static function attached($name = null) { if (!isset(static::$_scopes)) { static::_initScopes(); } if ($name === false) { $name = '__defaultScope__'; } return static::$_scopes->get($name); }
php
public static function attached($name = null) { if (!isset(static::$_scopes)) { static::_initScopes(); } if ($name === false) { $name = '__defaultScope__'; } return static::$_scopes->get($name); }
[ "public", "static", "function", "attached", "(", "$", "name", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "_scopes", ")", ")", "{", "static", "::", "_initScopes", "(", ")", ";", "}", "if", "(", "$", "name", "===", "f...
Returns an attached mount point configuration.
[ "Returns", "an", "attached", "mount", "point", "configuration", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/http/Media.php#L1070-L1078
UnionOfRAD/lithium
storage/session/adapter/Php.php
Php._init
protected function _init() { if ($this->isStarted()) { return true; } $config = $this->_config; unset($config['adapter'], $config['strategies'], $config['filters'], $config['init']); foreach ($config as $key => $value) { if (strpos($key, 'session.') === false) { continue; } if (ini_set($key, ...
php
protected function _init() { if ($this->isStarted()) { return true; } $config = $this->_config; unset($config['adapter'], $config['strategies'], $config['filters'], $config['init']); foreach ($config as $key => $value) { if (strpos($key, 'session.') === false) { continue; } if (ini_set($key, ...
[ "protected", "function", "_init", "(", ")", "{", "if", "(", "$", "this", "->", "isStarted", "(", ")", ")", "{", "return", "true", ";", "}", "$", "config", "=", "$", "this", "->", "_config", ";", "unset", "(", "$", "config", "[", "'adapter'", "]", ...
Initialization of the session. @todo Split up into an _initialize() and a _start().
[ "Initialization", "of", "the", "session", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Php.php#L68-L83
UnionOfRAD/lithium
storage/session/adapter/Php.php
Php.check
public function check($key, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { return Set::check($_SESSION, $params['key']); }; }
php
public function check($key, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { return Set::check($_SESSION, $params['key']); }; }
[ "public", "function", "check", "(", "$", "key", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "isStarted", "(", ")", "&&", "!", "$", "this", "->", "_start", "(", ")", ")", "{", "throw", "new", "Runtim...
Checks if a value has been set in the session. @param string $key Key of the entry to be checked. @param array $options Options array. Not used for this adapter method. @return \Closure Function returning boolean `true` if the key exists, `false` otherwise.
[ "Checks", "if", "a", "value", "has", "been", "set", "in", "the", "session", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Php.php#L133-L140
UnionOfRAD/lithium
storage/session/adapter/Php.php
Php.read
public function read($key = null, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { $key = $params['key']; if (!$key) { return $_SESSION; } if (strpos($key, '.') === false) { return iss...
php
public function read($key = null, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { $key = $params['key']; if (!$key) { return $_SESSION; } if (strpos($key, '.') === false) { return iss...
[ "public", "function", "read", "(", "$", "key", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "isStarted", "(", ")", "&&", "!", "$", "this", "->", "_start", "(", ")", ")", "{", "throw", ...
Read a value from the session. @param null|string $key Key of the entry to be read. If no key is passed, all current session data is returned. @param array $options Options array. Not used for this adapter method. @return \Closure Function returning data in the session if successful, `false` otherwise.
[ "Read", "a", "value", "from", "the", "session", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Php.php#L150-L171
UnionOfRAD/lithium
storage/session/adapter/Php.php
Php.write
public function write($key, $value, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { return $this->overwrite( $_SESSION, Set::insert($_SESSION, $params['key'], $params['value']) ); }; }
php
public function write($key, $value, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { return $this->overwrite( $_SESSION, Set::insert($_SESSION, $params['key'], $params['value']) ); }; }
[ "public", "function", "write", "(", "$", "key", ",", "$", "value", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "isStarted", "(", ")", "&&", "!", "$", "this", "->", "_start", "(", ")", ")", "{", "t...
Write a value to the session. @param string $key Key of the item to be stored. @param mixed $value The value to be stored. @param array $options Options array. Not used for this adapter method. @return \Closure Function returning boolean `true` on successful write, `false` otherwise.
[ "Write", "a", "value", "to", "the", "session", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Php.php#L181-L190
UnionOfRAD/lithium
storage/session/adapter/Php.php
Php.delete
public function delete($key, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { $key = $params['key']; $this->overwrite($_SESSION, Set::remove($_SESSION, $key)); return !Set::check($_SESSION, $key);...
php
public function delete($key, array $options = []) { if (!$this->isStarted() && !$this->_start()) { throw new RuntimeException('Could not start session.'); } return function($params) { $key = $params['key']; $this->overwrite($_SESSION, Set::remove($_SESSION, $key)); return !Set::check($_SESSION, $key);...
[ "public", "function", "delete", "(", "$", "key", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "isStarted", "(", ")", "&&", "!", "$", "this", "->", "_start", "(", ")", ")", "{", "throw", "new", "Runti...
Delete value from the session @param string $key The key to be deleted. @param array $options Options array. Not used for this adapter method. @return \Closure Function returning boolean `true` if the key no longer exists in the session, `false` otherwise
[ "Delete", "value", "from", "the", "session" ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Php.php#L200-L209
UnionOfRAD/lithium
storage/session/adapter/Php.php
Php.overwrite
public function overwrite(&$old, $new) { if (!empty($old)) { foreach ($old as $key => $value) { if (!isset($new[$key])) { unset($old[$key]); } } } foreach ($new as $key => $value) { $old[$key] = $value; } return true; }
php
public function overwrite(&$old, $new) { if (!empty($old)) { foreach ($old as $key => $value) { if (!isset($new[$key])) { unset($old[$key]); } } } foreach ($new as $key => $value) { $old[$key] = $value; } return true; }
[ "public", "function", "overwrite", "(", "&", "$", "old", ",", "$", "new", ")", "{", "if", "(", "!", "empty", "(", "$", "old", ")", ")", "{", "foreach", "(", "$", "old", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", ...
Overwrites session keys and values. @param array $old Reference to the array that needs to be overwritten. Will usually be `$_SESSION`. @param array $new The data that should overwrite the keys/values in `$old`. @return boolean Always `true`.
[ "Overwrites", "session", "keys", "and", "values", "." ]
train
https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Php.php#L247-L259