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
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
titon/db
src/Titon/Db/Query.php
Query.attribute
public function attribute($key, $value = null) { if (is_array($key)) { $this->_attributes = array_replace($this->_attributes, $key); } else { $this->_attributes[$key] = $value; } return $this; }
php
public function attribute($key, $value = null) { if (is_array($key)) { $this->_attributes = array_replace($this->_attributes, $key); } else { $this->_attributes[$key] = $value; } return $this; }
[ "public", "function", "attribute", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "this", "->", "_attributes", "=", "array_replace", "(", "$", "this", "->", "_attributes", ",", "$", "key", ")", ";", "}", "else", "{", "$", "this", "->", "_attributes", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set an attribute. @param string $key @param mixed $value @return $this
[ "Set", "an", "attribute", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L224-L232
titon/db
src/Titon/Db/Query.php
Query.bindCallback
public function bindCallback($callback, $argument = null) { if ($callback instanceof Closure) { call_user_func_array($callback, [$this, $argument]); } return $this; }
php
public function bindCallback($callback, $argument = null) { if ($callback instanceof Closure) { call_user_func_array($callback, [$this, $argument]); } return $this; }
[ "public", "function", "bindCallback", "(", "$", "callback", ",", "$", "argument", "=", "null", ")", "{", "if", "(", "$", "callback", "instanceof", "Closure", ")", "{", "call_user_func_array", "(", "$", "callback", ",", "[", "$", "this", ",", "$", "argument", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Bind a Closure callback to this query and execute it. @param \Closure $callback @param mixed $argument @return $this
[ "Bind", "a", "Closure", "callback", "to", "this", "query", "and", "execute", "it", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L251-L257
titon/db
src/Titon/Db/Query.php
Query.cache
public function cache($key, $expires = null) { if ($this->getType() !== self::SELECT) { return $this; } $this->_cacheKey = $key; $this->_cacheLength = $expires; return $this; }
php
public function cache($key, $expires = null) { if ($this->getType() !== self::SELECT) { return $this; } $this->_cacheKey = $key; $this->_cacheLength = $expires; return $this; }
[ "public", "function", "cache", "(", "$", "key", ",", "$", "expires", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getType", "(", ")", "!==", "self", "::", "SELECT", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "_cacheKey", "=", "$", "key", ";", "$", "this", "->", "_cacheLength", "=", "$", "expires", ";", "return", "$", "this", ";", "}" ]
Set the cache key and duration length. @param mixed $key @param mixed $expires @return $this
[ "Set", "the", "cache", "key", "and", "duration", "length", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L266-L275
titon/db
src/Titon/Db/Query.php
Query.count
public function count() { $repo = $this->getRepository(); return $repo->aggregate($this->limit(0), __FUNCTION__, $repo->getPrimaryKey()); }
php
public function count() { $repo = $this->getRepository(); return $repo->aggregate($this->limit(0), __FUNCTION__, $repo->getPrimaryKey()); }
[ "public", "function", "count", "(", ")", "{", "$", "repo", "=", "$", "this", "->", "getRepository", "(", ")", ";", "return", "$", "repo", "->", "aggregate", "(", "$", "this", "->", "limit", "(", "0", ")", ",", "__FUNCTION__", ",", "$", "repo", "->", "getPrimaryKey", "(", ")", ")", ";", "}" ]
Pass the query to the repository to interact with the database. Return the count of how many records exist. @return int
[ "Pass", "the", "query", "to", "the", "repository", "to", "interact", "with", "the", "database", ".", "Return", "the", "count", "of", "how", "many", "records", "exist", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L283-L287
titon/db
src/Titon/Db/Query.php
Query.data
public function data($data) { if ($data instanceof Arrayable) { $data = $data->toArray(); } else if (!is_array($data)) { throw new InvalidArgumentException('Data passed must be an array or extend the Titon\Type\Contract\Arrayable interface'); } $type = $this->getType(); // Only set binds for queries with dynamic data if (in_array($type, [self::INSERT, self::UPDATE, self::MULTI_INSERT], true)) { $binds = []; $rows = $data; if ($type !== self::MULTI_INSERT) { $rows = [$rows]; } foreach ($rows as $row) { foreach ($row as $field => $value) { $binds[] = [ 'field' => $field, 'value' => $value ]; } } $this->setBindings($binds); } $this->_data = $data; return $this; }
php
public function data($data) { if ($data instanceof Arrayable) { $data = $data->toArray(); } else if (!is_array($data)) { throw new InvalidArgumentException('Data passed must be an array or extend the Titon\Type\Contract\Arrayable interface'); } $type = $this->getType(); // Only set binds for queries with dynamic data if (in_array($type, [self::INSERT, self::UPDATE, self::MULTI_INSERT], true)) { $binds = []; $rows = $data; if ($type !== self::MULTI_INSERT) { $rows = [$rows]; } foreach ($rows as $row) { foreach ($row as $field => $value) { $binds[] = [ 'field' => $field, 'value' => $value ]; } } $this->setBindings($binds); } $this->_data = $data; return $this; }
[ "public", "function", "data", "(", "$", "data", ")", "{", "if", "(", "$", "data", "instanceof", "Arrayable", ")", "{", "$", "data", "=", "$", "data", "->", "toArray", "(", ")", ";", "}", "else", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Data passed must be an array or extend the Titon\\Type\\Contract\\Arrayable interface'", ")", ";", "}", "$", "type", "=", "$", "this", "->", "getType", "(", ")", ";", "// Only set binds for queries with dynamic data", "if", "(", "in_array", "(", "$", "type", ",", "[", "self", "::", "INSERT", ",", "self", "::", "UPDATE", ",", "self", "::", "MULTI_INSERT", "]", ",", "true", ")", ")", "{", "$", "binds", "=", "[", "]", ";", "$", "rows", "=", "$", "data", ";", "if", "(", "$", "type", "!==", "self", "::", "MULTI_INSERT", ")", "{", "$", "rows", "=", "[", "$", "rows", "]", ";", "}", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "foreach", "(", "$", "row", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "binds", "[", "]", "=", "[", "'field'", "=>", "$", "field", ",", "'value'", "=>", "$", "value", "]", ";", "}", "}", "$", "this", "->", "setBindings", "(", "$", "binds", ")", ";", "}", "$", "this", "->", "_data", "=", "$", "data", ";", "return", "$", "this", ";", "}" ]
Set the data to use in an update, insert, or create index statement. We should also extract data to later bind during a prepared statement. @param array|\Titon\Type\Contract\Arrayable $data @return $this @throws \Titon\Db\Exception\InvalidArgumentException
[ "Set", "the", "data", "to", "use", "in", "an", "update", "insert", "or", "create", "index", "statement", ".", "We", "should", "also", "extract", "data", "to", "later", "bind", "during", "a", "prepared", "statement", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L297-L331
titon/db
src/Titon/Db/Query.php
Query.except
public function except(Query $query, $flag = null) { if ($flag === Dialect::ALL) { $query->attribute('flag', $flag); } return $this->_addCompound(Dialect::EXCEPT, $query); }
php
public function except(Query $query, $flag = null) { if ($flag === Dialect::ALL) { $query->attribute('flag', $flag); } return $this->_addCompound(Dialect::EXCEPT, $query); }
[ "public", "function", "except", "(", "Query", "$", "query", ",", "$", "flag", "=", "null", ")", "{", "if", "(", "$", "flag", "===", "Dialect", "::", "ALL", ")", "{", "$", "query", "->", "attribute", "(", "'flag'", ",", "$", "flag", ")", ";", "}", "return", "$", "this", "->", "_addCompound", "(", "Dialect", "::", "EXCEPT", ",", "$", "query", ")", ";", "}" ]
Add a select query as an except. @param \Titon\Db\Query $query @param string $flag @return $this
[ "Add", "a", "select", "query", "as", "an", "except", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L349-L355
titon/db
src/Titon/Db/Query.php
Query.fields
public function fields($fields, $merge = false) { if (!is_array($fields)) { $fields = func_get_args(); $merge = false; } if ($merge) { $fields = array_merge($this->_fields, $fields); } // When doing a select, unique the field list if ($this->getType() === self::SELECT) { $fields = array_values(array_unique($fields, SORT_REGULAR)); // SORT_REGULAR allows for objects } $this->_fields = $fields; return $this; }
php
public function fields($fields, $merge = false) { if (!is_array($fields)) { $fields = func_get_args(); $merge = false; } if ($merge) { $fields = array_merge($this->_fields, $fields); } // When doing a select, unique the field list if ($this->getType() === self::SELECT) { $fields = array_values(array_unique($fields, SORT_REGULAR)); // SORT_REGULAR allows for objects } $this->_fields = $fields; return $this; }
[ "public", "function", "fields", "(", "$", "fields", ",", "$", "merge", "=", "false", ")", "{", "if", "(", "!", "is_array", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "func_get_args", "(", ")", ";", "$", "merge", "=", "false", ";", "}", "if", "(", "$", "merge", ")", "{", "$", "fields", "=", "array_merge", "(", "$", "this", "->", "_fields", ",", "$", "fields", ")", ";", "}", "// When doing a select, unique the field list", "if", "(", "$", "this", "->", "getType", "(", ")", "===", "self", "::", "SELECT", ")", "{", "$", "fields", "=", "array_values", "(", "array_unique", "(", "$", "fields", ",", "SORT_REGULAR", ")", ")", ";", "// SORT_REGULAR allows for objects", "}", "$", "this", "->", "_fields", "=", "$", "fields", ";", "return", "$", "this", ";", "}" ]
Set the list of fields to return. @param string|array $fields @param bool $merge @return $this
[ "Set", "the", "list", "of", "fields", "to", "return", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L364-L382
titon/db
src/Titon/Db/Query.php
Query.getAlias
public function getAlias() { if ($this->getJoins() || $this instanceof SubQuery || in_array($this->getType(), [self::CREATE_INDEX, self::DROP_INDEX])) { return $this->_alias; } return null; }
php
public function getAlias() { if ($this->getJoins() || $this instanceof SubQuery || in_array($this->getType(), [self::CREATE_INDEX, self::DROP_INDEX])) { return $this->_alias; } return null; }
[ "public", "function", "getAlias", "(", ")", "{", "if", "(", "$", "this", "->", "getJoins", "(", ")", "||", "$", "this", "instanceof", "SubQuery", "||", "in_array", "(", "$", "this", "->", "getType", "(", ")", ",", "[", "self", "::", "CREATE_INDEX", ",", "self", "::", "DROP_INDEX", "]", ")", ")", "{", "return", "$", "this", "->", "_alias", ";", "}", "return", "null", ";", "}" ]
Only return the alias if joins have been set or this is a sub-query. @return string
[ "Only", "return", "the", "alias", "if", "joins", "have", "been", "set", "or", "this", "is", "a", "sub", "-", "query", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L424-L430
titon/db
src/Titon/Db/Query.php
Query.getFields
public function getFields() { $fields = $this->_fields; if ($this->getJoins() && !$fields && $this->getType() === self::SELECT) { return array_keys($this->getRepository()->getSchema()->getColumns()); } return $fields; }
php
public function getFields() { $fields = $this->_fields; if ($this->getJoins() && !$fields && $this->getType() === self::SELECT) { return array_keys($this->getRepository()->getSchema()->getColumns()); } return $fields; }
[ "public", "function", "getFields", "(", ")", "{", "$", "fields", "=", "$", "this", "->", "_fields", ";", "if", "(", "$", "this", "->", "getJoins", "(", ")", "&&", "!", "$", "fields", "&&", "$", "this", "->", "getType", "(", ")", "===", "self", "::", "SELECT", ")", "{", "return", "array_keys", "(", "$", "this", "->", "getRepository", "(", ")", "->", "getSchema", "(", ")", "->", "getColumns", "(", ")", ")", ";", "}", "return", "$", "fields", ";", "}" ]
Return the list of fields and or values. Return all table fields if a join exists and no fields were whitelisted. @return string[]
[ "Return", "the", "list", "of", "fields", "and", "or", "values", ".", "Return", "all", "table", "fields", "if", "a", "join", "exists", "and", "no", "fields", "were", "whitelisted", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L483-L491
titon/db
src/Titon/Db/Query.php
Query.groupBy
public function groupBy() { $fields = func_get_args(); if (is_array($fields[0])) { $fields = $fields[0]; } $this->_groupBy = array_unique(array_merge($this->_groupBy, $fields)); return $this; }
php
public function groupBy() { $fields = func_get_args(); if (is_array($fields[0])) { $fields = $fields[0]; } $this->_groupBy = array_unique(array_merge($this->_groupBy, $fields)); return $this; }
[ "public", "function", "groupBy", "(", ")", "{", "$", "fields", "=", "func_get_args", "(", ")", ";", "if", "(", "is_array", "(", "$", "fields", "[", "0", "]", ")", ")", "{", "$", "fields", "=", "$", "fields", "[", "0", "]", ";", "}", "$", "this", "->", "_groupBy", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "_groupBy", ",", "$", "fields", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set what fields to group on. @return $this
[ "Set", "what", "fields", "to", "group", "on", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L601-L611
titon/db
src/Titon/Db/Query.php
Query.having
public function having($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_having, Predicate::ALSO, $field, $op, $value); }
php
public function having($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_having, Predicate::ALSO, $field, $op, $value); }
[ "public", "function", "having", "(", "$", "field", ",", "$", "op", "=", "null", ",", "$", "value", "=", "null", ")", "{", "return", "$", "this", "->", "_modifyPredicate", "(", "$", "this", "->", "_having", ",", "Predicate", "::", "ALSO", ",", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "}" ]
Will modify or create a having predicate using the AND conjunction. @param string $field @param string $op @param mixed $value @return $this
[ "Will", "modify", "or", "create", "a", "having", "predicate", "using", "the", "AND", "conjunction", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L621-L623
titon/db
src/Titon/Db/Query.php
Query.innerJoin
public function innerJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::INNER, $table, $fields, $on); }
php
public function innerJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::INNER, $table, $fields, $on); }
[ "public", "function", "innerJoin", "(", "$", "table", ",", "array", "$", "fields", "=", "[", "]", ",", "array", "$", "on", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_addJoin", "(", "Join", "::", "INNER", ",", "$", "table", ",", "$", "fields", ",", "$", "on", ")", ";", "}" ]
Add a new INNER join. @param string|array $table @param array $fields @param array $on @return $this
[ "Add", "a", "new", "INNER", "join", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L633-L635
titon/db
src/Titon/Db/Query.php
Query.intersect
public function intersect(Query $query, $flag = null) { if ($flag === Dialect::ALL) { $query->attribute('flag', $flag); } return $this->_addCompound(Dialect::INTERSECT, $query); }
php
public function intersect(Query $query, $flag = null) { if ($flag === Dialect::ALL) { $query->attribute('flag', $flag); } return $this->_addCompound(Dialect::INTERSECT, $query); }
[ "public", "function", "intersect", "(", "Query", "$", "query", ",", "$", "flag", "=", "null", ")", "{", "if", "(", "$", "flag", "===", "Dialect", "::", "ALL", ")", "{", "$", "query", "->", "attribute", "(", "'flag'", ",", "$", "flag", ")", ";", "}", "return", "$", "this", "->", "_addCompound", "(", "Dialect", "::", "INTERSECT", ",", "$", "query", ")", ";", "}" ]
Add a select query as an intersect. @param \Titon\Db\Query $query @param string $flag @return $this
[ "Add", "a", "select", "query", "as", "an", "intersect", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L644-L650
titon/db
src/Titon/Db/Query.php
Query.last
public function last(array $options = []) { if ($order = $this->getOrderBy()) { $this->_orderBy = []; foreach ($order as $field => $dir) { if ($dir === 'asc') { $dir = 'desc'; } else if ($dir === 'desc') { $dir = 'asc'; } if (is_numeric($field)) { $this->orderBy($dir); } else { $this->orderBy($field, $dir); } } } else { $this->orderBy($this->getRepository()->getPrimaryKey(), 'desc'); } return $this->limit(1)->find('first', $options); }
php
public function last(array $options = []) { if ($order = $this->getOrderBy()) { $this->_orderBy = []; foreach ($order as $field => $dir) { if ($dir === 'asc') { $dir = 'desc'; } else if ($dir === 'desc') { $dir = 'asc'; } if (is_numeric($field)) { $this->orderBy($dir); } else { $this->orderBy($field, $dir); } } } else { $this->orderBy($this->getRepository()->getPrimaryKey(), 'desc'); } return $this->limit(1)->find('first', $options); }
[ "public", "function", "last", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "order", "=", "$", "this", "->", "getOrderBy", "(", ")", ")", "{", "$", "this", "->", "_orderBy", "=", "[", "]", ";", "foreach", "(", "$", "order", "as", "$", "field", "=>", "$", "dir", ")", "{", "if", "(", "$", "dir", "===", "'asc'", ")", "{", "$", "dir", "=", "'desc'", ";", "}", "else", "if", "(", "$", "dir", "===", "'desc'", ")", "{", "$", "dir", "=", "'asc'", ";", "}", "if", "(", "is_numeric", "(", "$", "field", ")", ")", "{", "$", "this", "->", "orderBy", "(", "$", "dir", ")", ";", "}", "else", "{", "$", "this", "->", "orderBy", "(", "$", "field", ",", "$", "dir", ")", ";", "}", "}", "}", "else", "{", "$", "this", "->", "orderBy", "(", "$", "this", "->", "getRepository", "(", ")", "->", "getPrimaryKey", "(", ")", ",", "'desc'", ")", ";", "}", "return", "$", "this", "->", "limit", "(", "1", ")", "->", "find", "(", "'first'", ",", "$", "options", ")", ";", "}" ]
Return the last record from the results. Reverse the direction of any order by declarations. @param array $options @return \Titon\Db\Entity
[ "Return", "the", "last", "record", "from", "the", "results", ".", "Reverse", "the", "direction", "of", "any", "order", "by", "declarations", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L659-L681
titon/db
src/Titon/Db/Query.php
Query.leftJoin
public function leftJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::LEFT, $table, $fields, $on); }
php
public function leftJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::LEFT, $table, $fields, $on); }
[ "public", "function", "leftJoin", "(", "$", "table", ",", "array", "$", "fields", "=", "[", "]", ",", "array", "$", "on", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_addJoin", "(", "Join", "::", "LEFT", ",", "$", "table", ",", "$", "fields", ",", "$", "on", ")", ";", "}" ]
Add a new LEFT join. @param string|array $table @param array $fields @param array $on @return $this
[ "Add", "a", "new", "LEFT", "join", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L691-L693
titon/db
src/Titon/Db/Query.php
Query.lists
public function lists($value = null, $key = null, array $options = []) { $repo = $this->getRepository(); $key = $key ?: $repo->getPrimaryKey(); $value = $value ?: $repo->getDisplayField(); $options['key'] = $key; $options['value'] = $value; return $this->fields([$key, $value], true)->find('list', $options); }
php
public function lists($value = null, $key = null, array $options = []) { $repo = $this->getRepository(); $key = $key ?: $repo->getPrimaryKey(); $value = $value ?: $repo->getDisplayField(); $options['key'] = $key; $options['value'] = $value; return $this->fields([$key, $value], true)->find('list', $options); }
[ "public", "function", "lists", "(", "$", "value", "=", "null", ",", "$", "key", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "repo", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "key", "=", "$", "key", "?", ":", "$", "repo", "->", "getPrimaryKey", "(", ")", ";", "$", "value", "=", "$", "value", "?", ":", "$", "repo", "->", "getDisplayField", "(", ")", ";", "$", "options", "[", "'key'", "]", "=", "$", "key", ";", "$", "options", "[", "'value'", "]", "=", "$", "value", ";", "return", "$", "this", "->", "fields", "(", "[", "$", "key", ",", "$", "value", "]", ",", "true", ")", "->", "find", "(", "'list'", ",", "$", "options", ")", ";", "}" ]
Return all records as a key value list. @param string $value @param string $key @param array $options @return array
[ "Return", "all", "records", "as", "a", "key", "value", "list", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L720-L729
titon/db
src/Titon/Db/Query.php
Query.orderBy
public function orderBy($field, $direction = self::DESC) { if (is_array($field)) { foreach ($field as $key => $dir) { $this->orderBy($key, $dir); } } else if ($field === 'RAND') { $this->_orderBy[] = $this->func('RAND'); } else if ($field instanceof Func) { $this->_orderBy[] = $field; } else { $direction = strtolower($direction); if ($direction != self::ASC && $direction != self::DESC) { throw new InvalidArgumentException(sprintf('Invalid order direction %s for field %s', $direction, $field)); } $this->_orderBy[$field] = $direction; } return $this; }
php
public function orderBy($field, $direction = self::DESC) { if (is_array($field)) { foreach ($field as $key => $dir) { $this->orderBy($key, $dir); } } else if ($field === 'RAND') { $this->_orderBy[] = $this->func('RAND'); } else if ($field instanceof Func) { $this->_orderBy[] = $field; } else { $direction = strtolower($direction); if ($direction != self::ASC && $direction != self::DESC) { throw new InvalidArgumentException(sprintf('Invalid order direction %s for field %s', $direction, $field)); } $this->_orderBy[$field] = $direction; } return $this; }
[ "public", "function", "orderBy", "(", "$", "field", ",", "$", "direction", "=", "self", "::", "DESC", ")", "{", "if", "(", "is_array", "(", "$", "field", ")", ")", "{", "foreach", "(", "$", "field", "as", "$", "key", "=>", "$", "dir", ")", "{", "$", "this", "->", "orderBy", "(", "$", "key", ",", "$", "dir", ")", ";", "}", "}", "else", "if", "(", "$", "field", "===", "'RAND'", ")", "{", "$", "this", "->", "_orderBy", "[", "]", "=", "$", "this", "->", "func", "(", "'RAND'", ")", ";", "}", "else", "if", "(", "$", "field", "instanceof", "Func", ")", "{", "$", "this", "->", "_orderBy", "[", "]", "=", "$", "field", ";", "}", "else", "{", "$", "direction", "=", "strtolower", "(", "$", "direction", ")", ";", "if", "(", "$", "direction", "!=", "self", "::", "ASC", "&&", "$", "direction", "!=", "self", "::", "DESC", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid order direction %s for field %s'", ",", "$", "direction", ",", "$", "field", ")", ")", ";", "}", "$", "this", "->", "_orderBy", "[", "$", "field", "]", "=", "$", "direction", ";", "}", "return", "$", "this", ";", "}" ]
Set the fields and direction to order by. @param string|array $field @param string $direction @return $this @throws \Titon\Db\Exception\InvalidArgumentException
[ "Set", "the", "fields", "and", "direction", "to", "order", "by", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L771-L794
titon/db
src/Titon/Db/Query.php
Query.orHaving
public function orHaving($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_having, Predicate::EITHER, $field, $op, $value); }
php
public function orHaving($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_having, Predicate::EITHER, $field, $op, $value); }
[ "public", "function", "orHaving", "(", "$", "field", ",", "$", "op", "=", "null", ",", "$", "value", "=", "null", ")", "{", "return", "$", "this", "->", "_modifyPredicate", "(", "$", "this", "->", "_having", ",", "Predicate", "::", "EITHER", ",", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "}" ]
Will modify or create a having predicate using the OR conjunction. @param string $field @param string $op @param mixed $value @return $this
[ "Will", "modify", "or", "create", "a", "having", "predicate", "using", "the", "OR", "conjunction", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L804-L806
titon/db
src/Titon/Db/Query.php
Query.orWhere
public function orWhere($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_where, Predicate::EITHER, $field, $op, $value); }
php
public function orWhere($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_where, Predicate::EITHER, $field, $op, $value); }
[ "public", "function", "orWhere", "(", "$", "field", ",", "$", "op", "=", "null", ",", "$", "value", "=", "null", ")", "{", "return", "$", "this", "->", "_modifyPredicate", "(", "$", "this", "->", "_where", ",", "Predicate", "::", "EITHER", ",", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "}" ]
Will modify or create a where predicate using the OR conjunction. @param string $field @param string $op @param mixed $value @return $this
[ "Will", "modify", "or", "create", "a", "where", "predicate", "using", "the", "OR", "conjunction", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L816-L818
titon/db
src/Titon/Db/Query.php
Query.outerJoin
public function outerJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::OUTER, $table, $fields, $on); }
php
public function outerJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::OUTER, $table, $fields, $on); }
[ "public", "function", "outerJoin", "(", "$", "table", ",", "array", "$", "fields", "=", "[", "]", ",", "array", "$", "on", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_addJoin", "(", "Join", "::", "OUTER", ",", "$", "table", ",", "$", "fields", ",", "$", "on", ")", ";", "}" ]
Add a new OUTER join. @param string|array $table @param array $fields @param array $on @return $this
[ "Add", "a", "new", "OUTER", "join", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L828-L830
titon/db
src/Titon/Db/Query.php
Query.rightJoin
public function rightJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::RIGHT, $table, $fields, $on); }
php
public function rightJoin($table, array $fields = [], array $on = []) { return $this->_addJoin(Join::RIGHT, $table, $fields, $on); }
[ "public", "function", "rightJoin", "(", "$", "table", ",", "array", "$", "fields", "=", "[", "]", ",", "array", "$", "on", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_addJoin", "(", "Join", "::", "RIGHT", ",", "$", "table", ",", "$", "fields", ",", "$", "on", ")", ";", "}" ]
Add a new RIGHT join. @param string|array $table @param array $fields @param array $on @return $this
[ "Add", "a", "new", "RIGHT", "join", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L840-L842
titon/db
src/Titon/Db/Query.php
Query.save
public function save($data = null, array $options = []) { if ($data) { $this->data($data); } return $this->getRepository()->save($this, $options); }
php
public function save($data = null, array $options = []) { if ($data) { $this->data($data); } return $this->getRepository()->save($this, $options); }
[ "public", "function", "save", "(", "$", "data", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "data", ")", "{", "$", "this", "->", "data", "(", "$", "data", ")", ";", "}", "return", "$", "this", "->", "getRepository", "(", ")", "->", "save", "(", "$", "this", ",", "$", "options", ")", ";", "}" ]
Pass the query to the repository to interact with the database. Return the count of how many records were affected. @param array|\Titon\Type\Contract\Arrayable $data @param array $options @return int
[ "Pass", "the", "query", "to", "the", "repository", "to", "interact", "with", "the", "database", ".", "Return", "the", "count", "of", "how", "many", "records", "were", "affected", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L852-L858
titon/db
src/Titon/Db/Query.php
Query.setType
public function setType($type) { if (!in_array($type, [ self::INSERT, self::MULTI_INSERT, self::SELECT, self::UPDATE, self::DELETE, self::TRUNCATE, self::CREATE_TABLE, self::CREATE_INDEX, self::DROP_TABLE, self::DROP_INDEX ], true)) { throw new UnsupportedTypeException(sprintf('Invalid query type %s', $type)); } $this->_type = $type; // Reset data and binds when changing types $this->_data = []; $this->_bindings = []; return $this; }
php
public function setType($type) { if (!in_array($type, [ self::INSERT, self::MULTI_INSERT, self::SELECT, self::UPDATE, self::DELETE, self::TRUNCATE, self::CREATE_TABLE, self::CREATE_INDEX, self::DROP_TABLE, self::DROP_INDEX ], true)) { throw new UnsupportedTypeException(sprintf('Invalid query type %s', $type)); } $this->_type = $type; // Reset data and binds when changing types $this->_data = []; $this->_bindings = []; return $this; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "[", "self", "::", "INSERT", ",", "self", "::", "MULTI_INSERT", ",", "self", "::", "SELECT", ",", "self", "::", "UPDATE", ",", "self", "::", "DELETE", ",", "self", "::", "TRUNCATE", ",", "self", "::", "CREATE_TABLE", ",", "self", "::", "CREATE_INDEX", ",", "self", "::", "DROP_TABLE", ",", "self", "::", "DROP_INDEX", "]", ",", "true", ")", ")", "{", "throw", "new", "UnsupportedTypeException", "(", "sprintf", "(", "'Invalid query type %s'", ",", "$", "type", ")", ")", ";", "}", "$", "this", "->", "_type", "=", "$", "type", ";", "// Reset data and binds when changing types", "$", "this", "->", "_data", "=", "[", "]", ";", "$", "this", "->", "_bindings", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
Set the type of query. @param string $type @return $this @throws \Titon\Db\Exception\UnsupportedTypeException
[ "Set", "the", "type", "of", "query", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L879-L894
titon/db
src/Titon/Db/Query.php
Query.straightJoin
public function straightJoin($table, array $fields, array $on = []) { return $this->_addJoin(Join::STRAIGHT, $table, $fields, $on); }
php
public function straightJoin($table, array $fields, array $on = []) { return $this->_addJoin(Join::STRAIGHT, $table, $fields, $on); }
[ "public", "function", "straightJoin", "(", "$", "table", ",", "array", "$", "fields", ",", "array", "$", "on", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_addJoin", "(", "Join", "::", "STRAIGHT", ",", "$", "table", ",", "$", "fields", ",", "$", "on", ")", ";", "}" ]
Add a new STRAIGHT join. @param string|array $table @param array $fields @param array $on @return $this
[ "Add", "a", "new", "STRAIGHT", "join", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L904-L906
titon/db
src/Titon/Db/Query.php
Query.subQuery
public function subQuery() { $query = new SubQuery(Query::SELECT, $this->getRepository()); $query->fields(func_get_args()); return $query; }
php
public function subQuery() { $query = new SubQuery(Query::SELECT, $this->getRepository()); $query->fields(func_get_args()); return $query; }
[ "public", "function", "subQuery", "(", ")", "{", "$", "query", "=", "new", "SubQuery", "(", "Query", "::", "SELECT", ",", "$", "this", "->", "getRepository", "(", ")", ")", ";", "$", "query", "->", "fields", "(", "func_get_args", "(", ")", ")", ";", "return", "$", "query", ";", "}" ]
Instantiate a new query object that will be used for sub-queries. @return \Titon\Db\Query\SubQuery
[ "Instantiate", "a", "new", "query", "object", "that", "will", "be", "used", "for", "sub", "-", "queries", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L913-L918
titon/db
src/Titon/Db/Query.php
Query.union
public function union(Query $query, $flag = null) { if ($flag === Dialect::ALL || $flag === Dialect::DISTINCT) { $query->attribute('flag', $flag); } return $this->_addCompound(Dialect::UNION, $query); }
php
public function union(Query $query, $flag = null) { if ($flag === Dialect::ALL || $flag === Dialect::DISTINCT) { $query->attribute('flag', $flag); } return $this->_addCompound(Dialect::UNION, $query); }
[ "public", "function", "union", "(", "Query", "$", "query", ",", "$", "flag", "=", "null", ")", "{", "if", "(", "$", "flag", "===", "Dialect", "::", "ALL", "||", "$", "flag", "===", "Dialect", "::", "DISTINCT", ")", "{", "$", "query", "->", "attribute", "(", "'flag'", ",", "$", "flag", ")", ";", "}", "return", "$", "this", "->", "_addCompound", "(", "Dialect", "::", "UNION", ",", "$", "query", ")", ";", "}" ]
Add a select query as a union. @param \Titon\Db\Query $query @param string $flag @return $this
[ "Add", "a", "select", "query", "as", "a", "union", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L946-L952
titon/db
src/Titon/Db/Query.php
Query.where
public function where($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_where, Predicate::ALSO, $field, $op, $value); }
php
public function where($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_where, Predicate::ALSO, $field, $op, $value); }
[ "public", "function", "where", "(", "$", "field", ",", "$", "op", "=", "null", ",", "$", "value", "=", "null", ")", "{", "return", "$", "this", "->", "_modifyPredicate", "(", "$", "this", "->", "_where", ",", "Predicate", "::", "ALSO", ",", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "}" ]
Will modify or create a where predicate using the AND conjunction. @param string $field @param string $op @param mixed $value @return $this
[ "Will", "modify", "or", "create", "a", "where", "predicate", "using", "the", "AND", "conjunction", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L962-L964
titon/db
src/Titon/Db/Query.php
Query.xorHaving
public function xorHaving($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_having, Predicate::MAYBE, $field, $op, $value); }
php
public function xorHaving($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_having, Predicate::MAYBE, $field, $op, $value); }
[ "public", "function", "xorHaving", "(", "$", "field", ",", "$", "op", "=", "null", ",", "$", "value", "=", "null", ")", "{", "return", "$", "this", "->", "_modifyPredicate", "(", "$", "this", "->", "_having", ",", "Predicate", "::", "MAYBE", ",", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "}" ]
Will modify or create a having predicate using the XOR conjunction. @param string $field @param string $op @param mixed $value @return $this
[ "Will", "modify", "or", "create", "a", "having", "predicate", "using", "the", "XOR", "conjunction", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L974-L976
titon/db
src/Titon/Db/Query.php
Query.xorWhere
public function xorWhere($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_where, Predicate::MAYBE, $field, $op, $value); }
php
public function xorWhere($field, $op = null, $value = null) { return $this->_modifyPredicate($this->_where, Predicate::MAYBE, $field, $op, $value); }
[ "public", "function", "xorWhere", "(", "$", "field", ",", "$", "op", "=", "null", ",", "$", "value", "=", "null", ")", "{", "return", "$", "this", "->", "_modifyPredicate", "(", "$", "this", "->", "_where", ",", "Predicate", "::", "MAYBE", ",", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "}" ]
Will modify or create a where predicate using the XOR conjunction. @param string $field @param string $op @param mixed $value @return $this
[ "Will", "modify", "or", "create", "a", "where", "predicate", "using", "the", "XOR", "conjunction", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L986-L988
titon/db
src/Titon/Db/Query.php
Query._addCompound
protected function _addCompound($type, Query $query) { if ($query->getType() !== self::SELECT) { throw new InvalidQueryException(sprintf('Only a select query can be used with %s', $type)); } $query->attribute('compound', $type); $this->_compounds[] = $query; return $this; }
php
protected function _addCompound($type, Query $query) { if ($query->getType() !== self::SELECT) { throw new InvalidQueryException(sprintf('Only a select query can be used with %s', $type)); } $query->attribute('compound', $type); $this->_compounds[] = $query; return $this; }
[ "protected", "function", "_addCompound", "(", "$", "type", ",", "Query", "$", "query", ")", "{", "if", "(", "$", "query", "->", "getType", "(", ")", "!==", "self", "::", "SELECT", ")", "{", "throw", "new", "InvalidQueryException", "(", "sprintf", "(", "'Only a select query can be used with %s'", ",", "$", "type", ")", ")", ";", "}", "$", "query", "->", "attribute", "(", "'compound'", ",", "$", "type", ")", ";", "$", "this", "->", "_compounds", "[", "]", "=", "$", "query", ";", "return", "$", "this", ";", "}" ]
Add a new compound query. Only select queries can be used with compounds. @param string $type @param \Titon\Db\Query $query @return $this @throws \Titon\Db\Exception\InvalidQueryException
[ "Add", "a", "new", "compound", "query", ".", "Only", "select", "queries", "can", "be", "used", "with", "compounds", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L998-L1008
titon/db
src/Titon/Db/Query.php
Query._addJoin
protected function _addJoin($type, $table, $fields, $on = []) { $repo = $this->getRepository(); $join = new Join($type); $conditions = []; if (is_array($table)) { $alias = $table[1]; $table = $table[0]; } else { $alias = $table; } foreach ($on as $pfk => $rfk) { if (strpos($pfk, '.') === false) { $pfk = $repo->getAlias() . '.' . $pfk; } if (strpos($rfk, '.') === false) { $rfk = $alias . '.' . $rfk; } $conditions[$pfk] = $rfk; } $this->_joins[] = $join->from($table, $alias)->on($conditions)->fields($fields); return $this; }
php
protected function _addJoin($type, $table, $fields, $on = []) { $repo = $this->getRepository(); $join = new Join($type); $conditions = []; if (is_array($table)) { $alias = $table[1]; $table = $table[0]; } else { $alias = $table; } foreach ($on as $pfk => $rfk) { if (strpos($pfk, '.') === false) { $pfk = $repo->getAlias() . '.' . $pfk; } if (strpos($rfk, '.') === false) { $rfk = $alias . '.' . $rfk; } $conditions[$pfk] = $rfk; } $this->_joins[] = $join->from($table, $alias)->on($conditions)->fields($fields); return $this; }
[ "protected", "function", "_addJoin", "(", "$", "type", ",", "$", "table", ",", "$", "fields", ",", "$", "on", "=", "[", "]", ")", "{", "$", "repo", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "join", "=", "new", "Join", "(", "$", "type", ")", ";", "$", "conditions", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "table", ")", ")", "{", "$", "alias", "=", "$", "table", "[", "1", "]", ";", "$", "table", "=", "$", "table", "[", "0", "]", ";", "}", "else", "{", "$", "alias", "=", "$", "table", ";", "}", "foreach", "(", "$", "on", "as", "$", "pfk", "=>", "$", "rfk", ")", "{", "if", "(", "strpos", "(", "$", "pfk", ",", "'.'", ")", "===", "false", ")", "{", "$", "pfk", "=", "$", "repo", "->", "getAlias", "(", ")", ".", "'.'", ".", "$", "pfk", ";", "}", "if", "(", "strpos", "(", "$", "rfk", ",", "'.'", ")", "===", "false", ")", "{", "$", "rfk", "=", "$", "alias", ".", "'.'", ".", "$", "rfk", ";", "}", "$", "conditions", "[", "$", "pfk", "]", "=", "$", "rfk", ";", "}", "$", "this", "->", "_joins", "[", "]", "=", "$", "join", "->", "from", "(", "$", "table", ",", "$", "alias", ")", "->", "on", "(", "$", "conditions", ")", "->", "fields", "(", "$", "fields", ")", ";", "return", "$", "this", ";", "}" ]
Add a new join type. @param string $type @param string|array $table @param array $fields @param array $on @return $this
[ "Add", "a", "new", "join", "type", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L1019-L1046
titon/db
src/Titon/Db/Query.php
Query._modifyPredicate
protected function _modifyPredicate(&$predicate, $type, $field, $op, $value) { if (!$predicate) { $predicate = new Predicate($type); } else if ($predicate->getType() !== $type) { throw new ExistingPredicateException(sprintf('Predicate clause already created using "%s" conjunction', $predicate->getType())); } if ($field instanceof Closure) { $predicate->bindCallback($field, $this); } else if ($value !== null || in_array($op, [Expr::NULL, Expr::NOT_NULL], true)) { $predicate->add($field, $op, $value); } else if ($op === '!=') { $predicate->notEq($field, $value); } else { $predicate->eq($field, $op); } return $this; }
php
protected function _modifyPredicate(&$predicate, $type, $field, $op, $value) { if (!$predicate) { $predicate = new Predicate($type); } else if ($predicate->getType() !== $type) { throw new ExistingPredicateException(sprintf('Predicate clause already created using "%s" conjunction', $predicate->getType())); } if ($field instanceof Closure) { $predicate->bindCallback($field, $this); } else if ($value !== null || in_array($op, [Expr::NULL, Expr::NOT_NULL], true)) { $predicate->add($field, $op, $value); } else if ($op === '!=') { $predicate->notEq($field, $value); } else { $predicate->eq($field, $op); } return $this; }
[ "protected", "function", "_modifyPredicate", "(", "&", "$", "predicate", ",", "$", "type", ",", "$", "field", ",", "$", "op", ",", "$", "value", ")", "{", "if", "(", "!", "$", "predicate", ")", "{", "$", "predicate", "=", "new", "Predicate", "(", "$", "type", ")", ";", "}", "else", "if", "(", "$", "predicate", "->", "getType", "(", ")", "!==", "$", "type", ")", "{", "throw", "new", "ExistingPredicateException", "(", "sprintf", "(", "'Predicate clause already created using \"%s\" conjunction'", ",", "$", "predicate", "->", "getType", "(", ")", ")", ")", ";", "}", "if", "(", "$", "field", "instanceof", "Closure", ")", "{", "$", "predicate", "->", "bindCallback", "(", "$", "field", ",", "$", "this", ")", ";", "}", "else", "if", "(", "$", "value", "!==", "null", "||", "in_array", "(", "$", "op", ",", "[", "Expr", "::", "NULL", ",", "Expr", "::", "NOT_NULL", "]", ",", "true", ")", ")", "{", "$", "predicate", "->", "add", "(", "$", "field", ",", "$", "op", ",", "$", "value", ")", ";", "}", "else", "if", "(", "$", "op", "===", "'!='", ")", "{", "$", "predicate", "->", "notEq", "(", "$", "field", ",", "$", "value", ")", ";", "}", "else", "{", "$", "predicate", "->", "eq", "(", "$", "field", ",", "$", "op", ")", ";", "}", "return", "$", "this", ";", "}" ]
Modify a predicate by adding additional clauses. @param \Titon\Db\Query\Predicate $predicate @param int $type @param string $field @param mixed $op @param mixed $value @return $this @throws \Titon\Db\Exception\ExistingPredicateException
[ "Modify", "a", "predicate", "by", "adding", "additional", "clauses", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L1059-L1081
askupasoftware/amarkal
Extensions/WordPress/Editor/Plugin.php
Plugin.register
public function register() { add_action( 'admin_head', array( $this, 'add_filters' ) ); add_action( 'wp_head', array( $this, 'add_filters' ) ); if( is_array( $this->config['callback'] ) ) { foreach( $this->config['callback'] as $handle => $callback ) { $callback->register( $this->config['slug'].'_'.$handle ); } } else { $this->config['callback']->register( $this->config['slug'] ); } }
php
public function register() { add_action( 'admin_head', array( $this, 'add_filters' ) ); add_action( 'wp_head', array( $this, 'add_filters' ) ); if( is_array( $this->config['callback'] ) ) { foreach( $this->config['callback'] as $handle => $callback ) { $callback->register( $this->config['slug'].'_'.$handle ); } } else { $this->config['callback']->register( $this->config['slug'] ); } }
[ "public", "function", "register", "(", ")", "{", "add_action", "(", "'admin_head'", ",", "array", "(", "$", "this", ",", "'add_filters'", ")", ")", ";", "add_action", "(", "'wp_head'", ",", "array", "(", "$", "this", ",", "'add_filters'", ")", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "config", "[", "'callback'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "config", "[", "'callback'", "]", "as", "$", "handle", "=>", "$", "callback", ")", "{", "$", "callback", "->", "register", "(", "$", "this", "->", "config", "[", "'slug'", "]", ".", "'_'", ".", "$", "handle", ")", ";", "}", "}", "else", "{", "$", "this", "->", "config", "[", "'callback'", "]", "->", "register", "(", "$", "this", "->", "config", "[", "'slug'", "]", ")", ";", "}", "}" ]
Register the plugin to the TinyMCE plugin registry and add a form callback or callbacks.
[ "Register", "the", "plugin", "to", "the", "TinyMCE", "plugin", "registry", "and", "add", "a", "form", "callback", "or", "callbacks", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Editor/Plugin.php#L33-L49
askupasoftware/amarkal
Extensions/WordPress/Editor/Plugin.php
Plugin.add_filters
public function add_filters() { // check if WYSIWYG is enabled if ( get_user_option('rich_editing') ) { add_filter( 'mce_external_plugins', array( $this, 'register_plugin' ) ); add_filter( 'mce_buttons'.($this->config['row'] > 1 ? '_'.$this->config['row'] : ''), array( $this, 'register_button' ) ); } }
php
public function add_filters() { // check if WYSIWYG is enabled if ( get_user_option('rich_editing') ) { add_filter( 'mce_external_plugins', array( $this, 'register_plugin' ) ); add_filter( 'mce_buttons'.($this->config['row'] > 1 ? '_'.$this->config['row'] : ''), array( $this, 'register_button' ) ); } }
[ "public", "function", "add_filters", "(", ")", "{", "// check if WYSIWYG is enabled ", "if", "(", "get_user_option", "(", "'rich_editing'", ")", ")", "{", "add_filter", "(", "'mce_external_plugins'", ",", "array", "(", "$", "this", ",", "'register_plugin'", ")", ")", ";", "add_filter", "(", "'mce_buttons'", ".", "(", "$", "this", "->", "config", "[", "'row'", "]", ">", "1", "?", "'_'", ".", "$", "this", "->", "config", "[", "'row'", "]", ":", "''", ")", ",", "array", "(", "$", "this", ",", "'register_button'", ")", ")", ";", "}", "}" ]
Add a button to the tinyMCE editor, if the user has the required settings.
[ "Add", "a", "button", "to", "the", "tinyMCE", "editor", "if", "the", "user", "has", "the", "required", "settings", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Editor/Plugin.php#L54-L62
xinix-technology/norm
src/Norm/Cursor/MemoryCursor.php
MemoryCursor.next
public function next() { // Try to get the next element in our data buffer. $this->next = each($this->buffer); // Past the end of the data buffer if (false === $this->next && !$this->isQueried) { $this->isQueried = true; $connection = $this->collection->getConnection(); $buffer = $connection->getCollectionData($this->collection->getName()); if (empty($this->criteria)) { $this->buffer = $buffer; } else { $this->buffer = array(); foreach ($buffer as $k => $row) { $match = true; foreach ($this->criteria as $ckey => $cval) { if ($row[$ckey] !== $cval) { $match = false; } } if ($match) { $this->buffer[] = $row; } } } $this->next = each($this->buffer); } }
php
public function next() { // Try to get the next element in our data buffer. $this->next = each($this->buffer); // Past the end of the data buffer if (false === $this->next && !$this->isQueried) { $this->isQueried = true; $connection = $this->collection->getConnection(); $buffer = $connection->getCollectionData($this->collection->getName()); if (empty($this->criteria)) { $this->buffer = $buffer; } else { $this->buffer = array(); foreach ($buffer as $k => $row) { $match = true; foreach ($this->criteria as $ckey => $cval) { if ($row[$ckey] !== $cval) { $match = false; } } if ($match) { $this->buffer[] = $row; } } } $this->next = each($this->buffer); } }
[ "public", "function", "next", "(", ")", "{", "// Try to get the next element in our data buffer.", "$", "this", "->", "next", "=", "each", "(", "$", "this", "->", "buffer", ")", ";", "// Past the end of the data buffer", "if", "(", "false", "===", "$", "this", "->", "next", "&&", "!", "$", "this", "->", "isQueried", ")", "{", "$", "this", "->", "isQueried", "=", "true", ";", "$", "connection", "=", "$", "this", "->", "collection", "->", "getConnection", "(", ")", ";", "$", "buffer", "=", "$", "connection", "->", "getCollectionData", "(", "$", "this", "->", "collection", "->", "getName", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "criteria", ")", ")", "{", "$", "this", "->", "buffer", "=", "$", "buffer", ";", "}", "else", "{", "$", "this", "->", "buffer", "=", "array", "(", ")", ";", "foreach", "(", "$", "buffer", "as", "$", "k", "=>", "$", "row", ")", "{", "$", "match", "=", "true", ";", "foreach", "(", "$", "this", "->", "criteria", "as", "$", "ckey", "=>", "$", "cval", ")", "{", "if", "(", "$", "row", "[", "$", "ckey", "]", "!==", "$", "cval", ")", "{", "$", "match", "=", "false", ";", "}", "}", "if", "(", "$", "match", ")", "{", "$", "this", "->", "buffer", "[", "]", "=", "$", "row", ";", "}", "}", "}", "$", "this", "->", "next", "=", "each", "(", "$", "this", "->", "buffer", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MemoryCursor.php#L49-L83
xinix-technology/norm
src/Norm/Cursor/MemoryCursor.php
MemoryCursor.count
public function count($foundOnly = false) { if ($foundOnly) { throw new Exception('Unimplemented '.__METHOD__); } else { $this->rewind(); return count($this->buffer); } }
php
public function count($foundOnly = false) { if ($foundOnly) { throw new Exception('Unimplemented '.__METHOD__); } else { $this->rewind(); return count($this->buffer); } }
[ "public", "function", "count", "(", "$", "foundOnly", "=", "false", ")", "{", "if", "(", "$", "foundOnly", ")", "{", "throw", "new", "Exception", "(", "'Unimplemented '", ".", "__METHOD__", ")", ";", "}", "else", "{", "$", "this", "->", "rewind", "(", ")", ";", "return", "count", "(", "$", "this", "->", "buffer", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/MemoryCursor.php#L114-L123
phpmob/changmin
src/PhpMob/CmsBundle/Model/Page.php
Page.getTemplateName
public function getTemplateName(): ?string { return $this->template ? TemplateInterface::PREFIX.$this->template->getName() : null; }
php
public function getTemplateName(): ?string { return $this->template ? TemplateInterface::PREFIX.$this->template->getName() : null; }
[ "public", "function", "getTemplateName", "(", ")", ":", "?", "string", "{", "return", "$", "this", "->", "template", "?", "TemplateInterface", "::", "PREFIX", ".", "$", "this", "->", "template", "->", "getName", "(", ")", ":", "null", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CmsBundle/Model/Page.php#L206-L209
xinix-technology/norm
src/Norm/Hookable.php
Hookable.applyFilter
public function applyFilter($name, $filterArg = null) { if (!isset($this->hooks[$name])) { $this->hooks[$name] = array(array()); } if (!empty($this->hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($this->hooks[$name]) > 1) { ksort($this->hooks[$name]); } foreach ($this->hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $filterArg = call_user_func($callable, $filterArg); } } } } return $filterArg; }
php
public function applyFilter($name, $filterArg = null) { if (!isset($this->hooks[$name])) { $this->hooks[$name] = array(array()); } if (!empty($this->hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($this->hooks[$name]) > 1) { ksort($this->hooks[$name]); } foreach ($this->hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $filterArg = call_user_func($callable, $filterArg); } } } } return $filterArg; }
[ "public", "function", "applyFilter", "(", "$", "name", ",", "$", "filterArg", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "hooks", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "hooks", "[", "$", "name", "]", "=", "array", "(", "array", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "hooks", "[", "$", "name", "]", ")", ")", "{", "// Sort by priority, low to high, if there's more than one priority", "if", "(", "count", "(", "$", "this", "->", "hooks", "[", "$", "name", "]", ")", ">", "1", ")", "{", "ksort", "(", "$", "this", "->", "hooks", "[", "$", "name", "]", ")", ";", "}", "foreach", "(", "$", "this", "->", "hooks", "[", "$", "name", "]", "as", "$", "priority", ")", "{", "if", "(", "!", "empty", "(", "$", "priority", ")", ")", "{", "foreach", "(", "$", "priority", "as", "$", "callable", ")", "{", "$", "filterArg", "=", "call_user_func", "(", "$", "callable", ",", "$", "filterArg", ")", ";", "}", "}", "}", "}", "return", "$", "filterArg", ";", "}" ]
Invoke filter @param string $name The hook name @param mixed $filterArg (Optional) Argument for hooked functions @return mixed
[ "Invoke", "filter" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Hookable.php#L75-L96
liugene/framework
src/Make.php
Make.url
static public function url($c=null,$a=null,$p=null) { switch(Config::get('url_module')){ case 0: $platform = isset($_GET[Config::get('var_platform')]) ? ucfirst($_GET[Config::get('var_platform')]) : Config::get('var_platform'); $p = is_null($p) ? $platform : $p; $c = is_null($c) ? $_GET[Config::get('var_controller')] : ucfirst($c); $a = is_null($a) ? $_GET[Config::get('var_action')] : ucfirst($a); $url = 'index.php?' . Config::get('var_platform') . '=' . $p . '&' . Config::get('var_controller') . '=' . $c . '&' . Config::get('var_action') . '=' . strtolower($a); break; case 1; $url = 'index.php/' . Config::get('default_platform') . '/' . $c . '/' . strtolower($a); break; } return $url; }
php
static public function url($c=null,$a=null,$p=null) { switch(Config::get('url_module')){ case 0: $platform = isset($_GET[Config::get('var_platform')]) ? ucfirst($_GET[Config::get('var_platform')]) : Config::get('var_platform'); $p = is_null($p) ? $platform : $p; $c = is_null($c) ? $_GET[Config::get('var_controller')] : ucfirst($c); $a = is_null($a) ? $_GET[Config::get('var_action')] : ucfirst($a); $url = 'index.php?' . Config::get('var_platform') . '=' . $p . '&' . Config::get('var_controller') . '=' . $c . '&' . Config::get('var_action') . '=' . strtolower($a); break; case 1; $url = 'index.php/' . Config::get('default_platform') . '/' . $c . '/' . strtolower($a); break; } return $url; }
[ "static", "public", "function", "url", "(", "$", "c", "=", "null", ",", "$", "a", "=", "null", ",", "$", "p", "=", "null", ")", "{", "switch", "(", "Config", "::", "get", "(", "'url_module'", ")", ")", "{", "case", "0", ":", "$", "platform", "=", "isset", "(", "$", "_GET", "[", "Config", "::", "get", "(", "'var_platform'", ")", "]", ")", "?", "ucfirst", "(", "$", "_GET", "[", "Config", "::", "get", "(", "'var_platform'", ")", "]", ")", ":", "Config", "::", "get", "(", "'var_platform'", ")", ";", "$", "p", "=", "is_null", "(", "$", "p", ")", "?", "$", "platform", ":", "$", "p", ";", "$", "c", "=", "is_null", "(", "$", "c", ")", "?", "$", "_GET", "[", "Config", "::", "get", "(", "'var_controller'", ")", "]", ":", "ucfirst", "(", "$", "c", ")", ";", "$", "a", "=", "is_null", "(", "$", "a", ")", "?", "$", "_GET", "[", "Config", "::", "get", "(", "'var_action'", ")", "]", ":", "ucfirst", "(", "$", "a", ")", ";", "$", "url", "=", "'index.php?'", ".", "Config", "::", "get", "(", "'var_platform'", ")", ".", "'='", ".", "$", "p", ".", "'&'", ".", "Config", "::", "get", "(", "'var_controller'", ")", ".", "'='", ".", "$", "c", ".", "'&'", ".", "Config", "::", "get", "(", "'var_action'", ")", ".", "'='", ".", "strtolower", "(", "$", "a", ")", ";", "break", ";", "case", "1", ";", "$", "url", "=", "'index.php/'", ".", "Config", "::", "get", "(", "'default_platform'", ")", ".", "'/'", ".", "$", "c", ".", "'/'", ".", "strtolower", "(", "$", "a", ")", ";", "break", ";", "}", "return", "$", "url", ";", "}" ]
Make::url方法自动生成URL @param $c [string] 需要设置跳转的控制器 默认为空获取当前控制器名 @param $a [string] 需要设置跳转的方法名 默认为空获取当前方法名 @param $p [string] 需要设置跳转的模块名 默认为空获取当前的模块名 @return url [string] 返回拼接好的URL跳转地址
[ "Make", "::", "url方法自动生成URL" ]
train
https://github.com/liugene/framework/blob/450642242442c5884d47552a588a2639923e7289/src/Make.php#L35-L50
liugene/framework
src/Make.php
Make.buildDir
public static function buildDir($list) { foreach ($list as $dir) { // 目录不存在则创建目录 !is_dir(APPLICATION_PATH . $dir) && mkdir(APPLICATION_PATH . $dir, 0755, true); } }
php
public static function buildDir($list) { foreach ($list as $dir) { // 目录不存在则创建目录 !is_dir(APPLICATION_PATH . $dir) && mkdir(APPLICATION_PATH . $dir, 0755, true); } }
[ "public", "static", "function", "buildDir", "(", "$", "list", ")", "{", "foreach", "(", "$", "list", "as", "$", "dir", ")", "{", "// 目录不存在则创建目录", "!", "is_dir", "(", "APPLICATION_PATH", ".", "$", "dir", ")", "&&", "mkdir", "(", "APPLICATION_PATH", ".", "$", "dir", ",", "0755", ",", "true", ")", ";", "}", "}" ]
创建目录 @access protected @param array $list 目录列表 @return void
[ "创建目录" ]
train
https://github.com/liugene/framework/blob/450642242442c5884d47552a588a2639923e7289/src/Make.php#L58-L64
mgallegos/decima-file
src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php
DecimaFileServiceProvider.boot
public function boot() { include __DIR__.'/../../routes.php'; // include __DIR__.'/../../helpers.php'; $this->loadViewsFrom(__DIR__.'/../../views', 'decima-file'); $this->loadTranslationsFrom(__DIR__.'/../../lang', 'decima-file'); $this->publishes([ __DIR__ . '/../../config/config.php' => config_path('file-general.php'), ], 'config'); $this->mergeConfigFrom( __DIR__ . '/../../config/config.php', 'file-general' ); $this->publishes([ __DIR__ . '/../../config/extensions.php' => config_path('file-extensions.php'), ], 'config'); $this->mergeConfigFrom( __DIR__ . '/../../config/extensions.php', 'file-extensions' ); $this->publishes([ __DIR__ . '/../../config/journal.php' => config_path('file-journal.php'), ], 'config'); $this->mergeConfigFrom( __DIR__ . '/../../config/journal.php', 'file-journal' ); $this->publishes([ __DIR__.'/../../migrations/' => database_path('/migrations') ], 'migrations'); $this->registerJournalConfiguration(); $this->registrerSecurityFileInterface(); $this->registrerFileInterface(); $this->registerFileManagementInterface(); }
php
public function boot() { include __DIR__.'/../../routes.php'; // include __DIR__.'/../../helpers.php'; $this->loadViewsFrom(__DIR__.'/../../views', 'decima-file'); $this->loadTranslationsFrom(__DIR__.'/../../lang', 'decima-file'); $this->publishes([ __DIR__ . '/../../config/config.php' => config_path('file-general.php'), ], 'config'); $this->mergeConfigFrom( __DIR__ . '/../../config/config.php', 'file-general' ); $this->publishes([ __DIR__ . '/../../config/extensions.php' => config_path('file-extensions.php'), ], 'config'); $this->mergeConfigFrom( __DIR__ . '/../../config/extensions.php', 'file-extensions' ); $this->publishes([ __DIR__ . '/../../config/journal.php' => config_path('file-journal.php'), ], 'config'); $this->mergeConfigFrom( __DIR__ . '/../../config/journal.php', 'file-journal' ); $this->publishes([ __DIR__.'/../../migrations/' => database_path('/migrations') ], 'migrations'); $this->registerJournalConfiguration(); $this->registrerSecurityFileInterface(); $this->registrerFileInterface(); $this->registerFileManagementInterface(); }
[ "public", "function", "boot", "(", ")", "{", "include", "__DIR__", ".", "'/../../routes.php'", ";", "// include __DIR__.'/../../helpers.php';", "$", "this", "->", "loadViewsFrom", "(", "__DIR__", ".", "'/../../views'", ",", "'decima-file'", ")", ";", "$", "this", "->", "loadTranslationsFrom", "(", "__DIR__", ".", "'/../../lang'", ",", "'decima-file'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../../config/config.php'", "=>", "config_path", "(", "'file-general.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/../../config/config.php'", ",", "'file-general'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../../config/extensions.php'", "=>", "config_path", "(", "'file-extensions.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/../../config/extensions.php'", ",", "'file-extensions'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../../config/journal.php'", "=>", "config_path", "(", "'file-journal.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/../../config/journal.php'", ",", "'file-journal'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../../migrations/'", "=>", "database_path", "(", "'/migrations'", ")", "]", ",", "'migrations'", ")", ";", "$", "this", "->", "registerJournalConfiguration", "(", ")", ";", "$", "this", "->", "registrerSecurityFileInterface", "(", ")", ";", "$", "this", "->", "registrerFileInterface", "(", ")", ";", "$", "this", "->", "registerFileManagementInterface", "(", ")", ";", "}" ]
Bootstrap any application services. @return void
[ "Bootstrap", "any", "application", "services", "." ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php#L21-L66
mgallegos/decima-file
src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php
DecimaFileServiceProvider.registrerSecurityFileInterface
protected function registrerSecurityFileInterface() { $this->app->bind('Mgallegos\DecimaFile\System\Repositories\File\FileInterface', function($app) { return new \Mgallegos\DecimaFile\System\Repositories\File\EloquentFile( new \Mgallegos\DecimaFile\System\File()); }); }
php
protected function registrerSecurityFileInterface() { $this->app->bind('Mgallegos\DecimaFile\System\Repositories\File\FileInterface', function($app) { return new \Mgallegos\DecimaFile\System\Repositories\File\EloquentFile( new \Mgallegos\DecimaFile\System\File()); }); }
[ "protected", "function", "registrerSecurityFileInterface", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'Mgallegos\\DecimaFile\\System\\Repositories\\File\\FileInterface'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "\\", "Mgallegos", "\\", "DecimaFile", "\\", "System", "\\", "Repositories", "\\", "File", "\\", "EloquentFile", "(", "new", "\\", "Mgallegos", "\\", "DecimaFile", "\\", "System", "\\", "File", "(", ")", ")", ";", "}", ")", ";", "}" ]
Register a ... interface instance. @return void
[ "Register", "a", "...", "interface", "instance", "." ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php#L95-L101
mgallegos/decima-file
src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php
DecimaFileServiceProvider.registrerFileInterface
protected function registrerFileInterface() { $this->app->bind('Mgallegos\DecimaFile\File\Repositories\File\FileInterface', function($app) { $AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'); return new \Mgallegos\DecimaFile\File\Repositories\File\EloquentFile( new \Mgallegos\DecimaFile\File\File() , $AuthenticationManager->getCurrentUserOrganizationConnection()); }); }
php
protected function registrerFileInterface() { $this->app->bind('Mgallegos\DecimaFile\File\Repositories\File\FileInterface', function($app) { $AuthenticationManager = $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'); return new \Mgallegos\DecimaFile\File\Repositories\File\EloquentFile( new \Mgallegos\DecimaFile\File\File() , $AuthenticationManager->getCurrentUserOrganizationConnection()); }); }
[ "protected", "function", "registrerFileInterface", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'Mgallegos\\DecimaFile\\File\\Repositories\\File\\FileInterface'", ",", "function", "(", "$", "app", ")", "{", "$", "AuthenticationManager", "=", "$", "app", "->", "make", "(", "'App\\Kwaai\\Security\\Services\\AuthenticationManagement\\AuthenticationManagementInterface'", ")", ";", "return", "new", "\\", "Mgallegos", "\\", "DecimaFile", "\\", "File", "\\", "Repositories", "\\", "File", "\\", "EloquentFile", "(", "new", "\\", "Mgallegos", "\\", "DecimaFile", "\\", "File", "\\", "File", "(", ")", ",", "$", "AuthenticationManager", "->", "getCurrentUserOrganizationConnection", "(", ")", ")", ";", "}", ")", ";", "}" ]
Register a ... interface instance. @return void
[ "Register", "a", "...", "interface", "instance", "." ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php#L108-L116
mgallegos/decima-file
src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php
DecimaFileServiceProvider.registerFileManagementInterface
protected function registerFileManagementInterface() { $this->app->bind('Mgallegos\DecimaFile\File\Services\FileManagement\FileManagementInterface', function($app) { return new \Mgallegos\DecimaFile\File\Services\FileManagement\FileManager( $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'), $app->make('App\Kwaai\Security\Services\AppManagement\AppManagementInterface'), $app->make('App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface'), $app->make('App\Kwaai\Security\Repositories\Journal\JournalInterface'), new \Mgallegos\LaravelJqgrid\Encoders\JqGridJsonEncoder($app->make('excel')), new \Mgallegos\DecimaFile\File\Repositories\File\EloquentFileGridRepository( $app['db'], $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'), $app['translator'] ), $app->make('Mgallegos\DecimaFile\File\Repositories\File\FileInterface'), $app->make('Mgallegos\DecimaFile\System\Repositories\File\FileInterface'), $app->make('image'), $app->make('AppJournalConfigurations'), new Carbon(), $app['db'], $app['translator'], $app['config'], $app['filesystem'], $app['request'], $app['url'], $app['Illuminate\Contracts\Routing\ResponseFactory'], $app['redirect'], $app['cache'] ); }); }
php
protected function registerFileManagementInterface() { $this->app->bind('Mgallegos\DecimaFile\File\Services\FileManagement\FileManagementInterface', function($app) { return new \Mgallegos\DecimaFile\File\Services\FileManagement\FileManager( $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'), $app->make('App\Kwaai\Security\Services\AppManagement\AppManagementInterface'), $app->make('App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface'), $app->make('App\Kwaai\Security\Repositories\Journal\JournalInterface'), new \Mgallegos\LaravelJqgrid\Encoders\JqGridJsonEncoder($app->make('excel')), new \Mgallegos\DecimaFile\File\Repositories\File\EloquentFileGridRepository( $app['db'], $app->make('App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface'), $app['translator'] ), $app->make('Mgallegos\DecimaFile\File\Repositories\File\FileInterface'), $app->make('Mgallegos\DecimaFile\System\Repositories\File\FileInterface'), $app->make('image'), $app->make('AppJournalConfigurations'), new Carbon(), $app['db'], $app['translator'], $app['config'], $app['filesystem'], $app['request'], $app['url'], $app['Illuminate\Contracts\Routing\ResponseFactory'], $app['redirect'], $app['cache'] ); }); }
[ "protected", "function", "registerFileManagementInterface", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'Mgallegos\\DecimaFile\\File\\Services\\FileManagement\\FileManagementInterface'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "\\", "Mgallegos", "\\", "DecimaFile", "\\", "File", "\\", "Services", "\\", "FileManagement", "\\", "FileManager", "(", "$", "app", "->", "make", "(", "'App\\Kwaai\\Security\\Services\\AuthenticationManagement\\AuthenticationManagementInterface'", ")", ",", "$", "app", "->", "make", "(", "'App\\Kwaai\\Security\\Services\\AppManagement\\AppManagementInterface'", ")", ",", "$", "app", "->", "make", "(", "'App\\Kwaai\\Security\\Services\\JournalManagement\\JournalManagementInterface'", ")", ",", "$", "app", "->", "make", "(", "'App\\Kwaai\\Security\\Repositories\\Journal\\JournalInterface'", ")", ",", "new", "\\", "Mgallegos", "\\", "LaravelJqgrid", "\\", "Encoders", "\\", "JqGridJsonEncoder", "(", "$", "app", "->", "make", "(", "'excel'", ")", ")", ",", "new", "\\", "Mgallegos", "\\", "DecimaFile", "\\", "File", "\\", "Repositories", "\\", "File", "\\", "EloquentFileGridRepository", "(", "$", "app", "[", "'db'", "]", ",", "$", "app", "->", "make", "(", "'App\\Kwaai\\Security\\Services\\AuthenticationManagement\\AuthenticationManagementInterface'", ")", ",", "$", "app", "[", "'translator'", "]", ")", ",", "$", "app", "->", "make", "(", "'Mgallegos\\DecimaFile\\File\\Repositories\\File\\FileInterface'", ")", ",", "$", "app", "->", "make", "(", "'Mgallegos\\DecimaFile\\System\\Repositories\\File\\FileInterface'", ")", ",", "$", "app", "->", "make", "(", "'image'", ")", ",", "$", "app", "->", "make", "(", "'AppJournalConfigurations'", ")", ",", "new", "Carbon", "(", ")", ",", "$", "app", "[", "'db'", "]", ",", "$", "app", "[", "'translator'", "]", ",", "$", "app", "[", "'config'", "]", ",", "$", "app", "[", "'filesystem'", "]", ",", "$", "app", "[", "'request'", "]", ",", "$", "app", "[", "'url'", "]", ",", "$", "app", "[", "'Illuminate\\Contracts\\Routing\\ResponseFactory'", "]", ",", "$", "app", "[", "'redirect'", "]", ",", "$", "app", "[", "'cache'", "]", ")", ";", "}", ")", ";", "}" ]
Register a ... interface instance. @return void
[ "Register", "a", "...", "interface", "instance", "." ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/DecimaFileServiceProvider.php#L123-L154
photogabble/laravel-remember-uploads
src/RememberUploadsServiceProvider.php
RememberUploadsServiceProvider.register
public function register() { $this->mergeConfigFrom( __DIR__.DIRECTORY_SEPARATOR.'config.php', 'remember-uploads' ); /** @var Router $router */ $router =$this->app->make(Router::class); $router->aliasMiddleware('remember.files', RememberFileUploads::class); }
php
public function register() { $this->mergeConfigFrom( __DIR__.DIRECTORY_SEPARATOR.'config.php', 'remember-uploads' ); /** @var Router $router */ $router =$this->app->make(Router::class); $router->aliasMiddleware('remember.files', RememberFileUploads::class); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "DIRECTORY_SEPARATOR", ".", "'config.php'", ",", "'remember-uploads'", ")", ";", "/** @var Router $router */", "$", "router", "=", "$", "this", "->", "app", "->", "make", "(", "Router", "::", "class", ")", ";", "$", "router", "->", "aliasMiddleware", "(", "'remember.files'", ",", "RememberFileUploads", "::", "class", ")", ";", "}" ]
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/photogabble/laravel-remember-uploads/blob/28d0667d2de74e5cd4f1980920df828cc5f99514/src/RememberUploadsServiceProvider.php#L35-L44
steeffeen/FancyManiaLinks
FML/Components/CheckBox.php
CheckBox.setEnabledDesign
public function setEnabledDesign($style, $subStyle = null) { if ($style instanceof CheckBoxDesign) { $this->feature->setEnabledDesign($style); } else { $checkBoxDesign = new CheckBoxDesign($style, $subStyle); $this->feature->setEnabledDesign($checkBoxDesign); } return $this; }
php
public function setEnabledDesign($style, $subStyle = null) { if ($style instanceof CheckBoxDesign) { $this->feature->setEnabledDesign($style); } else { $checkBoxDesign = new CheckBoxDesign($style, $subStyle); $this->feature->setEnabledDesign($checkBoxDesign); } return $this; }
[ "public", "function", "setEnabledDesign", "(", "$", "style", ",", "$", "subStyle", "=", "null", ")", "{", "if", "(", "$", "style", "instanceof", "CheckBoxDesign", ")", "{", "$", "this", "->", "feature", "->", "setEnabledDesign", "(", "$", "style", ")", ";", "}", "else", "{", "$", "checkBoxDesign", "=", "new", "CheckBoxDesign", "(", "$", "style", ",", "$", "subStyle", ")", ";", "$", "this", "->", "feature", "->", "setEnabledDesign", "(", "$", "checkBoxDesign", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the enabled design @api @param string|CheckBoxDesign $style Style name, image url or checkbox design @param string $subStyle SubStyle name @return static
[ "Set", "the", "enabled", "design" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBox.php#L124-L133
steeffeen/FancyManiaLinks
FML/Components/CheckBox.php
CheckBox.setDisabledDesign
public function setDisabledDesign($style, $subStyle = null) { if ($style instanceof CheckBoxDesign) { $this->feature->setDisabledDesign($style); } else { $checkBoxDesign = new CheckBoxDesign($style, $subStyle); $this->feature->setDisabledDesign($checkBoxDesign); } return $this; }
php
public function setDisabledDesign($style, $subStyle = null) { if ($style instanceof CheckBoxDesign) { $this->feature->setDisabledDesign($style); } else { $checkBoxDesign = new CheckBoxDesign($style, $subStyle); $this->feature->setDisabledDesign($checkBoxDesign); } return $this; }
[ "public", "function", "setDisabledDesign", "(", "$", "style", ",", "$", "subStyle", "=", "null", ")", "{", "if", "(", "$", "style", "instanceof", "CheckBoxDesign", ")", "{", "$", "this", "->", "feature", "->", "setDisabledDesign", "(", "$", "style", ")", ";", "}", "else", "{", "$", "checkBoxDesign", "=", "new", "CheckBoxDesign", "(", "$", "style", ",", "$", "subStyle", ")", ";", "$", "this", "->", "feature", "->", "setDisabledDesign", "(", "$", "checkBoxDesign", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the disabled design @api @param string|CheckBoxDesign $style Style name, image url or checkbox design @param string $subStyle SubStyle name @return static
[ "Set", "the", "disabled", "design" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBox.php#L154-L163
tomphp/patch-builder
src/TomPHP/PatchBuilder/LineTracker/LineTracker.php
LineTracker.trackLine
public function trackLine(LineNumber $lineNumber) { $this->trackedLine = $lineNumber->getNumber(); foreach ($this->actions as $action) { $actionLine = $action['line']; switch ($action['name']) { case 'add': $this->trackLineAdded($actionLine); break; case 'delete': $this->trackLineDeleted($actionLine, $lineNumber->getNumber()); } } return new ModifiedLineNumber($this->trackedLine); }
php
public function trackLine(LineNumber $lineNumber) { $this->trackedLine = $lineNumber->getNumber(); foreach ($this->actions as $action) { $actionLine = $action['line']; switch ($action['name']) { case 'add': $this->trackLineAdded($actionLine); break; case 'delete': $this->trackLineDeleted($actionLine, $lineNumber->getNumber()); } } return new ModifiedLineNumber($this->trackedLine); }
[ "public", "function", "trackLine", "(", "LineNumber", "$", "lineNumber", ")", "{", "$", "this", "->", "trackedLine", "=", "$", "lineNumber", "->", "getNumber", "(", ")", ";", "foreach", "(", "$", "this", "->", "actions", "as", "$", "action", ")", "{", "$", "actionLine", "=", "$", "action", "[", "'line'", "]", ";", "switch", "(", "$", "action", "[", "'name'", "]", ")", "{", "case", "'add'", ":", "$", "this", "->", "trackLineAdded", "(", "$", "actionLine", ")", ";", "break", ";", "case", "'delete'", ":", "$", "this", "->", "trackLineDeleted", "(", "$", "actionLine", ",", "$", "lineNumber", "->", "getNumber", "(", ")", ")", ";", "}", "}", "return", "new", "ModifiedLineNumber", "(", "$", "this", "->", "trackedLine", ")", ";", "}" ]
@param int $lineNumber @return int
[ "@param", "int", "$lineNumber" ]
train
https://github.com/tomphp/patch-builder/blob/4419eaad23016c7db1deffc6cce3f539096c11ce/src/TomPHP/PatchBuilder/LineTracker/LineTracker.php#L27-L45
barebone-php/barebone-core
lib/Config.php
Config.instance
public static function instance() { if (null === self::$_instance) { if (!defined('APP_ROOT')) { $path = __DIR__ . '/../../app/config.json'; } else { $path = APP_ROOT . 'config.json'; } if (!file_exists($path)) { $config = json_encode(self::$defaults, JSON_PRETTY_PRINT); file_put_contents($path, $config); } self::$_instance = new static($path); } return self::$_instance; }
php
public static function instance() { if (null === self::$_instance) { if (!defined('APP_ROOT')) { $path = __DIR__ . '/../../app/config.json'; } else { $path = APP_ROOT . 'config.json'; } if (!file_exists($path)) { $config = json_encode(self::$defaults, JSON_PRETTY_PRINT); file_put_contents($path, $config); } self::$_instance = new static($path); } return self::$_instance; }
[ "public", "static", "function", "instance", "(", ")", "{", "if", "(", "null", "===", "self", "::", "$", "_instance", ")", "{", "if", "(", "!", "defined", "(", "'APP_ROOT'", ")", ")", "{", "$", "path", "=", "__DIR__", ".", "'/../../app/config.json'", ";", "}", "else", "{", "$", "path", "=", "APP_ROOT", ".", "'config.json'", ";", "}", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "$", "config", "=", "json_encode", "(", "self", "::", "$", "defaults", ",", "JSON_PRETTY_PRINT", ")", ";", "file_put_contents", "(", "$", "path", ",", "$", "config", ")", ";", "}", "self", "::", "$", "_instance", "=", "new", "static", "(", "$", "path", ")", ";", "}", "return", "self", "::", "$", "_instance", ";", "}" ]
Instantiate Loader @return Config
[ "Instantiate", "Loader" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Config.php#L69-L85
barebone-php/barebone-core
lib/Config.php
Config.read
public static function read($key = '', $default = null) { if (empty($key)) { return self::instance()->all(); } if (!self::exists($key)) { return $default; } return self::instance()->get($key); }
php
public static function read($key = '', $default = null) { if (empty($key)) { return self::instance()->all(); } if (!self::exists($key)) { return $default; } return self::instance()->get($key); }
[ "public", "static", "function", "read", "(", "$", "key", "=", "''", ",", "$", "default", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "self", "::", "instance", "(", ")", "->", "all", "(", ")", ";", "}", "if", "(", "!", "self", "::", "exists", "(", "$", "key", ")", ")", "{", "return", "$", "default", ";", "}", "return", "self", "::", "instance", "(", ")", "->", "get", "(", "$", "key", ")", ";", "}" ]
Read configuration value @param string $key Configuration-Key Path @param mixed $default Default value if key is empty/not-found @return mixed
[ "Read", "configuration", "value" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Config.php#L95-L104
nyeholt/silverstripe-external-content
thirdparty/Zend/Validate/Ccnum.php
Zend_Validate_Ccnum.isValid
public function isValid($value) { $this->_setValue($value); if (null === self::$_filter) { /** * @see Zend_Filter_Digits */ require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } $valueFiltered = self::$_filter->filter($value); $length = strlen($valueFiltered); if ($length < 13 || $length > 19) { $this->_error(self::LENGTH); return false; } $sum = 0; $weight = 2; for ($i = $length - 2; $i >= 0; $i--) { $digit = $weight * $valueFiltered[$i]; $sum += floor($digit / 10) + $digit % 10; $weight = $weight % 2 + 1; } if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) { $this->_error(self::CHECKSUM, $valueFiltered); return false; } return true; }
php
public function isValid($value) { $this->_setValue($value); if (null === self::$_filter) { /** * @see Zend_Filter_Digits */ require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } $valueFiltered = self::$_filter->filter($value); $length = strlen($valueFiltered); if ($length < 13 || $length > 19) { $this->_error(self::LENGTH); return false; } $sum = 0; $weight = 2; for ($i = $length - 2; $i >= 0; $i--) { $digit = $weight * $valueFiltered[$i]; $sum += floor($digit / 10) + $digit % 10; $weight = $weight % 2 + 1; } if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) { $this->_error(self::CHECKSUM, $valueFiltered); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "this", "->", "_setValue", "(", "$", "value", ")", ";", "if", "(", "null", "===", "self", "::", "$", "_filter", ")", "{", "/**\n * @see Zend_Filter_Digits\n */", "require_once", "'Zend/Filter/Digits.php'", ";", "self", "::", "$", "_filter", "=", "new", "Zend_Filter_Digits", "(", ")", ";", "}", "$", "valueFiltered", "=", "self", "::", "$", "_filter", "->", "filter", "(", "$", "value", ")", ";", "$", "length", "=", "strlen", "(", "$", "valueFiltered", ")", ";", "if", "(", "$", "length", "<", "13", "||", "$", "length", ">", "19", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "LENGTH", ")", ";", "return", "false", ";", "}", "$", "sum", "=", "0", ";", "$", "weight", "=", "2", ";", "for", "(", "$", "i", "=", "$", "length", "-", "2", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "digit", "=", "$", "weight", "*", "$", "valueFiltered", "[", "$", "i", "]", ";", "$", "sum", "+=", "floor", "(", "$", "digit", "/", "10", ")", "+", "$", "digit", "%", "10", ";", "$", "weight", "=", "$", "weight", "%", "2", "+", "1", ";", "}", "if", "(", "(", "10", "-", "$", "sum", "%", "10", ")", "%", "10", "!=", "$", "valueFiltered", "[", "$", "length", "-", "1", "]", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "CHECKSUM", ",", "$", "valueFiltered", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Defined by Zend_Validate_Interface Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum) @param string $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/Ccnum.php#L73-L109
lmammino/e-foundation
src/Product/Model/AttributeValue.php
AttributeValue.setSubject
public function setSubject(AttributeSubjectInterface $subject = null) { $this->subject = $this->product = $subject; return $this; }
php
public function setSubject(AttributeSubjectInterface $subject = null) { $this->subject = $this->product = $subject; return $this; }
[ "public", "function", "setSubject", "(", "AttributeSubjectInterface", "$", "subject", "=", "null", ")", "{", "$", "this", "->", "subject", "=", "$", "this", "->", "product", "=", "$", "subject", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Product/Model/AttributeValue.php#L39-L44
anime-db/app-bundle
src/Service/Downloader.php
Downloader.download
public function download($url, $target, $override = false) { if (!$override && file_exists($target)) { return true; } $this->fs->mkdir(dirname($target), 0755); return $this->client ->get($url) ->setResponseBody($target) ->send() ->isSuccessful(); }
php
public function download($url, $target, $override = false) { if (!$override && file_exists($target)) { return true; } $this->fs->mkdir(dirname($target), 0755); return $this->client ->get($url) ->setResponseBody($target) ->send() ->isSuccessful(); }
[ "public", "function", "download", "(", "$", "url", ",", "$", "target", ",", "$", "override", "=", "false", ")", "{", "if", "(", "!", "$", "override", "&&", "file_exists", "(", "$", "target", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "fs", "->", "mkdir", "(", "dirname", "(", "$", "target", ")", ",", "0755", ")", ";", "return", "$", "this", "->", "client", "->", "get", "(", "$", "url", ")", "->", "setResponseBody", "(", "$", "target", ")", "->", "send", "(", ")", "->", "isSuccessful", "(", ")", ";", "}" ]
@param string $url @param string $target @param bool $override @return bool
[ "@param", "string", "$url", "@param", "string", "$target", "@param", "bool", "$override" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/Downloader.php#L96-L109
anime-db/app-bundle
src/Service/Downloader.php
Downloader.image
public function image($url, $target, $override = false) { if (!$this->download($url, $target, $override)) { return false; } // check file type $fi = new \finfo(FILEINFO_MIME_TYPE); if (strpos($fi->file($target), 'image/') !== 0) { unlink($target); // remove dangerous file return false; } return true; }
php
public function image($url, $target, $override = false) { if (!$this->download($url, $target, $override)) { return false; } // check file type $fi = new \finfo(FILEINFO_MIME_TYPE); if (strpos($fi->file($target), 'image/') !== 0) { unlink($target); // remove dangerous file return false; } return true; }
[ "public", "function", "image", "(", "$", "url", ",", "$", "target", ",", "$", "override", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "download", "(", "$", "url", ",", "$", "target", ",", "$", "override", ")", ")", "{", "return", "false", ";", "}", "// check file type", "$", "fi", "=", "new", "\\", "finfo", "(", "FILEINFO_MIME_TYPE", ")", ";", "if", "(", "strpos", "(", "$", "fi", "->", "file", "(", "$", "target", ")", ",", "'image/'", ")", "!==", "0", ")", "{", "unlink", "(", "$", "target", ")", ";", "// remove dangerous file", "return", "false", ";", "}", "return", "true", ";", "}" ]
@param string $url @param string $target @param bool $override @return bool
[ "@param", "string", "$url", "@param", "string", "$target", "@param", "bool", "$override" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/Downloader.php#L118-L132
anime-db/app-bundle
src/Service/Downloader.php
Downloader.isExists
public function isExists($url) { $request = $this->client->get($url); $request->getCurlOptions()->set(CURLOPT_NOBODY, true); try { return $request->send()->isSuccessful(); } catch (HttpException $e) { return false; } }
php
public function isExists($url) { $request = $this->client->get($url); $request->getCurlOptions()->set(CURLOPT_NOBODY, true); try { return $request->send()->isSuccessful(); } catch (HttpException $e) { return false; } }
[ "public", "function", "isExists", "(", "$", "url", ")", "{", "$", "request", "=", "$", "this", "->", "client", "->", "get", "(", "$", "url", ")", ";", "$", "request", "->", "getCurlOptions", "(", ")", "->", "set", "(", "CURLOPT_NOBODY", ",", "true", ")", ";", "try", "{", "return", "$", "request", "->", "send", "(", ")", "->", "isSuccessful", "(", ")", ";", "}", "catch", "(", "HttpException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
@param string $url @return bool
[ "@param", "string", "$url" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/Downloader.php#L139-L149
anime-db/app-bundle
src/Service/Downloader.php
Downloader.favicon
public function favicon($host, $override = false) { $target = $this->favicon_root.$host.'.ico'; if ($this->image(sprintf($this->favicon_proxy, $host), $target, $override)) { return $target; } return false; }
php
public function favicon($host, $override = false) { $target = $this->favicon_root.$host.'.ico'; if ($this->image(sprintf($this->favicon_proxy, $host), $target, $override)) { return $target; } return false; }
[ "public", "function", "favicon", "(", "$", "host", ",", "$", "override", "=", "false", ")", "{", "$", "target", "=", "$", "this", "->", "favicon_root", ".", "$", "host", ".", "'.ico'", ";", "if", "(", "$", "this", "->", "image", "(", "sprintf", "(", "$", "this", "->", "favicon_proxy", ",", "$", "host", ")", ",", "$", "target", ",", "$", "override", ")", ")", "{", "return", "$", "target", ";", "}", "return", "false", ";", "}" ]
@param string $host @param bool $override @return string|false
[ "@param", "string", "$host", "@param", "bool", "$override" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/Downloader.php#L157-L166
anime-db/app-bundle
src/Service/Downloader.php
Downloader.entity
public function entity($url, EntityInterface $entity, $override = false) { if (!($path = parse_url($url, PHP_URL_PATH))) { throw new \InvalidArgumentException('It is invalid URL: '.$url); } $entity->setFilename(pathinfo($path, PATHINFO_BASENAME)); $target = $this->root.$entity->getDownloadPath().'/'.$entity->getFilename(); if ($entity instanceof ImageInterface) { return $this->image($url, $target, $override); } else { return $this->download($url, $target, $override); } }
php
public function entity($url, EntityInterface $entity, $override = false) { if (!($path = parse_url($url, PHP_URL_PATH))) { throw new \InvalidArgumentException('It is invalid URL: '.$url); } $entity->setFilename(pathinfo($path, PATHINFO_BASENAME)); $target = $this->root.$entity->getDownloadPath().'/'.$entity->getFilename(); if ($entity instanceof ImageInterface) { return $this->image($url, $target, $override); } else { return $this->download($url, $target, $override); } }
[ "public", "function", "entity", "(", "$", "url", ",", "EntityInterface", "$", "entity", ",", "$", "override", "=", "false", ")", "{", "if", "(", "!", "(", "$", "path", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_PATH", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'It is invalid URL: '", ".", "$", "url", ")", ";", "}", "$", "entity", "->", "setFilename", "(", "pathinfo", "(", "$", "path", ",", "PATHINFO_BASENAME", ")", ")", ";", "$", "target", "=", "$", "this", "->", "root", ".", "$", "entity", "->", "getDownloadPath", "(", ")", ".", "'/'", ".", "$", "entity", "->", "getFilename", "(", ")", ";", "if", "(", "$", "entity", "instanceof", "ImageInterface", ")", "{", "return", "$", "this", "->", "image", "(", "$", "url", ",", "$", "target", ",", "$", "override", ")", ";", "}", "else", "{", "return", "$", "this", "->", "download", "(", "$", "url", ",", "$", "target", ",", "$", "override", ")", ";", "}", "}" ]
@param string $url @param EntityInterface $entity @param bool $override @return bool
[ "@param", "string", "$url", "@param", "EntityInterface", "$entity", "@param", "bool", "$override" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/Downloader.php#L175-L188
anime-db/app-bundle
src/Service/Downloader.php
Downloader.getTargetDirForImageField
protected function getTargetDirForImageField(Image $entity, $override = false) { $target = $this->root.$entity->getDownloadPath().'/'.$entity->getFilename(); if (!$override) { $target = $this->getUniqueFilename($target); $entity->setFilename(pathinfo($target, PATHINFO_BASENAME)); // update filename } return $target; }
php
protected function getTargetDirForImageField(Image $entity, $override = false) { $target = $this->root.$entity->getDownloadPath().'/'.$entity->getFilename(); if (!$override) { $target = $this->getUniqueFilename($target); $entity->setFilename(pathinfo($target, PATHINFO_BASENAME)); // update filename } return $target; }
[ "protected", "function", "getTargetDirForImageField", "(", "Image", "$", "entity", ",", "$", "override", "=", "false", ")", "{", "$", "target", "=", "$", "this", "->", "root", ".", "$", "entity", "->", "getDownloadPath", "(", ")", ".", "'/'", ".", "$", "entity", "->", "getFilename", "(", ")", ";", "if", "(", "!", "$", "override", ")", "{", "$", "target", "=", "$", "this", "->", "getUniqueFilename", "(", "$", "target", ")", ";", "$", "entity", "->", "setFilename", "(", "pathinfo", "(", "$", "target", ",", "PATHINFO_BASENAME", ")", ")", ";", "// update filename", "}", "return", "$", "target", ";", "}" ]
@param Image $entity @param bool $override @return string
[ "@param", "Image", "$entity", "@param", "bool", "$override" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/Downloader.php#L247-L256
anime-db/app-bundle
src/Service/Downloader.php
Downloader.getUniqueFilename
public function getUniqueFilename($filename) { $info = pathinfo($filename); $name = $info['filename']; $ext = isset($info['extension']) ? '.'.$info['extension'] : ''; for ($i = 1; file_exists($info['dirname'].'/'.$name.$ext); ++$i) { $name = $info['filename'].'['.$i.']'; } return $info['dirname'].'/'.$name.$ext; }
php
public function getUniqueFilename($filename) { $info = pathinfo($filename); $name = $info['filename']; $ext = isset($info['extension']) ? '.'.$info['extension'] : ''; for ($i = 1; file_exists($info['dirname'].'/'.$name.$ext); ++$i) { $name = $info['filename'].'['.$i.']'; } return $info['dirname'].'/'.$name.$ext; }
[ "public", "function", "getUniqueFilename", "(", "$", "filename", ")", "{", "$", "info", "=", "pathinfo", "(", "$", "filename", ")", ";", "$", "name", "=", "$", "info", "[", "'filename'", "]", ";", "$", "ext", "=", "isset", "(", "$", "info", "[", "'extension'", "]", ")", "?", "'.'", ".", "$", "info", "[", "'extension'", "]", ":", "''", ";", "for", "(", "$", "i", "=", "1", ";", "file_exists", "(", "$", "info", "[", "'dirname'", "]", ".", "'/'", ".", "$", "name", ".", "$", "ext", ")", ";", "++", "$", "i", ")", "{", "$", "name", "=", "$", "info", "[", "'filename'", "]", ".", "'['", ".", "$", "i", ".", "']'", ";", "}", "return", "$", "info", "[", "'dirname'", "]", ".", "'/'", ".", "$", "name", ".", "$", "ext", ";", "}" ]
@param string $filename @return string
[ "@param", "string", "$filename" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/Downloader.php#L263-L273
koriym/Koriym.QueryLocator
src/QueryLocatorModule.php
QueryLocatorModule.configure
protected function configure() { $this->bind()->annotatedWith('sql_dir')->toInstance($this->sqlDir); $this->bind(QueryLocatorInterface::class)->toConstructor(QueryLocator::class, 'sqlDir=sql_dir'); }
php
protected function configure() { $this->bind()->annotatedWith('sql_dir')->toInstance($this->sqlDir); $this->bind(QueryLocatorInterface::class)->toConstructor(QueryLocator::class, 'sqlDir=sql_dir'); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "bind", "(", ")", "->", "annotatedWith", "(", "'sql_dir'", ")", "->", "toInstance", "(", "$", "this", "->", "sqlDir", ")", ";", "$", "this", "->", "bind", "(", "QueryLocatorInterface", "::", "class", ")", "->", "toConstructor", "(", "QueryLocator", "::", "class", ",", "'sqlDir=sql_dir'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/koriym/Koriym.QueryLocator/blob/4e9b9ecfdd99c4850e39e88204a597af503c3823/src/QueryLocatorModule.php#L25-L29
GrafiteInc/Mission-Control-Package
src/WebhookService.php
WebhookService.send
public function send($title, $content, $flag) { $headers = []; $query = [ 'title' => $title, 'content' => $content, 'flag' => $flag, ]; if (is_null($this->webhook)) { throw new Exception("Missing webhook", 1); } $response = $this->curl::post($this->webhook, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your webhook'); } return true; }
php
public function send($title, $content, $flag) { $headers = []; $query = [ 'title' => $title, 'content' => $content, 'flag' => $flag, ]; if (is_null($this->webhook)) { throw new Exception("Missing webhook", 1); } $response = $this->curl::post($this->webhook, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your webhook'); } return true; }
[ "public", "function", "send", "(", "$", "title", ",", "$", "content", ",", "$", "flag", ")", "{", "$", "headers", "=", "[", "]", ";", "$", "query", "=", "[", "'title'", "=>", "$", "title", ",", "'content'", "=>", "$", "content", ",", "'flag'", "=>", "$", "flag", ",", "]", ";", "if", "(", "is_null", "(", "$", "this", "->", "webhook", ")", ")", "{", "throw", "new", "Exception", "(", "\"Missing webhook\"", ",", "1", ")", ";", "}", "$", "response", "=", "$", "this", "->", "curl", "::", "post", "(", "$", "this", "->", "webhook", ",", "$", "headers", ",", "$", "query", ")", ";", "if", "(", "$", "response", "->", "code", "!=", "200", ")", "{", "$", "this", "->", "error", "(", "'Unable to message Mission Control, please confirm your webhook'", ")", ";", "}", "return", "true", ";", "}" ]
Send the data to Mission Control @param string $title @param string $content @param string $flag @return bool
[ "Send", "the", "data", "to", "Mission", "Control" ]
train
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/WebhookService.php#L30-L52
fubhy/graphql-php
src/Type/Definition/Types/ObjectType.php
ObjectType.getField
public function getField($field) { $fields = $this->getFields(); if (!isset($fields[$field])) { throw new \LogicException(sprintf('Undefined field %s.', $field)); } return $fields[$field]; }
php
public function getField($field) { $fields = $this->getFields(); if (!isset($fields[$field])) { throw new \LogicException(sprintf('Undefined field %s.', $field)); } return $fields[$field]; }
[ "public", "function", "getField", "(", "$", "field", ")", "{", "$", "fields", "=", "$", "this", "->", "getFields", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "fields", "[", "$", "field", "]", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Undefined field %s.'", ",", "$", "field", ")", ")", ";", "}", "return", "$", "fields", "[", "$", "field", "]", ";", "}" ]
@param string $field @return \Fubhy\GraphQL\Type\Definition\FieldDefinition
[ "@param", "string", "$field" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Type/Definition/Types/ObjectType.php#L95-L103
fubhy/graphql-php
src/Type/Definition/Types/ObjectType.php
ObjectType.isTypeOf
public function isTypeOf($value) { return isset($this->isTypeOf) ? call_user_func($this->isTypeOf, $value) : NULL; }
php
public function isTypeOf($value) { return isset($this->isTypeOf) ? call_user_func($this->isTypeOf, $value) : NULL; }
[ "public", "function", "isTypeOf", "(", "$", "value", ")", "{", "return", "isset", "(", "$", "this", "->", "isTypeOf", ")", "?", "call_user_func", "(", "$", "this", "->", "isTypeOf", ",", "$", "value", ")", ":", "NULL", ";", "}" ]
@param mixed $value @return bool|null
[ "@param", "mixed", "$value" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Type/Definition/Types/ObjectType.php#L118-L121
shrink0r/workflux
src/State/StateSet.php
StateSet.add
public function add(StateInterface $state): self { $cloned_set = clone $this; $cloned_set->internal_set->add($state); return $cloned_set; }
php
public function add(StateInterface $state): self { $cloned_set = clone $this; $cloned_set->internal_set->add($state); return $cloned_set; }
[ "public", "function", "add", "(", "StateInterface", "$", "state", ")", ":", "self", "{", "$", "cloned_set", "=", "clone", "$", "this", ";", "$", "cloned_set", "->", "internal_set", "->", "add", "(", "$", "state", ")", ";", "return", "$", "cloned_set", ";", "}" ]
@param StateInterface @return self
[ "@param", "StateInterface" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/State/StateSet.php#L69-L75
aedart/config-loader
src/Providers/ConfigurationLoaderServiceProvider.php
ConfigurationLoaderServiceProvider.register
public function register() { $this->app->singleton(ParserFactoryInterface::class, function ($application) { return new DefaultParserFactory(); }); $this->app->bind(ConfigLoaderInterface::class, function ($application) { return new ConfigLoader(); }); }
php
public function register() { $this->app->singleton(ParserFactoryInterface::class, function ($application) { return new DefaultParserFactory(); }); $this->app->bind(ConfigLoaderInterface::class, function ($application) { return new ConfigLoader(); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "ParserFactoryInterface", "::", "class", ",", "function", "(", "$", "application", ")", "{", "return", "new", "DefaultParserFactory", "(", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "ConfigLoaderInterface", "::", "class", ",", "function", "(", "$", "application", ")", "{", "return", "new", "ConfigLoader", "(", ")", ";", "}", ")", ";", "}" ]
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/aedart/config-loader/blob/9e1cf592bee46ba4930bb9c352aaf475d81266ea/src/Providers/ConfigurationLoaderServiceProvider.php#L28-L37
ARCANEDEV/Sanitizer
src/Filters/FormatDateFilter.php
FormatDateFilter.filter
public function filter($value, array $options = []) { if ( ! is_string($value) || empty(trim($value))) return $value; $this->checkOptions($options); list($currentFormat, $targetFormat) = array_map('trim', $options); return DateTime::createFromFormat($currentFormat, $value)->format($targetFormat); }
php
public function filter($value, array $options = []) { if ( ! is_string($value) || empty(trim($value))) return $value; $this->checkOptions($options); list($currentFormat, $targetFormat) = array_map('trim', $options); return DateTime::createFromFormat($currentFormat, $value)->format($targetFormat); }
[ "public", "function", "filter", "(", "$", "value", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "is_string", "(", "$", "value", ")", "||", "empty", "(", "trim", "(", "$", "value", ")", ")", ")", "return", "$", "value", ";", "$", "this", "->", "checkOptions", "(", "$", "options", ")", ";", "list", "(", "$", "currentFormat", ",", "$", "targetFormat", ")", "=", "array_map", "(", "'trim'", ",", "$", "options", ")", ";", "return", "DateTime", "::", "createFromFormat", "(", "$", "currentFormat", ",", "$", "value", ")", "->", "format", "(", "$", "targetFormat", ")", ";", "}" ]
Format date of the given string. @param mixed $value @param array $options @return string|mixed
[ "Format", "date", "of", "the", "given", "string", "." ]
train
https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Filters/FormatDateFilter.php#L27-L37
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionIndex
public function actionIndex() { $auth = \Yii::$app->getAuthManager(); $items = $auth->getRoles(); $dataProvider = new ArrayDataProvider(); $dataProvider->setModels($items); return $this->render('index',[ 'dataProvider' => $dataProvider, ]); }
php
public function actionIndex() { $auth = \Yii::$app->getAuthManager(); $items = $auth->getRoles(); $dataProvider = new ArrayDataProvider(); $dataProvider->setModels($items); return $this->render('index',[ 'dataProvider' => $dataProvider, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "items", "=", "$", "auth", "->", "getRoles", "(", ")", ";", "$", "dataProvider", "=", "new", "ArrayDataProvider", "(", ")", ";", "$", "dataProvider", "->", "setModels", "(", "$", "items", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'dataProvider'", "=>", "$", "dataProvider", ",", "]", ")", ";", "}" ]
角色列表
[ "角色列表" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L16-L25
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionCreate
public function actionCreate() { $model = new RoleForm(); $model->isNewRecord = true; if($model->load(\Yii::$app->getRequest()->post())) { $auth = \Yii::$app->getAuthManager(); if($auth->getRole($model->name)) { $model->addError('name','角色标识已存在'); } else { $item = $auth->createRole($model->name); $item->description = $model->description; if($auth->add($item)) { return $this->redirect(['index']); } } } return $this->render('create',[ 'model'=>$model ]); }
php
public function actionCreate() { $model = new RoleForm(); $model->isNewRecord = true; if($model->load(\Yii::$app->getRequest()->post())) { $auth = \Yii::$app->getAuthManager(); if($auth->getRole($model->name)) { $model->addError('name','角色标识已存在'); } else { $item = $auth->createRole($model->name); $item->description = $model->description; if($auth->add($item)) { return $this->redirect(['index']); } } } return $this->render('create',[ 'model'=>$model ]); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "RoleForm", "(", ")", ";", "$", "model", "->", "isNewRecord", "=", "true", ";", "if", "(", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", ")", ")", ")", "{", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "if", "(", "$", "auth", "->", "getRole", "(", "$", "model", "->", "name", ")", ")", "{", "$", "model", "->", "addError", "(", "'name'", ",", "'角色标识已存在');", "", "", "}", "else", "{", "$", "item", "=", "$", "auth", "->", "createRole", "(", "$", "model", "->", "name", ")", ";", "$", "item", "->", "description", "=", "$", "model", "->", "description", ";", "if", "(", "$", "auth", "->", "add", "(", "$", "item", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}", "}", "}", "return", "$", "this", "->", "render", "(", "'create'", ",", "[", "'model'", "=>", "$", "model", "]", ")", ";", "}" ]
创建角色
[ "创建角色" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L28-L47
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionUpdate
public function actionUpdate($id) { $name = $id; $model = new RoleForm(); $model->isNewRecord = false; $auth = \Yii::$app->getAuthManager(); $item = $auth->getRole($name); if($model->load(\Yii::$app->getRequest()->post())) { $item->name = $model->name; $item->description = $model->description; if($auth->update($name,$item)) { return $this->redirect(['index']); } } $model->name = $name; $model->description = $item->description; return $this->render('update',[ 'model' => $model ]); }
php
public function actionUpdate($id) { $name = $id; $model = new RoleForm(); $model->isNewRecord = false; $auth = \Yii::$app->getAuthManager(); $item = $auth->getRole($name); if($model->load(\Yii::$app->getRequest()->post())) { $item->name = $model->name; $item->description = $model->description; if($auth->update($name,$item)) { return $this->redirect(['index']); } } $model->name = $name; $model->description = $item->description; return $this->render('update',[ 'model' => $model ]); }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "name", "=", "$", "id", ";", "$", "model", "=", "new", "RoleForm", "(", ")", ";", "$", "model", "->", "isNewRecord", "=", "false", ";", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "item", "=", "$", "auth", "->", "getRole", "(", "$", "name", ")", ";", "if", "(", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", ")", ")", ")", "{", "$", "item", "->", "name", "=", "$", "model", "->", "name", ";", "$", "item", "->", "description", "=", "$", "model", "->", "description", ";", "if", "(", "$", "auth", "->", "update", "(", "$", "name", ",", "$", "item", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}", "}", "$", "model", "->", "name", "=", "$", "name", ";", "$", "model", "->", "description", "=", "$", "item", "->", "description", ";", "return", "$", "this", "->", "render", "(", "'update'", ",", "[", "'model'", "=>", "$", "model", "]", ")", ";", "}" ]
更新角色
[ "更新角色" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L76-L95
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionView
public function actionView($id) { $name = $id; $auth = \Yii::$app->getAuthManager(); $item = $auth->getRole($name); return $this->render('view',[ 'item' => $item ]); }
php
public function actionView($id) { $name = $id; $auth = \Yii::$app->getAuthManager(); $item = $auth->getRole($name); return $this->render('view',[ 'item' => $item ]); }
[ "public", "function", "actionView", "(", "$", "id", ")", "{", "$", "name", "=", "$", "id", ";", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "item", "=", "$", "auth", "->", "getRole", "(", "$", "name", ")", ";", "return", "$", "this", "->", "render", "(", "'view'", ",", "[", "'item'", "=>", "$", "item", "]", ")", ";", "}" ]
查看角色详细信息
[ "查看角色详细信息" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L98-L106
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionUserindex
public function actionUserindex($id) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($id); $roleUserIds = $auth->getUserIdsByRole($id); $dataProvider = new ActiveDataProvider([ 'query' => $auth->getUserQuery()->where('`status`!=9'), 'pagination' => [ 'pageSize' => 20, ], ]); return $this->render('userindex',[ 'dataProvider' => $dataProvider, 'role' => $role, 'roleUserIds' => $roleUserIds ]); }
php
public function actionUserindex($id) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($id); $roleUserIds = $auth->getUserIdsByRole($id); $dataProvider = new ActiveDataProvider([ 'query' => $auth->getUserQuery()->where('`status`!=9'), 'pagination' => [ 'pageSize' => 20, ], ]); return $this->render('userindex',[ 'dataProvider' => $dataProvider, 'role' => $role, 'roleUserIds' => $roleUserIds ]); }
[ "public", "function", "actionUserindex", "(", "$", "id", ")", "{", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "role", "=", "$", "auth", "->", "getRole", "(", "$", "id", ")", ";", "$", "roleUserIds", "=", "$", "auth", "->", "getUserIdsByRole", "(", "$", "id", ")", ";", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "auth", "->", "getUserQuery", "(", ")", "->", "where", "(", "'`status`!=9'", ")", ",", "'pagination'", "=>", "[", "'pageSize'", "=>", "20", ",", "]", ",", "]", ")", ";", "return", "$", "this", "->", "render", "(", "'userindex'", ",", "[", "'dataProvider'", "=>", "$", "dataProvider", ",", "'role'", "=>", "$", "role", ",", "'roleUserIds'", "=>", "$", "roleUserIds", "]", ")", ";", "}" ]
查看角色用户列表
[ "查看角色用户列表" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L109-L125
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionSetuser
public function actionSetuser($name) { if (\Yii::$app->getRequest()->getIsPost() && isset($_POST['act'],$_POST['val'])) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($name); try { $flag = true; if($_POST['act'] == 'add') { if(!$auth->assign($role,$_POST['val'])) $flag = false; } else if($_POST['act'] == 'del') { if(!$auth->revoke($role,$_POST['val'])) $flag = false; } else { $flag = false; } return $flag ? 1 : 0; } catch(\Exception $e) { return 0; } } return $this->redirect(['index']); }
php
public function actionSetuser($name) { if (\Yii::$app->getRequest()->getIsPost() && isset($_POST['act'],$_POST['val'])) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($name); try { $flag = true; if($_POST['act'] == 'add') { if(!$auth->assign($role,$_POST['val'])) $flag = false; } else if($_POST['act'] == 'del') { if(!$auth->revoke($role,$_POST['val'])) $flag = false; } else { $flag = false; } return $flag ? 1 : 0; } catch(\Exception $e) { return 0; } } return $this->redirect(['index']); }
[ "public", "function", "actionSetuser", "(", "$", "name", ")", "{", "if", "(", "\\", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "getIsPost", "(", ")", "&&", "isset", "(", "$", "_POST", "[", "'act'", "]", ",", "$", "_POST", "[", "'val'", "]", ")", ")", "{", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "role", "=", "$", "auth", "->", "getRole", "(", "$", "name", ")", ";", "try", "{", "$", "flag", "=", "true", ";", "if", "(", "$", "_POST", "[", "'act'", "]", "==", "'add'", ")", "{", "if", "(", "!", "$", "auth", "->", "assign", "(", "$", "role", ",", "$", "_POST", "[", "'val'", "]", ")", ")", "$", "flag", "=", "false", ";", "}", "else", "if", "(", "$", "_POST", "[", "'act'", "]", "==", "'del'", ")", "{", "if", "(", "!", "$", "auth", "->", "revoke", "(", "$", "role", ",", "$", "_POST", "[", "'val'", "]", ")", ")", "$", "flag", "=", "false", ";", "}", "else", "{", "$", "flag", "=", "false", ";", "}", "return", "$", "flag", "?", "1", ":", "0", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "0", ";", "}", "}", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}" ]
设置角色用户
[ "设置角色用户" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L128-L148
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionPermissionindex
public function actionPermissionindex($id) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($id); $allItems = $auth->getPermissions(); $roleItems = $auth->getPermissionsByRole($id); $ownItems = $auth->getChildren($id); // var_dump($roleItems);exit(); $dataProvider = new ArrayDataProvider(); $dataProvider->setModels($allItems); return $this->render('permissionindex',[ 'dataProvider' => $dataProvider, 'allItems' => $allItems, 'roleItems' => $roleItems, 'ownItems' => $ownItems, 'role' => $role ]); }
php
public function actionPermissionindex($id) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($id); $allItems = $auth->getPermissions(); $roleItems = $auth->getPermissionsByRole($id); $ownItems = $auth->getChildren($id); // var_dump($roleItems);exit(); $dataProvider = new ArrayDataProvider(); $dataProvider->setModels($allItems); return $this->render('permissionindex',[ 'dataProvider' => $dataProvider, 'allItems' => $allItems, 'roleItems' => $roleItems, 'ownItems' => $ownItems, 'role' => $role ]); }
[ "public", "function", "actionPermissionindex", "(", "$", "id", ")", "{", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "role", "=", "$", "auth", "->", "getRole", "(", "$", "id", ")", ";", "$", "allItems", "=", "$", "auth", "->", "getPermissions", "(", ")", ";", "$", "roleItems", "=", "$", "auth", "->", "getPermissionsByRole", "(", "$", "id", ")", ";", "$", "ownItems", "=", "$", "auth", "->", "getChildren", "(", "$", "id", ")", ";", "// var_dump($roleItems);exit();", "$", "dataProvider", "=", "new", "ArrayDataProvider", "(", ")", ";", "$", "dataProvider", "->", "setModels", "(", "$", "allItems", ")", ";", "return", "$", "this", "->", "render", "(", "'permissionindex'", ",", "[", "'dataProvider'", "=>", "$", "dataProvider", ",", "'allItems'", "=>", "$", "allItems", ",", "'roleItems'", "=>", "$", "roleItems", ",", "'ownItems'", "=>", "$", "ownItems", ",", "'role'", "=>", "$", "role", "]", ")", ";", "}" ]
查看角色权限列表
[ "查看角色权限列表" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L151-L168
JeanWolf/yii2-jrbac
controllers/RoleController.php
RoleController.actionSubindex
public function actionSubindex($id) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($id); $allItems = $auth->getRoles(); $subItems = $auth->getChildren($id); $dataProvider = new ArrayDataProvider(); $dataProvider->setModels($allItems); return $this->render('subindex',[ 'dataProvider' => $dataProvider, 'allItems' => $allItems, 'subItems' => $subItems, 'role' => $role ]); }
php
public function actionSubindex($id) { $auth = \Yii::$app->getAuthManager(); $role = $auth->getRole($id); $allItems = $auth->getRoles(); $subItems = $auth->getChildren($id); $dataProvider = new ArrayDataProvider(); $dataProvider->setModels($allItems); return $this->render('subindex',[ 'dataProvider' => $dataProvider, 'allItems' => $allItems, 'subItems' => $subItems, 'role' => $role ]); }
[ "public", "function", "actionSubindex", "(", "$", "id", ")", "{", "$", "auth", "=", "\\", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "role", "=", "$", "auth", "->", "getRole", "(", "$", "id", ")", ";", "$", "allItems", "=", "$", "auth", "->", "getRoles", "(", ")", ";", "$", "subItems", "=", "$", "auth", "->", "getChildren", "(", "$", "id", ")", ";", "$", "dataProvider", "=", "new", "ArrayDataProvider", "(", ")", ";", "$", "dataProvider", "->", "setModels", "(", "$", "allItems", ")", ";", "return", "$", "this", "->", "render", "(", "'subindex'", ",", "[", "'dataProvider'", "=>", "$", "dataProvider", ",", "'allItems'", "=>", "$", "allItems", ",", "'subItems'", "=>", "$", "subItems", ",", "'role'", "=>", "$", "role", "]", ")", ";", "}" ]
子角色列表
[ "子角色列表" ]
train
https://github.com/JeanWolf/yii2-jrbac/blob/1e5c80038451bd5b385f83cb9344c3bd5edd85e0/controllers/RoleController.php#L195-L209
fubhy/graphql-php
src/Type/Definition/Types/Scalars/IntType.php
IntType.coerce
public function coerce($value) { if ((is_numeric($value) && $value <= PHP_INT_MAX && $value >= -PHP_INT_MAX) || is_bool($value)) { return (int) $value; } return NULL; }
php
public function coerce($value) { if ((is_numeric($value) && $value <= PHP_INT_MAX && $value >= -PHP_INT_MAX) || is_bool($value)) { return (int) $value; } return NULL; }
[ "public", "function", "coerce", "(", "$", "value", ")", "{", "if", "(", "(", "is_numeric", "(", "$", "value", ")", "&&", "$", "value", "<=", "PHP_INT_MAX", "&&", "$", "value", ">=", "-", "PHP_INT_MAX", ")", "||", "is_bool", "(", "$", "value", ")", ")", "{", "return", "(", "int", ")", "$", "value", ";", "}", "return", "NULL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Type/Definition/Types/Scalars/IntType.php#L19-L26
fubhy/graphql-php
src/Type/Definition/Types/Scalars/IntType.php
IntType.coerceLiteral
public function coerceLiteral(Node $node) { if ($node instanceof IntValue) { $num = $node->get('value'); if ($num <= PHP_INT_MAX && $num >= -PHP_INT_MAX) { return intval($num); } } return NULL; }
php
public function coerceLiteral(Node $node) { if ($node instanceof IntValue) { $num = $node->get('value'); if ($num <= PHP_INT_MAX && $num >= -PHP_INT_MAX) { return intval($num); } } return NULL; }
[ "public", "function", "coerceLiteral", "(", "Node", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "IntValue", ")", "{", "$", "num", "=", "$", "node", "->", "get", "(", "'value'", ")", ";", "if", "(", "$", "num", "<=", "PHP_INT_MAX", "&&", "$", "num", ">=", "-", "PHP_INT_MAX", ")", "{", "return", "intval", "(", "$", "num", ")", ";", "}", "}", "return", "NULL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Type/Definition/Types/Scalars/IntType.php#L31-L42
inpsyde/inpsyde-filter
src/ArrayValue.php
ArrayValue.add_filter_by_key
public function add_filter_by_key( FilterInterface $filter, $key ) { if ( ! is_scalar( $key ) ) { throw new Exception\InvalidArgumentException( 'key should be a scalar value.' ); } $key = (string) $key; if ( ! isset ( $this->filters_by_key[ $key ] ) ) { $this->filters_by_key[ $key ] = [ ]; } $this->filters_by_key[ $key ][] = $filter; return $this; }
php
public function add_filter_by_key( FilterInterface $filter, $key ) { if ( ! is_scalar( $key ) ) { throw new Exception\InvalidArgumentException( 'key should be a scalar value.' ); } $key = (string) $key; if ( ! isset ( $this->filters_by_key[ $key ] ) ) { $this->filters_by_key[ $key ] = [ ]; } $this->filters_by_key[ $key ][] = $filter; return $this; }
[ "public", "function", "add_filter_by_key", "(", "FilterInterface", "$", "filter", ",", "$", "key", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "key", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'key should be a scalar value.'", ")", ";", "}", "$", "key", "=", "(", "string", ")", "$", "key", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "filters_by_key", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "filters_by_key", "[", "$", "key", "]", "=", "[", "]", ";", "}", "$", "this", "->", "filters_by_key", "[", "$", "key", "]", "[", "]", "=", "$", "filter", ";", "return", "$", "this", ";", "}" ]
Adding a filter grouped by array key. @throws Exception\InvalidArgumentException if type of $key is not scalar. @param FilterInterface $filter @param $key @return ArrayValue
[ "Adding", "a", "filter", "grouped", "by", "array", "key", "." ]
train
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/ArrayValue.php#L50-L65
inpsyde/inpsyde-filter
src/ArrayValue.php
ArrayValue.filter
public function filter( $values ) { if ( ! is_array( $values )&& ! $values instanceof \Traversable ) { return $values; } $values = $this->all_filters( $values ); $values = $this->filter_by_key( $values ); return $values; }
php
public function filter( $values ) { if ( ! is_array( $values )&& ! $values instanceof \Traversable ) { return $values; } $values = $this->all_filters( $values ); $values = $this->filter_by_key( $values ); return $values; }
[ "public", "function", "filter", "(", "$", "values", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", "&&", "!", "$", "values", "instanceof", "\\", "Traversable", ")", "{", "return", "$", "values", ";", "}", "$", "values", "=", "$", "this", "->", "all_filters", "(", "$", "values", ")", ";", "$", "values", "=", "$", "this", "->", "filter_by_key", "(", "$", "values", ")", ";", "return", "$", "values", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/ArrayValue.php#L70-L81
inpsyde/inpsyde-filter
src/ArrayValue.php
ArrayValue.all_filters
private function all_filters( $values ) { foreach ( $values as $key => $value ) { foreach ( $this->filters as $filter ) { $values[ $key ] = $filter->filter( $value ); } } return $values; }
php
private function all_filters( $values ) { foreach ( $values as $key => $value ) { foreach ( $this->filters as $filter ) { $values[ $key ] = $filter->filter( $value ); } } return $values; }
[ "private", "function", "all_filters", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "filters", "as", "$", "filter", ")", "{", "$", "values", "[", "$", "key", "]", "=", "$", "filter", "->", "filter", "(", "$", "value", ")", ";", "}", "}", "return", "$", "values", ";", "}" ]
@param mixed $values @return mixed
[ "@param", "mixed", "$values" ]
train
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/ArrayValue.php#L88-L97
inpsyde/inpsyde-filter
src/ArrayValue.php
ArrayValue.filter_by_key
protected function filter_by_key( $values ) { if ( count( $this->filters_by_key ) < 1 ) { return $values; } foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) || ! isset( $this->filters_by_key[ $key ] ) ) { continue; } /** @var FilterInterface[] */ $filters = $this->filters_by_key[ $key ]; foreach ( $filters as $filter ) { $values[ $key ] = $filter->filter( $value ); } } return $values; }
php
protected function filter_by_key( $values ) { if ( count( $this->filters_by_key ) < 1 ) { return $values; } foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) || ! isset( $this->filters_by_key[ $key ] ) ) { continue; } /** @var FilterInterface[] */ $filters = $this->filters_by_key[ $key ]; foreach ( $filters as $filter ) { $values[ $key ] = $filter->filter( $value ); } } return $values; }
[ "protected", "function", "filter_by_key", "(", "$", "values", ")", "{", "if", "(", "count", "(", "$", "this", "->", "filters_by_key", ")", "<", "1", ")", "{", "return", "$", "values", ";", "}", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "value", ")", "||", "!", "isset", "(", "$", "this", "->", "filters_by_key", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "/** @var FilterInterface[] */", "$", "filters", "=", "$", "this", "->", "filters_by_key", "[", "$", "key", "]", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "$", "values", "[", "$", "key", "]", "=", "$", "filter", "->", "filter", "(", "$", "value", ")", ";", "}", "}", "return", "$", "values", ";", "}" ]
Filters all values by array-key. @param mixed $values @return mixed $value
[ "Filters", "all", "values", "by", "array", "-", "key", "." ]
train
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/ArrayValue.php#L106-L125
tomphp/siren-php
src/EntityBuilder.php
EntityBuilder.addLink
public function addLink( $linkOrRel, string $href = null, $classes = [], string $title = null, string $type = null ) : self { $link = $linkOrRel; if (!$linkOrRel instanceof Link) { $rels = is_array($linkOrRel) ? $linkOrRel : [$linkOrRel]; $classes = is_array($classes) ? $classes : [$classes]; $link = new Link($rels, $href, $classes, $title, $type); } $this->links[] = $link; return $this; }
php
public function addLink( $linkOrRel, string $href = null, $classes = [], string $title = null, string $type = null ) : self { $link = $linkOrRel; if (!$linkOrRel instanceof Link) { $rels = is_array($linkOrRel) ? $linkOrRel : [$linkOrRel]; $classes = is_array($classes) ? $classes : [$classes]; $link = new Link($rels, $href, $classes, $title, $type); } $this->links[] = $link; return $this; }
[ "public", "function", "addLink", "(", "$", "linkOrRel", ",", "string", "$", "href", "=", "null", ",", "$", "classes", "=", "[", "]", ",", "string", "$", "title", "=", "null", ",", "string", "$", "type", "=", "null", ")", ":", "self", "{", "$", "link", "=", "$", "linkOrRel", ";", "if", "(", "!", "$", "linkOrRel", "instanceof", "Link", ")", "{", "$", "rels", "=", "is_array", "(", "$", "linkOrRel", ")", "?", "$", "linkOrRel", ":", "[", "$", "linkOrRel", "]", ";", "$", "classes", "=", "is_array", "(", "$", "classes", ")", "?", "$", "classes", ":", "[", "$", "classes", "]", ";", "$", "link", "=", "new", "Link", "(", "$", "rels", ",", "$", "href", ",", "$", "classes", ",", "$", "title", ",", "$", "type", ")", ";", "}", "$", "this", "->", "links", "[", "]", "=", "$", "link", ";", "return", "$", "this", ";", "}" ]
@param Link|string|string[] $linkOrRel @param string $href @param string|string[] $classes @param string $title @param string $type @return $this
[ "@param", "Link|string|string", "[]", "$linkOrRel", "@param", "string", "$href", "@param", "string|string", "[]", "$classes", "@param", "string", "$title", "@param", "string", "$type" ]
train
https://github.com/tomphp/siren-php/blob/22bdce3d7d87693df29011a5139dbad349c875db/src/EntityBuilder.php#L89-L107
fond-of/spryker-brand
src/FondOfSpryker/Zed/Brand/BrandDependencyProvider.php
BrandDependencyProvider.provideBusinessLayerDependencies
public function provideBusinessLayerDependencies(Container $container): Container { $container = parent::provideBusinessLayerDependencies($container); $container = $this->addBrandTransferExpanderPlugins($container); return $container; }
php
public function provideBusinessLayerDependencies(Container $container): Container { $container = parent::provideBusinessLayerDependencies($container); $container = $this->addBrandTransferExpanderPlugins($container); return $container; }
[ "public", "function", "provideBusinessLayerDependencies", "(", "Container", "$", "container", ")", ":", "Container", "{", "$", "container", "=", "parent", "::", "provideBusinessLayerDependencies", "(", "$", "container", ")", ";", "$", "container", "=", "$", "this", "->", "addBrandTransferExpanderPlugins", "(", "$", "container", ")", ";", "return", "$", "container", ";", "}" ]
@param \Spryker\Zed\Kernel\Container $container @return \Spryker\Zed\Kernel\Container
[ "@param", "\\", "Spryker", "\\", "Zed", "\\", "Kernel", "\\", "Container", "$container" ]
train
https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/BrandDependencyProvider.php#L16-L22
fond-of/spryker-brand
src/FondOfSpryker/Zed/Brand/BrandDependencyProvider.php
BrandDependencyProvider.addBrandTransferExpanderPlugins
public function addBrandTransferExpanderPlugins(Container $container): Container { $container[static::PLUGINS_BRAND_TRANSFER_EXPANDER] = function (Container $container) { return $this->getBrandTransferExpanderPlugins(); }; return $container; }
php
public function addBrandTransferExpanderPlugins(Container $container): Container { $container[static::PLUGINS_BRAND_TRANSFER_EXPANDER] = function (Container $container) { return $this->getBrandTransferExpanderPlugins(); }; return $container; }
[ "public", "function", "addBrandTransferExpanderPlugins", "(", "Container", "$", "container", ")", ":", "Container", "{", "$", "container", "[", "static", "::", "PLUGINS_BRAND_TRANSFER_EXPANDER", "]", "=", "function", "(", "Container", "$", "container", ")", "{", "return", "$", "this", "->", "getBrandTransferExpanderPlugins", "(", ")", ";", "}", ";", "return", "$", "container", ";", "}" ]
@param \Spryker\Zed\Kernel\Container $container @return \Spryker\Zed\Kernel\Container
[ "@param", "\\", "Spryker", "\\", "Zed", "\\", "Kernel", "\\", "Container", "$container" ]
train
https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/BrandDependencyProvider.php#L29-L36
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.create
public static function create($maniaLinkId = null, $version = null, $name = null, array $children = null) { return new static($maniaLinkId, $version, $name, $children); }
php
public static function create($maniaLinkId = null, $version = null, $name = null, array $children = null) { return new static($maniaLinkId, $version, $name, $children); }
[ "public", "static", "function", "create", "(", "$", "maniaLinkId", "=", "null", ",", "$", "version", "=", "null", ",", "$", "name", "=", "null", ",", "array", "$", "children", "=", "null", ")", "{", "return", "new", "static", "(", "$", "maniaLinkId", ",", "$", "version", ",", "$", "name", ",", "$", "children", ")", ";", "}" ]
Create a new ManiaLink @api @param string $maniaLinkId (optional) ManiaLink ID @param int $version (optional) Version @param string $name (optional) Name @param Renderable[] $children (optional) Children @return static
[ "Create", "a", "new", "ManiaLink" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L109-L112
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.setId
public function setId($maniaLinkId) { $this->maniaLinkId = (string)$maniaLinkId; if ($this->maniaLinkId && !$this->name) { $this->setName($this->maniaLinkId); } return $this; }
php
public function setId($maniaLinkId) { $this->maniaLinkId = (string)$maniaLinkId; if ($this->maniaLinkId && !$this->name) { $this->setName($this->maniaLinkId); } return $this; }
[ "public", "function", "setId", "(", "$", "maniaLinkId", ")", "{", "$", "this", "->", "maniaLinkId", "=", "(", "string", ")", "$", "maniaLinkId", ";", "if", "(", "$", "this", "->", "maniaLinkId", "&&", "!", "$", "this", "->", "name", ")", "{", "$", "this", "->", "setName", "(", "$", "this", "->", "maniaLinkId", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the ID @api @param string $maniaLinkId ManiaLink ID @return static
[ "Set", "the", "ID" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L165-L172
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.getDico
public function getDico($createIfEmpty = true) { if (!$this->dico && $createIfEmpty) { $this->setDico(new Dico()); } return $this->dico; }
php
public function getDico($createIfEmpty = true) { if (!$this->dico && $createIfEmpty) { $this->setDico(new Dico()); } return $this->dico; }
[ "public", "function", "getDico", "(", "$", "createIfEmpty", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "dico", "&&", "$", "createIfEmpty", ")", "{", "$", "this", "->", "setDico", "(", "new", "Dico", "(", ")", ")", ";", "}", "return", "$", "this", "->", "dico", ";", "}" ]
Get the Dictionary @api @param bool $createIfEmpty (optional) If the Dico should be created if it doesn't exist yet @return Dico
[ "Get", "the", "Dictionary" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L438-L444
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.getStylesheet
public function getStylesheet($createIfEmpty = true) { if (!$this->stylesheet && $createIfEmpty) { return $this->createStylesheet(); } return $this->stylesheet; }
php
public function getStylesheet($createIfEmpty = true) { if (!$this->stylesheet && $createIfEmpty) { return $this->createStylesheet(); } return $this->stylesheet; }
[ "public", "function", "getStylesheet", "(", "$", "createIfEmpty", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "stylesheet", "&&", "$", "createIfEmpty", ")", "{", "return", "$", "this", "->", "createStylesheet", "(", ")", ";", "}", "return", "$", "this", "->", "stylesheet", ";", "}" ]
Get the Stylesheet @api @return Stylesheet
[ "Get", "the", "Stylesheet" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L465-L471
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.createStylesheet
public function createStylesheet() { if ($this->stylesheet) { return $this->stylesheet; } $stylesheet = new Stylesheet(); $this->setStylesheet($stylesheet); return $this->stylesheet; }
php
public function createStylesheet() { if ($this->stylesheet) { return $this->stylesheet; } $stylesheet = new Stylesheet(); $this->setStylesheet($stylesheet); return $this->stylesheet; }
[ "public", "function", "createStylesheet", "(", ")", "{", "if", "(", "$", "this", "->", "stylesheet", ")", "{", "return", "$", "this", "->", "stylesheet", ";", "}", "$", "stylesheet", "=", "new", "Stylesheet", "(", ")", ";", "$", "this", "->", "setStylesheet", "(", "$", "stylesheet", ")", ";", "return", "$", "this", "->", "stylesheet", ";", "}" ]
Create and assign a new Stylesheet if necessary @api @return Stylesheet
[ "Create", "and", "assign", "a", "new", "Stylesheet", "if", "necessary" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L492-L500
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.getScript
public function getScript($createIfEmpty = true) { if (!$this->script && $createIfEmpty) { return $this->createScript(); } return $this->script; }
php
public function getScript($createIfEmpty = true) { if (!$this->script && $createIfEmpty) { return $this->createScript(); } return $this->script; }
[ "public", "function", "getScript", "(", "$", "createIfEmpty", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "script", "&&", "$", "createIfEmpty", ")", "{", "return", "$", "this", "->", "createScript", "(", ")", ";", "}", "return", "$", "this", "->", "script", ";", "}" ]
Get the Script @api @param bool $createIfEmpty (optional) Create the script if it's not set yet @return Script
[ "Get", "the", "Script" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L509-L515
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.createScript
public function createScript() { if ($this->script) { return $this->script; } $script = new Script(); $this->setScript($script); return $this->script; }
php
public function createScript() { if ($this->script) { return $this->script; } $script = new Script(); $this->setScript($script); return $this->script; }
[ "public", "function", "createScript", "(", ")", "{", "if", "(", "$", "this", "->", "script", ")", "{", "return", "$", "this", "->", "script", ";", "}", "$", "script", "=", "new", "Script", "(", ")", ";", "$", "this", "->", "setScript", "(", "$", "script", ")", ";", "return", "$", "this", "->", "script", ";", "}" ]
Create and assign a new Script if necessary @api @return Script
[ "Create", "and", "assign", "a", "new", "Script", "if", "necessary" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L536-L544
steeffeen/FancyManiaLinks
FML/ManiaLink.php
ManiaLink.render
public function render($echo = false, $domDocument = null) { $isChild = (bool)$domDocument; if (!$isChild) { $domDocument = new \DOMDocument("1.0", "utf-8"); $domDocument->xmlStandalone = true; } $maniaLink = $domDocument->createElement("manialink"); if (!$isChild) { $domDocument->appendChild($maniaLink); } if ($this->maniaLinkId) { $maniaLink->setAttribute("id", $this->maniaLinkId); } if ($this->version > 0) { $maniaLink->setAttribute("version", $this->version); } if ($this->name) { $maniaLink->setAttribute("name", $this->name); } if ($this->background) { $maniaLink->setAttribute("background", $this->background); } if (!$this->navigable3d) { $maniaLink->setAttribute("navigable3d", "0"); } if ($this->timeout) { $timeoutXml = $domDocument->createElement("timeout", $this->timeout); $maniaLink->appendChild($timeoutXml); } if ($this->dico) { $dicoXml = $this->dico->render($domDocument); $maniaLink->appendChild($dicoXml); } if ($this->layer) { $maniaLink->setAttribute("layer", $this->layer); } $scriptFeatures = array(); foreach ($this->children as $child) { $childXml = $child->render($domDocument); $maniaLink->appendChild($childXml); if ($child instanceof ScriptFeatureable) { $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); } } if ($this->stylesheet) { $stylesheetXml = $this->stylesheet->render($domDocument); $maniaLink->appendChild($stylesheetXml); } if ($scriptFeatures) { $this->createScript() ->loadFeatures($scriptFeatures); } if ($this->script) { if ($this->script->needsRendering()) { $scriptXml = $this->script->render($domDocument); $maniaLink->appendChild($scriptXml); } $this->script->resetGenericScriptLabels(); } if ($isChild) { return $maniaLink; } if ($echo) { header("Content-Type: application/xml; charset=utf-8;"); echo $domDocument->saveXML(); } return $domDocument; }
php
public function render($echo = false, $domDocument = null) { $isChild = (bool)$domDocument; if (!$isChild) { $domDocument = new \DOMDocument("1.0", "utf-8"); $domDocument->xmlStandalone = true; } $maniaLink = $domDocument->createElement("manialink"); if (!$isChild) { $domDocument->appendChild($maniaLink); } if ($this->maniaLinkId) { $maniaLink->setAttribute("id", $this->maniaLinkId); } if ($this->version > 0) { $maniaLink->setAttribute("version", $this->version); } if ($this->name) { $maniaLink->setAttribute("name", $this->name); } if ($this->background) { $maniaLink->setAttribute("background", $this->background); } if (!$this->navigable3d) { $maniaLink->setAttribute("navigable3d", "0"); } if ($this->timeout) { $timeoutXml = $domDocument->createElement("timeout", $this->timeout); $maniaLink->appendChild($timeoutXml); } if ($this->dico) { $dicoXml = $this->dico->render($domDocument); $maniaLink->appendChild($dicoXml); } if ($this->layer) { $maniaLink->setAttribute("layer", $this->layer); } $scriptFeatures = array(); foreach ($this->children as $child) { $childXml = $child->render($domDocument); $maniaLink->appendChild($childXml); if ($child instanceof ScriptFeatureable) { $scriptFeatures = array_merge($scriptFeatures, $child->getScriptFeatures()); } } if ($this->stylesheet) { $stylesheetXml = $this->stylesheet->render($domDocument); $maniaLink->appendChild($stylesheetXml); } if ($scriptFeatures) { $this->createScript() ->loadFeatures($scriptFeatures); } if ($this->script) { if ($this->script->needsRendering()) { $scriptXml = $this->script->render($domDocument); $maniaLink->appendChild($scriptXml); } $this->script->resetGenericScriptLabels(); } if ($isChild) { return $maniaLink; } if ($echo) { header("Content-Type: application/xml; charset=utf-8;"); echo $domDocument->saveXML(); } return $domDocument; }
[ "public", "function", "render", "(", "$", "echo", "=", "false", ",", "$", "domDocument", "=", "null", ")", "{", "$", "isChild", "=", "(", "bool", ")", "$", "domDocument", ";", "if", "(", "!", "$", "isChild", ")", "{", "$", "domDocument", "=", "new", "\\", "DOMDocument", "(", "\"1.0\"", ",", "\"utf-8\"", ")", ";", "$", "domDocument", "->", "xmlStandalone", "=", "true", ";", "}", "$", "maniaLink", "=", "$", "domDocument", "->", "createElement", "(", "\"manialink\"", ")", ";", "if", "(", "!", "$", "isChild", ")", "{", "$", "domDocument", "->", "appendChild", "(", "$", "maniaLink", ")", ";", "}", "if", "(", "$", "this", "->", "maniaLinkId", ")", "{", "$", "maniaLink", "->", "setAttribute", "(", "\"id\"", ",", "$", "this", "->", "maniaLinkId", ")", ";", "}", "if", "(", "$", "this", "->", "version", ">", "0", ")", "{", "$", "maniaLink", "->", "setAttribute", "(", "\"version\"", ",", "$", "this", "->", "version", ")", ";", "}", "if", "(", "$", "this", "->", "name", ")", "{", "$", "maniaLink", "->", "setAttribute", "(", "\"name\"", ",", "$", "this", "->", "name", ")", ";", "}", "if", "(", "$", "this", "->", "background", ")", "{", "$", "maniaLink", "->", "setAttribute", "(", "\"background\"", ",", "$", "this", "->", "background", ")", ";", "}", "if", "(", "!", "$", "this", "->", "navigable3d", ")", "{", "$", "maniaLink", "->", "setAttribute", "(", "\"navigable3d\"", ",", "\"0\"", ")", ";", "}", "if", "(", "$", "this", "->", "timeout", ")", "{", "$", "timeoutXml", "=", "$", "domDocument", "->", "createElement", "(", "\"timeout\"", ",", "$", "this", "->", "timeout", ")", ";", "$", "maniaLink", "->", "appendChild", "(", "$", "timeoutXml", ")", ";", "}", "if", "(", "$", "this", "->", "dico", ")", "{", "$", "dicoXml", "=", "$", "this", "->", "dico", "->", "render", "(", "$", "domDocument", ")", ";", "$", "maniaLink", "->", "appendChild", "(", "$", "dicoXml", ")", ";", "}", "if", "(", "$", "this", "->", "layer", ")", "{", "$", "maniaLink", "->", "setAttribute", "(", "\"layer\"", ",", "$", "this", "->", "layer", ")", ";", "}", "$", "scriptFeatures", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "$", "childXml", "=", "$", "child", "->", "render", "(", "$", "domDocument", ")", ";", "$", "maniaLink", "->", "appendChild", "(", "$", "childXml", ")", ";", "if", "(", "$", "child", "instanceof", "ScriptFeatureable", ")", "{", "$", "scriptFeatures", "=", "array_merge", "(", "$", "scriptFeatures", ",", "$", "child", "->", "getScriptFeatures", "(", ")", ")", ";", "}", "}", "if", "(", "$", "this", "->", "stylesheet", ")", "{", "$", "stylesheetXml", "=", "$", "this", "->", "stylesheet", "->", "render", "(", "$", "domDocument", ")", ";", "$", "maniaLink", "->", "appendChild", "(", "$", "stylesheetXml", ")", ";", "}", "if", "(", "$", "scriptFeatures", ")", "{", "$", "this", "->", "createScript", "(", ")", "->", "loadFeatures", "(", "$", "scriptFeatures", ")", ";", "}", "if", "(", "$", "this", "->", "script", ")", "{", "if", "(", "$", "this", "->", "script", "->", "needsRendering", "(", ")", ")", "{", "$", "scriptXml", "=", "$", "this", "->", "script", "->", "render", "(", "$", "domDocument", ")", ";", "$", "maniaLink", "->", "appendChild", "(", "$", "scriptXml", ")", ";", "}", "$", "this", "->", "script", "->", "resetGenericScriptLabels", "(", ")", ";", "}", "if", "(", "$", "isChild", ")", "{", "return", "$", "maniaLink", ";", "}", "if", "(", "$", "echo", ")", "{", "header", "(", "\"Content-Type: application/xml; charset=utf-8;\"", ")", ";", "echo", "$", "domDocument", "->", "saveXML", "(", ")", ";", "}", "return", "$", "domDocument", ";", "}" ]
Render the ManiaLink @param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set @param \DOMDocument $domDocument (optional) DOMDocument for which the ManiaLink should be rendered @return \DOMDocument
[ "Render", "the", "ManiaLink" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L553-L626
Double-Opt-in/php-client-api
src/Security/CryptographyEngine.php
CryptographyEngine.encrypt
public function encrypt($text, $email) { $key = $this->hasher->key($email); return $this->crypter->encrypt($text, $key); }
php
public function encrypt($text, $email) { $key = $this->hasher->key($email); return $this->crypter->encrypt($text, $key); }
[ "public", "function", "encrypt", "(", "$", "text", ",", "$", "email", ")", "{", "$", "key", "=", "$", "this", "->", "hasher", "->", "key", "(", "$", "email", ")", ";", "return", "$", "this", "->", "crypter", "->", "encrypt", "(", "$", "text", ",", "$", "key", ")", ";", "}" ]
encrypts a given string with given hash @param string $text @param string $email @return string
[ "encrypts", "a", "given", "string", "with", "given", "hash" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/CryptographyEngine.php#L50-L55
Double-Opt-in/php-client-api
src/Security/CryptographyEngine.php
CryptographyEngine.decrypt
public function decrypt($text, $email) { $key = $this->hasher->key($email); return $this->crypter->decrypt($text, $key); }
php
public function decrypt($text, $email) { $key = $this->hasher->key($email); return $this->crypter->decrypt($text, $key); }
[ "public", "function", "decrypt", "(", "$", "text", ",", "$", "email", ")", "{", "$", "key", "=", "$", "this", "->", "hasher", "->", "key", "(", "$", "email", ")", ";", "return", "$", "this", "->", "crypter", "->", "decrypt", "(", "$", "text", ",", "$", "key", ")", ";", "}" ]
decrypts a given encrypted message container e.g.: "slowaes:11 41bc1eacf6ce685c8eb7649da0d080995223165277af8bc068c90f7eb831d5ae 97be775203f003fef3c808e4b588c69b" @param string $text @param string $email @return string @throws Exception
[ "decrypts", "a", "given", "encrypted", "message", "container", "e", ".", "g", ".", ":", "slowaes", ":", "11", "41bc1eacf6ce685c8eb7649da0d080995223165277af8bc068c90f7eb831d5ae", "97be775203f003fef3c808e4b588c69b" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/CryptographyEngine.php#L68-L73
krzysztofmazur/php-object-mapper
src/KrzysztofMazur/ObjectMapper/Mapping/Field/ValueReader/AbstractValueReader.php
AbstractValueReader.read
public function read($object) { if ($object === null) { throw new \InvalidArgumentException("Unexpected null value"); } $value = $this->readValue($object); if ($this->next !== null) { $value = $this->next->read($value); } return $value; }
php
public function read($object) { if ($object === null) { throw new \InvalidArgumentException("Unexpected null value"); } $value = $this->readValue($object); if ($this->next !== null) { $value = $this->next->read($value); } return $value; }
[ "public", "function", "read", "(", "$", "object", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Unexpected null value\"", ")", ";", "}", "$", "value", "=", "$", "this", "->", "readValue", "(", "$", "object", ")", ";", "if", "(", "$", "this", "->", "next", "!==", "null", ")", "{", "$", "value", "=", "$", "this", "->", "next", "->", "read", "(", "$", "value", ")", ";", "}", "return", "$", "value", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/Mapping/Field/ValueReader/AbstractValueReader.php#L40-L51
ufocoder/yii2-SyncSocial
src/components/services/Google.php
Google.publishPost
public function publishPost( $message, $url = null ) { throw new Exception( Yii::t( 'SyncSocial', '{service} not support post publish', [ 'service' => $this->service->getName() ] ) ); }
php
public function publishPost( $message, $url = null ) { throw new Exception( Yii::t( 'SyncSocial', '{service} not support post publish', [ 'service' => $this->service->getName() ] ) ); }
[ "public", "function", "publishPost", "(", "$", "message", ",", "$", "url", "=", "null", ")", "{", "throw", "new", "Exception", "(", "Yii", "::", "t", "(", "'SyncSocial'", ",", "'{service} not support post publish'", ",", "[", "'service'", "=>", "$", "this", "->", "service", "->", "getName", "(", ")", "]", ")", ")", ";", "}" ]
@param $message @param null $url @return array|void @throws Exception
[ "@param", "$message", "@param", "null", "$url" ]
train
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/components/services/Google.php#L38-L43
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Abstract.php
Zend_Feed_Abstract._buildEntryCache
protected function _buildEntryCache() { $this->_entries = array(); foreach ($this->_element->childNodes as $child) { if ($child->localName == $this->_entryElementName) { $this->_entries[] = $child; } } }
php
protected function _buildEntryCache() { $this->_entries = array(); foreach ($this->_element->childNodes as $child) { if ($child->localName == $this->_entryElementName) { $this->_entries[] = $child; } } }
[ "protected", "function", "_buildEntryCache", "(", ")", "{", "$", "this", "->", "_entries", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_element", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "localName", "==", "$", "this", "->", "_entryElementName", ")", "{", "$", "this", "->", "_entries", "[", "]", "=", "$", "child", ";", "}", "}", "}" ]
Cache the individual feed elements so they don't need to be searched for on every operation. @return void
[ "Cache", "the", "individual", "feed", "elements", "so", "they", "don", "t", "need", "to", "be", "searched", "for", "on", "every", "operation", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Abstract.php#L157-L165
ClanCats/Core
src/console/session.php
session.get_manager
public function get_manager( $params ) { if ( array_key_exists( 'm', $params ) ) { $manager = $params['m']; } else { $manager = reset( $params ); } if ( $manager ) { $this->info( 'Using session manager: '.$manager ); } else { $manager = null; $this->info( 'Using default session manager.' ); } return \CCSession::manager( $manager ); }
php
public function get_manager( $params ) { if ( array_key_exists( 'm', $params ) ) { $manager = $params['m']; } else { $manager = reset( $params ); } if ( $manager ) { $this->info( 'Using session manager: '.$manager ); } else { $manager = null; $this->info( 'Using default session manager.' ); } return \CCSession::manager( $manager ); }
[ "public", "function", "get_manager", "(", "$", "params", ")", "{", "if", "(", "array_key_exists", "(", "'m'", ",", "$", "params", ")", ")", "{", "$", "manager", "=", "$", "params", "[", "'m'", "]", ";", "}", "else", "{", "$", "manager", "=", "reset", "(", "$", "params", ")", ";", "}", "if", "(", "$", "manager", ")", "{", "$", "this", "->", "info", "(", "'Using session manager: '", ".", "$", "manager", ")", ";", "}", "else", "{", "$", "manager", "=", "null", ";", "$", "this", "->", "info", "(", "'Using default session manager.'", ")", ";", "}", "return", "\\", "CCSession", "::", "manager", "(", "$", "manager", ")", ";", "}" ]
Get a manager instance @param array $params @return Session\Manager
[ "Get", "a", "manager", "instance" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/session.php#L34-L56
ClanCats/Core
src/console/session.php
session.action_gc
public function action_gc( $params ) { $manager = $this->get_manager( $params ); $manager->gc(); $this->success( 'Garbage collection executed successfully' ); }
php
public function action_gc( $params ) { $manager = $this->get_manager( $params ); $manager->gc(); $this->success( 'Garbage collection executed successfully' ); }
[ "public", "function", "action_gc", "(", "$", "params", ")", "{", "$", "manager", "=", "$", "this", "->", "get_manager", "(", "$", "params", ")", ";", "$", "manager", "->", "gc", "(", ")", ";", "$", "this", "->", "success", "(", "'Garbage collection executed successfully'", ")", ";", "}" ]
Gabrage collect old sessions @param array $params
[ "Gabrage", "collect", "old", "sessions" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/session.php#L63-L69
vi-kon/laravel-auth
src/database/migrations/2014_08_27_100003_create_rel_role_permission_table.php
CreateRelRolePermissionTable.up
public function up() { $schema = app()->make('db')->connection()->getSchemaBuilder(); $schema->create(config('vi-kon.auth.table.rel__role__permission'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->unsignedInteger('role_id'); $table->foreign('role_id') ->references('id') ->on(config('vi-kon.auth.table.user_roles')) ->onUpdate('cascade') ->onDelete('cascade'); $table->unsignedInteger('permission_id'); $table->foreign('permission_id') ->references('id') ->on(config('vi-kon.auth.table.user_permissions')) ->onUpdate('cascade') ->onDelete('cascade'); }); }
php
public function up() { $schema = app()->make('db')->connection()->getSchemaBuilder(); $schema->create(config('vi-kon.auth.table.rel__role__permission'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->unsignedInteger('role_id'); $table->foreign('role_id') ->references('id') ->on(config('vi-kon.auth.table.user_roles')) ->onUpdate('cascade') ->onDelete('cascade'); $table->unsignedInteger('permission_id'); $table->foreign('permission_id') ->references('id') ->on(config('vi-kon.auth.table.user_permissions')) ->onUpdate('cascade') ->onDelete('cascade'); }); }
[ "public", "function", "up", "(", ")", "{", "$", "schema", "=", "app", "(", ")", "->", "make", "(", "'db'", ")", "->", "connection", "(", ")", "->", "getSchemaBuilder", "(", ")", ";", "$", "schema", "->", "create", "(", "config", "(", "'vi-kon.auth.table.rel__role__permission'", ")", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "engine", "=", "'InnoDB'", ";", "$", "table", "->", "unsignedInteger", "(", "'role_id'", ")", ";", "$", "table", "->", "foreign", "(", "'role_id'", ")", "->", "references", "(", "'id'", ")", "->", "on", "(", "config", "(", "'vi-kon.auth.table.user_roles'", ")", ")", "->", "onUpdate", "(", "'cascade'", ")", "->", "onDelete", "(", "'cascade'", ")", ";", "$", "table", "->", "unsignedInteger", "(", "'permission_id'", ")", ";", "$", "table", "->", "foreign", "(", "'permission_id'", ")", "->", "references", "(", "'id'", ")", "->", "on", "(", "config", "(", "'vi-kon.auth.table.user_permissions'", ")", ")", "->", "onUpdate", "(", "'cascade'", ")", "->", "onDelete", "(", "'cascade'", ")", ";", "}", ")", ";", "}" ]
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/database/migrations/2014_08_27_100003_create_rel_role_permission_table.php#L18-L39
slashworks/control-bundle
src/Slashworks/AppBundle/Model/map/RemoteAppTableMap.php
RemoteAppTableMap.initialize
public function initialize() { // attributes $this->setName('remote_app'); $this->setPhpName('RemoteApp'); $this->setClassname('Slashworks\\AppBundle\\Model\\RemoteApp'); $this->setPackage('src.Slashworks.AppBundle.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('id', 'Id', 'INTEGER', true, 10, null); $this->addColumn('type', 'Type', 'CHAR', true, null, 'contao'); $this->getColumn('type', false)->setValueSet(array ( 0 => 'contao', )); $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); $this->addColumn('domain', 'Domain', 'VARCHAR', true, 255, null); $this->addColumn('api_url', 'ApiUrl', 'VARCHAR', true, 255, null); $this->addColumn('api_auth_http_user', 'ApiAuthHttpUser', 'VARCHAR', false, 50, null); $this->addColumn('api_auth_http_password', 'ApiAuthHttpPassword', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_type', 'ApiAuthType', 'CHAR', true, null, 'none'); $this->getColumn('api_auth_type', false)->setValueSet(array ( 0 => 'none', 1 => 'http-basic', 2 => 'url-user-password', 3 => 'url-token', )); $this->addColumn('api_auth_user', 'ApiAuthUser', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_password', 'ApiAuthPassword', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_token', 'ApiAuthToken', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_url_user_key', 'ApiAuthUrlUserKey', 'VARCHAR', false, 50, null); $this->addColumn('api_auth_url_pw_key', 'ApiAuthUrlPwKey', 'VARCHAR', false, 50, null); $this->addColumn('cron', 'Cron', 'VARCHAR', false, 20, null); $this->addForeignKey('customer_id', 'CustomerId', 'INTEGER', 'customer', 'id', false, 10, null); $this->addColumn('activated', 'Activated', 'BOOLEAN', true, 1, false); $this->addColumn('notes', 'Notes', 'LONGVARCHAR', false, null, null); $this->addColumn('last_run', 'LastRun', 'TIMESTAMP', false, null, null); $this->addColumn('includeLog', 'Includelog', 'BOOLEAN', true, 1, false); $this->addColumn('public_key', 'PublicKey', 'VARCHAR', false, 512, null); $this->addColumn('website_hash', 'WebsiteHash', 'VARCHAR', false, 255, ''); $this->addColumn('notification_recipient', 'NotificationRecipient', 'VARCHAR', true, 255, ''); $this->addColumn('notification_sender', 'NotificationSender', 'VARCHAR', true, 255, ''); $this->addColumn('notification_change', 'NotificationChange', 'BOOLEAN', true, 1, true); $this->addColumn('notification_error', 'NotificationError', 'BOOLEAN', true, 1, true); // validators }
php
public function initialize() { // attributes $this->setName('remote_app'); $this->setPhpName('RemoteApp'); $this->setClassname('Slashworks\\AppBundle\\Model\\RemoteApp'); $this->setPackage('src.Slashworks.AppBundle.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('id', 'Id', 'INTEGER', true, 10, null); $this->addColumn('type', 'Type', 'CHAR', true, null, 'contao'); $this->getColumn('type', false)->setValueSet(array ( 0 => 'contao', )); $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); $this->addColumn('domain', 'Domain', 'VARCHAR', true, 255, null); $this->addColumn('api_url', 'ApiUrl', 'VARCHAR', true, 255, null); $this->addColumn('api_auth_http_user', 'ApiAuthHttpUser', 'VARCHAR', false, 50, null); $this->addColumn('api_auth_http_password', 'ApiAuthHttpPassword', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_type', 'ApiAuthType', 'CHAR', true, null, 'none'); $this->getColumn('api_auth_type', false)->setValueSet(array ( 0 => 'none', 1 => 'http-basic', 2 => 'url-user-password', 3 => 'url-token', )); $this->addColumn('api_auth_user', 'ApiAuthUser', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_password', 'ApiAuthPassword', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_token', 'ApiAuthToken', 'VARCHAR', false, 255, null); $this->addColumn('api_auth_url_user_key', 'ApiAuthUrlUserKey', 'VARCHAR', false, 50, null); $this->addColumn('api_auth_url_pw_key', 'ApiAuthUrlPwKey', 'VARCHAR', false, 50, null); $this->addColumn('cron', 'Cron', 'VARCHAR', false, 20, null); $this->addForeignKey('customer_id', 'CustomerId', 'INTEGER', 'customer', 'id', false, 10, null); $this->addColumn('activated', 'Activated', 'BOOLEAN', true, 1, false); $this->addColumn('notes', 'Notes', 'LONGVARCHAR', false, null, null); $this->addColumn('last_run', 'LastRun', 'TIMESTAMP', false, null, null); $this->addColumn('includeLog', 'Includelog', 'BOOLEAN', true, 1, false); $this->addColumn('public_key', 'PublicKey', 'VARCHAR', false, 512, null); $this->addColumn('website_hash', 'WebsiteHash', 'VARCHAR', false, 255, ''); $this->addColumn('notification_recipient', 'NotificationRecipient', 'VARCHAR', true, 255, ''); $this->addColumn('notification_sender', 'NotificationSender', 'VARCHAR', true, 255, ''); $this->addColumn('notification_change', 'NotificationChange', 'BOOLEAN', true, 1, true); $this->addColumn('notification_error', 'NotificationError', 'BOOLEAN', true, 1, true); // validators }
[ "public", "function", "initialize", "(", ")", "{", "// attributes", "$", "this", "->", "setName", "(", "'remote_app'", ")", ";", "$", "this", "->", "setPhpName", "(", "'RemoteApp'", ")", ";", "$", "this", "->", "setClassname", "(", "'Slashworks\\\\AppBundle\\\\Model\\\\RemoteApp'", ")", ";", "$", "this", "->", "setPackage", "(", "'src.Slashworks.AppBundle.Model'", ")", ";", "$", "this", "->", "setUseIdGenerator", "(", "true", ")", ";", "// columns", "$", "this", "->", "addPrimaryKey", "(", "'id'", ",", "'Id'", ",", "'INTEGER'", ",", "true", ",", "10", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'type'", ",", "'Type'", ",", "'CHAR'", ",", "true", ",", "null", ",", "'contao'", ")", ";", "$", "this", "->", "getColumn", "(", "'type'", ",", "false", ")", "->", "setValueSet", "(", "array", "(", "0", "=>", "'contao'", ",", ")", ")", ";", "$", "this", "->", "addColumn", "(", "'name'", ",", "'Name'", ",", "'VARCHAR'", ",", "true", ",", "255", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'domain'", ",", "'Domain'", ",", "'VARCHAR'", ",", "true", ",", "255", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_url'", ",", "'ApiUrl'", ",", "'VARCHAR'", ",", "true", ",", "255", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_http_user'", ",", "'ApiAuthHttpUser'", ",", "'VARCHAR'", ",", "false", ",", "50", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_http_password'", ",", "'ApiAuthHttpPassword'", ",", "'VARCHAR'", ",", "false", ",", "255", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_type'", ",", "'ApiAuthType'", ",", "'CHAR'", ",", "true", ",", "null", ",", "'none'", ")", ";", "$", "this", "->", "getColumn", "(", "'api_auth_type'", ",", "false", ")", "->", "setValueSet", "(", "array", "(", "0", "=>", "'none'", ",", "1", "=>", "'http-basic'", ",", "2", "=>", "'url-user-password'", ",", "3", "=>", "'url-token'", ",", ")", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_user'", ",", "'ApiAuthUser'", ",", "'VARCHAR'", ",", "false", ",", "255", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_password'", ",", "'ApiAuthPassword'", ",", "'VARCHAR'", ",", "false", ",", "255", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_token'", ",", "'ApiAuthToken'", ",", "'VARCHAR'", ",", "false", ",", "255", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_url_user_key'", ",", "'ApiAuthUrlUserKey'", ",", "'VARCHAR'", ",", "false", ",", "50", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'api_auth_url_pw_key'", ",", "'ApiAuthUrlPwKey'", ",", "'VARCHAR'", ",", "false", ",", "50", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'cron'", ",", "'Cron'", ",", "'VARCHAR'", ",", "false", ",", "20", ",", "null", ")", ";", "$", "this", "->", "addForeignKey", "(", "'customer_id'", ",", "'CustomerId'", ",", "'INTEGER'", ",", "'customer'", ",", "'id'", ",", "false", ",", "10", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'activated'", ",", "'Activated'", ",", "'BOOLEAN'", ",", "true", ",", "1", ",", "false", ")", ";", "$", "this", "->", "addColumn", "(", "'notes'", ",", "'Notes'", ",", "'LONGVARCHAR'", ",", "false", ",", "null", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'last_run'", ",", "'LastRun'", ",", "'TIMESTAMP'", ",", "false", ",", "null", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'includeLog'", ",", "'Includelog'", ",", "'BOOLEAN'", ",", "true", ",", "1", ",", "false", ")", ";", "$", "this", "->", "addColumn", "(", "'public_key'", ",", "'PublicKey'", ",", "'VARCHAR'", ",", "false", ",", "512", ",", "null", ")", ";", "$", "this", "->", "addColumn", "(", "'website_hash'", ",", "'WebsiteHash'", ",", "'VARCHAR'", ",", "false", ",", "255", ",", "''", ")", ";", "$", "this", "->", "addColumn", "(", "'notification_recipient'", ",", "'NotificationRecipient'", ",", "'VARCHAR'", ",", "true", ",", "255", ",", "''", ")", ";", "$", "this", "->", "addColumn", "(", "'notification_sender'", ",", "'NotificationSender'", ",", "'VARCHAR'", ",", "true", ",", "255", ",", "''", ")", ";", "$", "this", "->", "addColumn", "(", "'notification_change'", ",", "'NotificationChange'", ",", "'BOOLEAN'", ",", "true", ",", "1", ",", "true", ")", ";", "$", "this", "->", "addColumn", "(", "'notification_error'", ",", "'NotificationError'", ",", "'BOOLEAN'", ",", "true", ",", "1", ",", "true", ")", ";", "// validators", "}" ]
Initialize the table attributes, columns and validators Relations are not initialized by this method since they are lazy loaded @return void @throws PropelException
[ "Initialize", "the", "table", "attributes", "columns", "and", "validators", "Relations", "are", "not", "initialized", "by", "this", "method", "since", "they", "are", "lazy", "loaded" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/map/RemoteAppTableMap.php#L36-L80