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
koldy/framework
src/Koldy/Db/Query/Select.php
Select.from
public function from(string $table, string $alias = null, $field = null): Select { $this->from[] = [ 'table' => $table, 'alias' => $alias ]; if ($field !== null) { if (is_array($field)) { foreach ($field as $fld) { $this->field(($alias ?? $table) . '.' . $fld); } } else { $this->field(($alias ?? $table) . '.' . $field); } } return $this; }
php
public function from(string $table, string $alias = null, $field = null): Select { $this->from[] = [ 'table' => $table, 'alias' => $alias ]; if ($field !== null) { if (is_array($field)) { foreach ($field as $fld) { $this->field(($alias ?? $table) . '.' . $fld); } } else { $this->field(($alias ?? $table) . '.' . $field); } } return $this; }
[ "public", "function", "from", "(", "string", "$", "table", ",", "string", "$", "alias", "=", "null", ",", "$", "field", "=", "null", ")", ":", "Select", "{", "$", "this", "->", "from", "[", "]", "=", "[", "'table'", "=>", "$", "table", ",", "'ali...
Set the table FROM which fields will be fetched @param string $table @param string $alias @param mixed $field one field as string or more fields as array or just '*' @return Select
[ "Set", "the", "table", "FROM", "which", "fields", "will", "be", "fetched" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L78-L96
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.innerJoin
public function innerJoin(string $table, $firstTableField, string $operator = null, string $secondTableField = null): Select { $this->joins[] = [ 'type' => 'INNER JOIN', 'table' => $table, 'first' => $firstTableField, 'operator' => $operator, 'second' => $secondTableField ]; return $this; }
php
public function innerJoin(string $table, $firstTableField, string $operator = null, string $secondTableField = null): Select { $this->joins[] = [ 'type' => 'INNER JOIN', 'table' => $table, 'first' => $firstTableField, 'operator' => $operator, 'second' => $secondTableField ]; return $this; }
[ "public", "function", "innerJoin", "(", "string", "$", "table", ",", "$", "firstTableField", ",", "string", "$", "operator", "=", "null", ",", "string", "$", "secondTableField", "=", "null", ")", ":", "Select", "{", "$", "this", "->", "joins", "[", "]", ...
"Inner" join two tables @param string $table @param string|array $firstTableField @param string $operator @param string $secondTableField @return Select @example innerJoin('user u', 'u.id', '=', 'r.user_role_id')
[ "Inner", "join", "two", "tables" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L109-L119
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.field
public function field(string $field, string $as = null): Select { $this->fields[] = [ 'name' => $field, 'as' => $as ]; return $this; }
php
public function field(string $field, string $as = null): Select { $this->fields[] = [ 'name' => $field, 'as' => $as ]; return $this; }
[ "public", "function", "field", "(", "string", "$", "field", ",", "string", "$", "as", "=", "null", ")", ":", "Select", "{", "$", "this", "->", "fields", "[", "]", "=", "[", "'name'", "=>", "$", "field", ",", "'as'", "=>", "$", "as", "]", ";", "...
Add one field that will be fetched @param string $field @param string $as @return Select
[ "Add", "one", "field", "that", "will", "be", "fetched" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L218-L226
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.fields
public function fields(array $fields, string $alias = null): Select { $alias = ($alias === null) ? '' : "{$alias}."; foreach ($fields as $field => $as) { if (is_numeric($field)) { $this->field($alias . $as); } else { $this->field($alias . $field, $as); } } return $this; }
php
public function fields(array $fields, string $alias = null): Select { $alias = ($alias === null) ? '' : "{$alias}."; foreach ($fields as $field => $as) { if (is_numeric($field)) { $this->field($alias . $as); } else { $this->field($alias . $field, $as); } } return $this; }
[ "public", "function", "fields", "(", "array", "$", "fields", ",", "string", "$", "alias", "=", "null", ")", ":", "Select", "{", "$", "alias", "=", "(", "$", "alias", "===", "null", ")", "?", "''", ":", "\"{$alias}.\"", ";", "foreach", "(", "$", "fi...
Add fields to fetch by passing array of fields @param array $fields @param null|string $alias @return Select
[ "Add", "fields", "to", "fetch", "by", "passing", "array", "of", "fields" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L236-L249
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.having
public function having(string $field, string $operator = null, $value = null): Select { $this->having[] = [ 'link' => 'AND', 'field' => $field, 'operator' => $operator, 'value' => $value ]; return $this; }
php
public function having(string $field, string $operator = null, $value = null): Select { $this->having[] = [ 'link' => 'AND', 'field' => $field, 'operator' => $operator, 'value' => $value ]; return $this; }
[ "public", "function", "having", "(", "string", "$", "field", ",", "string", "$", "operator", "=", "null", ",", "$", "value", "=", "null", ")", ":", "Select", "{", "$", "this", "->", "having", "[", "]", "=", "[", "'link'", "=>", "'AND'", ",", "'fiel...
Add HAVING to your SELECT query @param string $field @param string $operator @param mixed $value @return Select
[ "Add", "HAVING", "to", "your", "SELECT", "query" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L304-L313
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.orderBy
public function orderBy(string $field, string $direction = null): Select { if ($direction === null) { $direction = 'ASC'; } else { $direction = strtoupper($direction); } if ($direction !== 'ASC' && $direction !== 'DESC') { throw new Exception("Can not use invalid direction order ({$direction}) in ORDER BY statement"); } $this->orderBy[] = [ 'field' => $field, 'direction' => $direction ]; return $this; }
php
public function orderBy(string $field, string $direction = null): Select { if ($direction === null) { $direction = 'ASC'; } else { $direction = strtoupper($direction); } if ($direction !== 'ASC' && $direction !== 'DESC') { throw new Exception("Can not use invalid direction order ({$direction}) in ORDER BY statement"); } $this->orderBy[] = [ 'field' => $field, 'direction' => $direction ]; return $this; }
[ "public", "function", "orderBy", "(", "string", "$", "field", ",", "string", "$", "direction", "=", "null", ")", ":", "Select", "{", "if", "(", "$", "direction", "===", "null", ")", "{", "$", "direction", "=", "'ASC'", ";", "}", "else", "{", "$", "...
Add field to ORDER BY @param string $field @param string $direction @throws Exception @return Select
[ "Add", "field", "to", "ORDER", "BY" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L354-L371
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.limit
public function limit(int $start, int $howMuch): Select { $this->limit = new \stdClass; $this->limit->start = $start; $this->limit->howMuch = $howMuch; return $this; }
php
public function limit(int $start, int $howMuch): Select { $this->limit = new \stdClass; $this->limit->start = $start; $this->limit->howMuch = $howMuch; return $this; }
[ "public", "function", "limit", "(", "int", "$", "start", ",", "int", "$", "howMuch", ")", ":", "Select", "{", "$", "this", "->", "limit", "=", "new", "\\", "stdClass", ";", "$", "this", "->", "limit", "->", "start", "=", "$", "start", ";", "$", "...
Set the LIMIT on query results @param int $start @param int $howMuch @return Select
[ "Set", "the", "LIMIT", "on", "query", "results" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L391-L397
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.page
public function page(int $number, int $limitPerPage): Select { return $this->limit(($number - 1) * $limitPerPage, $limitPerPage); }
php
public function page(int $number, int $limitPerPage): Select { return $this->limit(($number - 1) * $limitPerPage, $limitPerPage); }
[ "public", "function", "page", "(", "int", "$", "number", ",", "int", "$", "limitPerPage", ")", ":", "Select", "{", "return", "$", "this", "->", "limit", "(", "(", "$", "number", "-", "1", ")", "*", "$", "limitPerPage", ",", "$", "limitPerPage", ")", ...
Limit the results by "page" @param int $number @param int $limitPerPage @return Select
[ "Limit", "the", "results", "by", "page" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L407-L410
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.fetchAll
public function fetchAll(): array { if (!$this->wasExecuted()) { $this->exec(); } return $this->getAdapter()->getStatement()->fetchAll(PDO::FETCH_ASSOC); }
php
public function fetchAll(): array { if (!$this->wasExecuted()) { $this->exec(); } return $this->getAdapter()->getStatement()->fetchAll(PDO::FETCH_ASSOC); }
[ "public", "function", "fetchAll", "(", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "wasExecuted", "(", ")", ")", "{", "$", "this", "->", "exec", "(", ")", ";", "}", "return", "$", "this", "->", "getAdapter", "(", ")", "->", "getSta...
Fetch all records by this query @return array @throws Exception @throws \Koldy\Exception
[ "Fetch", "all", "records", "by", "this", "query" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L576-L583
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.fetchAllGenerator
public function fetchAllGenerator(): Generator { if (!$this->wasExecuted()) { $this->exec(); } $statement = $this->getAdapter()->getStatement(); while ($record = $statement->fetch(PDO::FETCH_ASSOC)) { yield $record; } $statement->closeCursor(); }
php
public function fetchAllGenerator(): Generator { if (!$this->wasExecuted()) { $this->exec(); } $statement = $this->getAdapter()->getStatement(); while ($record = $statement->fetch(PDO::FETCH_ASSOC)) { yield $record; } $statement->closeCursor(); }
[ "public", "function", "fetchAllGenerator", "(", ")", ":", "Generator", "{", "if", "(", "!", "$", "this", "->", "wasExecuted", "(", ")", ")", "{", "$", "this", "->", "exec", "(", ")", ";", "}", "$", "statement", "=", "$", "this", "->", "getAdapter", ...
Fetch all records by getting Generator back @return Generator @throws Exception @throws \Koldy\Exception
[ "Fetch", "all", "records", "by", "getting", "Generator", "back" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L592-L605
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.fetchAllObjGenerator
public function fetchAllObjGenerator(string $class = null): Generator { if (!$this->wasExecuted()) { $this->exec(); } $statement = $this->getAdapter()->getStatement(); if ($class === null) { while ($record = $statement->fetch(PDO::FETCH_OBJ)) { yield $record; } } else { while ($record = $statement->fetch(PDO::FETCH_ASSOC)) { yield new $class($record); } } $statement->closeCursor(); }
php
public function fetchAllObjGenerator(string $class = null): Generator { if (!$this->wasExecuted()) { $this->exec(); } $statement = $this->getAdapter()->getStatement(); if ($class === null) { while ($record = $statement->fetch(PDO::FETCH_OBJ)) { yield $record; } } else { while ($record = $statement->fetch(PDO::FETCH_ASSOC)) { yield new $class($record); } } $statement->closeCursor(); }
[ "public", "function", "fetchAllObjGenerator", "(", "string", "$", "class", "=", "null", ")", ":", "Generator", "{", "if", "(", "!", "$", "this", "->", "wasExecuted", "(", ")", ")", "{", "$", "this", "->", "exec", "(", ")", ";", "}", "$", "statement",...
Fetch all records from the executed SELECT statement and get the Generator back. @param string|null $class the name of class on which you want the instance of - class has to be able to accept array in constructor @return Generator @throws Exception @throws \Koldy\Exception
[ "Fetch", "all", "records", "from", "the", "executed", "SELECT", "statement", "and", "get", "the", "Generator", "back", "." ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L643-L662
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.fetchAllOf
public function fetchAllOf(string $field): array { $array = []; foreach ($this->fetchAllGenerator() as $record) { $array[] = $record[$field] ?? null; } return $array; }
php
public function fetchAllOf(string $field): array { $array = []; foreach ($this->fetchAllGenerator() as $record) { $array[] = $record[$field] ?? null; } return $array; }
[ "public", "function", "fetchAllOf", "(", "string", "$", "field", ")", ":", "array", "{", "$", "array", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "fetchAllGenerator", "(", ")", "as", "$", "record", ")", "{", "$", "array", "[", "]", "=",...
Fetch all records and return array of values from each row from given field name. @param string $field @return array @throws Exception @throws \Koldy\Exception
[ "Fetch", "all", "records", "and", "return", "array", "of", "values", "from", "each", "row", "from", "given", "field", "name", "." ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L673-L681
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.fetchAllOfGenerator
public function fetchAllOfGenerator(string $field): Generator { foreach ($this->fetchAllGenerator() as $index => $record) { yield $index => $record[$field] ?? null; } }
php
public function fetchAllOfGenerator(string $field): Generator { foreach ($this->fetchAllGenerator() as $index => $record) { yield $index => $record[$field] ?? null; } }
[ "public", "function", "fetchAllOfGenerator", "(", "string", "$", "field", ")", ":", "Generator", "{", "foreach", "(", "$", "this", "->", "fetchAllGenerator", "(", ")", "as", "$", "index", "=>", "$", "record", ")", "{", "yield", "$", "index", "=>", "$", ...
Fetch all records and return Generator of values from each row from given field name. @param string $field @return Generator @throws Exception @throws \Koldy\Exception
[ "Fetch", "all", "records", "and", "return", "Generator", "of", "values", "from", "each", "row", "from", "given", "field", "name", "." ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L692-L697
train
koldy/framework
src/Koldy/Db/Query/Select.php
Select.fetchFirst
public function fetchFirst(): ?array { if (!$this->wasExecuted()) { $this->exec(); } $this->resetLimit()->limit(0, 1); $results = $this->fetchAll(); return isset($results[0]) ? $results[0] : null; }
php
public function fetchFirst(): ?array { if (!$this->wasExecuted()) { $this->exec(); } $this->resetLimit()->limit(0, 1); $results = $this->fetchAll(); return isset($results[0]) ? $results[0] : null; }
[ "public", "function", "fetchFirst", "(", ")", ":", "?", "array", "{", "if", "(", "!", "$", "this", "->", "wasExecuted", "(", ")", ")", "{", "$", "this", "->", "exec", "(", ")", ";", "}", "$", "this", "->", "resetLimit", "(", ")", "->", "limit", ...
Fetch only first record as object or return null if there is no records @return array|null @throws Exception @throws \Koldy\Exception
[ "Fetch", "only", "first", "record", "as", "object", "or", "return", "null", "if", "there", "is", "no", "records" ]
73559e7040e13ca583d831c7dde6ae02d2bae8e0
https://github.com/koldy/framework/blob/73559e7040e13ca583d831c7dde6ae02d2bae8e0/src/Koldy/Db/Query/Select.php#L705-L714
train
dewsign/maxfactor-laravel-support
src/Webpage/Traits/HasContent.php
HasContent.getFirst
protected function getFirst(string $key, $default = null) { return collect($this->content->get($key))->first(); }
php
protected function getFirst(string $key, $default = null) { return collect($this->content->get($key))->first(); }
[ "protected", "function", "getFirst", "(", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "collect", "(", "$", "this", "->", "content", "->", "get", "(", "$", "key", ")", ")", "->", "first", "(", ")", ";", "}" ]
Helper to get the first item within a collection @param string $key @param mixed $default @return mixed
[ "Helper", "to", "get", "the", "first", "item", "within", "a", "collection" ]
49ad96edfdd7480a5f50ddea96800d1fe379a2b8
https://github.com/dewsign/maxfactor-laravel-support/blob/49ad96edfdd7480a5f50ddea96800d1fe379a2b8/src/Webpage/Traits/HasContent.php#L184-L187
train
dewsign/maxfactor-laravel-support
src/Webpage/Traits/HasContent.php
HasContent.withFeatured
public function withFeatured(int $count = 1) { if (!$items = $this->get('items')) { $this->append('featured', []); return $this; } $featured = $items->shift(); $this->content['items'] = $items; $this->append('featured', [$featured]); return $this; }
php
public function withFeatured(int $count = 1) { if (!$items = $this->get('items')) { $this->append('featured', []); return $this; } $featured = $items->shift(); $this->content['items'] = $items; $this->append('featured', [$featured]); return $this; }
[ "public", "function", "withFeatured", "(", "int", "$", "count", "=", "1", ")", "{", "if", "(", "!", "$", "items", "=", "$", "this", "->", "get", "(", "'items'", ")", ")", "{", "$", "this", "->", "append", "(", "'featured'", ",", "[", "]", ")", ...
Moves the first X elements into a separate collection item @param int $count @return Model
[ "Moves", "the", "first", "X", "elements", "into", "a", "separate", "collection", "item" ]
49ad96edfdd7480a5f50ddea96800d1fe379a2b8
https://github.com/dewsign/maxfactor-laravel-support/blob/49ad96edfdd7480a5f50ddea96800d1fe379a2b8/src/Webpage/Traits/HasContent.php#L195-L209
train
dewsign/maxfactor-laravel-support
src/Webpage/Traits/HasContent.php
HasContent.take
public function take(int $max = null) { $items = $this->get('items'); if (!isset($max)) { $max = $items->count(); } if ($items->count() >= $max) { $items = $items->take($max); } $this->content['items'] = $items; return $this; }
php
public function take(int $max = null) { $items = $this->get('items'); if (!isset($max)) { $max = $items->count(); } if ($items->count() >= $max) { $items = $items->take($max); } $this->content['items'] = $items; return $this; }
[ "public", "function", "take", "(", "int", "$", "max", "=", "null", ")", "{", "$", "items", "=", "$", "this", "->", "get", "(", "'items'", ")", ";", "if", "(", "!", "isset", "(", "$", "max", ")", ")", "{", "$", "max", "=", "$", "items", "->", ...
Limit the number of items returned @param int $max @return Model
[ "Limit", "the", "number", "of", "items", "returned" ]
49ad96edfdd7480a5f50ddea96800d1fe379a2b8
https://github.com/dewsign/maxfactor-laravel-support/blob/49ad96edfdd7480a5f50ddea96800d1fe379a2b8/src/Webpage/Traits/HasContent.php#L240-L254
train
dewsign/maxfactor-laravel-support
src/Webpage/Traits/HasContent.php
HasContent.append
public function append(string $key, $value) { $this->content->put($key, $value); return $this; }
php
public function append(string $key, $value) { $this->content->put($key, $value); return $this; }
[ "public", "function", "append", "(", "string", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "content", "->", "put", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Add new fields to the content @param string $key @param mixed $value @return Model
[ "Add", "new", "fields", "to", "the", "content" ]
49ad96edfdd7480a5f50ddea96800d1fe379a2b8
https://github.com/dewsign/maxfactor-laravel-support/blob/49ad96edfdd7480a5f50ddea96800d1fe379a2b8/src/Webpage/Traits/HasContent.php#L263-L268
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/FileSelect.php
FileSelect.prepareFileSelector
private function prepareFileSelector(ModelIdInterface $modelId, Ajax $ajax = null) { $inputProvider = $this->itemContainer->getEnvironment()->getInputProvider(); $propertyName = $inputProvider->getParameter('field'); $information = (array) $GLOBALS['TL_DCA'][$modelId->getDataProviderName()]['fields'][$propertyName]; if (!isset($information['eval'])) { $information['eval'] = []; } // Merge with the information from the data container. $property = $this ->itemContainer ->getEnvironment() ->getDataDefinition() ->getPropertiesDefinition() ->getProperty($propertyName); $extra = $property->getExtra(); $information['eval'] = \array_merge($extra, (array) $information['eval']); $this->session->set('filePickerRef', Environment::get('request')); $combat = new DcCompat($this->itemContainer->getEnvironment(), $this->getActiveModel($modelId), $propertyName); /** @var FileSelector $fileSelector */ $fileSelector = new $GLOBALS['BE_FFL']['fileSelector']( Widget::getAttributesFromDca( $information, $propertyName, $this->prepareValuesForFileSelector($propertyName, $modelId, $combat), $propertyName, $modelId->getDataProviderName(), $combat ), $combat ); // AJAX request. if ($ajax) { $ajax->executePostActions($combat); } return $fileSelector; }
php
private function prepareFileSelector(ModelIdInterface $modelId, Ajax $ajax = null) { $inputProvider = $this->itemContainer->getEnvironment()->getInputProvider(); $propertyName = $inputProvider->getParameter('field'); $information = (array) $GLOBALS['TL_DCA'][$modelId->getDataProviderName()]['fields'][$propertyName]; if (!isset($information['eval'])) { $information['eval'] = []; } // Merge with the information from the data container. $property = $this ->itemContainer ->getEnvironment() ->getDataDefinition() ->getPropertiesDefinition() ->getProperty($propertyName); $extra = $property->getExtra(); $information['eval'] = \array_merge($extra, (array) $information['eval']); $this->session->set('filePickerRef', Environment::get('request')); $combat = new DcCompat($this->itemContainer->getEnvironment(), $this->getActiveModel($modelId), $propertyName); /** @var FileSelector $fileSelector */ $fileSelector = new $GLOBALS['BE_FFL']['fileSelector']( Widget::getAttributesFromDca( $information, $propertyName, $this->prepareValuesForFileSelector($propertyName, $modelId, $combat), $propertyName, $modelId->getDataProviderName(), $combat ), $combat ); // AJAX request. if ($ajax) { $ajax->executePostActions($combat); } return $fileSelector; }
[ "private", "function", "prepareFileSelector", "(", "ModelIdInterface", "$", "modelId", ",", "Ajax", "$", "ajax", "=", "null", ")", "{", "$", "inputProvider", "=", "$", "this", "->", "itemContainer", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "...
Prepare the file selector. @param ModelIdInterface $modelId The model identifier. @param Ajax $ajax The ajax request. @return FileSelector @SuppressWarnings(PHPMD.Superglobals)
[ "Prepare", "the", "file", "selector", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/FileSelect.php#L187-L231
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/FileSelect.php
FileSelect.prepareValuesForFileSelector
private function prepareValuesForFileSelector($propertyName, ModelIdInterface $modelId, DcCompat $combat) { $inputProvider = $this->itemContainer->getEnvironment()->getInputProvider(); $fileSelectorValues = []; foreach (\array_filter(\explode(',', $inputProvider->getParameter('value'))) as $k => $v) { // Can be a UUID or a path if (Validator::isStringUuid($v)) { $fileSelectorValues[$k] = StringUtil::uuidToBin($v); } } if (\is_array($GLOBALS['TL_DCA'][$modelId->getDataProviderName()]['fields'][$propertyName]['load_callback'])) { $callbacks = $GLOBALS['TL_DCA'][$modelId->getDataProviderName()]['fields'][$propertyName]['load_callback']; foreach ($callbacks as $callback) { if (\is_array($callback)) { $fileSelectorValues = Callbacks::callArgs($callback, [$fileSelectorValues, $combat]); } elseif (\is_callable($callback)) { $fileSelectorValues = $callback($fileSelectorValues, $combat); } } } return $fileSelectorValues; }
php
private function prepareValuesForFileSelector($propertyName, ModelIdInterface $modelId, DcCompat $combat) { $inputProvider = $this->itemContainer->getEnvironment()->getInputProvider(); $fileSelectorValues = []; foreach (\array_filter(\explode(',', $inputProvider->getParameter('value'))) as $k => $v) { // Can be a UUID or a path if (Validator::isStringUuid($v)) { $fileSelectorValues[$k] = StringUtil::uuidToBin($v); } } if (\is_array($GLOBALS['TL_DCA'][$modelId->getDataProviderName()]['fields'][$propertyName]['load_callback'])) { $callbacks = $GLOBALS['TL_DCA'][$modelId->getDataProviderName()]['fields'][$propertyName]['load_callback']; foreach ($callbacks as $callback) { if (\is_array($callback)) { $fileSelectorValues = Callbacks::callArgs($callback, [$fileSelectorValues, $combat]); } elseif (\is_callable($callback)) { $fileSelectorValues = $callback($fileSelectorValues, $combat); } } } return $fileSelectorValues; }
[ "private", "function", "prepareValuesForFileSelector", "(", "$", "propertyName", ",", "ModelIdInterface", "$", "modelId", ",", "DcCompat", "$", "combat", ")", "{", "$", "inputProvider", "=", "$", "this", "->", "itemContainer", "->", "getEnvironment", "(", ")", "...
Prepare the values for the file selector. @param string $propertyName The property name. @param ModelIdInterface $modelId The model identifier. @param DcCompat $combat The data container compatibility. @return array @SuppressWarnings(PHPMD.Superglobals)
[ "Prepare", "the", "values", "for", "the", "file", "selector", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/FileSelect.php#L244-L269
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/FileSelect.php
FileSelect.setupItemContainer
private function setupItemContainer(ModelIdInterface $modelId) { $dispatcher = $GLOBALS['container']['event-dispatcher']; $translator = new TranslatorChain(); $translator->add(new LangArrayTranslator($dispatcher)); $factory = new DcGeneralFactory(); $this->itemContainer = $factory ->setContainerName($modelId->getDataProviderName()) ->setTranslator($translator) ->setEventDispatcher($dispatcher) ->createDcGeneral(); }
php
private function setupItemContainer(ModelIdInterface $modelId) { $dispatcher = $GLOBALS['container']['event-dispatcher']; $translator = new TranslatorChain(); $translator->add(new LangArrayTranslator($dispatcher)); $factory = new DcGeneralFactory(); $this->itemContainer = $factory ->setContainerName($modelId->getDataProviderName()) ->setTranslator($translator) ->setEventDispatcher($dispatcher) ->createDcGeneral(); }
[ "private", "function", "setupItemContainer", "(", "ModelIdInterface", "$", "modelId", ")", "{", "$", "dispatcher", "=", "$", "GLOBALS", "[", "'container'", "]", "[", "'event-dispatcher'", "]", ";", "$", "translator", "=", "new", "TranslatorChain", "(", ")", ";...
Setup the item container. @param ModelIdInterface $modelId The model identifier. @return void @SuppressWarnings(PHPMD.Superglobals)
[ "Setup", "the", "item", "container", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/FileSelect.php#L280-L293
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/FileSelect.php
FileSelect.runAjaxRequest
private function runAjaxRequest() { // Ajax request. // @codingStandardsIgnoreStart - We need POST access here. if (!($_POST && Environment::get('isAjaxRequest'))) // @codingStandardsIgnoreEnd { return null; } $ajax = new Ajax(Input::post('action')); $ajax->executePreActions(); return $ajax; }
php
private function runAjaxRequest() { // Ajax request. // @codingStandardsIgnoreStart - We need POST access here. if (!($_POST && Environment::get('isAjaxRequest'))) // @codingStandardsIgnoreEnd { return null; } $ajax = new Ajax(Input::post('action')); $ajax->executePreActions(); return $ajax; }
[ "private", "function", "runAjaxRequest", "(", ")", "{", "// Ajax request.", "// @codingStandardsIgnoreStart - We need POST access here.", "if", "(", "!", "(", "$", "_POST", "&&", "Environment", "::", "get", "(", "'isAjaxRequest'", ")", ")", ")", "// @codingStandardsIgno...
Run the ajax request if is determine for run. @SuppressWarnings(PHPMD.Superglobals) @return Ajax|null
[ "Run", "the", "ajax", "request", "if", "is", "determine", "for", "run", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/FileSelect.php#L302-L315
train
contao-community-alliance/dc-general
src/Contao/Callback/ContainerPasteButtonCallbackListener.php
ContainerPasteButtonCallbackListener.update
public function update($event, $value) { if (null === $value) { return; } $event->setHtml($value); $event->stopPropagation(); }
php
public function update($event, $value) { if (null === $value) { return; } $event->setHtml($value); $event->stopPropagation(); }
[ "public", "function", "update", "(", "$", "event", ",", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", ";", "}", "$", "event", "->", "setHtml", "(", "$", "value", ")", ";", "$", "event", "->", "stopPropagation",...
Set the HTML code for the button. @param GetPasteButtonEvent $event The event being emitted. @param string $value The value returned by the callback. @return void
[ "Set", "the", "HTML", "code", "for", "the", "button", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Callback/ContainerPasteButtonCallbackListener.php#L62-L70
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.process
private function process(Action $action, EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $translator = $environment->getTranslator(); $editInformation = $GLOBALS['container']['dc-general.edit-information']; $renderInformation = new \ArrayObject(); $propertyValueBag = new PropertyValueBag(); foreach ($this->getOverrideProperties($action, $environment) as $property) { $propertyValueBag->setPropertyValue($property->getName(), $property->getDefaultValue()); } if (false !== $inputProvider->hasValue('FORM_INPUTS')) { foreach ($inputProvider->getValue('FORM_INPUTS') as $formInput) { $propertyValueBag->setPropertyValue($formInput, $inputProvider->getValue($formInput)); } } $this->invisibleUnusedProperties($action, $environment); $this->handleOverrideCollection($action, $renderInformation, $propertyValueBag, $environment); $this->renderFieldSets($action, $renderInformation, $propertyValueBag, $environment); $this->updateErrorInformation($renderInformation); if (!$editInformation->hasAnyModelError()) { $this->handleSubmit($action, $environment); } return $this->renderTemplate( $action, [ 'subHeadline' => $translator->translate('MSC.' . $inputProvider->getParameter('mode') . 'Selected') . ': ' . $translator->translate('MSC.all.0'), 'fieldsets' => $renderInformation->offsetGet('fieldsets'), 'table' => $environment->getDataDefinition()->getName(), 'error' => $renderInformation->offsetGet('error'), 'breadcrumb' => $this->renderBreadcrumb($environment), 'editButtons' => $this->getEditButtons($action, $environment), 'noReload' => (bool) $editInformation->hasAnyModelError($action, $environment) ] ); }
php
private function process(Action $action, EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $translator = $environment->getTranslator(); $editInformation = $GLOBALS['container']['dc-general.edit-information']; $renderInformation = new \ArrayObject(); $propertyValueBag = new PropertyValueBag(); foreach ($this->getOverrideProperties($action, $environment) as $property) { $propertyValueBag->setPropertyValue($property->getName(), $property->getDefaultValue()); } if (false !== $inputProvider->hasValue('FORM_INPUTS')) { foreach ($inputProvider->getValue('FORM_INPUTS') as $formInput) { $propertyValueBag->setPropertyValue($formInput, $inputProvider->getValue($formInput)); } } $this->invisibleUnusedProperties($action, $environment); $this->handleOverrideCollection($action, $renderInformation, $propertyValueBag, $environment); $this->renderFieldSets($action, $renderInformation, $propertyValueBag, $environment); $this->updateErrorInformation($renderInformation); if (!$editInformation->hasAnyModelError()) { $this->handleSubmit($action, $environment); } return $this->renderTemplate( $action, [ 'subHeadline' => $translator->translate('MSC.' . $inputProvider->getParameter('mode') . 'Selected') . ': ' . $translator->translate('MSC.all.0'), 'fieldsets' => $renderInformation->offsetGet('fieldsets'), 'table' => $environment->getDataDefinition()->getName(), 'error' => $renderInformation->offsetGet('error'), 'breadcrumb' => $this->renderBreadcrumb($environment), 'editButtons' => $this->getEditButtons($action, $environment), 'noReload' => (bool) $editInformation->hasAnyModelError($action, $environment) ] ); }
[ "private", "function", "process", "(", "Action", "$", "action", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "translator", "=", "$", "environment", "->",...
Process the override all handler. @param Action $action The action. @param EnvironmentInterface $environment The enviroment. @return string @SuppressWarnings(PHPMD.Superglobals)
[ "Process", "the", "override", "all", "handler", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L80-L122
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.handleInvalidPropertyValueBag
protected function handleInvalidPropertyValueBag( PropertyValueBagInterface $propertyValueBag = null, ModelInterface $model = null, EnvironmentInterface $environment ) { // @codingStandardsIgnoreStart @\trigger_error('This function where remove in 3.0. ' . __CLASS__ . '::' . __FUNCTION__, E_USER_DEPRECATED); // @codingStandardsIgnoreEnd if ((null === $propertyValueBag) || (null === $model) ) { return; } $inputProvider = $environment->getInputProvider(); foreach (\array_keys($propertyValueBag->getArrayCopy()) as $propertyName) { $allErrors = $propertyValueBag->getPropertyValueErrors($propertyName); $mergedErrors = []; if (\count($allErrors) > 0) { foreach ($allErrors as $error) { if (\in_array($error, $mergedErrors)) { continue; } $mergedErrors[] = $error; } } $eventPropertyValueBag = new PropertyValueBag(); $eventPropertyValueBag->setPropertyValue($propertyName, $inputProvider->getValue($propertyName, true)); $event = new EncodePropertyValueFromWidgetEvent($environment, $model, $eventPropertyValueBag); $event->setProperty($propertyName) ->setValue($inputProvider->getValue($propertyName, true)); $environment->getEventDispatcher()->dispatch(EncodePropertyValueFromWidgetEvent::NAME, $event); $propertyValueBag->setPropertyValue($propertyName, $event->getValue()); if (\count($mergedErrors) > 0) { $propertyValueBag->markPropertyValueAsInvalid($propertyName, $mergedErrors); } } }
php
protected function handleInvalidPropertyValueBag( PropertyValueBagInterface $propertyValueBag = null, ModelInterface $model = null, EnvironmentInterface $environment ) { // @codingStandardsIgnoreStart @\trigger_error('This function where remove in 3.0. ' . __CLASS__ . '::' . __FUNCTION__, E_USER_DEPRECATED); // @codingStandardsIgnoreEnd if ((null === $propertyValueBag) || (null === $model) ) { return; } $inputProvider = $environment->getInputProvider(); foreach (\array_keys($propertyValueBag->getArrayCopy()) as $propertyName) { $allErrors = $propertyValueBag->getPropertyValueErrors($propertyName); $mergedErrors = []; if (\count($allErrors) > 0) { foreach ($allErrors as $error) { if (\in_array($error, $mergedErrors)) { continue; } $mergedErrors[] = $error; } } $eventPropertyValueBag = new PropertyValueBag(); $eventPropertyValueBag->setPropertyValue($propertyName, $inputProvider->getValue($propertyName, true)); $event = new EncodePropertyValueFromWidgetEvent($environment, $model, $eventPropertyValueBag); $event->setProperty($propertyName) ->setValue($inputProvider->getValue($propertyName, true)); $environment->getEventDispatcher()->dispatch(EncodePropertyValueFromWidgetEvent::NAME, $event); $propertyValueBag->setPropertyValue($propertyName, $event->getValue()); if (\count($mergedErrors) > 0) { $propertyValueBag->markPropertyValueAsInvalid($propertyName, $mergedErrors); } } }
[ "protected", "function", "handleInvalidPropertyValueBag", "(", "PropertyValueBagInterface", "$", "propertyValueBag", "=", "null", ",", "ModelInterface", "$", "model", "=", "null", ",", "EnvironmentInterface", "$", "environment", ")", "{", "// @codingStandardsIgnoreStart", ...
Handle invalid property value bag. @param PropertyValueBagInterface|null $propertyValueBag The property value bag. @param ModelInterface|null $model The model. @param EnvironmentInterface $environment The environment. @return void @deprecated Deprecated since 2.1 and where remove in 3.0.
[ "Handle", "invalid", "property", "value", "bag", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L135-L179
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.handleOverrideCollection
private function handleOverrideCollection( Action $action, \ArrayObject $renderInformation, PropertyValueBagInterface $propertyValues = null, EnvironmentInterface $environment ) { if (!$propertyValues) { return; } $revertCollection = $this->getCollectionFromSession($action, $environment); $this->editCollection( $action, $this->getCollectionFromSession($action, $environment), $propertyValues, $renderInformation, $environment ); if ($propertyValues->hasNoInvalidPropertyValues()) { $this->handleSubmit($action, $environment); } $this->revertValuesByErrors($action, $revertCollection, $environment); }
php
private function handleOverrideCollection( Action $action, \ArrayObject $renderInformation, PropertyValueBagInterface $propertyValues = null, EnvironmentInterface $environment ) { if (!$propertyValues) { return; } $revertCollection = $this->getCollectionFromSession($action, $environment); $this->editCollection( $action, $this->getCollectionFromSession($action, $environment), $propertyValues, $renderInformation, $environment ); if ($propertyValues->hasNoInvalidPropertyValues()) { $this->handleSubmit($action, $environment); } $this->revertValuesByErrors($action, $revertCollection, $environment); }
[ "private", "function", "handleOverrideCollection", "(", "Action", "$", "action", ",", "\\", "ArrayObject", "$", "renderInformation", ",", "PropertyValueBagInterface", "$", "propertyValues", "=", "null", ",", "EnvironmentInterface", "$", "environment", ")", "{", "if", ...
Handle override of model collection. @param Action $action The action. @param \ArrayObject $renderInformation The render information. @param PropertyValueBagInterface $propertyValues The property values. @param EnvironmentInterface $environment The environment. @return void
[ "Handle", "override", "of", "model", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L191-L213
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.getOverrideProperties
private function getOverrideProperties(Action $action, EnvironmentInterface $environment) { $selectProperties = $this->getPropertiesFromSession($action, $environment); $properties = []; foreach (\array_keys($selectProperties) as $propertyName) { $properties[$propertyName] = $selectProperties[$propertyName]; } return $properties; }
php
private function getOverrideProperties(Action $action, EnvironmentInterface $environment) { $selectProperties = $this->getPropertiesFromSession($action, $environment); $properties = []; foreach (\array_keys($selectProperties) as $propertyName) { $properties[$propertyName] = $selectProperties[$propertyName]; } return $properties; }
[ "private", "function", "getOverrideProperties", "(", "Action", "$", "action", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "selectProperties", "=", "$", "this", "->", "getPropertiesFromSession", "(", "$", "action", ",", "$", "environment", ")", ...
Return the select properties from the session. @param Action $action The action. @param EnvironmentInterface $environment The environment. @return array
[ "Return", "the", "select", "properties", "from", "the", "session", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L223-L233
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.renderFieldSets
private function renderFieldSets( Action $action, \ArrayObject $renderInformation, PropertyValueBagInterface $propertyValues = null, EnvironmentInterface $environment ) { $properties = $this->getOverrideProperties($action, $environment); $model = $this->getIntersectionModel($action, $environment); $widgetManager = new ContaoWidgetManager($environment, $model); $errors = []; $fieldSet = ['palette' => '', 'class' => 'tl_box']; $propertyNames = $propertyValues ? \array_keys($propertyValues->getArrayCopy()) : \array_keys($properties); foreach ($propertyNames as $propertyName) { $errors = $this->getPropertyValueErrors($propertyValues, $propertyName, $errors); if (false === \array_key_exists($propertyName, $properties)) { continue; } $property = $properties[$propertyName]; $this->setDefaultValue($model, $propertyValues, $propertyName, $environment); $widget = $widgetManager->getWidget($property->getName(), $propertyValues); $widgetModel = $this->getModelFromWidget($widget); if (!$this->ensurePropertyVisibleInModel($action, $property->getName(), $widgetModel, $environment)) { $fieldSet['palette'] .= $this->injectSelectParentPropertyInformation($action, $property, $widgetModel, $environment); continue; } if ($extra = $property->getExtra()) { foreach (['tl_class'] as $extraName) { unset($extra[$extraName]); } $property->setExtra($extra); } $fieldSet['palette'] .= $widgetManager->renderWidget($property->getName(), false, $propertyValues); $fieldSet['palette'] .= $this->injectSelectSubPropertiesInformation( $property, $widgetModel, $propertyValues, $environment ); } if (empty($fieldSet['palette'])) { $fieldSet['palette'] = \sprintf( '<p>&nbsp;</p><strong>%s</strong><p>&nbsp;</p>', $environment->getTranslator()->translate('MSC.no_properties_available') ); } $renderInformation->offsetSet('fieldsets', [$fieldSet]); $renderInformation->offsetSet('error', $errors); }
php
private function renderFieldSets( Action $action, \ArrayObject $renderInformation, PropertyValueBagInterface $propertyValues = null, EnvironmentInterface $environment ) { $properties = $this->getOverrideProperties($action, $environment); $model = $this->getIntersectionModel($action, $environment); $widgetManager = new ContaoWidgetManager($environment, $model); $errors = []; $fieldSet = ['palette' => '', 'class' => 'tl_box']; $propertyNames = $propertyValues ? \array_keys($propertyValues->getArrayCopy()) : \array_keys($properties); foreach ($propertyNames as $propertyName) { $errors = $this->getPropertyValueErrors($propertyValues, $propertyName, $errors); if (false === \array_key_exists($propertyName, $properties)) { continue; } $property = $properties[$propertyName]; $this->setDefaultValue($model, $propertyValues, $propertyName, $environment); $widget = $widgetManager->getWidget($property->getName(), $propertyValues); $widgetModel = $this->getModelFromWidget($widget); if (!$this->ensurePropertyVisibleInModel($action, $property->getName(), $widgetModel, $environment)) { $fieldSet['palette'] .= $this->injectSelectParentPropertyInformation($action, $property, $widgetModel, $environment); continue; } if ($extra = $property->getExtra()) { foreach (['tl_class'] as $extraName) { unset($extra[$extraName]); } $property->setExtra($extra); } $fieldSet['palette'] .= $widgetManager->renderWidget($property->getName(), false, $propertyValues); $fieldSet['palette'] .= $this->injectSelectSubPropertiesInformation( $property, $widgetModel, $propertyValues, $environment ); } if (empty($fieldSet['palette'])) { $fieldSet['palette'] = \sprintf( '<p>&nbsp;</p><strong>%s</strong><p>&nbsp;</p>', $environment->getTranslator()->translate('MSC.no_properties_available') ); } $renderInformation->offsetSet('fieldsets', [$fieldSet]); $renderInformation->offsetSet('error', $errors); }
[ "private", "function", "renderFieldSets", "(", "Action", "$", "action", ",", "\\", "ArrayObject", "$", "renderInformation", ",", "PropertyValueBagInterface", "$", "propertyValues", "=", "null", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "propert...
Render the field sets. @param Action $action The action. @param \ArrayObject $renderInformation The render information. @param PropertyValueBagInterface|null $propertyValues The property values. @param EnvironmentInterface $environment The environment. @return void
[ "Render", "the", "field", "sets", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L245-L310
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.getModelFromWidget
private function getModelFromWidget(Widget $widget) { if ($widget->dataContainer) { return $widget->dataContainer->getModel(); } return $widget->getModel(); }
php
private function getModelFromWidget(Widget $widget) { if ($widget->dataContainer) { return $widget->dataContainer->getModel(); } return $widget->getModel(); }
[ "private", "function", "getModelFromWidget", "(", "Widget", "$", "widget", ")", "{", "if", "(", "$", "widget", "->", "dataContainer", ")", "{", "return", "$", "widget", "->", "dataContainer", "->", "getModel", "(", ")", ";", "}", "return", "$", "widget", ...
Get the model from the widget. @param Widget $widget The widget the contains the model. @return ModelInterface
[ "Get", "the", "model", "from", "the", "widget", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L319-L326
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.getPropertyValueErrors
private function getPropertyValueErrors(PropertyValueBagInterface $propertyValueBag, $propertyName, array $errors) { if ((null !== $propertyValueBag) && $propertyValueBag->hasPropertyValue($propertyName) && $propertyValueBag->isPropertyValueInvalid($propertyName) ) { $errors = \array_merge( $errors, $propertyValueBag->getPropertyValueErrors($propertyName) ); } return $errors; }
php
private function getPropertyValueErrors(PropertyValueBagInterface $propertyValueBag, $propertyName, array $errors) { if ((null !== $propertyValueBag) && $propertyValueBag->hasPropertyValue($propertyName) && $propertyValueBag->isPropertyValueInvalid($propertyName) ) { $errors = \array_merge( $errors, $propertyValueBag->getPropertyValueErrors($propertyName) ); } return $errors; }
[ "private", "function", "getPropertyValueErrors", "(", "PropertyValueBagInterface", "$", "propertyValueBag", ",", "$", "propertyName", ",", "array", "$", "errors", ")", "{", "if", "(", "(", "null", "!==", "$", "propertyValueBag", ")", "&&", "$", "propertyValueBag",...
Get the merged property value errors. @param PropertyValueBagInterface $propertyValueBag The property value bag. @param string $propertyName The property name. @param array $errors The errors. @return array
[ "Get", "the", "merged", "property", "value", "errors", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L337-L350
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php
OverrideAllHandler.setDefaultValue
private function setDefaultValue( ModelInterface $model, PropertyValueBagInterface $propertyValueBag, $propertyName, EnvironmentInterface $environment ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); // If in the intersect model the value available, then set it as default. if ($modelValue = $model->getProperty($propertyName)) { $propertyValueBag->setPropertyValue($propertyName, $modelValue); return; } if ($propertiesDefinition->hasProperty($propertyName) && !$environment->getInputProvider()->hasValue($propertyName) ) { $propertyValueBag->setPropertyValue( $propertyName, $propertiesDefinition->getProperty($propertyName)->getDefaultValue() ); } }
php
private function setDefaultValue( ModelInterface $model, PropertyValueBagInterface $propertyValueBag, $propertyName, EnvironmentInterface $environment ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); // If in the intersect model the value available, then set it as default. if ($modelValue = $model->getProperty($propertyName)) { $propertyValueBag->setPropertyValue($propertyName, $modelValue); return; } if ($propertiesDefinition->hasProperty($propertyName) && !$environment->getInputProvider()->hasValue($propertyName) ) { $propertyValueBag->setPropertyValue( $propertyName, $propertiesDefinition->getProperty($propertyName)->getDefaultValue() ); } }
[ "private", "function", "setDefaultValue", "(", "ModelInterface", "$", "model", ",", "PropertyValueBagInterface", "$", "propertyValueBag", ",", "$", "propertyName", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "propertiesDefinition", "=", "$", "envir...
Set the default value if no value is set. @param ModelInterface $model The model. @param PropertyValueBagInterface $propertyValueBag The property value bag. @param string $propertyName The property name. @param EnvironmentInterface $environment The environment. @return void
[ "Set", "the", "default", "value", "if", "no", "value", "is", "set", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/OverrideAllHandler.php#L362-L385
train
contao-community-alliance/dc-general
src/Controller/TreeCollector.php
TreeCollector.getChildProvidersOf
private function getChildProvidersOf($parentProvider, $relationships = null) { if (null === $relationships) { $relationships = $this->getEnvironment()->getDataDefinition()->getModelRelationshipDefinition(); } $mySubTables = []; foreach ($relationships->getChildConditions($parentProvider) as $condition) { $mySubTables[] = $condition->getDestinationName(); } return $mySubTables; }
php
private function getChildProvidersOf($parentProvider, $relationships = null) { if (null === $relationships) { $relationships = $this->getEnvironment()->getDataDefinition()->getModelRelationshipDefinition(); } $mySubTables = []; foreach ($relationships->getChildConditions($parentProvider) as $condition) { $mySubTables[] = $condition->getDestinationName(); } return $mySubTables; }
[ "private", "function", "getChildProvidersOf", "(", "$", "parentProvider", ",", "$", "relationships", "=", "null", ")", "{", "if", "(", "null", "===", "$", "relationships", ")", "{", "$", "relationships", "=", "$", "this", "->", "getEnvironment", "(", ")", ...
Retrieve the child data provider names for the passed parent provider. @param string $parentProvider The name of the parent provider. @param null|ModelRelationshipDefinitionInterface $relationships The relationship information (optional). @return array
[ "Retrieve", "the", "child", "data", "provider", "names", "for", "the", "passed", "parent", "provider", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/TreeCollector.php#L144-L156
train
contao-community-alliance/dc-general
src/Controller/TreeCollector.php
TreeCollector.addParentFilter
private function addParentFilter(ConfigInterface $config, ModelInterface $parentModel) { $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $basicDefinition = $definition->getBasicDefinition(); if (!$basicDefinition->getParentDataProvider()) { return; } if ($basicDefinition->getParentDataProvider() !== $parentModel->getProviderName()) { throw new \RuntimeException( \sprintf( 'Parent provider mismatch: %s vs. %s', $basicDefinition->getParentDataProvider(), $parentModel->getProviderName() ) ); } // Apply parent filtering, do this only for root elements. if ($parentCondition = $definition->getModelRelationshipDefinition()->getChildCondition( $basicDefinition->getParentDataProvider(), $basicDefinition->getRootDataProvider() )) { $baseFilter = $config->getFilter(); $filter = $parentCondition->getFilter($parentModel); if ($baseFilter) { $filter = \array_merge($baseFilter, $filter); } $config->setFilter($filter); } }
php
private function addParentFilter(ConfigInterface $config, ModelInterface $parentModel) { $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $basicDefinition = $definition->getBasicDefinition(); if (!$basicDefinition->getParentDataProvider()) { return; } if ($basicDefinition->getParentDataProvider() !== $parentModel->getProviderName()) { throw new \RuntimeException( \sprintf( 'Parent provider mismatch: %s vs. %s', $basicDefinition->getParentDataProvider(), $parentModel->getProviderName() ) ); } // Apply parent filtering, do this only for root elements. if ($parentCondition = $definition->getModelRelationshipDefinition()->getChildCondition( $basicDefinition->getParentDataProvider(), $basicDefinition->getRootDataProvider() )) { $baseFilter = $config->getFilter(); $filter = $parentCondition->getFilter($parentModel); if ($baseFilter) { $filter = \array_merge($baseFilter, $filter); } $config->setFilter($filter); } }
[ "private", "function", "addParentFilter", "(", "ConfigInterface", "$", "config", ",", "ModelInterface", "$", "parentModel", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "definition", "=", "$", "environment", "->",...
Add the parent filtering to the given data config if any defined. @param ConfigInterface $config The data config. @param ModelInterface $parentModel The parent model. @return void @throws \RuntimeException When the parent provider does not match.
[ "Add", "the", "parent", "filtering", "to", "the", "given", "data", "config", "if", "any", "defined", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/TreeCollector.php#L264-L298
train
contao-community-alliance/dc-general
src/Controller/TreeCollector.php
TreeCollector.calculateRootConfig
private function calculateRootConfig() { $rootConfig = $this ->getEnvironment() ->getBaseConfigRegistry() ->getBaseConfig() ->setSorting($this->getSorting()); $this->getPanel()->initialize($rootConfig); return $rootConfig; }
php
private function calculateRootConfig() { $rootConfig = $this ->getEnvironment() ->getBaseConfigRegistry() ->getBaseConfig() ->setSorting($this->getSorting()); $this->getPanel()->initialize($rootConfig); return $rootConfig; }
[ "private", "function", "calculateRootConfig", "(", ")", "{", "$", "rootConfig", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getBaseConfigRegistry", "(", ")", "->", "getBaseConfig", "(", ")", "->", "setSorting", "(", "$", "this", "->", "getSort...
Put the base filter and sorting into a config. @return ConfigInterface
[ "Put", "the", "base", "filter", "and", "sorting", "into", "a", "config", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/TreeCollector.php#L305-L315
train
contao-community-alliance/dc-general
src/Controller/TreeCollector.php
TreeCollector.getChildrenOf
public function getChildrenOf($providerName, $level = 0, $parentModel = null) { $environment = $this->getEnvironment(); $dataProvider = $environment->getDataProvider($providerName); $rootConfig = $this->calculateRootConfig(); if ($rootCondition = $environment->getDataDefinition()->getModelRelationshipDefinition()->getRootCondition()) { $baseFilter = $rootConfig->getFilter(); $filter = $rootCondition->getFilterArray(); if ($baseFilter) { $filter = \array_merge($baseFilter, $filter); } $rootConfig->setFilter($filter); } if ($parentModel) { $this->addParentFilter($rootConfig, $parentModel); } $rootCollection = $dataProvider->fetchAll($rootConfig); $tableTreeData = $dataProvider->getEmptyCollection(); if ($rootCollection->length() > 0) { $mySubTables = $this->getChildProvidersOf($providerName); foreach ($rootCollection as $rootModel) { $tableTreeData->push($rootModel); $this->treeWalkModel($rootModel, $level, $mySubTables); } } return $tableTreeData; }
php
public function getChildrenOf($providerName, $level = 0, $parentModel = null) { $environment = $this->getEnvironment(); $dataProvider = $environment->getDataProvider($providerName); $rootConfig = $this->calculateRootConfig(); if ($rootCondition = $environment->getDataDefinition()->getModelRelationshipDefinition()->getRootCondition()) { $baseFilter = $rootConfig->getFilter(); $filter = $rootCondition->getFilterArray(); if ($baseFilter) { $filter = \array_merge($baseFilter, $filter); } $rootConfig->setFilter($filter); } if ($parentModel) { $this->addParentFilter($rootConfig, $parentModel); } $rootCollection = $dataProvider->fetchAll($rootConfig); $tableTreeData = $dataProvider->getEmptyCollection(); if ($rootCollection->length() > 0) { $mySubTables = $this->getChildProvidersOf($providerName); foreach ($rootCollection as $rootModel) { $tableTreeData->push($rootModel); $this->treeWalkModel($rootModel, $level, $mySubTables); } } return $tableTreeData; }
[ "public", "function", "getChildrenOf", "(", "$", "providerName", ",", "$", "level", "=", "0", ",", "$", "parentModel", "=", "null", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "dataProvider", "=", "$", "e...
Collect all items from real root - without root id. @param string $providerName The data provider from which the root element originates from. @param int $level The level in the tree. @param ModelInterface $parentModel The optional parent model (mode 4 parent). @return CollectionInterface
[ "Collect", "all", "items", "from", "real", "root", "-", "without", "root", "id", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/TreeCollector.php#L350-L384
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractHandler.php
AbstractHandler.handleEvent
public function handleEvent(ActionEvent $event) { $this->event = $event; $this->process(); $this->event = null; }
php
public function handleEvent(ActionEvent $event) { $this->event = $event; $this->process(); $this->event = null; }
[ "public", "function", "handleEvent", "(", "ActionEvent", "$", "event", ")", "{", "$", "this", "->", "event", "=", "$", "event", ";", "$", "this", "->", "process", "(", ")", ";", "$", "this", "->", "event", "=", "null", ";", "}" ]
Method to buffer the event and then process it. @param ActionEvent $event The event to process. @return void
[ "Method", "to", "buffer", "the", "event", "and", "then", "process", "it", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractHandler.php#L54-L59
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractHandler.php
AbstractHandler.isEditOnlyResponse
protected function isEditOnlyResponse() { if ($this->getEnvironment()->getDataDefinition()->getBasicDefinition()->isEditOnlyMode()) { $this->callAction('edit'); return true; } return false; }
php
protected function isEditOnlyResponse() { if ($this->getEnvironment()->getDataDefinition()->getBasicDefinition()->isEditOnlyMode()) { $this->callAction('edit'); return true; } return false; }
[ "protected", "function", "isEditOnlyResponse", "(", ")", "{", "if", "(", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", "->", "getBasicDefinition", "(", ")", "->", "isEditOnlyMode", "(", ")", ")", "{", "$", "this", "->"...
Get response from edit action if we are in edit only mode. It returns true if the data definition is in edit only mode. @return bool
[ "Get", "response", "from", "edit", "action", "if", "we", "are", "in", "edit", "only", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractHandler.php#L125-L134
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php
ShowHandler.getModel
protected function getModel(EnvironmentInterface $environment) { $modelId = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id')); $dataProvider = $environment->getDataProvider($modelId->getDataProviderName()); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); if ($model) { return $model; } $eventDispatcher = $environment->getEventDispatcher(); $eventDispatcher->dispatch( ContaoEvents::SYSTEM_LOG, new LogEvent( \sprintf( 'Could not find ID %s in %s. DC_General show()', $modelId->getId(), $environment->getDataDefinition()->getName() ), __CLASS__ . '::' . __FUNCTION__, TL_ERROR ) ); $eventDispatcher->dispatch( ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent('contao?act=error') ); return null; }
php
protected function getModel(EnvironmentInterface $environment) { $modelId = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id')); $dataProvider = $environment->getDataProvider($modelId->getDataProviderName()); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); if ($model) { return $model; } $eventDispatcher = $environment->getEventDispatcher(); $eventDispatcher->dispatch( ContaoEvents::SYSTEM_LOG, new LogEvent( \sprintf( 'Could not find ID %s in %s. DC_General show()', $modelId->getId(), $environment->getDataDefinition()->getName() ), __CLASS__ . '::' . __FUNCTION__, TL_ERROR ) ); $eventDispatcher->dispatch( ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent('contao?act=error') ); return null; }
[ "protected", "function", "getModel", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "modelId", "=", "ModelId", "::", "fromSerialized", "(", "$", "environment", "->", "getInputProvider", "(", ")", "->", "getParameter", "(", "'id'", ")", ")", ";...
Retrieve the model from the database or redirect to error page if model could not be found. @param EnvironmentInterface $environment The environment. @return ModelInterface|null
[ "Retrieve", "the", "model", "from", "the", "database", "or", "redirect", "to", "error", "page", "if", "model", "could", "not", "be", "found", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php#L80-L111
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php
ShowHandler.getPropertyLabel
protected function getPropertyLabel(EnvironmentInterface $environment, PropertyInterface $property) { $translator = $environment->getTranslator(); $label = $translator->translate($property->getLabel(), $environment->getDataDefinition()->getName()); if (!$label) { $label = $translator->translate('MSC.' . $property->getName()); } if (\is_array($label)) { $label = $label[0]; } if (!$label) { $label = $property->getName(); } return $label; }
php
protected function getPropertyLabel(EnvironmentInterface $environment, PropertyInterface $property) { $translator = $environment->getTranslator(); $label = $translator->translate($property->getLabel(), $environment->getDataDefinition()->getName()); if (!$label) { $label = $translator->translate('MSC.' . $property->getName()); } if (\is_array($label)) { $label = $label[0]; } if (!$label) { $label = $property->getName(); } return $label; }
[ "protected", "function", "getPropertyLabel", "(", "EnvironmentInterface", "$", "environment", ",", "PropertyInterface", "$", "property", ")", "{", "$", "translator", "=", "$", "environment", "->", "getTranslator", "(", ")", ";", "$", "label", "=", "$", "translat...
Calculate the label of a property to se in "show" view. @param EnvironmentInterface $environment The environment. @param PropertyInterface $property The property for which the label shall be calculated. @return string
[ "Calculate", "the", "label", "of", "a", "property", "to", "se", "in", "show", "view", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php#L121-L139
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php
ShowHandler.convertModel
protected function convertModel($model, $environment) { $definition = $environment->getDataDefinition(); $properties = $definition->getPropertiesDefinition(); $palette = $definition->getPalettesDefinition()->findPalette($model); $values = []; $labels = []; // Show only allowed fields. foreach ($palette->getVisibleProperties($model) as $paletteProperty) { if (!($property = $properties->getProperty($paletteProperty->getName()))) { throw new DcGeneralRuntimeException('Unable to retrieve property ' . $paletteProperty->getName()); } // Make it human readable. $values[$paletteProperty->getName()] = ViewHelpers::getReadableFieldValue( $environment, $property, $model ); $labels[$paletteProperty->getName()] = $this->getPropertyLabel($environment, $property); } return [ 'labels' => $labels, 'values' => $values ]; }
php
protected function convertModel($model, $environment) { $definition = $environment->getDataDefinition(); $properties = $definition->getPropertiesDefinition(); $palette = $definition->getPalettesDefinition()->findPalette($model); $values = []; $labels = []; // Show only allowed fields. foreach ($palette->getVisibleProperties($model) as $paletteProperty) { if (!($property = $properties->getProperty($paletteProperty->getName()))) { throw new DcGeneralRuntimeException('Unable to retrieve property ' . $paletteProperty->getName()); } // Make it human readable. $values[$paletteProperty->getName()] = ViewHelpers::getReadableFieldValue( $environment, $property, $model ); $labels[$paletteProperty->getName()] = $this->getPropertyLabel($environment, $property); } return [ 'labels' => $labels, 'values' => $values ]; }
[ "protected", "function", "convertModel", "(", "$", "model", ",", "$", "environment", ")", "{", "$", "definition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "properties", "=", "$", "definition", "->", "getPropertiesDefinition", "("...
Convert a model to it's labels and human readable values. @param ModelInterface $model The model to display. @param EnvironmentInterface $environment The environment. @return array @throws DcGeneralRuntimeException When a property could not be retrieved.
[ "Convert", "a", "model", "to", "it", "s", "labels", "and", "human", "readable", "values", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php#L151-L178
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php
ShowHandler.getHeadline
protected function getHeadline(TranslatorInterface $translator, $model) { $headline = $translator->translate( 'MSC.showRecord', $model->getProviderName(), ['ID ' . $model->getId()] ); if ('MSC.showRecord' !== $headline) { return $headline; } return $translator->translate( 'MSC.showRecord', null, ['ID ' . $model->getId()] ); }
php
protected function getHeadline(TranslatorInterface $translator, $model) { $headline = $translator->translate( 'MSC.showRecord', $model->getProviderName(), ['ID ' . $model->getId()] ); if ('MSC.showRecord' !== $headline) { return $headline; } return $translator->translate( 'MSC.showRecord', null, ['ID ' . $model->getId()] ); }
[ "protected", "function", "getHeadline", "(", "TranslatorInterface", "$", "translator", ",", "$", "model", ")", "{", "$", "headline", "=", "$", "translator", "->", "translate", "(", "'MSC.showRecord'", ",", "$", "model", "->", "getProviderName", "(", ")", ",", ...
Get the headline for the template. @param TranslatorInterface $translator The translator. @param ModelInterface $model The model. @return string
[ "Get", "the", "headline", "for", "the", "template", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php#L188-L205
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php
ShowHandler.process
protected function process(Action $action, EnvironmentInterface $environment) { if ($environment->getDataDefinition()->getBasicDefinition()->isEditOnlyMode()) { return $environment->getView()->edit($action); } $modelId = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id')); $dataProvider = $environment->getDataProvider($modelId->getDataProviderName()); $translator = $environment->getTranslator(); $model = $this->getModel($environment); $data = $this->convertModel($model, $environment); $template = (new ContaoBackendViewTemplate('dcbe_general_show')) ->set('headline', $this->getHeadline($translator, $model)) ->set('arrFields', $data['values']) ->set('arrLabels', $data['labels']); if ($dataProvider instanceof MultiLanguageDataProviderInterface) { $template ->set('languages', $environment->getController()->getSupportedLanguages($model->getId())) ->set('currentLanguage', $dataProvider->getCurrentLanguage()) ->set('languageSubmit', $translator->translate('MSC.showSelected')) ->set('backBT', StringUtil::specialchars($translator->translate('MSC.backBT'))); } else { $template->set('languages', null); } return $template->parse(); }
php
protected function process(Action $action, EnvironmentInterface $environment) { if ($environment->getDataDefinition()->getBasicDefinition()->isEditOnlyMode()) { return $environment->getView()->edit($action); } $modelId = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id')); $dataProvider = $environment->getDataProvider($modelId->getDataProviderName()); $translator = $environment->getTranslator(); $model = $this->getModel($environment); $data = $this->convertModel($model, $environment); $template = (new ContaoBackendViewTemplate('dcbe_general_show')) ->set('headline', $this->getHeadline($translator, $model)) ->set('arrFields', $data['values']) ->set('arrLabels', $data['labels']); if ($dataProvider instanceof MultiLanguageDataProviderInterface) { $template ->set('languages', $environment->getController()->getSupportedLanguages($model->getId())) ->set('currentLanguage', $dataProvider->getCurrentLanguage()) ->set('languageSubmit', $translator->translate('MSC.showSelected')) ->set('backBT', StringUtil::specialchars($translator->translate('MSC.backBT'))); } else { $template->set('languages', null); } return $template->parse(); }
[ "protected", "function", "process", "(", "Action", "$", "action", ",", "EnvironmentInterface", "$", "environment", ")", "{", "if", "(", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getBasicDefinition", "(", ")", "->", "isEditOnlyMode", "(", ...
Handle the show event. @param Action $action The action which is handled. @param EnvironmentInterface $environment The environment. @return string
[ "Handle", "the", "show", "event", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php#L215-L243
train
contao-community-alliance/dc-general
src/Data/DefaultConfig.php
DefaultConfig.get
public function get($informationName) { if (isset($this->arrData[$informationName])) { return $this->arrData[$informationName]; } return null; }
php
public function get($informationName) { if (isset($this->arrData[$informationName])) { return $this->arrData[$informationName]; } return null; }
[ "public", "function", "get", "(", "$", "informationName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "arrData", "[", "$", "informationName", "]", ")", ")", "{", "return", "$", "this", "->", "arrData", "[", "$", "informationName", "]", ";", ...
Get the additional information. @param string $informationName The name of the information to retrieve. @return mixed || null
[ "Get", "the", "additional", "information", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultConfig.php#L351-L358
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/CopyHandler.php
CopyHandler.guardIsCreatable
protected function guardIsCreatable(EnvironmentInterface $environment, ModelIdInterface $modelId, $redirect = false) { $dataDefinition = $environment->getDataDefinition(); if ($dataDefinition->getBasicDefinition()->isCreatable()) { return; } if ($redirect) { $eventDispatcher = $environment->getEventDispatcher(); $eventDispatcher->dispatch( ContaoEvents::SYSTEM_LOG, new LogEvent( \sprintf( 'Table "%s" is not creatable, DC_General - DefaultController - copy()', $dataDefinition->getName() ), __CLASS__ . '::delete()', TL_ERROR ) ); $eventDispatcher->dispatch( ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent('contao?act=error') ); } throw new NotCreatableException($modelId->getDataProviderName()); }
php
protected function guardIsCreatable(EnvironmentInterface $environment, ModelIdInterface $modelId, $redirect = false) { $dataDefinition = $environment->getDataDefinition(); if ($dataDefinition->getBasicDefinition()->isCreatable()) { return; } if ($redirect) { $eventDispatcher = $environment->getEventDispatcher(); $eventDispatcher->dispatch( ContaoEvents::SYSTEM_LOG, new LogEvent( \sprintf( 'Table "%s" is not creatable, DC_General - DefaultController - copy()', $dataDefinition->getName() ), __CLASS__ . '::delete()', TL_ERROR ) ); $eventDispatcher->dispatch( ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent('contao?act=error') ); } throw new NotCreatableException($modelId->getDataProviderName()); }
[ "protected", "function", "guardIsCreatable", "(", "EnvironmentInterface", "$", "environment", ",", "ModelIdInterface", "$", "modelId", ",", "$", "redirect", "=", "false", ")", "{", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")"...
Check if is it allowed to create a new record. This is necessary to create the copy. @param EnvironmentInterface $environment The environment. @param ModelIdInterface $modelId The model id. @param bool $redirect If true it redirects to error page instead of throwing an exception. @return void @throws NotCreatableException If deletion is disabled.
[ "Check", "if", "is", "it", "allowed", "to", "create", "a", "new", "record", ".", "This", "is", "necessary", "to", "create", "the", "copy", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/CopyHandler.php#L109-L138
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/CopyHandler.php
CopyHandler.copy
public function copy(EnvironmentInterface $environment, ModelIdInterface $modelId) { $this->guardNotEditOnly($environment->getDataDefinition(), $modelId); $this->guardIsCreatable($environment, $modelId); $dataProvider = $environment->getDataProvider(); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); // We need to keep the original data here. $copyModel = $environment->getController()->createClonedModel($model); $eventDispatcher = $environment->getEventDispatcher(); // Dispatch pre duplicate event. $preCopyEvent = new PreDuplicateModelEvent($environment, $copyModel, $model); $eventDispatcher->dispatch($preCopyEvent::NAME, $preCopyEvent); // Save the copy. $environment->getDataProvider($copyModel->getProviderName())->save($copyModel); // Dispatch post duplicate event. $postCopyEvent = new PostDuplicateModelEvent($environment, $copyModel, $model); $eventDispatcher->dispatch($postCopyEvent::NAME, $postCopyEvent); return $copyModel; }
php
public function copy(EnvironmentInterface $environment, ModelIdInterface $modelId) { $this->guardNotEditOnly($environment->getDataDefinition(), $modelId); $this->guardIsCreatable($environment, $modelId); $dataProvider = $environment->getDataProvider(); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); // We need to keep the original data here. $copyModel = $environment->getController()->createClonedModel($model); $eventDispatcher = $environment->getEventDispatcher(); // Dispatch pre duplicate event. $preCopyEvent = new PreDuplicateModelEvent($environment, $copyModel, $model); $eventDispatcher->dispatch($preCopyEvent::NAME, $preCopyEvent); // Save the copy. $environment->getDataProvider($copyModel->getProviderName())->save($copyModel); // Dispatch post duplicate event. $postCopyEvent = new PostDuplicateModelEvent($environment, $copyModel, $model); $eventDispatcher->dispatch($postCopyEvent::NAME, $postCopyEvent); return $copyModel; }
[ "public", "function", "copy", "(", "EnvironmentInterface", "$", "environment", ",", "ModelIdInterface", "$", "modelId", ")", "{", "$", "this", "->", "guardNotEditOnly", "(", "$", "environment", "->", "getDataDefinition", "(", ")", ",", "$", "modelId", ")", ";"...
Copy a model by using. @param EnvironmentInterface $environment The environment. @param ModelIdInterface $modelId The model id. @return ModelInterface
[ "Copy", "a", "model", "by", "using", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/CopyHandler.php#L148-L172
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/CopyHandler.php
CopyHandler.redirect
protected function redirect($environment, $copiedModelId) { // Build a clean url to remove the copy related arguments instead of using the AddToUrlEvent. $urlBuilder = new UrlBuilder(); $urlBuilder ->setPath('contao') ->setQueryParameter('do', $environment->getInputProvider()->getParameter('do')) ->setQueryParameter('table', $copiedModelId->getDataProviderName()) ->setQueryParameter('act', 'edit') ->setQueryParameter('id', $copiedModelId->getSerialized()) ->setQueryParameter('pid', $environment->getInputProvider()->getParameter('pid')); $securityUrlBuilder = System::getContainer()->get('cca.dc-general.security-url-builder-factory'); $redirectEvent = new RedirectEvent($securityUrlBuilder->create($urlBuilder->getUrl())->getUrl()); $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $redirectEvent); }
php
protected function redirect($environment, $copiedModelId) { // Build a clean url to remove the copy related arguments instead of using the AddToUrlEvent. $urlBuilder = new UrlBuilder(); $urlBuilder ->setPath('contao') ->setQueryParameter('do', $environment->getInputProvider()->getParameter('do')) ->setQueryParameter('table', $copiedModelId->getDataProviderName()) ->setQueryParameter('act', 'edit') ->setQueryParameter('id', $copiedModelId->getSerialized()) ->setQueryParameter('pid', $environment->getInputProvider()->getParameter('pid')); $securityUrlBuilder = System::getContainer()->get('cca.dc-general.security-url-builder-factory'); $redirectEvent = new RedirectEvent($securityUrlBuilder->create($urlBuilder->getUrl())->getUrl()); $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $redirectEvent); }
[ "protected", "function", "redirect", "(", "$", "environment", ",", "$", "copiedModelId", ")", "{", "// Build a clean url to remove the copy related arguments instead of using the AddToUrlEvent.", "$", "urlBuilder", "=", "new", "UrlBuilder", "(", ")", ";", "$", "urlBuilder",...
Redirect to edit mask. @param EnvironmentInterface $environment The environment. @param ModelIdInterface $copiedModelId The model id. @return void
[ "Redirect", "to", "edit", "mask", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/CopyHandler.php#L182-L198
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/DcaReadingDataDefinitionBuilder.php
DcaReadingDataDefinitionBuilder.getFromDca
protected function getFromDca($path) { $chunks = \explode('/', \trim($path, '/')); $dca = $this->dca; while (null !== ($chunk = \array_shift($chunks))) { if (!(\is_array($dca) && \array_key_exists($chunk, $dca))) { return null; } $dca = $dca[$chunk]; } return $dca; }
php
protected function getFromDca($path) { $chunks = \explode('/', \trim($path, '/')); $dca = $this->dca; while (null !== ($chunk = \array_shift($chunks))) { if (!(\is_array($dca) && \array_key_exists($chunk, $dca))) { return null; } $dca = $dca[$chunk]; } return $dca; }
[ "protected", "function", "getFromDca", "(", "$", "path", ")", "{", "$", "chunks", "=", "\\", "explode", "(", "'/'", ",", "\\", "trim", "(", "$", "path", ",", "'/'", ")", ")", ";", "$", "dca", "=", "$", "this", "->", "dca", ";", "while", "(", "n...
Read the specified sub path from the dca. @param string $path The path from the Dca to read. @return mixed
[ "Read", "the", "specified", "sub", "path", "from", "the", "dca", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/DcaReadingDataDefinitionBuilder.php#L72-L86
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.saveTreeNodeStates
protected function saveTreeNodeStates(TreeNodeStates $states) { $sessionStorage = $this->getEnvironment()->getSessionStorage(); $sessionStorage->set($this->getToggleId(), $states->getStates()); }
php
protected function saveTreeNodeStates(TreeNodeStates $states) { $sessionStorage = $this->getEnvironment()->getSessionStorage(); $sessionStorage->set($this->getToggleId(), $states->getStates()); }
[ "protected", "function", "saveTreeNodeStates", "(", "TreeNodeStates", "$", "states", ")", "{", "$", "sessionStorage", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getSessionStorage", "(", ")", ";", "$", "sessionStorage", "->", "set", "(", "$", ...
Save a tree node states instance to the session. @param TreeNodeStates $states The instance to be saved. @return void
[ "Save", "a", "tree", "node", "states", "instance", "to", "the", "session", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L96-L100
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.handleNodeStateChanges
private function handleNodeStateChanges() { $input = $this->getEnvironment()->getInputProvider(); if (($modelId = $input->getParameter('ptg')) && ($providerName = $input->getParameter('provider'))) { $states = $this->getTreeNodeStates(); // Check if the open/close all has been triggered or just a model. if ('all' === $modelId) { if ($states->isAllOpen()) { $states->resetAll(); } $states->setAllOpen($states->isAllOpen()); } else { $this->toggleModel($providerName, $modelId); } ViewHelpers::redirectHome($this->environment); } }
php
private function handleNodeStateChanges() { $input = $this->getEnvironment()->getInputProvider(); if (($modelId = $input->getParameter('ptg')) && ($providerName = $input->getParameter('provider'))) { $states = $this->getTreeNodeStates(); // Check if the open/close all has been triggered or just a model. if ('all' === $modelId) { if ($states->isAllOpen()) { $states->resetAll(); } $states->setAllOpen($states->isAllOpen()); } else { $this->toggleModel($providerName, $modelId); } ViewHelpers::redirectHome($this->environment); } }
[ "private", "function", "handleNodeStateChanges", "(", ")", "{", "$", "input", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "(", ")", ";", "if", "(", "(", "$", "modelId", "=", "$", "input", "->", "getParameter", "(", "'ptg...
Check the get parameters if there is any node toggling. CAUTION: If there has been any action, the browser will get redirected and the script therefore exited. @return void
[ "Check", "the", "get", "parameters", "if", "there", "is", "any", "node", "toggling", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L109-L126
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.generateTreeView
protected function generateTreeView($collection, $treeClass) { $content = []; // Generate buttons - only if not in select mode! if (!$this->isSelectModeActive()) { (new ButtonRenderer($this->environment))->renderButtonsForCollection($collection); } foreach ($collection as $model) { /** @var ModelInterface $model */ $toggleID = $model->getProviderName() . '_' . $treeClass . '_' . $model->getId(); $content[] = $this->parseModel($model, $toggleID); if ($model->getMeta($model::HAS_CHILDREN) && $model->getMeta($model::SHOW_CHILDREN)) { $template = $this->getTemplate('dcbe_general_treeview_child'); $subHtml = ''; foreach ($model->getMeta($model::CHILD_COLLECTIONS) as $childCollection) { $subHtml .= $this->generateTreeView($childCollection, $treeClass); } $this ->addToTemplate('select', $this->isSelectModeActive(), $template) ->addToTemplate('objParentModel', $model, $template) ->addToTemplate('strToggleID', $toggleID, $template) ->addToTemplate('strHTML', $subHtml, $template) ->addToTemplate('strTable', $model->getProviderName(), $template); $content[] = $template->parse(); } } return \implode("\n", $content); }
php
protected function generateTreeView($collection, $treeClass) { $content = []; // Generate buttons - only if not in select mode! if (!$this->isSelectModeActive()) { (new ButtonRenderer($this->environment))->renderButtonsForCollection($collection); } foreach ($collection as $model) { /** @var ModelInterface $model */ $toggleID = $model->getProviderName() . '_' . $treeClass . '_' . $model->getId(); $content[] = $this->parseModel($model, $toggleID); if ($model->getMeta($model::HAS_CHILDREN) && $model->getMeta($model::SHOW_CHILDREN)) { $template = $this->getTemplate('dcbe_general_treeview_child'); $subHtml = ''; foreach ($model->getMeta($model::CHILD_COLLECTIONS) as $childCollection) { $subHtml .= $this->generateTreeView($childCollection, $treeClass); } $this ->addToTemplate('select', $this->isSelectModeActive(), $template) ->addToTemplate('objParentModel', $model, $template) ->addToTemplate('strToggleID', $toggleID, $template) ->addToTemplate('strHTML', $subHtml, $template) ->addToTemplate('strTable', $model->getProviderName(), $template); $content[] = $template->parse(); } } return \implode("\n", $content); }
[ "protected", "function", "generateTreeView", "(", "$", "collection", ",", "$", "treeClass", ")", "{", "$", "content", "=", "[", "]", ";", "// Generate buttons - only if not in select mode!", "if", "(", "!", "$", "this", "->", "isSelectModeActive", "(", ")", ")",...
Render the tree view and return it as string. @param CollectionInterface $collection The collection to iterate over. @param string $treeClass The class to use for the tree. @return string
[ "Render", "the", "tree", "view", "and", "return", "it", "as", "string", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L322-L358
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.renderPasteRootButton
public static function renderPasteRootButton(GetPasteRootButtonEvent $event) { if (null !== $event->getHtml()) { return $event->getHtml(); } $environment = $event->getEnvironment(); $label = $environment->getTranslator()->translate( 'pasteinto.0', $environment->getDataDefinition()->getName() ); if ($event->isPasteDisabled()) { /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $environment->getEventDispatcher()->dispatch( ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent( 'pasteinto_.svg', $label, 'class="blink"' ) ); return $imageEvent->getHtml(); } /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $environment->getEventDispatcher()->dispatch( ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent( 'pasteinto.svg', $label, 'class="blink"' ) ); return \sprintf( ' <a href="%s" title="%s" %s>%s</a>', $event->getHref(), StringUtil::specialchars($label), 'onclick="Backend.getScrollOffset()"', $imageEvent->getHtml() ); }
php
public static function renderPasteRootButton(GetPasteRootButtonEvent $event) { if (null !== $event->getHtml()) { return $event->getHtml(); } $environment = $event->getEnvironment(); $label = $environment->getTranslator()->translate( 'pasteinto.0', $environment->getDataDefinition()->getName() ); if ($event->isPasteDisabled()) { /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $environment->getEventDispatcher()->dispatch( ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent( 'pasteinto_.svg', $label, 'class="blink"' ) ); return $imageEvent->getHtml(); } /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $environment->getEventDispatcher()->dispatch( ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent( 'pasteinto.svg', $label, 'class="blink"' ) ); return \sprintf( ' <a href="%s" title="%s" %s>%s</a>', $event->getHref(), StringUtil::specialchars($label), 'onclick="Backend.getScrollOffset()"', $imageEvent->getHtml() ); }
[ "public", "static", "function", "renderPasteRootButton", "(", "GetPasteRootButtonEvent", "$", "event", ")", "{", "if", "(", "null", "!==", "$", "event", "->", "getHtml", "(", ")", ")", "{", "return", "$", "event", "->", "getHtml", "(", ")", ";", "}", "$"...
Render the paste button for pasting into the root of the tree. @param GetPasteRootButtonEvent $event The event that has been triggered. @return string
[ "Render", "the", "paste", "button", "for", "pasting", "into", "the", "root", "of", "the", "tree", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L367-L408
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.viewTree
protected function viewTree($collection) { $definition = $this->getDataDefinition(); $listing = $this->getViewSection()->getListingConfig(); $basicDefinition = $definition->getBasicDefinition(); $environment = $this->getEnvironment(); $dispatcher = $environment->getEventDispatcher(); // Init some Vars switch (6) { case 6: $treeClass = 'tree_xtnd'; break; default: $treeClass = 'tree'; } // Label + Icon. if (null === $listing->getRootLabel()) { $labelText = 'DC General Tree BackendView Ultimate'; } else { $labelText = $listing->getRootLabel(); } if (null === $listing->getRootIcon()) { $labelIcon = 'pagemounts.svg'; } else { $labelIcon = $listing->getRootIcon(); } $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($parentDataProviderName = $basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($parentDataProviderName); } else { $filter->andHasNoParent(); } // Root paste into. if ($environment->getClipboard()->isNotEmpty($filter)) { /** @var AddToUrlEvent $urlEvent */ $urlEvent = $dispatcher->dispatch( ContaoEvents::BACKEND_ADD_TO_URL, new AddToUrlEvent( \sprintf( 'act=paste&amp;into=%s::0', $definition->getName() ) ) ); $buttonEvent = new GetPasteRootButtonEvent($this->getEnvironment()); $buttonEvent ->setHref($urlEvent->getUrl()) ->setPasteDisabled(false); $dispatcher->dispatch($buttonEvent::NAME, $buttonEvent); $rootPasteInto = static::renderPasteRootButton($buttonEvent); } else { $rootPasteInto = ''; } /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent($labelIcon)); // Build template. $template = $this->getTemplate('dcbe_general_treeview'); $template ->set('treeClass', 'tl_' . $treeClass) ->set('tableName', $definition->getName()) ->set('strLabelIcon', $imageEvent->getHtml()) ->set('strLabelText', $labelText) ->set('strHTML', $this->generateTreeView($collection, $treeClass)) ->set('strRootPasteinto', $rootPasteInto) ->set('select', $this->isSelectModeActive()) ->set('selectButtons', $this->getSelectButtons()) ->set('intMode', 6); $this->formActionForSelect($template); // Add breadcrumb, if we have one. if (null !== ($breadcrumb = $this->breadcrumb())) { $template->set('breadcrumb', $breadcrumb); } return $template->parse(); }
php
protected function viewTree($collection) { $definition = $this->getDataDefinition(); $listing = $this->getViewSection()->getListingConfig(); $basicDefinition = $definition->getBasicDefinition(); $environment = $this->getEnvironment(); $dispatcher = $environment->getEventDispatcher(); // Init some Vars switch (6) { case 6: $treeClass = 'tree_xtnd'; break; default: $treeClass = 'tree'; } // Label + Icon. if (null === $listing->getRootLabel()) { $labelText = 'DC General Tree BackendView Ultimate'; } else { $labelText = $listing->getRootLabel(); } if (null === $listing->getRootIcon()) { $labelIcon = 'pagemounts.svg'; } else { $labelIcon = $listing->getRootIcon(); } $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($parentDataProviderName = $basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($parentDataProviderName); } else { $filter->andHasNoParent(); } // Root paste into. if ($environment->getClipboard()->isNotEmpty($filter)) { /** @var AddToUrlEvent $urlEvent */ $urlEvent = $dispatcher->dispatch( ContaoEvents::BACKEND_ADD_TO_URL, new AddToUrlEvent( \sprintf( 'act=paste&amp;into=%s::0', $definition->getName() ) ) ); $buttonEvent = new GetPasteRootButtonEvent($this->getEnvironment()); $buttonEvent ->setHref($urlEvent->getUrl()) ->setPasteDisabled(false); $dispatcher->dispatch($buttonEvent::NAME, $buttonEvent); $rootPasteInto = static::renderPasteRootButton($buttonEvent); } else { $rootPasteInto = ''; } /** @var GenerateHtmlEvent $imageEvent */ $imageEvent = $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent($labelIcon)); // Build template. $template = $this->getTemplate('dcbe_general_treeview'); $template ->set('treeClass', 'tl_' . $treeClass) ->set('tableName', $definition->getName()) ->set('strLabelIcon', $imageEvent->getHtml()) ->set('strLabelText', $labelText) ->set('strHTML', $this->generateTreeView($collection, $treeClass)) ->set('strRootPasteinto', $rootPasteInto) ->set('select', $this->isSelectModeActive()) ->set('selectButtons', $this->getSelectButtons()) ->set('intMode', 6); $this->formActionForSelect($template); // Add breadcrumb, if we have one. if (null !== ($breadcrumb = $this->breadcrumb())) { $template->set('breadcrumb', $breadcrumb); } return $template->parse(); }
[ "protected", "function", "viewTree", "(", "$", "collection", ")", "{", "$", "definition", "=", "$", "this", "->", "getDataDefinition", "(", ")", ";", "$", "listing", "=", "$", "this", "->", "getViewSection", "(", ")", "->", "getListingConfig", "(", ")", ...
Render the tree view. @param CollectionInterface $collection The collection of items. @return string
[ "Render", "the", "tree", "view", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L417-L505
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.formActionForSelect
protected function formActionForSelect(ContaoBackendViewTemplate $template) { $environment = $this->getEnvironment(); if (!$template->get('select') || ('select' !== $environment->getInputProvider()->getParameter('act')) ) { return; } $actionUrlEvent = new AddToUrlEvent('select=properties'); $environment->getEventDispatcher()->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $actionUrlEvent); $template->set('action', $actionUrlEvent->getUrl()); }
php
protected function formActionForSelect(ContaoBackendViewTemplate $template) { $environment = $this->getEnvironment(); if (!$template->get('select') || ('select' !== $environment->getInputProvider()->getParameter('act')) ) { return; } $actionUrlEvent = new AddToUrlEvent('select=properties'); $environment->getEventDispatcher()->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $actionUrlEvent); $template->set('action', $actionUrlEvent->getUrl()); }
[ "protected", "function", "formActionForSelect", "(", "ContaoBackendViewTemplate", "$", "template", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "if", "(", "!", "$", "template", "->", "get", "(", "'select'", ")", "||"...
Add the form action url for input parameter action is select. @param ContaoBackendViewTemplate $template The template. @return void
[ "Add", "the", "form", "action", "url", "for", "input", "parameter", "action", "is", "select", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L514-L527
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.handleAjaxCall
public function handleAjaxCall() { $input = $this->getEnvironment()->getInputProvider(); if ('DcGeneralLoadSubTree' !== $input->getValue('action')) { parent::handleAjaxCall(); return; } $response = new Response( $this->ajaxTreeView( $input->getValue('id'), $input->getValue('providerName'), $input->getValue('level') ) ); throw new ResponseException($response); }
php
public function handleAjaxCall() { $input = $this->getEnvironment()->getInputProvider(); if ('DcGeneralLoadSubTree' !== $input->getValue('action')) { parent::handleAjaxCall(); return; } $response = new Response( $this->ajaxTreeView( $input->getValue('id'), $input->getValue('providerName'), $input->getValue('level') ) ); throw new ResponseException($response); }
[ "public", "function", "handleAjaxCall", "(", ")", "{", "$", "input", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "(", ")", ";", "if", "(", "'DcGeneralLoadSubTree'", "!==", "$", "input", "->", "getValue", "(", "'action'", "...
Handle an ajax call. @return void @throws ResponseException Throws a response exception. @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName) @SuppressWarnings(PHPMD.ExitExpression)
[ "Handle", "an", "ajax", "call", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L615-L634
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreeView.php
TreeView.ajaxTreeView
public function ajaxTreeView($rootId, $providerName, $level) { $this->toggleModel($providerName, $rootId); $collection = $this->loadCollection($rootId, $level, $providerName); $treeClass = ''; switch (6) { case 5: $treeClass = 'tree'; break; case 6: $treeClass = 'tree_xtnd'; break; default: } return $this->generateTreeView($collection, $treeClass); }
php
public function ajaxTreeView($rootId, $providerName, $level) { $this->toggleModel($providerName, $rootId); $collection = $this->loadCollection($rootId, $level, $providerName); $treeClass = ''; switch (6) { case 5: $treeClass = 'tree'; break; case 6: $treeClass = 'tree_xtnd'; break; default: } return $this->generateTreeView($collection, $treeClass); }
[ "public", "function", "ajaxTreeView", "(", "$", "rootId", ",", "$", "providerName", ",", "$", "level", ")", "{", "$", "this", "->", "toggleModel", "(", "$", "providerName", ",", "$", "rootId", ")", ";", "$", "collection", "=", "$", "this", "->", "loadC...
Handle ajax rendering of a sub tree. @param string $rootId Id of the root node. @param string $providerName Name of the data provider where the model is contained within. @param int $level Level depth of the model in the whole tree. @return string
[ "Handle", "ajax", "rendering", "of", "a", "sub", "tree", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreeView.php#L645-L665
train
contao-community-alliance/dc-general
src/Controller/Ajax3X.php
Ajax3X.getWidget
protected function getWidget($fieldName, $serializedId, $propertyValue) { $environment = $this->getEnvironment(); $property = $environment->getDataDefinition()->getPropertiesDefinition()->getProperty($fieldName); $propertyValues = new PropertyValueBag(); if (null !== $serializedId) { $model = $this->getModelFromSerializedId($serializedId); } else { $dataProvider = $environment->getDataProvider(); $model = $dataProvider->getEmptyModel(); } $widgetManager = new ContaoWidgetManager($environment, $model); // Process input and update changed properties. $treeType = \substr($property->getWidgetType(), 0, 4); $propertyValue = $this->getTreeValue($treeType, $propertyValue); if (('file' === $treeType) || ('page' === $treeType)) { $extra = $property->getExtra(); if (\is_array($propertyValue) && !isset($extra['multiple'])) { $propertyValue = $propertyValue[0]; } else { $propertyValue = \implode(',', (array) $propertyValue); } } $propertyValues->setPropertyValue($fieldName, $propertyValue); $widgetManager->processInput($propertyValues); $model->setProperty($fieldName, $propertyValues->getPropertyValue($fieldName)); return $widgetManager->getWidget($fieldName); }
php
protected function getWidget($fieldName, $serializedId, $propertyValue) { $environment = $this->getEnvironment(); $property = $environment->getDataDefinition()->getPropertiesDefinition()->getProperty($fieldName); $propertyValues = new PropertyValueBag(); if (null !== $serializedId) { $model = $this->getModelFromSerializedId($serializedId); } else { $dataProvider = $environment->getDataProvider(); $model = $dataProvider->getEmptyModel(); } $widgetManager = new ContaoWidgetManager($environment, $model); // Process input and update changed properties. $treeType = \substr($property->getWidgetType(), 0, 4); $propertyValue = $this->getTreeValue($treeType, $propertyValue); if (('file' === $treeType) || ('page' === $treeType)) { $extra = $property->getExtra(); if (\is_array($propertyValue) && !isset($extra['multiple'])) { $propertyValue = $propertyValue[0]; } else { $propertyValue = \implode(',', (array) $propertyValue); } } $propertyValues->setPropertyValue($fieldName, $propertyValue); $widgetManager->processInput($propertyValues); $model->setProperty($fieldName, $propertyValues->getPropertyValue($fieldName)); return $widgetManager->getWidget($fieldName); }
[ "protected", "function", "getWidget", "(", "$", "fieldName", ",", "$", "serializedId", ",", "$", "propertyValue", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "property", "=", "$", "environment", "->", "getDat...
Get the widget instance. @param string $fieldName The property name. @param string $serializedId The serialized id of the model. @param string $propertyValue The property value. @return Widget
[ "Get", "the", "widget", "instance", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/Ajax3X.php#L54-L86
train
contao-community-alliance/dc-general
src/Controller/Ajax3X.php
Ajax3X.getTreeValue
protected function getTreeValue($type, $value) { // Convert the selected values. if ('' !== $value) { $value = StringUtil::trimsplit("\t", $value); // Automatically add resources to the DBAFS. if ('file' === $type) { foreach ($value as $k => $v) { $value[$k] = StringUtil::binToUuid(Dbafs::addResource(\urldecode($v))->uuid); } } } return $value; }
php
protected function getTreeValue($type, $value) { // Convert the selected values. if ('' !== $value) { $value = StringUtil::trimsplit("\t", $value); // Automatically add resources to the DBAFS. if ('file' === $type) { foreach ($value as $k => $v) { $value[$k] = StringUtil::binToUuid(Dbafs::addResource(\urldecode($v))->uuid); } } } return $value; }
[ "protected", "function", "getTreeValue", "(", "$", "type", ",", "$", "value", ")", "{", "// Convert the selected values.", "if", "(", "''", "!==", "$", "value", ")", "{", "$", "value", "=", "StringUtil", "::", "trimsplit", "(", "\"\\t\"", ",", "$", "value"...
Retrieve the value as serialized array. If the type is "file", the file names will automatically be added to the Dbafs and converted to file id. @param string $type Either "page" or "file". @param string $value The value as comma separated list. @return string The value array.
[ "Retrieve", "the", "value", "as", "serialized", "array", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/Ajax3X.php#L180-L195
train
contao-community-alliance/dc-general
src/Controller/Ajax3X.php
Ajax3X.getModelFromSerializedId
protected function getModelFromSerializedId($serializedId) { $modelId = ModelId::fromSerialized($serializedId); $dataProvider = $this->getEnvironment()->getDataProvider($modelId->getDataProviderName()); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); if (null === $model) { $event = new LogEvent( 'A record with the ID "' . $serializedId . '" does not exist in "' . $this->getEnvironment()->getDataDefinition()->getName() . '"', 'Ajax executePostActions()', TL_ERROR ); $this->getEnvironment()->getEventDispatcher()->dispatch(ContaoEvents::SYSTEM_LOG, $event); throw new ResponseException(new Response(Response::$statusTexts[400], 400)); } return $model; }
php
protected function getModelFromSerializedId($serializedId) { $modelId = ModelId::fromSerialized($serializedId); $dataProvider = $this->getEnvironment()->getDataProvider($modelId->getDataProviderName()); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); if (null === $model) { $event = new LogEvent( 'A record with the ID "' . $serializedId . '" does not exist in "' . $this->getEnvironment()->getDataDefinition()->getName() . '"', 'Ajax executePostActions()', TL_ERROR ); $this->getEnvironment()->getEventDispatcher()->dispatch(ContaoEvents::SYSTEM_LOG, $event); throw new ResponseException(new Response(Response::$statusTexts[400], 400)); } return $model; }
[ "protected", "function", "getModelFromSerializedId", "(", "$", "serializedId", ")", "{", "$", "modelId", "=", "ModelId", "::", "fromSerialized", "(", "$", "serializedId", ")", ";", "$", "dataProvider", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", ...
Retrieve a model from a serialized id. Exits the script if no model has been found. @param string $serializedId The serialized id. @return ModelInterface @throws ResponseException Throws a response exception.
[ "Retrieve", "a", "model", "from", "a", "serialized", "id", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/Ajax3X.php#L208-L227
train
contao-community-alliance/dc-general
src/Controller/Ajax3X.php
Ajax3X.reloadTree
protected function reloadTree() { $input = $this->getEnvironment()->getInputProvider(); $serializedId = ($input->hasParameter('id') && $input->getParameter('id')) ? $input->getParameter('id') : null; $value = $input->hasValue('value') ? $input->getValue('value', true) : null; $this->generateWidget($this->getWidget($this->getFieldName(), $serializedId, $value)); throw new ResponseException(new Response('')); }
php
protected function reloadTree() { $input = $this->getEnvironment()->getInputProvider(); $serializedId = ($input->hasParameter('id') && $input->getParameter('id')) ? $input->getParameter('id') : null; $value = $input->hasValue('value') ? $input->getValue('value', true) : null; $this->generateWidget($this->getWidget($this->getFieldName(), $serializedId, $value)); throw new ResponseException(new Response('')); }
[ "protected", "function", "reloadTree", "(", ")", "{", "$", "input", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "(", ")", ";", "$", "serializedId", "=", "(", "$", "input", "->", "hasParameter", "(", "'id'", ")", "&&", ...
Reload the file tree. @return void @throws ResponseException Throws a response exception.
[ "Reload", "the", "file", "tree", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/Ajax3X.php#L236-L245
train
contao-community-alliance/dc-general
src/Controller/Ajax3X.php
Ajax3X.getFieldName
private function getFieldName() { $environment = $this->getEnvironment(); $inputProvider = $environment->getInputProvider(); $fieldName = $inputProvider->hasValue('name') ? $inputProvider->getValue('name') : null; if (null === $fieldName) { return $fieldName; } if (('select' !== $inputProvider->getParameter('act')) && ('edit' !== $inputProvider->getParameter('mode')) ) { return $fieldName; } $dataDefinition = $environment->getDataDefinition(); $sessionStorage = $environment->getSessionStorage(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('select')); $originalPropertyName = null; foreach ($session['models'] as $modelId) { if (null !== $originalPropertyName) { break; } $propertyNamePrefix = \str_replace('::', '____', $modelId) . '_'; if (0 !== strpos($fieldName, $propertyNamePrefix)) { continue; } $originalPropertyName = \substr($fieldName, \strlen($propertyNamePrefix)); } if (!$originalPropertyName) { return $fieldName; } return $originalPropertyName; }
php
private function getFieldName() { $environment = $this->getEnvironment(); $inputProvider = $environment->getInputProvider(); $fieldName = $inputProvider->hasValue('name') ? $inputProvider->getValue('name') : null; if (null === $fieldName) { return $fieldName; } if (('select' !== $inputProvider->getParameter('act')) && ('edit' !== $inputProvider->getParameter('mode')) ) { return $fieldName; } $dataDefinition = $environment->getDataDefinition(); $sessionStorage = $environment->getSessionStorage(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('select')); $originalPropertyName = null; foreach ($session['models'] as $modelId) { if (null !== $originalPropertyName) { break; } $propertyNamePrefix = \str_replace('::', '____', $modelId) . '_'; if (0 !== strpos($fieldName, $propertyNamePrefix)) { continue; } $originalPropertyName = \substr($fieldName, \strlen($propertyNamePrefix)); } if (!$originalPropertyName) { return $fieldName; } return $originalPropertyName; }
[ "private", "function", "getFieldName", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "fieldName", "=", "$", "inputPro...
Get the field name. @return null|string
[ "Get", "the", "field", "name", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/Ajax3X.php#L286-L326
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.assembleChildrenFor
protected function assembleChildrenFor(ModelInterface $model, $sortingProperty = null) { $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $provider = $environment->getDataProvider($model->getProviderName()); $config = $environment->getBaseConfigRegistry()->getBaseConfig(); $relationships = $definition->getModelRelationshipDefinition(); if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $definition->getBasicDefinition()->getMode()) { throw new DcGeneralRuntimeException('Unable to retrieve children in non hierarchical mode.'); } $condition = $relationships->getChildCondition($model->getProviderName(), $model->getProviderName()); $config->setFilter($condition->getFilter($model)); if ($sortingProperty) { $config->setSorting([(string) $sortingProperty => 'ASC']); } return $provider->fetchAll($config); }
php
protected function assembleChildrenFor(ModelInterface $model, $sortingProperty = null) { $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $provider = $environment->getDataProvider($model->getProviderName()); $config = $environment->getBaseConfigRegistry()->getBaseConfig(); $relationships = $definition->getModelRelationshipDefinition(); if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $definition->getBasicDefinition()->getMode()) { throw new DcGeneralRuntimeException('Unable to retrieve children in non hierarchical mode.'); } $condition = $relationships->getChildCondition($model->getProviderName(), $model->getProviderName()); $config->setFilter($condition->getFilter($model)); if ($sortingProperty) { $config->setSorting([(string) $sortingProperty => 'ASC']); } return $provider->fetchAll($config); }
[ "protected", "function", "assembleChildrenFor", "(", "ModelInterface", "$", "model", ",", "$", "sortingProperty", "=", "null", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "definition", "=", "$", "environment", ...
Retrieve children of a given model. @param ModelInterface $model The model for which the children shall be retrieved. @param string|null $sortingProperty The property name to use for sorting. @return CollectionInterface @throws DcGeneralRuntimeException When not in hierarchical mode.
[ "Retrieve", "children", "of", "a", "given", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L262-L282
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.getSupportedLanguages
public function getSupportedLanguages($currentID) { $environment = $this->getEnvironment(); $dataProvider = $environment->getDataProvider(); // Check if current data provider supports multi language. if ($dataProvider instanceof MultiLanguageDataProviderInterface) { $supportedLanguages = $dataProvider->getLanguages($currentID); } else { $supportedLanguages = null; } // Check if we have some languages. if (null === $supportedLanguages) { return []; } $translator = $environment->getTranslator(); // Make an array from the collection. $languages = []; foreach ($supportedLanguages as $value) { /** @var LanguageInformationInterface $value */ $locale = $value->getLocale(); $languages[$locale] = $translator->translate('LNG.' . $locale, 'languages'); } return $languages; }
php
public function getSupportedLanguages($currentID) { $environment = $this->getEnvironment(); $dataProvider = $environment->getDataProvider(); // Check if current data provider supports multi language. if ($dataProvider instanceof MultiLanguageDataProviderInterface) { $supportedLanguages = $dataProvider->getLanguages($currentID); } else { $supportedLanguages = null; } // Check if we have some languages. if (null === $supportedLanguages) { return []; } $translator = $environment->getTranslator(); // Make an array from the collection. $languages = []; foreach ($supportedLanguages as $value) { /** @var LanguageInformationInterface $value */ $locale = $value->getLocale(); $languages[$locale] = $translator->translate('LNG.' . $locale, 'languages'); } return $languages; }
[ "public", "function", "getSupportedLanguages", "(", "$", "currentID", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "dataProvider", "=", "$", "environment", "->", "getDataProvider", "(", ")", ";", "// Check if curr...
Return all supported languages from the default data data provider. @param mixed $currentID The id of the item for which to retrieve the valid languages. @return array
[ "Return", "all", "supported", "languages", "from", "the", "default", "data", "data", "provider", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L307-L336
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.handleClonedModelProperty
private function handleClonedModelProperty( ModelInterface $model, PropertyInterface $property, DataProviderInterface $dataProvider ) { $extra = $property->getExtra(); $propName = $property->getName(); // Check doNotCopy. if (isset($extra['doNotCopy']) && (true === $extra['doNotCopy'])) { $model->setProperty($propName, null); return; } // Check uniqueness. if (isset($extra['unique']) && (true === $extra['unique']) && !$dataProvider->isUniqueValue($propName, $model->getProperty($propName)) ) { // Implicit "do not copy" unique values, they cannot be unique anymore. $model->setProperty($propName, null); } }
php
private function handleClonedModelProperty( ModelInterface $model, PropertyInterface $property, DataProviderInterface $dataProvider ) { $extra = $property->getExtra(); $propName = $property->getName(); // Check doNotCopy. if (isset($extra['doNotCopy']) && (true === $extra['doNotCopy'])) { $model->setProperty($propName, null); return; } // Check uniqueness. if (isset($extra['unique']) && (true === $extra['unique']) && !$dataProvider->isUniqueValue($propName, $model->getProperty($propName)) ) { // Implicit "do not copy" unique values, they cannot be unique anymore. $model->setProperty($propName, null); } }
[ "private", "function", "handleClonedModelProperty", "(", "ModelInterface", "$", "model", ",", "PropertyInterface", "$", "property", ",", "DataProviderInterface", "$", "dataProvider", ")", "{", "$", "extra", "=", "$", "property", "->", "getExtra", "(", ")", ";", ...
Handle a property in a cloned model. @param ModelInterface $model The cloned model. @param PropertyInterface $property The property to handle. @param DataProviderInterface $dataProvider The data provider the model originates from. @return void
[ "Handle", "a", "property", "in", "a", "cloned", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L347-L369
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.getActionsFromSource
private function getActionsFromSource(ModelIdInterface $source, ModelIdInterface $parentModelId = null) { $basicDefinition = $this->getEnvironment()->getDataDefinition()->getBasicDefinition(); $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($basicDefinition->getParentDataProvider()); } else { $filter->andHasNoParent(); } $filter->andModelIs($source); $item = $this->getEnvironment()->getClipboard()->fetch($filter)[0]; $action = $item ? $item->getAction() : ItemInterface::CUT; $model = $this->modelCollector->getModel($source); $actions = [ [ 'model' => $model, 'item' => new Item($action, $parentModelId, ModelId::fromModel($model)) ] ]; return $actions; }
php
private function getActionsFromSource(ModelIdInterface $source, ModelIdInterface $parentModelId = null) { $basicDefinition = $this->getEnvironment()->getDataDefinition()->getBasicDefinition(); $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($basicDefinition->getParentDataProvider()); } else { $filter->andHasNoParent(); } $filter->andModelIs($source); $item = $this->getEnvironment()->getClipboard()->fetch($filter)[0]; $action = $item ? $item->getAction() : ItemInterface::CUT; $model = $this->modelCollector->getModel($source); $actions = [ [ 'model' => $model, 'item' => new Item($action, $parentModelId, ModelId::fromModel($model)) ] ]; return $actions; }
[ "private", "function", "getActionsFromSource", "(", "ModelIdInterface", "$", "source", ",", "ModelIdInterface", "$", "parentModelId", "=", "null", ")", "{", "$", "basicDefinition", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(",...
Fetch actions from source. @param ModelIdInterface $source The source id. @param ModelIdInterface|null $parentModelId The parent id. @return array @throws \InvalidArgumentException When the model id is invalid.
[ "Fetch", "actions", "from", "source", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L532-L556
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.fetchModelsFromClipboard
private function fetchModelsFromClipboard(FilterInterface $filter = null, ModelIdInterface $parentModelId = null) { $environment = $this->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); if (!$filter) { $filter = new Filter(); } $basicDefinition = $dataDefinition->getBasicDefinition(); $modelProviderName = $basicDefinition->getDataProvider(); $filter->andModelIsFromProvider($modelProviderName); if ($parentModelId) { $filter->andParentIsFromProvider($parentModelId->getDataProviderName()); } else { $filter->andHasNoParent(); } $environment = $this->getEnvironment(); $clipboard = $environment->getClipboard(); $items = $clipboard->fetch($filter); $actions = []; foreach ($items as $item) { $model = null; if (!$item->isCreate() && $item->getModelId()) { $model = $this->modelCollector->getModel($item->getModelId()->getId(), $item->getDataProviderName()); } $actions[] = [ 'model' => $model, 'item' => $item, ]; } return $actions; }
php
private function fetchModelsFromClipboard(FilterInterface $filter = null, ModelIdInterface $parentModelId = null) { $environment = $this->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); if (!$filter) { $filter = new Filter(); } $basicDefinition = $dataDefinition->getBasicDefinition(); $modelProviderName = $basicDefinition->getDataProvider(); $filter->andModelIsFromProvider($modelProviderName); if ($parentModelId) { $filter->andParentIsFromProvider($parentModelId->getDataProviderName()); } else { $filter->andHasNoParent(); } $environment = $this->getEnvironment(); $clipboard = $environment->getClipboard(); $items = $clipboard->fetch($filter); $actions = []; foreach ($items as $item) { $model = null; if (!$item->isCreate() && $item->getModelId()) { $model = $this->modelCollector->getModel($item->getModelId()->getId(), $item->getDataProviderName()); } $actions[] = [ 'model' => $model, 'item' => $item, ]; } return $actions; }
[ "private", "function", "fetchModelsFromClipboard", "(", "FilterInterface", "$", "filter", "=", "null", ",", "ModelIdInterface", "$", "parentModelId", "=", "null", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "data...
Fetch actions from the clipboard. @param FilterInterface|null $filter The clipboard filter. @param ModelIdInterface $parentModelId The parent id. @return array
[ "Fetch", "actions", "from", "the", "clipboard", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L566-L603
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.doActions
private function doActions( array $actions, ModelIdInterface $after = null, ModelIdInterface $into = null, ModelIdInterface $parentModelId = null, array &$items = [] ) { if ($parentModelId) { $parentModel = $this->modelCollector->getModel($parentModelId); } else { $parentModel = null; } // Holds models, that need deep-copy $deepCopyList = []; // Apply create and copy actions foreach ($actions as &$action) { $this->applyAction($action, $deepCopyList, $parentModel); } unset($action); // When pasting after another model, apply same grouping information $this->ensureSameGrouping($actions, $after); // Now apply sorting and persist all models $models = $this->sortAndPersistModels($actions, $after, $into, $parentModelId, $items); // At least, go ahead with the deep copy $this->doDeepCopy($deepCopyList); return $models; }
php
private function doActions( array $actions, ModelIdInterface $after = null, ModelIdInterface $into = null, ModelIdInterface $parentModelId = null, array &$items = [] ) { if ($parentModelId) { $parentModel = $this->modelCollector->getModel($parentModelId); } else { $parentModel = null; } // Holds models, that need deep-copy $deepCopyList = []; // Apply create and copy actions foreach ($actions as &$action) { $this->applyAction($action, $deepCopyList, $parentModel); } unset($action); // When pasting after another model, apply same grouping information $this->ensureSameGrouping($actions, $after); // Now apply sorting and persist all models $models = $this->sortAndPersistModels($actions, $after, $into, $parentModelId, $items); // At least, go ahead with the deep copy $this->doDeepCopy($deepCopyList); return $models; }
[ "private", "function", "doActions", "(", "array", "$", "actions", ",", "ModelIdInterface", "$", "after", "=", "null", ",", "ModelIdInterface", "$", "into", "=", "null", ",", "ModelIdInterface", "$", "parentModelId", "=", "null", ",", "array", "&", "$", "item...
Effectively do the actions. @param array $actions The actions collection. @param ModelIdInterface $after The previous model id. @param ModelIdInterface $into The hierarchical parent model id. @param ModelIdInterface $parentModelId The parent model id. @param array $items Write-back clipboard items. @return CollectionInterface
[ "Effectively", "do", "the", "actions", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L616-L648
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.applyAction
private function applyAction(array &$action, array &$deepCopyList, ModelInterface $parentModel = null) { /** @var ModelInterface|null $model */ $model = $action['model']; /** @var ItemInterface $item */ $item = $action['item']; if ($item->isCreate()) { // create new model $model = $this->createEmptyModelWithDefaults(); } elseif ($item->isCopy() || $isDeepCopy = $item->isDeepCopy()) { // copy model $model = $this->modelCollector->getModel(ModelId::fromModel($model)); $clonedModel = $this->doCloneAction($model); if (isset($isDeepCopy) && $isDeepCopy) { $deepCopyList[] = [ 'origin' => $model, 'model' => $clonedModel, ]; } $model = $clonedModel; } if (!$model) { throw new \UnexpectedValueException( 'Invalid clipboard action entry, no model created. ' . $item->getAction() ); } if ($parentModel) { $this->relationshipManager->setParent($model, $parentModel); } $action['model'] = $model; }
php
private function applyAction(array &$action, array &$deepCopyList, ModelInterface $parentModel = null) { /** @var ModelInterface|null $model */ $model = $action['model']; /** @var ItemInterface $item */ $item = $action['item']; if ($item->isCreate()) { // create new model $model = $this->createEmptyModelWithDefaults(); } elseif ($item->isCopy() || $isDeepCopy = $item->isDeepCopy()) { // copy model $model = $this->modelCollector->getModel(ModelId::fromModel($model)); $clonedModel = $this->doCloneAction($model); if (isset($isDeepCopy) && $isDeepCopy) { $deepCopyList[] = [ 'origin' => $model, 'model' => $clonedModel, ]; } $model = $clonedModel; } if (!$model) { throw new \UnexpectedValueException( 'Invalid clipboard action entry, no model created. ' . $item->getAction() ); } if ($parentModel) { $this->relationshipManager->setParent($model, $parentModel); } $action['model'] = $model; }
[ "private", "function", "applyAction", "(", "array", "&", "$", "action", ",", "array", "&", "$", "deepCopyList", ",", "ModelInterface", "$", "parentModel", "=", "null", ")", "{", "/** @var ModelInterface|null $model */", "$", "model", "=", "$", "action", "[", "...
Apply the action onto the model. This will create or clone the model in the action. @param array $action The action, containing a model and an item. @param array $deepCopyList A list of models that need deep copy. @param ModelInterface $parentModel The parent model. @return void @throws \UnexpectedValueException When the action is neither create, copy or deep copy.
[ "Apply", "the", "action", "onto", "the", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L663-L699
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.doCloneAction
private function doCloneAction(ModelInterface $model) { $environment = $this->getEnvironment(); // Make a duplicate. $clonedModel = $this->createClonedModel($model); // Trigger the pre duplicate event. $duplicateEvent = new PreDuplicateModelEvent($environment, $clonedModel, $model); $environment->getEventDispatcher()->dispatch($duplicateEvent::NAME, $duplicateEvent); // And trigger the post event for it. $duplicateEvent = new PostDuplicateModelEvent($environment, $clonedModel, $model); $environment->getEventDispatcher()->dispatch($duplicateEvent::NAME, $duplicateEvent); return $clonedModel; }
php
private function doCloneAction(ModelInterface $model) { $environment = $this->getEnvironment(); // Make a duplicate. $clonedModel = $this->createClonedModel($model); // Trigger the pre duplicate event. $duplicateEvent = new PreDuplicateModelEvent($environment, $clonedModel, $model); $environment->getEventDispatcher()->dispatch($duplicateEvent::NAME, $duplicateEvent); // And trigger the post event for it. $duplicateEvent = new PostDuplicateModelEvent($environment, $clonedModel, $model); $environment->getEventDispatcher()->dispatch($duplicateEvent::NAME, $duplicateEvent); return $clonedModel; }
[ "private", "function", "doCloneAction", "(", "ModelInterface", "$", "model", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "// Make a duplicate.", "$", "clonedModel", "=", "$", "this", "->", "createClonedModel", "(", "$...
Effectively do the clone action on the model. @param ModelInterface $model The model to clone. @return ModelInterface Return the cloned model.
[ "Effectively", "do", "the", "clone", "action", "on", "the", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L708-L724
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.ensureSameGrouping
private function ensureSameGrouping(array $actions, ModelIdInterface $after = null) { $environment = $this->getEnvironment(); $groupingMode = ViewHelpers::getGroupingMode($environment); if ($groupingMode && $after && $after->getId()) { // when pasting after another item, inherit the grouping field $groupingField = $groupingMode['property']; $previous = $this->modelCollector->getModel($after); $groupingValue = $previous->getProperty($groupingField); foreach ($actions as $action) { /** @var ModelInterface $model */ $model = $action['model']; $model->setProperty($groupingField, $groupingValue); } } }
php
private function ensureSameGrouping(array $actions, ModelIdInterface $after = null) { $environment = $this->getEnvironment(); $groupingMode = ViewHelpers::getGroupingMode($environment); if ($groupingMode && $after && $after->getId()) { // when pasting after another item, inherit the grouping field $groupingField = $groupingMode['property']; $previous = $this->modelCollector->getModel($after); $groupingValue = $previous->getProperty($groupingField); foreach ($actions as $action) { /** @var ModelInterface $model */ $model = $action['model']; $model->setProperty($groupingField, $groupingValue); } } }
[ "private", "function", "ensureSameGrouping", "(", "array", "$", "actions", ",", "ModelIdInterface", "$", "after", "=", "null", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "groupingMode", "=", "ViewHelpers", "::...
Ensure all models have the same grouping. @param array $actions The actions collection. @param ModelIdInterface $after The previous model id. @return void
[ "Ensure", "all", "models", "have", "the", "same", "grouping", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L734-L750
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.sortAndPersistModels
private function sortAndPersistModels( array $actions, ModelIdInterface $after = null, ModelIdInterface $into = null, ModelIdInterface $parentModelId = null, array &$items = [] ) { /** @var DefaultCollection|ModelInterface[] $models */ $models = $this->createModelCollectionFromActions($actions, $items); $this->triggerPrePasteModel($models); $this->processPasteAfter($models, $after); $this->processPasteInto($models, $into); $this->processPasteTopWithoutReference($models, $after, $into, $parentModelId); $this->processPasteTopAfterModel($models, $parentModelId); if ($models->count()) { throw new DcGeneralRuntimeException('Invalid parameters.'); } return $models; }
php
private function sortAndPersistModels( array $actions, ModelIdInterface $after = null, ModelIdInterface $into = null, ModelIdInterface $parentModelId = null, array &$items = [] ) { /** @var DefaultCollection|ModelInterface[] $models */ $models = $this->createModelCollectionFromActions($actions, $items); $this->triggerPrePasteModel($models); $this->processPasteAfter($models, $after); $this->processPasteInto($models, $into); $this->processPasteTopWithoutReference($models, $after, $into, $parentModelId); $this->processPasteTopAfterModel($models, $parentModelId); if ($models->count()) { throw new DcGeneralRuntimeException('Invalid parameters.'); } return $models; }
[ "private", "function", "sortAndPersistModels", "(", "array", "$", "actions", ",", "ModelIdInterface", "$", "after", "=", "null", ",", "ModelIdInterface", "$", "into", "=", "null", ",", "ModelIdInterface", "$", "parentModelId", "=", "null", ",", "array", "&", "...
Apply sorting and persist all models. @param array $actions The actions collection. @param ModelIdInterface $after The previous model id. @param ModelIdInterface $into The hierarchical parent model id. @param ModelIdInterface $parentModelId The parent model id. @param array $items Write-back clipboard items. @return DefaultCollection|ModelInterface[] @throws DcGeneralRuntimeException When the parameters for the pasting destination are invalid.
[ "Apply", "sorting", "and", "persist", "all", "models", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L765-L787
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.processPasteAfter
private function processPasteAfter(CollectionInterface $models, ModelIdInterface $after = null) { if ($after && $models->count() && $after->getId()) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); $this->pasteAfter($this->modelCollector->getModel($after), $models, $manualSorting); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
php
private function processPasteAfter(CollectionInterface $models, ModelIdInterface $after = null) { if ($after && $models->count() && $after->getId()) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); $this->pasteAfter($this->modelCollector->getModel($after), $models, $manualSorting); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
[ "private", "function", "processPasteAfter", "(", "CollectionInterface", "$", "models", ",", "ModelIdInterface", "$", "after", "=", "null", ")", "{", "if", "(", "$", "after", "&&", "$", "models", "->", "count", "(", ")", "&&", "$", "after", "->", "getId", ...
Process paste the collection of models after the a model. @param CollectionInterface $models The collection of models. @param ModelIdInterface $after The paste after model. @return void
[ "Process", "paste", "the", "collection", "of", "models", "after", "the", "a", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L797-L807
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.processPasteInto
private function processPasteInto(CollectionInterface $models, ModelIdInterface $into = null) { if ($into && $models->count() && $into->getId()) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); $this->pasteInto($this->modelCollector->getModel($into), $models, $manualSorting); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
php
private function processPasteInto(CollectionInterface $models, ModelIdInterface $into = null) { if ($into && $models->count() && $into->getId()) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); $this->pasteInto($this->modelCollector->getModel($into), $models, $manualSorting); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
[ "private", "function", "processPasteInto", "(", "CollectionInterface", "$", "models", ",", "ModelIdInterface", "$", "into", "=", "null", ")", "{", "if", "(", "$", "into", "&&", "$", "models", "->", "count", "(", ")", "&&", "$", "into", "->", "getId", "("...
Process paste the collection of models into the a model. @param CollectionInterface $models The collection of models. @param ModelIdInterface $into The paste into model. @return void
[ "Process", "paste", "the", "collection", "of", "models", "into", "the", "a", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L817-L827
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.processPasteTopWithoutReference
private function processPasteTopWithoutReference( CollectionInterface $models, ModelIdInterface $after = null, ModelIdInterface $into = null, ModelIdInterface $parent = null ) { if ($models->count() && (($after && (0 === (int) $after->getId())) || ($into && (0 === (int) $into->getId()))) ) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); $dataDefinition = $this->getEnvironment()->getDataDefinition(); if (BasicDefinitionInterface::MODE_HIERARCHICAL === $dataDefinition->getBasicDefinition()->getMode()) { $this->relationshipManager->setAllRoot($models); } $this->pasteTop($models, $manualSorting, $parent); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
php
private function processPasteTopWithoutReference( CollectionInterface $models, ModelIdInterface $after = null, ModelIdInterface $into = null, ModelIdInterface $parent = null ) { if ($models->count() && (($after && (0 === (int) $after->getId())) || ($into && (0 === (int) $into->getId()))) ) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); $dataDefinition = $this->getEnvironment()->getDataDefinition(); if (BasicDefinitionInterface::MODE_HIERARCHICAL === $dataDefinition->getBasicDefinition()->getMode()) { $this->relationshipManager->setAllRoot($models); } $this->pasteTop($models, $manualSorting, $parent); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
[ "private", "function", "processPasteTopWithoutReference", "(", "CollectionInterface", "$", "models", ",", "ModelIdInterface", "$", "after", "=", "null", ",", "ModelIdInterface", "$", "into", "=", "null", ",", "ModelIdInterface", "$", "parent", "=", "null", ")", "{...
Process paste the content of the clipboard onto the top after a model without reference. @param CollectionInterface $models The collection of models. @param ModelIdInterface $after The previous model id. @param ModelIdInterface $into The hierarchical parent model id. @param ModelIdInterface $parent The parent model id. @return void
[ "Process", "paste", "the", "content", "of", "the", "clipboard", "onto", "the", "top", "after", "a", "model", "without", "reference", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L839-L861
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.processPasteTopAfterModel
private function processPasteTopAfterModel(CollectionInterface $models, ModelIdInterface $parent = null) { if ($parent && $models->count()) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); if ($manualSorting) { $this->pasteTop($models, $manualSorting, $parent); return; } $dataProvider = $this->getEnvironment()->getDataProvider(); $dataProvider->saveEach($models); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
php
private function processPasteTopAfterModel(CollectionInterface $models, ModelIdInterface $parent = null) { if ($parent && $models->count()) { $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment()); if ($manualSorting) { $this->pasteTop($models, $manualSorting, $parent); return; } $dataProvider = $this->getEnvironment()->getDataProvider(); $dataProvider->saveEach($models); $this->triggerPostPasteModel($models); $this->clearModelCollection($models); } }
[ "private", "function", "processPasteTopAfterModel", "(", "CollectionInterface", "$", "models", ",", "ModelIdInterface", "$", "parent", "=", "null", ")", "{", "if", "(", "$", "parent", "&&", "$", "models", "->", "count", "(", ")", ")", "{", "$", "manualSortin...
Process paste the content of the clipboard onto the top after a model. @param CollectionInterface $models The collection of models. @param ModelIdInterface $parent The parent model id. @return void
[ "Process", "paste", "the", "content", "of", "the", "clipboard", "onto", "the", "top", "after", "a", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L871-L888
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.createModelCollectionFromActions
private function createModelCollectionFromActions(array $actions, array &$items) { $models = new DefaultCollection(); foreach ($actions as $action) { $models->push($action['model']); $items[] = $action['item']; } return $models; }
php
private function createModelCollectionFromActions(array $actions, array &$items) { $models = new DefaultCollection(); foreach ($actions as $action) { $models->push($action['model']); $items[] = $action['item']; } return $models; }
[ "private", "function", "createModelCollectionFromActions", "(", "array", "$", "actions", ",", "array", "&", "$", "items", ")", "{", "$", "models", "=", "new", "DefaultCollection", "(", ")", ";", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{"...
Create the model collection from the internal models in the action collection. @param array $actions The actions collection. @param array $items Write-back clipboard items. @return DefaultCollection
[ "Create", "the", "model", "collection", "from", "the", "internal", "models", "in", "the", "action", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L898-L907
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.triggerPrePasteModel
private function triggerPrePasteModel(CollectionInterface $collection) { foreach ($collection as $model) { $event = new PrePasteModelEvent($this->getEnvironment(), $model); $this->getEnvironment()->getEventDispatcher()->dispatch($event::NAME, $event); } }
php
private function triggerPrePasteModel(CollectionInterface $collection) { foreach ($collection as $model) { $event = new PrePasteModelEvent($this->getEnvironment(), $model); $this->getEnvironment()->getEventDispatcher()->dispatch($event::NAME, $event); } }
[ "private", "function", "triggerPrePasteModel", "(", "CollectionInterface", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "model", ")", "{", "$", "event", "=", "new", "PrePasteModelEvent", "(", "$", "this", "->", "getEnvironment", "...
Trigger for each model the pre persist event. @param CollectionInterface $collection The collection of models. @return void
[ "Trigger", "for", "each", "model", "the", "pre", "persist", "event", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L916-L922
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.triggerPostPasteModel
private function triggerPostPasteModel(CollectionInterface $collection) { foreach ($collection as $model) { $event = new PostPasteModelEvent($this->getEnvironment(), $model); $this->getEnvironment()->getEventDispatcher()->dispatch($event::NAME, $event); } }
php
private function triggerPostPasteModel(CollectionInterface $collection) { foreach ($collection as $model) { $event = new PostPasteModelEvent($this->getEnvironment(), $model); $this->getEnvironment()->getEventDispatcher()->dispatch($event::NAME, $event); } }
[ "private", "function", "triggerPostPasteModel", "(", "CollectionInterface", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "model", ")", "{", "$", "event", "=", "new", "PostPasteModelEvent", "(", "$", "this", "->", "getEnvironment", ...
Trigger for each model the past persist event. @param CollectionInterface $collection The collection of models. @return void
[ "Trigger", "for", "each", "model", "the", "past", "persist", "event", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L931-L937
train
contao-community-alliance/dc-general
src/Controller/DefaultController.php
DefaultController.doDeepCopy
protected function doDeepCopy(array $deepCopyList) { if (empty($deepCopyList)) { return; } $factory = DcGeneralFactory::deriveFromEnvironment($this->getEnvironment()); $dataDefinition = $this->getEnvironment()->getDataDefinition(); $modelRelationshipDefinition = $dataDefinition->getModelRelationshipDefinition(); $childConditions = $modelRelationshipDefinition->getChildConditions($dataDefinition->getName()); foreach ($deepCopyList as $deepCopy) { /** @var ModelInterface $origin */ $origin = $deepCopy['origin']; /** @var ModelInterface $model */ $model = $deepCopy['model']; $parentId = ModelId::fromModel($model); foreach ($childConditions as $childCondition) { // create new destination environment $destinationName = $childCondition->getDestinationName(); $factory->setContainerName($destinationName); $destinationEnvironment = $factory->createEnvironment(); $destinationDataDefinition = $destinationEnvironment->getDataDefinition(); $destinationViewDefinition = $destinationDataDefinition->getDefinition( Contao2BackendViewDefinitionInterface::NAME ); $destinationDataProvider = $destinationEnvironment->getDataProvider(); $destinationController = $destinationEnvironment->getController(); /** @var Contao2BackendViewDefinitionInterface $destinationViewDefinition */ /** @var DefaultController $destinationController */ $listingConfig = $destinationViewDefinition->getListingConfig(); $groupAndSortingCollection = $listingConfig->getGroupAndSortingDefinition(); $groupAndSorting = $groupAndSortingCollection->getDefault(); // ***** fetch the children $filter = $childCondition->getFilter($origin); // apply parent-child condition $config = $destinationDataProvider->getEmptyConfig(); $config->setFilter($filter); // apply sorting $sorting = []; foreach ($groupAndSorting as $information) { /** @var GroupAndSortingInformationInterface $information */ $sorting[$information->getProperty()] = $information->getSortingMode(); } $config->setSorting($sorting); // receive children $children = $destinationDataProvider->fetchAll($config); // ***** do the deep copy $actions = []; // build the copy actions foreach ($children as $childModel) { $childModelId = ModelId::fromModel($childModel); $actions[] = [ 'model' => $childModel, 'item' => new Item(ItemInterface::DEEP_COPY, $parentId, $childModelId) ]; } // do the deep copy $childrenModels = $destinationController->doActions($actions, null, null, $parentId); // ensure parent-child condition foreach ($childrenModels as $childrenModel) { $childCondition->applyTo($model, $childrenModel); } $destinationDataProvider->saveEach($childrenModels); } } }
php
protected function doDeepCopy(array $deepCopyList) { if (empty($deepCopyList)) { return; } $factory = DcGeneralFactory::deriveFromEnvironment($this->getEnvironment()); $dataDefinition = $this->getEnvironment()->getDataDefinition(); $modelRelationshipDefinition = $dataDefinition->getModelRelationshipDefinition(); $childConditions = $modelRelationshipDefinition->getChildConditions($dataDefinition->getName()); foreach ($deepCopyList as $deepCopy) { /** @var ModelInterface $origin */ $origin = $deepCopy['origin']; /** @var ModelInterface $model */ $model = $deepCopy['model']; $parentId = ModelId::fromModel($model); foreach ($childConditions as $childCondition) { // create new destination environment $destinationName = $childCondition->getDestinationName(); $factory->setContainerName($destinationName); $destinationEnvironment = $factory->createEnvironment(); $destinationDataDefinition = $destinationEnvironment->getDataDefinition(); $destinationViewDefinition = $destinationDataDefinition->getDefinition( Contao2BackendViewDefinitionInterface::NAME ); $destinationDataProvider = $destinationEnvironment->getDataProvider(); $destinationController = $destinationEnvironment->getController(); /** @var Contao2BackendViewDefinitionInterface $destinationViewDefinition */ /** @var DefaultController $destinationController */ $listingConfig = $destinationViewDefinition->getListingConfig(); $groupAndSortingCollection = $listingConfig->getGroupAndSortingDefinition(); $groupAndSorting = $groupAndSortingCollection->getDefault(); // ***** fetch the children $filter = $childCondition->getFilter($origin); // apply parent-child condition $config = $destinationDataProvider->getEmptyConfig(); $config->setFilter($filter); // apply sorting $sorting = []; foreach ($groupAndSorting as $information) { /** @var GroupAndSortingInformationInterface $information */ $sorting[$information->getProperty()] = $information->getSortingMode(); } $config->setSorting($sorting); // receive children $children = $destinationDataProvider->fetchAll($config); // ***** do the deep copy $actions = []; // build the copy actions foreach ($children as $childModel) { $childModelId = ModelId::fromModel($childModel); $actions[] = [ 'model' => $childModel, 'item' => new Item(ItemInterface::DEEP_COPY, $parentId, $childModelId) ]; } // do the deep copy $childrenModels = $destinationController->doActions($actions, null, null, $parentId); // ensure parent-child condition foreach ($childrenModels as $childrenModel) { $childCondition->applyTo($model, $childrenModel); } $destinationDataProvider->saveEach($childrenModels); } } }
[ "protected", "function", "doDeepCopy", "(", "array", "$", "deepCopyList", ")", "{", "if", "(", "empty", "(", "$", "deepCopyList", ")", ")", "{", "return", ";", "}", "$", "factory", "=", "DcGeneralFactory", "::", "deriveFromEnvironment", "(", "$", "this", "...
Do deep copy. @param array $deepCopyList The deep copy list. @return void
[ "Do", "deep", "copy", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/DefaultController.php#L946-L1023
train
contao-community-alliance/dc-general
src/Contao/Dca/Populator/DataProviderPopulator.php
DataProviderPopulator.populate
public function populate(EnvironmentInterface $environment) { foreach ($environment->getDataDefinition()->getDataProviderDefinition() as $information) { if ($information instanceof ContaoDataProviderInformation) { if ($environment->hasDataProvider($information->getName())) { throw new DcGeneralRuntimeException( \sprintf( 'Data provider %s already added to environment.', $information->getName() ) ); } /** @var DataProviderInterface $dataProvider */ $dataProvider = (new \ReflectionClass($information->getClassName()))->newInstance(); if ($initializationData = $information->getInitializationData()) { $dataProvider->setBaseConfig($initializationData); } $environment->addDataProvider($information->getName(), $dataProvider); } } }
php
public function populate(EnvironmentInterface $environment) { foreach ($environment->getDataDefinition()->getDataProviderDefinition() as $information) { if ($information instanceof ContaoDataProviderInformation) { if ($environment->hasDataProvider($information->getName())) { throw new DcGeneralRuntimeException( \sprintf( 'Data provider %s already added to environment.', $information->getName() ) ); } /** @var DataProviderInterface $dataProvider */ $dataProvider = (new \ReflectionClass($information->getClassName()))->newInstance(); if ($initializationData = $information->getInitializationData()) { $dataProvider->setBaseConfig($initializationData); } $environment->addDataProvider($information->getName(), $dataProvider); } } }
[ "public", "function", "populate", "(", "EnvironmentInterface", "$", "environment", ")", "{", "foreach", "(", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getDataProviderDefinition", "(", ")", "as", "$", "information", ")", "{", "if", "(", "$...
Instantiates and adds the data providers implementing ContaoDataProviderInformation to the environment. @param EnvironmentInterface $environment The environment to populate. @return void @throws DcGeneralRuntimeException When a data provider has already been added to the environment.
[ "Instantiates", "and", "adds", "the", "data", "providers", "implementing", "ContaoDataProviderInformation", "to", "the", "environment", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Populator/DataProviderPopulator.php#L49-L71
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
MultipleHandlerSubscriber.prepareGlobalAllButton
public function prepareGlobalAllButton(ActionEvent $event) { if (!$this->scopeDeterminator->currentScopeIsBackend() || ('showAll' !== $event->getAction()->getName())) { return; } $dataDefinition = $event->getEnvironment()->getDataDefinition(); $backendView = $dataDefinition->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $globalCommands = $backendView->getGlobalCommands(); if ($globalCommands->hasCommandNamed('all')) { $allCommand = $globalCommands->getCommandNamed('all'); $parameters = $allCommand->getParameters(); $parameters->offsetSet('select', 'models'); } }
php
public function prepareGlobalAllButton(ActionEvent $event) { if (!$this->scopeDeterminator->currentScopeIsBackend() || ('showAll' !== $event->getAction()->getName())) { return; } $dataDefinition = $event->getEnvironment()->getDataDefinition(); $backendView = $dataDefinition->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $globalCommands = $backendView->getGlobalCommands(); if ($globalCommands->hasCommandNamed('all')) { $allCommand = $globalCommands->getCommandNamed('all'); $parameters = $allCommand->getParameters(); $parameters->offsetSet('select', 'models'); } }
[ "public", "function", "prepareGlobalAllButton", "(", "ActionEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "scopeDeterminator", "->", "currentScopeIsBackend", "(", ")", "||", "(", "'showAll'", "!==", "$", "event", "->", "getAction", "(", ...
Prepare the global all button. @param ActionEvent $event The event. @return void
[ "Prepare", "the", "global", "all", "button", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php#L87-L103
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
MultipleHandlerSubscriber.deactivateGlobalButton
public function deactivateGlobalButton(ActionEvent $event) { $allowedAction = ['selectModelAll', 'selectPropertyAll', 'editAll', 'overrideAll']; if (!$this->scopeDeterminator->currentScopeIsBackend() || !\in_array($event->getAction()->getName(), $allowedAction)) { return; } $dataDefinition = $event->getEnvironment()->getDataDefinition(); $backendView = $dataDefinition->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $globalCommands = $backendView->getGlobalCommands(); $allowedButton = ['close_all_button']; if ('selectModelAll' !== $event->getAction()->getName()) { $allowedButton[] = 'back_button'; } foreach ($globalCommands->getCommands() as $command) { if (\in_array($command->getName(), $allowedButton)) { continue; } $command->setDisabled(true); } }
php
public function deactivateGlobalButton(ActionEvent $event) { $allowedAction = ['selectModelAll', 'selectPropertyAll', 'editAll', 'overrideAll']; if (!$this->scopeDeterminator->currentScopeIsBackend() || !\in_array($event->getAction()->getName(), $allowedAction)) { return; } $dataDefinition = $event->getEnvironment()->getDataDefinition(); $backendView = $dataDefinition->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $globalCommands = $backendView->getGlobalCommands(); $allowedButton = ['close_all_button']; if ('selectModelAll' !== $event->getAction()->getName()) { $allowedButton[] = 'back_button'; } foreach ($globalCommands->getCommands() as $command) { if (\in_array($command->getName(), $allowedButton)) { continue; } $command->setDisabled(true); } }
[ "public", "function", "deactivateGlobalButton", "(", "ActionEvent", "$", "event", ")", "{", "$", "allowedAction", "=", "[", "'selectModelAll'", ",", "'selectPropertyAll'", ",", "'editAll'", ",", "'overrideAll'", "]", ";", "if", "(", "!", "$", "this", "->", "sc...
Deactivate global button their are not useful. @param ActionEvent $event The event. @return void
[ "Deactivate", "global", "button", "their", "are", "not", "useful", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php#L112-L136
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
MultipleHandlerSubscriber.handleOriginalOptions
public function handleOriginalOptions(GetOptionsEvent $event) { $environment = $event->getEnvironment(); if (!$this->scopeDeterminator->currentScopeIsBackend() || ('select' !== $environment->getInputProvider()->getParameter('act')) || ('edit' !== $environment->getInputProvider()->getParameter('select')) ) { return; } $model = $event->getModel(); if (!($propertyName = $this->getOriginalPropertyName($event->getPropertyName(), ModelId::fromModel($model))) || !$model->getProperty($propertyName) ) { return; } $originalWidget = clone $event->getWidget(); $originalWidget->id = $propertyName; $originalWidget->name = $propertyName; $originalOptionsEvent = new GetOptionsEvent( $propertyName, $event->getSubPropertyName(), $event->getEnvironment(), $model, $originalWidget, $event->getOptions() ); $environment->getEventDispatcher()->dispatch(GetOptionsEvent::NAME, $originalOptionsEvent); $event->setOptions($originalOptionsEvent->getOptions()); $event->stopPropagation(); }
php
public function handleOriginalOptions(GetOptionsEvent $event) { $environment = $event->getEnvironment(); if (!$this->scopeDeterminator->currentScopeIsBackend() || ('select' !== $environment->getInputProvider()->getParameter('act')) || ('edit' !== $environment->getInputProvider()->getParameter('select')) ) { return; } $model = $event->getModel(); if (!($propertyName = $this->getOriginalPropertyName($event->getPropertyName(), ModelId::fromModel($model))) || !$model->getProperty($propertyName) ) { return; } $originalWidget = clone $event->getWidget(); $originalWidget->id = $propertyName; $originalWidget->name = $propertyName; $originalOptionsEvent = new GetOptionsEvent( $propertyName, $event->getSubPropertyName(), $event->getEnvironment(), $model, $originalWidget, $event->getOptions() ); $environment->getEventDispatcher()->dispatch(GetOptionsEvent::NAME, $originalOptionsEvent); $event->setOptions($originalOptionsEvent->getOptions()); $event->stopPropagation(); }
[ "public", "function", "handleOriginalOptions", "(", "GetOptionsEvent", "$", "event", ")", "{", "$", "environment", "=", "$", "event", "->", "getEnvironment", "(", ")", ";", "if", "(", "!", "$", "this", "->", "scopeDeterminator", "->", "currentScopeIsBackend", ...
Handle the original widget options. @param GetOptionsEvent $event The event. @return void
[ "Handle", "the", "original", "widget", "options", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php#L145-L183
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
MultipleHandlerSubscriber.handleOriginalWidget
public function handleOriginalWidget(BuildWidgetEvent $event) { $environment = $event->getEnvironment(); if (!$this->scopeDeterminator->currentScopeIsBackend() || ('select' !== $environment->getInputProvider()->getParameter('act')) || ('edit' !== $environment->getInputProvider()->getParameter('select')) ) { return; } $properties = $environment->getDataDefinition()->getPropertiesDefinition(); $this->findModelIdByPropertyName($event); $model = $event->getModel(); $modelId = ModelId::fromModel($model); $originalPropertyName = $this->getOriginalPropertyName($event->getProperty()->getName(), $modelId); if ((null === $originalPropertyName) || ((null !== $originalPropertyName) && (false === $properties->hasProperty($originalPropertyName))) ) { return; } $originalProperty = $properties->getProperty($originalPropertyName); $originalExtra = $copiedExtra = $originalProperty->getExtra(); if (!empty($originalExtra['orderField'])) { $orderId = \str_replace('::', '____', $modelId->getSerialized()) . '_' . $copiedExtra['orderField']; $copiedExtra['orderField'] = $orderId; $isChanged = $model->getMeta($model::IS_CHANGED); $model->setProperty($orderId, $model->getProperty($originalExtra['orderField'])); $model->setMeta($model::IS_CHANGED, $isChanged); } $originalProperty->setExtra($copiedExtra); $originalEvent = new BuildWidgetEvent($environment, $model, $originalProperty); $environment->getEventDispatcher()->dispatch(BuildWidgetEvent::NAME, $originalEvent); $originalEvent->getWidget()->id = $event->getProperty()->getName(); $originalEvent->getWidget()->name = \str_replace('::', '____', $modelId->getSerialized()) . '_[' . $originalPropertyName . ']'; $originalEvent->getWidget()->tl_class = ''; $event->setWidget($originalEvent->getWidget()); $originalProperty->setExtra($originalExtra); $event->stopPropagation(); }
php
public function handleOriginalWidget(BuildWidgetEvent $event) { $environment = $event->getEnvironment(); if (!$this->scopeDeterminator->currentScopeIsBackend() || ('select' !== $environment->getInputProvider()->getParameter('act')) || ('edit' !== $environment->getInputProvider()->getParameter('select')) ) { return; } $properties = $environment->getDataDefinition()->getPropertiesDefinition(); $this->findModelIdByPropertyName($event); $model = $event->getModel(); $modelId = ModelId::fromModel($model); $originalPropertyName = $this->getOriginalPropertyName($event->getProperty()->getName(), $modelId); if ((null === $originalPropertyName) || ((null !== $originalPropertyName) && (false === $properties->hasProperty($originalPropertyName))) ) { return; } $originalProperty = $properties->getProperty($originalPropertyName); $originalExtra = $copiedExtra = $originalProperty->getExtra(); if (!empty($originalExtra['orderField'])) { $orderId = \str_replace('::', '____', $modelId->getSerialized()) . '_' . $copiedExtra['orderField']; $copiedExtra['orderField'] = $orderId; $isChanged = $model->getMeta($model::IS_CHANGED); $model->setProperty($orderId, $model->getProperty($originalExtra['orderField'])); $model->setMeta($model::IS_CHANGED, $isChanged); } $originalProperty->setExtra($copiedExtra); $originalEvent = new BuildWidgetEvent($environment, $model, $originalProperty); $environment->getEventDispatcher()->dispatch(BuildWidgetEvent::NAME, $originalEvent); $originalEvent->getWidget()->id = $event->getProperty()->getName(); $originalEvent->getWidget()->name = \str_replace('::', '____', $modelId->getSerialized()) . '_[' . $originalPropertyName . ']'; $originalEvent->getWidget()->tl_class = ''; $event->setWidget($originalEvent->getWidget()); $originalProperty->setExtra($originalExtra); $event->stopPropagation(); }
[ "public", "function", "handleOriginalWidget", "(", "BuildWidgetEvent", "$", "event", ")", "{", "$", "environment", "=", "$", "event", "->", "getEnvironment", "(", ")", ";", "if", "(", "!", "$", "this", "->", "scopeDeterminator", "->", "currentScopeIsBackend", ...
Handle the original widget. @param BuildWidgetEvent $event The build widget event. @return void
[ "Handle", "the", "original", "widget", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php#L192-L249
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
MultipleHandlerSubscriber.findModelIdByPropertyName
private function findModelIdByPropertyName(BuildWidgetEvent $event) { if (null !== $event->getModel()->getId()) { return; } $environment = $event->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); $inputProvider = $environment->getInputProvider(); $sessionStorage = $environment->getSessionStorage(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('mode')); $model = null; foreach ($session['models'] as $sessionModel) { $model = $sessionModel; if (0 !== \strpos($event->getProperty()->getName(), \str_replace('::', '____', $sessionModel))) { continue; } break; } $modelId = ModelId::fromSerialized($model); $event->getModel()->setId($modelId->getId()); }
php
private function findModelIdByPropertyName(BuildWidgetEvent $event) { if (null !== $event->getModel()->getId()) { return; } $environment = $event->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); $inputProvider = $environment->getInputProvider(); $sessionStorage = $environment->getSessionStorage(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('mode')); $model = null; foreach ($session['models'] as $sessionModel) { $model = $sessionModel; if (0 !== \strpos($event->getProperty()->getName(), \str_replace('::', '____', $sessionModel))) { continue; } break; } $modelId = ModelId::fromSerialized($model); $event->getModel()->setId($modelId->getId()); }
[ "private", "function", "findModelIdByPropertyName", "(", "BuildWidgetEvent", "$", "event", ")", "{", "if", "(", "null", "!==", "$", "event", "->", "getModel", "(", ")", "->", "getId", "(", ")", ")", "{", "return", ";", "}", "$", "environment", "=", "$", ...
Find the model id by property name, if model id not set. @param BuildWidgetEvent $event The event. @return void
[ "Find", "the", "model", "id", "by", "property", "name", "if", "model", "id", "not", "set", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php#L258-L285
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php
MultipleHandlerSubscriber.getOriginalPropertyName
private function getOriginalPropertyName($propertyName, ModelIdInterface $modelId) { $originalPropertyName = \trim(\substr($propertyName, \strlen(\str_replace('::', '____', $modelId->getSerialized()) . '_')), '[]'); return $originalPropertyName ?: null; }
php
private function getOriginalPropertyName($propertyName, ModelIdInterface $modelId) { $originalPropertyName = \trim(\substr($propertyName, \strlen(\str_replace('::', '____', $modelId->getSerialized()) . '_')), '[]'); return $originalPropertyName ?: null; }
[ "private", "function", "getOriginalPropertyName", "(", "$", "propertyName", ",", "ModelIdInterface", "$", "modelId", ")", "{", "$", "originalPropertyName", "=", "\\", "trim", "(", "\\", "substr", "(", "$", "propertyName", ",", "\\", "strlen", "(", "\\", "str_r...
Get the original property name. @param string $propertyName The property name. @param ModelIdInterface $modelId The model id. @return string|null
[ "Get", "the", "original", "property", "name", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/MultipleHandlerSubscriber.php#L295-L301
train
yiisoft/cache
src/Cache.php
Cache.set
public function set($key, $value, $ttl = null, $dependency = null): bool { if ($dependency !== null) { $dependency->evaluateDependency($this); $value = [$value, $dependency]; } $key = $this->buildKey($key); return $this->_handler->set($key, $value, $ttl); }
php
public function set($key, $value, $ttl = null, $dependency = null): bool { if ($dependency !== null) { $dependency->evaluateDependency($this); $value = [$value, $dependency]; } $key = $this->buildKey($key); return $this->_handler->set($key, $value, $ttl); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ",", "$", "dependency", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "dependency", "!==", "null", ")", "{", "$", "dependency", "->", "evaluateDepe...
Stores a value identified by a key into cache. If the cache already contains such a key, the existing value and expiration time will be replaced with the new ones, respectively. @param mixed $key a key identifying the value to be cached. This can be a simple string or a complex data structure consisting of factors representing the key. @param mixed $value the value to be cached @param null|int|\DateInterval $ttl the TTL value of this item. If not set, default value is used. @param Dependency $dependency dependency of the cached item. If the dependency changes, the corresponding value in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false. @return bool whether the value is successfully stored into cache
[ "Stores", "a", "value", "identified", "by", "a", "key", "into", "cache", ".", "If", "the", "cache", "already", "contains", "such", "a", "key", "the", "existing", "value", "and", "expiration", "time", "will", "be", "replaced", "with", "the", "new", "ones", ...
d3ffe8436270481e34842705817a5cf8025d947f
https://github.com/yiisoft/cache/blob/d3ffe8436270481e34842705817a5cf8025d947f/src/Cache.php#L201-L209
train
yiisoft/cache
src/Cache.php
Cache.delete
public function delete($key): bool { $key = $this->buildKey($key); return $this->_handler->delete($key); }
php
public function delete($key): bool { $key = $this->buildKey($key); return $this->_handler->delete($key); }
[ "public", "function", "delete", "(", "$", "key", ")", ":", "bool", "{", "$", "key", "=", "$", "this", "->", "buildKey", "(", "$", "key", ")", ";", "return", "$", "this", "->", "_handler", "->", "delete", "(", "$", "key", ")", ";", "}" ]
Deletes a value with the specified key from cache. @param mixed $key a key identifying the value to be deleted from cache. This can be a simple string or a complex data structure consisting of factors representing the key. @return bool if no error happens during deletion
[ "Deletes", "a", "value", "with", "the", "specified", "key", "from", "cache", "." ]
d3ffe8436270481e34842705817a5cf8025d947f
https://github.com/yiisoft/cache/blob/d3ffe8436270481e34842705817a5cf8025d947f/src/Cache.php#L323-L328
train
contao-community-alliance/dc-general
src/Data/DefaultDataProviderSqlUtils.php
DefaultDataProviderSqlUtils.buildFieldQuery
public static function buildFieldQuery($config, $idProperty) { if ($config->getIdOnly()) { return $idProperty; } if (null !== $config->getFields()) { $fields = \implode(', ', $config->getFields()); if (false !== \stripos($fields, 'DISTINCT')) { return $fields; } return $idProperty . ', ' . $fields; } return '*'; }
php
public static function buildFieldQuery($config, $idProperty) { if ($config->getIdOnly()) { return $idProperty; } if (null !== $config->getFields()) { $fields = \implode(', ', $config->getFields()); if (false !== \stripos($fields, 'DISTINCT')) { return $fields; } return $idProperty . ', ' . $fields; } return '*'; }
[ "public", "static", "function", "buildFieldQuery", "(", "$", "config", ",", "$", "idProperty", ")", "{", "if", "(", "$", "config", "->", "getIdOnly", "(", ")", ")", "{", "return", "$", "idProperty", ";", "}", "if", "(", "null", "!==", "$", "config", ...
Build the field list. Returns all values from $objConfig->getFields() as comma separated list. @param ConfigInterface $config The configuration to use. @param string $idProperty The name of the id property. @return string @deprecated Use DefaultDataProviderDBalUtils::addField. This will be removed.
[ "Build", "the", "field", "list", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderSqlUtils.php#L45-L59
train
contao-community-alliance/dc-general
src/Data/DefaultDataProviderSqlUtils.php
DefaultDataProviderSqlUtils.buildWhereQuery
public static function buildWhereQuery($config, array &$parameters) { $query = static::buildFilterQuery($config, $parameters); if (empty($query)) { return ''; } return ' WHERE ' . $query; }
php
public static function buildWhereQuery($config, array &$parameters) { $query = static::buildFilterQuery($config, $parameters); if (empty($query)) { return ''; } return ' WHERE ' . $query; }
[ "public", "static", "function", "buildWhereQuery", "(", "$", "config", ",", "array", "&", "$", "parameters", ")", "{", "$", "query", "=", "static", "::", "buildFilterQuery", "(", "$", "config", ",", "$", "parameters", ")", ";", "if", "(", "empty", "(", ...
Build the WHERE clause for a configuration. @param ConfigInterface $config The configuration to use. @param array $parameters The query parameters will get stored into this array. @return string The combined WHERE clause (including the word "WHERE"). @deprecated Use DefaultDataProviderDBalUtils::addWhere. This will be removed.
[ "Build", "the", "WHERE", "clause", "for", "a", "configuration", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderSqlUtils.php#L72-L80
train
contao-community-alliance/dc-general
src/Data/DefaultDataProviderSqlUtils.php
DefaultDataProviderSqlUtils.buildSortingQuery
public static function buildSortingQuery($config) { $sorting = $config->getSorting(); $result = ''; $fields = []; if (empty($sorting) || !\is_array($sorting)) { return ''; } foreach ($sorting as $field => $direction) { // array could be a simple field list or list of field => direction combinations. if (!empty($direction)) { $direction = \strtoupper($direction); if (!\in_array($direction, [DCGE::MODEL_SORTING_ASC, DCGE::MODEL_SORTING_DESC])) { $field = $direction; $direction = DCGE::MODEL_SORTING_ASC; } } else { $direction = DCGE::MODEL_SORTING_ASC; } $fields[] = $field . ' ' . $direction; } $result .= ' ORDER BY ' . \implode(', ', $fields); return $result; }
php
public static function buildSortingQuery($config) { $sorting = $config->getSorting(); $result = ''; $fields = []; if (empty($sorting) || !\is_array($sorting)) { return ''; } foreach ($sorting as $field => $direction) { // array could be a simple field list or list of field => direction combinations. if (!empty($direction)) { $direction = \strtoupper($direction); if (!\in_array($direction, [DCGE::MODEL_SORTING_ASC, DCGE::MODEL_SORTING_DESC])) { $field = $direction; $direction = DCGE::MODEL_SORTING_ASC; } } else { $direction = DCGE::MODEL_SORTING_ASC; } $fields[] = $field . ' ' . $direction; } $result .= ' ORDER BY ' . \implode(', ', $fields); return $result; }
[ "public", "static", "function", "buildSortingQuery", "(", "$", "config", ")", "{", "$", "sorting", "=", "$", "config", "->", "getSorting", "(", ")", ";", "$", "result", "=", "''", ";", "$", "fields", "=", "[", "]", ";", "if", "(", "empty", "(", "$"...
Build the order by part of a query. @param ConfigInterface $config The configuration to use. @return string @deprecated Use DefaultDataProviderDBalUtils::addSorting. This will be removed.
[ "Build", "the", "order", "by", "part", "of", "a", "query", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderSqlUtils.php#L91-L118
train
contao-community-alliance/dc-general
src/Controller/TreeNodeStates.php
TreeNodeStates.isModelOpen
public function isModelOpen($providerName, $modelId, $ignoreAllState = false) { if (!$ignoreAllState && isset($this->states['all']) && (1 === $this->states['all'])) { return true; } return (isset($this->states[$providerName][$modelId]) && $this->states[$providerName][$modelId]) || (isset($this->implicitOpen[$providerName][$modelId]) && $this->implicitOpen[$providerName][$modelId]); }
php
public function isModelOpen($providerName, $modelId, $ignoreAllState = false) { if (!$ignoreAllState && isset($this->states['all']) && (1 === $this->states['all'])) { return true; } return (isset($this->states[$providerName][$modelId]) && $this->states[$providerName][$modelId]) || (isset($this->implicitOpen[$providerName][$modelId]) && $this->implicitOpen[$providerName][$modelId]); }
[ "public", "function", "isModelOpen", "(", "$", "providerName", ",", "$", "modelId", ",", "$", "ignoreAllState", "=", "false", ")", "{", "if", "(", "!", "$", "ignoreAllState", "&&", "isset", "(", "$", "this", "->", "states", "[", "'all'", "]", ")", "&&"...
Determine if the model is expanded. @param string $providerName The data provider name. @param mixed $modelId The id of the model. @param bool $ignoreAllState If this is true, the "all open" flag will be ignored. @return bool
[ "Determine", "if", "the", "model", "is", "expanded", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Controller/TreeNodeStates.php#L166-L174
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EventListener/SelectModeButtonsListener.php
SelectModeButtonsListener.handleEvent
public function handleEvent(GetSelectModeButtonsEvent $event) { $environment = $event->getEnvironment(); $translator = $environment->getTranslator(); $basicDefinition = $environment->getDataDefinition()->getBasicDefinition(); $buttons = []; $confirmMessage = \htmlentities( \sprintf( '<h2 class="tl_error">%s</h2>' . '<p></p>' . '<div class="tl_submit_container">' . '<input type="submit" name="close" class="%s" value="%s" onclick="%s">' . '</div>', StringUtil::specialchars($translator->translate('MSC.nothingSelect', 'contao_default')), 'tl_submit', StringUtil::specialchars($translator->translate('MSC.close', 'contao_default')), 'this.blur(); BackendGeneral.hideMessage(); return false;' ) ); $onClick = 'BackendGeneral.confirmSelectOverrideEditAll(this, \'models[]\', \'' . $confirmMessage . '\'); return false;'; $input = '<input type="submit" name="%s" id="%s" class="tl_submit" accesskey="%s" value="%s" onclick="%s">'; if ($basicDefinition->isDeletable()) { $onClickDelete = \sprintf( 'BackendGeneral.confirmSelectDeleteAll(this, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\'); return false;', 'models[]', $confirmMessage, StringUtil::specialchars($translator->translate('MSC.delAllConfirm', 'contao_default')), StringUtil::specialchars($translator->translate('MSC.confirmOk', 'contao_default')), StringUtil::specialchars($translator->translate('MSC.confirmAbort', 'contao_default')) ); $buttons['delete'] = \sprintf( $input, 'delete', 'delete', 'd', StringUtil::specialchars($translator->translate('MSC.deleteSelected', 'contao_default')), $onClickDelete ); } $sortingProperty = ViewHelpers::getManualSortingProperty($event->getEnvironment()); if ($sortingProperty && $basicDefinition->isEditable()) { $buttons['cut'] = \sprintf( $input, 'cut', 'cut', 's', StringUtil::specialchars($translator->translate('MSC.moveSelected', 'contao_default')), $onClick ); } if ($basicDefinition->isCreatable()) { $buttons['copy'] = \sprintf( $input, 'copy', 'copy', 'c', StringUtil::specialchars($translator->translate('MSC.copySelected', 'contao_default')), $onClick ); } if ($basicDefinition->isEditable()) { $buttons['override'] = \sprintf( $input, 'override', 'override', 'v', StringUtil::specialchars($translator->translate('MSC.overrideSelected', 'contao_default')), $onClick ); $buttons['edit'] = \sprintf( $input, 'edit', 'edit', 's', StringUtil::specialchars($translator->translate('MSC.editSelected', 'contao_default')), $onClick ); } $event->setButtons($buttons); }
php
public function handleEvent(GetSelectModeButtonsEvent $event) { $environment = $event->getEnvironment(); $translator = $environment->getTranslator(); $basicDefinition = $environment->getDataDefinition()->getBasicDefinition(); $buttons = []; $confirmMessage = \htmlentities( \sprintf( '<h2 class="tl_error">%s</h2>' . '<p></p>' . '<div class="tl_submit_container">' . '<input type="submit" name="close" class="%s" value="%s" onclick="%s">' . '</div>', StringUtil::specialchars($translator->translate('MSC.nothingSelect', 'contao_default')), 'tl_submit', StringUtil::specialchars($translator->translate('MSC.close', 'contao_default')), 'this.blur(); BackendGeneral.hideMessage(); return false;' ) ); $onClick = 'BackendGeneral.confirmSelectOverrideEditAll(this, \'models[]\', \'' . $confirmMessage . '\'); return false;'; $input = '<input type="submit" name="%s" id="%s" class="tl_submit" accesskey="%s" value="%s" onclick="%s">'; if ($basicDefinition->isDeletable()) { $onClickDelete = \sprintf( 'BackendGeneral.confirmSelectDeleteAll(this, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\'); return false;', 'models[]', $confirmMessage, StringUtil::specialchars($translator->translate('MSC.delAllConfirm', 'contao_default')), StringUtil::specialchars($translator->translate('MSC.confirmOk', 'contao_default')), StringUtil::specialchars($translator->translate('MSC.confirmAbort', 'contao_default')) ); $buttons['delete'] = \sprintf( $input, 'delete', 'delete', 'd', StringUtil::specialchars($translator->translate('MSC.deleteSelected', 'contao_default')), $onClickDelete ); } $sortingProperty = ViewHelpers::getManualSortingProperty($event->getEnvironment()); if ($sortingProperty && $basicDefinition->isEditable()) { $buttons['cut'] = \sprintf( $input, 'cut', 'cut', 's', StringUtil::specialchars($translator->translate('MSC.moveSelected', 'contao_default')), $onClick ); } if ($basicDefinition->isCreatable()) { $buttons['copy'] = \sprintf( $input, 'copy', 'copy', 'c', StringUtil::specialchars($translator->translate('MSC.copySelected', 'contao_default')), $onClick ); } if ($basicDefinition->isEditable()) { $buttons['override'] = \sprintf( $input, 'override', 'override', 'v', StringUtil::specialchars($translator->translate('MSC.overrideSelected', 'contao_default')), $onClick ); $buttons['edit'] = \sprintf( $input, 'edit', 'edit', 's', StringUtil::specialchars($translator->translate('MSC.editSelected', 'contao_default')), $onClick ); } $event->setButtons($buttons); }
[ "public", "function", "handleEvent", "(", "GetSelectModeButtonsEvent", "$", "event", ")", "{", "$", "environment", "=", "$", "event", "->", "getEnvironment", "(", ")", ";", "$", "translator", "=", "$", "environment", "->", "getTranslator", "(", ")", ";", "$"...
Handle event for add the default buttons for the select mode. @param GetSelectModeButtonsEvent $event The event. @return void
[ "Handle", "event", "for", "add", "the", "default", "buttons", "for", "the", "select", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EventListener/SelectModeButtonsListener.php#L38-L127
train
contao-community-alliance/dc-general
src/Contao/Callback/ModelOptionsCallbackListener.php
ModelOptionsCallbackListener.update
public function update($event, $value) { if (null === $value) { return; } $event->setOptions($value); $event->stopPropagation(); }
php
public function update($event, $value) { if (null === $value) { return; } $event->setOptions($value); $event->stopPropagation(); }
[ "public", "function", "update", "(", "$", "event", ",", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", ";", "}", "$", "event", "->", "setOptions", "(", "$", "value", ")", ";", "$", "event", "->", "stopPropagatio...
Update the options list in the event. @param GetPropertyOptionsEvent $event The event being emitted. @param array $value The options array. @return void
[ "Update", "the", "options", "list", "in", "the", "event", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Callback/ModelOptionsCallbackListener.php#L56-L64
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.encodeValue
public function encodeValue($property, $value, PropertyValueBag $propertyValues) { $environment = $this->getEnvironment(); $event = new EncodePropertyValueFromWidgetEvent($environment, $this->model, $propertyValues); $event ->setProperty($property) ->setValue($value); $environment->getEventDispatcher()->dispatch(EncodePropertyValueFromWidgetEvent::NAME, $event); return $event->getValue(); }
php
public function encodeValue($property, $value, PropertyValueBag $propertyValues) { $environment = $this->getEnvironment(); $event = new EncodePropertyValueFromWidgetEvent($environment, $this->model, $propertyValues); $event ->setProperty($property) ->setValue($value); $environment->getEventDispatcher()->dispatch(EncodePropertyValueFromWidgetEvent::NAME, $event); return $event->getValue(); }
[ "public", "function", "encodeValue", "(", "$", "property", ",", "$", "value", ",", "PropertyValueBag", "$", "propertyValues", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "event", "=", "new", "EncodePropertyValu...
Encode a value from the widget to native data of the data provider via event. @param string $property The property. @param mixed $value The value of the property. @param PropertyValueBag $propertyValues The property value bag the property value originates from. @return mixed
[ "Encode", "a", "value", "from", "the", "widget", "to", "native", "data", "of", "the", "data", "provider", "via", "event", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L98-L110
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.loadRichTextEditor
public function loadRichTextEditor($buffer, Widget $widget) { if ((null === $widget->rte) || ((0 !== (\strncmp($widget->rte, 'tiny', 4))) && (0 !== \strncmp($widget->rte, 'ace', 3))) ) { return $buffer; } $backendAdapter = $this->framework->getAdapter(Backend::class); $templateLoaderAdapter = $this->framework->getAdapter(TemplateLoader::class); [$file, $type] = \explode('|', $widget->rte); $templateName = 'be_' . $file; // This test if the rich text editor template exist. $templateLoaderAdapter->getDefaultPath($templateName, 'html5'); $template = new ContaoBackendViewTemplate($templateName); $template ->set('selector', 'ctrl_' . $widget->id) ->set('type', $type); if (0 !== \strncmp($widget->rte, 'tiny', 4)) { /** @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0 */ $template->set('language', $backendAdapter->getTinyMceLanguage()); } $buffer .= $template->parse(); return $buffer; }
php
public function loadRichTextEditor($buffer, Widget $widget) { if ((null === $widget->rte) || ((0 !== (\strncmp($widget->rte, 'tiny', 4))) && (0 !== \strncmp($widget->rte, 'ace', 3))) ) { return $buffer; } $backendAdapter = $this->framework->getAdapter(Backend::class); $templateLoaderAdapter = $this->framework->getAdapter(TemplateLoader::class); [$file, $type] = \explode('|', $widget->rte); $templateName = 'be_' . $file; // This test if the rich text editor template exist. $templateLoaderAdapter->getDefaultPath($templateName, 'html5'); $template = new ContaoBackendViewTemplate($templateName); $template ->set('selector', 'ctrl_' . $widget->id) ->set('type', $type); if (0 !== \strncmp($widget->rte, 'tiny', 4)) { /** @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0 */ $template->set('language', $backendAdapter->getTinyMceLanguage()); } $buffer .= $template->parse(); return $buffer; }
[ "public", "function", "loadRichTextEditor", "(", "$", "buffer", ",", "Widget", "$", "widget", ")", "{", "if", "(", "(", "null", "===", "$", "widget", "->", "rte", ")", "||", "(", "(", "0", "!==", "(", "\\", "strncmp", "(", "$", "widget", "->", "rte...
Function for pre-loading the tiny mce. @param string $buffer The rendered widget as string. @param Widget $widget The widget. @return string The widget.
[ "Function", "for", "pre", "-", "loading", "the", "tiny", "mce", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L164-L195
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.getUniqueId
protected function getUniqueId($propertyName) { $inputProvider = $this->getEnvironment()->getInputProvider(); $sessionStorage = $this->getEnvironment()->getSessionStorage(); $selector = 'ctrl_' . $propertyName; if (('select' !== $inputProvider->getParameter('act')) || (false === $inputProvider->hasValue('edit') && false === $inputProvider->hasValue('edit_save')) ) { return $selector; } $modelId = ModelId::fromModel($this->model); $fields = $sessionStorage->get($modelId->getDataProviderName() . '.edit')['properties']; $fieldId = new ModelId('property.' . $modelId->getDataProviderName(), $propertyName); if (!\in_array($fieldId->getSerialized(), $fields)) { return $selector; } $selector = 'ctrl_' . \str_replace('::', '____', $modelId->getSerialized()) . '_' . $propertyName; return $selector; }
php
protected function getUniqueId($propertyName) { $inputProvider = $this->getEnvironment()->getInputProvider(); $sessionStorage = $this->getEnvironment()->getSessionStorage(); $selector = 'ctrl_' . $propertyName; if (('select' !== $inputProvider->getParameter('act')) || (false === $inputProvider->hasValue('edit') && false === $inputProvider->hasValue('edit_save')) ) { return $selector; } $modelId = ModelId::fromModel($this->model); $fields = $sessionStorage->get($modelId->getDataProviderName() . '.edit')['properties']; $fieldId = new ModelId('property.' . $modelId->getDataProviderName(), $propertyName); if (!\in_array($fieldId->getSerialized(), $fields)) { return $selector; } $selector = 'ctrl_' . \str_replace('::', '____', $modelId->getSerialized()) . '_' . $propertyName; return $selector; }
[ "protected", "function", "getUniqueId", "(", "$", "propertyName", ")", "{", "$", "inputProvider", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "(", ")", ";", "$", "sessionStorage", "=", "$", "this", "->", "getEnvironment", "(...
Get the unique id. @param string $propertyName The property name. @return string
[ "Get", "the", "unique", "id", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L204-L228
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.getWidget
public function getWidget($property, PropertyValueBag $inputValues = null) { $environment = $this->getEnvironment(); $propertyDefinitions = $environment->getDataDefinition()->getPropertiesDefinition(); if (!$propertyDefinitions->hasProperty($property)) { throw new DcGeneralInvalidArgumentException( 'Property ' . $property . ' is not defined in propertyDefinitions.' ); } $model = clone $this->model; $model->setId($this->model->getId()); if ($inputValues) { $values = new PropertyValueBag($inputValues->getArrayCopy()); $this->environment->getController()->updateModelFromPropertyBag($model, $values); } $event = new BuildWidgetEvent($environment, $model, $propertyDefinitions->getProperty($property)); $environment->getEventDispatcher()->dispatch($event::NAME, $event); if (!$event->getWidget()) { throw new DcGeneralRuntimeException( \sprintf('Widget was not build for property %s::%s.', $this->model->getProviderName(), $property) ); } return $event->getWidget(); }
php
public function getWidget($property, PropertyValueBag $inputValues = null) { $environment = $this->getEnvironment(); $propertyDefinitions = $environment->getDataDefinition()->getPropertiesDefinition(); if (!$propertyDefinitions->hasProperty($property)) { throw new DcGeneralInvalidArgumentException( 'Property ' . $property . ' is not defined in propertyDefinitions.' ); } $model = clone $this->model; $model->setId($this->model->getId()); if ($inputValues) { $values = new PropertyValueBag($inputValues->getArrayCopy()); $this->environment->getController()->updateModelFromPropertyBag($model, $values); } $event = new BuildWidgetEvent($environment, $model, $propertyDefinitions->getProperty($property)); $environment->getEventDispatcher()->dispatch($event::NAME, $event); if (!$event->getWidget()) { throw new DcGeneralRuntimeException( \sprintf('Widget was not build for property %s::%s.', $this->model->getProviderName(), $property) ); } return $event->getWidget(); }
[ "public", "function", "getWidget", "(", "$", "property", ",", "PropertyValueBag", "$", "inputValues", "=", "null", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "propertyDefinitions", "=", "$", "environment", "->...
Retrieve the instance of a widget for the given property. @param string $property Name of the property for which the widget shall be retrieved. @param PropertyValueBag $inputValues The input values to use (optional). @return Widget @throws DcGeneralRuntimeException When No widget could be build. @throws DcGeneralInvalidArgumentException When property is not defined in the property definitions. @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Retrieve", "the", "instance", "of", "a", "widget", "for", "the", "given", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L244-L273
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.buildDatePicker
protected function buildDatePicker($objWidget) { $translator = $this->getEnvironment()->getTranslator(); $strFormat = $GLOBALS['TL_CONFIG'][$objWidget->rgxp . 'Format']; switch ($objWidget->rgxp) { case 'datim': $time = ",\n timePicker:true"; break; case 'time': $time = ",\n pickOnly:\"time\""; break; default: $time = ''; } return 'new Picker.Date($$("#ctrl_' . $objWidget->id . '"), { draggable:false, toggle:$$("#toggle_' . $objWidget->id . '"), format:"' . Date::formatToJs($strFormat) . '", positionOffset:{x:-197,y:-182}' . $time . ', pickerClass:"datepicker_bootstrap", useFadeInOut:!Browser.ie, startDay:' . $translator->translate('weekOffset', 'MSC') . ', titleFormat:"' . $translator->translate('titleFormat', 'MSC') . '" });'; }
php
protected function buildDatePicker($objWidget) { $translator = $this->getEnvironment()->getTranslator(); $strFormat = $GLOBALS['TL_CONFIG'][$objWidget->rgxp . 'Format']; switch ($objWidget->rgxp) { case 'datim': $time = ",\n timePicker:true"; break; case 'time': $time = ",\n pickOnly:\"time\""; break; default: $time = ''; } return 'new Picker.Date($$("#ctrl_' . $objWidget->id . '"), { draggable:false, toggle:$$("#toggle_' . $objWidget->id . '"), format:"' . Date::formatToJs($strFormat) . '", positionOffset:{x:-197,y:-182}' . $time . ', pickerClass:"datepicker_bootstrap", useFadeInOut:!Browser.ie, startDay:' . $translator->translate('weekOffset', 'MSC') . ', titleFormat:"' . $translator->translate('titleFormat', 'MSC') . '" });'; }
[ "protected", "function", "buildDatePicker", "(", "$", "objWidget", ")", "{", "$", "translator", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getTranslator", "(", ")", ";", "$", "strFormat", "=", "$", "GLOBALS", "[", "'TL_CONFIG'", "]", "[", ...
Build the date picker string. @param Widget $objWidget The widget instance to generate the date picker string for. @return string @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Build", "the", "date", "picker", "string", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L285-L312
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.generateHelpText
protected function generateHelpText($property) { $propInfo = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition()->getProperty($property); $label = $propInfo->getDescription(); $widgetType = $propInfo->getWidgetType(); if (null === $label || ('password' === $widgetType) || !\is_string($label) || !$GLOBALS['TL_CONFIG']['showHelp'] ) { return ''; } return '<p class="tl_help tl_tip">' . $label . '</p>'; }
php
protected function generateHelpText($property) { $propInfo = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition()->getProperty($property); $label = $propInfo->getDescription(); $widgetType = $propInfo->getWidgetType(); if (null === $label || ('password' === $widgetType) || !\is_string($label) || !$GLOBALS['TL_CONFIG']['showHelp'] ) { return ''; } return '<p class="tl_help tl_tip">' . $label . '</p>'; }
[ "protected", "function", "generateHelpText", "(", "$", "property", ")", "{", "$", "propInfo", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", "->", "getProperty", "(", "$", "...
Generate the help msg for a property. @param string $property The name of the property. @return string @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Generate", "the", "help", "msg", "for", "a", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L324-L339
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.renderWidget
public function renderWidget($property, $ignoreErrors = false, PropertyValueBag $inputValues = null) { /** @var Widget $widget */ $widget = $this->getWidget($property, $inputValues); if (!$widget) { throw new DcGeneralRuntimeException('No widget for property ' . $property); } $this->cleanErrors($widget, $ignoreErrors); $this->widgetAddError($property, $widget, $inputValues, $ignoreErrors); $propInfo = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition()->getProperty($property); $content = (new ContaoBackendViewTemplate('dcbe_general_field')) ->set('strName', $property) ->set('strClass', $widget->tl_class) ->set('widget', $widget->parse()) ->set('hasErrors', $widget->hasErrors()) ->set('strDatepicker', $this->getDatePicker($propInfo->getExtra(), $widget)) // We used the var blnUpdate before. ->set('blnUpdate', false) ->set('strHelp', $this->generateHelpText($property)) ->set('strId', $widget->id) ->parse(); return $this->loadRichTextEditor($content, $widget); }
php
public function renderWidget($property, $ignoreErrors = false, PropertyValueBag $inputValues = null) { /** @var Widget $widget */ $widget = $this->getWidget($property, $inputValues); if (!$widget) { throw new DcGeneralRuntimeException('No widget for property ' . $property); } $this->cleanErrors($widget, $ignoreErrors); $this->widgetAddError($property, $widget, $inputValues, $ignoreErrors); $propInfo = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition()->getProperty($property); $content = (new ContaoBackendViewTemplate('dcbe_general_field')) ->set('strName', $property) ->set('strClass', $widget->tl_class) ->set('widget', $widget->parse()) ->set('hasErrors', $widget->hasErrors()) ->set('strDatepicker', $this->getDatePicker($propInfo->getExtra(), $widget)) // We used the var blnUpdate before. ->set('blnUpdate', false) ->set('strHelp', $this->generateHelpText($property)) ->set('strId', $widget->id) ->parse(); return $this->loadRichTextEditor($content, $widget); }
[ "public", "function", "renderWidget", "(", "$", "property", ",", "$", "ignoreErrors", "=", "false", ",", "PropertyValueBag", "$", "inputValues", "=", "null", ")", "{", "/** @var Widget $widget */", "$", "widget", "=", "$", "this", "->", "getWidget", "(", "$", ...
Render the widget for the named property. @param string $property The name of the property for which the widget shall be rendered. @param bool $ignoreErrors Flag if the error property of the widget shall get cleared prior rendering. @param PropertyValueBag $inputValues The input values to use (optional). @return string @throws DcGeneralRuntimeException For unknown properties.
[ "Render", "the", "widget", "for", "the", "named", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L352-L377
train