id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
19,700 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L659-L681
|
19,701 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L691-L693
|
19,702 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L720-L729
|
19,703 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L771-L794
|
19,704 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L804-L806
|
19,705 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L816-L818
|
19,706 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L828-L830
|
19,707 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L840-L842
|
19,708 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L852-L858
|
19,709 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L879-L894
|
19,710 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L904-L906
|
19,711 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L913-L918
|
19,712 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L946-L952
|
19,713 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L962-L964
|
19,714 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L974-L976
|
19,715 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L986-L988
|
19,716 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L998-L1008
|
19,717 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L1019-L1046
|
19,718 |
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",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L1059-L1081
|
19,719 |
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",
"."
] |
fe8283e2d6847ef697abec832da7ee741a85058c
|
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Editor/Plugin.php#L33-L49
|
19,720 |
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",
"."
] |
fe8283e2d6847ef697abec832da7ee741a85058c
|
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Editor/Plugin.php#L54-L62
|
19,721 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBox.php#L124-L133
|
19,722 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Components/CheckBox.php#L154-L163
|
19,723 |
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"
] |
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
|
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Config.php#L95-L104
|
19,724 |
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"
] |
4e85f0b729329783b34e35d90abba2807899ff58
|
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/WebhookService.php#L30-L52
|
19,725 |
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",
"."
] |
e21990ce6d881366d52a7f4e5040b07cc3ecca96
|
https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Filters/FormatDateFilter.php#L27-L37
|
19,726 |
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",
"."
] |
777a6208ea4dfbeed89e6d0712a35dc25eab498b
|
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/ArrayValue.php#L50-L65
|
19,727 |
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",
"."
] |
777a6208ea4dfbeed89e6d0712a35dc25eab498b
|
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/ArrayValue.php#L106-L125
|
19,728 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L109-L112
|
19,729 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L165-L172
|
19,730 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L438-L444
|
19,731 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L465-L471
|
19,732 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L492-L500
|
19,733 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L509-L515
|
19,734 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L536-L544
|
19,735 |
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"
] |
227b0759306f0a3c75873ba50276e4163a93bfa6
|
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLink.php#L553-L626
|
19,736 |
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"
] |
2f17da58ec20a408bbd55b2cdd053bc689f995f4
|
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/CryptographyEngine.php#L50-L55
|
19,737 |
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",
"."
] |
1c6da8c56ef717225ff904e1522aff94ed051601
|
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Abstract.php#L157-L165
|
19,738 |
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"
] |
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/session.php#L34-L56
|
19,739 |
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"
] |
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
|
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/session.php#L63-L69
|
19,740 |
titon/db
|
src/Titon/Db/Driver/ResultSet/PdoResultSet.php
|
PdoResultSet._mapAliases
|
protected function _mapAliases() {
return $this->cache(__METHOD__, function() {
$query = $this->getQuery();
if (!$query) {
return [];
}
$alias = $query->getAlias();
$map = [
$query->getTable() => $alias,
strtolower($alias) => $alias
];
foreach ($query->getJoins() as $join) {
$joinAlias = $join->getAlias();
$map[$join->getTable()] = $joinAlias;
$map[strtolower($joinAlias)] = $joinAlias;
}
return $map;
});
}
|
php
|
protected function _mapAliases() {
return $this->cache(__METHOD__, function() {
$query = $this->getQuery();
if (!$query) {
return [];
}
$alias = $query->getAlias();
$map = [
$query->getTable() => $alias,
strtolower($alias) => $alias
];
foreach ($query->getJoins() as $join) {
$joinAlias = $join->getAlias();
$map[$join->getTable()] = $joinAlias;
$map[strtolower($joinAlias)] = $joinAlias;
}
return $map;
});
}
|
[
"protected",
"function",
"_mapAliases",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"__METHOD__",
",",
"function",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"!",
"$",
"query",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"alias",
"=",
"$",
"query",
"->",
"getAlias",
"(",
")",
";",
"$",
"map",
"=",
"[",
"$",
"query",
"->",
"getTable",
"(",
")",
"=>",
"$",
"alias",
",",
"strtolower",
"(",
"$",
"alias",
")",
"=>",
"$",
"alias",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"getJoins",
"(",
")",
"as",
"$",
"join",
")",
"{",
"$",
"joinAlias",
"=",
"$",
"join",
"->",
"getAlias",
"(",
")",
";",
"$",
"map",
"[",
"$",
"join",
"->",
"getTable",
"(",
")",
"]",
"=",
"$",
"joinAlias",
";",
"$",
"map",
"[",
"strtolower",
"(",
"$",
"joinAlias",
")",
"]",
"=",
"$",
"joinAlias",
";",
"}",
"return",
"$",
"map",
";",
"}",
")",
";",
"}"
] |
Return a mapping of table to alias for the primary table and joins.
@return array
|
[
"Return",
"a",
"mapping",
"of",
"table",
"to",
"alias",
"for",
"the",
"primary",
"table",
"and",
"joins",
"."
] |
fbc5159d1ce9d2139759c9367565986981485604
|
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/ResultSet/PdoResultSet.php#L218-L241
|
19,741 |
shiftio/safestream-php-sdk
|
src/Video/VideoClient.php
|
VideoClient.create
|
public function create(Video $video, $waitForIngest = 0) {
if(is_null($video)) {
throw new VideoClientException("No video provided");
}
if(is_null($video->sourceUrl) || !filter_var($video->sourceUrl, FILTER_VALIDATE_URL)) {
throw new VideoClientException("Invalid source URL");
}
$ingestedStatus = "INGESTED";
try {
// Make the request to the SafeStream REST API
$videoResponse = $this->post($this->apiResourcePath, $video);
// Wait for the video to be ingested before returning
// TODO: Have the ingest wait be on a separate thread
if($waitForIngest > 0 && !$ingestedStatus == $videoResponse->status) {
$startTime = round(microtime(true) * 1000);
$ingested = false;
while(!$ingested && (round(microtime(true) * 1000) - $startTime) < $waitForIngest) {
$test = $this->find($video->key);
if($ingestedStatus == $videoResponse->status) {
return $test;
}
sleep(3);
}
throw new VideoClientException("Timeout reached waiting for video to be ingested");
} else {
return $videoResponse;
}
} catch(SafeStreamHttpException $e) {
throw new VideoClientException($e);
}
}
|
php
|
public function create(Video $video, $waitForIngest = 0) {
if(is_null($video)) {
throw new VideoClientException("No video provided");
}
if(is_null($video->sourceUrl) || !filter_var($video->sourceUrl, FILTER_VALIDATE_URL)) {
throw new VideoClientException("Invalid source URL");
}
$ingestedStatus = "INGESTED";
try {
// Make the request to the SafeStream REST API
$videoResponse = $this->post($this->apiResourcePath, $video);
// Wait for the video to be ingested before returning
// TODO: Have the ingest wait be on a separate thread
if($waitForIngest > 0 && !$ingestedStatus == $videoResponse->status) {
$startTime = round(microtime(true) * 1000);
$ingested = false;
while(!$ingested && (round(microtime(true) * 1000) - $startTime) < $waitForIngest) {
$test = $this->find($video->key);
if($ingestedStatus == $videoResponse->status) {
return $test;
}
sleep(3);
}
throw new VideoClientException("Timeout reached waiting for video to be ingested");
} else {
return $videoResponse;
}
} catch(SafeStreamHttpException $e) {
throw new VideoClientException($e);
}
}
|
[
"public",
"function",
"create",
"(",
"Video",
"$",
"video",
",",
"$",
"waitForIngest",
"=",
"0",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"video",
")",
")",
"{",
"throw",
"new",
"VideoClientException",
"(",
"\"No video provided\"",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"video",
"->",
"sourceUrl",
")",
"||",
"!",
"filter_var",
"(",
"$",
"video",
"->",
"sourceUrl",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"throw",
"new",
"VideoClientException",
"(",
"\"Invalid source URL\"",
")",
";",
"}",
"$",
"ingestedStatus",
"=",
"\"INGESTED\"",
";",
"try",
"{",
"// Make the request to the SafeStream REST API",
"$",
"videoResponse",
"=",
"$",
"this",
"->",
"post",
"(",
"$",
"this",
"->",
"apiResourcePath",
",",
"$",
"video",
")",
";",
"// Wait for the video to be ingested before returning",
"// TODO: Have the ingest wait be on a separate thread",
"if",
"(",
"$",
"waitForIngest",
">",
"0",
"&&",
"!",
"$",
"ingestedStatus",
"==",
"$",
"videoResponse",
"->",
"status",
")",
"{",
"$",
"startTime",
"=",
"round",
"(",
"microtime",
"(",
"true",
")",
"*",
"1000",
")",
";",
"$",
"ingested",
"=",
"false",
";",
"while",
"(",
"!",
"$",
"ingested",
"&&",
"(",
"round",
"(",
"microtime",
"(",
"true",
")",
"*",
"1000",
")",
"-",
"$",
"startTime",
")",
"<",
"$",
"waitForIngest",
")",
"{",
"$",
"test",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"video",
"->",
"key",
")",
";",
"if",
"(",
"$",
"ingestedStatus",
"==",
"$",
"videoResponse",
"->",
"status",
")",
"{",
"return",
"$",
"test",
";",
"}",
"sleep",
"(",
"3",
")",
";",
"}",
"throw",
"new",
"VideoClientException",
"(",
"\"Timeout reached waiting for video to be ingested\"",
")",
";",
"}",
"else",
"{",
"return",
"$",
"videoResponse",
";",
"}",
"}",
"catch",
"(",
"SafeStreamHttpException",
"$",
"e",
")",
"{",
"throw",
"new",
"VideoClientException",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Creates a new video allowing a specific timeout while waiting for the video to downloaded
and encoded. If not timeout is set then the function will return immediately, before the
ingest is complete. The video cannot be watermarked until it has been ingested at which
point the video status will be INGESTED.
This will block until either the video is ingested OR the timeout is reached.
@param Video $video
@param int $waitForIngest: Time in millis to wait for the video to be ingested
@return mixed: The newly created video
@throws VideoClientException
|
[
"Creates",
"a",
"new",
"video",
"allowing",
"a",
"specific",
"timeout",
"while",
"waiting",
"for",
"the",
"video",
"to",
"downloaded",
"and",
"encoded",
".",
"If",
"not",
"timeout",
"is",
"set",
"then",
"the",
"function",
"will",
"return",
"immediately",
"before",
"the",
"ingest",
"is",
"complete",
".",
"The",
"video",
"cannot",
"be",
"watermarked",
"until",
"it",
"has",
"been",
"ingested",
"at",
"which",
"point",
"the",
"video",
"status",
"will",
"be",
"INGESTED",
"."
] |
1957cd5574725b24da1bbff9059aa30a9ca123c2
|
https://github.com/shiftio/safestream-php-sdk/blob/1957cd5574725b24da1bbff9059aa30a9ca123c2/src/Video/VideoClient.php#L77-L114
|
19,742 |
shiftio/safestream-php-sdk
|
src/Video/VideoClient.php
|
VideoClient.find
|
public function find($videoKey) {
if(is_null($videoKey) || empty($videoKey)) {
throw new VideoClientException("A key is needed to fnd a video");
}
try {
// Request the video from the SafeStream REST API
$videos = $this->get(sprintf("%s?key=%s", $this->apiResourcePath, $videoKey));
return $videos[0];
} catch (SafeStreamHttpException $e) {
throw new VideoClientException($e);
}
}
|
php
|
public function find($videoKey) {
if(is_null($videoKey) || empty($videoKey)) {
throw new VideoClientException("A key is needed to fnd a video");
}
try {
// Request the video from the SafeStream REST API
$videos = $this->get(sprintf("%s?key=%s", $this->apiResourcePath, $videoKey));
return $videos[0];
} catch (SafeStreamHttpException $e) {
throw new VideoClientException($e);
}
}
|
[
"public",
"function",
"find",
"(",
"$",
"videoKey",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"videoKey",
")",
"||",
"empty",
"(",
"$",
"videoKey",
")",
")",
"{",
"throw",
"new",
"VideoClientException",
"(",
"\"A key is needed to fnd a video\"",
")",
";",
"}",
"try",
"{",
"// Request the video from the SafeStream REST API",
"$",
"videos",
"=",
"$",
"this",
"->",
"get",
"(",
"sprintf",
"(",
"\"%s?key=%s\"",
",",
"$",
"this",
"->",
"apiResourcePath",
",",
"$",
"videoKey",
")",
")",
";",
"return",
"$",
"videos",
"[",
"0",
"]",
";",
"}",
"catch",
"(",
"SafeStreamHttpException",
"$",
"e",
")",
"{",
"throw",
"new",
"VideoClientException",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Gets an existing video by it's key.
@param $videoKey: If no key was passed in when creating the video then the key will be the
source URL of the video
@return mixed: An existing video {@link Video}
@throws VideoClientException
|
[
"Gets",
"an",
"existing",
"video",
"by",
"it",
"s",
"key",
"."
] |
1957cd5574725b24da1bbff9059aa30a9ca123c2
|
https://github.com/shiftio/safestream-php-sdk/blob/1957cd5574725b24da1bbff9059aa30a9ca123c2/src/Video/VideoClient.php#L124-L137
|
19,743 |
webforge-labs/psc-cms
|
lib/Psc/TPL/ContentStream/Converter.php
|
Converter.shiftFirstEntry
|
public function shiftFirstEntry(ContentStream $cs, $type, \Closure $withFilter = NULL) {
if (($entry = $cs->findFirst($type, $withFilter)) != NULL) {
$vars = $this->convertEntryTemplateVariables($entry, $cs);
$cs->removeEntry($entry);
return $vars;
}
return NULL;
}
|
php
|
public function shiftFirstEntry(ContentStream $cs, $type, \Closure $withFilter = NULL) {
if (($entry = $cs->findFirst($type, $withFilter)) != NULL) {
$vars = $this->convertEntryTemplateVariables($entry, $cs);
$cs->removeEntry($entry);
return $vars;
}
return NULL;
}
|
[
"public",
"function",
"shiftFirstEntry",
"(",
"ContentStream",
"$",
"cs",
",",
"$",
"type",
",",
"\\",
"Closure",
"$",
"withFilter",
"=",
"NULL",
")",
"{",
"if",
"(",
"(",
"$",
"entry",
"=",
"$",
"cs",
"->",
"findFirst",
"(",
"$",
"type",
",",
"$",
"withFilter",
")",
")",
"!=",
"NULL",
")",
"{",
"$",
"vars",
"=",
"$",
"this",
"->",
"convertEntryTemplateVariables",
"(",
"$",
"entry",
",",
"$",
"cs",
")",
";",
"$",
"cs",
"->",
"removeEntry",
"(",
"$",
"entry",
")",
";",
"return",
"$",
"vars",
";",
"}",
"return",
"NULL",
";",
"}"
] |
Finds the first occurence of the entry, removes it and returns the template Variables for it
if nothing is found NULL is returned
if entry is found it will be removed from content stream and its variables will be returned
if $withFilter is given the function has to return true to find the entry
@param Closure $withFilter function ($entry) should return TRUE if the filter matches
@return Scalar|NULL
|
[
"Finds",
"the",
"first",
"occurence",
"of",
"the",
"entry",
"removes",
"it",
"and",
"returns",
"the",
"template",
"Variables",
"for",
"it"
] |
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/TPL/ContentStream/Converter.php#L139-L148
|
19,744 |
webforge-labs/psc-cms
|
lib/Psc/TPL/ContentStream/Converter.php
|
Converter.convertUnserialized
|
public function convertUnserialized(Array $serialized, ContentStream $contentStream = NULL) {
if (isset($contentStream)) {
foreach ($serialized as $serializedEntry) {
$entry = $this->unserializeEntry((object) $serializedEntry);
$entry->setContentStream($contentStream);
}
return $contentStream;
} else {
$unserialized = array();
foreach ($serialized as $serializedEntry) {
$unserialized[] = $this->unserializeEntry($serializedEntry);
}
}
return $unserialized;
}
|
php
|
public function convertUnserialized(Array $serialized, ContentStream $contentStream = NULL) {
if (isset($contentStream)) {
foreach ($serialized as $serializedEntry) {
$entry = $this->unserializeEntry((object) $serializedEntry);
$entry->setContentStream($contentStream);
}
return $contentStream;
} else {
$unserialized = array();
foreach ($serialized as $serializedEntry) {
$unserialized[] = $this->unserializeEntry($serializedEntry);
}
}
return $unserialized;
}
|
[
"public",
"function",
"convertUnserialized",
"(",
"Array",
"$",
"serialized",
",",
"ContentStream",
"$",
"contentStream",
"=",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"contentStream",
")",
")",
"{",
"foreach",
"(",
"$",
"serialized",
"as",
"$",
"serializedEntry",
")",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"unserializeEntry",
"(",
"(",
"object",
")",
"$",
"serializedEntry",
")",
";",
"$",
"entry",
"->",
"setContentStream",
"(",
"$",
"contentStream",
")",
";",
"}",
"return",
"$",
"contentStream",
";",
"}",
"else",
"{",
"$",
"unserialized",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"serialized",
"as",
"$",
"serializedEntry",
")",
"{",
"$",
"unserialized",
"[",
"]",
"=",
"$",
"this",
"->",
"unserializeEntry",
"(",
"$",
"serializedEntry",
")",
";",
"}",
"}",
"return",
"$",
"unserialized",
";",
"}"
] |
Convertes an serialized ContentStream to the real object structure
|
[
"Convertes",
"an",
"serialized",
"ContentStream",
"to",
"the",
"real",
"object",
"structure"
] |
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/TPL/ContentStream/Converter.php#L183-L198
|
19,745 |
transfer-framework/ezplatform
|
src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php
|
ObjectService.getContentManager
|
public function getContentManager()
{
if ($this->contentManager != null) {
return $this->contentManager;
}
$this->contentManager = new ContentManager($this->options, $this->getContentService(), $this->getContentTypeService(), $this->getLocationService(), $this->getLocationManager());
if ($this->logger) {
$this->contentManager->setLogger($this->logger);
}
return $this->contentManager;
}
|
php
|
public function getContentManager()
{
if ($this->contentManager != null) {
return $this->contentManager;
}
$this->contentManager = new ContentManager($this->options, $this->getContentService(), $this->getContentTypeService(), $this->getLocationService(), $this->getLocationManager());
if ($this->logger) {
$this->contentManager->setLogger($this->logger);
}
return $this->contentManager;
}
|
[
"public",
"function",
"getContentManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contentManager",
"!=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"contentManager",
";",
"}",
"$",
"this",
"->",
"contentManager",
"=",
"new",
"ContentManager",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"this",
"->",
"getContentService",
"(",
")",
",",
"$",
"this",
"->",
"getContentTypeService",
"(",
")",
",",
"$",
"this",
"->",
"getLocationService",
"(",
")",
",",
"$",
"this",
"->",
"getLocationManager",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"contentManager",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"this",
"->",
"contentManager",
";",
"}"
] |
Returns content manager.
@return ContentManager
|
[
"Returns",
"content",
"manager",
"."
] |
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
|
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php#L79-L92
|
19,746 |
transfer-framework/ezplatform
|
src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php
|
ObjectService.getLocationManager
|
public function getLocationManager()
{
if ($this->locationManager != null) {
return $this->locationManager;
}
$this->locationManager = new LocationManager($this->getLocationService(), $this->getContentService());
if ($this->logger) {
$this->locationManager->setLogger($this->logger);
}
return $this->locationManager;
}
|
php
|
public function getLocationManager()
{
if ($this->locationManager != null) {
return $this->locationManager;
}
$this->locationManager = new LocationManager($this->getLocationService(), $this->getContentService());
if ($this->logger) {
$this->locationManager->setLogger($this->logger);
}
return $this->locationManager;
}
|
[
"public",
"function",
"getLocationManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locationManager",
"!=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"locationManager",
";",
"}",
"$",
"this",
"->",
"locationManager",
"=",
"new",
"LocationManager",
"(",
"$",
"this",
"->",
"getLocationService",
"(",
")",
",",
"$",
"this",
"->",
"getContentService",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"locationManager",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"this",
"->",
"locationManager",
";",
"}"
] |
Returns location manager.
@return LocationManager
|
[
"Returns",
"location",
"manager",
"."
] |
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
|
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php#L99-L112
|
19,747 |
transfer-framework/ezplatform
|
src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php
|
ObjectService.getContentTypeManager
|
public function getContentTypeManager()
{
if ($this->contentTypeManager != null) {
return $this->contentTypeManager;
}
$this->contentTypeManager = new ContentTypeManager($this->getContentTypeService(), $this->getLanguageManager(), $this->getFieldDefinitionSubManager(), $this->getContentTypeGroupSubManager());
if ($this->logger) {
$this->contentTypeManager->setLogger($this->logger);
}
return $this->contentTypeManager;
}
|
php
|
public function getContentTypeManager()
{
if ($this->contentTypeManager != null) {
return $this->contentTypeManager;
}
$this->contentTypeManager = new ContentTypeManager($this->getContentTypeService(), $this->getLanguageManager(), $this->getFieldDefinitionSubManager(), $this->getContentTypeGroupSubManager());
if ($this->logger) {
$this->contentTypeManager->setLogger($this->logger);
}
return $this->contentTypeManager;
}
|
[
"public",
"function",
"getContentTypeManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contentTypeManager",
"!=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"contentTypeManager",
";",
"}",
"$",
"this",
"->",
"contentTypeManager",
"=",
"new",
"ContentTypeManager",
"(",
"$",
"this",
"->",
"getContentTypeService",
"(",
")",
",",
"$",
"this",
"->",
"getLanguageManager",
"(",
")",
",",
"$",
"this",
"->",
"getFieldDefinitionSubManager",
"(",
")",
",",
"$",
"this",
"->",
"getContentTypeGroupSubManager",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"contentTypeManager",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"this",
"->",
"contentTypeManager",
";",
"}"
] |
Returns contenttype manager.
@return ContentTypeManager
|
[
"Returns",
"contenttype",
"manager",
"."
] |
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
|
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php#L119-L132
|
19,748 |
transfer-framework/ezplatform
|
src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php
|
ObjectService.getLanguageManager
|
public function getLanguageManager()
{
if ($this->languageManager != null) {
return $this->languageManager;
}
$this->languageManager = new LanguageManager($this->getLanguageService());
if ($this->logger) {
$this->languageManager->setLogger($this->logger);
}
return $this->languageManager;
}
|
php
|
public function getLanguageManager()
{
if ($this->languageManager != null) {
return $this->languageManager;
}
$this->languageManager = new LanguageManager($this->getLanguageService());
if ($this->logger) {
$this->languageManager->setLogger($this->logger);
}
return $this->languageManager;
}
|
[
"public",
"function",
"getLanguageManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"languageManager",
"!=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"languageManager",
";",
"}",
"$",
"this",
"->",
"languageManager",
"=",
"new",
"LanguageManager",
"(",
"$",
"this",
"->",
"getLanguageService",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"languageManager",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"this",
"->",
"languageManager",
";",
"}"
] |
Returns language manager.
@return LanguageManager
|
[
"Returns",
"language",
"manager",
"."
] |
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
|
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php#L139-L152
|
19,749 |
transfer-framework/ezplatform
|
src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php
|
ObjectService.getUserGroupManager
|
public function getUserGroupManager()
{
if ($this->userGroupManager != null) {
return $this->userGroupManager;
}
$this->userGroupManager = new UserGroupManager($this->options, $this->getUserService(), $this->getContentService(), $this->getContentTypeService());
if ($this->logger) {
$this->userGroupManager->setLogger($this->logger);
}
return $this->userGroupManager;
}
|
php
|
public function getUserGroupManager()
{
if ($this->userGroupManager != null) {
return $this->userGroupManager;
}
$this->userGroupManager = new UserGroupManager($this->options, $this->getUserService(), $this->getContentService(), $this->getContentTypeService());
if ($this->logger) {
$this->userGroupManager->setLogger($this->logger);
}
return $this->userGroupManager;
}
|
[
"public",
"function",
"getUserGroupManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"userGroupManager",
"!=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"userGroupManager",
";",
"}",
"$",
"this",
"->",
"userGroupManager",
"=",
"new",
"UserGroupManager",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"this",
"->",
"getUserService",
"(",
")",
",",
"$",
"this",
"->",
"getContentService",
"(",
")",
",",
"$",
"this",
"->",
"getContentTypeService",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"userGroupManager",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"this",
"->",
"userGroupManager",
";",
"}"
] |
Returns user group manager.
@return UserGroupManager
|
[
"Returns",
"user",
"group",
"manager",
"."
] |
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
|
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php#L159-L172
|
19,750 |
transfer-framework/ezplatform
|
src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php
|
ObjectService.getUserManager
|
public function getUserManager()
{
if ($this->userManager != null) {
return $this->userManager;
}
$this->userManager = new UserManager($this->options, $this->getUserService(), $this->getContentTypeService(), $this->getUserGroupManager());
if ($this->logger) {
$this->userManager->setLogger($this->logger);
}
return $this->userManager;
}
|
php
|
public function getUserManager()
{
if ($this->userManager != null) {
return $this->userManager;
}
$this->userManager = new UserManager($this->options, $this->getUserService(), $this->getContentTypeService(), $this->getUserGroupManager());
if ($this->logger) {
$this->userManager->setLogger($this->logger);
}
return $this->userManager;
}
|
[
"public",
"function",
"getUserManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"userManager",
"!=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"userManager",
";",
"}",
"$",
"this",
"->",
"userManager",
"=",
"new",
"UserManager",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"this",
"->",
"getUserService",
"(",
")",
",",
"$",
"this",
"->",
"getContentTypeService",
"(",
")",
",",
"$",
"this",
"->",
"getUserGroupManager",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"userManager",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"this",
"->",
"userManager",
";",
"}"
] |
Returns user manager.
@return UserManager
|
[
"Returns",
"user",
"manager",
"."
] |
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
|
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ObjectService.php#L179-L192
|
19,751 |
OwlyCode/StreamingBird
|
src/Oauth.php
|
Oauth.prepareHeaders
|
protected function prepareHeaders($method, $url, array $params, array $overrides = [])
{
$oauth = array_merge([
'oauth_consumer_key' => $this->consumerKey,
'oauth_nonce' => md5(uniqid(rand(), true)),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => time(),
'oauth_version' => '1.0A',
'oauth_token' => $this->oauthToken,
], $overrides);
foreach ($oauth as $k => $v) {
$oauth[$k] = rawurlencode($v);
}
foreach ($params as $k => $v) {
$params[$k] = rawurlencode($v);
}
$sigParams = array_merge($oauth, $params);
ksort($sigParams);
$oauth['oauth_signature'] = rawurlencode($this->generateSignature($method, $url, $sigParams));
return $oauth;
}
|
php
|
protected function prepareHeaders($method, $url, array $params, array $overrides = [])
{
$oauth = array_merge([
'oauth_consumer_key' => $this->consumerKey,
'oauth_nonce' => md5(uniqid(rand(), true)),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => time(),
'oauth_version' => '1.0A',
'oauth_token' => $this->oauthToken,
], $overrides);
foreach ($oauth as $k => $v) {
$oauth[$k] = rawurlencode($v);
}
foreach ($params as $k => $v) {
$params[$k] = rawurlencode($v);
}
$sigParams = array_merge($oauth, $params);
ksort($sigParams);
$oauth['oauth_signature'] = rawurlencode($this->generateSignature($method, $url, $sigParams));
return $oauth;
}
|
[
"protected",
"function",
"prepareHeaders",
"(",
"$",
"method",
",",
"$",
"url",
",",
"array",
"$",
"params",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"$",
"oauth",
"=",
"array_merge",
"(",
"[",
"'oauth_consumer_key'",
"=>",
"$",
"this",
"->",
"consumerKey",
",",
"'oauth_nonce'",
"=>",
"md5",
"(",
"uniqid",
"(",
"rand",
"(",
")",
",",
"true",
")",
")",
",",
"'oauth_signature_method'",
"=>",
"'HMAC-SHA1'",
",",
"'oauth_timestamp'",
"=>",
"time",
"(",
")",
",",
"'oauth_version'",
"=>",
"'1.0A'",
",",
"'oauth_token'",
"=>",
"$",
"this",
"->",
"oauthToken",
",",
"]",
",",
"$",
"overrides",
")",
";",
"foreach",
"(",
"$",
"oauth",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"oauth",
"[",
"$",
"k",
"]",
"=",
"rawurlencode",
"(",
"$",
"v",
")",
";",
"}",
"foreach",
"(",
"$",
"params",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"params",
"[",
"$",
"k",
"]",
"=",
"rawurlencode",
"(",
"$",
"v",
")",
";",
"}",
"$",
"sigParams",
"=",
"array_merge",
"(",
"$",
"oauth",
",",
"$",
"params",
")",
";",
"ksort",
"(",
"$",
"sigParams",
")",
";",
"$",
"oauth",
"[",
"'oauth_signature'",
"]",
"=",
"rawurlencode",
"(",
"$",
"this",
"->",
"generateSignature",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"sigParams",
")",
")",
";",
"return",
"$",
"oauth",
";",
"}"
] |
Prepares oauth headers for a given request.
@param string $method
@param string $url
@param array $params
@return array
|
[
"Prepares",
"oauth",
"headers",
"for",
"a",
"given",
"request",
"."
] |
177fc8a9dc8f911865a5abd9ac8d4ef85cef4003
|
https://github.com/OwlyCode/StreamingBird/blob/177fc8a9dc8f911865a5abd9ac8d4ef85cef4003/src/Oauth.php#L67-L92
|
19,752 |
aedart/laravel-helpers
|
src/Traits/Auth/PasswordBrokerFactoryTrait.php
|
PasswordBrokerFactoryTrait.getPasswordBrokerFactory
|
public function getPasswordBrokerFactory(): ?PasswordBrokerFactory
{
if (!$this->hasPasswordBrokerFactory()) {
$this->setPasswordBrokerFactory($this->getDefaultPasswordBrokerFactory());
}
return $this->passwordBrokerFactory;
}
|
php
|
public function getPasswordBrokerFactory(): ?PasswordBrokerFactory
{
if (!$this->hasPasswordBrokerFactory()) {
$this->setPasswordBrokerFactory($this->getDefaultPasswordBrokerFactory());
}
return $this->passwordBrokerFactory;
}
|
[
"public",
"function",
"getPasswordBrokerFactory",
"(",
")",
":",
"?",
"PasswordBrokerFactory",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPasswordBrokerFactory",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setPasswordBrokerFactory",
"(",
"$",
"this",
"->",
"getDefaultPasswordBrokerFactory",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"passwordBrokerFactory",
";",
"}"
] |
Get password broker factory
If no password broker factory has been set, this method will
set and return a default password broker factory, if any such
value is available
@see getDefaultPasswordBrokerFactory()
@return PasswordBrokerFactory|null password broker factory or null if none password broker factory has been set
|
[
"Get",
"password",
"broker",
"factory"
] |
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
|
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Auth/PasswordBrokerFactoryTrait.php#L53-L59
|
19,753 |
aedart/laravel-helpers
|
src/Traits/Broadcasting/BroadcastTrait.php
|
BroadcastTrait.getDefaultBroadcast
|
public function getDefaultBroadcast(): ?Broadcaster
{
// By default, the Broadcast Facade does not return the
// any actual broadcaster, but rather an
// instance of a manager.
// Therefore, we make sure only to obtain its
// "broadcaster", to make sure that its only the
// connection is obtained!
$manager = Broadcast::getFacadeRoot();
if (isset($manager)) {
return $manager->connection();
}
return $manager;
}
|
php
|
public function getDefaultBroadcast(): ?Broadcaster
{
// By default, the Broadcast Facade does not return the
// any actual broadcaster, but rather an
// instance of a manager.
// Therefore, we make sure only to obtain its
// "broadcaster", to make sure that its only the
// connection is obtained!
$manager = Broadcast::getFacadeRoot();
if (isset($manager)) {
return $manager->connection();
}
return $manager;
}
|
[
"public",
"function",
"getDefaultBroadcast",
"(",
")",
":",
"?",
"Broadcaster",
"{",
"// By default, the Broadcast Facade does not return the",
"// any actual broadcaster, but rather an",
"// instance of a manager.",
"// Therefore, we make sure only to obtain its",
"// \"broadcaster\", to make sure that its only the",
"// connection is obtained!",
"$",
"manager",
"=",
"Broadcast",
"::",
"getFacadeRoot",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"manager",
")",
")",
"{",
"return",
"$",
"manager",
"->",
"connection",
"(",
")",
";",
"}",
"return",
"$",
"manager",
";",
"}"
] |
Get a default broadcast value, if any is available
@return Broadcaster|null A default broadcast value or Null if no default value is available
|
[
"Get",
"a",
"default",
"broadcast",
"value",
"if",
"any",
"is",
"available"
] |
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
|
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Broadcasting/BroadcastTrait.php#L76-L89
|
19,754 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.getExports
|
public function getExports($whereUserIsGranted = true)
{
foreach ($this->exports as $alias => $export) {
if ($whereUserIsGranted) {
if ($this->isGrantedForElement($export, null, null)) {
yield $alias => $export;
}
} else {
yield $alias => $export;
}
}
}
|
php
|
public function getExports($whereUserIsGranted = true)
{
foreach ($this->exports as $alias => $export) {
if ($whereUserIsGranted) {
if ($this->isGrantedForElement($export, null, null)) {
yield $alias => $export;
}
} else {
yield $alias => $export;
}
}
}
|
[
"public",
"function",
"getExports",
"(",
"$",
"whereUserIsGranted",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"exports",
"as",
"$",
"alias",
"=>",
"$",
"export",
")",
"{",
"if",
"(",
"$",
"whereUserIsGranted",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isGrantedForElement",
"(",
"$",
"export",
",",
"null",
",",
"null",
")",
")",
"{",
"yield",
"$",
"alias",
"=>",
"$",
"export",
";",
"}",
"}",
"else",
"{",
"yield",
"$",
"alias",
"=>",
"$",
"export",
";",
"}",
"}",
"}"
] |
Return all exports. The exports's alias are the array's keys.
@param boolean $whereUserIsGranted if true (default), restrict to user which are granted the right to execute the export
@return ExportInterface[] an array where export's alias are keys
|
[
"Return",
"all",
"exports",
".",
"The",
"exports",
"s",
"alias",
"are",
"the",
"array",
"s",
"keys",
"."
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L194-L205
|
19,755 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.getExport
|
public function getExport($alias)
{
if (!array_key_exists($alias, $this->exports)) {
throw new \RuntimeException("The export with alias $alias is not known.");
}
return $this->exports[$alias];
}
|
php
|
public function getExport($alias)
{
if (!array_key_exists($alias, $this->exports)) {
throw new \RuntimeException("The export with alias $alias is not known.");
}
return $this->exports[$alias];
}
|
[
"public",
"function",
"getExport",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"exports",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"The export with alias $alias is not known.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"exports",
"[",
"$",
"alias",
"]",
";",
"}"
] |
Return an export by his alias
@param string $alias
@return ExportInterface
@throws \RuntimeException
|
[
"Return",
"an",
"export",
"by",
"his",
"alias"
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L214-L221
|
19,756 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.isGrantedForElement
|
public function isGrantedForElement(ExportElementInterface $element, ExportInterface $export = NULL, array $centers = null)
{
if ($element instanceof ExportInterface) {
$role = $element->requiredRole();
} elseif ($element instanceof ModifierInterface ) {
if (is_null($element->addRole())) {
if (is_null($export)) {
throw new \LogicException("The export should not be null: as the "
. "ModifierInstance element is not an export, we should "
. "be aware of the export to determine which role is required");
} else {
$role = $export->requiredRole();
}
} else {
$role = $element->addRole();
}
} else {
throw new \LogicException("The element is not an ModifiersInterface or "
. "an ExportInterface.");
}
if ($centers === null) {
$centers = $this->authorizationHelper->getReachableCenters($this->user,
$role);
}
if (count($centers) === 0) {
return false;
}
foreach($centers as $center) {
if ($this->authorizationChecker->isGranted($role->getRole(), $center) === false) {
//debugging
$this->logger->debug('user has no access to element', array(
'method' => __METHOD__,
'type' => get_class($element), 'center' => $center->getName()
));
return false;
}
}
return true;
}
|
php
|
public function isGrantedForElement(ExportElementInterface $element, ExportInterface $export = NULL, array $centers = null)
{
if ($element instanceof ExportInterface) {
$role = $element->requiredRole();
} elseif ($element instanceof ModifierInterface ) {
if (is_null($element->addRole())) {
if (is_null($export)) {
throw new \LogicException("The export should not be null: as the "
. "ModifierInstance element is not an export, we should "
. "be aware of the export to determine which role is required");
} else {
$role = $export->requiredRole();
}
} else {
$role = $element->addRole();
}
} else {
throw new \LogicException("The element is not an ModifiersInterface or "
. "an ExportInterface.");
}
if ($centers === null) {
$centers = $this->authorizationHelper->getReachableCenters($this->user,
$role);
}
if (count($centers) === 0) {
return false;
}
foreach($centers as $center) {
if ($this->authorizationChecker->isGranted($role->getRole(), $center) === false) {
//debugging
$this->logger->debug('user has no access to element', array(
'method' => __METHOD__,
'type' => get_class($element), 'center' => $center->getName()
));
return false;
}
}
return true;
}
|
[
"public",
"function",
"isGrantedForElement",
"(",
"ExportElementInterface",
"$",
"element",
",",
"ExportInterface",
"$",
"export",
"=",
"NULL",
",",
"array",
"$",
"centers",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"ExportInterface",
")",
"{",
"$",
"role",
"=",
"$",
"element",
"->",
"requiredRole",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"instanceof",
"ModifierInterface",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"element",
"->",
"addRole",
"(",
")",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"export",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"The export should not be null: as the \"",
".",
"\"ModifierInstance element is not an export, we should \"",
".",
"\"be aware of the export to determine which role is required\"",
")",
";",
"}",
"else",
"{",
"$",
"role",
"=",
"$",
"export",
"->",
"requiredRole",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"role",
"=",
"$",
"element",
"->",
"addRole",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"The element is not an ModifiersInterface or \"",
".",
"\"an ExportInterface.\"",
")",
";",
"}",
"if",
"(",
"$",
"centers",
"===",
"null",
")",
"{",
"$",
"centers",
"=",
"$",
"this",
"->",
"authorizationHelper",
"->",
"getReachableCenters",
"(",
"$",
"this",
"->",
"user",
",",
"$",
"role",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"centers",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"centers",
"as",
"$",
"center",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"authorizationChecker",
"->",
"isGranted",
"(",
"$",
"role",
"->",
"getRole",
"(",
")",
",",
"$",
"center",
")",
"===",
"false",
")",
"{",
"//debugging",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'user has no access to element'",
",",
"array",
"(",
"'method'",
"=>",
"__METHOD__",
",",
"'type'",
"=>",
"get_class",
"(",
"$",
"element",
")",
",",
"'center'",
"=>",
"$",
"center",
"->",
"getName",
"(",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Return true if the current user has access to the ExportElement for every
center, false if the user hasn't access to element for at least one center.
@param \Chill\MainBundle\Export\ExportElementInterface $element
@param array|null $centers, if null, the function take into account all the reachables centers for the current user and the role given by element::requiredRole
@return boolean
|
[
"Return",
"true",
"if",
"the",
"current",
"user",
"has",
"access",
"to",
"the",
"ExportElement",
"for",
"every",
"center",
"false",
"if",
"the",
"user",
"hasn",
"t",
"access",
"to",
"element",
"for",
"at",
"least",
"one",
"center",
"."
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L315-L358
|
19,757 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.&
|
public function &getAggregatorsApplyingOn(ExportInterface $export, array $centers = null)
{
foreach ($this->aggregators as $alias => $aggregator) {
if (in_array($aggregator->applyOn(), $export->supportsModifiers()) &&
$this->isGrantedForElement($aggregator, $export, $centers)) {
yield $alias => $aggregator;
}
}
}
|
php
|
public function &getAggregatorsApplyingOn(ExportInterface $export, array $centers = null)
{
foreach ($this->aggregators as $alias => $aggregator) {
if (in_array($aggregator->applyOn(), $export->supportsModifiers()) &&
$this->isGrantedForElement($aggregator, $export, $centers)) {
yield $alias => $aggregator;
}
}
}
|
[
"public",
"function",
"&",
"getAggregatorsApplyingOn",
"(",
"ExportInterface",
"$",
"export",
",",
"array",
"$",
"centers",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"aggregators",
"as",
"$",
"alias",
"=>",
"$",
"aggregator",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"aggregator",
"->",
"applyOn",
"(",
")",
",",
"$",
"export",
"->",
"supportsModifiers",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"isGrantedForElement",
"(",
"$",
"aggregator",
",",
"$",
"export",
",",
"$",
"centers",
")",
")",
"{",
"yield",
"$",
"alias",
"=>",
"$",
"aggregator",
";",
"}",
"}",
"}"
] |
Return a \Generator containing aggregators which support type
@return AggregatorInterface[] a \Generator that contains aggretagors. The key is the filter's alias
|
[
"Return",
"a",
"\\",
"Generator",
"containing",
"aggregators",
"which",
"support",
"type"
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L365-L373
|
19,758 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.generate
|
public function generate($exportAlias, array $pickedCentersData, array $data, array $formatterData)
{
$export = $this->getExport($exportAlias);
//$qb = $this->em->createQueryBuilder();
$centers = $this->getPickedCenters($pickedCentersData);
$query = $export->initiateQuery(
$this->retrieveUsedModifiers($data),
$this->buildCenterReachableScopes($centers, $export),
$data[ExportType::EXPORT_KEY]
);
if ($query instanceof \Doctrine\ORM\NativeQuery) {
// throw an error if the export require other modifier, which is
// not allowed when the export return a `NativeQuery`
if (count($export->supportsModifiers()) > 0) {
throw new \LogicException("The export with alias `$exportAlias` return "
. "a `\Doctrine\ORM\NativeQuery` and supports modifiers, which is not "
. "allowed. Either the method `supportsModifiers` should return an empty "
. "array, or return a `Doctrine\ORM\QueryBuilder`");
}
} elseif ($query instanceof QueryBuilder) {
//handle filters
$this->handleFilters($export, $query, $data[ExportType::FILTER_KEY], $centers);
//handle aggregators
$this->handleAggregators($export, $query, $data[ExportType::AGGREGATOR_KEY], $centers);
$this->logger->debug('current query is '.$query->getDQL(), array(
'class' => self::class, 'function' => __FUNCTION__
));
} else {
throw new \UnexpectedValueException("The method `intiateQuery` should return "
. "a `\Doctrine\ORM\NativeQuery` or a `Doctrine\ORM\QueryBuilder` "
. "object.");
}
$result = $export->getResult($query, $data[ExportType::EXPORT_KEY]);
if (!is_array($result)) {
throw new \UnexpectedValueException(
sprintf(
'The result of the export should be an array, %s given',
gettype($result)
)
);
}
/* @var $formatter Formatter\CSVFormatter */
$formatter = $this->getFormatter($this->getFormatterAlias($data));
$filters = array();
$aggregatorsData = array();
if ($query instanceof QueryBuilder) {
$aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]);
foreach($aggregators as $alias => $aggregator) {
$aggregatorsData[$alias] = $data[ExportType::AGGREGATOR_KEY][$alias]['form'];
}
}
return $formatter->getResponse(
$result,
$formatterData,
$exportAlias,
$data[ExportType::EXPORT_KEY],
$filters,
$aggregatorsData);
}
|
php
|
public function generate($exportAlias, array $pickedCentersData, array $data, array $formatterData)
{
$export = $this->getExport($exportAlias);
//$qb = $this->em->createQueryBuilder();
$centers = $this->getPickedCenters($pickedCentersData);
$query = $export->initiateQuery(
$this->retrieveUsedModifiers($data),
$this->buildCenterReachableScopes($centers, $export),
$data[ExportType::EXPORT_KEY]
);
if ($query instanceof \Doctrine\ORM\NativeQuery) {
// throw an error if the export require other modifier, which is
// not allowed when the export return a `NativeQuery`
if (count($export->supportsModifiers()) > 0) {
throw new \LogicException("The export with alias `$exportAlias` return "
. "a `\Doctrine\ORM\NativeQuery` and supports modifiers, which is not "
. "allowed. Either the method `supportsModifiers` should return an empty "
. "array, or return a `Doctrine\ORM\QueryBuilder`");
}
} elseif ($query instanceof QueryBuilder) {
//handle filters
$this->handleFilters($export, $query, $data[ExportType::FILTER_KEY], $centers);
//handle aggregators
$this->handleAggregators($export, $query, $data[ExportType::AGGREGATOR_KEY], $centers);
$this->logger->debug('current query is '.$query->getDQL(), array(
'class' => self::class, 'function' => __FUNCTION__
));
} else {
throw new \UnexpectedValueException("The method `intiateQuery` should return "
. "a `\Doctrine\ORM\NativeQuery` or a `Doctrine\ORM\QueryBuilder` "
. "object.");
}
$result = $export->getResult($query, $data[ExportType::EXPORT_KEY]);
if (!is_array($result)) {
throw new \UnexpectedValueException(
sprintf(
'The result of the export should be an array, %s given',
gettype($result)
)
);
}
/* @var $formatter Formatter\CSVFormatter */
$formatter = $this->getFormatter($this->getFormatterAlias($data));
$filters = array();
$aggregatorsData = array();
if ($query instanceof QueryBuilder) {
$aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]);
foreach($aggregators as $alias => $aggregator) {
$aggregatorsData[$alias] = $data[ExportType::AGGREGATOR_KEY][$alias]['form'];
}
}
return $formatter->getResponse(
$result,
$formatterData,
$exportAlias,
$data[ExportType::EXPORT_KEY],
$filters,
$aggregatorsData);
}
|
[
"public",
"function",
"generate",
"(",
"$",
"exportAlias",
",",
"array",
"$",
"pickedCentersData",
",",
"array",
"$",
"data",
",",
"array",
"$",
"formatterData",
")",
"{",
"$",
"export",
"=",
"$",
"this",
"->",
"getExport",
"(",
"$",
"exportAlias",
")",
";",
"//$qb = $this->em->createQueryBuilder();",
"$",
"centers",
"=",
"$",
"this",
"->",
"getPickedCenters",
"(",
"$",
"pickedCentersData",
")",
";",
"$",
"query",
"=",
"$",
"export",
"->",
"initiateQuery",
"(",
"$",
"this",
"->",
"retrieveUsedModifiers",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"buildCenterReachableScopes",
"(",
"$",
"centers",
",",
"$",
"export",
")",
",",
"$",
"data",
"[",
"ExportType",
"::",
"EXPORT_KEY",
"]",
")",
";",
"if",
"(",
"$",
"query",
"instanceof",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"NativeQuery",
")",
"{",
"// throw an error if the export require other modifier, which is ",
"// not allowed when the export return a `NativeQuery`",
"if",
"(",
"count",
"(",
"$",
"export",
"->",
"supportsModifiers",
"(",
")",
")",
">",
"0",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"The export with alias `$exportAlias` return \"",
".",
"\"a `\\Doctrine\\ORM\\NativeQuery` and supports modifiers, which is not \"",
".",
"\"allowed. Either the method `supportsModifiers` should return an empty \"",
".",
"\"array, or return a `Doctrine\\ORM\\QueryBuilder`\"",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"query",
"instanceof",
"QueryBuilder",
")",
"{",
"//handle filters",
"$",
"this",
"->",
"handleFilters",
"(",
"$",
"export",
",",
"$",
"query",
",",
"$",
"data",
"[",
"ExportType",
"::",
"FILTER_KEY",
"]",
",",
"$",
"centers",
")",
";",
"//handle aggregators",
"$",
"this",
"->",
"handleAggregators",
"(",
"$",
"export",
",",
"$",
"query",
",",
"$",
"data",
"[",
"ExportType",
"::",
"AGGREGATOR_KEY",
"]",
",",
"$",
"centers",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'current query is '",
".",
"$",
"query",
"->",
"getDQL",
"(",
")",
",",
"array",
"(",
"'class'",
"=>",
"self",
"::",
"class",
",",
"'function'",
"=>",
"__FUNCTION__",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"The method `intiateQuery` should return \"",
".",
"\"a `\\Doctrine\\ORM\\NativeQuery` or a `Doctrine\\ORM\\QueryBuilder` \"",
".",
"\"object.\"",
")",
";",
"}",
"$",
"result",
"=",
"$",
"export",
"->",
"getResult",
"(",
"$",
"query",
",",
"$",
"data",
"[",
"ExportType",
"::",
"EXPORT_KEY",
"]",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"result",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'The result of the export should be an array, %s given'",
",",
"gettype",
"(",
"$",
"result",
")",
")",
")",
";",
"}",
"/* @var $formatter Formatter\\CSVFormatter */",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
"$",
"this",
"->",
"getFormatterAlias",
"(",
"$",
"data",
")",
")",
";",
"$",
"filters",
"=",
"array",
"(",
")",
";",
"$",
"aggregatorsData",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"query",
"instanceof",
"QueryBuilder",
")",
"{",
"$",
"aggregators",
"=",
"$",
"this",
"->",
"retrieveUsedAggregators",
"(",
"$",
"data",
"[",
"ExportType",
"::",
"AGGREGATOR_KEY",
"]",
")",
";",
"foreach",
"(",
"$",
"aggregators",
"as",
"$",
"alias",
"=>",
"$",
"aggregator",
")",
"{",
"$",
"aggregatorsData",
"[",
"$",
"alias",
"]",
"=",
"$",
"data",
"[",
"ExportType",
"::",
"AGGREGATOR_KEY",
"]",
"[",
"$",
"alias",
"]",
"[",
"'form'",
"]",
";",
"}",
"}",
"return",
"$",
"formatter",
"->",
"getResponse",
"(",
"$",
"result",
",",
"$",
"formatterData",
",",
"$",
"exportAlias",
",",
"$",
"data",
"[",
"ExportType",
"::",
"EXPORT_KEY",
"]",
",",
"$",
"filters",
",",
"$",
"aggregatorsData",
")",
";",
"}"
] |
Generate a response which contains the requested data.
@param string $exportAlias
@param mixed[] $data
@return Response
|
[
"Generate",
"a",
"response",
"which",
"contains",
"the",
"requested",
"data",
"."
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L382-L450
|
19,759 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.buildCenterReachableScopes
|
private function buildCenterReachableScopes(array $centers, ExportElementInterface $element) {
$r = array();
foreach($centers as $center) {
$r[] = array(
'center' => $center,
'circles' => $this->authorizationHelper->getReachableScopes($this->user,
$element->requiredRole(), $center)
);
}
return $r;
}
|
php
|
private function buildCenterReachableScopes(array $centers, ExportElementInterface $element) {
$r = array();
foreach($centers as $center) {
$r[] = array(
'center' => $center,
'circles' => $this->authorizationHelper->getReachableScopes($this->user,
$element->requiredRole(), $center)
);
}
return $r;
}
|
[
"private",
"function",
"buildCenterReachableScopes",
"(",
"array",
"$",
"centers",
",",
"ExportElementInterface",
"$",
"element",
")",
"{",
"$",
"r",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"centers",
"as",
"$",
"center",
")",
"{",
"$",
"r",
"[",
"]",
"=",
"array",
"(",
"'center'",
"=>",
"$",
"center",
",",
"'circles'",
"=>",
"$",
"this",
"->",
"authorizationHelper",
"->",
"getReachableScopes",
"(",
"$",
"this",
"->",
"user",
",",
"$",
"element",
"->",
"requiredRole",
"(",
")",
",",
"$",
"center",
")",
")",
";",
"}",
"return",
"$",
"r",
";",
"}"
] |
build the array required for defining centers and circles in the initiate
queries of ExportElementsInterfaces
@param \Chill\MainBundle\Entity\Center[] $centers
|
[
"build",
"the",
"array",
"required",
"for",
"defining",
"centers",
"and",
"circles",
"in",
"the",
"initiate",
"queries",
"of",
"ExportElementsInterfaces"
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L458-L470
|
19,760 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.getUsedAggregatorsAliases
|
public function getUsedAggregatorsAliases(array $data)
{
$aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]);
return array_keys(iterator_to_array($aggregators));
}
|
php
|
public function getUsedAggregatorsAliases(array $data)
{
$aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]);
return array_keys(iterator_to_array($aggregators));
}
|
[
"public",
"function",
"getUsedAggregatorsAliases",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"aggregators",
"=",
"$",
"this",
"->",
"retrieveUsedAggregators",
"(",
"$",
"data",
"[",
"ExportType",
"::",
"AGGREGATOR_KEY",
"]",
")",
";",
"return",
"array_keys",
"(",
"iterator_to_array",
"(",
"$",
"aggregators",
")",
")",
";",
"}"
] |
get the aggregators typse used in the form export data
@param array $data the data from the export form
@return string[]
|
[
"get",
"the",
"aggregators",
"typse",
"used",
"in",
"the",
"form",
"export",
"data"
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L478-L483
|
19,761 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.retrieveUsedModifiers
|
private function retrieveUsedModifiers($data)
{
$usedTypes = array_merge(
$this->retrieveUsedFiltersType($data[ExportType::FILTER_KEY]),
$this->retrieveUsedAggregatorsType($data[ExportType::AGGREGATOR_KEY])
);
$this->logger->debug('Required types are '.implode(', ', $usedTypes),
array('class' => self::class, 'function' => __FUNCTION__));
return array_unique($usedTypes);
}
|
php
|
private function retrieveUsedModifiers($data)
{
$usedTypes = array_merge(
$this->retrieveUsedFiltersType($data[ExportType::FILTER_KEY]),
$this->retrieveUsedAggregatorsType($data[ExportType::AGGREGATOR_KEY])
);
$this->logger->debug('Required types are '.implode(', ', $usedTypes),
array('class' => self::class, 'function' => __FUNCTION__));
return array_unique($usedTypes);
}
|
[
"private",
"function",
"retrieveUsedModifiers",
"(",
"$",
"data",
")",
"{",
"$",
"usedTypes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"retrieveUsedFiltersType",
"(",
"$",
"data",
"[",
"ExportType",
"::",
"FILTER_KEY",
"]",
")",
",",
"$",
"this",
"->",
"retrieveUsedAggregatorsType",
"(",
"$",
"data",
"[",
"ExportType",
"::",
"AGGREGATOR_KEY",
"]",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Required types are '",
".",
"implode",
"(",
"', '",
",",
"$",
"usedTypes",
")",
",",
"array",
"(",
"'class'",
"=>",
"self",
"::",
"class",
",",
"'function'",
"=>",
"__FUNCTION__",
")",
")",
";",
"return",
"array_unique",
"(",
"$",
"usedTypes",
")",
";",
"}"
] |
parse the data to retrieve the used filters and aggregators
@param mixed $data
@return string[]
|
[
"parse",
"the",
"data",
"to",
"retrieve",
"the",
"used",
"filters",
"and",
"aggregators"
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L514-L525
|
19,762 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.retrieveUsedFiltersType
|
private function retrieveUsedFiltersType($data)
{
$usedTypes = array();
foreach($data as $alias => $filterData) {
if ($filterData['enabled'] == true){
$filter = $this->getFilter($alias);
if (!in_array($filter->applyOn(), $usedTypes)) {
array_push($usedTypes, $filter->applyOn());
}
}
}
return $usedTypes;
}
|
php
|
private function retrieveUsedFiltersType($data)
{
$usedTypes = array();
foreach($data as $alias => $filterData) {
if ($filterData['enabled'] == true){
$filter = $this->getFilter($alias);
if (!in_array($filter->applyOn(), $usedTypes)) {
array_push($usedTypes, $filter->applyOn());
}
}
}
return $usedTypes;
}
|
[
"private",
"function",
"retrieveUsedFiltersType",
"(",
"$",
"data",
")",
"{",
"$",
"usedTypes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"alias",
"=>",
"$",
"filterData",
")",
"{",
"if",
"(",
"$",
"filterData",
"[",
"'enabled'",
"]",
"==",
"true",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"getFilter",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"filter",
"->",
"applyOn",
"(",
")",
",",
"$",
"usedTypes",
")",
")",
"{",
"array_push",
"(",
"$",
"usedTypes",
",",
"$",
"filter",
"->",
"applyOn",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"usedTypes",
";",
"}"
] |
Retrieve the filter used in this export.
@param mixed $data the data from the `filters` key of the ExportType
@return array an array with types
|
[
"Retrieve",
"the",
"filter",
"used",
"in",
"this",
"export",
"."
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L533-L546
|
19,763 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.handleFilters
|
private function handleFilters(
ExportInterface $export,
QueryBuilder $qb,
$data,
array $centers)
{
$filters = $this->retrieveUsedFilters($data);
foreach($filters as $alias => $filter) {
if ($this->isGrantedForElement($filter, $export, $centers) === false) {
throw new UnauthorizedHttpException("You are not authorized to "
. "use the filter ".$filter->getTitle());
}
$formData = $data[$alias];
$this->logger->debug('alter query by filter '.$alias, array(
'class' => self::class, 'function' => __FUNCTION__
));
$filter->alterQuery($qb, $formData['form']);
}
}
|
php
|
private function handleFilters(
ExportInterface $export,
QueryBuilder $qb,
$data,
array $centers)
{
$filters = $this->retrieveUsedFilters($data);
foreach($filters as $alias => $filter) {
if ($this->isGrantedForElement($filter, $export, $centers) === false) {
throw new UnauthorizedHttpException("You are not authorized to "
. "use the filter ".$filter->getTitle());
}
$formData = $data[$alias];
$this->logger->debug('alter query by filter '.$alias, array(
'class' => self::class, 'function' => __FUNCTION__
));
$filter->alterQuery($qb, $formData['form']);
}
}
|
[
"private",
"function",
"handleFilters",
"(",
"ExportInterface",
"$",
"export",
",",
"QueryBuilder",
"$",
"qb",
",",
"$",
"data",
",",
"array",
"$",
"centers",
")",
"{",
"$",
"filters",
"=",
"$",
"this",
"->",
"retrieveUsedFilters",
"(",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"alias",
"=>",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isGrantedForElement",
"(",
"$",
"filter",
",",
"$",
"export",
",",
"$",
"centers",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"UnauthorizedHttpException",
"(",
"\"You are not authorized to \"",
".",
"\"use the filter \"",
".",
"$",
"filter",
"->",
"getTitle",
"(",
")",
")",
";",
"}",
"$",
"formData",
"=",
"$",
"data",
"[",
"$",
"alias",
"]",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'alter query by filter '",
".",
"$",
"alias",
",",
"array",
"(",
"'class'",
"=>",
"self",
"::",
"class",
",",
"'function'",
"=>",
"__FUNCTION__",
")",
")",
";",
"$",
"filter",
"->",
"alterQuery",
"(",
"$",
"qb",
",",
"$",
"formData",
"[",
"'form'",
"]",
")",
";",
"}",
"}"
] |
alter the query with selected filters.
This function check the acl.
@param ExportInterface $export
@param QueryBuilder $qb
@param mixed $data the data under the initial 'filters' data
@param \Chill\MainBundle\Entity\Center[] $centers the picked centers
@throw UnauthorizedHttpException if the user is not authorized
|
[
"alter",
"the",
"query",
"with",
"selected",
"filters",
"."
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L603-L625
|
19,764 |
Chill-project/Main
|
Export/ExportManager.php
|
ExportManager.handleAggregators
|
private function handleAggregators(
ExportInterface $export,
QueryBuilder $qb,
$data,
array $center)
{
$aggregators = $this->retrieveUsedAggregators($data);
foreach ($aggregators as $alias => $aggregator) {
$formData = $data[$alias];
$aggregator->alterQuery($qb, $formData['form']);
}
}
|
php
|
private function handleAggregators(
ExportInterface $export,
QueryBuilder $qb,
$data,
array $center)
{
$aggregators = $this->retrieveUsedAggregators($data);
foreach ($aggregators as $alias => $aggregator) {
$formData = $data[$alias];
$aggregator->alterQuery($qb, $formData['form']);
}
}
|
[
"private",
"function",
"handleAggregators",
"(",
"ExportInterface",
"$",
"export",
",",
"QueryBuilder",
"$",
"qb",
",",
"$",
"data",
",",
"array",
"$",
"center",
")",
"{",
"$",
"aggregators",
"=",
"$",
"this",
"->",
"retrieveUsedAggregators",
"(",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"aggregators",
"as",
"$",
"alias",
"=>",
"$",
"aggregator",
")",
"{",
"$",
"formData",
"=",
"$",
"data",
"[",
"$",
"alias",
"]",
";",
"$",
"aggregator",
"->",
"alterQuery",
"(",
"$",
"qb",
",",
"$",
"formData",
"[",
"'form'",
"]",
")",
";",
"}",
"}"
] |
Alter the query with selected aggregators
Check for acl. If an user is not authorized to see an aggregator, throw an
UnauthorizedException.
@param ExportInterface $export
@param QueryBuilder $qb
@param type $data
@param \Chill\MainBundle\Entity\Center[] $centers the picked centers
@throw UnauthorizedHttpException if the user is not authorized
|
[
"Alter",
"the",
"query",
"with",
"selected",
"aggregators"
] |
384cb6c793072a4f1047dc5cafc2157ee2419f60
|
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/ExportManager.php#L639-L651
|
19,765 |
2amigos/yiifoundation
|
helpers/Nav.php
|
Nav.side
|
public static function side($items, $htmlOptions = array())
{
ArrayHelper::addValue('class', Enum::NAV_SIDE, $htmlOptions);
ob_start();
echo \CHtml::openTag('ul', $htmlOptions);
foreach ($items as $item) {
if (is_string($item)) // treat as divider
echo \CHtml::tag('li', array('class' => Enum::NAV_DIVIDER));
else {
$itemOptions = ArrayHelper::getValue($item, 'itemOptions', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$label = ArrayHelper::getValue($item, 'label', 'Item');
$url = ArrayHelper::getValue($item, 'url', '#');
echo \CHtml::openTag('li', $itemOptions);
echo \CHtml::link($label, $url, $linkOptions);
echo \CHtml::closeTag('li');
}
}
echo \CHtml::closeTag('ul');
return ob_get_clean();
}
|
php
|
public static function side($items, $htmlOptions = array())
{
ArrayHelper::addValue('class', Enum::NAV_SIDE, $htmlOptions);
ob_start();
echo \CHtml::openTag('ul', $htmlOptions);
foreach ($items as $item) {
if (is_string($item)) // treat as divider
echo \CHtml::tag('li', array('class' => Enum::NAV_DIVIDER));
else {
$itemOptions = ArrayHelper::getValue($item, 'itemOptions', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$label = ArrayHelper::getValue($item, 'label', 'Item');
$url = ArrayHelper::getValue($item, 'url', '#');
echo \CHtml::openTag('li', $itemOptions);
echo \CHtml::link($label, $url, $linkOptions);
echo \CHtml::closeTag('li');
}
}
echo \CHtml::closeTag('ul');
return ob_get_clean();
}
|
[
"public",
"static",
"function",
"side",
"(",
"$",
"items",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"Enum",
"::",
"NAV_SIDE",
",",
"$",
"htmlOptions",
")",
";",
"ob_start",
"(",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'ul'",
",",
"$",
"htmlOptions",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"// treat as divider",
"echo",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"array",
"(",
"'class'",
"=>",
"Enum",
"::",
"NAV_DIVIDER",
")",
")",
";",
"else",
"{",
"$",
"itemOptions",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'itemOptions'",
",",
"array",
"(",
")",
")",
";",
"$",
"linkOptions",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'linkOptions'",
",",
"array",
"(",
")",
")",
";",
"$",
"label",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'label'",
",",
"'Item'",
")",
";",
"$",
"url",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'url'",
",",
"'#'",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'li'",
",",
"$",
"itemOptions",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"link",
"(",
"$",
"label",
",",
"$",
"url",
",",
"$",
"linkOptions",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'li'",
")",
";",
"}",
"}",
"echo",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'ul'",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
] |
Generates a side nav
@param array $items the link items to display as a side nav. The items have the following format:
<pre>
array('label'=>'Item', 'url'=>'#', 'linkOptions'=>array(), 'itemOptions'=>array())
</pre>
@param array $htmlOptions
@return string
@see http://foundation.zurb.com/docs/components/side-nav.html
|
[
"Generates",
"a",
"side",
"nav"
] |
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
|
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Nav.php#L33-L56
|
19,766 |
2amigos/yiifoundation
|
helpers/Nav.php
|
Nav.sub
|
public static function sub($items, $htmlOptions = array())
{
ArrayHelper::addValue('class', Enum::NAV_SUB, $htmlOptions);
ob_start();
echo \CHtml::openTag('dl', $htmlOptions);
foreach ($items as $item) {
$itemOptions = ArrayHelper::getValue($item, 'itemOptions', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$label = ArrayHelper::getValue($item, 'label', 'Item');
$url = ArrayHelper::getValue($item, 'url', '#');
echo \CHtml::openTag('dt', $itemOptions);
echo \CHtml::link($label, $url, $linkOptions);
echo \CHtml::closeTag('dt');
}
echo \CHtml::closeTag('dl');
return ob_get_clean();
}
|
php
|
public static function sub($items, $htmlOptions = array())
{
ArrayHelper::addValue('class', Enum::NAV_SUB, $htmlOptions);
ob_start();
echo \CHtml::openTag('dl', $htmlOptions);
foreach ($items as $item) {
$itemOptions = ArrayHelper::getValue($item, 'itemOptions', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$label = ArrayHelper::getValue($item, 'label', 'Item');
$url = ArrayHelper::getValue($item, 'url', '#');
echo \CHtml::openTag('dt', $itemOptions);
echo \CHtml::link($label, $url, $linkOptions);
echo \CHtml::closeTag('dt');
}
echo \CHtml::closeTag('dl');
return ob_get_clean();
}
|
[
"public",
"static",
"function",
"sub",
"(",
"$",
"items",
",",
"$",
"htmlOptions",
"=",
"array",
"(",
")",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"Enum",
"::",
"NAV_SUB",
",",
"$",
"htmlOptions",
")",
";",
"ob_start",
"(",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'dl'",
",",
"$",
"htmlOptions",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"itemOptions",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'itemOptions'",
",",
"array",
"(",
")",
")",
";",
"$",
"linkOptions",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'linkOptions'",
",",
"array",
"(",
")",
")",
";",
"$",
"label",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'label'",
",",
"'Item'",
")",
";",
"$",
"url",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'url'",
",",
"'#'",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'dt'",
",",
"$",
"itemOptions",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"link",
"(",
"$",
"label",
",",
"$",
"url",
",",
"$",
"linkOptions",
")",
";",
"echo",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'dt'",
")",
";",
"}",
"echo",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'dl'",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
] |
Generates a foundation sub nav
@param array $items the link items to display as a side nav. The items have the following format:
<pre>
array('label'=>'Item', 'url'=>'#', 'linkOptions'=>array(), 'itemOptions'=>array())
</pre>
@param array $htmlOptions
@return string
@see http://foundation.zurb.com/docs/components/sub-nav.html
|
[
"Generates",
"a",
"foundation",
"sub",
"nav"
] |
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
|
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Nav.php#L69-L86
|
19,767 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.boot
|
public function boot()
{
if (!$this->booted) {
foreach ($this->container->getProviders() as $provider) {
$provider->boot($this);
}
$this->booted = true;
}
}
|
php
|
public function boot()
{
if (!$this->booted) {
foreach ($this->container->getProviders() as $provider) {
$provider->boot($this);
}
$this->booted = true;
}
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"booted",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"container",
"->",
"getProviders",
"(",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"provider",
"->",
"boot",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"booted",
"=",
"true",
";",
"}",
"}"
] |
Boots of the all providers of the application
@access public
@return void
|
[
"Boots",
"of",
"the",
"all",
"providers",
"of",
"the",
"application"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L81-L90
|
19,768 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.getAppDir
|
public function getAppDir()
{
if (null === $this->container->getAppDir()) {
$r = new \ReflectionObject($this);
$this->container->setAppDir(str_replace('\\', '/', dirname($r->getFileName())));
}
return $this->container->getAppDir();
}
|
php
|
public function getAppDir()
{
if (null === $this->container->getAppDir()) {
$r = new \ReflectionObject($this);
$this->container->setAppDir(str_replace('\\', '/', dirname($r->getFileName())));
}
return $this->container->getAppDir();
}
|
[
"public",
"function",
"getAppDir",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"container",
"->",
"getAppDir",
"(",
")",
")",
"{",
"$",
"r",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"container",
"->",
"setAppDir",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"dirname",
"(",
"$",
"r",
"->",
"getFileName",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"->",
"getAppDir",
"(",
")",
";",
"}"
] |
Get Application Dir
@return string Application Dir
|
[
"Get",
"Application",
"Dir"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L139-L147
|
19,769 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.getInstance
|
public static function getInstance(array $userSettings = array())
{
if (!self::$instance) {
self::$instance = new self($userSettings);
}
return self::$instance;
}
|
php
|
public static function getInstance(array $userSettings = array())
{
if (!self::$instance) {
self::$instance = new self($userSettings);
}
return self::$instance;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
"array",
"$",
"userSettings",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"instance",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
"(",
"$",
"userSettings",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] |
Get instance of MVC
@param array $userSettings
@return MVC
|
[
"Get",
"instance",
"of",
"MVC"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L192-L199
|
19,770 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.group
|
public function group()
{
$args = func_get_args();
$route = array_shift($args);
$callable = array_pop($args);
if (is_string($route) && is_callable($callable)) {
call_user_func($callable, $route);
}
}
|
php
|
public function group()
{
$args = func_get_args();
$route = array_shift($args);
$callable = array_pop($args);
if (is_string($route) && is_callable($callable)) {
call_user_func($callable, $route);
}
}
|
[
"public",
"function",
"group",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"route",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"callable",
"=",
"array_pop",
"(",
"$",
"args",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"route",
")",
"&&",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"route",
")",
";",
"}",
"}"
] |
Add Group routes
@access public
@return void
|
[
"Add",
"Group",
"routes"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L325-L333
|
19,771 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.ajax
|
public function ajax($patternUri, $action, $name)
{
$route = new Route("ajax", $patternUri, $action, $name);
$this->container->addRoute($route);
return $route;
}
|
php
|
public function ajax($patternUri, $action, $name)
{
$route = new Route("ajax", $patternUri, $action, $name);
$this->container->addRoute($route);
return $route;
}
|
[
"public",
"function",
"ajax",
"(",
"$",
"patternUri",
",",
"$",
"action",
",",
"$",
"name",
")",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
"\"ajax\"",
",",
"$",
"patternUri",
",",
"$",
"action",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"container",
"->",
"addRoute",
"(",
"$",
"route",
")",
";",
"return",
"$",
"route",
";",
"}"
] |
Add AJAX route
@access public
@param string $patternUri
@param string|\callable $action
@paran string $name
@return Route
|
[
"Add",
"AJAX",
"route"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L344-L349
|
19,772 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.registerProvider
|
public function registerProvider(Provider $provider)
{
$provider->register($this);
$this->container->addProvider($provider);
return $this;
}
|
php
|
public function registerProvider(Provider $provider)
{
$provider->register($this);
$this->container->addProvider($provider);
return $this;
}
|
[
"public",
"function",
"registerProvider",
"(",
"Provider",
"$",
"provider",
")",
"{",
"$",
"provider",
"->",
"register",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"container",
"->",
"addProvider",
"(",
"$",
"provider",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Register the providers
@access public
@param Provider $provider
@return MVC
|
[
"Register",
"the",
"providers"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L499-L506
|
19,773 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.setRoutes
|
public function setRoutes()
{
$routesJsonFile = $this->getAppDir() . '/config/routes.json';
$routesPhpFile = $this->getAppDir() . '/config/routes.php';
$routes = array();
if (file_exists($routesJsonFile)) {
$routes[] = json_decode(file_get_contents($routesJsonFile), true);
} elseif (file_exists($routesPhpFile)) {
$routes[] = require_once $routesPhpFile;
}
foreach ($this->container->getModules() as $module) {
$extension = $module->getModuleExtension();
if (is_object($extension) && $extension instanceof Injection\Extension) {
$routes[] = $extension->loadRoutes();
}
}
return $routes;
}
|
php
|
public function setRoutes()
{
$routesJsonFile = $this->getAppDir() . '/config/routes.json';
$routesPhpFile = $this->getAppDir() . '/config/routes.php';
$routes = array();
if (file_exists($routesJsonFile)) {
$routes[] = json_decode(file_get_contents($routesJsonFile), true);
} elseif (file_exists($routesPhpFile)) {
$routes[] = require_once $routesPhpFile;
}
foreach ($this->container->getModules() as $module) {
$extension = $module->getModuleExtension();
if (is_object($extension) && $extension instanceof Injection\Extension) {
$routes[] = $extension->loadRoutes();
}
}
return $routes;
}
|
[
"public",
"function",
"setRoutes",
"(",
")",
"{",
"$",
"routesJsonFile",
"=",
"$",
"this",
"->",
"getAppDir",
"(",
")",
".",
"'/config/routes.json'",
";",
"$",
"routesPhpFile",
"=",
"$",
"this",
"->",
"getAppDir",
"(",
")",
".",
"'/config/routes.php'",
";",
"$",
"routes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"routesJsonFile",
")",
")",
"{",
"$",
"routes",
"[",
"]",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"routesJsonFile",
")",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"file_exists",
"(",
"$",
"routesPhpFile",
")",
")",
"{",
"$",
"routes",
"[",
"]",
"=",
"require_once",
"$",
"routesPhpFile",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"container",
"->",
"getModules",
"(",
")",
"as",
"$",
"module",
")",
"{",
"$",
"extension",
"=",
"$",
"module",
"->",
"getModuleExtension",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"extension",
")",
"&&",
"$",
"extension",
"instanceof",
"Injection",
"\\",
"Extension",
")",
"{",
"$",
"routes",
"[",
"]",
"=",
"$",
"extension",
"->",
"loadRoutes",
"(",
")",
";",
"}",
"}",
"return",
"$",
"routes",
";",
"}"
] |
Set Routes from JSON|PHP File
@return Route[]
|
[
"Set",
"Routes",
"from",
"JSON|PHP",
"File"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L547-L567
|
19,774 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.share
|
public static function share($callable)
{
if (!is_object($callable) || !method_exists($callable, '__invoke')) {
throw new InvalidArgumentException('Callable is not a Closure or invokable object.');
}
return function ($c) use ($callable) {
static $object;
if (null === $object) {
$object = $callable($c);
}
return $object;
};
}
|
php
|
public static function share($callable)
{
if (!is_object($callable) || !method_exists($callable, '__invoke')) {
throw new InvalidArgumentException('Callable is not a Closure or invokable object.');
}
return function ($c) use ($callable) {
static $object;
if (null === $object) {
$object = $callable($c);
}
return $object;
};
}
|
[
"public",
"static",
"function",
"share",
"(",
"$",
"callable",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"callable",
")",
"||",
"!",
"method_exists",
"(",
"$",
"callable",
",",
"'__invoke'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Callable is not a Closure or invokable object.'",
")",
";",
"}",
"return",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"callable",
")",
"{",
"static",
"$",
"object",
";",
"if",
"(",
"null",
"===",
"$",
"object",
")",
"{",
"$",
"object",
"=",
"$",
"callable",
"(",
"$",
"c",
")",
";",
"}",
"return",
"$",
"object",
";",
"}",
";",
"}"
] |
Share a clousure object or callback object
@access public
@param $callable
@return callable
@throws InvalidArgumentException
|
[
"Share",
"a",
"clousure",
"object",
"or",
"callback",
"object"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L577-L592
|
19,775 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.urlFor
|
public function urlFor($path, $type_name = 'asset', array $params = array())
{
switch ($type_name) {
case 'asset':
return $this->container->getRequest()->getRootUri() . $path;
break;
case 'route':
$routeUrl = $this->container->getRequest()->getRootUri($this->getSetting('debug')) . $this->container->getRoute($path)->getPatternUri();
return (!empty($params)) ? $routeUrl . '?' . http_build_query($params) : $routeUrl;
break;
}
}
|
php
|
public function urlFor($path, $type_name = 'asset', array $params = array())
{
switch ($type_name) {
case 'asset':
return $this->container->getRequest()->getRootUri() . $path;
break;
case 'route':
$routeUrl = $this->container->getRequest()->getRootUri($this->getSetting('debug')) . $this->container->getRoute($path)->getPatternUri();
return (!empty($params)) ? $routeUrl . '?' . http_build_query($params) : $routeUrl;
break;
}
}
|
[
"public",
"function",
"urlFor",
"(",
"$",
"path",
",",
"$",
"type_name",
"=",
"'asset'",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"switch",
"(",
"$",
"type_name",
")",
"{",
"case",
"'asset'",
":",
"return",
"$",
"this",
"->",
"container",
"->",
"getRequest",
"(",
")",
"->",
"getRootUri",
"(",
")",
".",
"$",
"path",
";",
"break",
";",
"case",
"'route'",
":",
"$",
"routeUrl",
"=",
"$",
"this",
"->",
"container",
"->",
"getRequest",
"(",
")",
"->",
"getRootUri",
"(",
"$",
"this",
"->",
"getSetting",
"(",
"'debug'",
")",
")",
".",
"$",
"this",
"->",
"container",
"->",
"getRoute",
"(",
"$",
"path",
")",
"->",
"getPatternUri",
"(",
")",
";",
"return",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"?",
"$",
"routeUrl",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
":",
"$",
"routeUrl",
";",
"break",
";",
"}",
"}"
] |
Return the url for the path given
@param string $path Path url path or Route name if type_name is not uri
@param string $type_name Url type uri|route
@param array $params Array params route
@return string
|
[
"Return",
"the",
"url",
"for",
"the",
"path",
"given"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L620-L631
|
19,776 |
simple-php-mvc/simple-php-mvc
|
src/MVC/MVC.php
|
MVC.data
|
public function data($json = false)
{
return ($json) ? $this->container->getRequest()->data->JSON : $this->container->getRequest()->data;
}
|
php
|
public function data($json = false)
{
return ($json) ? $this->container->getRequest()->data->JSON : $this->container->getRequest()->data;
}
|
[
"public",
"function",
"data",
"(",
"$",
"json",
"=",
"false",
")",
"{",
"return",
"(",
"$",
"json",
")",
"?",
"$",
"this",
"->",
"container",
"->",
"getRequest",
"(",
")",
"->",
"data",
"->",
"JSON",
":",
"$",
"this",
"->",
"container",
"->",
"getRequest",
"(",
")",
"->",
"data",
";",
"}"
] |
Get the data of request
@access public
@return \stdClass
|
[
"Get",
"the",
"data",
"of",
"request"
] |
e319eb09d29afad6993acb4a7e35f32a87dd0841
|
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/MVC.php#L677-L680
|
19,777 |
nguyenanhung/nusoap
|
src/nusoap_client_mime.php
|
nusoap_client_mime.addAttachment
|
function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = FALSE)
{
if (!$cid) {
$cid = md5(uniqid(time()));
}
$info['data'] = $data;
$info['filename'] = $filename;
$info['contenttype'] = $contenttype;
$info['cid'] = $cid;
$this->requestAttachments[] = $info;
return $cid;
}
|
php
|
function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = FALSE)
{
if (!$cid) {
$cid = md5(uniqid(time()));
}
$info['data'] = $data;
$info['filename'] = $filename;
$info['contenttype'] = $contenttype;
$info['cid'] = $cid;
$this->requestAttachments[] = $info;
return $cid;
}
|
[
"function",
"addAttachment",
"(",
"$",
"data",
",",
"$",
"filename",
"=",
"''",
",",
"$",
"contenttype",
"=",
"'application/octet-stream'",
",",
"$",
"cid",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"cid",
")",
"{",
"$",
"cid",
"=",
"md5",
"(",
"uniqid",
"(",
"time",
"(",
")",
")",
")",
";",
"}",
"$",
"info",
"[",
"'data'",
"]",
"=",
"$",
"data",
";",
"$",
"info",
"[",
"'filename'",
"]",
"=",
"$",
"filename",
";",
"$",
"info",
"[",
"'contenttype'",
"]",
"=",
"$",
"contenttype",
";",
"$",
"info",
"[",
"'cid'",
"]",
"=",
"$",
"cid",
";",
"$",
"this",
"->",
"requestAttachments",
"[",
"]",
"=",
"$",
"info",
";",
"return",
"$",
"cid",
";",
"}"
] |
adds a MIME attachment to the current request.
If the $data parameter contains an empty string, this method will read
the contents of the file named by the $filename parameter.
If the $cid parameter is false, this method will generate the cid.
@param string $data The data of the attachment
@param string $filename The filename of the attachment (default is empty string)
@param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
@param string $cid The content-id (cid) of the attachment (default is false)
@return string The content-id (cid) of the attachment
@access public
|
[
"adds",
"a",
"MIME",
"attachment",
"to",
"the",
"current",
"request",
"."
] |
a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556
|
https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src/nusoap_client_mime.php#L93-L107
|
19,778 |
kevintweber/phpunit-markup-validators
|
src/Kevintweber/PhpunitMarkupValidators/Connector/Connector.php
|
Connector.execute
|
public function execute($type)
{
switch (strtolower($type)) {
case 'markup':
$curlOptArray = $this->getMarkupOpts();
break;
case 'file':
$curlOptArray = $this->getFileOpts();
break;
case 'url':
$curlOptArray = $this->getUrlOpts();
break;
default:
throw new \PHPUnit_Framework_Exception('Invalid type: '.$type);
break;
}
$curlOptArray = $curlOptArray + array(CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10, );
// Throttle calls (if necessary).
Throttle::delay(get_class($this));
$curl = curl_init();
curl_setopt_array($curl, $curlOptArray);
if (!$response = curl_exec($curl)) {
throw new \PHPUnit_Framework_Exception('Unable to validate. Error: '.
curl_error($curl));
}
curl_close($curl);
return $response;
}
|
php
|
public function execute($type)
{
switch (strtolower($type)) {
case 'markup':
$curlOptArray = $this->getMarkupOpts();
break;
case 'file':
$curlOptArray = $this->getFileOpts();
break;
case 'url':
$curlOptArray = $this->getUrlOpts();
break;
default:
throw new \PHPUnit_Framework_Exception('Invalid type: '.$type);
break;
}
$curlOptArray = $curlOptArray + array(CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10, );
// Throttle calls (if necessary).
Throttle::delay(get_class($this));
$curl = curl_init();
curl_setopt_array($curl, $curlOptArray);
if (!$response = curl_exec($curl)) {
throw new \PHPUnit_Framework_Exception('Unable to validate. Error: '.
curl_error($curl));
}
curl_close($curl);
return $response;
}
|
[
"public",
"function",
"execute",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"'markup'",
":",
"$",
"curlOptArray",
"=",
"$",
"this",
"->",
"getMarkupOpts",
"(",
")",
";",
"break",
";",
"case",
"'file'",
":",
"$",
"curlOptArray",
"=",
"$",
"this",
"->",
"getFileOpts",
"(",
")",
";",
"break",
";",
"case",
"'url'",
":",
"$",
"curlOptArray",
"=",
"$",
"this",
"->",
"getUrlOpts",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"PHPUnit_Framework_Exception",
"(",
"'Invalid type: '",
".",
"$",
"type",
")",
";",
"break",
";",
"}",
"$",
"curlOptArray",
"=",
"$",
"curlOptArray",
"+",
"array",
"(",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"CURLOPT_TIMEOUT",
"=>",
"10",
",",
")",
";",
"// Throttle calls (if necessary).",
"Throttle",
"::",
"delay",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt_array",
"(",
"$",
"curl",
",",
"$",
"curlOptArray",
")",
";",
"if",
"(",
"!",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"curl",
")",
")",
"{",
"throw",
"new",
"\\",
"PHPUnit_Framework_Exception",
"(",
"'Unable to validate. Error: '",
".",
"curl_error",
"(",
"$",
"curl",
")",
")",
";",
"}",
"curl_close",
"(",
"$",
"curl",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Will execute a cURL request.
@param string $type The type of input.
@return mixed The response from the web service.
|
[
"Will",
"execute",
"a",
"cURL",
"request",
"."
] |
bee48f48c7c1c9e811d1a4bedeca8f413d049cb3
|
https://github.com/kevintweber/phpunit-markup-validators/blob/bee48f48c7c1c9e811d1a4bedeca8f413d049cb3/src/Kevintweber/PhpunitMarkupValidators/Connector/Connector.php#L29-L66
|
19,779 |
terion-name/package-installer
|
src/Terion/PackageInstaller/PackageInstallerServiceProvider.php
|
PackageInstallerServiceProvider.bindInstallCommand
|
protected function bindInstallCommand()
{
$this->app['package.install'] = $this->app->share(function ($app) {
return $app->make('Terion\PackageInstaller\PackageInstallCommand');
});
$this->app['package.process'] = $this->app->share(function ($app) {
return $app->make('Terion\PackageInstaller\PackageProcessCommand');
});
}
|
php
|
protected function bindInstallCommand()
{
$this->app['package.install'] = $this->app->share(function ($app) {
return $app->make('Terion\PackageInstaller\PackageInstallCommand');
});
$this->app['package.process'] = $this->app->share(function ($app) {
return $app->make('Terion\PackageInstaller\PackageProcessCommand');
});
}
|
[
"protected",
"function",
"bindInstallCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'package.install'",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'Terion\\PackageInstaller\\PackageInstallCommand'",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"[",
"'package.process'",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'Terion\\PackageInstaller\\PackageProcessCommand'",
")",
";",
"}",
")",
";",
"}"
] |
Bind command to IoC
|
[
"Bind",
"command",
"to",
"IoC"
] |
a1f53085b0b5dbbcc308476f61188103051bd201
|
https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/PackageInstallerServiceProvider.php#L67-L75
|
19,780 |
spiral-modules/scaffolder
|
source/Scaffolder/Declarations/RequestDeclaration.php
|
RequestDeclaration.declareField
|
public function declareField(string $field, string $type, string $source, string $origin = null)
{
$schema = $this->constant('SCHEMA')->getValue();
$setters = $this->constant('SETTERS')->getValue();
$validates = $this->constant('VALIDATES')->getValue();
if (!isset($this->mapping[$type])) {
$schema[$field] = $source . ':' . ($origin ? $origin : $field);
$this->constant('SCHEMA')->setValue($schema);
return;
}
$definition = $this->mapping[$type];
//Source can depend on type
$source = $definition['source'];
$schema[$field] = $source . ':' . ($origin ? $origin : $field);
if (!empty($definition['setter'])) {
//Pre-defined setter
$setters[$field] = $definition['setter'];
}
if (!empty($definition['validates'])) {
//Pre-defined validation
$validates[$field] = $definition['validates'];
}
$this->constant('SCHEMA')->setValue($schema);
$this->constant('SETTERS')->setValue($setters);
$this->constant('VALIDATES')->setValue($validates);
}
|
php
|
public function declareField(string $field, string $type, string $source, string $origin = null)
{
$schema = $this->constant('SCHEMA')->getValue();
$setters = $this->constant('SETTERS')->getValue();
$validates = $this->constant('VALIDATES')->getValue();
if (!isset($this->mapping[$type])) {
$schema[$field] = $source . ':' . ($origin ? $origin : $field);
$this->constant('SCHEMA')->setValue($schema);
return;
}
$definition = $this->mapping[$type];
//Source can depend on type
$source = $definition['source'];
$schema[$field] = $source . ':' . ($origin ? $origin : $field);
if (!empty($definition['setter'])) {
//Pre-defined setter
$setters[$field] = $definition['setter'];
}
if (!empty($definition['validates'])) {
//Pre-defined validation
$validates[$field] = $definition['validates'];
}
$this->constant('SCHEMA')->setValue($schema);
$this->constant('SETTERS')->setValue($setters);
$this->constant('VALIDATES')->setValue($validates);
}
|
[
"public",
"function",
"declareField",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"type",
",",
"string",
"$",
"source",
",",
"string",
"$",
"origin",
"=",
"null",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"constant",
"(",
"'SCHEMA'",
")",
"->",
"getValue",
"(",
")",
";",
"$",
"setters",
"=",
"$",
"this",
"->",
"constant",
"(",
"'SETTERS'",
")",
"->",
"getValue",
"(",
")",
";",
"$",
"validates",
"=",
"$",
"this",
"->",
"constant",
"(",
"'VALIDATES'",
")",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mapping",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"schema",
"[",
"$",
"field",
"]",
"=",
"$",
"source",
".",
"':'",
".",
"(",
"$",
"origin",
"?",
"$",
"origin",
":",
"$",
"field",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'SCHEMA'",
")",
"->",
"setValue",
"(",
"$",
"schema",
")",
";",
"return",
";",
"}",
"$",
"definition",
"=",
"$",
"this",
"->",
"mapping",
"[",
"$",
"type",
"]",
";",
"//Source can depend on type",
"$",
"source",
"=",
"$",
"definition",
"[",
"'source'",
"]",
";",
"$",
"schema",
"[",
"$",
"field",
"]",
"=",
"$",
"source",
".",
"':'",
".",
"(",
"$",
"origin",
"?",
"$",
"origin",
":",
"$",
"field",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"definition",
"[",
"'setter'",
"]",
")",
")",
"{",
"//Pre-defined setter",
"$",
"setters",
"[",
"$",
"field",
"]",
"=",
"$",
"definition",
"[",
"'setter'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"definition",
"[",
"'validates'",
"]",
")",
")",
"{",
"//Pre-defined validation",
"$",
"validates",
"[",
"$",
"field",
"]",
"=",
"$",
"definition",
"[",
"'validates'",
"]",
";",
"}",
"$",
"this",
"->",
"constant",
"(",
"'SCHEMA'",
")",
"->",
"setValue",
"(",
"$",
"schema",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'SETTERS'",
")",
"->",
"setValue",
"(",
"$",
"setters",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'VALIDATES'",
")",
"->",
"setValue",
"(",
"$",
"validates",
")",
";",
"}"
] |
Add new field to request and generate default filters and validations if type presented in
mapping.
@param string $field
@param string $type
@param string $source
@param string $origin
|
[
"Add",
"new",
"field",
"to",
"request",
"and",
"generate",
"default",
"filters",
"and",
"validations",
"if",
"type",
"presented",
"in",
"mapping",
"."
] |
9be9dd0da6e4b02232db24e797fe5c288afbbddf
|
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Declarations/RequestDeclaration.php#L50-L83
|
19,781 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication.route
|
public function route()
{
// Get the full request URI.
$uri = clone JUri::getInstance();
$router = $this->getRouter();
$result = $router->parse($uri);
foreach ($result as $key => $value)
{
$this->input->def($key, $value);
}
// Trigger the onAfterRoute event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterRoute');
}
|
php
|
public function route()
{
// Get the full request URI.
$uri = clone JUri::getInstance();
$router = $this->getRouter();
$result = $router->parse($uri);
foreach ($result as $key => $value)
{
$this->input->def($key, $value);
}
// Trigger the onAfterRoute event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterRoute');
}
|
[
"public",
"function",
"route",
"(",
")",
"{",
"// Get the full request URI.",
"$",
"uri",
"=",
"clone",
"JUri",
"::",
"getInstance",
"(",
")",
";",
"$",
"router",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
";",
"$",
"result",
"=",
"$",
"router",
"->",
"parse",
"(",
"$",
"uri",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"input",
"->",
"def",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"// Trigger the onAfterRoute event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onAfterRoute'",
")",
";",
"}"
] |
Route the application.
Routing is the process of examining the request environment to determine which
component should receive the request. The component optional parameters
are then set in the request object to be processed when the application is being
dispatched.
@return void
@since 11.1
@deprecated 4.0
|
[
"Route",
"the",
"application",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L239-L255
|
19,782 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication.dispatch
|
public function dispatch($component = null)
{
$document = JFactory::getDocument();
$contents = JComponentHelper::renderComponent($component);
$document->setBuffer($contents, 'component');
// Trigger the onAfterDispatch event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterDispatch');
}
|
php
|
public function dispatch($component = null)
{
$document = JFactory::getDocument();
$contents = JComponentHelper::renderComponent($component);
$document->setBuffer($contents, 'component');
// Trigger the onAfterDispatch event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterDispatch');
}
|
[
"public",
"function",
"dispatch",
"(",
"$",
"component",
"=",
"null",
")",
"{",
"$",
"document",
"=",
"JFactory",
"::",
"getDocument",
"(",
")",
";",
"$",
"contents",
"=",
"JComponentHelper",
"::",
"renderComponent",
"(",
"$",
"component",
")",
";",
"$",
"document",
"->",
"setBuffer",
"(",
"$",
"contents",
",",
"'component'",
")",
";",
"// Trigger the onAfterDispatch event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onAfterDispatch'",
")",
";",
"}"
] |
Dispatch the application.
Dispatching is the process of pulling the option from the request object and
mapping them to a component. If the component does not exist, it handles
determining a default component to dispatch.
@param string $component The component to dispatch.
@return void
@since 11.1
@deprecated 4.0
|
[
"Dispatch",
"the",
"application",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L271-L281
|
19,783 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication.render
|
public function render()
{
$template = $this->getTemplate(true);
$params = array('template' => $template->template, 'file' => 'index.php', 'directory' => JPATH_THEMES, 'params' => $template->params);
// Parse the document.
$document = JFactory::getDocument();
$document->parse($params);
// Trigger the onBeforeRender event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onBeforeRender');
// Render the document.
$caching = ($this->getCfg('caching') >= 2) ? true : false;
JResponse::setBody($document->render($caching, $params));
// Trigger the onAfterRender event.
$this->triggerEvent('onAfterRender');
}
|
php
|
public function render()
{
$template = $this->getTemplate(true);
$params = array('template' => $template->template, 'file' => 'index.php', 'directory' => JPATH_THEMES, 'params' => $template->params);
// Parse the document.
$document = JFactory::getDocument();
$document->parse($params);
// Trigger the onBeforeRender event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onBeforeRender');
// Render the document.
$caching = ($this->getCfg('caching') >= 2) ? true : false;
JResponse::setBody($document->render($caching, $params));
// Trigger the onAfterRender event.
$this->triggerEvent('onAfterRender');
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"true",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'template'",
"=>",
"$",
"template",
"->",
"template",
",",
"'file'",
"=>",
"'index.php'",
",",
"'directory'",
"=>",
"JPATH_THEMES",
",",
"'params'",
"=>",
"$",
"template",
"->",
"params",
")",
";",
"// Parse the document.",
"$",
"document",
"=",
"JFactory",
"::",
"getDocument",
"(",
")",
";",
"$",
"document",
"->",
"parse",
"(",
"$",
"params",
")",
";",
"// Trigger the onBeforeRender event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onBeforeRender'",
")",
";",
"// Render the document.",
"$",
"caching",
"=",
"(",
"$",
"this",
"->",
"getCfg",
"(",
"'caching'",
")",
">=",
"2",
")",
"?",
"true",
":",
"false",
";",
"JResponse",
"::",
"setBody",
"(",
"$",
"document",
"->",
"render",
"(",
"$",
"caching",
",",
"$",
"params",
")",
")",
";",
"// Trigger the onAfterRender event.",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onAfterRender'",
")",
";",
"}"
] |
Render the application.
Rendering is the process of pushing the document buffers into the template
placeholders, retrieving data from the document and pushing it into
the JResponse buffer.
@return void
@since 11.1
@deprecated 4.0
|
[
"Render",
"the",
"application",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L295-L315
|
19,784 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication.getName
|
public function getName()
{
$name = $this->_name;
if (empty($name))
{
$r = null;
if (!preg_match('/J(.*)/i', get_class($this), $r))
{
JLog::add(JText::_('JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME'), JLog::WARNING, 'jerror');
}
$name = strtolower($r[1]);
}
return $name;
}
|
php
|
public function getName()
{
$name = $this->_name;
if (empty($name))
{
$r = null;
if (!preg_match('/J(.*)/i', get_class($this), $r))
{
JLog::add(JText::_('JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME'), JLog::WARNING, 'jerror');
}
$name = strtolower($r[1]);
}
return $name;
}
|
[
"public",
"function",
"getName",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_name",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"r",
"=",
"null",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/J(.*)/i'",
",",
"get_class",
"(",
"$",
"this",
")",
",",
"$",
"r",
")",
")",
"{",
"JLog",
"::",
"add",
"(",
"JText",
"::",
"_",
"(",
"'JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME'",
")",
",",
"JLog",
"::",
"WARNING",
",",
"'jerror'",
")",
";",
"}",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"r",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"name",
";",
"}"
] |
Method to get the application name.
The dispatcher name is by default parsed using the classname, or it can be set
by passing a $config['name'] in the class constructor.
@return string The name of the dispatcher.
@since 11.1
@deprecated 4.0
|
[
"Method",
"to",
"get",
"the",
"application",
"name",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L503-L520
|
19,785 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication.getTemplate
|
public function getTemplate($params = false)
{
$template = new stdClass;
$template->template = 'system';
$template->params = new Registry;
if ($params)
{
return $template;
}
return $template->template;
}
|
php
|
public function getTemplate($params = false)
{
$template = new stdClass;
$template->template = 'system';
$template->params = new Registry;
if ($params)
{
return $template;
}
return $template->template;
}
|
[
"public",
"function",
"getTemplate",
"(",
"$",
"params",
"=",
"false",
")",
"{",
"$",
"template",
"=",
"new",
"stdClass",
";",
"$",
"template",
"->",
"template",
"=",
"'system'",
";",
"$",
"template",
"->",
"params",
"=",
"new",
"Registry",
";",
"if",
"(",
"$",
"params",
")",
"{",
"return",
"$",
"template",
";",
"}",
"return",
"$",
"template",
"->",
"template",
";",
"}"
] |
Gets the name of the current template.
@param boolean $params An optional associative array of configuration settings
@return mixed System is the fallback.
@since 11.1
@deprecated 4.0
|
[
"Gets",
"the",
"name",
"of",
"the",
"current",
"template",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L790-L803
|
19,786 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication._createConfiguration
|
protected function _createConfiguration($file)
{
JLoader::register('JConfig', $file);
// Create the JConfig object.
$config = new JConfig;
// Get the global configuration object.
$registry = JFactory::getConfig();
// Load the configuration values into the registry.
$registry->loadObject($config);
return $config;
}
|
php
|
protected function _createConfiguration($file)
{
JLoader::register('JConfig', $file);
// Create the JConfig object.
$config = new JConfig;
// Get the global configuration object.
$registry = JFactory::getConfig();
// Load the configuration values into the registry.
$registry->loadObject($config);
return $config;
}
|
[
"protected",
"function",
"_createConfiguration",
"(",
"$",
"file",
")",
"{",
"JLoader",
"::",
"register",
"(",
"'JConfig'",
",",
"$",
"file",
")",
";",
"// Create the JConfig object.",
"$",
"config",
"=",
"new",
"JConfig",
";",
"// Get the global configuration object.",
"$",
"registry",
"=",
"JFactory",
"::",
"getConfig",
"(",
")",
";",
"// Load the configuration values into the registry.",
"$",
"registry",
"->",
"loadObject",
"(",
"$",
"config",
")",
";",
"return",
"$",
"config",
";",
"}"
] |
Create the configuration registry.
@param string $file The path to the configuration file
@return JConfig A JConfig object
@since 11.1
@deprecated 4.0
|
[
"Create",
"the",
"configuration",
"registry",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L938-L952
|
19,787 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication.checkSession
|
public function checkSession()
{
$db = JFactory::getDbo();
$session = JFactory::getSession();
$user = JFactory::getUser();
$query = $db->getQuery(true)
->select($db->quoteName('session_id'))
->from($db->quoteName('#__users_sessions'))
->where($db->quoteName('session_id') . ' = ' . $db->quote($session->getId()));
$db->setQuery($query, 0, 1);
$exists = $db->loadResult();
// If the session record doesn't exist initialise it.
if (!$exists)
{
$query->clear();
if ($session->isNew())
{
$query->insert($db->quoteName('#__users_sessions'))
->columns($db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('time'))
->values($db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . $db->quote((int) time()));
$db->setQuery($query);
}
else
{
$query->insert($db->quoteName('#__users_sessions'))
->columns(
$db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('guest') . ', ' .
$db->quoteName('time') . ', ' . $db->quoteName('userid') . ', ' . $db->quoteName('username')
)
->values(
$db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . (int) $user->get('guest') . ', ' .
$db->quote((int) $session->get('session.timer.start')) . ', ' . (int) $user->get('id') . ', ' . $db->quote($user->get('username'))
);
$db->setQuery($query);
}
// If the insert failed, exit the application.
try
{
$db->execute();
}
catch (RuntimeException $e)
{
jexit($e->getMessage());
}
}
}
|
php
|
public function checkSession()
{
$db = JFactory::getDbo();
$session = JFactory::getSession();
$user = JFactory::getUser();
$query = $db->getQuery(true)
->select($db->quoteName('session_id'))
->from($db->quoteName('#__users_sessions'))
->where($db->quoteName('session_id') . ' = ' . $db->quote($session->getId()));
$db->setQuery($query, 0, 1);
$exists = $db->loadResult();
// If the session record doesn't exist initialise it.
if (!$exists)
{
$query->clear();
if ($session->isNew())
{
$query->insert($db->quoteName('#__users_sessions'))
->columns($db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('time'))
->values($db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . $db->quote((int) time()));
$db->setQuery($query);
}
else
{
$query->insert($db->quoteName('#__users_sessions'))
->columns(
$db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('guest') . ', ' .
$db->quoteName('time') . ', ' . $db->quoteName('userid') . ', ' . $db->quoteName('username')
)
->values(
$db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . (int) $user->get('guest') . ', ' .
$db->quote((int) $session->get('session.timer.start')) . ', ' . (int) $user->get('id') . ', ' . $db->quote($user->get('username'))
);
$db->setQuery($query);
}
// If the insert failed, exit the application.
try
{
$db->execute();
}
catch (RuntimeException $e)
{
jexit($e->getMessage());
}
}
}
|
[
"public",
"function",
"checkSession",
"(",
")",
"{",
"$",
"db",
"=",
"JFactory",
"::",
"getDbo",
"(",
")",
";",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
")",
";",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
")",
"->",
"from",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'#__users_sessions'",
")",
")",
"->",
"where",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
".",
"' = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
",",
"0",
",",
"1",
")",
";",
"$",
"exists",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"// If the session record doesn't exist initialise it.",
"if",
"(",
"!",
"$",
"exists",
")",
"{",
"$",
"query",
"->",
"clear",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"query",
"->",
"insert",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'#__users_sessions'",
")",
")",
"->",
"columns",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'client_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'time'",
")",
")",
"->",
"values",
"(",
"$",
"db",
"->",
"quote",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"this",
"->",
"getClientId",
"(",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quote",
"(",
"(",
"int",
")",
"time",
"(",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"insert",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'#__users_sessions'",
")",
")",
"->",
"columns",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'client_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'guest'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'time'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'userid'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'username'",
")",
")",
"->",
"values",
"(",
"$",
"db",
"->",
"quote",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"this",
"->",
"getClientId",
"(",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"user",
"->",
"get",
"(",
"'guest'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quote",
"(",
"(",
"int",
")",
"$",
"session",
"->",
"get",
"(",
"'session.timer.start'",
")",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"user",
"->",
"get",
"(",
"'id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"user",
"->",
"get",
"(",
"'username'",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"}",
"// If the insert failed, exit the application.",
"try",
"{",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"jexit",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Checks the user session.
If the session record doesn't exist, initialise it.
If session is new, create session variables
@return void
@since 11.1
@deprecated 4.0
|
[
"Checks",
"the",
"user",
"session",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L1053-L1104
|
19,788 |
joomlatools/joomlatools-platform-legacy
|
code/application/application.php
|
JApplication.afterSessionStart
|
public function afterSessionStart()
{
$session = JFactory::getSession();
if ($session->isNew())
{
$session->set('registry', new Registry('session'));
$session->set('user', new JUser);
}
}
|
php
|
public function afterSessionStart()
{
$session = JFactory::getSession();
if ($session->isNew())
{
$session->set('registry', new Registry('session'));
$session->set('user', new JUser);
}
}
|
[
"public",
"function",
"afterSessionStart",
"(",
")",
"{",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"session",
"->",
"set",
"(",
"'registry'",
",",
"new",
"Registry",
"(",
"'session'",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'user'",
",",
"new",
"JUser",
")",
";",
"}",
"}"
] |
After the session has been started we need to populate it with some default values.
@return void
@since 12.2
@deprecated 4.0
|
[
"After",
"the",
"session",
"has",
"been",
"started",
"we",
"need",
"to",
"populate",
"it",
"with",
"some",
"default",
"values",
"."
] |
3a76944e2f2c415faa6504754c75321a3b478c06
|
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L1114-L1123
|
19,789 |
qcubed/orm
|
src/Codegen/SqlTable.php
|
SqlTable.getColumnByName
|
public function getColumnByName($strColumnName) {
if ($this->objColumnArray) {
foreach ($this->objColumnArray as $objColumn){
if ($objColumn->Name == $strColumnName)
return $objColumn;
}
}
return null;
}
|
php
|
public function getColumnByName($strColumnName) {
if ($this->objColumnArray) {
foreach ($this->objColumnArray as $objColumn){
if ($objColumn->Name == $strColumnName)
return $objColumn;
}
}
return null;
}
|
[
"public",
"function",
"getColumnByName",
"(",
"$",
"strColumnName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"objColumnArray",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"objColumnArray",
"as",
"$",
"objColumn",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Name",
"==",
"$",
"strColumnName",
")",
"return",
"$",
"objColumn",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
return the SqlColumn object related to that column name
@param string $strColumnName Name of the column
@return SqlColumn
|
[
"return",
"the",
"SqlColumn",
"object",
"related",
"to",
"that",
"column",
"name"
] |
f320eba671f20874b1f3809c5293f8c02d5b1204
|
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/SqlTable.php#L115-L123
|
19,790 |
4devs/ElfinderPhpConnector
|
Response.php
|
Response.toArray
|
public function toArray()
{
$data = array(
'added' => $this->getAdded(true),
'api' => $this->getApi(),
'cwd' => $this->getCwd(true),
'debug' => $this->getDebug(),
'files' => $this->getFiles(true),
'list' => $this->getList(),
'netDrivers' => $this->getNetDrivers(),
'options' => $this->getOptions(),
'removed' => $this->getRemoved(true),
'tree' => $this->getTree(true),
'uplMaxSize' => $this->getUplMaxSize(),
'content' => $this->getContent(),
'size' => $this->getSize(),
'error' => $this->getError(),
'dim' => $this->getDim(),
);
return array_filter(
$data,
function ($var) {
return !is_null($var);
}
);
}
|
php
|
public function toArray()
{
$data = array(
'added' => $this->getAdded(true),
'api' => $this->getApi(),
'cwd' => $this->getCwd(true),
'debug' => $this->getDebug(),
'files' => $this->getFiles(true),
'list' => $this->getList(),
'netDrivers' => $this->getNetDrivers(),
'options' => $this->getOptions(),
'removed' => $this->getRemoved(true),
'tree' => $this->getTree(true),
'uplMaxSize' => $this->getUplMaxSize(),
'content' => $this->getContent(),
'size' => $this->getSize(),
'error' => $this->getError(),
'dim' => $this->getDim(),
);
return array_filter(
$data,
function ($var) {
return !is_null($var);
}
);
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'added'",
"=>",
"$",
"this",
"->",
"getAdded",
"(",
"true",
")",
",",
"'api'",
"=>",
"$",
"this",
"->",
"getApi",
"(",
")",
",",
"'cwd'",
"=>",
"$",
"this",
"->",
"getCwd",
"(",
"true",
")",
",",
"'debug'",
"=>",
"$",
"this",
"->",
"getDebug",
"(",
")",
",",
"'files'",
"=>",
"$",
"this",
"->",
"getFiles",
"(",
"true",
")",
",",
"'list'",
"=>",
"$",
"this",
"->",
"getList",
"(",
")",
",",
"'netDrivers'",
"=>",
"$",
"this",
"->",
"getNetDrivers",
"(",
")",
",",
"'options'",
"=>",
"$",
"this",
"->",
"getOptions",
"(",
")",
",",
"'removed'",
"=>",
"$",
"this",
"->",
"getRemoved",
"(",
"true",
")",
",",
"'tree'",
"=>",
"$",
"this",
"->",
"getTree",
"(",
"true",
")",
",",
"'uplMaxSize'",
"=>",
"$",
"this",
"->",
"getUplMaxSize",
"(",
")",
",",
"'content'",
"=>",
"$",
"this",
"->",
"getContent",
"(",
")",
",",
"'size'",
"=>",
"$",
"this",
"->",
"getSize",
"(",
")",
",",
"'error'",
"=>",
"$",
"this",
"->",
"getError",
"(",
")",
",",
"'dim'",
"=>",
"$",
"this",
"->",
"getDim",
"(",
")",
",",
")",
";",
"return",
"array_filter",
"(",
"$",
"data",
",",
"function",
"(",
"$",
"var",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"var",
")",
";",
"}",
")",
";",
"}"
] |
get response as array.
@return array
|
[
"get",
"response",
"as",
"array",
"."
] |
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
|
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L80-L106
|
19,791 |
4devs/ElfinderPhpConnector
|
Response.php
|
Response.getAdded
|
public function getAdded($asArray = true)
{
$return = array();
if ($asArray && $this->added) {
foreach ($this->added as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->added;
}
|
php
|
public function getAdded($asArray = true)
{
$return = array();
if ($asArray && $this->added) {
foreach ($this->added as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->added;
}
|
[
"public",
"function",
"getAdded",
"(",
"$",
"asArray",
"=",
"true",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"asArray",
"&&",
"$",
"this",
"->",
"added",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"added",
"as",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"file",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"return",
"$",
"asArray",
"?",
"$",
"return",
":",
"$",
"this",
"->",
"added",
";",
"}"
] |
get Added.
@param bool $asArray
@return array|FileInfo[]
|
[
"get",
"Added",
"."
] |
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
|
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L223-L233
|
19,792 |
4devs/ElfinderPhpConnector
|
Response.php
|
Response.getCwd
|
public function getCwd($asArray = false)
{
return $this->cwd && $asArray ? $this->cwd->toArray() : $this->cwd;
}
|
php
|
public function getCwd($asArray = false)
{
return $this->cwd && $asArray ? $this->cwd->toArray() : $this->cwd;
}
|
[
"public",
"function",
"getCwd",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"cwd",
"&&",
"$",
"asArray",
"?",
"$",
"this",
"->",
"cwd",
"->",
"toArray",
"(",
")",
":",
"$",
"this",
"->",
"cwd",
";",
"}"
] |
get Current Working Directory.
@param bool $asArray
@return array|FileInfo
|
[
"get",
"Current",
"Working",
"Directory",
"."
] |
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
|
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L272-L275
|
19,793 |
4devs/ElfinderPhpConnector
|
Response.php
|
Response.getFiles
|
public function getFiles($asArray = false)
{
$return = array();
if ($asArray && $this->files) {
foreach ($this->files as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->files;
}
|
php
|
public function getFiles($asArray = false)
{
$return = array();
if ($asArray && $this->files) {
foreach ($this->files as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->files;
}
|
[
"public",
"function",
"getFiles",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"asArray",
"&&",
"$",
"this",
"->",
"files",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"file",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"return",
"$",
"asArray",
"?",
"$",
"return",
":",
"$",
"this",
"->",
"files",
";",
"}"
] |
get Files.
@param bool $asArray
@return array|FileInfo[]
|
[
"get",
"Files",
"."
] |
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
|
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L355-L365
|
19,794 |
4devs/ElfinderPhpConnector
|
Response.php
|
Response.getTree
|
public function getTree($asArray = false)
{
$return = array();
if ($asArray && $this->tree) {
foreach ($this->tree as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->tree;
}
|
php
|
public function getTree($asArray = false)
{
$return = array();
if ($asArray && $this->tree) {
foreach ($this->tree as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->tree;
}
|
[
"public",
"function",
"getTree",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"asArray",
"&&",
"$",
"this",
"->",
"tree",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"tree",
"as",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"file",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"return",
"$",
"asArray",
"?",
"$",
"return",
":",
"$",
"this",
"->",
"tree",
";",
"}"
] |
get Tree.
@param bool $asArray
@return array|FileInfo[]
|
[
"get",
"Tree",
"."
] |
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
|
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L503-L513
|
19,795 |
webforge-labs/psc-cms
|
lib/Psc/JS/JS.php
|
JS.register
|
public static function register($jsFile, $alias = NULL, Array $dependencies = array()) {
return self::getManager()->register($jsFile, $alias, $dependencies);
}
|
php
|
public static function register($jsFile, $alias = NULL, Array $dependencies = array()) {
return self::getManager()->register($jsFile, $alias, $dependencies);
}
|
[
"public",
"static",
"function",
"register",
"(",
"$",
"jsFile",
",",
"$",
"alias",
"=",
"NULL",
",",
"Array",
"$",
"dependencies",
"=",
"array",
"(",
")",
")",
"{",
"return",
"self",
"::",
"getManager",
"(",
")",
"->",
"register",
"(",
"$",
"jsFile",
",",
"$",
"alias",
",",
"$",
"dependencies",
")",
";",
"}"
] |
Macht dem Standard JS Manager eine JS Datei bekannt
|
[
"Macht",
"dem",
"Standard",
"JS",
"Manager",
"eine",
"JS",
"Datei",
"bekannt"
] |
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
|
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/JS.php#L20-L22
|
19,796 |
maniaplanet/maniaplanet-ws-sdk
|
libraries/Maniaplanet/WebServices/ManiaConnect/Player.php
|
Player.getPlayer
|
function getPlayer()
{
$player = self::$persistance->getVariable('player');
if(!$player)
{
if($this->getAccessToken())
{
$player = $this->executeOAuth2('GET', '/player/');
self::$persistance->setVariable('player', $player);
}
}
return $player;
}
|
php
|
function getPlayer()
{
$player = self::$persistance->getVariable('player');
if(!$player)
{
if($this->getAccessToken())
{
$player = $this->executeOAuth2('GET', '/player/');
self::$persistance->setVariable('player', $player);
}
}
return $player;
}
|
[
"function",
"getPlayer",
"(",
")",
"{",
"$",
"player",
"=",
"self",
"::",
"$",
"persistance",
"->",
"getVariable",
"(",
"'player'",
")",
";",
"if",
"(",
"!",
"$",
"player",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
")",
"{",
"$",
"player",
"=",
"$",
"this",
"->",
"executeOAuth2",
"(",
"'GET'",
",",
"'/player/'",
")",
";",
"self",
"::",
"$",
"persistance",
"->",
"setVariable",
"(",
"'player'",
",",
"$",
"player",
")",
";",
"}",
"}",
"return",
"$",
"player",
";",
"}"
] |
This is the first method to call when you have an authorization code.
It will retrieve an access token if possible and then call the service to
retrieve a basic object about the authentified player.
You do not need any special scope to call this service, as long as you
have an access token.
If an access token is not found, it will return false
@return object A player object or false if no access token is found
|
[
"This",
"is",
"the",
"first",
"method",
"to",
"call",
"when",
"you",
"have",
"an",
"authorization",
"code",
".",
"It",
"will",
"retrieve",
"an",
"access",
"token",
"if",
"possible",
"and",
"then",
"call",
"the",
"service",
"to",
"retrieve",
"a",
"basic",
"object",
"about",
"the",
"authentified",
"player",
"."
] |
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
|
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaConnect/Player.php#L33-L45
|
19,797 |
2amigos/yiifoundation
|
widgets/Alert.php
|
Alert.renderAlert
|
public function renderAlert()
{
$user = \Yii::app()->user;
if (count($user->getFlashes(false)) == 0) {
return;
}
$alerts = array();
foreach ($this->config as $style => $config) {
if ($user->hasFlash($style)) {
$options = ArrayHelper::getValue($config, 'htmlOptions', array());
Html::addCssClass($options, $style);
$close = ArrayHelper::getValue($config, 'close', '×');
$alerts[] = \foundation\helpers\Alert::alert($user->getFlash($style), $options, $close);
}
}
$this->registerEvents("#{$this->htmlOptions['id']} > .alert-box", $this->events);
return \CHtml::tag('div', $this->htmlOptions, implode("\n", $alerts));
}
|
php
|
public function renderAlert()
{
$user = \Yii::app()->user;
if (count($user->getFlashes(false)) == 0) {
return;
}
$alerts = array();
foreach ($this->config as $style => $config) {
if ($user->hasFlash($style)) {
$options = ArrayHelper::getValue($config, 'htmlOptions', array());
Html::addCssClass($options, $style);
$close = ArrayHelper::getValue($config, 'close', '×');
$alerts[] = \foundation\helpers\Alert::alert($user->getFlash($style), $options, $close);
}
}
$this->registerEvents("#{$this->htmlOptions['id']} > .alert-box", $this->events);
return \CHtml::tag('div', $this->htmlOptions, implode("\n", $alerts));
}
|
[
"public",
"function",
"renderAlert",
"(",
")",
"{",
"$",
"user",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"user",
";",
"if",
"(",
"count",
"(",
"$",
"user",
"->",
"getFlashes",
"(",
"false",
")",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"alerts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"as",
"$",
"style",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"hasFlash",
"(",
"$",
"style",
")",
")",
"{",
"$",
"options",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"config",
",",
"'htmlOptions'",
",",
"array",
"(",
")",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"options",
",",
"$",
"style",
")",
";",
"$",
"close",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"config",
",",
"'close'",
",",
"'×'",
")",
";",
"$",
"alerts",
"[",
"]",
"=",
"\\",
"foundation",
"\\",
"helpers",
"\\",
"Alert",
"::",
"alert",
"(",
"$",
"user",
"->",
"getFlash",
"(",
"$",
"style",
")",
",",
"$",
"options",
",",
"$",
"close",
")",
";",
"}",
"}",
"$",
"this",
"->",
"registerEvents",
"(",
"\"#{$this->htmlOptions['id']} > .alert-box\"",
",",
"$",
"this",
"->",
"events",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'div'",
",",
"$",
"this",
"->",
"htmlOptions",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"alerts",
")",
")",
";",
"}"
] |
Renders the alert
@return string the rendering result
|
[
"Renders",
"the",
"alert"
] |
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
|
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Alert.php#L77-L95
|
19,798 |
arsengoian/viper-framework
|
src/Viper/Support/Libs/Util.php
|
Util.recursiveMkdir
|
public static function recursiveMkdir(string $dir, int $loops = 0) {
if ($loops > 20)
throw new UtilException('No more than 20 directories in a row');
if(!file_exists($newdir = dirname($dir)))
self::recursiveMkdir($newdir);
@mkdir($dir);
@chmod($dir, 0777);
}
|
php
|
public static function recursiveMkdir(string $dir, int $loops = 0) {
if ($loops > 20)
throw new UtilException('No more than 20 directories in a row');
if(!file_exists($newdir = dirname($dir)))
self::recursiveMkdir($newdir);
@mkdir($dir);
@chmod($dir, 0777);
}
|
[
"public",
"static",
"function",
"recursiveMkdir",
"(",
"string",
"$",
"dir",
",",
"int",
"$",
"loops",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"loops",
">",
"20",
")",
"throw",
"new",
"UtilException",
"(",
"'No more than 20 directories in a row'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"newdir",
"=",
"dirname",
"(",
"$",
"dir",
")",
")",
")",
"self",
"::",
"recursiveMkdir",
"(",
"$",
"newdir",
")",
";",
"@",
"mkdir",
"(",
"$",
"dir",
")",
";",
"@",
"chmod",
"(",
"$",
"dir",
",",
"0777",
")",
";",
"}"
] |
Warning! Ignoring warnings
|
[
"Warning!",
"Ignoring",
"warnings"
] |
22796c5cc219cae3ca0b4af370a347ba2acab0f2
|
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Support/Libs/Util.php#L84-L91
|
19,799 |
teneleven/GeolocatorBundle
|
Controller/GeolocatorController.php
|
GeolocatorController.locate
|
public function locate($entity, Request $request, $template = null)
{
if (!$template) {
$template = 'TenelevenGeolocatorBundle::results.html.twig';
}
$provider = $this->getLocationProvider($entity);
$form = $this->get('form.factory')->createNamed('', $provider->getFilterFormType(), null, array(
'method' => 'GET',
'csrf_protection' => false,
'allow_extra_fields' => true,
));
foreach ($request->query->all() as $key => $value) {
if ($form->has($key)) {
continue;
}
$form->add($key, HiddenType::class, [
'data' => $value,
]);
}
try {
$form->handleRequest($request);
} catch (QuotaExceeded $e) {
$this->get('logger')->error($e->getMessage());
$this->get('session')->getFlashBag()->add('error', 'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.');
}
if (!$form->isValid()) {
return $this->render($template, array(
'map' => $map = $this->getMap(),
'form' => $form->createView()
));
}
$result = $provider->findLocations($form);
$map = $this->buildMap($template, $result);
return $this->render($template, array(
'form' => $form->createView(),
'result' => $result,
'map' => $map
));
}
|
php
|
public function locate($entity, Request $request, $template = null)
{
if (!$template) {
$template = 'TenelevenGeolocatorBundle::results.html.twig';
}
$provider = $this->getLocationProvider($entity);
$form = $this->get('form.factory')->createNamed('', $provider->getFilterFormType(), null, array(
'method' => 'GET',
'csrf_protection' => false,
'allow_extra_fields' => true,
));
foreach ($request->query->all() as $key => $value) {
if ($form->has($key)) {
continue;
}
$form->add($key, HiddenType::class, [
'data' => $value,
]);
}
try {
$form->handleRequest($request);
} catch (QuotaExceeded $e) {
$this->get('logger')->error($e->getMessage());
$this->get('session')->getFlashBag()->add('error', 'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.');
}
if (!$form->isValid()) {
return $this->render($template, array(
'map' => $map = $this->getMap(),
'form' => $form->createView()
));
}
$result = $provider->findLocations($form);
$map = $this->buildMap($template, $result);
return $this->render($template, array(
'form' => $form->createView(),
'result' => $result,
'map' => $map
));
}
|
[
"public",
"function",
"locate",
"(",
"$",
"entity",
",",
"Request",
"$",
"request",
",",
"$",
"template",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"'TenelevenGeolocatorBundle::results.html.twig'",
";",
"}",
"$",
"provider",
"=",
"$",
"this",
"->",
"getLocationProvider",
"(",
"$",
"entity",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"get",
"(",
"'form.factory'",
")",
"->",
"createNamed",
"(",
"''",
",",
"$",
"provider",
"->",
"getFilterFormType",
"(",
")",
",",
"null",
",",
"array",
"(",
"'method'",
"=>",
"'GET'",
",",
"'csrf_protection'",
"=>",
"false",
",",
"'allow_extra_fields'",
"=>",
"true",
",",
")",
")",
";",
"foreach",
"(",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"continue",
";",
"}",
"$",
"form",
"->",
"add",
"(",
"$",
"key",
",",
"HiddenType",
"::",
"class",
",",
"[",
"'data'",
"=>",
"$",
"value",
",",
"]",
")",
";",
"}",
"try",
"{",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"}",
"catch",
"(",
"QuotaExceeded",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'error'",
",",
"'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"array",
"(",
"'map'",
"=>",
"$",
"map",
"=",
"$",
"this",
"->",
"getMap",
"(",
")",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"provider",
"->",
"findLocations",
"(",
"$",
"form",
")",
";",
"$",
"map",
"=",
"$",
"this",
"->",
"buildMap",
"(",
"$",
"template",
",",
"$",
"result",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'result'",
"=>",
"$",
"result",
",",
"'map'",
"=>",
"$",
"map",
")",
")",
";",
"}"
] |
Displays a geo-locator screen with map, form, and locations
@param string $entity The entity key that the provider is registered under
@param Request $request
@param string $template The template to render
@return Response
|
[
"Displays",
"a",
"geo",
"-",
"locator",
"screen",
"with",
"map",
"form",
"and",
"locations"
] |
4ead8e783a91577f2a67aa302b79641d4b9e99ad
|
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Controller/GeolocatorController.php#L44-L89
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.