repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.initialiseQuery | protected function initialiseQuery()
{
// Join on base table and let lazy loading join subtables
$baseClass = DataObject::getSchema()->baseDataClass($this->dataClass());
if (!$baseClass) {
throw new InvalidArgumentException("DataQuery::create() Can't find data classes for '{$this... | php | protected function initialiseQuery()
{
// Join on base table and let lazy loading join subtables
$baseClass = DataObject::getSchema()->baseDataClass($this->dataClass());
if (!$baseClass) {
throw new InvalidArgumentException("DataQuery::create() Can't find data classes for '{$this... | [
"protected",
"function",
"initialiseQuery",
"(",
")",
"{",
"// Join on base table and let lazy loading join subtables",
"$",
"baseClass",
"=",
"DataObject",
"::",
"getSchema",
"(",
")",
"->",
"baseDataClass",
"(",
"$",
"this",
"->",
"dataClass",
"(",
")",
")",
";",
... | Set up the simplest initial query | [
"Set",
"up",
"the",
"simplest",
"initial",
"query"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L162-L183 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.ensureSelectContainsOrderbyColumns | protected function ensureSelectContainsOrderbyColumns($query, $originalSelect = array())
{
if ($orderby = $query->getOrderBy()) {
$newOrderby = array();
$i = 0;
foreach ($orderby as $k => $dir) {
$newOrderby[$k] = $dir;
// don't touch func... | php | protected function ensureSelectContainsOrderbyColumns($query, $originalSelect = array())
{
if ($orderby = $query->getOrderBy()) {
$newOrderby = array();
$i = 0;
foreach ($orderby as $k => $dir) {
$newOrderby[$k] = $dir;
// don't touch func... | [
"protected",
"function",
"ensureSelectContainsOrderbyColumns",
"(",
"$",
"query",
",",
"$",
"originalSelect",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"orderby",
"=",
"$",
"query",
"->",
"getOrderBy",
"(",
")",
")",
"{",
"$",
"newOrderby",
"=",
... | Ensure that if a query has an order by clause, those columns are present in the select.
@param SQLSelect $query
@param array $originalSelect | [
"Ensure",
"that",
"if",
"a",
"query",
"has",
"an",
"order",
"by",
"clause",
"those",
"columns",
"are",
"present",
"in",
"the",
"select",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L353-L415 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.max | public function max($field)
{
$table = DataObject::getSchema()->tableForField($this->dataClass, $field);
if (!$table) {
return $this->aggregate("MAX(\"$field\")");
}
return $this->aggregate("MAX(\"$table\".\"$field\")");
} | php | public function max($field)
{
$table = DataObject::getSchema()->tableForField($this->dataClass, $field);
if (!$table) {
return $this->aggregate("MAX(\"$field\")");
}
return $this->aggregate("MAX(\"$table\".\"$field\")");
} | [
"public",
"function",
"max",
"(",
"$",
"field",
")",
"{",
"$",
"table",
"=",
"DataObject",
"::",
"getSchema",
"(",
")",
"->",
"tableForField",
"(",
"$",
"this",
"->",
"dataClass",
",",
"$",
"field",
")",
";",
"if",
"(",
"!",
"$",
"table",
")",
"{",... | Return the maximum value of the given field in this DataList
@param string $field Unquoted database column name. Will be ANSI quoted
automatically so must not contain double quotes.
@return string | [
"Return",
"the",
"maximum",
"value",
"of",
"the",
"given",
"field",
"in",
"this",
"DataList"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L457-L464 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.selectColumnsFromTable | protected function selectColumnsFromTable(SQLSelect &$query, $tableClass, $columns = null)
{
// Add SQL for multi-value fields
$schema = DataObject::getSchema();
$databaseFields = $schema->databaseFields($tableClass, false);
$compositeFields = $schema->compositeFields($tableClass, fa... | php | protected function selectColumnsFromTable(SQLSelect &$query, $tableClass, $columns = null)
{
// Add SQL for multi-value fields
$schema = DataObject::getSchema();
$databaseFields = $schema->databaseFields($tableClass, false);
$compositeFields = $schema->compositeFields($tableClass, fa... | [
"protected",
"function",
"selectColumnsFromTable",
"(",
"SQLSelect",
"&",
"$",
"query",
",",
"$",
"tableClass",
",",
"$",
"columns",
"=",
"null",
")",
"{",
"// Add SQL for multi-value fields",
"$",
"schema",
"=",
"DataObject",
"::",
"getSchema",
"(",
")",
";",
... | Update the SELECT clause of the query with the columns from the given table
@param SQLSelect $query
@param string $tableClass Class to select from
@param array $columns | [
"Update",
"the",
"SELECT",
"clause",
"of",
"the",
"query",
"with",
"the",
"columns",
"from",
"the",
"given",
"table"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L555-L585 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.sort | public function sort($sort = null, $direction = null, $clear = true)
{
if ($clear) {
$this->query->setOrderBy($sort, $direction);
} else {
$this->query->addOrderBy($sort, $direction);
}
return $this;
} | php | public function sort($sort = null, $direction = null, $clear = true)
{
if ($clear) {
$this->query->setOrderBy($sort, $direction);
} else {
$this->query->addOrderBy($sort, $direction);
}
return $this;
} | [
"public",
"function",
"sort",
"(",
"$",
"sort",
"=",
"null",
",",
"$",
"direction",
"=",
"null",
",",
"$",
"clear",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"clear",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"setOrderBy",
"(",
"$",
"sort",
",",
... | Set the ORDER BY clause of this query
@see SQLSelect::orderby()
@param string $sort Column to sort on (escaped SQL statement)
@param string $direction Direction ("ASC" or "DESC", escaped SQL statement)
@param bool $clear Clear existing values
@return $this | [
"Set",
"the",
"ORDER",
"BY",
"clause",
"of",
"this",
"query"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L681-L690 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.innerJoin | public function innerJoin($table, $onClause, $alias = null, $order = 20, $parameters = array())
{
if ($table) {
$this->query->addInnerJoin($table, $onClause, $alias, $order, $parameters);
}
return $this;
} | php | public function innerJoin($table, $onClause, $alias = null, $order = 20, $parameters = array())
{
if ($table) {
$this->query->addInnerJoin($table, $onClause, $alias, $order, $parameters);
}
return $this;
} | [
"public",
"function",
"innerJoin",
"(",
"$",
"table",
",",
"$",
"onClause",
",",
"$",
"alias",
"=",
"null",
",",
"$",
"order",
"=",
"20",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"table",
")",
"{",
"$",
"this",
... | Add an INNER JOIN clause to this query.
@param string $table The unquoted table name to join to.
@param string $onClause The filter for the join (escaped SQL statement)
@param string $alias An optional alias name (unquoted)
@param int $order A numerical index to control the order that joins are added to the query; low... | [
"Add",
"an",
"INNER",
"JOIN",
"clause",
"to",
"this",
"query",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L740-L746 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.leftJoin | public function leftJoin($table, $onClause, $alias = null, $order = 20, $parameters = array())
{
if ($table) {
$this->query->addLeftJoin($table, $onClause, $alias, $order, $parameters);
}
return $this;
} | php | public function leftJoin($table, $onClause, $alias = null, $order = 20, $parameters = array())
{
if ($table) {
$this->query->addLeftJoin($table, $onClause, $alias, $order, $parameters);
}
return $this;
} | [
"public",
"function",
"leftJoin",
"(",
"$",
"table",
",",
"$",
"onClause",
",",
"$",
"alias",
"=",
"null",
",",
"$",
"order",
"=",
"20",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"table",
")",
"{",
"$",
"this",
"... | Add a LEFT JOIN clause to this query.
@param string $table The unquoted table to join to.
@param string $onClause The filter for the join (escaped SQL statement).
@param string $alias An optional alias name (unquoted)
@param int $order A numerical index to control the order that joins are added to the query; lower ord... | [
"Add",
"a",
"LEFT",
"JOIN",
"clause",
"to",
"this",
"query",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L760-L766 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.joinHasManyRelation | protected function joinHasManyRelation(
$localClass,
$localField,
$foreignClass,
$localPrefix = null,
$foreignPrefix = null,
$type = 'has_many'
) {
if (!$foreignClass || $foreignClass === DataObject::class) {
throw new InvalidArgumentException("Cou... | php | protected function joinHasManyRelation(
$localClass,
$localField,
$foreignClass,
$localPrefix = null,
$foreignPrefix = null,
$type = 'has_many'
) {
if (!$foreignClass || $foreignClass === DataObject::class) {
throw new InvalidArgumentException("Cou... | [
"protected",
"function",
"joinHasManyRelation",
"(",
"$",
"localClass",
",",
"$",
"localField",
",",
"$",
"foreignClass",
",",
"$",
"localPrefix",
"=",
"null",
",",
"$",
"foreignPrefix",
"=",
"null",
",",
"$",
"type",
"=",
"'has_many'",
")",
"{",
"if",
"("... | Join the given has_many relation to this query.
Also works with belongs_to
Doesn't work with polymorphic relationships
@param string $localClass Name of class that has the has_many to the joined class
@param string $localField Name of the has_many relationship to join
@param string $foreignClass Class to join
@param ... | [
"Join",
"the",
"given",
"has_many",
"relation",
"to",
"this",
"query",
".",
"Also",
"works",
"with",
"belongs_to"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L894-L950 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.joinHasOneRelation | protected function joinHasOneRelation(
$localClass,
$localField,
$foreignClass,
$localPrefix = null,
$foreignPrefix = null
) {
if (!$foreignClass) {
throw new InvalidArgumentException("Could not find a has_one relationship {$localField} on {$localClass}");... | php | protected function joinHasOneRelation(
$localClass,
$localField,
$foreignClass,
$localPrefix = null,
$foreignPrefix = null
) {
if (!$foreignClass) {
throw new InvalidArgumentException("Could not find a has_one relationship {$localField} on {$localClass}");... | [
"protected",
"function",
"joinHasOneRelation",
"(",
"$",
"localClass",
",",
"$",
"localField",
",",
"$",
"foreignClass",
",",
"$",
"localPrefix",
"=",
"null",
",",
"$",
"foreignPrefix",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"foreignClass",
")",
"{",
... | Join the given class to this query with the given key
@param string $localClass Name of class that has the has_one to the joined class
@param string $localField Name of the has_one relationship to joi
@param string $foreignClass Class to join
@param string $localPrefix Table prefix to use for local class
@param string... | [
"Join",
"the",
"given",
"class",
"to",
"this",
"query",
"with",
"the",
"given",
"key"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L961-L1012 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.joinManyManyRelationship | protected function joinManyManyRelationship(
$relationClass,
$parentClass,
$componentClass,
$parentField,
$componentField,
$relationClassOrTable,
$parentPrefix = null,
$componentPrefix = null
) {
$schema = DataObject::getSchema();
if (... | php | protected function joinManyManyRelationship(
$relationClass,
$parentClass,
$componentClass,
$parentField,
$componentField,
$relationClassOrTable,
$parentPrefix = null,
$componentPrefix = null
) {
$schema = DataObject::getSchema();
if (... | [
"protected",
"function",
"joinManyManyRelationship",
"(",
"$",
"relationClass",
",",
"$",
"parentClass",
",",
"$",
"componentClass",
",",
"$",
"parentField",
",",
"$",
"componentField",
",",
"$",
"relationClassOrTable",
",",
"$",
"parentPrefix",
"=",
"null",
",",
... | Join table via many_many relationship
@param string $relationClass
@param string $parentClass
@param string $componentClass
@param string $parentField
@param string $componentField
@param string $relationClassOrTable Name of relation table
@param string $parentPrefix Table prefix for parent class
@param string $compon... | [
"Join",
"table",
"via",
"many_many",
"relationship"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L1026-L1082 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.subtract | public function subtract(DataQuery $subtractQuery, $field = 'ID')
{
$fieldExpression = $subtractQuery->expressionForField($field);
$subSelect = $subtractQuery->getFinalisedQuery();
$subSelect->setSelect(array());
$subSelect->selectField($fieldExpression, $field);
$subSelect->... | php | public function subtract(DataQuery $subtractQuery, $field = 'ID')
{
$fieldExpression = $subtractQuery->expressionForField($field);
$subSelect = $subtractQuery->getFinalisedQuery();
$subSelect->setSelect(array());
$subSelect->selectField($fieldExpression, $field);
$subSelect->... | [
"public",
"function",
"subtract",
"(",
"DataQuery",
"$",
"subtractQuery",
",",
"$",
"field",
"=",
"'ID'",
")",
"{",
"$",
"fieldExpression",
"=",
"$",
"subtractQuery",
"->",
"expressionForField",
"(",
"$",
"field",
")",
";",
"$",
"subSelect",
"=",
"$",
"sub... | Removes the result of query from this query.
@param DataQuery $subtractQuery
@param string $field
@return $this | [
"Removes",
"the",
"result",
"of",
"query",
"from",
"this",
"query",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L1091-L1102 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.selectFromTable | public function selectFromTable($table, $fields)
{
$fieldExpressions = array_map(function ($item) use ($table) {
return Convert::symbol2sql("{$table}.{$item}");
}, $fields);
$this->query->setSelect($fieldExpressions);
return $this;
} | php | public function selectFromTable($table, $fields)
{
$fieldExpressions = array_map(function ($item) use ($table) {
return Convert::symbol2sql("{$table}.{$item}");
}, $fields);
$this->query->setSelect($fieldExpressions);
return $this;
} | [
"public",
"function",
"selectFromTable",
"(",
"$",
"table",
",",
"$",
"fields",
")",
"{",
"$",
"fieldExpressions",
"=",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"table",
")",
"{",
"return",
"Convert",
"::",
"symbol2sql",
"(",... | Select the only given fields from the given table.
@param string $table Unquoted table name (will be escaped automatically)
@param array $fields Database column names (will be escaped automatically)
@return $this | [
"Select",
"the",
"only",
"given",
"fields",
"from",
"the",
"given",
"table",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L1111-L1120 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.addSelectFromTable | public function addSelectFromTable($table, $fields)
{
$fieldExpressions = array_map(function ($item) use ($table) {
return Convert::symbol2sql("{$table}.{$item}");
}, $fields);
$this->query->addSelect($fieldExpressions);
return $this;
} | php | public function addSelectFromTable($table, $fields)
{
$fieldExpressions = array_map(function ($item) use ($table) {
return Convert::symbol2sql("{$table}.{$item}");
}, $fields);
$this->query->addSelect($fieldExpressions);
return $this;
} | [
"public",
"function",
"addSelectFromTable",
"(",
"$",
"table",
",",
"$",
"fields",
")",
"{",
"$",
"fieldExpressions",
"=",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"table",
")",
"{",
"return",
"Convert",
"::",
"symbol2sql",
"... | Add the given fields from the given table to the select statement.
@param string $table Unquoted table name (will be escaped automatically)
@param array $fields Database column names (will be escaped automatically)
@return $this | [
"Add",
"the",
"given",
"fields",
"from",
"the",
"given",
"table",
"to",
"the",
"select",
"statement",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L1129-L1138 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.column | public function column($field = 'ID')
{
$fieldExpression = $this->expressionForField($field);
$query = $this->getFinalisedQuery(array($field));
$originalSelect = $query->getSelect();
$query->setSelect(array());
$query->selectField($fieldExpression, $field);
$this->ens... | php | public function column($field = 'ID')
{
$fieldExpression = $this->expressionForField($field);
$query = $this->getFinalisedQuery(array($field));
$originalSelect = $query->getSelect();
$query->setSelect(array());
$query->selectField($fieldExpression, $field);
$this->ens... | [
"public",
"function",
"column",
"(",
"$",
"field",
"=",
"'ID'",
")",
"{",
"$",
"fieldExpression",
"=",
"$",
"this",
"->",
"expressionForField",
"(",
"$",
"field",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getFinalisedQuery",
"(",
"array",
"(",
"... | Query the given field column from the database and return as an array.
@param string $field See {@link expressionForField()}.
@return array List of column values for the specified column | [
"Query",
"the",
"given",
"field",
"column",
"from",
"the",
"database",
"and",
"return",
"as",
"an",
"array",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L1146-L1156 | train |
silverstripe/silverstripe-framework | src/ORM/DataQuery.php | DataQuery.getQueryParam | public function getQueryParam($key)
{
if (isset($this->queryParams[$key])) {
return $this->queryParams[$key];
}
return null;
} | php | public function getQueryParam($key)
{
if (isset($this->queryParams[$key])) {
return $this->queryParams[$key];
}
return null;
} | [
"public",
"function",
"getQueryParam",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queryParams",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"queryParams",
"[",
"$",
"key",
"]",
";",
"}",
"return",
... | Set an arbitrary query parameter, that can be used by decorators to add additional meta-data to the query.
@param string $key
@return string | [
"Set",
"an",
"arbitrary",
"query",
"parameter",
"that",
"can",
"be",
"used",
"by",
"decorators",
"to",
"add",
"additional",
"meta",
"-",
"data",
"to",
"the",
"query",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataQuery.php#L1219-L1225 | train |
silverstripe/silverstripe-framework | src/Control/Controller.php | Controller.doInit | public function doInit()
{
//extension hook
$this->extend('onBeforeInit');
// Safety call
$this->baseInitCalled = false;
$this->init();
if (!$this->baseInitCalled) {
$class = static::class;
user_error(
"init() method on class '... | php | public function doInit()
{
//extension hook
$this->extend('onBeforeInit');
// Safety call
$this->baseInitCalled = false;
$this->init();
if (!$this->baseInitCalled) {
$class = static::class;
user_error(
"init() method on class '... | [
"public",
"function",
"doInit",
"(",
")",
"{",
"//extension hook",
"$",
"this",
"->",
"extend",
"(",
"'onBeforeInit'",
")",
";",
"// Safety call",
"$",
"this",
"->",
"baseInitCalled",
"=",
"false",
";",
"$",
"this",
"->",
"init",
"(",
")",
";",
"if",
"("... | A stand in function to protect the init function from failing to be called as well as providing before and
after hooks for the init function itself
This should be called on all controllers before handling requests | [
"A",
"stand",
"in",
"function",
"to",
"protect",
"the",
"init",
"function",
"from",
"failing",
"to",
"be",
"called",
"as",
"well",
"as",
"providing",
"before",
"and",
"after",
"hooks",
"for",
"the",
"init",
"function",
"itself"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Controller.php#L120-L138 | train |
silverstripe/silverstripe-framework | src/Control/Controller.php | Controller.beforeHandleRequest | protected function beforeHandleRequest(HTTPRequest $request)
{
//Set up the internal dependencies (request, response)
$this->setRequest($request);
//Push the current controller to protect against weird session issues
$this->pushCurrent();
$this->setResponse(new HTTPResponse()... | php | protected function beforeHandleRequest(HTTPRequest $request)
{
//Set up the internal dependencies (request, response)
$this->setRequest($request);
//Push the current controller to protect against weird session issues
$this->pushCurrent();
$this->setResponse(new HTTPResponse()... | [
"protected",
"function",
"beforeHandleRequest",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"//Set up the internal dependencies (request, response)",
"$",
"this",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"//Push the current controller to protect against weird sessio... | A bootstrap for the handleRequest method
@todo setDataModel and setRequest are redundantly called in parent::handleRequest() - sort this out
@param HTTPRequest $request | [
"A",
"bootstrap",
"for",
"the",
"handleRequest",
"method"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Controller.php#L160-L169 | train |
silverstripe/silverstripe-framework | src/Control/Controller.php | Controller.removeAction | public function removeAction($fullURL, $action = null)
{
if (!$action) {
$action = $this->getAction(); //default to current action
}
$returnURL = $fullURL;
if (($pos = strpos($fullURL, $action)) !== false) {
$returnURL = substr($fullURL, 0, $pos);
... | php | public function removeAction($fullURL, $action = null)
{
if (!$action) {
$action = $this->getAction(); //default to current action
}
$returnURL = $fullURL;
if (($pos = strpos($fullURL, $action)) !== false) {
$returnURL = substr($fullURL, 0, $pos);
... | [
"public",
"function",
"removeAction",
"(",
"$",
"fullURL",
",",
"$",
"action",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"action",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"getAction",
"(",
")",
";",
"//default to current action",
"}",
"$",
... | Removes all the "action" part of the current URL and returns the result. If no action parameter
is present, returns the full URL.
@param string $fullURL
@param null|string $action
@return string | [
"Removes",
"all",
"the",
"action",
"part",
"of",
"the",
"current",
"URL",
"and",
"returns",
"the",
"result",
".",
"If",
"no",
"action",
"parameter",
"is",
"present",
"returns",
"the",
"full",
"URL",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Controller.php#L441-L453 | train |
silverstripe/silverstripe-framework | src/Control/Controller.php | Controller.definingClassForAction | protected function definingClassForAction($action)
{
$definingClass = parent::definingClassForAction($action);
if ($definingClass) {
return $definingClass;
}
$class = static::class;
while ($class != 'SilverStripe\\Control\\RequestHandler') {
$template... | php | protected function definingClassForAction($action)
{
$definingClass = parent::definingClassForAction($action);
if ($definingClass) {
return $definingClass;
}
$class = static::class;
while ($class != 'SilverStripe\\Control\\RequestHandler') {
$template... | [
"protected",
"function",
"definingClassForAction",
"(",
"$",
"action",
")",
"{",
"$",
"definingClass",
"=",
"parent",
"::",
"definingClassForAction",
"(",
"$",
"action",
")",
";",
"if",
"(",
"$",
"definingClass",
")",
"{",
"return",
"$",
"definingClass",
";",
... | Return the class that defines the given action, so that we know where to check allowed_actions.
Overrides RequestHandler to also look at defined templates.
@param string $action
@return string | [
"Return",
"the",
"class",
"that",
"defines",
"the",
"given",
"action",
"so",
"that",
"we",
"know",
"where",
"to",
"check",
"allowed_actions",
".",
"Overrides",
"RequestHandler",
"to",
"also",
"look",
"at",
"defined",
"templates",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Controller.php#L463-L481 | train |
silverstripe/silverstripe-framework | src/Control/Controller.php | Controller.hasActionTemplate | public function hasActionTemplate($action)
{
if (isset($this->templates[$action])) {
return true;
}
$parentClass = static::class;
$templates = array();
while ($parentClass != __CLASS__) {
$templates[] = strtok($parentClass, '_') . '_' . $action;
... | php | public function hasActionTemplate($action)
{
if (isset($this->templates[$action])) {
return true;
}
$parentClass = static::class;
$templates = array();
while ($parentClass != __CLASS__) {
$templates[] = strtok($parentClass, '_') . '_' . $action;
... | [
"public",
"function",
"hasActionTemplate",
"(",
"$",
"action",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"action",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"parentClass",
"=",
"static",
"::",
"class",
";... | Returns TRUE if this controller has a template that is specifically designed to handle a
specific action.
@param string $action
@return bool | [
"Returns",
"TRUE",
"if",
"this",
"controller",
"has",
"a",
"template",
"that",
"is",
"specifically",
"designed",
"to",
"handle",
"a",
"specific",
"action",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Controller.php#L491-L506 | train |
silverstripe/silverstripe-framework | src/Control/Controller.php | Controller.can | public function can($perm, $member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if (is_array($perm)) {
$perm = array_map(array($this, 'can'), $perm, array_fill(0, count($perm), $member));
return min($perm);
}
if ($this-... | php | public function can($perm, $member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if (is_array($perm)) {
$perm = array_map(array($this, 'can'), $perm, array_fill(0, count($perm), $member));
return min($perm);
}
if ($this-... | [
"public",
"function",
"can",
"(",
"$",
"perm",
",",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"perm"... | Returns true if the member is allowed to do the given action. Defaults to the currently logged
in user.
@param string $perm
@param null|member $member
@return bool | [
"Returns",
"true",
"if",
"the",
"member",
"is",
"allowed",
"to",
"do",
"the",
"given",
"action",
".",
"Defaults",
"to",
"the",
"currently",
"logged",
"in",
"user",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Controller.php#L580-L594 | train |
silverstripe/silverstripe-framework | src/ORM/ValidationResult.php | ValidationResult.combineAnd | public function combineAnd(ValidationResult $other)
{
$this->isValid = $this->isValid && $other->isValid();
$this->messages = array_merge($this->messages, $other->getMessages());
return $this;
} | php | public function combineAnd(ValidationResult $other)
{
$this->isValid = $this->isValid && $other->isValid();
$this->messages = array_merge($this->messages, $other->getMessages());
return $this;
} | [
"public",
"function",
"combineAnd",
"(",
"ValidationResult",
"$",
"other",
")",
"{",
"$",
"this",
"->",
"isValid",
"=",
"$",
"this",
"->",
"isValid",
"&&",
"$",
"other",
"->",
"isValid",
"(",
")",
";",
"$",
"this",
"->",
"messages",
"=",
"array_merge",
... | Combine this Validation Result with the ValidationResult given in other.
It will be valid if both this and the other result are valid.
This object will be modified to contain the new validation information.
@param ValidationResult $other the validation result object to combine
@return $this | [
"Combine",
"this",
"Validation",
"Result",
"with",
"the",
"ValidationResult",
"given",
"in",
"other",
".",
"It",
"will",
"be",
"valid",
"if",
"both",
"this",
"and",
"the",
"other",
"result",
"are",
"valid",
".",
"This",
"object",
"will",
"be",
"modified",
... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ValidationResult.php#L210-L215 | train |
silverstripe/silverstripe-framework | src/Core/Startup/ErrorControlChainMiddleware.php | ErrorControlChainMiddleware.safeReloadWithTokens | protected function safeReloadWithTokens(HTTPRequest $request, ConfirmationTokenChain $confirmationTokenChain)
{
// Safe reload requires manual boot
$this->getApplication()->getKernel()->boot(false);
// Ensure session is started
$request->getSession()->init($request);
... | php | protected function safeReloadWithTokens(HTTPRequest $request, ConfirmationTokenChain $confirmationTokenChain)
{
// Safe reload requires manual boot
$this->getApplication()->getKernel()->boot(false);
// Ensure session is started
$request->getSession()->init($request);
... | [
"protected",
"function",
"safeReloadWithTokens",
"(",
"HTTPRequest",
"$",
"request",
",",
"ConfirmationTokenChain",
"$",
"confirmationTokenChain",
")",
"{",
"// Safe reload requires manual boot",
"$",
"this",
"->",
"getApplication",
"(",
")",
"->",
"getKernel",
"(",
")"... | Reload application with the given token, but only if either the user is authenticated,
or authentication is impossible.
@param HTTPRequest $request
@param ConfirmationTokenChain $confirmationTokenChain
@return HTTPResponse | [
"Reload",
"application",
"with",
"the",
"given",
"token",
"but",
"only",
"if",
"either",
"the",
"user",
"is",
"authenticated",
"or",
"authentication",
"is",
"impossible",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Startup/ErrorControlChainMiddleware.php#L104-L130 | train |
silverstripe/silverstripe-framework | src/Forms/OptionsetField.php | OptionsetField.getOptionClass | protected function getOptionClass($value, $odd)
{
$oddClass = $odd ? 'odd' : 'even';
$valueClass = ' val' . Convert::raw2htmlid($value);
return $oddClass . $valueClass;
} | php | protected function getOptionClass($value, $odd)
{
$oddClass = $odd ? 'odd' : 'even';
$valueClass = ' val' . Convert::raw2htmlid($value);
return $oddClass . $valueClass;
} | [
"protected",
"function",
"getOptionClass",
"(",
"$",
"value",
",",
"$",
"odd",
")",
"{",
"$",
"oddClass",
"=",
"$",
"odd",
"?",
"'odd'",
":",
"'even'",
";",
"$",
"valueClass",
"=",
"' val'",
".",
"Convert",
"::",
"raw2htmlid",
"(",
"$",
"value",
")",
... | Get extra classes for each item in the list
@param string $value Value of this item
@param bool $odd If this item is odd numbered in the list
@return string | [
"Get",
"extra",
"classes",
"for",
"each",
"item",
"in",
"the",
"list"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/OptionsetField.php#L111-L116 | train |
silverstripe/silverstripe-framework | src/Forms/FormRequestHandler.php | FormRequestHandler.Link | public function Link($action = null)
{
// Forms without parent controller have no link;
// E.g. Submission handled via graphql
$controller = $this->form->getController();
if (empty($controller)) {
return null;
}
// Respect FormObjectLink() method
... | php | public function Link($action = null)
{
// Forms without parent controller have no link;
// E.g. Submission handled via graphql
$controller = $this->form->getController();
if (empty($controller)) {
return null;
}
// Respect FormObjectLink() method
... | [
"public",
"function",
"Link",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"// Forms without parent controller have no link;",
"// E.g. Submission handled via graphql",
"$",
"controller",
"=",
"$",
"this",
"->",
"form",
"->",
"getController",
"(",
")",
";",
"if",
"(",... | Get link for this form
@param string $action
@return string | [
"Get",
"link",
"for",
"this",
"form"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormRequestHandler.php#L77-L97 | train |
silverstripe/silverstripe-framework | src/Forms/FormRequestHandler.php | FormRequestHandler.getAjaxErrorResponse | protected function getAjaxErrorResponse(ValidationResult $result)
{
// Ajax form submissions accept json encoded errors by default
$acceptType = $this->getRequest()->getHeader('Accept');
if (strpos($acceptType, 'application/json') !== false) {
// Send validation errors back as JS... | php | protected function getAjaxErrorResponse(ValidationResult $result)
{
// Ajax form submissions accept json encoded errors by default
$acceptType = $this->getRequest()->getHeader('Accept');
if (strpos($acceptType, 'application/json') !== false) {
// Send validation errors back as JS... | [
"protected",
"function",
"getAjaxErrorResponse",
"(",
"ValidationResult",
"$",
"result",
")",
"{",
"// Ajax form submissions accept json encoded errors by default",
"$",
"acceptType",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getHeader",
"(",
"'Accept'",
")... | Build HTTP error response for ajax requests
@internal called from {@see Form::getValidationErrorResponse}
@param ValidationResult $result
@return HTTPResponse | [
"Build",
"HTTP",
"error",
"response",
"for",
"ajax",
"requests"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormRequestHandler.php#L373-L389 | train |
silverstripe/silverstripe-framework | src/Forms/FormRequestHandler.php | FormRequestHandler.buttonClicked | public function buttonClicked()
{
$actions = $this->getAllActions();
foreach ($actions as $action) {
if ($this->buttonClickedFunc === $action->actionName()) {
return $action;
}
}
return null;
} | php | public function buttonClicked()
{
$actions = $this->getAllActions();
foreach ($actions as $action) {
if ($this->buttonClickedFunc === $action->actionName()) {
return $action;
}
}
return null;
} | [
"public",
"function",
"buttonClicked",
"(",
")",
"{",
"$",
"actions",
"=",
"$",
"this",
"->",
"getAllActions",
"(",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"buttonClickedFunc",
"===",
"$",
... | Get instance of button which was clicked for this request
@return FormAction | [
"Get",
"instance",
"of",
"button",
"which",
"was",
"clicked",
"for",
"this",
"request"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormRequestHandler.php#L453-L462 | train |
silverstripe/silverstripe-framework | src/Forms/FormRequestHandler.php | FormRequestHandler.getAllActions | protected function getAllActions()
{
$fields = $this->form->Fields()->dataFields();
$actions = $this->form->Actions()->dataFields();
$fieldsAndActions = array_merge($fields, $actions);
$actions = array_filter($fieldsAndActions, function ($fieldOrAction) {
return $fieldOr... | php | protected function getAllActions()
{
$fields = $this->form->Fields()->dataFields();
$actions = $this->form->Actions()->dataFields();
$fieldsAndActions = array_merge($fields, $actions);
$actions = array_filter($fieldsAndActions, function ($fieldOrAction) {
return $fieldOr... | [
"protected",
"function",
"getAllActions",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"form",
"->",
"Fields",
"(",
")",
"->",
"dataFields",
"(",
")",
";",
"$",
"actions",
"=",
"$",
"this",
"->",
"form",
"->",
"Actions",
"(",
")",
"->",
"d... | Get a list of all actions, including those in the main "fields" FieldList
@return array | [
"Get",
"a",
"list",
"of",
"all",
"actions",
"including",
"those",
"in",
"the",
"main",
"fields",
"FieldList"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/FormRequestHandler.php#L469-L480 | train |
silverstripe/silverstripe-framework | src/Forms/GridField/GridState_Data.php | GridState_Data.getData | public function getData($name, $default = null)
{
if (!isset($this->data[$name])) {
$this->data[$name] = $default;
} else {
if (is_array($this->data[$name])) {
$this->data[$name] = new GridState_Data($this->data[$name]);
}
}
return... | php | public function getData($name, $default = null)
{
if (!isset($this->data[$name])) {
$this->data[$name] = $default;
} else {
if (is_array($this->data[$name])) {
$this->data[$name] = new GridState_Data($this->data[$name]);
}
}
return... | [
"public",
"function",
"getData",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=... | Retrieve the value for the given key
@param string $name The name of the value to retrieve
@param mixed $default Default value to assign if not set
@return mixed The value associated with this key, or the value specified by $default if not set | [
"Retrieve",
"the",
"value",
"for",
"the",
"given",
"key"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridState_Data.php#L43-L54 | train |
silverstripe/silverstripe-framework | src/Control/HTTPStreamResponse.php | HTTPStreamResponse.isSeekable | protected function isSeekable()
{
$stream = $this->getStream();
if (!$stream) {
return false;
}
$metadata = stream_get_meta_data($stream);
return $metadata['seekable'];
} | php | protected function isSeekable()
{
$stream = $this->getStream();
if (!$stream) {
return false;
}
$metadata = stream_get_meta_data($stream);
return $metadata['seekable'];
} | [
"protected",
"function",
"isSeekable",
"(",
")",
"{",
"$",
"stream",
"=",
"$",
"this",
"->",
"getStream",
"(",
")",
";",
"if",
"(",
"!",
"$",
"stream",
")",
"{",
"return",
"false",
";",
"}",
"$",
"metadata",
"=",
"stream_get_meta_data",
"(",
"$",
"st... | Determine if a stream is seekable
@return bool | [
"Determine",
"if",
"a",
"stream",
"is",
"seekable"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTPStreamResponse.php#L52-L60 | train |
silverstripe/silverstripe-framework | src/Control/HTTPStreamResponse.php | HTTPStreamResponse.consumeStream | protected function consumeStream($callback)
{
// Load from stream
$stream = $this->getStream();
if (!$stream) {
return null;
}
// Check if stream must be rewound
if ($this->consumed) {
if (!$this->isSeekable()) {
throw new BadM... | php | protected function consumeStream($callback)
{
// Load from stream
$stream = $this->getStream();
if (!$stream) {
return null;
}
// Check if stream must be rewound
if ($this->consumed) {
if (!$this->isSeekable()) {
throw new BadM... | [
"protected",
"function",
"consumeStream",
"(",
"$",
"callback",
")",
"{",
"// Load from stream",
"$",
"stream",
"=",
"$",
"this",
"->",
"getStream",
"(",
")",
";",
"if",
"(",
"!",
"$",
"stream",
")",
"{",
"return",
"null",
";",
"}",
"// Check if stream mus... | Safely consume the stream
@param callable $callback Callback which will perform the consumable action on the stream
@return mixed Result of $callback($stream) or null if no stream available
@throws BadMethodCallException Throws exception if stream can't be re-consumed | [
"Safely",
"consume",
"the",
"stream"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/HTTPStreamResponse.php#L119-L140 | train |
silverstripe/silverstripe-framework | src/Forms/UploadReceiver.php | UploadReceiver.constructUploadReceiver | protected function constructUploadReceiver()
{
// Set Upload instance
$this->setUpload(Upload::create());
// filter out '' since this would be a regex problem on JS end
$this->getValidator()->setAllowedExtensions(
array_filter(File::config()->allowed_extensions)
... | php | protected function constructUploadReceiver()
{
// Set Upload instance
$this->setUpload(Upload::create());
// filter out '' since this would be a regex problem on JS end
$this->getValidator()->setAllowedExtensions(
array_filter(File::config()->allowed_extensions)
... | [
"protected",
"function",
"constructUploadReceiver",
"(",
")",
"{",
"// Set Upload instance",
"$",
"this",
"->",
"setUpload",
"(",
"Upload",
"::",
"create",
"(",
")",
")",
";",
"// filter out '' since this would be a regex problem on JS end",
"$",
"this",
"->",
"getValid... | Bootstrap Uploadable field | [
"Bootstrap",
"Uploadable",
"field"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/UploadReceiver.php#L39-L53 | train |
silverstripe/silverstripe-framework | src/ORM/Map_Iterator.php | Map_Iterator.extractValue | protected function extractValue($item, $key)
{
if (is_object($item)) {
if (method_exists($item, 'hasMethod') && $item->hasMethod($key)) {
return $item->{$key}();
}
return $item->{$key};
} else {
if (array_key_exists($key, $item)) {
... | php | protected function extractValue($item, $key)
{
if (is_object($item)) {
if (method_exists($item, 'hasMethod') && $item->hasMethod($key)) {
return $item->{$key}();
}
return $item->{$key};
} else {
if (array_key_exists($key, $item)) {
... | [
"protected",
"function",
"extractValue",
"(",
"$",
"item",
",",
"$",
"key",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"item",
",",
"'hasMethod'",
")",
"&&",
"$",
"item",
"->",
"hasMethod"... | Extracts a value from an item in the list, where the item is either an
object or array.
@param array|object $item
@param string $key
@return mixed | [
"Extracts",
"a",
"value",
"from",
"an",
"item",
"in",
"the",
"list",
"where",
"the",
"item",
"is",
"either",
"an",
"object",
"or",
"array",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Map_Iterator.php#L110-L122 | train |
silverstripe/silverstripe-framework | src/ORM/Map_Iterator.php | Map_Iterator.key | public function key()
{
if (($this->endItemIdx !== null) && isset($this->lastItems[$this->endItemIdx])) {
return $this->lastItems[$this->endItemIdx][0];
} else {
if (isset($this->firstItems[$this->firstItemIdx])) {
return $this->firstItems[$this->firstItemIdx]... | php | public function key()
{
if (($this->endItemIdx !== null) && isset($this->lastItems[$this->endItemIdx])) {
return $this->lastItems[$this->endItemIdx][0];
} else {
if (isset($this->firstItems[$this->firstItemIdx])) {
return $this->firstItems[$this->firstItemIdx]... | [
"public",
"function",
"key",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"endItemIdx",
"!==",
"null",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"lastItems",
"[",
"$",
"this",
"->",
"endItemIdx",
"]",
")",
")",
"{",
"return",
"$",
"this",
... | Return the key of the current element.
@return string | [
"Return",
"the",
"key",
"of",
"the",
"current",
"element",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Map_Iterator.php#L129-L140 | train |
silverstripe/silverstripe-framework | src/Forms/HTMLEditor/HTMLEditorConfig.php | HTMLEditorConfig.get | public static function get($identifier = null)
{
if (!$identifier) {
return static::get_active();
}
// Create new instance if unconfigured
if (!isset(self::$configs[$identifier])) {
self::$configs[$identifier] = static::create();
self::$configs[$id... | php | public static function get($identifier = null)
{
if (!$identifier) {
return static::get_active();
}
// Create new instance if unconfigured
if (!isset(self::$configs[$identifier])) {
self::$configs[$identifier] = static::create();
self::$configs[$id... | [
"public",
"static",
"function",
"get",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"identifier",
")",
"{",
"return",
"static",
"::",
"get_active",
"(",
")",
";",
"}",
"// Create new instance if unconfigured",
"if",
"(",
"!",
"isset"... | Get the HTMLEditorConfig object for the given identifier. This is a correct way to get an HTMLEditorConfig
instance - do not call 'new'
@param string $identifier The identifier for the config set. If omitted, the active config is returned.
@return static The configuration object.
This will be created if it does not ye... | [
"Get",
"the",
"HTMLEditorConfig",
"object",
"for",
"the",
"given",
"identifier",
".",
"This",
"is",
"a",
"correct",
"way",
"to",
"get",
"an",
"HTMLEditorConfig",
"instance",
"-",
"do",
"not",
"call",
"new"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/HTMLEditor/HTMLEditorConfig.php#L78-L89 | train |
silverstripe/silverstripe-framework | src/Forms/HTMLEditor/HTMLEditorConfig.php | HTMLEditorConfig.set_config | public static function set_config($identifier, HTMLEditorConfig $config = null)
{
if ($config) {
self::$configs[$identifier] = $config;
self::$configs[$identifier]->setOption('editorIdentifier', $identifier);
} else {
unset(self::$configs[$identifier]);
}
... | php | public static function set_config($identifier, HTMLEditorConfig $config = null)
{
if ($config) {
self::$configs[$identifier] = $config;
self::$configs[$identifier]->setOption('editorIdentifier', $identifier);
} else {
unset(self::$configs[$identifier]);
}
... | [
"public",
"static",
"function",
"set_config",
"(",
"$",
"identifier",
",",
"HTMLEditorConfig",
"$",
"config",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"config",
")",
"{",
"self",
"::",
"$",
"configs",
"[",
"$",
"identifier",
"]",
"=",
"$",
"config",
";",... | Assign a new config, or clear existing, for the given identifier
@param string $identifier A specific identifier
@param HTMLEditorConfig $config Config to set, or null to clear
@return HTMLEditorConfig The assigned config | [
"Assign",
"a",
"new",
"config",
"or",
"clear",
"existing",
"for",
"the",
"given",
"identifier"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/HTMLEditor/HTMLEditorConfig.php#L98-L107 | train |
silverstripe/silverstripe-framework | src/Forms/HTMLEditor/HTMLEditorConfig.php | HTMLEditorConfig.get_available_configs_map | public static function get_available_configs_map()
{
$configs = array();
foreach (self::$configs as $identifier => $config) {
$configs[$identifier] = $config->getOption('friendly_name');
}
return $configs;
} | php | public static function get_available_configs_map()
{
$configs = array();
foreach (self::$configs as $identifier => $config) {
$configs[$identifier] = $config->getOption('friendly_name');
}
return $configs;
} | [
"public",
"static",
"function",
"get_available_configs_map",
"(",
")",
"{",
"$",
"configs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"configs",
"as",
"$",
"identifier",
"=>",
"$",
"config",
")",
"{",
"$",
"configs",
"[",
"$",
"id... | Get the available configurations as a map of friendly_name to
configuration name.
@return array | [
"Get",
"the",
"available",
"configurations",
"as",
"a",
"map",
"of",
"friendly_name",
"to",
"configuration",
"name",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/HTMLEditor/HTMLEditorConfig.php#L183-L192 | train |
silverstripe/silverstripe-framework | src/Forms/TabSet.php | TabSet.FieldHolder | public function FieldHolder($properties = array())
{
$obj = $properties ? $this->customise($properties) : $this;
return $obj->renderWith($this->getTemplates());
} | php | public function FieldHolder($properties = array())
{
$obj = $properties ? $this->customise($properties) : $this;
return $obj->renderWith($this->getTemplates());
} | [
"public",
"function",
"FieldHolder",
"(",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"obj",
"=",
"$",
"properties",
"?",
"$",
"this",
"->",
"customise",
"(",
"$",
"properties",
")",
":",
"$",
"this",
";",
"return",
"$",
"obj",
"->",
... | Returns a tab-strip and the associated tabs.
The HTML is a standardised format, containing a <ul;
@param array $properties
@return DBHTMLText|string | [
"Returns",
"a",
"tab",
"-",
"strip",
"and",
"the",
"associated",
"tabs",
".",
"The",
"HTML",
"is",
"a",
"standardised",
"format",
"containing",
"a",
"<",
";",
"ul",
";"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TabSet.php#L132-L137 | train |
silverstripe/silverstripe-framework | src/Forms/TabSet.php | TabSet.push | public function push(FormField $field)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
parent::push($field);
} | php | public function push(FormField $field)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
parent::push($field);
} | [
"public",
"function",
"push",
"(",
"FormField",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"instanceof",
"Tab",
"||",
"$",
"field",
"instanceof",
"TabSet",
")",
"{",
"$",
"field",
"->",
"setTabSet",
"(",
"$",
"this",
")",
";",
"}",
"parent",
":... | Add a new child field to the end of the set.
@param FormField $field | [
"Add",
"a",
"new",
"child",
"field",
"to",
"the",
"end",
"of",
"the",
"set",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TabSet.php#L195-L201 | train |
silverstripe/silverstripe-framework | src/Forms/TabSet.php | TabSet.unshift | public function unshift(FormField $field)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
parent::unshift($field);
} | php | public function unshift(FormField $field)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
parent::unshift($field);
} | [
"public",
"function",
"unshift",
"(",
"FormField",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"instanceof",
"Tab",
"||",
"$",
"field",
"instanceof",
"TabSet",
")",
"{",
"$",
"field",
"->",
"setTabSet",
"(",
"$",
"this",
")",
";",
"}",
"parent",
... | Add a new child field to the beginning of the set.
@param FormField $field | [
"Add",
"a",
"new",
"child",
"field",
"to",
"the",
"beginning",
"of",
"the",
"set",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TabSet.php#L208-L214 | train |
silverstripe/silverstripe-framework | src/Forms/TabSet.php | TabSet.insertBefore | public function insertBefore($insertBefore, $field, $appendIfMissing = true)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
return parent::insertBefore($insertBefore, $field, $appendIfMissing);
} | php | public function insertBefore($insertBefore, $field, $appendIfMissing = true)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
return parent::insertBefore($insertBefore, $field, $appendIfMissing);
} | [
"public",
"function",
"insertBefore",
"(",
"$",
"insertBefore",
",",
"$",
"field",
",",
"$",
"appendIfMissing",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"field",
"instanceof",
"Tab",
"||",
"$",
"field",
"instanceof",
"TabSet",
")",
"{",
"$",
"field",
"->",... | Inserts a field before a particular field in a FieldList.
@param string $insertBefore Name of the field to insert before
@param FormField $field The form field to insert
@return FormField|null | [
"Inserts",
"a",
"field",
"before",
"a",
"particular",
"field",
"in",
"a",
"FieldList",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TabSet.php#L223-L229 | train |
silverstripe/silverstripe-framework | src/Forms/TabSet.php | TabSet.insertAfter | public function insertAfter($insertAfter, $field, $appendIfMissing = true)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
return parent::insertAfter($insertAfter, $field, $appendIfMissing);
} | php | public function insertAfter($insertAfter, $field, $appendIfMissing = true)
{
if ($field instanceof Tab || $field instanceof TabSet) {
$field->setTabSet($this);
}
return parent::insertAfter($insertAfter, $field, $appendIfMissing);
} | [
"public",
"function",
"insertAfter",
"(",
"$",
"insertAfter",
",",
"$",
"field",
",",
"$",
"appendIfMissing",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"field",
"instanceof",
"Tab",
"||",
"$",
"field",
"instanceof",
"TabSet",
")",
"{",
"$",
"field",
"->",
... | Inserts a field after a particular field in a FieldList.
@param string $insertAfter Name of the field to insert after
@param FormField $field The form field to insert
@return FormField|null | [
"Inserts",
"a",
"field",
"after",
"a",
"particular",
"field",
"in",
"a",
"FieldList",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TabSet.php#L238-L244 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ModuleManifest.php | ModuleManifest.addModule | public function addModule($path)
{
$module = new Module($path, $this->base);
$name = $module->getName();
// Save if not already added
if (empty($this->modules[$name])) {
$this->modules[$name] = $module;
return;
}
// Validate duplicate module
... | php | public function addModule($path)
{
$module = new Module($path, $this->base);
$name = $module->getName();
// Save if not already added
if (empty($this->modules[$name])) {
$this->modules[$name] = $module;
return;
}
// Validate duplicate module
... | [
"public",
"function",
"addModule",
"(",
"$",
"path",
")",
"{",
"$",
"module",
"=",
"new",
"Module",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"base",
")",
";",
"$",
"name",
"=",
"$",
"module",
"->",
"getName",
"(",
")",
";",
"// Save if not already a... | Adds a path as a module
@param string $path | [
"Adds",
"a",
"path",
"as",
"a",
"module"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ModuleManifest.php#L74-L93 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ModuleManifest.php | ModuleManifest.activateConfig | public function activateConfig()
{
$modules = $this->getModules();
// Work in reverse priority, so the higher priority modules get later execution
/** @var Module $module */
foreach (array_reverse($modules) as $module) {
$module->activate();
}
} | php | public function activateConfig()
{
$modules = $this->getModules();
// Work in reverse priority, so the higher priority modules get later execution
/** @var Module $module */
foreach (array_reverse($modules) as $module) {
$module->activate();
}
} | [
"public",
"function",
"activateConfig",
"(",
")",
"{",
"$",
"modules",
"=",
"$",
"this",
"->",
"getModules",
"(",
")",
";",
"// Work in reverse priority, so the higher priority modules get later execution",
"/** @var Module $module */",
"foreach",
"(",
"array_reverse",
"(",... | Includes all of the php _config.php files found by this manifest. | [
"Includes",
"all",
"of",
"the",
"php",
"_config",
".",
"php",
"files",
"found",
"by",
"this",
"manifest",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ModuleManifest.php#L147-L155 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ModuleManifest.php | ModuleManifest.getModule | public function getModule($name)
{
// Optimised find
if (isset($this->modules[$name])) {
return $this->modules[$name];
}
// Fall back to lookup by shortname
if (!strstr($name, '/')) {
foreach ($this->modules as $module) {
if (strcasecm... | php | public function getModule($name)
{
// Optimised find
if (isset($this->modules[$name])) {
return $this->modules[$name];
}
// Fall back to lookup by shortname
if (!strstr($name, '/')) {
foreach ($this->modules as $module) {
if (strcasecm... | [
"public",
"function",
"getModule",
"(",
"$",
"name",
")",
"{",
"// Optimised find",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"modules",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"modules",
"[",
"$",
"name",
"]",
";",
"}"... | Get module by name
@param string $name
@return Module | [
"Get",
"module",
"by",
"name"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ModuleManifest.php#L198-L215 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ModuleManifest.php | ModuleManifest.sort | public function sort()
{
$order = static::config()->uninherited('module_priority');
$project = static::config()->get('project');
/* @var PrioritySorter $sorter */
$sorter = Injector::inst()->createWithArgs(
PrioritySorter::class . '.modulesorter',
[
... | php | public function sort()
{
$order = static::config()->uninherited('module_priority');
$project = static::config()->get('project');
/* @var PrioritySorter $sorter */
$sorter = Injector::inst()->createWithArgs(
PrioritySorter::class . '.modulesorter',
[
... | [
"public",
"function",
"sort",
"(",
")",
"{",
"$",
"order",
"=",
"static",
"::",
"config",
"(",
")",
"->",
"uninherited",
"(",
"'module_priority'",
")",
";",
"$",
"project",
"=",
"static",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'project'",
")",
... | Sort modules sorted by priority
@return void | [
"Sort",
"modules",
"sorted",
"by",
"priority"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ModuleManifest.php#L232-L251 | train |
silverstripe/silverstripe-framework | src/Core/Manifest/ModuleManifest.php | ModuleManifest.getModuleByPath | public function getModuleByPath($path)
{
// Ensure path exists
$path = realpath($path);
if (!$path) {
return null;
}
/** @var Module $rootModule */
$rootModule = null;
// Find based on loaded modules
$modules = ModuleLoader::inst()->getMa... | php | public function getModuleByPath($path)
{
// Ensure path exists
$path = realpath($path);
if (!$path) {
return null;
}
/** @var Module $rootModule */
$rootModule = null;
// Find based on loaded modules
$modules = ModuleLoader::inst()->getMa... | [
"public",
"function",
"getModuleByPath",
"(",
"$",
"path",
")",
"{",
"// Ensure path exists",
"$",
"path",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"return",
"null",
";",
"}",
"/** @var Module $rootModule */",
"$"... | Get module that contains the given path
@param string $path Full filesystem path to the given file
@return Module The module, or null if not a path in any module | [
"Get",
"module",
"that",
"contains",
"the",
"given",
"path"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ModuleManifest.php#L259-L288 | train |
silverstripe/silverstripe-framework | src/i18n/Data/Intl/IntlLocales.php | IntlLocales.scriptDirection | public function scriptDirection($locale = null)
{
$dirs = static::config()->get('text_direction');
if (!$locale) {
$locale = i18n::get_locale();
}
if (isset($dirs[$locale])) {
return $dirs[$locale];
}
$lang = $this->langFromLocale($locale);
... | php | public function scriptDirection($locale = null)
{
$dirs = static::config()->get('text_direction');
if (!$locale) {
$locale = i18n::get_locale();
}
if (isset($dirs[$locale])) {
return $dirs[$locale];
}
$lang = $this->langFromLocale($locale);
... | [
"public",
"function",
"scriptDirection",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"dirs",
"=",
"static",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'text_direction'",
")",
";",
"if",
"(",
"!",
"$",
"locale",
")",
"{",
"$",
"locale",
"=",
"... | Returns the script direction in format compatible with the HTML "dir" attribute.
@see http://www.w3.org/International/tutorials/bidi-xhtml/
@param string $locale Optional locale incl. region (underscored)
@return string "rtl" or "ltr" | [
"Returns",
"the",
"script",
"direction",
"in",
"format",
"compatible",
"with",
"the",
"HTML",
"dir",
"attribute",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/i18n/Data/Intl/IntlLocales.php#L1373-L1387 | train |
silverstripe/silverstripe-framework | src/i18n/Data/Intl/IntlLocales.php | IntlLocales.getLocales | public function getLocales()
{
// Cache by locale
$locale = i18n::get_locale();
if (!empty(static::$cache_locales[$locale])) {
return static::$cache_locales[$locale];
}
// Localise all locales
$locales = $this->config()->get('locales');
$localised... | php | public function getLocales()
{
// Cache by locale
$locale = i18n::get_locale();
if (!empty(static::$cache_locales[$locale])) {
return static::$cache_locales[$locale];
}
// Localise all locales
$locales = $this->config()->get('locales');
$localised... | [
"public",
"function",
"getLocales",
"(",
")",
"{",
"// Cache by locale",
"$",
"locale",
"=",
"i18n",
"::",
"get_locale",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"static",
"::",
"$",
"cache_locales",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"return"... | Get all locale codes and names
@return array Map of locale code => name | [
"Get",
"all",
"locale",
"codes",
"and",
"names"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/i18n/Data/Intl/IntlLocales.php#L1446-L1464 | train |
silverstripe/silverstripe-framework | src/i18n/Data/Intl/IntlLocales.php | IntlLocales.getLanguages | public function getLanguages()
{
// Cache by locale
$locale = i18n::get_locale();
if (!empty(static::$cache_languages[$locale])) {
return static::$cache_languages[$locale];
}
// Localise all languages
$languages = $this->config()->get('languages');
... | php | public function getLanguages()
{
// Cache by locale
$locale = i18n::get_locale();
if (!empty(static::$cache_languages[$locale])) {
return static::$cache_languages[$locale];
}
// Localise all languages
$languages = $this->config()->get('languages');
... | [
"public",
"function",
"getLanguages",
"(",
")",
"{",
"// Cache by locale",
"$",
"locale",
"=",
"i18n",
"::",
"get_locale",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"static",
"::",
"$",
"cache_languages",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"ret... | Get all language codes and names
@return array Map of language code => name | [
"Get",
"all",
"language",
"codes",
"and",
"names"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/i18n/Data/Intl/IntlLocales.php#L1478-L1496 | train |
silverstripe/silverstripe-framework | src/i18n/Data/Intl/IntlLocales.php | IntlLocales.getCountries | public function getCountries()
{
// Cache by locale
$locale = i18n::get_locale();
if (!empty(static::$cache_countries[$locale])) {
return static::$cache_countries[$locale];
}
// Localise all countries
$countries = $this->config()->get('countries');
... | php | public function getCountries()
{
// Cache by locale
$locale = i18n::get_locale();
if (!empty(static::$cache_countries[$locale])) {
return static::$cache_countries[$locale];
}
// Localise all countries
$countries = $this->config()->get('countries');
... | [
"public",
"function",
"getCountries",
"(",
")",
"{",
"// Cache by locale",
"$",
"locale",
"=",
"i18n",
"::",
"get_locale",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"static",
"::",
"$",
"cache_countries",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"ret... | Get all country codes and names
@return array Map of country code => name | [
"Get",
"all",
"country",
"codes",
"and",
"names"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/i18n/Data/Intl/IntlLocales.php#L1532-L1552 | train |
silverstripe/silverstripe-framework | src/Core/Config/ConfigLoader.php | ConfigLoader.nest | public function nest()
{
// Nest config
$manifest = clone $this->getManifest();
// Create new blank loader with new stack (top level nesting)
$newLoader = new static;
$newLoader->pushManifest($manifest);
// Activate new loader
return $newLoader->activate();
... | php | public function nest()
{
// Nest config
$manifest = clone $this->getManifest();
// Create new blank loader with new stack (top level nesting)
$newLoader = new static;
$newLoader->pushManifest($manifest);
// Activate new loader
return $newLoader->activate();
... | [
"public",
"function",
"nest",
"(",
")",
"{",
"// Nest config",
"$",
"manifest",
"=",
"clone",
"$",
"this",
"->",
"getManifest",
"(",
")",
";",
"// Create new blank loader with new stack (top level nesting)",
"$",
"newLoader",
"=",
"new",
"static",
";",
"$",
"newLo... | Nest the config loader and activates it
@return static | [
"Nest",
"the",
"config",
"loader",
"and",
"activates",
"it"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Config/ConfigLoader.php#L94-L105 | train |
silverstripe/silverstripe-framework | src/i18n/Messages/YamlWriter.php | YamlWriter.getPluralForm | protected function getPluralForm($value)
{
// Strip non-plural keys away
if (is_array($value)) {
$forms = i18n::config()->uninherited('plurals');
$forms = array_combine($forms, $forms);
return array_intersect_key($value, $forms);
}
// Parse from s... | php | protected function getPluralForm($value)
{
// Strip non-plural keys away
if (is_array($value)) {
$forms = i18n::config()->uninherited('plurals');
$forms = array_combine($forms, $forms);
return array_intersect_key($value, $forms);
}
// Parse from s... | [
"protected",
"function",
"getPluralForm",
"(",
"$",
"value",
")",
"{",
"// Strip non-plural keys away",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"forms",
"=",
"i18n",
"::",
"config",
"(",
")",
"->",
"uninherited",
"(",
"'plurals'",
")"... | Get array-plural form for any value
@param array|string $value
@return array List of plural forms, or empty array if not plural | [
"Get",
"array",
"-",
"plural",
"form",
"for",
"any",
"value"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/i18n/Messages/YamlWriter.php#L134-L146 | train |
silverstripe/silverstripe-framework | src/i18n/Messages/YamlWriter.php | YamlWriter.getYaml | public function getYaml($messages, $locale)
{
$entities = $this->denormaliseMessages($messages);
$content = $this->getDumper()->dump([
$locale => $entities
], 99);
return $content;
} | php | public function getYaml($messages, $locale)
{
$entities = $this->denormaliseMessages($messages);
$content = $this->getDumper()->dump([
$locale => $entities
], 99);
return $content;
} | [
"public",
"function",
"getYaml",
"(",
"$",
"messages",
",",
"$",
"locale",
")",
"{",
"$",
"entities",
"=",
"$",
"this",
"->",
"denormaliseMessages",
"(",
"$",
"messages",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getDumper",
"(",
")",
"->",
... | Convert messages to yml ready to write
@param array $messages
@param string $locale
@return string | [
"Convert",
"messages",
"to",
"yml",
"ready",
"to",
"write"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/i18n/Messages/YamlWriter.php#L155-L162 | train |
silverstripe/silverstripe-framework | src/i18n/Messages/YamlWriter.php | YamlWriter.getClassKey | protected function getClassKey($entity)
{
$parts = explode('.', $entity);
$class = array_shift($parts);
// Ensure the `.ss` suffix gets added to the top level class rather than the key
if (count($parts) > 1 && reset($parts) === 'ss') {
$class .= '.ss';
array_... | php | protected function getClassKey($entity)
{
$parts = explode('.', $entity);
$class = array_shift($parts);
// Ensure the `.ss` suffix gets added to the top level class rather than the key
if (count($parts) > 1 && reset($parts) === 'ss') {
$class .= '.ss';
array_... | [
"protected",
"function",
"getClassKey",
"(",
"$",
"entity",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"entity",
")",
";",
"$",
"class",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"// Ensure the `.ss` suffix gets added to the top level... | Determine class and key for a localisation entity
@param string $entity
@return array Two-length array with class and key as elements | [
"Determine",
"class",
"and",
"key",
"for",
"a",
"localisation",
"entity"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/i18n/Messages/YamlWriter.php#L170-L182 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.unnest | public static function unnest()
{
// Unnest unless we would be left at 0 manifests
$loader = InjectorLoader::inst();
if ($loader->countManifests() <= 1) {
user_error(
"Unable to unnest root Injector, please make sure you don't have mis-matched nest/unnest",
... | php | public static function unnest()
{
// Unnest unless we would be left at 0 manifests
$loader = InjectorLoader::inst();
if ($loader->countManifests() <= 1) {
user_error(
"Unable to unnest root Injector, please make sure you don't have mis-matched nest/unnest",
... | [
"public",
"static",
"function",
"unnest",
"(",
")",
"{",
"// Unnest unless we would be left at 0 manifests",
"$",
"loader",
"=",
"InjectorLoader",
"::",
"inst",
"(",
")",
";",
"if",
"(",
"$",
"loader",
"->",
"countManifests",
"(",
")",
"<=",
"1",
")",
"{",
"... | Change the active Injector back to the Injector instance the current active
Injector object was copied from.
@return Injector Reference to restored active Injector instance | [
"Change",
"the",
"active",
"Injector",
"back",
"to",
"the",
"Injector",
"instance",
"the",
"current",
"active",
"Injector",
"object",
"was",
"copied",
"from",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L278-L291 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.load | public function load($config = array())
{
foreach ($config as $specId => $spec) {
if (is_string($spec)) {
$spec = array('class' => $spec);
}
$file = isset($spec['src']) ? $spec['src'] : null;
// class is whatever's explicitly set,
... | php | public function load($config = array())
{
foreach ($config as $specId => $spec) {
if (is_string($spec)) {
$spec = array('class' => $spec);
}
$file = isset($spec['src']) ? $spec['src'] : null;
// class is whatever's explicitly set,
... | [
"public",
"function",
"load",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"specId",
"=>",
"$",
"spec",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"spec",
"=",
"arr... | Load services using the passed in configuration for those services
@param array $config
@return $this | [
"Load",
"services",
"using",
"the",
"passed",
"in",
"configuration",
"for",
"those",
"services"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L385-L450 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.updateSpec | public function updateSpec($id, $property, $value, $append = true)
{
if (isset($this->specs[$id]['properties'][$property])) {
// by ref so we're updating the actual value
$current = &$this->specs[$id]['properties'][$property];
if (is_array($current) && $append) {
... | php | public function updateSpec($id, $property, $value, $append = true)
{
if (isset($this->specs[$id]['properties'][$property])) {
// by ref so we're updating the actual value
$current = &$this->specs[$id]['properties'][$property];
if (is_array($current) && $append) {
... | [
"public",
"function",
"updateSpec",
"(",
"$",
"id",
",",
"$",
"property",
",",
"$",
"value",
",",
"$",
"append",
"=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"specs",
"[",
"$",
"id",
"]",
"[",
"'properties'",
"]",
"[",
"$",
... | Update the configuration of an already defined service
Use this if you don't want to register a complete new config, just append
to an existing configuration. Helpful to avoid overwriting someone else's changes
updateSpec('RequestProcessor', 'filters', '%$MyFilter')
@param string $id
The name of the service to updat... | [
"Update",
"the",
"configuration",
"of",
"an",
"already",
"defined",
"service"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L469-L486 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.convertServiceProperty | public function convertServiceProperty($value)
{
if (is_array($value)) {
$newVal = array();
foreach ($value as $k => $v) {
$newVal[$k] = $this->convertServiceProperty($v);
}
return $newVal;
}
// Evaluate service references
... | php | public function convertServiceProperty($value)
{
if (is_array($value)) {
$newVal = array();
foreach ($value as $k => $v) {
$newVal[$k] = $this->convertServiceProperty($v);
}
return $newVal;
}
// Evaluate service references
... | [
"public",
"function",
"convertServiceProperty",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"newVal",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"... | Recursively convert a value into its proper representation with service references
resolved to actual objects
@param string $value
@return array|mixed|string | [
"Recursively",
"convert",
"a",
"value",
"into",
"its",
"proper",
"representation",
"with",
"service",
"references",
"resolved",
"to",
"actual",
"objects"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L510-L539 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.instantiate | protected function instantiate($spec, $id = null, $type = null)
{
if (is_string($spec)) {
$spec = array('class' => $spec);
}
$class = $spec['class'];
// create the object, using any constructor bindings
$constructorParams = array();
if (isset($spec['const... | php | protected function instantiate($spec, $id = null, $type = null)
{
if (is_string($spec)) {
$spec = array('class' => $spec);
}
$class = $spec['class'];
// create the object, using any constructor bindings
$constructorParams = array();
if (isset($spec['const... | [
"protected",
"function",
"instantiate",
"(",
"$",
"spec",
",",
"$",
"id",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"spec",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"spec",... | Instantiate a managed object
Given a specification of the form
array(
'class' => 'ClassName',
'properties' => array('property' => 'scalar', 'other' => '%$BeanRef')
'id' => 'ServiceId',
'type' => 'singleton|prototype'
)
will create a new object, store it in the service registry, and
set any relevant properties
Optio... | [
"Instantiate",
"a",
"managed",
"object"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L572-L623 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.setObjectProperty | protected function setObjectProperty($object, $name, $value)
{
if (ClassInfo::hasMethod($object, 'set' . $name)) {
$object->{'set' . $name}($value);
} else {
$object->$name = $value;
}
} | php | protected function setObjectProperty($object, $name, $value)
{
if (ClassInfo::hasMethod($object, 'set' . $name)) {
$object->{'set' . $name}($value);
} else {
$object->$name = $value;
}
} | [
"protected",
"function",
"setObjectProperty",
"(",
"$",
"object",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"ClassInfo",
"::",
"hasMethod",
"(",
"$",
"object",
",",
"'set'",
".",
"$",
"name",
")",
")",
"{",
"$",
"object",
"->",
"{",
... | Helper to set a property's value
@param object $object
Set an object's property to a specific value
@param string $name
The name of the property to set
@param mixed $value
The value to set | [
"Helper",
"to",
"set",
"a",
"property",
"s",
"value"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L804-L811 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.getServiceName | public function getServiceName($name)
{
// Lazy load in spec (disable inheritance to check exact service name)
if ($this->getServiceSpec($name, false)) {
return $name;
}
// okay, check whether we've got a compound name - don't worry about 0 index, cause that's an
... | php | public function getServiceName($name)
{
// Lazy load in spec (disable inheritance to check exact service name)
if ($this->getServiceSpec($name, false)) {
return $name;
}
// okay, check whether we've got a compound name - don't worry about 0 index, cause that's an
... | [
"public",
"function",
"getServiceName",
"(",
"$",
"name",
")",
"{",
"// Lazy load in spec (disable inheritance to check exact service name)",
"if",
"(",
"$",
"this",
"->",
"getServiceSpec",
"(",
"$",
"name",
",",
"false",
")",
")",
"{",
"return",
"$",
"name",
";",... | Does the given service exist, and if so, what's the stored name for it?
We do a special check here for services that are using compound names. For example,
we might want to say that a property should be injected with Log.File or Log.Memory,
but have only registered a 'Log' service, we'll instead return that.
Will rec... | [
"Does",
"the",
"given",
"service",
"exist",
"and",
"if",
"so",
"what",
"s",
"the",
"stored",
"name",
"for",
"it?"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L854-L868 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.registerService | public function registerService($service, $replace = null)
{
$registerAt = get_class($service);
if ($replace !== null) {
$registerAt = $replace;
}
$this->specs[$registerAt] = array('class' => get_class($service));
$this->serviceCache[$registerAt] = $service;
... | php | public function registerService($service, $replace = null)
{
$registerAt = get_class($service);
if ($replace !== null) {
$registerAt = $replace;
}
$this->specs[$registerAt] = array('class' => get_class($service));
$this->serviceCache[$registerAt] = $service;
... | [
"public",
"function",
"registerService",
"(",
"$",
"service",
",",
"$",
"replace",
"=",
"null",
")",
"{",
"$",
"registerAt",
"=",
"get_class",
"(",
"$",
"service",
")",
";",
"if",
"(",
"$",
"replace",
"!==",
"null",
")",
"{",
"$",
"registerAt",
"=",
... | Register a service object with an optional name to register it as the
service for
@param object $service The object to register
@param string $replace The name of the object to replace (if different to the
class name of the object to register)
@return $this | [
"Register",
"a",
"service",
"object",
"with",
"an",
"optional",
"name",
"to",
"register",
"it",
"as",
"the",
"service",
"for"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L879-L889 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.unregisterObjects | public function unregisterObjects($types)
{
if (!is_array($types)) {
$types = [ $types ];
}
// Filter all objects
foreach ($this->serviceCache as $key => $object) {
foreach ($types as $filterClass) {
// Prevent destructive flushing
... | php | public function unregisterObjects($types)
{
if (!is_array($types)) {
$types = [ $types ];
}
// Filter all objects
foreach ($this->serviceCache as $key => $object) {
foreach ($types as $filterClass) {
// Prevent destructive flushing
... | [
"public",
"function",
"unregisterObjects",
"(",
"$",
"types",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"types",
")",
")",
"{",
"$",
"types",
"=",
"[",
"$",
"types",
"]",
";",
"}",
"// Filter all objects",
"foreach",
"(",
"$",
"this",
"->",
"se... | Clear out objects of one or more types that are managed by the injetor.
@param array|string $types Base class of object (not service name) to remove
@return $this | [
"Clear",
"out",
"objects",
"of",
"one",
"or",
"more",
"types",
"that",
"are",
"managed",
"by",
"the",
"injetor",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L911-L931 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.get | public function get($name, $asSingleton = true, $constructorArgs = [])
{
$object = $this->getNamedService($name, $asSingleton, $constructorArgs);
if (!$object) {
throw new InjectorNotFoundException("The '{$name}' service could not be found");
}
return $object;
} | php | public function get($name, $asSingleton = true, $constructorArgs = [])
{
$object = $this->getNamedService($name, $asSingleton, $constructorArgs);
if (!$object) {
throw new InjectorNotFoundException("The '{$name}' service could not be found");
}
return $object;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"asSingleton",
"=",
"true",
",",
"$",
"constructorArgs",
"=",
"[",
"]",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"getNamedService",
"(",
"$",
"name",
",",
"$",
"asSingleton",
",",
"$",
... | Get a named managed object
Will first check to see if the item has been registered as a configured service/bean
and return that if so.
Next, will check to see if there's any registered configuration for the given type
and will then try and load that
Failing all of that, will just return a new instance of the specifi... | [
"Get",
"a",
"named",
"managed",
"object"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L953-L962 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.getServiceNamedSpec | protected function getServiceNamedSpec($name, $constructorArgs = [])
{
$spec = $this->getServiceSpec($name);
if ($spec) {
// Resolve to exact service name (in case inherited)
$name = $this->getServiceName($name);
} else {
// Late-generate config spec for n... | php | protected function getServiceNamedSpec($name, $constructorArgs = [])
{
$spec = $this->getServiceSpec($name);
if ($spec) {
// Resolve to exact service name (in case inherited)
$name = $this->getServiceName($name);
} else {
// Late-generate config spec for n... | [
"protected",
"function",
"getServiceNamedSpec",
"(",
"$",
"name",
",",
"$",
"constructorArgs",
"=",
"[",
"]",
")",
"{",
"$",
"spec",
"=",
"$",
"this",
"->",
"getServiceSpec",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"spec",
")",
"{",
"// Resolve to ... | Get or build a named service and specification
@param string $name Service name
@param array $constructorArgs Optional constructor args
@return array | [
"Get",
"or",
"build",
"a",
"named",
"service",
"and",
"specification"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L1040-L1054 | train |
silverstripe/silverstripe-framework | src/Core/Injector/Injector.php | Injector.getServiceSpec | public function getServiceSpec($name, $inherit = true)
{
if (isset($this->specs[$name])) {
return $this->specs[$name];
}
// Lazy load
$config = $this->configLocator->locateConfigFor($name);
if ($config) {
$this->load([$name => $config]);
i... | php | public function getServiceSpec($name, $inherit = true)
{
if (isset($this->specs[$name])) {
return $this->specs[$name];
}
// Lazy load
$config = $this->configLocator->locateConfigFor($name);
if ($config) {
$this->load([$name => $config]);
i... | [
"public",
"function",
"getServiceSpec",
"(",
"$",
"name",
",",
"$",
"inherit",
"=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"specs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"specs",
"[",
"$",
"name... | Search for spec, lazy-loading in from config locator.
Falls back to parent service name if unloaded
@param string $name
@param bool $inherit Set to true to inherit from parent service if `.` suffixed
E.g. 'Psr/Log/LoggerInterface.custom' would fail over to 'Psr/Log/LoggerInterface'
@return mixed|object | [
"Search",
"for",
"spec",
"lazy",
"-",
"loading",
"in",
"from",
"config",
"locator",
".",
"Falls",
"back",
"to",
"parent",
"service",
"name",
"if",
"unloaded"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Injector/Injector.php#L1065-L1086 | train |
silverstripe/silverstripe-framework | src/ORM/FieldType/DBYear.php | DBYear.getDefaultOptions | private function getDefaultOptions($start = null, $end = null)
{
if (!$start) {
$start = (int)date('Y');
}
if (!$end) {
$end = 1900;
}
$years = array();
for ($i=$start; $i>=$end; $i--) {
$years[$i] = $i;
}
return $ye... | php | private function getDefaultOptions($start = null, $end = null)
{
if (!$start) {
$start = (int)date('Y');
}
if (!$end) {
$end = 1900;
}
$years = array();
for ($i=$start; $i>=$end; $i--) {
$years[$i] = $i;
}
return $ye... | [
"private",
"function",
"getDefaultOptions",
"(",
"$",
"start",
"=",
"null",
",",
"$",
"end",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"start",
")",
"{",
"$",
"start",
"=",
"(",
"int",
")",
"date",
"(",
"'Y'",
")",
";",
"}",
"if",
"(",
"!",
... | Returns a list of default options that can
be used to populate a select box, or compare against
input values. Starts by default at the current year,
and counts back to 1900.
@param int|bool $start starting date to count down from
@param int|bool $end end date to count down to
@return array | [
"Returns",
"a",
"list",
"of",
"default",
"options",
"that",
"can",
"be",
"used",
"to",
"populate",
"a",
"select",
"box",
"or",
"compare",
"against",
"input",
"values",
".",
"Starts",
"by",
"default",
"at",
"the",
"current",
"year",
"and",
"counts",
"back",... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBYear.php#L38-L51 | train |
silverstripe/silverstripe-framework | src/ORM/Filters/ExactMatchFilter.php | ExactMatchFilter.oneFilter | protected function oneFilter(DataQuery $query, $inclusive)
{
$this->model = $query->applyRelation($this->relation);
$field = $this->getDbName();
$value = $this->getValue();
// Null comparison check
if ($value === null) {
$where = DB::get_conn()->nullCheckClause($... | php | protected function oneFilter(DataQuery $query, $inclusive)
{
$this->model = $query->applyRelation($this->relation);
$field = $this->getDbName();
$value = $this->getValue();
// Null comparison check
if ($value === null) {
$where = DB::get_conn()->nullCheckClause($... | [
"protected",
"function",
"oneFilter",
"(",
"DataQuery",
"$",
"query",
",",
"$",
"inclusive",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"query",
"->",
"applyRelation",
"(",
"$",
"this",
"->",
"relation",
")",
";",
"$",
"field",
"=",
"$",
"this",
... | Applies a single match, either as inclusive or exclusive
@param DataQuery $query
@param bool $inclusive True if this is inclusive, or false if exclusive
@return DataQuery | [
"Applies",
"a",
"single",
"match",
"either",
"as",
"inclusive",
"or",
"exclusive"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Filters/ExactMatchFilter.php#L52-L84 | train |
silverstripe/silverstripe-framework | src/ORM/Filters/ExactMatchFilter.php | ExactMatchFilter.manyFilter | protected function manyFilter(DataQuery $query, $inclusive)
{
$this->model = $query->applyRelation($this->relation);
$caseSensitive = $this->getCaseSensitive();
// Check values for null
$field = $this->getDbName();
$values = $this->getValue();
if (empty($values)) {
... | php | protected function manyFilter(DataQuery $query, $inclusive)
{
$this->model = $query->applyRelation($this->relation);
$caseSensitive = $this->getCaseSensitive();
// Check values for null
$field = $this->getDbName();
$values = $this->getValue();
if (empty($values)) {
... | [
"protected",
"function",
"manyFilter",
"(",
"DataQuery",
"$",
"query",
",",
"$",
"inclusive",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"query",
"->",
"applyRelation",
"(",
"$",
"this",
"->",
"relation",
")",
";",
"$",
"caseSensitive",
"=",
"$",
... | Applies matches for several values, either as inclusive or exclusive
@param DataQuery $query
@param bool $inclusive True if this is inclusive, or false if exclusive
@return DataQuery | [
"Applies",
"matches",
"for",
"several",
"values",
"either",
"as",
"inclusive",
"or",
"exclusive"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Filters/ExactMatchFilter.php#L117-L202 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.getVary | public function getVary()
{
// Explicitly set vary
if (isset($this->vary)) {
return $this->vary;
}
// Load default from config
$defaultVary = $this->config()->get('defaultVary');
return array_keys(array_filter($defaultVary));
} | php | public function getVary()
{
// Explicitly set vary
if (isset($this->vary)) {
return $this->vary;
}
// Load default from config
$defaultVary = $this->config()->get('defaultVary');
return array_keys(array_filter($defaultVary));
} | [
"public",
"function",
"getVary",
"(",
")",
"{",
"// Explicitly set vary",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"vary",
")",
")",
"{",
"return",
"$",
"this",
"->",
"vary",
";",
"}",
"// Load default from config",
"$",
"defaultVary",
"=",
"$",
"this",... | Get current vary keys
@return array | [
"Get",
"current",
"vary",
"keys"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L201-L211 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.addVary | public function addVary($vary)
{
$combied = $this->combineVary($this->getVary(), $vary);
$this->setVary($combied);
return $this;
} | php | public function addVary($vary)
{
$combied = $this->combineVary($this->getVary(), $vary);
$this->setVary($combied);
return $this;
} | [
"public",
"function",
"addVary",
"(",
"$",
"vary",
")",
"{",
"$",
"combied",
"=",
"$",
"this",
"->",
"combineVary",
"(",
"$",
"this",
"->",
"getVary",
"(",
")",
",",
"$",
"vary",
")",
";",
"$",
"this",
"->",
"setVary",
"(",
"$",
"combied",
")",
"... | Add a vary
@param string|array $vary
@return $this | [
"Add",
"a",
"vary"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L219-L224 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.registerModificationDate | public function registerModificationDate($date)
{
$timestamp = is_numeric($date) ? $date : strtotime($date);
if ($timestamp > $this->modificationDate) {
$this->modificationDate = $timestamp;
}
return $this;
} | php | public function registerModificationDate($date)
{
$timestamp = is_numeric($date) ? $date : strtotime($date);
if ($timestamp > $this->modificationDate) {
$this->modificationDate = $timestamp;
}
return $this;
} | [
"public",
"function",
"registerModificationDate",
"(",
"$",
"date",
")",
"{",
"$",
"timestamp",
"=",
"is_numeric",
"(",
"$",
"date",
")",
"?",
"$",
"date",
":",
"strtotime",
"(",
"$",
"date",
")",
";",
"if",
"(",
"$",
"timestamp",
">",
"$",
"this",
"... | Register a modification date. Used to calculate the "Last-Modified" HTTP header.
Can be called multiple times, and will automatically retain the most recent date.
@param string|int $date Date string or timestamp
@return HTTPCacheControlMiddleware | [
"Register",
"a",
"modification",
"date",
".",
"Used",
"to",
"calculate",
"the",
"Last",
"-",
"Modified",
"HTTP",
"header",
".",
"Can",
"be",
"called",
"multiple",
"times",
"and",
"will",
"automatically",
"retain",
"the",
"most",
"recent",
"date",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L266-L273 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.setState | protected function setState($state)
{
if (!array_key_exists($state, $this->stateDirectives)) {
throw new InvalidArgumentException("Invalid state {$state}");
}
$this->state = $state;
return $this;
} | php | protected function setState($state)
{
if (!array_key_exists($state, $this->stateDirectives)) {
throw new InvalidArgumentException("Invalid state {$state}");
}
$this->state = $state;
return $this;
} | [
"protected",
"function",
"setState",
"(",
"$",
"state",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"state",
",",
"$",
"this",
"->",
"stateDirectives",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Invalid state {$state}\"",
")... | Set current state. Should only be invoked internally after processing precedence rules.
@param string $state
@return $this | [
"Set",
"current",
"state",
".",
"Should",
"only",
"be",
"invoked",
"internally",
"after",
"processing",
"precedence",
"rules",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L281-L288 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.applyChangeLevel | protected function applyChangeLevel($level, $force)
{
$forcingLevel = $level + ($force ? self::LEVEL_FORCED : 0);
if ($forcingLevel < $this->getForcingLevel()) {
return false;
}
$this->forcingLevel = $forcingLevel;
return true;
} | php | protected function applyChangeLevel($level, $force)
{
$forcingLevel = $level + ($force ? self::LEVEL_FORCED : 0);
if ($forcingLevel < $this->getForcingLevel()) {
return false;
}
$this->forcingLevel = $forcingLevel;
return true;
} | [
"protected",
"function",
"applyChangeLevel",
"(",
"$",
"level",
",",
"$",
"force",
")",
"{",
"$",
"forcingLevel",
"=",
"$",
"level",
"+",
"(",
"$",
"force",
"?",
"self",
"::",
"LEVEL_FORCED",
":",
"0",
")",
";",
"if",
"(",
"$",
"forcingLevel",
"<",
"... | Instruct the cache to apply a change with a given level, optionally
modifying it with a force flag to increase priority of this action.
If the apply level was successful, the change is made and the internal level
threshold is incremented.
@param int $level Priority of the given change
@param bool $force If usercode h... | [
"Instruct",
"the",
"cache",
"to",
"apply",
"a",
"change",
"with",
"a",
"given",
"level",
"optionally",
"modifying",
"it",
"with",
"a",
"force",
"flag",
"to",
"increase",
"priority",
"of",
"this",
"action",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L314-L322 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.setStateDirectivesFromArray | public function setStateDirectivesFromArray($states, $directives)
{
foreach ($directives as $directive => $value) {
$this->setStateDirective($states, $directive, $value);
}
return $this;
} | php | public function setStateDirectivesFromArray($states, $directives)
{
foreach ($directives as $directive => $value) {
$this->setStateDirective($states, $directive, $value);
}
return $this;
} | [
"public",
"function",
"setStateDirectivesFromArray",
"(",
"$",
"states",
",",
"$",
"directives",
")",
"{",
"foreach",
"(",
"$",
"directives",
"as",
"$",
"directive",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setStateDirective",
"(",
"$",
"states",
... | Low level method to set directives from an associative array
@param array|string $states State(s) to apply this directive to
@param array $directives
@return $this | [
"Low",
"level",
"method",
"to",
"set",
"directives",
"from",
"an",
"associative",
"array"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L367-L373 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.hasStateDirective | public function hasStateDirective($state, $directive)
{
$directive = strtolower($directive);
return isset($this->stateDirectives[$state][$directive]);
} | php | public function hasStateDirective($state, $directive)
{
$directive = strtolower($directive);
return isset($this->stateDirectives[$state][$directive]);
} | [
"public",
"function",
"hasStateDirective",
"(",
"$",
"state",
",",
"$",
"directive",
")",
"{",
"$",
"directive",
"=",
"strtolower",
"(",
"$",
"directive",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"stateDirectives",
"[",
"$",
"state",
"]",
"["... | Low level method to check if a directive is currently set
@param string $state State(s) to apply this directive to
@param string $directive
@return bool | [
"Low",
"level",
"method",
"to",
"check",
"if",
"a",
"directive",
"is",
"currently",
"set"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L395-L399 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.getStateDirective | public function getStateDirective($state, $directive)
{
$directive = strtolower($directive);
if (isset($this->stateDirectives[$state][$directive])) {
return $this->stateDirectives[$state][$directive];
}
return false;
} | php | public function getStateDirective($state, $directive)
{
$directive = strtolower($directive);
if (isset($this->stateDirectives[$state][$directive])) {
return $this->stateDirectives[$state][$directive];
}
return false;
} | [
"public",
"function",
"getStateDirective",
"(",
"$",
"state",
",",
"$",
"directive",
")",
"{",
"$",
"directive",
"=",
"strtolower",
"(",
"$",
"directive",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"stateDirectives",
"[",
"$",
"state",
"]",
... | Low level method to get the value of a directive for a state.
Returns false if there is no directive.
True means the flag is set, otherwise the value of the directive.
@param string $state
@param string $directive
@return int|string|bool | [
"Low",
"level",
"method",
"to",
"get",
"the",
"value",
"of",
"a",
"directive",
"for",
"a",
"state",
".",
"Returns",
"false",
"if",
"there",
"is",
"no",
"directive",
".",
"True",
"means",
"the",
"flag",
"is",
"set",
"otherwise",
"the",
"value",
"of",
"t... | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L421-L428 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.applyToResponse | public function applyToResponse($response)
{
$headers = $this->generateHeadersFor($response);
foreach ($headers as $name => $value) {
if (!$response->getHeader($name)) {
$response->addHeader($name, $value);
}
}
return $this;
} | php | public function applyToResponse($response)
{
$headers = $this->generateHeadersFor($response);
foreach ($headers as $name => $value) {
if (!$response->getHeader($name)) {
$response->addHeader($name, $value);
}
}
return $this;
} | [
"public",
"function",
"applyToResponse",
"(",
"$",
"response",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"generateHeadersFor",
"(",
"$",
"response",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if"... | Generate all headers to add to this object
@param HTTPResponse $response
@return $this | [
"Generate",
"all",
"headers",
"to",
"add",
"to",
"this",
"object"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L668-L677 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.generateCacheHeader | protected function generateCacheHeader()
{
$cacheControl = [];
foreach ($this->getDirectives() as $directive => $value) {
if ($value === true) {
$cacheControl[] = $directive;
} else {
$cacheControl[] = $directive . '=' . $value;
}
... | php | protected function generateCacheHeader()
{
$cacheControl = [];
foreach ($this->getDirectives() as $directive => $value) {
if ($value === true) {
$cacheControl[] = $directive;
} else {
$cacheControl[] = $directive . '=' . $value;
}
... | [
"protected",
"function",
"generateCacheHeader",
"(",
")",
"{",
"$",
"cacheControl",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getDirectives",
"(",
")",
"as",
"$",
"directive",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
... | Generate the cache header
@return string | [
"Generate",
"the",
"cache",
"header"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L684-L695 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.generateHeadersFor | public function generateHeadersFor(HTTPResponse $response)
{
return array_filter([
'Last-Modified' => $this->generateLastModifiedHeader(),
'Vary' => $this->generateVaryHeader($response),
'Cache-Control' => $this->generateCacheHeader(),
'Expires' => $this->gene... | php | public function generateHeadersFor(HTTPResponse $response)
{
return array_filter([
'Last-Modified' => $this->generateLastModifiedHeader(),
'Vary' => $this->generateVaryHeader($response),
'Cache-Control' => $this->generateCacheHeader(),
'Expires' => $this->gene... | [
"public",
"function",
"generateHeadersFor",
"(",
"HTTPResponse",
"$",
"response",
")",
"{",
"return",
"array_filter",
"(",
"[",
"'Last-Modified'",
"=>",
"$",
"this",
"->",
"generateLastModifiedHeader",
"(",
")",
",",
"'Vary'",
"=>",
"$",
"this",
"->",
"generateV... | Generate all headers to output
@param HTTPResponse $response
@return array | [
"Generate",
"all",
"headers",
"to",
"output"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L703-L711 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.generateVaryHeader | protected function generateVaryHeader(HTTPResponse $response)
{
// split the current vary header into it's parts and merge it with the config settings
// to create a list of unique vary values
$vary = $this->getVary();
if ($response->getHeader('Vary')) {
$vary = $this->co... | php | protected function generateVaryHeader(HTTPResponse $response)
{
// split the current vary header into it's parts and merge it with the config settings
// to create a list of unique vary values
$vary = $this->getVary();
if ($response->getHeader('Vary')) {
$vary = $this->co... | [
"protected",
"function",
"generateVaryHeader",
"(",
"HTTPResponse",
"$",
"response",
")",
"{",
"// split the current vary header into it's parts and merge it with the config settings",
"// to create a list of unique vary values",
"$",
"vary",
"=",
"$",
"this",
"->",
"getVary",
"(... | Generate vary http header
@param HTTPResponse $response
@return string|null | [
"Generate",
"vary",
"http",
"header"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L738-L750 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.generateExpiresHeader | protected function generateExpiresHeader()
{
$maxAge = $this->getDirective('max-age');
if ($maxAge === false) {
return null;
}
// Add now to max-age to generate expires
$expires = DBDatetime::now()->getTimestamp() + $maxAge;
return gmdate('D, d M Y H:i:s'... | php | protected function generateExpiresHeader()
{
$maxAge = $this->getDirective('max-age');
if ($maxAge === false) {
return null;
}
// Add now to max-age to generate expires
$expires = DBDatetime::now()->getTimestamp() + $maxAge;
return gmdate('D, d M Y H:i:s'... | [
"protected",
"function",
"generateExpiresHeader",
"(",
")",
"{",
"$",
"maxAge",
"=",
"$",
"this",
"->",
"getDirective",
"(",
"'max-age'",
")",
";",
"if",
"(",
"$",
"maxAge",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"// Add now to max-age to gene... | Generate Expires http header
@return null|string | [
"Generate",
"Expires",
"http",
"header"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L770-L780 | train |
silverstripe/silverstripe-framework | src/Control/Middleware/HTTPCacheControlMiddleware.php | HTTPCacheControlMiddleware.augmentState | protected function augmentState(HTTPRequest $request, HTTPResponse $response)
{
// Errors disable cache (unless some errors are cached intentionally by usercode)
if ($response->isError() || $response->isRedirect()) {
// Even if publicCache(true) is specified, errors will be uncacheable
... | php | protected function augmentState(HTTPRequest $request, HTTPResponse $response)
{
// Errors disable cache (unless some errors are cached intentionally by usercode)
if ($response->isError() || $response->isRedirect()) {
// Even if publicCache(true) is specified, errors will be uncacheable
... | [
"protected",
"function",
"augmentState",
"(",
"HTTPRequest",
"$",
"request",
",",
"HTTPResponse",
"$",
"response",
")",
"{",
"// Errors disable cache (unless some errors are cached intentionally by usercode)",
"if",
"(",
"$",
"response",
"->",
"isError",
"(",
")",
"||",
... | Update state based on current request and response objects
@param HTTPRequest $request
@param HTTPResponse $response | [
"Update",
"state",
"based",
"on",
"current",
"request",
"and",
"response",
"objects"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/HTTPCacheControlMiddleware.php#L788-L801 | train |
silverstripe/silverstripe-framework | src/Control/SimpleResourceURLGenerator.php | SimpleResourceURLGenerator.resolveModuleResource | protected function resolveModuleResource(ModuleResource $resource)
{
// Load from module resource
$relativePath = $resource->getRelativePath();
$exists = $resource->exists();
$absolutePath = $resource->getPath();
// Rewrite to _resources with public directory
if (Dir... | php | protected function resolveModuleResource(ModuleResource $resource)
{
// Load from module resource
$relativePath = $resource->getRelativePath();
$exists = $resource->exists();
$absolutePath = $resource->getPath();
// Rewrite to _resources with public directory
if (Dir... | [
"protected",
"function",
"resolveModuleResource",
"(",
"ModuleResource",
"$",
"resource",
")",
"{",
"// Load from module resource",
"$",
"relativePath",
"=",
"$",
"resource",
"->",
"getRelativePath",
"(",
")",
";",
"$",
"exists",
"=",
"$",
"resource",
"->",
"exist... | Update relative path for a module resource
@param ModuleResource $resource
@return array List of [$exists, $absolutePath, $relativePath] | [
"Update",
"relative",
"path",
"for",
"a",
"module",
"resource"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/SimpleResourceURLGenerator.php#L129-L149 | train |
silverstripe/silverstripe-framework | src/Forms/ConfirmedPasswordField.php | ConfirmedPasswordField.setValue | public function setValue($value, $data = null)
{
// If $data is a DataObject, don't use the value, since it's a hashed value
if ($data && $data instanceof DataObject) {
$value = '';
}
//store this for later
$oldValue = $this->value;
if (is_array($value))... | php | public function setValue($value, $data = null)
{
// If $data is a DataObject, don't use the value, since it's a hashed value
if ($data && $data instanceof DataObject) {
$value = '';
}
//store this for later
$oldValue = $this->value;
if (is_array($value))... | [
"public",
"function",
"setValue",
"(",
"$",
"value",
",",
"$",
"data",
"=",
"null",
")",
"{",
"// If $data is a DataObject, don't use the value, since it's a hashed value",
"if",
"(",
"$",
"data",
"&&",
"$",
"data",
"instanceof",
"DataObject",
")",
"{",
"$",
"valu... | Value is sometimes an array, and sometimes a single value, so we need
to handle both cases.
@param mixed $value
@param mixed $data
@return $this | [
"Value",
"is",
"sometimes",
"an",
"array",
"and",
"sometimes",
"a",
"single",
"value",
"so",
"we",
"need",
"to",
"handle",
"both",
"cases",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/ConfirmedPasswordField.php#L335-L373 | train |
silverstripe/silverstripe-framework | src/Forms/ConfirmedPasswordField.php | ConfirmedPasswordField.setName | public function setName($name)
{
$this->getPasswordField()->setName($name . '[_Password]');
$this->getConfirmPasswordField()->setName($name . '[_ConfirmPassword]');
if ($this->hiddenField) {
$this->hiddenField->setName($name . '[_PasswordFieldVisible]');
}
parent... | php | public function setName($name)
{
$this->getPasswordField()->setName($name . '[_Password]');
$this->getConfirmPasswordField()->setName($name . '[_ConfirmPassword]');
if ($this->hiddenField) {
$this->hiddenField->setName($name . '[_PasswordFieldVisible]');
}
parent... | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"getPasswordField",
"(",
")",
"->",
"setName",
"(",
"$",
"name",
".",
"'[_Password]'",
")",
";",
"$",
"this",
"->",
"getConfirmPasswordField",
"(",
")",
"->",
"setName",
"(",... | Update the names of the child fields when updating name of field.
@param string $name new name to give to the field.
@return $this | [
"Update",
"the",
"names",
"of",
"the",
"child",
"fields",
"when",
"updating",
"name",
"of",
"field",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/ConfirmedPasswordField.php#L381-L391 | train |
silverstripe/silverstripe-framework | src/Forms/ConfirmedPasswordField.php | ConfirmedPasswordField.isSaveable | public function isSaveable()
{
return !$this->showOnClick
|| ($this->showOnClick && $this->hiddenField && $this->hiddenField->Value());
} | php | public function isSaveable()
{
return !$this->showOnClick
|| ($this->showOnClick && $this->hiddenField && $this->hiddenField->Value());
} | [
"public",
"function",
"isSaveable",
"(",
")",
"{",
"return",
"!",
"$",
"this",
"->",
"showOnClick",
"||",
"(",
"$",
"this",
"->",
"showOnClick",
"&&",
"$",
"this",
"->",
"hiddenField",
"&&",
"$",
"this",
"->",
"hiddenField",
"->",
"Value",
"(",
")",
")... | Determines if the field was actually shown on the client side - if not,
we don't validate or save it.
@return boolean | [
"Determines",
"if",
"the",
"field",
"was",
"actually",
"shown",
"on",
"the",
"client",
"side",
"-",
"if",
"not",
"we",
"don",
"t",
"validate",
"or",
"save",
"it",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/ConfirmedPasswordField.php#L399-L403 | train |
silverstripe/silverstripe-framework | src/Forms/ConfirmedPasswordField.php | ConfirmedPasswordField.saveInto | public function saveInto(DataObjectInterface $record)
{
if (!$this->isSaveable()) {
return;
}
if (!($this->canBeEmpty && !$this->value)) {
parent::saveInto($record);
}
} | php | public function saveInto(DataObjectInterface $record)
{
if (!$this->isSaveable()) {
return;
}
if (!($this->canBeEmpty && !$this->value)) {
parent::saveInto($record);
}
} | [
"public",
"function",
"saveInto",
"(",
"DataObjectInterface",
"$",
"record",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isSaveable",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"canBeEmpty",
"&&",
"!",
"$",
"t... | Only save if field was shown on the client, and is not empty.
@param DataObjectInterface $record | [
"Only",
"save",
"if",
"field",
"was",
"shown",
"on",
"the",
"client",
"and",
"is",
"not",
"empty",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/ConfirmedPasswordField.php#L557-L566 | train |
silverstripe/silverstripe-framework | src/Forms/ConfirmedPasswordField.php | ConfirmedPasswordField.performReadonlyTransformation | public function performReadonlyTransformation()
{
/** @var ReadonlyField $field */
$field = $this->castedCopy(ReadonlyField::class)
->setTitle($this->title ? $this->title : _t('SilverStripe\\Security\\Member.PASSWORD', 'Password'))
->setValue('*****');
return $field;... | php | public function performReadonlyTransformation()
{
/** @var ReadonlyField $field */
$field = $this->castedCopy(ReadonlyField::class)
->setTitle($this->title ? $this->title : _t('SilverStripe\\Security\\Member.PASSWORD', 'Password'))
->setValue('*****');
return $field;... | [
"public",
"function",
"performReadonlyTransformation",
"(",
")",
"{",
"/** @var ReadonlyField $field */",
"$",
"field",
"=",
"$",
"this",
"->",
"castedCopy",
"(",
"ReadonlyField",
"::",
"class",
")",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"title",
"?",
"$",
... | Makes a read only field with some stars in it to replace the password
@return ReadonlyField | [
"Makes",
"a",
"read",
"only",
"field",
"with",
"some",
"stars",
"in",
"it",
"to",
"replace",
"the",
"password"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/ConfirmedPasswordField.php#L573-L581 | train |
silverstripe/silverstripe-framework | src/Forms/ConfirmedPasswordField.php | ConfirmedPasswordField.setRequireExistingPassword | public function setRequireExistingPassword($show)
{
// Don't modify if already added / removed
if ((bool)$show === $this->requireExistingPassword) {
return $this;
}
$this->requireExistingPassword = $show;
$name = $this->getName();
$currentName = "{$name}[_... | php | public function setRequireExistingPassword($show)
{
// Don't modify if already added / removed
if ((bool)$show === $this->requireExistingPassword) {
return $this;
}
$this->requireExistingPassword = $show;
$name = $this->getName();
$currentName = "{$name}[_... | [
"public",
"function",
"setRequireExistingPassword",
"(",
"$",
"show",
")",
"{",
"// Don't modify if already added / removed",
"if",
"(",
"(",
"bool",
")",
"$",
"show",
"===",
"$",
"this",
"->",
"requireExistingPassword",
")",
"{",
"return",
"$",
"this",
";",
"}"... | Set if the existing password should be required
@param bool $show Flag to show or hide this field
@return $this | [
"Set",
"if",
"the",
"existing",
"password",
"should",
"be",
"required"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/ConfirmedPasswordField.php#L604-L620 | train |
silverstripe/silverstripe-framework | src/Core/Startup/ConfirmationTokenChain.php | ConfirmationTokenChain.filteredTokens | protected function filteredTokens()
{
foreach ($this->tokens as $token) {
if ($token->reloadRequired() || $token->reloadRequiredIfError()) {
yield $token;
}
}
} | php | protected function filteredTokens()
{
foreach ($this->tokens as $token) {
if ($token->reloadRequired() || $token->reloadRequiredIfError()) {
yield $token;
}
}
} | [
"protected",
"function",
"filteredTokens",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"tokens",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"->",
"reloadRequired",
"(",
")",
"||",
"$",
"token",
"->",
"reloadRequiredIfError",
"(",
")",
... | Collect all tokens that require a redirect
@return \Generator | [
"Collect",
"all",
"tokens",
"that",
"require",
"a",
"redirect"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Startup/ConfirmationTokenChain.php#L36-L43 | train |
silverstripe/silverstripe-framework | src/Core/Startup/ConfirmationTokenChain.php | ConfirmationTokenChain.getRedirectUrlParams | public function getRedirectUrlParams()
{
$params = $_GET;
unset($params['url']); // CLIRequestBuilder may add this
foreach ($this->filteredTokens() as $token) {
$params = array_merge($params, $token->params());
}
return $params;
} | php | public function getRedirectUrlParams()
{
$params = $_GET;
unset($params['url']); // CLIRequestBuilder may add this
foreach ($this->filteredTokens() as $token) {
$params = array_merge($params, $token->params());
}
return $params;
} | [
"public",
"function",
"getRedirectUrlParams",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"_GET",
";",
"unset",
"(",
"$",
"params",
"[",
"'url'",
"]",
")",
";",
"// CLIRequestBuilder may add this",
"foreach",
"(",
"$",
"this",
"->",
"filteredTokens",
"(",
")",
... | Collate GET vars from all token providers that need to apply a token
@return array | [
"Collate",
"GET",
"vars",
"from",
"all",
"token",
"providers",
"that",
"need",
"to",
"apply",
"a",
"token"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Startup/ConfirmationTokenChain.php#L140-L149 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayLib.php | ArrayLib.invert | public static function invert($arr)
{
if (!$arr) {
return [];
}
$result = array();
foreach ($arr as $columnName => $column) {
foreach ($column as $rowName => $cell) {
$result[$rowName][$columnName] = $cell;
}
}
re... | php | public static function invert($arr)
{
if (!$arr) {
return [];
}
$result = array();
foreach ($arr as $columnName => $column) {
foreach ($column as $rowName => $cell) {
$result[$rowName][$columnName] = $cell;
}
}
re... | [
"public",
"static",
"function",
"invert",
"(",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"$",
"arr",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"columnName",
"=>",
"$",... | Inverses the first and second level keys of an associative
array, keying the result by the second level, and combines
all first level entries within them.
Before:
<example>
array(
'row1' => array(
'col1' =>'val1',
'col2' => 'val2'
),
'row2' => array(
'col1' => 'val3',
'col2' => 'val4'
)
)
</example>
After:
<example>
... | [
"Inverses",
"the",
"first",
"and",
"second",
"level",
"keys",
"of",
"an",
"associative",
"array",
"keying",
"the",
"result",
"by",
"the",
"second",
"level",
"and",
"combines",
"all",
"first",
"level",
"entries",
"within",
"them",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayLib.php#L49-L64 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayLib.php | ArrayLib.array_map_recursive | public static function array_map_recursive($f, $array)
{
$applyOrRecurse = function ($v) use ($f) {
return is_array($v) ? ArrayLib::array_map_recursive($f, $v) : call_user_func($f, $v);
};
return array_map($applyOrRecurse, $array);
} | php | public static function array_map_recursive($f, $array)
{
$applyOrRecurse = function ($v) use ($f) {
return is_array($v) ? ArrayLib::array_map_recursive($f, $v) : call_user_func($f, $v);
};
return array_map($applyOrRecurse, $array);
} | [
"public",
"static",
"function",
"array_map_recursive",
"(",
"$",
"f",
",",
"$",
"array",
")",
"{",
"$",
"applyOrRecurse",
"=",
"function",
"(",
"$",
"v",
")",
"use",
"(",
"$",
"f",
")",
"{",
"return",
"is_array",
"(",
"$",
"v",
")",
"?",
"ArrayLib",
... | Similar to array_map, but recurses when arrays are encountered.
Actually only one array argument is supported.
@param $f callback to apply
@param $array array
@return array | [
"Similar",
"to",
"array_map",
"but",
"recurses",
"when",
"arrays",
"are",
"encountered",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayLib.php#L167-L174 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayLib.php | ArrayLib.array_merge_recursive | public static function array_merge_recursive($array)
{
$arrays = func_get_args();
$merged = array();
if (count($arrays) == 1) {
return $array;
}
while ($arrays) {
$array = array_shift($arrays);
if (!is_array($array)) {
tr... | php | public static function array_merge_recursive($array)
{
$arrays = func_get_args();
$merged = array();
if (count($arrays) == 1) {
return $array;
}
while ($arrays) {
$array = array_shift($arrays);
if (!is_array($array)) {
tr... | [
"public",
"static",
"function",
"array_merge_recursive",
"(",
"$",
"array",
")",
"{",
"$",
"arrays",
"=",
"func_get_args",
"(",
")",
";",
"$",
"merged",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arrays",
")",
"==",
"1",
")",
"{",
... | Recursively merges two or more arrays.
Behaves similar to array_merge_recursive(), however it only merges
values when both are arrays rather than creating a new array with
both values, as the PHP version does. The same behaviour also occurs
with numeric keys, to match that of what PHP does to generate $_REQUEST.
@par... | [
"Recursively",
"merges",
"two",
"or",
"more",
"arrays",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayLib.php#L188-L222 | train |
silverstripe/silverstripe-framework | src/ORM/ArrayLib.php | ArrayLib.flatten | public static function flatten($array, $preserveKeys = true, &$out = array())
{
array_walk_recursive(
$array,
function ($value, $key) use (&$out, $preserveKeys) {
if (!is_scalar($value)) {
// Do nothing
} elseif ($preserveKeys) {
... | php | public static function flatten($array, $preserveKeys = true, &$out = array())
{
array_walk_recursive(
$array,
function ($value, $key) use (&$out, $preserveKeys) {
if (!is_scalar($value)) {
// Do nothing
} elseif ($preserveKeys) {
... | [
"public",
"static",
"function",
"flatten",
"(",
"$",
"array",
",",
"$",
"preserveKeys",
"=",
"true",
",",
"&",
"$",
"out",
"=",
"array",
"(",
")",
")",
"{",
"array_walk_recursive",
"(",
"$",
"array",
",",
"function",
"(",
"$",
"value",
",",
"$",
"key... | Takes an multi dimension array and returns the flattened version.
@param array $array
@param boolean $preserveKeys
@param array $out
@return array | [
"Takes",
"an",
"multi",
"dimension",
"array",
"and",
"returns",
"the",
"flattened",
"version",
"."
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/ArrayLib.php#L233-L249 | train |
silverstripe/silverstripe-framework | src/Control/RSS/RSSFeed_Entry.php | RSSFeed_Entry.Description | public function Description()
{
$description = $this->rssField($this->descriptionField);
// HTML fields need links re-written
if ($description instanceof DBHTMLText) {
return $description->obj('AbsoluteLinks');
}
return $description;
} | php | public function Description()
{
$description = $this->rssField($this->descriptionField);
// HTML fields need links re-written
if ($description instanceof DBHTMLText) {
return $description->obj('AbsoluteLinks');
}
return $description;
} | [
"public",
"function",
"Description",
"(",
")",
"{",
"$",
"description",
"=",
"$",
"this",
"->",
"rssField",
"(",
"$",
"this",
"->",
"descriptionField",
")",
";",
"// HTML fields need links re-written",
"if",
"(",
"$",
"description",
"instanceof",
"DBHTMLText",
"... | Get the description of this entry
@return DBField Returns the description of the entry. | [
"Get",
"the",
"description",
"of",
"this",
"entry"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/RSS/RSSFeed_Entry.php#L80-L90 | train |
silverstripe/silverstripe-framework | src/Control/RSS/RSSFeed_Entry.php | RSSFeed_Entry.AbsoluteLink | public function AbsoluteLink()
{
if ($this->failover->hasMethod('AbsoluteLink')) {
return $this->failover->AbsoluteLink();
} else {
if ($this->failover->hasMethod('Link')) {
return Director::absoluteURL($this->failover->Link());
}
}
... | php | public function AbsoluteLink()
{
if ($this->failover->hasMethod('AbsoluteLink')) {
return $this->failover->AbsoluteLink();
} else {
if ($this->failover->hasMethod('Link')) {
return Director::absoluteURL($this->failover->Link());
}
}
... | [
"public",
"function",
"AbsoluteLink",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"failover",
"->",
"hasMethod",
"(",
"'AbsoluteLink'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"failover",
"->",
"AbsoluteLink",
"(",
")",
";",
"}",
"else",
"{",
"if"... | Get a link to this entry
@return string Returns the URL of this entry
@throws BadMethodCallException | [
"Get",
"a",
"link",
"to",
"this",
"entry"
] | ed7aaff7da61eefa172fe213ec25e35d2568bc20 | https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/RSS/RSSFeed_Entry.php#L122-L136 | train |
appzcoder/laravel-admin | src/Setting.php | Setting.set | public function set($key, $value)
{
$setting = SettingModel::create(
[
'key' => $key,
'value' => $value,
]
);
return $setting ? $value : false;
} | php | public function set($key, $value)
{
$setting = SettingModel::create(
[
'key' => $key,
'value' => $value,
]
);
return $setting ? $value : false;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"setting",
"=",
"SettingModel",
"::",
"create",
"(",
"[",
"'key'",
"=>",
"$",
"key",
",",
"'value'",
"=>",
"$",
"value",
",",
"]",
")",
";",
"return",
"$",
"setting",
... | Set value against a key.
@param string $key
@param mixed $value
@return mixed | [
"Set",
"value",
"against",
"a",
"key",
"."
] | 70fcbbd82a267b5bbd462e23945dbcf13cab43b2 | https://github.com/appzcoder/laravel-admin/blob/70fcbbd82a267b5bbd462e23945dbcf13cab43b2/src/Setting.php#L18-L28 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.