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
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.cleanErrors
protected function cleanErrors(Widget $widget, $ignoreErrors = false) { if (!$ignoreErrors) { return; } // Clean the errors array and fix up the CSS class. $reflectionPropError = new \ReflectionProperty(\get_class($widget), 'arrErrors'); $reflectionPropError->setAccessible(true); $reflectionPropError->setValue($widget, []); $reflectionPropClass = new \ReflectionProperty(\get_class($widget), 'strClass'); $reflectionPropClass->setAccessible(true); $reflectionPropClass->setValue($widget, \str_replace('error', '', $reflectionPropClass->getValue($widget))); }
php
protected function cleanErrors(Widget $widget, $ignoreErrors = false) { if (!$ignoreErrors) { return; } // Clean the errors array and fix up the CSS class. $reflectionPropError = new \ReflectionProperty(\get_class($widget), 'arrErrors'); $reflectionPropError->setAccessible(true); $reflectionPropError->setValue($widget, []); $reflectionPropClass = new \ReflectionProperty(\get_class($widget), 'strClass'); $reflectionPropClass->setAccessible(true); $reflectionPropClass->setValue($widget, \str_replace('error', '', $reflectionPropClass->getValue($widget))); }
[ "protected", "function", "cleanErrors", "(", "Widget", "$", "widget", ",", "$", "ignoreErrors", "=", "false", ")", "{", "if", "(", "!", "$", "ignoreErrors", ")", "{", "return", ";", "}", "// Clean the errors array and fix up the CSS class.", "$", "reflectionPropError", "=", "new", "\\", "ReflectionProperty", "(", "\\", "get_class", "(", "$", "widget", ")", ",", "'arrErrors'", ")", ";", "$", "reflectionPropError", "->", "setAccessible", "(", "true", ")", ";", "$", "reflectionPropError", "->", "setValue", "(", "$", "widget", ",", "[", "]", ")", ";", "$", "reflectionPropClass", "=", "new", "\\", "ReflectionProperty", "(", "\\", "get_class", "(", "$", "widget", ")", ",", "'strClass'", ")", ";", "$", "reflectionPropClass", "->", "setAccessible", "(", "true", ")", ";", "$", "reflectionPropClass", "->", "setValue", "(", "$", "widget", ",", "\\", "str_replace", "(", "'error'", ",", "''", ",", "$", "reflectionPropClass", "->", "getValue", "(", "$", "widget", ")", ")", ")", ";", "}" ]
Clean errors for widget. @param Widget $widget The widget. @param bool $ignoreErrors The flag for errors cleared. @return void
[ "Clean", "errors", "for", "widget", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L461-L475
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
ContaoWidgetManager.widgetAddError
protected function widgetAddError( $property, Widget $widget, PropertyValueBagInterface $inputValues = null, $ignoreErrors = false ) { if (!(!$ignoreErrors && $inputValues && $inputValues->hasPropertyValue($property) && $inputValues->isPropertyValueInvalid($property)) ) { return; } foreach ($inputValues->getPropertyValueErrors($property) as $error) { $widget->addError($error); } }
php
protected function widgetAddError( $property, Widget $widget, PropertyValueBagInterface $inputValues = null, $ignoreErrors = false ) { if (!(!$ignoreErrors && $inputValues && $inputValues->hasPropertyValue($property) && $inputValues->isPropertyValueInvalid($property)) ) { return; } foreach ($inputValues->getPropertyValueErrors($property) as $error) { $widget->addError($error); } }
[ "protected", "function", "widgetAddError", "(", "$", "property", ",", "Widget", "$", "widget", ",", "PropertyValueBagInterface", "$", "inputValues", "=", "null", ",", "$", "ignoreErrors", "=", "false", ")", "{", "if", "(", "!", "(", "!", "$", "ignoreErrors", "&&", "$", "inputValues", "&&", "$", "inputValues", "->", "hasPropertyValue", "(", "$", "property", ")", "&&", "$", "inputValues", "->", "isPropertyValueInvalid", "(", "$", "property", ")", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "inputValues", "->", "getPropertyValueErrors", "(", "$", "property", ")", "as", "$", "error", ")", "{", "$", "widget", "->", "addError", "(", "$", "error", ")", ";", "}", "}" ]
Widget add error. @param string $property The property. @param Widget $widget The widget. @param PropertyValueBagInterface|null $inputValues The input values. @param bool $ignoreErrors The for add error. @return void
[ "Widget", "add", "error", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoWidgetManager.php#L487-L502
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseCallback
protected function parseCallback($dispatcher, $callbacks, $eventName, $arguments, $listener) { if (!(\is_array($callbacks) || \is_callable($callbacks))) { return; } // If only one callback given, ensure the loop below handles it correctly. if (\is_array($callbacks) && (2 === \count($callbacks)) && !\is_array($callbacks[0])) { $callbacks = [$callbacks]; } foreach ((array) $callbacks as $callback) { if ($this->isCallbackBlacklisted($callback, $listener)) { continue; } $dispatcher->addListener( $eventName, new $listener($callback, $arguments) ); } }
php
protected function parseCallback($dispatcher, $callbacks, $eventName, $arguments, $listener) { if (!(\is_array($callbacks) || \is_callable($callbacks))) { return; } // If only one callback given, ensure the loop below handles it correctly. if (\is_array($callbacks) && (2 === \count($callbacks)) && !\is_array($callbacks[0])) { $callbacks = [$callbacks]; } foreach ((array) $callbacks as $callback) { if ($this->isCallbackBlacklisted($callback, $listener)) { continue; } $dispatcher->addListener( $eventName, new $listener($callback, $arguments) ); } }
[ "protected", "function", "parseCallback", "(", "$", "dispatcher", ",", "$", "callbacks", ",", "$", "eventName", ",", "$", "arguments", ",", "$", "listener", ")", "{", "if", "(", "!", "(", "\\", "is_array", "(", "$", "callbacks", ")", "||", "\\", "is_callable", "(", "$", "callbacks", ")", ")", ")", "{", "return", ";", "}", "// If only one callback given, ensure the loop below handles it correctly.", "if", "(", "\\", "is_array", "(", "$", "callbacks", ")", "&&", "(", "2", "===", "\\", "count", "(", "$", "callbacks", ")", ")", "&&", "!", "\\", "is_array", "(", "$", "callbacks", "[", "0", "]", ")", ")", "{", "$", "callbacks", "=", "[", "$", "callbacks", "]", ";", "}", "foreach", "(", "(", "array", ")", "$", "callbacks", "as", "$", "callback", ")", "{", "if", "(", "$", "this", "->", "isCallbackBlacklisted", "(", "$", "callback", ",", "$", "listener", ")", ")", "{", "continue", ";", "}", "$", "dispatcher", "->", "addListener", "(", "$", "eventName", ",", "new", "$", "listener", "(", "$", "callback", ",", "$", "arguments", ")", ")", ";", "}", "}" ]
Register the callback handlers for the given legacy callbacks. @param EventDispatcherInterface $dispatcher The event dispatcher. @param array $callbacks The callbacks to be handled. @param string $eventName The event to be registered to. @param array $arguments The arguments to pass to the constructor. @param string $listener The listener class to use. @return void
[ "Register", "the", "callback", "handlers", "for", "the", "given", "legacy", "callbacks", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L150-L170
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.isCallbackBlacklisted
private function isCallbackBlacklisted($callback, $listener) { return ((ContainerOnLoadCallbackListener::class === $listener) && \is_array($callback) && ('checkPermission' === $callback[1]) && (0 === strpos($callback[0], 'tl_'))); }
php
private function isCallbackBlacklisted($callback, $listener) { return ((ContainerOnLoadCallbackListener::class === $listener) && \is_array($callback) && ('checkPermission' === $callback[1]) && (0 === strpos($callback[0], 'tl_'))); }
[ "private", "function", "isCallbackBlacklisted", "(", "$", "callback", ",", "$", "listener", ")", "{", "return", "(", "(", "ContainerOnLoadCallbackListener", "::", "class", "===", "$", "listener", ")", "&&", "\\", "is_array", "(", "$", "callback", ")", "&&", "(", "'checkPermission'", "===", "$", "callback", "[", "1", "]", ")", "&&", "(", "0", "===", "strpos", "(", "$", "callback", "[", "0", "]", ",", "'tl_'", ")", ")", ")", ";", "}" ]
Check if callback is blacklisted. @param mixed $callback The callback. @param string $listener The listener class. @return bool
[ "Check", "if", "callback", "is", "blacklisted", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L180-L186
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseBasicMode
protected function parseBasicMode(BasicDefinitionInterface $config) { if (null !== $config->getMode()) { return; } switch ($this->getFromDca('list/sorting/mode')) { case 0: // Records are not sorted. case 1: // Records are sorted by a fixed field. case 2: // Records are sorted by a switchable field. case 3: // Records are sorted by the parent table. $config->setMode(BasicDefinitionInterface::MODE_FLAT); break; case 4: // Displays the child records of a parent record (see style sheets module). $config->setMode(BasicDefinitionInterface::MODE_PARENTEDLIST); break; case 5: // Records are displayed as tree (see site structure). case 6: // Displays the child records within a tree structure (see articles module). $config->setMode(BasicDefinitionInterface::MODE_HIERARCHICAL); break; default: } }
php
protected function parseBasicMode(BasicDefinitionInterface $config) { if (null !== $config->getMode()) { return; } switch ($this->getFromDca('list/sorting/mode')) { case 0: // Records are not sorted. case 1: // Records are sorted by a fixed field. case 2: // Records are sorted by a switchable field. case 3: // Records are sorted by the parent table. $config->setMode(BasicDefinitionInterface::MODE_FLAT); break; case 4: // Displays the child records of a parent record (see style sheets module). $config->setMode(BasicDefinitionInterface::MODE_PARENTEDLIST); break; case 5: // Records are displayed as tree (see site structure). case 6: // Displays the child records within a tree structure (see articles module). $config->setMode(BasicDefinitionInterface::MODE_HIERARCHICAL); break; default: } }
[ "protected", "function", "parseBasicMode", "(", "BasicDefinitionInterface", "$", "config", ")", "{", "if", "(", "null", "!==", "$", "config", "->", "getMode", "(", ")", ")", "{", "return", ";", "}", "switch", "(", "$", "this", "->", "getFromDca", "(", "'list/sorting/mode'", ")", ")", "{", "case", "0", ":", "// Records are not sorted.", "case", "1", ":", "// Records are sorted by a fixed field.", "case", "2", ":", "// Records are sorted by a switchable field.", "case", "3", ":", "// Records are sorted by the parent table.", "$", "config", "->", "setMode", "(", "BasicDefinitionInterface", "::", "MODE_FLAT", ")", ";", "break", ";", "case", "4", ":", "// Displays the child records of a parent record (see style sheets module).", "$", "config", "->", "setMode", "(", "BasicDefinitionInterface", "::", "MODE_PARENTEDLIST", ")", ";", "break", ";", "case", "5", ":", "// Records are displayed as tree (see site structure).", "case", "6", ":", "// Displays the child records within a tree structure (see articles module).", "$", "config", "->", "setMode", "(", "BasicDefinitionInterface", "::", "MODE_HIERARCHICAL", ")", ";", "break", ";", "default", ":", "}", "}" ]
Parse the mode, flat, parented or hierarchical. @param BasicDefinitionInterface $config The basic definition of the data definition. @return void
[ "Parse", "the", "mode", "flat", "parented", "or", "hierarchical", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L343-L372
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseBasicFlags
protected function parseBasicFlags(BasicDefinitionInterface $config) { if (null !== ($switchToEdit = $this->getFromDca('config/switchToEdit'))) { $config->setSwitchToEditEnabled((bool) $switchToEdit); } if (null !== ($value = $this->getFromDca('config/forceEdit'))) { $config->setEditOnlyMode((bool) $value); } if (null !== ($value = $this->getFromDca('config/closed'))) { $config ->setEditable(!$value) ->setCreatable(!$value); } if (null !== ($value = $this->getFromDca('config/notEditable'))) { $config->setEditable(!$value); } if (null !== ($value = $this->getFromDca('config/notDeletable'))) { $config->setDeletable(!$value); } if (null !== ($value = $this->getFromDca('config/notCreatable'))) { $config->setCreatable(!(bool) $value); } if (null !== ($value = $this->getFromDca('config/dynamicPtable'))) { $config->setDynamicParentTable((bool) $value); } }
php
protected function parseBasicFlags(BasicDefinitionInterface $config) { if (null !== ($switchToEdit = $this->getFromDca('config/switchToEdit'))) { $config->setSwitchToEditEnabled((bool) $switchToEdit); } if (null !== ($value = $this->getFromDca('config/forceEdit'))) { $config->setEditOnlyMode((bool) $value); } if (null !== ($value = $this->getFromDca('config/closed'))) { $config ->setEditable(!$value) ->setCreatable(!$value); } if (null !== ($value = $this->getFromDca('config/notEditable'))) { $config->setEditable(!$value); } if (null !== ($value = $this->getFromDca('config/notDeletable'))) { $config->setDeletable(!$value); } if (null !== ($value = $this->getFromDca('config/notCreatable'))) { $config->setCreatable(!(bool) $value); } if (null !== ($value = $this->getFromDca('config/dynamicPtable'))) { $config->setDynamicParentTable((bool) $value); } }
[ "protected", "function", "parseBasicFlags", "(", "BasicDefinitionInterface", "$", "config", ")", "{", "if", "(", "null", "!==", "(", "$", "switchToEdit", "=", "$", "this", "->", "getFromDca", "(", "'config/switchToEdit'", ")", ")", ")", "{", "$", "config", "->", "setSwitchToEditEnabled", "(", "(", "bool", ")", "$", "switchToEdit", ")", ";", "}", "if", "(", "null", "!==", "(", "$", "value", "=", "$", "this", "->", "getFromDca", "(", "'config/forceEdit'", ")", ")", ")", "{", "$", "config", "->", "setEditOnlyMode", "(", "(", "bool", ")", "$", "value", ")", ";", "}", "if", "(", "null", "!==", "(", "$", "value", "=", "$", "this", "->", "getFromDca", "(", "'config/closed'", ")", ")", ")", "{", "$", "config", "->", "setEditable", "(", "!", "$", "value", ")", "->", "setCreatable", "(", "!", "$", "value", ")", ";", "}", "if", "(", "null", "!==", "(", "$", "value", "=", "$", "this", "->", "getFromDca", "(", "'config/notEditable'", ")", ")", ")", "{", "$", "config", "->", "setEditable", "(", "!", "$", "value", ")", ";", "}", "if", "(", "null", "!==", "(", "$", "value", "=", "$", "this", "->", "getFromDca", "(", "'config/notDeletable'", ")", ")", ")", "{", "$", "config", "->", "setDeletable", "(", "!", "$", "value", ")", ";", "}", "if", "(", "null", "!==", "(", "$", "value", "=", "$", "this", "->", "getFromDca", "(", "'config/notCreatable'", ")", ")", ")", "{", "$", "config", "->", "setCreatable", "(", "!", "(", "bool", ")", "$", "value", ")", ";", "}", "if", "(", "null", "!==", "(", "$", "value", "=", "$", "this", "->", "getFromDca", "(", "'config/dynamicPtable'", ")", ")", ")", "{", "$", "config", "->", "setDynamicParentTable", "(", "(", "bool", ")", "$", "value", ")", ";", "}", "}" ]
Parse the basic flags. @param BasicDefinitionInterface $config The basic definition of the data definition. @return void
[ "Parse", "the", "basic", "flags", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L381-L412
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseRootEntries
protected function parseRootEntries(ContainerInterface $container) { if (\is_array($root = $this->getFromDca('list/sorting/root'))) { $entries = $container->getBasicDefinition()->getRootEntries(); $container->getBasicDefinition()->setRootEntries(\array_merge($entries, $root)); } }
php
protected function parseRootEntries(ContainerInterface $container) { if (\is_array($root = $this->getFromDca('list/sorting/root'))) { $entries = $container->getBasicDefinition()->getRootEntries(); $container->getBasicDefinition()->setRootEntries(\array_merge($entries, $root)); } }
[ "protected", "function", "parseRootEntries", "(", "ContainerInterface", "$", "container", ")", "{", "if", "(", "\\", "is_array", "(", "$", "root", "=", "$", "this", "->", "getFromDca", "(", "'list/sorting/root'", ")", ")", ")", "{", "$", "entries", "=", "$", "container", "->", "getBasicDefinition", "(", ")", "->", "getRootEntries", "(", ")", ";", "$", "container", "->", "getBasicDefinition", "(", ")", "->", "setRootEntries", "(", "\\", "array_merge", "(", "$", "entries", ",", "$", "root", ")", ")", ";", "}", "}" ]
This method parses the root entries definition. @param ContainerInterface $container The container where the data shall be stored. @return void
[ "This", "method", "parses", "the", "root", "entries", "definition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L552-L559
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.getRootProviderName
protected function getRootProviderName(ContainerInterface $container) { $rootProvider = $container->getBasicDefinition()->getRootDataProvider(); if (!$rootProvider) { throw new DcGeneralRuntimeException( 'Root data provider name not specified in DCA but rootEntries section specified.' ); } if (!$container->getDataProviderDefinition()->hasInformation($rootProvider)) { throw new DcGeneralRuntimeException('Unknown root data provider but rootEntries section specified.'); } return $rootProvider; }
php
protected function getRootProviderName(ContainerInterface $container) { $rootProvider = $container->getBasicDefinition()->getRootDataProvider(); if (!$rootProvider) { throw new DcGeneralRuntimeException( 'Root data provider name not specified in DCA but rootEntries section specified.' ); } if (!$container->getDataProviderDefinition()->hasInformation($rootProvider)) { throw new DcGeneralRuntimeException('Unknown root data provider but rootEntries section specified.'); } return $rootProvider; }
[ "protected", "function", "getRootProviderName", "(", "ContainerInterface", "$", "container", ")", "{", "$", "rootProvider", "=", "$", "container", "->", "getBasicDefinition", "(", ")", "->", "getRootDataProvider", "(", ")", ";", "if", "(", "!", "$", "rootProvider", ")", "{", "throw", "new", "DcGeneralRuntimeException", "(", "'Root data provider name not specified in DCA but rootEntries section specified.'", ")", ";", "}", "if", "(", "!", "$", "container", "->", "getDataProviderDefinition", "(", ")", "->", "hasInformation", "(", "$", "rootProvider", ")", ")", "{", "throw", "new", "DcGeneralRuntimeException", "(", "'Unknown root data provider but rootEntries section specified.'", ")", ";", "}", "return", "$", "rootProvider", ";", "}" ]
Determine the root provider name from the container. @param ContainerInterface $container The container from where the name shall be retrieved. @return string @throws DcGeneralRuntimeException If the root provider can not be determined.
[ "Determine", "the", "root", "provider", "name", "from", "the", "container", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L570-L585
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseParentChildConditions
protected function parseParentChildConditions(ContainerInterface $container) { if ($container->hasDefinition(ModelRelationshipDefinitionInterface::NAME)) { $definition = $container->getDefinition(ModelRelationshipDefinitionInterface::NAME); } else { $definition = new DefaultModelRelationshipDefinition(); } // If mode is 5, we need to define tree view. if (5 === $this->getFromDca('list/sorting/mode')) { $rootProvider = $this->getRootProviderName($container); if (null === ($relationship = $definition->getRootCondition())) { $relationship = new RootCondition(); $relationship ->setSourceName($rootProvider); $definition->setRootCondition($relationship); $builder = FilterBuilder::fromArrayForRoot()->getFilter(); } else { $builder = FilterBuilder::fromArrayForRoot($relationship->getFilterArray())->getFilter(); } $relationship ->setSetters( \array_merge_recursive( [['property' => 'pid', 'value' => '0']] ), $relationship->getSetters() ); $builder->andPropertyEquals('pid', '0'); $relationship ->setFilterArray($builder->getAllAsArray()); if (null === ($relationship = $definition->getChildCondition($rootProvider, $rootProvider))) { $relationship = new ParentChildCondition(); $relationship ->setSourceName($rootProvider) ->setDestinationName($rootProvider); $definition->addChildCondition($relationship); $builder = FilterBuilder::fromArray()->getFilter(); } else { $builder = FilterBuilder::fromArray($relationship->getFilterArray())->getFilter(); } $relationship ->setSetters( \array_merge_recursive( [['to_field' => 'pid', 'from_field' => 'id']] ), $relationship->getSetters() ); $builder->andRemotePropertyEquals('pid', 'id'); $relationship ->setFilterArray($builder->getAllAsArray()); $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition); } // If ptable defined and no root setter we need to add (Contao default id=>pid mapping). if (null !== $this->getFromDca('config/ptable')) { $rootProvider = $this->getRootProviderName($container); if (null === ($relationship = $definition->getRootCondition())) { $relationship = new RootCondition(); $relationship ->setSourceName($rootProvider); $definition->setRootCondition($relationship); } if (!$relationship->getSetters()) { $relationship ->setSetters( \array_merge_recursive( [['property' => 'pid', 'value' => '0']] ), $relationship->getSetters() ); } $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition); } }
php
protected function parseParentChildConditions(ContainerInterface $container) { if ($container->hasDefinition(ModelRelationshipDefinitionInterface::NAME)) { $definition = $container->getDefinition(ModelRelationshipDefinitionInterface::NAME); } else { $definition = new DefaultModelRelationshipDefinition(); } // If mode is 5, we need to define tree view. if (5 === $this->getFromDca('list/sorting/mode')) { $rootProvider = $this->getRootProviderName($container); if (null === ($relationship = $definition->getRootCondition())) { $relationship = new RootCondition(); $relationship ->setSourceName($rootProvider); $definition->setRootCondition($relationship); $builder = FilterBuilder::fromArrayForRoot()->getFilter(); } else { $builder = FilterBuilder::fromArrayForRoot($relationship->getFilterArray())->getFilter(); } $relationship ->setSetters( \array_merge_recursive( [['property' => 'pid', 'value' => '0']] ), $relationship->getSetters() ); $builder->andPropertyEquals('pid', '0'); $relationship ->setFilterArray($builder->getAllAsArray()); if (null === ($relationship = $definition->getChildCondition($rootProvider, $rootProvider))) { $relationship = new ParentChildCondition(); $relationship ->setSourceName($rootProvider) ->setDestinationName($rootProvider); $definition->addChildCondition($relationship); $builder = FilterBuilder::fromArray()->getFilter(); } else { $builder = FilterBuilder::fromArray($relationship->getFilterArray())->getFilter(); } $relationship ->setSetters( \array_merge_recursive( [['to_field' => 'pid', 'from_field' => 'id']] ), $relationship->getSetters() ); $builder->andRemotePropertyEquals('pid', 'id'); $relationship ->setFilterArray($builder->getAllAsArray()); $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition); } // If ptable defined and no root setter we need to add (Contao default id=>pid mapping). if (null !== $this->getFromDca('config/ptable')) { $rootProvider = $this->getRootProviderName($container); if (null === ($relationship = $definition->getRootCondition())) { $relationship = new RootCondition(); $relationship ->setSourceName($rootProvider); $definition->setRootCondition($relationship); } if (!$relationship->getSetters()) { $relationship ->setSetters( \array_merge_recursive( [['property' => 'pid', 'value' => '0']] ), $relationship->getSetters() ); } $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition); } }
[ "protected", "function", "parseParentChildConditions", "(", "ContainerInterface", "$", "container", ")", "{", "if", "(", "$", "container", "->", "hasDefinition", "(", "ModelRelationshipDefinitionInterface", "::", "NAME", ")", ")", "{", "$", "definition", "=", "$", "container", "->", "getDefinition", "(", "ModelRelationshipDefinitionInterface", "::", "NAME", ")", ";", "}", "else", "{", "$", "definition", "=", "new", "DefaultModelRelationshipDefinition", "(", ")", ";", "}", "// If mode is 5, we need to define tree view.", "if", "(", "5", "===", "$", "this", "->", "getFromDca", "(", "'list/sorting/mode'", ")", ")", "{", "$", "rootProvider", "=", "$", "this", "->", "getRootProviderName", "(", "$", "container", ")", ";", "if", "(", "null", "===", "(", "$", "relationship", "=", "$", "definition", "->", "getRootCondition", "(", ")", ")", ")", "{", "$", "relationship", "=", "new", "RootCondition", "(", ")", ";", "$", "relationship", "->", "setSourceName", "(", "$", "rootProvider", ")", ";", "$", "definition", "->", "setRootCondition", "(", "$", "relationship", ")", ";", "$", "builder", "=", "FilterBuilder", "::", "fromArrayForRoot", "(", ")", "->", "getFilter", "(", ")", ";", "}", "else", "{", "$", "builder", "=", "FilterBuilder", "::", "fromArrayForRoot", "(", "$", "relationship", "->", "getFilterArray", "(", ")", ")", "->", "getFilter", "(", ")", ";", "}", "$", "relationship", "->", "setSetters", "(", "\\", "array_merge_recursive", "(", "[", "[", "'property'", "=>", "'pid'", ",", "'value'", "=>", "'0'", "]", "]", ")", ",", "$", "relationship", "->", "getSetters", "(", ")", ")", ";", "$", "builder", "->", "andPropertyEquals", "(", "'pid'", ",", "'0'", ")", ";", "$", "relationship", "->", "setFilterArray", "(", "$", "builder", "->", "getAllAsArray", "(", ")", ")", ";", "if", "(", "null", "===", "(", "$", "relationship", "=", "$", "definition", "->", "getChildCondition", "(", "$", "rootProvider", ",", "$", "rootProvider", ")", ")", ")", "{", "$", "relationship", "=", "new", "ParentChildCondition", "(", ")", ";", "$", "relationship", "->", "setSourceName", "(", "$", "rootProvider", ")", "->", "setDestinationName", "(", "$", "rootProvider", ")", ";", "$", "definition", "->", "addChildCondition", "(", "$", "relationship", ")", ";", "$", "builder", "=", "FilterBuilder", "::", "fromArray", "(", ")", "->", "getFilter", "(", ")", ";", "}", "else", "{", "$", "builder", "=", "FilterBuilder", "::", "fromArray", "(", "$", "relationship", "->", "getFilterArray", "(", ")", ")", "->", "getFilter", "(", ")", ";", "}", "$", "relationship", "->", "setSetters", "(", "\\", "array_merge_recursive", "(", "[", "[", "'to_field'", "=>", "'pid'", ",", "'from_field'", "=>", "'id'", "]", "]", ")", ",", "$", "relationship", "->", "getSetters", "(", ")", ")", ";", "$", "builder", "->", "andRemotePropertyEquals", "(", "'pid'", ",", "'id'", ")", ";", "$", "relationship", "->", "setFilterArray", "(", "$", "builder", "->", "getAllAsArray", "(", ")", ")", ";", "$", "container", "->", "setDefinition", "(", "ModelRelationshipDefinitionInterface", "::", "NAME", ",", "$", "definition", ")", ";", "}", "// If ptable defined and no root setter we need to add (Contao default id=>pid mapping).", "if", "(", "null", "!==", "$", "this", "->", "getFromDca", "(", "'config/ptable'", ")", ")", "{", "$", "rootProvider", "=", "$", "this", "->", "getRootProviderName", "(", "$", "container", ")", ";", "if", "(", "null", "===", "(", "$", "relationship", "=", "$", "definition", "->", "getRootCondition", "(", ")", ")", ")", "{", "$", "relationship", "=", "new", "RootCondition", "(", ")", ";", "$", "relationship", "->", "setSourceName", "(", "$", "rootProvider", ")", ";", "$", "definition", "->", "setRootCondition", "(", "$", "relationship", ")", ";", "}", "if", "(", "!", "$", "relationship", "->", "getSetters", "(", ")", ")", "{", "$", "relationship", "->", "setSetters", "(", "\\", "array_merge_recursive", "(", "[", "[", "'property'", "=>", "'pid'", ",", "'value'", "=>", "'0'", "]", "]", ")", ",", "$", "relationship", "->", "getSetters", "(", ")", ")", ";", "}", "$", "container", "->", "setDefinition", "(", "ModelRelationshipDefinitionInterface", "::", "NAME", ",", "$", "definition", ")", ";", "}", "}" ]
This method parses the parent-child conditions. @param ContainerInterface $container The container where the data shall be stored. @return void
[ "This", "method", "parses", "the", "parent", "-", "child", "conditions", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L594-L681
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseListing
protected function parseListing(ContainerInterface $container, Contao2BackendViewDefinitionInterface $view) { $listing = $view->getListingConfig(); $listDca = $this->getFromDca('list'); if ((null === $listing->getRootLabel()) && (null !== ($label = $this->getFromDca('config/label')))) { $listing->setRootLabel($label); } if ((null === $listing->getRootIcon()) && (null !== ($icon = $this->getFromDca('config/icon')))) { $listing->setRootIcon($icon); } // Cancel if no list configuration found. if (!$listDca) { return []; } $parsedProperties = $this->parseListSorting($listing, $listDca); $this->parseListLabel($container, $listing, $listDca); return $parsedProperties; }
php
protected function parseListing(ContainerInterface $container, Contao2BackendViewDefinitionInterface $view) { $listing = $view->getListingConfig(); $listDca = $this->getFromDca('list'); if ((null === $listing->getRootLabel()) && (null !== ($label = $this->getFromDca('config/label')))) { $listing->setRootLabel($label); } if ((null === $listing->getRootIcon()) && (null !== ($icon = $this->getFromDca('config/icon')))) { $listing->setRootIcon($icon); } // Cancel if no list configuration found. if (!$listDca) { return []; } $parsedProperties = $this->parseListSorting($listing, $listDca); $this->parseListLabel($container, $listing, $listDca); return $parsedProperties; }
[ "protected", "function", "parseListing", "(", "ContainerInterface", "$", "container", ",", "Contao2BackendViewDefinitionInterface", "$", "view", ")", "{", "$", "listing", "=", "$", "view", "->", "getListingConfig", "(", ")", ";", "$", "listDca", "=", "$", "this", "->", "getFromDca", "(", "'list'", ")", ";", "if", "(", "(", "null", "===", "$", "listing", "->", "getRootLabel", "(", ")", ")", "&&", "(", "null", "!==", "(", "$", "label", "=", "$", "this", "->", "getFromDca", "(", "'config/label'", ")", ")", ")", ")", "{", "$", "listing", "->", "setRootLabel", "(", "$", "label", ")", ";", "}", "if", "(", "(", "null", "===", "$", "listing", "->", "getRootIcon", "(", ")", ")", "&&", "(", "null", "!==", "(", "$", "icon", "=", "$", "this", "->", "getFromDca", "(", "'config/icon'", ")", ")", ")", ")", "{", "$", "listing", "->", "setRootIcon", "(", "$", "icon", ")", ";", "}", "// Cancel if no list configuration found.", "if", "(", "!", "$", "listDca", ")", "{", "return", "[", "]", ";", "}", "$", "parsedProperties", "=", "$", "this", "->", "parseListSorting", "(", "$", "listing", ",", "$", "listDca", ")", ";", "$", "this", "->", "parseListLabel", "(", "$", "container", ",", "$", "listing", ",", "$", "listDca", ")", ";", "return", "$", "parsedProperties", ";", "}" ]
Parse the listing configuration. @param ContainerInterface $container The container where the data shall be stored. @param Contao2BackendViewDefinitionInterface $view The view information for the backend view. @return array
[ "Parse", "the", "listing", "configuration", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L723-L745
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parsePropertySortingAndGroupings
protected function parsePropertySortingAndGroupings($view, $parsedProperties) { $definitions = $view->getListingConfig()->getGroupAndSortingDefinition(); foreach ((array) $this->getFromDca('fields') as $propName => $propInfo) { $this->parsePropertySortingAndGrouping($propName, $propInfo, $definitions, $parsedProperties); } }
php
protected function parsePropertySortingAndGroupings($view, $parsedProperties) { $definitions = $view->getListingConfig()->getGroupAndSortingDefinition(); foreach ((array) $this->getFromDca('fields') as $propName => $propInfo) { $this->parsePropertySortingAndGrouping($propName, $propInfo, $definitions, $parsedProperties); } }
[ "protected", "function", "parsePropertySortingAndGroupings", "(", "$", "view", ",", "$", "parsedProperties", ")", "{", "$", "definitions", "=", "$", "view", "->", "getListingConfig", "(", ")", "->", "getGroupAndSortingDefinition", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "getFromDca", "(", "'fields'", ")", "as", "$", "propName", "=>", "$", "propInfo", ")", "{", "$", "this", "->", "parsePropertySortingAndGrouping", "(", "$", "propName", ",", "$", "propInfo", ",", "$", "definitions", ",", "$", "parsedProperties", ")", ";", "}", "}" ]
Parse the sorting and grouping information for all properties. @param Contao2BackendViewDefinitionInterface $view The view information for the backend view. @param array $parsedProperties A list of properties already parsed. @return void
[ "Parse", "the", "sorting", "and", "grouping", "information", "for", "all", "properties", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L755-L762
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parsePropertySortingAndGrouping
protected function parsePropertySortingAndGrouping($propName, $propInfo, $definitions, $parsedProperties) { if (empty($propInfo['sorting']) || \in_array($propName, $parsedProperties)) { return; } $definition = $definitions->add()->setName($propName); $information = $definition->add(); $information->setProperty($propName); if (isset($propInfo['length'])) { $information->setGroupingLength($propInfo['length']); } // Special case for field named "sorting" in Contao. if ('sorting' === $propName) { $information->setManualSorting(); } // If no default sorting and grouping definition is defined, assume the first one is default. if (!$definitions->hasDefault()) { $definitions->markDefault($definition); } $flag = empty($propInfo['flag']) ? $this->getFromDca('list/sorting/flag') : $propInfo['flag']; $this->evalFlag($information, $flag); }
php
protected function parsePropertySortingAndGrouping($propName, $propInfo, $definitions, $parsedProperties) { if (empty($propInfo['sorting']) || \in_array($propName, $parsedProperties)) { return; } $definition = $definitions->add()->setName($propName); $information = $definition->add(); $information->setProperty($propName); if (isset($propInfo['length'])) { $information->setGroupingLength($propInfo['length']); } // Special case for field named "sorting" in Contao. if ('sorting' === $propName) { $information->setManualSorting(); } // If no default sorting and grouping definition is defined, assume the first one is default. if (!$definitions->hasDefault()) { $definitions->markDefault($definition); } $flag = empty($propInfo['flag']) ? $this->getFromDca('list/sorting/flag') : $propInfo['flag']; $this->evalFlag($information, $flag); }
[ "protected", "function", "parsePropertySortingAndGrouping", "(", "$", "propName", ",", "$", "propInfo", ",", "$", "definitions", ",", "$", "parsedProperties", ")", "{", "if", "(", "empty", "(", "$", "propInfo", "[", "'sorting'", "]", ")", "||", "\\", "in_array", "(", "$", "propName", ",", "$", "parsedProperties", ")", ")", "{", "return", ";", "}", "$", "definition", "=", "$", "definitions", "->", "add", "(", ")", "->", "setName", "(", "$", "propName", ")", ";", "$", "information", "=", "$", "definition", "->", "add", "(", ")", ";", "$", "information", "->", "setProperty", "(", "$", "propName", ")", ";", "if", "(", "isset", "(", "$", "propInfo", "[", "'length'", "]", ")", ")", "{", "$", "information", "->", "setGroupingLength", "(", "$", "propInfo", "[", "'length'", "]", ")", ";", "}", "// Special case for field named \"sorting\" in Contao.", "if", "(", "'sorting'", "===", "$", "propName", ")", "{", "$", "information", "->", "setManualSorting", "(", ")", ";", "}", "// If no default sorting and grouping definition is defined, assume the first one is default.", "if", "(", "!", "$", "definitions", "->", "hasDefault", "(", ")", ")", "{", "$", "definitions", "->", "markDefault", "(", "$", "definition", ")", ";", "}", "$", "flag", "=", "empty", "(", "$", "propInfo", "[", "'flag'", "]", ")", "?", "$", "this", "->", "getFromDca", "(", "'list/sorting/flag'", ")", ":", "$", "propInfo", "[", "'flag'", "]", ";", "$", "this", "->", "evalFlag", "(", "$", "information", ",", "$", "flag", ")", ";", "}" ]
Parse the sorting and grouping information for a given property. @param string $propName The property to parse. @param array $propInfo The property information. @param GroupAndSortingDefinitionCollectionInterface $definitions The definitions. @param array $parsedProperties A list of properties already parsed. @return void
[ "Parse", "the", "sorting", "and", "grouping", "information", "for", "a", "given", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L774-L799
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parsePanelFilter
protected function parsePanelFilter(PanelRowInterface $row) { foreach ($this->getFromDca('fields') as $property => $value) { if (isset($value['filter'])) { $element = new DefaultFilterElementInformation(); $element->setPropertyName($property); if (!$row->hasElement($element->getName())) { $row->addElement($element); } } } }
php
protected function parsePanelFilter(PanelRowInterface $row) { foreach ($this->getFromDca('fields') as $property => $value) { if (isset($value['filter'])) { $element = new DefaultFilterElementInformation(); $element->setPropertyName($property); if (!$row->hasElement($element->getName())) { $row->addElement($element); } } } }
[ "protected", "function", "parsePanelFilter", "(", "PanelRowInterface", "$", "row", ")", "{", "foreach", "(", "$", "this", "->", "getFromDca", "(", "'fields'", ")", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "'filter'", "]", ")", ")", "{", "$", "element", "=", "new", "DefaultFilterElementInformation", "(", ")", ";", "$", "element", "->", "setPropertyName", "(", "$", "property", ")", ";", "if", "(", "!", "$", "row", "->", "hasElement", "(", "$", "element", "->", "getName", "(", ")", ")", ")", "{", "$", "row", "->", "addElement", "(", "$", "element", ")", ";", "}", "}", "}", "}" ]
Add filter elements to the panel. @param PanelRowInterface $row The row to which the element shall get added to. @return void
[ "Add", "filter", "elements", "to", "the", "panel", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L935-L946
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parsePanelSearch
protected function parsePanelSearch(PanelRowInterface $row) { if ($row->hasElement('search')) { $element = $row->getElement('search'); } else { $element = new DefaultSearchElementInformation(); } foreach ($this->getFromDca('fields') as $property => $value) { if (isset($value['search'])) { $element->addProperty($property); } } if ($element->getPropertyNames() && !$row->hasElement('search')) { $row->addElement($element); } }
php
protected function parsePanelSearch(PanelRowInterface $row) { if ($row->hasElement('search')) { $element = $row->getElement('search'); } else { $element = new DefaultSearchElementInformation(); } foreach ($this->getFromDca('fields') as $property => $value) { if (isset($value['search'])) { $element->addProperty($property); } } if ($element->getPropertyNames() && !$row->hasElement('search')) { $row->addElement($element); } }
[ "protected", "function", "parsePanelSearch", "(", "PanelRowInterface", "$", "row", ")", "{", "if", "(", "$", "row", "->", "hasElement", "(", "'search'", ")", ")", "{", "$", "element", "=", "$", "row", "->", "getElement", "(", "'search'", ")", ";", "}", "else", "{", "$", "element", "=", "new", "DefaultSearchElementInformation", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "getFromDca", "(", "'fields'", ")", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "'search'", "]", ")", ")", "{", "$", "element", "->", "addProperty", "(", "$", "property", ")", ";", "}", "}", "if", "(", "$", "element", "->", "getPropertyNames", "(", ")", "&&", "!", "$", "row", "->", "hasElement", "(", "'search'", ")", ")", "{", "$", "row", "->", "addElement", "(", "$", "element", ")", ";", "}", "}" ]
Add search element to the panel. @param PanelRowInterface $row The row to which the element shall get added to. @return void
[ "Add", "search", "element", "to", "the", "panel", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L969-L984
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parsePanelRow
protected function parsePanelRow(PanelRowInterface $row, $elementList) { foreach (\explode(',', $elementList) as $element) { switch ($element) { case 'filter': $this->parsePanelFilter($row); break; case 'sort': $this->parsePanelSort($row); break; case 'search': $this->parsePanelSearch($row); break; case 'limit': $this->parsePanelLimit($row); break; case 'submit': $this->parsePanelSubmit($row); break; default: } } }
php
protected function parsePanelRow(PanelRowInterface $row, $elementList) { foreach (\explode(',', $elementList) as $element) { switch ($element) { case 'filter': $this->parsePanelFilter($row); break; case 'sort': $this->parsePanelSort($row); break; case 'search': $this->parsePanelSearch($row); break; case 'limit': $this->parsePanelLimit($row); break; case 'submit': $this->parsePanelSubmit($row); break; default: } } }
[ "protected", "function", "parsePanelRow", "(", "PanelRowInterface", "$", "row", ",", "$", "elementList", ")", "{", "foreach", "(", "\\", "explode", "(", "','", ",", "$", "elementList", ")", "as", "$", "element", ")", "{", "switch", "(", "$", "element", ")", "{", "case", "'filter'", ":", "$", "this", "->", "parsePanelFilter", "(", "$", "row", ")", ";", "break", ";", "case", "'sort'", ":", "$", "this", "->", "parsePanelSort", "(", "$", "row", ")", ";", "break", ";", "case", "'search'", ":", "$", "this", "->", "parsePanelSearch", "(", "$", "row", ")", ";", "break", ";", "case", "'limit'", ":", "$", "this", "->", "parsePanelLimit", "(", "$", "row", ")", ";", "break", ";", "case", "'submit'", ":", "$", "this", "->", "parsePanelSubmit", "(", "$", "row", ")", ";", "break", ";", "default", ":", "}", "}", "}" ]
Parse a single panel row. @param PanelRowInterface $row The row to be populated. @param string $elementList A comma separated list of elements to be stored in the row. @return void
[ "Parse", "a", "single", "panel", "row", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1022-L1049
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.hasSubmit
private function hasSubmit($rows) { foreach ($rows as $row) { foreach ($row as $element) { if ($element instanceof SubmitElementInformationInterface) { return true; } } } return false; }
php
private function hasSubmit($rows) { foreach ($rows as $row) { foreach ($row as $element) { if ($element instanceof SubmitElementInformationInterface) { return true; } } } return false; }
[ "private", "function", "hasSubmit", "(", "$", "rows", ")", "{", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "foreach", "(", "$", "row", "as", "$", "element", ")", "{", "if", "(", "$", "element", "instanceof", "SubmitElementInformationInterface", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Check if the rows is somewhere a submit element. @param PanelRowCollectionInterface $rows The panel rows. @return bool
[ "Check", "if", "the", "rows", "is", "somewhere", "a", "submit", "element", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1090-L1101
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseGlobalOperations
protected function parseGlobalOperations(Contao2BackendViewDefinitionInterface $view) { $operationsDca = $this->getFromDca('list/global_operations'); $collection = $view->getGlobalCommands(); $collection->addCommand(new BackCommand()); $collection->addCommand(new CreateModelCommand()); if (!\is_array($operationsDca)) { return; } foreach (\array_keys($operationsDca) as $operationName) { $command = $this->createCommand($operationName, $operationsDca[$operationName]); $collection->addCommand($command); } }
php
protected function parseGlobalOperations(Contao2BackendViewDefinitionInterface $view) { $operationsDca = $this->getFromDca('list/global_operations'); $collection = $view->getGlobalCommands(); $collection->addCommand(new BackCommand()); $collection->addCommand(new CreateModelCommand()); if (!\is_array($operationsDca)) { return; } foreach (\array_keys($operationsDca) as $operationName) { $command = $this->createCommand($operationName, $operationsDca[$operationName]); $collection->addCommand($command); } }
[ "protected", "function", "parseGlobalOperations", "(", "Contao2BackendViewDefinitionInterface", "$", "view", ")", "{", "$", "operationsDca", "=", "$", "this", "->", "getFromDca", "(", "'list/global_operations'", ")", ";", "$", "collection", "=", "$", "view", "->", "getGlobalCommands", "(", ")", ";", "$", "collection", "->", "addCommand", "(", "new", "BackCommand", "(", ")", ")", ";", "$", "collection", "->", "addCommand", "(", "new", "CreateModelCommand", "(", ")", ")", ";", "if", "(", "!", "\\", "is_array", "(", "$", "operationsDca", ")", ")", "{", "return", ";", "}", "foreach", "(", "\\", "array_keys", "(", "$", "operationsDca", ")", "as", "$", "operationName", ")", "{", "$", "command", "=", "$", "this", "->", "createCommand", "(", "$", "operationName", ",", "$", "operationsDca", "[", "$", "operationName", "]", ")", ";", "$", "collection", "->", "addCommand", "(", "$", "command", ")", ";", "}", "}" ]
Parse the defined container scoped operations and populate the definition. @param Contao2BackendViewDefinitionInterface $view The backend view configuration definition to populate. @return void
[ "Parse", "the", "defined", "container", "scoped", "operations", "and", "populate", "the", "definition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1110-L1126
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseModelOperations
protected function parseModelOperations(Contao2BackendViewDefinitionInterface $view) { $operationsDca = $this->getFromDca('list/operations'); if (!\is_array($operationsDca)) { return; } $collection = $view->getModelCommands(); foreach ($operationsDca as $operationName => $operationDca) { $command = $this->createCommand($operationName, $operationDca); $collection->addCommand($command); } }
php
protected function parseModelOperations(Contao2BackendViewDefinitionInterface $view) { $operationsDca = $this->getFromDca('list/operations'); if (!\is_array($operationsDca)) { return; } $collection = $view->getModelCommands(); foreach ($operationsDca as $operationName => $operationDca) { $command = $this->createCommand($operationName, $operationDca); $collection->addCommand($command); } }
[ "protected", "function", "parseModelOperations", "(", "Contao2BackendViewDefinitionInterface", "$", "view", ")", "{", "$", "operationsDca", "=", "$", "this", "->", "getFromDca", "(", "'list/operations'", ")", ";", "if", "(", "!", "\\", "is_array", "(", "$", "operationsDca", ")", ")", "{", "return", ";", "}", "$", "collection", "=", "$", "view", "->", "getModelCommands", "(", ")", ";", "foreach", "(", "$", "operationsDca", "as", "$", "operationName", "=>", "$", "operationDca", ")", "{", "$", "command", "=", "$", "this", "->", "createCommand", "(", "$", "operationName", ",", "$", "operationDca", ")", ";", "$", "collection", "->", "addCommand", "(", "$", "command", ")", ";", "}", "}" ]
Parse the defined model scoped operations and populate the definition. @param Contao2BackendViewDefinitionInterface $view The backend view configuration definition to populate. @return void
[ "Parse", "the", "defined", "model", "scoped", "operations", "and", "populate", "the", "definition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1135-L1149
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseOderPropertyInPalette
private function parseOderPropertyInPalette(ContainerInterface $container) { foreach ($container->getPropertiesDefinition()->getProperties() as $property) { $extra = $property->getExtra(); if (!isset($extra['orderField']) || !$container->getPropertiesDefinition()->hasProperty($extra['orderField']) ) { continue; } $orderProperty = $container->getPropertiesDefinition()->getProperty($extra['orderField']); if (false === (bool) $orderProperty->getWidgetType()) { continue; } foreach ($container->getPalettesDefinition()->getPalettes() as $palette) { foreach ($palette->getLegends() as $legend) { if ((false === $legend->hasProperty($property->getName())) || (true === $legend->hasProperty($orderProperty->getName())) ) { continue; } $paletteProperty = $legend->getProperty($property->getName()); $paletteOrderProperty = new Property($orderProperty->getName()); $legend->addProperty($paletteOrderProperty, $paletteProperty); $paletteOrderProperty->setEditableCondition($paletteProperty->getEditableCondition()); $visibleCondition = new PropertyTrueCondition($property->getName(), false); $paletteOrderProperty->setVisibleCondition($visibleCondition); } } } }
php
private function parseOderPropertyInPalette(ContainerInterface $container) { foreach ($container->getPropertiesDefinition()->getProperties() as $property) { $extra = $property->getExtra(); if (!isset($extra['orderField']) || !$container->getPropertiesDefinition()->hasProperty($extra['orderField']) ) { continue; } $orderProperty = $container->getPropertiesDefinition()->getProperty($extra['orderField']); if (false === (bool) $orderProperty->getWidgetType()) { continue; } foreach ($container->getPalettesDefinition()->getPalettes() as $palette) { foreach ($palette->getLegends() as $legend) { if ((false === $legend->hasProperty($property->getName())) || (true === $legend->hasProperty($orderProperty->getName())) ) { continue; } $paletteProperty = $legend->getProperty($property->getName()); $paletteOrderProperty = new Property($orderProperty->getName()); $legend->addProperty($paletteOrderProperty, $paletteProperty); $paletteOrderProperty->setEditableCondition($paletteProperty->getEditableCondition()); $visibleCondition = new PropertyTrueCondition($property->getName(), false); $paletteOrderProperty->setVisibleCondition($visibleCondition); } } } }
[ "private", "function", "parseOderPropertyInPalette", "(", "ContainerInterface", "$", "container", ")", "{", "foreach", "(", "$", "container", "->", "getPropertiesDefinition", "(", ")", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "extra", "=", "$", "property", "->", "getExtra", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "extra", "[", "'orderField'", "]", ")", "||", "!", "$", "container", "->", "getPropertiesDefinition", "(", ")", "->", "hasProperty", "(", "$", "extra", "[", "'orderField'", "]", ")", ")", "{", "continue", ";", "}", "$", "orderProperty", "=", "$", "container", "->", "getPropertiesDefinition", "(", ")", "->", "getProperty", "(", "$", "extra", "[", "'orderField'", "]", ")", ";", "if", "(", "false", "===", "(", "bool", ")", "$", "orderProperty", "->", "getWidgetType", "(", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "container", "->", "getPalettesDefinition", "(", ")", "->", "getPalettes", "(", ")", "as", "$", "palette", ")", "{", "foreach", "(", "$", "palette", "->", "getLegends", "(", ")", "as", "$", "legend", ")", "{", "if", "(", "(", "false", "===", "$", "legend", "->", "hasProperty", "(", "$", "property", "->", "getName", "(", ")", ")", ")", "||", "(", "true", "===", "$", "legend", "->", "hasProperty", "(", "$", "orderProperty", "->", "getName", "(", ")", ")", ")", ")", "{", "continue", ";", "}", "$", "paletteProperty", "=", "$", "legend", "->", "getProperty", "(", "$", "property", "->", "getName", "(", ")", ")", ";", "$", "paletteOrderProperty", "=", "new", "Property", "(", "$", "orderProperty", "->", "getName", "(", ")", ")", ";", "$", "legend", "->", "addProperty", "(", "$", "paletteOrderProperty", ",", "$", "paletteProperty", ")", ";", "$", "paletteOrderProperty", "->", "setEditableCondition", "(", "$", "paletteProperty", "->", "getEditableCondition", "(", ")", ")", ";", "$", "visibleCondition", "=", "new", "PropertyTrueCondition", "(", "$", "property", "->", "getName", "(", ")", ",", "false", ")", ";", "$", "paletteOrderProperty", "->", "setVisibleCondition", "(", "$", "visibleCondition", ")", ";", "}", "}", "}", "}" ]
Parse if the order property is defined in the same palette as the corresponding source property. If not, then define it. @param ContainerInterface $container The container. @return void
[ "Parse", "if", "the", "order", "property", "is", "defined", "in", "the", "same", "palette", "as", "the", "corresponding", "source", "property", ".", "If", "not", "then", "define", "it", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1198-L1231
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseSinglePropertyLabel
protected function parseSinglePropertyLabel(PropertyInterface $property, $label) { if (!$property->getLabel()) { if (\is_array($label)) { $lang = $label; $label = \reset($lang); $description = \next($lang); $property->setDescription($description); } $property->setLabel($label); } }
php
protected function parseSinglePropertyLabel(PropertyInterface $property, $label) { if (!$property->getLabel()) { if (\is_array($label)) { $lang = $label; $label = \reset($lang); $description = \next($lang); $property->setDescription($description); } $property->setLabel($label); } }
[ "protected", "function", "parseSinglePropertyLabel", "(", "PropertyInterface", "$", "property", ",", "$", "label", ")", "{", "if", "(", "!", "$", "property", "->", "getLabel", "(", ")", ")", "{", "if", "(", "\\", "is_array", "(", "$", "label", ")", ")", "{", "$", "lang", "=", "$", "label", ";", "$", "label", "=", "\\", "reset", "(", "$", "lang", ")", ";", "$", "description", "=", "\\", "next", "(", "$", "lang", ")", ";", "$", "property", "->", "setDescription", "(", "$", "description", ")", ";", "}", "$", "property", "->", "setLabel", "(", "$", "label", ")", ";", "}", "}" ]
Parse the label of a single property. @param PropertyInterface $property The property to parse the label for. @param string|array $label The label value. @return void
[ "Parse", "the", "label", "of", "a", "single", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1241-L1254
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseSingleProperty
protected function parseSingleProperty(PropertyInterface $property, array $propInfo) { foreach ($propInfo as $key => $value) { switch ($key) { case 'label': $this->parseSinglePropertyLabel($property, $value); break; case 'description': if (!$property->getDescription()) { $property->setDescription($value); } break; case 'default': if (!$property->getDefaultValue()) { $property->setDefaultValue($value); } break; case 'exclude': $property->setExcluded((bool) $value); break; case 'search': $property->setSearchable((bool) $value); break; case 'filter': $property->setFilterable((bool) $value); break; case 'inputType': $property->setWidgetType($value); break; case 'options': $property->setOptions($value); break; case 'explanation': $property->setExplanation($value); break; case 'eval': $property->setExtra( \array_merge( (array) $property->getExtra(), (array) $value ) ); break; case 'reference': $property->setExtra( \array_merge( (array) $property->getExtra(), ['reference' => &$propInfo['reference']] ) ); break; case 'sql': $this->determineEmptyValueFromSql($property, $value); break; default: } } $this->parseWidgetPageTree($property, $propInfo); }
php
protected function parseSingleProperty(PropertyInterface $property, array $propInfo) { foreach ($propInfo as $key => $value) { switch ($key) { case 'label': $this->parseSinglePropertyLabel($property, $value); break; case 'description': if (!$property->getDescription()) { $property->setDescription($value); } break; case 'default': if (!$property->getDefaultValue()) { $property->setDefaultValue($value); } break; case 'exclude': $property->setExcluded((bool) $value); break; case 'search': $property->setSearchable((bool) $value); break; case 'filter': $property->setFilterable((bool) $value); break; case 'inputType': $property->setWidgetType($value); break; case 'options': $property->setOptions($value); break; case 'explanation': $property->setExplanation($value); break; case 'eval': $property->setExtra( \array_merge( (array) $property->getExtra(), (array) $value ) ); break; case 'reference': $property->setExtra( \array_merge( (array) $property->getExtra(), ['reference' => &$propInfo['reference']] ) ); break; case 'sql': $this->determineEmptyValueFromSql($property, $value); break; default: } } $this->parseWidgetPageTree($property, $propInfo); }
[ "protected", "function", "parseSingleProperty", "(", "PropertyInterface", "$", "property", ",", "array", "$", "propInfo", ")", "{", "foreach", "(", "$", "propInfo", "as", "$", "key", "=>", "$", "value", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'label'", ":", "$", "this", "->", "parseSinglePropertyLabel", "(", "$", "property", ",", "$", "value", ")", ";", "break", ";", "case", "'description'", ":", "if", "(", "!", "$", "property", "->", "getDescription", "(", ")", ")", "{", "$", "property", "->", "setDescription", "(", "$", "value", ")", ";", "}", "break", ";", "case", "'default'", ":", "if", "(", "!", "$", "property", "->", "getDefaultValue", "(", ")", ")", "{", "$", "property", "->", "setDefaultValue", "(", "$", "value", ")", ";", "}", "break", ";", "case", "'exclude'", ":", "$", "property", "->", "setExcluded", "(", "(", "bool", ")", "$", "value", ")", ";", "break", ";", "case", "'search'", ":", "$", "property", "->", "setSearchable", "(", "(", "bool", ")", "$", "value", ")", ";", "break", ";", "case", "'filter'", ":", "$", "property", "->", "setFilterable", "(", "(", "bool", ")", "$", "value", ")", ";", "break", ";", "case", "'inputType'", ":", "$", "property", "->", "setWidgetType", "(", "$", "value", ")", ";", "break", ";", "case", "'options'", ":", "$", "property", "->", "setOptions", "(", "$", "value", ")", ";", "break", ";", "case", "'explanation'", ":", "$", "property", "->", "setExplanation", "(", "$", "value", ")", ";", "break", ";", "case", "'eval'", ":", "$", "property", "->", "setExtra", "(", "\\", "array_merge", "(", "(", "array", ")", "$", "property", "->", "getExtra", "(", ")", ",", "(", "array", ")", "$", "value", ")", ")", ";", "break", ";", "case", "'reference'", ":", "$", "property", "->", "setExtra", "(", "\\", "array_merge", "(", "(", "array", ")", "$", "property", "->", "getExtra", "(", ")", ",", "[", "'reference'", "=>", "&", "$", "propInfo", "[", "'reference'", "]", "]", ")", ")", ";", "break", ";", "case", "'sql'", ":", "$", "this", "->", "determineEmptyValueFromSql", "(", "$", "property", ",", "$", "value", ")", ";", "break", ";", "default", ":", "}", "}", "$", "this", "->", "parseWidgetPageTree", "(", "$", "property", ",", "$", "propInfo", ")", ";", "}" ]
Parse a single property. @param PropertyInterface $property The property to parse. @param array $propInfo The property information. @return void @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Parse", "a", "single", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1266-L1337
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseWidgetPageTree
private function parseWidgetPageTree(PropertyInterface $property, array $propInfo) { if (isset($propInfo['sourceName']) || ('pageTree' !== $property->getWidgetType()) ) { return; } // If the foreign key not set, then use an standard as fallback. if (!isset($propInfo['foreignKey'])) { $propInfo['foreignKey'] = 'tl_page.title'; } $property ->setExtra( \array_merge( [ 'sourceName' => \explode('.', $propInfo['foreignKey'])[0], 'idProperty' => 'id' ], (array) $property->getExtra() ) ); }
php
private function parseWidgetPageTree(PropertyInterface $property, array $propInfo) { if (isset($propInfo['sourceName']) || ('pageTree' !== $property->getWidgetType()) ) { return; } // If the foreign key not set, then use an standard as fallback. if (!isset($propInfo['foreignKey'])) { $propInfo['foreignKey'] = 'tl_page.title'; } $property ->setExtra( \array_merge( [ 'sourceName' => \explode('.', $propInfo['foreignKey'])[0], 'idProperty' => 'id' ], (array) $property->getExtra() ) ); }
[ "private", "function", "parseWidgetPageTree", "(", "PropertyInterface", "$", "property", ",", "array", "$", "propInfo", ")", "{", "if", "(", "isset", "(", "$", "propInfo", "[", "'sourceName'", "]", ")", "||", "(", "'pageTree'", "!==", "$", "property", "->", "getWidgetType", "(", ")", ")", ")", "{", "return", ";", "}", "// If the foreign key not set, then use an standard as fallback.", "if", "(", "!", "isset", "(", "$", "propInfo", "[", "'foreignKey'", "]", ")", ")", "{", "$", "propInfo", "[", "'foreignKey'", "]", "=", "'tl_page.title'", ";", "}", "$", "property", "->", "setExtra", "(", "\\", "array_merge", "(", "[", "'sourceName'", "=>", "\\", "explode", "(", "'.'", ",", "$", "propInfo", "[", "'foreignKey'", "]", ")", "[", "0", "]", ",", "'idProperty'", "=>", "'id'", "]", ",", "(", "array", ")", "$", "property", "->", "getExtra", "(", ")", ")", ")", ";", "}" ]
Parse the property widget type of page tree. @param PropertyInterface $property The property to parse. @param array $propInfo The property information. @return void
[ "Parse", "the", "property", "widget", "type", "of", "page", "tree", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1347-L1370
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseOrderProperty
private function parseOrderProperty(PropertyInterface $property, PropertyInterface $orderProperty) { $orderWidgets = [ 'pageTree' => 'pageTreeOrder', 'fileTree' => 'fileTreeOrder', 'DcGeneralTreePicker' => 'treePickerOrder' ]; if (false === \array_key_exists($property->getWidgetType(), $orderWidgets)) { return; } $orderProperty->setWidgetType($orderWidgets[$property->getWidgetType()]); }
php
private function parseOrderProperty(PropertyInterface $property, PropertyInterface $orderProperty) { $orderWidgets = [ 'pageTree' => 'pageTreeOrder', 'fileTree' => 'fileTreeOrder', 'DcGeneralTreePicker' => 'treePickerOrder' ]; if (false === \array_key_exists($property->getWidgetType(), $orderWidgets)) { return; } $orderProperty->setWidgetType($orderWidgets[$property->getWidgetType()]); }
[ "private", "function", "parseOrderProperty", "(", "PropertyInterface", "$", "property", ",", "PropertyInterface", "$", "orderProperty", ")", "{", "$", "orderWidgets", "=", "[", "'pageTree'", "=>", "'pageTreeOrder'", ",", "'fileTree'", "=>", "'fileTreeOrder'", ",", "'DcGeneralTreePicker'", "=>", "'treePickerOrder'", "]", ";", "if", "(", "false", "===", "\\", "array_key_exists", "(", "$", "property", "->", "getWidgetType", "(", ")", ",", "$", "orderWidgets", ")", ")", "{", "return", ";", "}", "$", "orderProperty", "->", "setWidgetType", "(", "$", "orderWidgets", "[", "$", "property", "->", "getWidgetType", "(", ")", "]", ")", ";", "}" ]
Parse the property for order and set the order widget. @param PropertyInterface $property The base property. @param PropertyInterface $orderProperty The order property. @return void
[ "Parse", "the", "property", "for", "order", "and", "set", "the", "order", "widget", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1380-L1392
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.parseProperties
protected function parseProperties(ContainerInterface $container) { if ($container->hasPropertiesDefinition()) { $definition = $container->getPropertiesDefinition(); } else { $definition = new DefaultPropertiesDefinition(); $container->setPropertiesDefinition($definition); } foreach ((array) $this->getFromDca('fields') as $propName => $propInfo) { if ($definition->hasProperty($propName)) { $property = $definition->getProperty($propName); } else { $property = new DefaultProperty($propName); $definition->addProperty($property); } // Some extensions create invalid DCA information and the DCA must therefore be validated. if (!\is_array($propInfo)) { continue; } $this->parseSingleProperty($property, $propInfo); $extra = $property->getExtra(); if (isset($extra['orderField']) && \array_key_exists($extra['orderField'], (array) $this->getFromDca('fields')) ) { if (!$definition->hasProperty($extra['orderField'])) { $definition->addProperty(new DefaultProperty($extra['orderField'])); } $orderProperty = $definition->getProperty($extra['orderField']); $this->parseOrderProperty($property, $orderProperty); } } }
php
protected function parseProperties(ContainerInterface $container) { if ($container->hasPropertiesDefinition()) { $definition = $container->getPropertiesDefinition(); } else { $definition = new DefaultPropertiesDefinition(); $container->setPropertiesDefinition($definition); } foreach ((array) $this->getFromDca('fields') as $propName => $propInfo) { if ($definition->hasProperty($propName)) { $property = $definition->getProperty($propName); } else { $property = new DefaultProperty($propName); $definition->addProperty($property); } // Some extensions create invalid DCA information and the DCA must therefore be validated. if (!\is_array($propInfo)) { continue; } $this->parseSingleProperty($property, $propInfo); $extra = $property->getExtra(); if (isset($extra['orderField']) && \array_key_exists($extra['orderField'], (array) $this->getFromDca('fields')) ) { if (!$definition->hasProperty($extra['orderField'])) { $definition->addProperty(new DefaultProperty($extra['orderField'])); } $orderProperty = $definition->getProperty($extra['orderField']); $this->parseOrderProperty($property, $orderProperty); } } }
[ "protected", "function", "parseProperties", "(", "ContainerInterface", "$", "container", ")", "{", "if", "(", "$", "container", "->", "hasPropertiesDefinition", "(", ")", ")", "{", "$", "definition", "=", "$", "container", "->", "getPropertiesDefinition", "(", ")", ";", "}", "else", "{", "$", "definition", "=", "new", "DefaultPropertiesDefinition", "(", ")", ";", "$", "container", "->", "setPropertiesDefinition", "(", "$", "definition", ")", ";", "}", "foreach", "(", "(", "array", ")", "$", "this", "->", "getFromDca", "(", "'fields'", ")", "as", "$", "propName", "=>", "$", "propInfo", ")", "{", "if", "(", "$", "definition", "->", "hasProperty", "(", "$", "propName", ")", ")", "{", "$", "property", "=", "$", "definition", "->", "getProperty", "(", "$", "propName", ")", ";", "}", "else", "{", "$", "property", "=", "new", "DefaultProperty", "(", "$", "propName", ")", ";", "$", "definition", "->", "addProperty", "(", "$", "property", ")", ";", "}", "// Some extensions create invalid DCA information and the DCA must therefore be validated.", "if", "(", "!", "\\", "is_array", "(", "$", "propInfo", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "parseSingleProperty", "(", "$", "property", ",", "$", "propInfo", ")", ";", "$", "extra", "=", "$", "property", "->", "getExtra", "(", ")", ";", "if", "(", "isset", "(", "$", "extra", "[", "'orderField'", "]", ")", "&&", "\\", "array_key_exists", "(", "$", "extra", "[", "'orderField'", "]", ",", "(", "array", ")", "$", "this", "->", "getFromDca", "(", "'fields'", ")", ")", ")", "{", "if", "(", "!", "$", "definition", "->", "hasProperty", "(", "$", "extra", "[", "'orderField'", "]", ")", ")", "{", "$", "definition", "->", "addProperty", "(", "new", "DefaultProperty", "(", "$", "extra", "[", "'orderField'", "]", ")", ")", ";", "}", "$", "orderProperty", "=", "$", "definition", "->", "getProperty", "(", "$", "extra", "[", "'orderField'", "]", ")", ";", "$", "this", "->", "parseOrderProperty", "(", "$", "property", ",", "$", "orderProperty", ")", ";", "}", "}", "}" ]
Parse the defined properties and populate the definition. @param ContainerInterface $container The container where the data shall be stored. @return void
[ "Parse", "the", "defined", "properties", "and", "populate", "the", "definition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1401-L1437
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.createCommandInstance
protected function createCommandInstance($commandName, array &$commandDca) { switch ($commandName) { case 'cut': return new CutCommand(); case 'copy': case 'deepcopy': return new CopyCommand(); case 'all': return new SelectCommand(); case 'toggle': $command = new ToggleCommand(); if (isset($commandDca['toggleProperty'])) { $command->setToggleProperty($commandDca['toggleProperty']); unset($commandDca['toggleProperty']); } else { // Implicit fallback to "published" as in Contao core. $command->setToggleProperty('published'); } if (isset($commandDca['toggleInverse'])) { $command->setInverse($commandDca['toggleInverse']); unset($commandDca['toggleInverse']); } return $command; default: } return new Command(); }
php
protected function createCommandInstance($commandName, array &$commandDca) { switch ($commandName) { case 'cut': return new CutCommand(); case 'copy': case 'deepcopy': return new CopyCommand(); case 'all': return new SelectCommand(); case 'toggle': $command = new ToggleCommand(); if (isset($commandDca['toggleProperty'])) { $command->setToggleProperty($commandDca['toggleProperty']); unset($commandDca['toggleProperty']); } else { // Implicit fallback to "published" as in Contao core. $command->setToggleProperty('published'); } if (isset($commandDca['toggleInverse'])) { $command->setInverse($commandDca['toggleInverse']); unset($commandDca['toggleInverse']); } return $command; default: } return new Command(); }
[ "protected", "function", "createCommandInstance", "(", "$", "commandName", ",", "array", "&", "$", "commandDca", ")", "{", "switch", "(", "$", "commandName", ")", "{", "case", "'cut'", ":", "return", "new", "CutCommand", "(", ")", ";", "case", "'copy'", ":", "case", "'deepcopy'", ":", "return", "new", "CopyCommand", "(", ")", ";", "case", "'all'", ":", "return", "new", "SelectCommand", "(", ")", ";", "case", "'toggle'", ":", "$", "command", "=", "new", "ToggleCommand", "(", ")", ";", "if", "(", "isset", "(", "$", "commandDca", "[", "'toggleProperty'", "]", ")", ")", "{", "$", "command", "->", "setToggleProperty", "(", "$", "commandDca", "[", "'toggleProperty'", "]", ")", ";", "unset", "(", "$", "commandDca", "[", "'toggleProperty'", "]", ")", ";", "}", "else", "{", "// Implicit fallback to \"published\" as in Contao core.", "$", "command", "->", "setToggleProperty", "(", "'published'", ")", ";", "}", "if", "(", "isset", "(", "$", "commandDca", "[", "'toggleInverse'", "]", ")", ")", "{", "$", "command", "->", "setInverse", "(", "$", "commandDca", "[", "'toggleInverse'", "]", ")", ";", "unset", "(", "$", "commandDca", "[", "'toggleInverse'", "]", ")", ";", "}", "return", "$", "command", ";", "default", ":", "}", "return", "new", "Command", "(", ")", ";", "}" ]
Create the correct command instance for the given information. @param string $commandName The name of the command to create. @param array $commandDca The Dca information of the command. @return CommandInterface
[ "Create", "the", "correct", "command", "instance", "for", "the", "given", "information", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1447-L1480
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.createCommand
protected function createCommand($commandName, array $commandDca) { $command = $this->createCommandInstance($commandName, $commandDca); $command->setName($commandName); $parameters = $command->getParameters(); if (isset($commandDca['href'])) { \parse_str($commandDca['href'], $queryParameters); foreach ($queryParameters as $name => $value) { $parameters[$name] = $value; } unset($commandDca['href']); } if (isset($commandDca['parameters'])) { foreach ($commandDca['parameters'] as $name => $value) { $parameters[$name] = $value; } unset($commandDca['parameters']); } if (isset($commandDca['label'])) { $lang = $commandDca['label']; if (\is_array($lang)) { $label = \reset($lang); $description = \next($lang); $command->setDescription($description); } else { $label = $lang; } $command->setLabel($label); unset($commandDca['label']); } if (isset($commandDca['description'])) { $command->setDescription($commandDca['description']); unset($commandDca['description']); } // Callback is transformed into event in parseCallbacks(). unset($commandDca['button_callback']); if (\count($commandDca)) { $extra = $command->getExtra(); foreach ($commandDca as $name => $value) { $extra[$name] = $value; } } return $command; }
php
protected function createCommand($commandName, array $commandDca) { $command = $this->createCommandInstance($commandName, $commandDca); $command->setName($commandName); $parameters = $command->getParameters(); if (isset($commandDca['href'])) { \parse_str($commandDca['href'], $queryParameters); foreach ($queryParameters as $name => $value) { $parameters[$name] = $value; } unset($commandDca['href']); } if (isset($commandDca['parameters'])) { foreach ($commandDca['parameters'] as $name => $value) { $parameters[$name] = $value; } unset($commandDca['parameters']); } if (isset($commandDca['label'])) { $lang = $commandDca['label']; if (\is_array($lang)) { $label = \reset($lang); $description = \next($lang); $command->setDescription($description); } else { $label = $lang; } $command->setLabel($label); unset($commandDca['label']); } if (isset($commandDca['description'])) { $command->setDescription($commandDca['description']); unset($commandDca['description']); } // Callback is transformed into event in parseCallbacks(). unset($commandDca['button_callback']); if (\count($commandDca)) { $extra = $command->getExtra(); foreach ($commandDca as $name => $value) { $extra[$name] = $value; } } return $command; }
[ "protected", "function", "createCommand", "(", "$", "commandName", ",", "array", "$", "commandDca", ")", "{", "$", "command", "=", "$", "this", "->", "createCommandInstance", "(", "$", "commandName", ",", "$", "commandDca", ")", ";", "$", "command", "->", "setName", "(", "$", "commandName", ")", ";", "$", "parameters", "=", "$", "command", "->", "getParameters", "(", ")", ";", "if", "(", "isset", "(", "$", "commandDca", "[", "'href'", "]", ")", ")", "{", "\\", "parse_str", "(", "$", "commandDca", "[", "'href'", "]", ",", "$", "queryParameters", ")", ";", "foreach", "(", "$", "queryParameters", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "parameters", "[", "$", "name", "]", "=", "$", "value", ";", "}", "unset", "(", "$", "commandDca", "[", "'href'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "commandDca", "[", "'parameters'", "]", ")", ")", "{", "foreach", "(", "$", "commandDca", "[", "'parameters'", "]", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "parameters", "[", "$", "name", "]", "=", "$", "value", ";", "}", "unset", "(", "$", "commandDca", "[", "'parameters'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "commandDca", "[", "'label'", "]", ")", ")", "{", "$", "lang", "=", "$", "commandDca", "[", "'label'", "]", ";", "if", "(", "\\", "is_array", "(", "$", "lang", ")", ")", "{", "$", "label", "=", "\\", "reset", "(", "$", "lang", ")", ";", "$", "description", "=", "\\", "next", "(", "$", "lang", ")", ";", "$", "command", "->", "setDescription", "(", "$", "description", ")", ";", "}", "else", "{", "$", "label", "=", "$", "lang", ";", "}", "$", "command", "->", "setLabel", "(", "$", "label", ")", ";", "unset", "(", "$", "commandDca", "[", "'label'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "commandDca", "[", "'description'", "]", ")", ")", "{", "$", "command", "->", "setDescription", "(", "$", "commandDca", "[", "'description'", "]", ")", ";", "unset", "(", "$", "commandDca", "[", "'description'", "]", ")", ";", "}", "// Callback is transformed into event in parseCallbacks().", "unset", "(", "$", "commandDca", "[", "'button_callback'", "]", ")", ";", "if", "(", "\\", "count", "(", "$", "commandDca", ")", ")", "{", "$", "extra", "=", "$", "command", "->", "getExtra", "(", ")", ";", "foreach", "(", "$", "commandDca", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "extra", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "command", ";", "}" ]
Create a command from dca. @param string $commandName The name of the command to parse. @param array $commandDca The chunk from the DCA containing the command specification. @return CommandInterface
[ "Create", "a", "command", "from", "dca", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1490-L1548
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.evalFlagSorting
protected function evalFlagSorting($config, $flag) { if (($flag < 0) || ($flag > 12)) { return; } if (1 === ($flag % 2)) { $config->setSortingMode(GroupAndSortingInformationInterface::SORT_ASC); } else { $config->setSortingMode(GroupAndSortingInformationInterface::SORT_DESC); } }
php
protected function evalFlagSorting($config, $flag) { if (($flag < 0) || ($flag > 12)) { return; } if (1 === ($flag % 2)) { $config->setSortingMode(GroupAndSortingInformationInterface::SORT_ASC); } else { $config->setSortingMode(GroupAndSortingInformationInterface::SORT_DESC); } }
[ "protected", "function", "evalFlagSorting", "(", "$", "config", ",", "$", "flag", ")", "{", "if", "(", "(", "$", "flag", "<", "0", ")", "||", "(", "$", "flag", ">", "12", ")", ")", "{", "return", ";", "}", "if", "(", "1", "===", "(", "$", "flag", "%", "2", ")", ")", "{", "$", "config", "->", "setSortingMode", "(", "GroupAndSortingInformationInterface", "::", "SORT_ASC", ")", ";", "}", "else", "{", "$", "config", "->", "setSortingMode", "(", "GroupAndSortingInformationInterface", "::", "SORT_DESC", ")", ";", "}", "}" ]
Evaluate the contao 2 sorting flag into sorting mode. @param GroupAndSortingInformationInterface $config The property to evaluate the flag for. @param int $flag The flag to be evaluated. @return void
[ "Evaluate", "the", "contao", "2", "sorting", "flag", "into", "sorting", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1558-L1569
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.evalFlagGrouping
protected function evalFlagGrouping($config, $flag) { if (($flag < 0) || ($flag > 12)) { return; } if ($flag <= 4) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_CHAR); } elseif ($flag <= 6) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_DAY); } elseif ($flag <= 8) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_MONTH); } elseif ($flag <= 10) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_YEAR); } else { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_NONE); } }
php
protected function evalFlagGrouping($config, $flag) { if (($flag < 0) || ($flag > 12)) { return; } if ($flag <= 4) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_CHAR); } elseif ($flag <= 6) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_DAY); } elseif ($flag <= 8) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_MONTH); } elseif ($flag <= 10) { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_YEAR); } else { $config->setGroupingMode(GroupAndSortingInformationInterface::GROUP_NONE); } }
[ "protected", "function", "evalFlagGrouping", "(", "$", "config", ",", "$", "flag", ")", "{", "if", "(", "(", "$", "flag", "<", "0", ")", "||", "(", "$", "flag", ">", "12", ")", ")", "{", "return", ";", "}", "if", "(", "$", "flag", "<=", "4", ")", "{", "$", "config", "->", "setGroupingMode", "(", "GroupAndSortingInformationInterface", "::", "GROUP_CHAR", ")", ";", "}", "elseif", "(", "$", "flag", "<=", "6", ")", "{", "$", "config", "->", "setGroupingMode", "(", "GroupAndSortingInformationInterface", "::", "GROUP_DAY", ")", ";", "}", "elseif", "(", "$", "flag", "<=", "8", ")", "{", "$", "config", "->", "setGroupingMode", "(", "GroupAndSortingInformationInterface", "::", "GROUP_MONTH", ")", ";", "}", "elseif", "(", "$", "flag", "<=", "10", ")", "{", "$", "config", "->", "setGroupingMode", "(", "GroupAndSortingInformationInterface", "::", "GROUP_YEAR", ")", ";", "}", "else", "{", "$", "config", "->", "setGroupingMode", "(", "GroupAndSortingInformationInterface", "::", "GROUP_NONE", ")", ";", "}", "}" ]
Evaluate the contao 2 sorting flag into grouping mode. @param GroupAndSortingInformationInterface $config The property to evaluate the flag for. @param int $flag The flag to be evaluated. @return void
[ "Evaluate", "the", "contao", "2", "sorting", "flag", "into", "grouping", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1579-L1596
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.evalFlagGroupingLength
protected function evalFlagGroupingLength($config, $flag) { if ((1 === $flag) || (2 === $flag)) { $config->setGroupingLength(1); } elseif ((3 === $flag) || (4 === $flag)) { $config->setGroupingLength(2); } }
php
protected function evalFlagGroupingLength($config, $flag) { if ((1 === $flag) || (2 === $flag)) { $config->setGroupingLength(1); } elseif ((3 === $flag) || (4 === $flag)) { $config->setGroupingLength(2); } }
[ "protected", "function", "evalFlagGroupingLength", "(", "$", "config", ",", "$", "flag", ")", "{", "if", "(", "(", "1", "===", "$", "flag", ")", "||", "(", "2", "===", "$", "flag", ")", ")", "{", "$", "config", "->", "setGroupingLength", "(", "1", ")", ";", "}", "elseif", "(", "(", "3", "===", "$", "flag", ")", "||", "(", "4", "===", "$", "flag", ")", ")", "{", "$", "config", "->", "setGroupingLength", "(", "2", ")", ";", "}", "}" ]
Evaluate the contao 2 sorting flag into grouping length. @param GroupAndSortingInformationInterface $config The property to evaluate the flag for. @param int $flag The flag to be evaluated. @return void
[ "Evaluate", "the", "contao", "2", "sorting", "flag", "into", "grouping", "length", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1606-L1613
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.evalFlag
protected function evalFlag($config, $flag) { $this->evalFlagSorting($config, $flag); $this->evalFlagGrouping($config, $flag); $this->evalFlagGroupingLength($config, $flag); }
php
protected function evalFlag($config, $flag) { $this->evalFlagSorting($config, $flag); $this->evalFlagGrouping($config, $flag); $this->evalFlagGroupingLength($config, $flag); }
[ "protected", "function", "evalFlag", "(", "$", "config", ",", "$", "flag", ")", "{", "$", "this", "->", "evalFlagSorting", "(", "$", "config", ",", "$", "flag", ")", ";", "$", "this", "->", "evalFlagGrouping", "(", "$", "config", ",", "$", "flag", ")", ";", "$", "this", "->", "evalFlagGroupingLength", "(", "$", "config", ",", "$", "flag", ")", ";", "}" ]
Evaluate the contao 2 sorting flag into sorting mode, grouping mode and grouping length. @param GroupAndSortingInformationInterface $config The property to evaluate the flag for. @param int $flag The flag to be evaluated. @return void
[ "Evaluate", "the", "contao", "2", "sorting", "flag", "into", "sorting", "mode", "grouping", "mode", "and", "grouping", "length", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1623-L1628
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php
LegacyDcaDataDefinitionBuilder.determineEmptyValueFromSql
private function determineEmptyValueFromSql(PropertyInterface $property, $sqlType) { if ($property instanceof EmptyValueAwarePropertyInterface) { $property->setEmptyValue(Widget::getEmptyValueByFieldType($sqlType)); } }
php
private function determineEmptyValueFromSql(PropertyInterface $property, $sqlType) { if ($property instanceof EmptyValueAwarePropertyInterface) { $property->setEmptyValue(Widget::getEmptyValueByFieldType($sqlType)); } }
[ "private", "function", "determineEmptyValueFromSql", "(", "PropertyInterface", "$", "property", ",", "$", "sqlType", ")", "{", "if", "(", "$", "property", "instanceof", "EmptyValueAwarePropertyInterface", ")", "{", "$", "property", "->", "setEmptyValue", "(", "Widget", "::", "getEmptyValueByFieldType", "(", "$", "sqlType", ")", ")", ";", "}", "}" ]
Try to determine the empty type from SQL type. @param PropertyInterface $property The property to store the value into. @param string $sqlType The SQL type. @return void
[ "Try", "to", "determine", "the", "empty", "type", "from", "SQL", "type", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/LegacyDcaDataDefinitionBuilder.php#L1638-L1643
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.checkCreatable
protected function checkCreatable($model) { $environment = $this->getEnvironment(); $definition = $this->getDataDefinition(); // Check if table is closed but we are adding a new item. if (!($model->getId() || $definition->getBasicDefinition()->isCreatable())) { $message = 'DataContainer ' . $definition->getName() . ' is closed'; $environment->getEventDispatcher()->dispatch( ContaoEvents::SYSTEM_LOG, new LogEvent($message, TL_ERROR, 'DC_General - edit()') ); throw new DcGeneralRuntimeException($message); } }
php
protected function checkCreatable($model) { $environment = $this->getEnvironment(); $definition = $this->getDataDefinition(); // Check if table is closed but we are adding a new item. if (!($model->getId() || $definition->getBasicDefinition()->isCreatable())) { $message = 'DataContainer ' . $definition->getName() . ' is closed'; $environment->getEventDispatcher()->dispatch( ContaoEvents::SYSTEM_LOG, new LogEvent($message, TL_ERROR, 'DC_General - edit()') ); throw new DcGeneralRuntimeException($message); } }
[ "protected", "function", "checkCreatable", "(", "$", "model", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "definition", "=", "$", "this", "->", "getDataDefinition", "(", ")", ";", "// Check if table is closed but we are adding a new item.", "if", "(", "!", "(", "$", "model", "->", "getId", "(", ")", "||", "$", "definition", "->", "getBasicDefinition", "(", ")", "->", "isCreatable", "(", ")", ")", ")", "{", "$", "message", "=", "'DataContainer '", ".", "$", "definition", "->", "getName", "(", ")", ".", "' is closed'", ";", "$", "environment", "->", "getEventDispatcher", "(", ")", "->", "dispatch", "(", "ContaoEvents", "::", "SYSTEM_LOG", ",", "new", "LogEvent", "(", "$", "message", ",", "TL_ERROR", ",", "'DC_General - edit()'", ")", ")", ";", "throw", "new", "DcGeneralRuntimeException", "(", "$", "message", ")", ";", "}", "}" ]
Ensure the view is editable and throw an Exception if not. @param ModelInterface $model The model to be edited, if this is given, we are not in create mode. @return void @throws DcGeneralRuntimeException When the definition is not editable.
[ "Ensure", "the", "view", "is", "editable", "and", "throw", "an", "Exception", "if", "not", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L190-L204
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.handlePrePersist
protected function handlePrePersist() { $environment = $this->getEnvironment(); if (null !== $this->preFunction) { \call_user_func($this->preFunction, $environment, $this->model, $this->originalModel); } $environment->getEventDispatcher()->dispatch( PrePersistModelEvent::NAME, new PrePersistModelEvent($environment, $this->model, $this->originalModel) ); }
php
protected function handlePrePersist() { $environment = $this->getEnvironment(); if (null !== $this->preFunction) { \call_user_func($this->preFunction, $environment, $this->model, $this->originalModel); } $environment->getEventDispatcher()->dispatch( PrePersistModelEvent::NAME, new PrePersistModelEvent($environment, $this->model, $this->originalModel) ); }
[ "protected", "function", "handlePrePersist", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "if", "(", "null", "!==", "$", "this", "->", "preFunction", ")", "{", "\\", "call_user_func", "(", "$", "this", "->", "preFunction", ",", "$", "environment", ",", "$", "this", "->", "model", ",", "$", "this", "->", "originalModel", ")", ";", "}", "$", "environment", "->", "getEventDispatcher", "(", ")", "->", "dispatch", "(", "PrePersistModelEvent", "::", "NAME", ",", "new", "PrePersistModelEvent", "(", "$", "environment", ",", "$", "this", "->", "model", ",", "$", "this", "->", "originalModel", ")", ")", ";", "}" ]
Trigger the pre persist event and handle the prePersist function if available. @return void
[ "Trigger", "the", "pre", "persist", "event", "and", "handle", "the", "prePersist", "function", "if", "available", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L265-L276
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.getButtonLabel
protected function getButtonLabel($buttonLabel) { $translator = $this->getEnvironment()->getTranslator(); if (($label = $translator->translate($buttonLabel, $this->getDataDefinition()->getName())) !== $buttonLabel) { return $label; } if (($label = $translator->translate('MSC.' . $buttonLabel)) !== $buttonLabel) { return $label; } // Fallback, just return the key as is it. return $buttonLabel; }
php
protected function getButtonLabel($buttonLabel) { $translator = $this->getEnvironment()->getTranslator(); if (($label = $translator->translate($buttonLabel, $this->getDataDefinition()->getName())) !== $buttonLabel) { return $label; } if (($label = $translator->translate('MSC.' . $buttonLabel)) !== $buttonLabel) { return $label; } // Fallback, just return the key as is it. return $buttonLabel; }
[ "protected", "function", "getButtonLabel", "(", "$", "buttonLabel", ")", "{", "$", "translator", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getTranslator", "(", ")", ";", "if", "(", "(", "$", "label", "=", "$", "translator", "->", "translate", "(", "$", "buttonLabel", ",", "$", "this", "->", "getDataDefinition", "(", ")", "->", "getName", "(", ")", ")", ")", "!==", "$", "buttonLabel", ")", "{", "return", "$", "label", ";", "}", "if", "(", "(", "$", "label", "=", "$", "translator", "->", "translate", "(", "'MSC.'", ".", "$", "buttonLabel", ")", ")", "!==", "$", "buttonLabel", ")", "{", "return", "$", "label", ";", "}", "// Fallback, just return the key as is it.", "return", "$", "buttonLabel", ";", "}" ]
Get the label for a button from the translator. The fallback is as follows: 1. Try to translate the button via the data definition name as translation section. 2. Try to translate the button name with the prefix 'MSC.'. 3. Return the input value as nothing worked out. @param string $buttonLabel The non translated label for the button. @return string
[ "Get", "the", "label", "for", "a", "button", "from", "the", "translator", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L306-L319
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.buildFieldSet
protected function buildFieldSet($widgetManager, $palette, $propertyValues) { $environment = $this->getEnvironment(); $definition = $this->getDataDefinition(); $translator = $environment->getTranslator(); $propertyDefinitions = $definition->getPropertiesDefinition(); $isAutoSubmit = ('auto' === $environment->getInputProvider()->getValue('SUBMIT_TYPE')); $legendStates = $this->getLegendStates(); $editInformation = $GLOBALS['container']['dc-general.edit-information']; $fieldSets = []; $first = true; foreach ($palette->getLegends() as $legend) { $legendName = $translator->translate( $legend->getName() . '_legend', $definition->getName() ); $fields = []; $properties = $legend->getProperties($this->model, $propertyValues); if (!$properties) { continue; } $legendVisible = $this->isLegendVisible($legend, $legendStates); foreach ($properties as $property) { $this->ensurePropertyExists($property->getName(), $propertyDefinitions); // If this property is invalid, fetch the error. if ((!$isAutoSubmit) && $propertyValues && $propertyValues->hasPropertyValue($property->getName()) && $propertyValues->isPropertyValueInvalid($property->getName()) ) { // Force legend open on error. $legendVisible = true; $editInformation->setModelError( $this->model, $propertyValues->getPropertyValueErrors($property->getName()), $propertyDefinitions->getProperty($property->getName()) ); } $fields[] = $widgetManager->renderWidget($property->getName(), $isAutoSubmit, $propertyValues); } $fieldSet['label'] = $legendName; $fieldSet['class'] = $this->getLegendClass($first, $legendVisible); $fieldSet['palette'] = \implode('', $fields); $fieldSet['legend'] = $legend->getName(); $fieldSets[] = $fieldSet; $first = false; } // Check if input mask has visible properties. if (!$fieldSets) { // @codingStandardsIgnoreStart \trigger_error('No visible properties for this edit mask defined!', E_USER_ERROR); // @codingStandardsIgnoreEnd } return $fieldSets; }
php
protected function buildFieldSet($widgetManager, $palette, $propertyValues) { $environment = $this->getEnvironment(); $definition = $this->getDataDefinition(); $translator = $environment->getTranslator(); $propertyDefinitions = $definition->getPropertiesDefinition(); $isAutoSubmit = ('auto' === $environment->getInputProvider()->getValue('SUBMIT_TYPE')); $legendStates = $this->getLegendStates(); $editInformation = $GLOBALS['container']['dc-general.edit-information']; $fieldSets = []; $first = true; foreach ($palette->getLegends() as $legend) { $legendName = $translator->translate( $legend->getName() . '_legend', $definition->getName() ); $fields = []; $properties = $legend->getProperties($this->model, $propertyValues); if (!$properties) { continue; } $legendVisible = $this->isLegendVisible($legend, $legendStates); foreach ($properties as $property) { $this->ensurePropertyExists($property->getName(), $propertyDefinitions); // If this property is invalid, fetch the error. if ((!$isAutoSubmit) && $propertyValues && $propertyValues->hasPropertyValue($property->getName()) && $propertyValues->isPropertyValueInvalid($property->getName()) ) { // Force legend open on error. $legendVisible = true; $editInformation->setModelError( $this->model, $propertyValues->getPropertyValueErrors($property->getName()), $propertyDefinitions->getProperty($property->getName()) ); } $fields[] = $widgetManager->renderWidget($property->getName(), $isAutoSubmit, $propertyValues); } $fieldSet['label'] = $legendName; $fieldSet['class'] = $this->getLegendClass($first, $legendVisible); $fieldSet['palette'] = \implode('', $fields); $fieldSet['legend'] = $legend->getName(); $fieldSets[] = $fieldSet; $first = false; } // Check if input mask has visible properties. if (!$fieldSets) { // @codingStandardsIgnoreStart \trigger_error('No visible properties for this edit mask defined!', E_USER_ERROR); // @codingStandardsIgnoreEnd } return $fieldSets; }
[ "protected", "function", "buildFieldSet", "(", "$", "widgetManager", ",", "$", "palette", ",", "$", "propertyValues", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "definition", "=", "$", "this", "->", "getDataDefinition", "(", ")", ";", "$", "translator", "=", "$", "environment", "->", "getTranslator", "(", ")", ";", "$", "propertyDefinitions", "=", "$", "definition", "->", "getPropertiesDefinition", "(", ")", ";", "$", "isAutoSubmit", "=", "(", "'auto'", "===", "$", "environment", "->", "getInputProvider", "(", ")", "->", "getValue", "(", "'SUBMIT_TYPE'", ")", ")", ";", "$", "legendStates", "=", "$", "this", "->", "getLegendStates", "(", ")", ";", "$", "editInformation", "=", "$", "GLOBALS", "[", "'container'", "]", "[", "'dc-general.edit-information'", "]", ";", "$", "fieldSets", "=", "[", "]", ";", "$", "first", "=", "true", ";", "foreach", "(", "$", "palette", "->", "getLegends", "(", ")", "as", "$", "legend", ")", "{", "$", "legendName", "=", "$", "translator", "->", "translate", "(", "$", "legend", "->", "getName", "(", ")", ".", "'_legend'", ",", "$", "definition", "->", "getName", "(", ")", ")", ";", "$", "fields", "=", "[", "]", ";", "$", "properties", "=", "$", "legend", "->", "getProperties", "(", "$", "this", "->", "model", ",", "$", "propertyValues", ")", ";", "if", "(", "!", "$", "properties", ")", "{", "continue", ";", "}", "$", "legendVisible", "=", "$", "this", "->", "isLegendVisible", "(", "$", "legend", ",", "$", "legendStates", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "this", "->", "ensurePropertyExists", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "propertyDefinitions", ")", ";", "// If this property is invalid, fetch the error.", "if", "(", "(", "!", "$", "isAutoSubmit", ")", "&&", "$", "propertyValues", "&&", "$", "propertyValues", "->", "hasPropertyValue", "(", "$", "property", "->", "getName", "(", ")", ")", "&&", "$", "propertyValues", "->", "isPropertyValueInvalid", "(", "$", "property", "->", "getName", "(", ")", ")", ")", "{", "// Force legend open on error.", "$", "legendVisible", "=", "true", ";", "$", "editInformation", "->", "setModelError", "(", "$", "this", "->", "model", ",", "$", "propertyValues", "->", "getPropertyValueErrors", "(", "$", "property", "->", "getName", "(", ")", ")", ",", "$", "propertyDefinitions", "->", "getProperty", "(", "$", "property", "->", "getName", "(", ")", ")", ")", ";", "}", "$", "fields", "[", "]", "=", "$", "widgetManager", "->", "renderWidget", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "isAutoSubmit", ",", "$", "propertyValues", ")", ";", "}", "$", "fieldSet", "[", "'label'", "]", "=", "$", "legendName", ";", "$", "fieldSet", "[", "'class'", "]", "=", "$", "this", "->", "getLegendClass", "(", "$", "first", ",", "$", "legendVisible", ")", ";", "$", "fieldSet", "[", "'palette'", "]", "=", "\\", "implode", "(", "''", ",", "$", "fields", ")", ";", "$", "fieldSet", "[", "'legend'", "]", "=", "$", "legend", "->", "getName", "(", ")", ";", "$", "fieldSets", "[", "]", "=", "$", "fieldSet", ";", "$", "first", "=", "false", ";", "}", "// Check if input mask has visible properties.", "if", "(", "!", "$", "fieldSets", ")", "{", "// @codingStandardsIgnoreStart", "\\", "trigger_error", "(", "'No visible properties for this edit mask defined!'", ",", "E_USER_ERROR", ")", ";", "// @codingStandardsIgnoreEnd", "}", "return", "$", "fieldSets", ";", "}" ]
Build the field sets. @param ContaoWidgetManager $widgetManager The widget manager in use. @param PaletteInterface $palette The palette to use. @param PropertyValueBag $propertyValues The property values. @return array @SuppressWarnings(PHPMD.Superglobals)
[ "Build", "the", "field", "sets", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L448-L513
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.handleSubmit
protected function handleSubmit(ModelInterface $model) { $environment = $this->getEnvironment(); $dispatcher = $environment->getEventDispatcher(); $inputProvider = $environment->getInputProvider(); if ($inputProvider->hasValue('save')) { $newUrlEvent = new AddToUrlEvent('act=edit&id=' . ModelId::fromModel($model)->getSerialized()); $dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getUrl())); } elseif ($inputProvider->hasValue('saveNclose')) { $this->clearBackendStates(); $newUrlEvent = new GetReferrerEvent(); $dispatcher->dispatch(ContaoEvents::SYSTEM_GET_REFERRER, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getReferrerUrl())); } elseif ($inputProvider->hasValue('saveNcreate')) { $this->clearBackendStates(); $after = ModelId::fromModel($model); $newUrlEvent = new AddToUrlEvent('act=create&id=&after=' . $after->getSerialized()); $dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getUrl())); } elseif ($inputProvider->hasValue('saveNback')) { $this->clearBackendStates(); $parentProviderName = $environment->getDataDefinition()->getBasicDefinition()->getParentDataProvider(); $newUrlEvent = new GetReferrerEvent(false, $parentProviderName); $dispatcher->dispatch(ContaoEvents::SYSTEM_GET_REFERRER, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getReferrerUrl())); } }
php
protected function handleSubmit(ModelInterface $model) { $environment = $this->getEnvironment(); $dispatcher = $environment->getEventDispatcher(); $inputProvider = $environment->getInputProvider(); if ($inputProvider->hasValue('save')) { $newUrlEvent = new AddToUrlEvent('act=edit&id=' . ModelId::fromModel($model)->getSerialized()); $dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getUrl())); } elseif ($inputProvider->hasValue('saveNclose')) { $this->clearBackendStates(); $newUrlEvent = new GetReferrerEvent(); $dispatcher->dispatch(ContaoEvents::SYSTEM_GET_REFERRER, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getReferrerUrl())); } elseif ($inputProvider->hasValue('saveNcreate')) { $this->clearBackendStates(); $after = ModelId::fromModel($model); $newUrlEvent = new AddToUrlEvent('act=create&id=&after=' . $after->getSerialized()); $dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getUrl())); } elseif ($inputProvider->hasValue('saveNback')) { $this->clearBackendStates(); $parentProviderName = $environment->getDataDefinition()->getBasicDefinition()->getParentDataProvider(); $newUrlEvent = new GetReferrerEvent(false, $parentProviderName); $dispatcher->dispatch(ContaoEvents::SYSTEM_GET_REFERRER, $newUrlEvent); $dispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($newUrlEvent->getReferrerUrl())); } }
[ "protected", "function", "handleSubmit", "(", "ModelInterface", "$", "model", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "dispatcher", "=", "$", "environment", "->", "getEventDispatcher", "(", ")", ";", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "if", "(", "$", "inputProvider", "->", "hasValue", "(", "'save'", ")", ")", "{", "$", "newUrlEvent", "=", "new", "AddToUrlEvent", "(", "'act=edit&id='", ".", "ModelId", "::", "fromModel", "(", "$", "model", ")", "->", "getSerialized", "(", ")", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "BACKEND_ADD_TO_URL", ",", "$", "newUrlEvent", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "CONTROLLER_REDIRECT", ",", "new", "RedirectEvent", "(", "$", "newUrlEvent", "->", "getUrl", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "inputProvider", "->", "hasValue", "(", "'saveNclose'", ")", ")", "{", "$", "this", "->", "clearBackendStates", "(", ")", ";", "$", "newUrlEvent", "=", "new", "GetReferrerEvent", "(", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "SYSTEM_GET_REFERRER", ",", "$", "newUrlEvent", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "CONTROLLER_REDIRECT", ",", "new", "RedirectEvent", "(", "$", "newUrlEvent", "->", "getReferrerUrl", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "inputProvider", "->", "hasValue", "(", "'saveNcreate'", ")", ")", "{", "$", "this", "->", "clearBackendStates", "(", ")", ";", "$", "after", "=", "ModelId", "::", "fromModel", "(", "$", "model", ")", ";", "$", "newUrlEvent", "=", "new", "AddToUrlEvent", "(", "'act=create&id=&after='", ".", "$", "after", "->", "getSerialized", "(", ")", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "BACKEND_ADD_TO_URL", ",", "$", "newUrlEvent", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "CONTROLLER_REDIRECT", ",", "new", "RedirectEvent", "(", "$", "newUrlEvent", "->", "getUrl", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "inputProvider", "->", "hasValue", "(", "'saveNback'", ")", ")", "{", "$", "this", "->", "clearBackendStates", "(", ")", ";", "$", "parentProviderName", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getBasicDefinition", "(", ")", "->", "getParentDataProvider", "(", ")", ";", "$", "newUrlEvent", "=", "new", "GetReferrerEvent", "(", "false", ",", "$", "parentProviderName", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "SYSTEM_GET_REFERRER", ",", "$", "newUrlEvent", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "CONTROLLER_REDIRECT", ",", "new", "RedirectEvent", "(", "$", "newUrlEvent", "->", "getReferrerUrl", "(", ")", ")", ")", ";", "}", "}" ]
Handle the submit and determine which button has been triggered. This method will redirect the client. @param ModelInterface $model The model that has been submitted. @return void @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Handle", "the", "submit", "and", "determine", "which", "button", "has", "been", "triggered", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L570-L602
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.getHeadline
protected function getHeadline() { $definitionName = $this->getDataDefinition()->getName(); $translator = $this->getEnvironment()->getTranslator(); if ($this->model->getId()) { $headline = $translator->translate('editRecord', $definitionName, [$this->model->getId()]); if ('editRecord' !== $headline) { return $headline; } return $translator->translate('MSC.editRecord', null, [$this->model->getId()]); } $headline = $translator->translate('newRecord', $definitionName, [$this->model->getId()]); if ('newRecord' !== $headline) { return $headline; } return $translator->translate('MSC.editRecord', null, ['']); }
php
protected function getHeadline() { $definitionName = $this->getDataDefinition()->getName(); $translator = $this->getEnvironment()->getTranslator(); if ($this->model->getId()) { $headline = $translator->translate('editRecord', $definitionName, [$this->model->getId()]); if ('editRecord' !== $headline) { return $headline; } return $translator->translate('MSC.editRecord', null, [$this->model->getId()]); } $headline = $translator->translate('newRecord', $definitionName, [$this->model->getId()]); if ('newRecord' !== $headline) { return $headline; } return $translator->translate('MSC.editRecord', null, ['']); }
[ "protected", "function", "getHeadline", "(", ")", "{", "$", "definitionName", "=", "$", "this", "->", "getDataDefinition", "(", ")", "->", "getName", "(", ")", ";", "$", "translator", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getTranslator", "(", ")", ";", "if", "(", "$", "this", "->", "model", "->", "getId", "(", ")", ")", "{", "$", "headline", "=", "$", "translator", "->", "translate", "(", "'editRecord'", ",", "$", "definitionName", ",", "[", "$", "this", "->", "model", "->", "getId", "(", ")", "]", ")", ";", "if", "(", "'editRecord'", "!==", "$", "headline", ")", "{", "return", "$", "headline", ";", "}", "return", "$", "translator", "->", "translate", "(", "'MSC.editRecord'", ",", "null", ",", "[", "$", "this", "->", "model", "->", "getId", "(", ")", "]", ")", ";", "}", "$", "headline", "=", "$", "translator", "->", "translate", "(", "'newRecord'", ",", "$", "definitionName", ",", "[", "$", "this", "->", "model", "->", "getId", "(", ")", "]", ")", ";", "if", "(", "'newRecord'", "!==", "$", "headline", ")", "{", "return", "$", "headline", ";", "}", "return", "$", "translator", "->", "translate", "(", "'MSC.editRecord'", ",", "null", ",", "[", "''", "]", ")", ";", "}" ]
Determine the headline to use. @return string.
[ "Determine", "the", "headline", "to", "use", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L609-L629
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.doPersist
protected function doPersist() { $environment = $this->getEnvironment(); $dataProvider = $environment->getDataProvider($this->model->getProviderName()); $inputProvider = $environment->getInputProvider(); if (!$this->model->getMeta(ModelInterface::IS_CHANGED)) { return true; } $this->handlePrePersist(); if ((null === $this->model->getId()) && $this->getManualSortingProperty()) { $models = $dataProvider->getEmptyCollection(); $models->push($this->model); $controller = $environment->getController(); if ($inputProvider->hasParameter('after')) { $after = ModelId::fromSerialized($inputProvider->getParameter('after')); $previousDataProvider = $environment->getDataProvider($after->getDataProviderName()); $previousFetchConfig = $previousDataProvider->getEmptyConfig(); $previousFetchConfig->setId($after->getId()); $previousModel = $previousDataProvider->fetch($previousFetchConfig); if ($previousModel) { $controller->pasteAfter($previousModel, $models, $this->getManualSortingProperty()); } else { $controller->pasteTop($models, $this->getManualSortingProperty()); } } elseif ($inputProvider->hasParameter('into')) { $into = ModelId::fromSerialized($inputProvider->getParameter('into')); $parentDataProvider = $environment->getDataProvider($into->getDataProviderName()); $parentFetchConfig = $parentDataProvider->getEmptyConfig(); $parentFetchConfig->setId($into->getId()); $parentModel = $parentDataProvider->fetch($parentFetchConfig); if ($parentModel) { $controller->pasteInto($parentModel, $models, $this->getManualSortingProperty()); } else { $controller->pasteTop($models, $this->getManualSortingProperty()); } } else { $controller->pasteTop($models, $this->getManualSortingProperty()); } $environment->getClipboard()->clear()->saveTo($environment); } else { if (!$this->allValuesUnique()) { return false; } $editInformation = $GLOBALS['container']['dc-general.edit-information']; // Save the model. $dataProvider->save($this->model, $editInformation->uniformTime()); } $this->handlePostPersist(); $this->storeVersion($this->model); return true; }
php
protected function doPersist() { $environment = $this->getEnvironment(); $dataProvider = $environment->getDataProvider($this->model->getProviderName()); $inputProvider = $environment->getInputProvider(); if (!$this->model->getMeta(ModelInterface::IS_CHANGED)) { return true; } $this->handlePrePersist(); if ((null === $this->model->getId()) && $this->getManualSortingProperty()) { $models = $dataProvider->getEmptyCollection(); $models->push($this->model); $controller = $environment->getController(); if ($inputProvider->hasParameter('after')) { $after = ModelId::fromSerialized($inputProvider->getParameter('after')); $previousDataProvider = $environment->getDataProvider($after->getDataProviderName()); $previousFetchConfig = $previousDataProvider->getEmptyConfig(); $previousFetchConfig->setId($after->getId()); $previousModel = $previousDataProvider->fetch($previousFetchConfig); if ($previousModel) { $controller->pasteAfter($previousModel, $models, $this->getManualSortingProperty()); } else { $controller->pasteTop($models, $this->getManualSortingProperty()); } } elseif ($inputProvider->hasParameter('into')) { $into = ModelId::fromSerialized($inputProvider->getParameter('into')); $parentDataProvider = $environment->getDataProvider($into->getDataProviderName()); $parentFetchConfig = $parentDataProvider->getEmptyConfig(); $parentFetchConfig->setId($into->getId()); $parentModel = $parentDataProvider->fetch($parentFetchConfig); if ($parentModel) { $controller->pasteInto($parentModel, $models, $this->getManualSortingProperty()); } else { $controller->pasteTop($models, $this->getManualSortingProperty()); } } else { $controller->pasteTop($models, $this->getManualSortingProperty()); } $environment->getClipboard()->clear()->saveTo($environment); } else { if (!$this->allValuesUnique()) { return false; } $editInformation = $GLOBALS['container']['dc-general.edit-information']; // Save the model. $dataProvider->save($this->model, $editInformation->uniformTime()); } $this->handlePostPersist(); $this->storeVersion($this->model); return true; }
[ "protected", "function", "doPersist", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "dataProvider", "=", "$", "environment", "->", "getDataProvider", "(", "$", "this", "->", "model", "->", "getProviderName", "(", ")", ")", ";", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "if", "(", "!", "$", "this", "->", "model", "->", "getMeta", "(", "ModelInterface", "::", "IS_CHANGED", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "handlePrePersist", "(", ")", ";", "if", "(", "(", "null", "===", "$", "this", "->", "model", "->", "getId", "(", ")", ")", "&&", "$", "this", "->", "getManualSortingProperty", "(", ")", ")", "{", "$", "models", "=", "$", "dataProvider", "->", "getEmptyCollection", "(", ")", ";", "$", "models", "->", "push", "(", "$", "this", "->", "model", ")", ";", "$", "controller", "=", "$", "environment", "->", "getController", "(", ")", ";", "if", "(", "$", "inputProvider", "->", "hasParameter", "(", "'after'", ")", ")", "{", "$", "after", "=", "ModelId", "::", "fromSerialized", "(", "$", "inputProvider", "->", "getParameter", "(", "'after'", ")", ")", ";", "$", "previousDataProvider", "=", "$", "environment", "->", "getDataProvider", "(", "$", "after", "->", "getDataProviderName", "(", ")", ")", ";", "$", "previousFetchConfig", "=", "$", "previousDataProvider", "->", "getEmptyConfig", "(", ")", ";", "$", "previousFetchConfig", "->", "setId", "(", "$", "after", "->", "getId", "(", ")", ")", ";", "$", "previousModel", "=", "$", "previousDataProvider", "->", "fetch", "(", "$", "previousFetchConfig", ")", ";", "if", "(", "$", "previousModel", ")", "{", "$", "controller", "->", "pasteAfter", "(", "$", "previousModel", ",", "$", "models", ",", "$", "this", "->", "getManualSortingProperty", "(", ")", ")", ";", "}", "else", "{", "$", "controller", "->", "pasteTop", "(", "$", "models", ",", "$", "this", "->", "getManualSortingProperty", "(", ")", ")", ";", "}", "}", "elseif", "(", "$", "inputProvider", "->", "hasParameter", "(", "'into'", ")", ")", "{", "$", "into", "=", "ModelId", "::", "fromSerialized", "(", "$", "inputProvider", "->", "getParameter", "(", "'into'", ")", ")", ";", "$", "parentDataProvider", "=", "$", "environment", "->", "getDataProvider", "(", "$", "into", "->", "getDataProviderName", "(", ")", ")", ";", "$", "parentFetchConfig", "=", "$", "parentDataProvider", "->", "getEmptyConfig", "(", ")", ";", "$", "parentFetchConfig", "->", "setId", "(", "$", "into", "->", "getId", "(", ")", ")", ";", "$", "parentModel", "=", "$", "parentDataProvider", "->", "fetch", "(", "$", "parentFetchConfig", ")", ";", "if", "(", "$", "parentModel", ")", "{", "$", "controller", "->", "pasteInto", "(", "$", "parentModel", ",", "$", "models", ",", "$", "this", "->", "getManualSortingProperty", "(", ")", ")", ";", "}", "else", "{", "$", "controller", "->", "pasteTop", "(", "$", "models", ",", "$", "this", "->", "getManualSortingProperty", "(", ")", ")", ";", "}", "}", "else", "{", "$", "controller", "->", "pasteTop", "(", "$", "models", ",", "$", "this", "->", "getManualSortingProperty", "(", ")", ")", ";", "}", "$", "environment", "->", "getClipboard", "(", ")", "->", "clear", "(", ")", "->", "saveTo", "(", "$", "environment", ")", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "allValuesUnique", "(", ")", ")", "{", "return", "false", ";", "}", "$", "editInformation", "=", "$", "GLOBALS", "[", "'container'", "]", "[", "'dc-general.edit-information'", "]", ";", "// Save the model.", "$", "dataProvider", "->", "save", "(", "$", "this", "->", "model", ",", "$", "editInformation", "->", "uniformTime", "(", ")", ")", ";", "}", "$", "this", "->", "handlePostPersist", "(", ")", ";", "$", "this", "->", "storeVersion", "(", "$", "this", "->", "model", ")", ";", "return", "true", ";", "}" ]
Handle the persisting of the currently loaded model. @return bool True means everything is okay, False error. @SuppressWarnings(PHPMD.Superglobals)
[ "Handle", "the", "persisting", "of", "the", "currently", "loaded", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L638-L702
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.allValuesUnique
protected function allValuesUnique() { // Init some vars. $environment = $this->getEnvironment(); $translator = $environment->getTranslator(); $dataProvider = $environment->getDataProvider($this->model->getProviderName()); $editInformation = $GLOBALS['container']['dc-general.edit-information']; // Run each and check the unique flag. foreach ($this->getDataDefinition()->getPropertiesDefinition()->getPropertyNames() as $propertyName) { $definition = $this->getDataDefinition()->getPropertiesDefinition()->getProperty($propertyName); $extra = $definition->getExtra(); $value = $this->model->getProperty($propertyName); // Check the flag and the value. if (('' !== $value) && $extra['unique'] && isset($extra['unique'])) { // Check the database. If return true the value is already in the database. if (!$dataProvider->isUniqueValue($propertyName, $value, $this->model->getId())) { $editInformation->setModelError( $this->model, [$translator->translate('not_unique', 'MSC', [$propertyName])], $definition ); return false; } } } return true; }
php
protected function allValuesUnique() { // Init some vars. $environment = $this->getEnvironment(); $translator = $environment->getTranslator(); $dataProvider = $environment->getDataProvider($this->model->getProviderName()); $editInformation = $GLOBALS['container']['dc-general.edit-information']; // Run each and check the unique flag. foreach ($this->getDataDefinition()->getPropertiesDefinition()->getPropertyNames() as $propertyName) { $definition = $this->getDataDefinition()->getPropertiesDefinition()->getProperty($propertyName); $extra = $definition->getExtra(); $value = $this->model->getProperty($propertyName); // Check the flag and the value. if (('' !== $value) && $extra['unique'] && isset($extra['unique'])) { // Check the database. If return true the value is already in the database. if (!$dataProvider->isUniqueValue($propertyName, $value, $this->model->getId())) { $editInformation->setModelError( $this->model, [$translator->translate('not_unique', 'MSC', [$propertyName])], $definition ); return false; } } } return true; }
[ "protected", "function", "allValuesUnique", "(", ")", "{", "// Init some vars.", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "translator", "=", "$", "environment", "->", "getTranslator", "(", ")", ";", "$", "dataProvider", "=", "$", "environment", "->", "getDataProvider", "(", "$", "this", "->", "model", "->", "getProviderName", "(", ")", ")", ";", "$", "editInformation", "=", "$", "GLOBALS", "[", "'container'", "]", "[", "'dc-general.edit-information'", "]", ";", "// Run each and check the unique flag.", "foreach", "(", "$", "this", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", "->", "getPropertyNames", "(", ")", "as", "$", "propertyName", ")", "{", "$", "definition", "=", "$", "this", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", "->", "getProperty", "(", "$", "propertyName", ")", ";", "$", "extra", "=", "$", "definition", "->", "getExtra", "(", ")", ";", "$", "value", "=", "$", "this", "->", "model", "->", "getProperty", "(", "$", "propertyName", ")", ";", "// Check the flag and the value.", "if", "(", "(", "''", "!==", "$", "value", ")", "&&", "$", "extra", "[", "'unique'", "]", "&&", "isset", "(", "$", "extra", "[", "'unique'", "]", ")", ")", "{", "// Check the database. If return true the value is already in the database.", "if", "(", "!", "$", "dataProvider", "->", "isUniqueValue", "(", "$", "propertyName", ",", "$", "value", ",", "$", "this", "->", "model", "->", "getId", "(", ")", ")", ")", "{", "$", "editInformation", "->", "setModelError", "(", "$", "this", "->", "model", ",", "[", "$", "translator", "->", "translate", "(", "'not_unique'", ",", "'MSC'", ",", "[", "$", "propertyName", "]", ")", "]", ",", "$", "definition", ")", ";", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Check if all values are unique, but only for the fields which have the option enabled. @return bool True => everything is okay | False => One value is not unique. @SuppressWarnings(PHPMD.Superglobals)
[ "Check", "if", "all", "values", "are", "unique", "but", "only", "for", "the", "fields", "which", "have", "the", "option", "enabled", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L711-L741
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.isLegendVisible
private function isLegendVisible($legend, $legendStates) { if (\array_key_exists($legend->getName(), $legendStates)) { return $legendStates[$legend->getName()]; } return $legend->isInitialVisible(); }
php
private function isLegendVisible($legend, $legendStates) { if (\array_key_exists($legend->getName(), $legendStates)) { return $legendStates[$legend->getName()]; } return $legend->isInitialVisible(); }
[ "private", "function", "isLegendVisible", "(", "$", "legend", ",", "$", "legendStates", ")", "{", "if", "(", "\\", "array_key_exists", "(", "$", "legend", "->", "getName", "(", ")", ",", "$", "legendStates", ")", ")", "{", "return", "$", "legendStates", "[", "$", "legend", "->", "getName", "(", ")", "]", ";", "}", "return", "$", "legend", "->", "isInitialVisible", "(", ")", ";", "}" ]
Determine if the passed legend is visible or collapsed. @param LegendInterface $legend The legend. @param bool[] $legendStates The states from the session. @return bool
[ "Determine", "if", "the", "passed", "legend", "is", "visible", "or", "collapsed", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L894-L901
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/EditMask.php
EditMask.getLegendStates
private function getLegendStates() { $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $legendStates = $environment->getSessionStorage()->get('LEGENDS') ?: []; if (\array_key_exists($definition->getName(), $legendStates)) { $legendStates = $legendStates[$definition->getName()]; return $legendStates; } $legendStates = []; return $legendStates; }
php
private function getLegendStates() { $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $legendStates = $environment->getSessionStorage()->get('LEGENDS') ?: []; if (\array_key_exists($definition->getName(), $legendStates)) { $legendStates = $legendStates[$definition->getName()]; return $legendStates; } $legendStates = []; return $legendStates; }
[ "private", "function", "getLegendStates", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "definition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "legendStates", "=", "$", "environment", "->", "getSessionStorage", "(", ")", "->", "get", "(", "'LEGENDS'", ")", "?", ":", "[", "]", ";", "if", "(", "\\", "array_key_exists", "(", "$", "definition", "->", "getName", "(", ")", ",", "$", "legendStates", ")", ")", "{", "$", "legendStates", "=", "$", "legendStates", "[", "$", "definition", "->", "getName", "(", ")", "]", ";", "return", "$", "legendStates", ";", "}", "$", "legendStates", "=", "[", "]", ";", "return", "$", "legendStates", ";", "}" ]
Obtain the legend states. @return array
[ "Obtain", "the", "legend", "states", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/EditMask.php#L908-L923
train
contao-community-alliance/dc-general
src/Data/ModelId.php
ModelId.getSerialized
public function getSerialized() { if (\is_numeric($this->modelId)) { return \sprintf('%s::%s', $this->dataProviderName, $this->modelId); } return \sprintf('%s::%s', $this->dataProviderName, \base64_encode(\json_encode($this->modelId))); }
php
public function getSerialized() { if (\is_numeric($this->modelId)) { return \sprintf('%s::%s', $this->dataProviderName, $this->modelId); } return \sprintf('%s::%s', $this->dataProviderName, \base64_encode(\json_encode($this->modelId))); }
[ "public", "function", "getSerialized", "(", ")", "{", "if", "(", "\\", "is_numeric", "(", "$", "this", "->", "modelId", ")", ")", "{", "return", "\\", "sprintf", "(", "'%s::%s'", ",", "$", "this", "->", "dataProviderName", ",", "$", "this", "->", "modelId", ")", ";", "}", "return", "\\", "sprintf", "(", "'%s::%s'", ",", "$", "this", "->", "dataProviderName", ",", "\\", "base64_encode", "(", "\\", "json_encode", "(", "$", "this", "->", "modelId", ")", ")", ")", ";", "}" ]
Serialize the id. @return string
[ "Serialize", "the", "id", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/ModelId.php#L135-L142
train
contao-community-alliance/dc-general
src/Contao/Callback/ContainerHeaderCallbackListener.php
ContainerHeaderCallbackListener.update
public function update($event, $value) { if (null === $value) { return; } $event->setAdditional($value); $event->stopPropagation(); }
php
public function update($event, $value) { if (null === $value) { return; } $event->setAdditional($value); $event->stopPropagation(); }
[ "public", "function", "update", "(", "$", "event", ",", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", ";", "}", "$", "event", "->", "setAdditional", "(", "$", "value", ")", ";", "$", "event", "->", "stopPropagation", "(", ")", ";", "}" ]
Update the event with the information returned by the callback. @param GetParentHeaderEvent $event The event being emitted. @param array $value The additional information. @return void
[ "Update", "the", "event", "with", "the", "information", "returned", "by", "the", "callback", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Callback/ContainerHeaderCallbackListener.php#L54-L62
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php
LanguageFilter.handleAction
public function handleAction(ActionEvent $event) { if (!$this->scopeDeterminator->currentScopeIsBackend()) { return; } $this->checkLanguage($event->getEnvironment(), 'create' === $event->getAction()->getName()); }
php
public function handleAction(ActionEvent $event) { if (!$this->scopeDeterminator->currentScopeIsBackend()) { return; } $this->checkLanguage($event->getEnvironment(), 'create' === $event->getAction()->getName()); }
[ "public", "function", "handleAction", "(", "ActionEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "scopeDeterminator", "->", "currentScopeIsBackend", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "checkLanguage", "(", "$", "event", "->", "getEnvironment", "(", ")", ",", "'create'", "===", "$", "event", "->", "getAction", "(", ")", "->", "getName", "(", ")", ")", ";", "}" ]
Handle action events. @param ActionEvent $event The action event. @return void
[ "Handle", "action", "events", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php#L76-L83
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php
LanguageFilter.checkLanguage
private function checkLanguage($environment, $resetToFallback) { $sessionStorage = $environment->getSessionStorage(); $dataProvider = $environment->getDataProvider(); $providerName = $environment->getDataDefinition()->getName(); $modelId = $this->modelIdFromInput($environment->getInputProvider()); $languages = $environment->getController()->getSupportedLanguages($modelId); if (!$languages) { return; } // Exit out when not a multi language provider. if (!($dataProvider instanceof MultiLanguageDataProviderInterface)) { return; } // If a new item, we MUST reset to the fallback as that is the first language that has to be stored // and set this language to session. if ((null === $modelId) && $resetToFallback) { $dataProvider->setCurrentLanguage($dataProvider->getFallbackLanguage(null)->getLocale()); $session['ml_support'][$providerName] = $dataProvider->getCurrentLanguage(); $sessionStorage->set('dc_general', $session); return; } $this->checkLanguageSubmit($environment, $languages); // Load language from Session. $session = (array) $sessionStorage->get('dc_general'); // Try to get the language from session. $currentLanguage = ($session['ml_support'][$providerName] ?? $GLOBALS['TL_LANGUAGE']); if (!\array_key_exists($currentLanguage, $languages)) { $currentLanguage = $dataProvider->getFallbackLanguage($modelId)->getLocale(); } $session['ml_support'][$providerName] = $currentLanguage; $sessionStorage->set('dc_general', $session); $dataProvider->setCurrentLanguage($currentLanguage); }
php
private function checkLanguage($environment, $resetToFallback) { $sessionStorage = $environment->getSessionStorage(); $dataProvider = $environment->getDataProvider(); $providerName = $environment->getDataDefinition()->getName(); $modelId = $this->modelIdFromInput($environment->getInputProvider()); $languages = $environment->getController()->getSupportedLanguages($modelId); if (!$languages) { return; } // Exit out when not a multi language provider. if (!($dataProvider instanceof MultiLanguageDataProviderInterface)) { return; } // If a new item, we MUST reset to the fallback as that is the first language that has to be stored // and set this language to session. if ((null === $modelId) && $resetToFallback) { $dataProvider->setCurrentLanguage($dataProvider->getFallbackLanguage(null)->getLocale()); $session['ml_support'][$providerName] = $dataProvider->getCurrentLanguage(); $sessionStorage->set('dc_general', $session); return; } $this->checkLanguageSubmit($environment, $languages); // Load language from Session. $session = (array) $sessionStorage->get('dc_general'); // Try to get the language from session. $currentLanguage = ($session['ml_support'][$providerName] ?? $GLOBALS['TL_LANGUAGE']); if (!\array_key_exists($currentLanguage, $languages)) { $currentLanguage = $dataProvider->getFallbackLanguage($modelId)->getLocale(); } $session['ml_support'][$providerName] = $currentLanguage; $sessionStorage->set('dc_general', $session); $dataProvider->setCurrentLanguage($currentLanguage); }
[ "private", "function", "checkLanguage", "(", "$", "environment", ",", "$", "resetToFallback", ")", "{", "$", "sessionStorage", "=", "$", "environment", "->", "getSessionStorage", "(", ")", ";", "$", "dataProvider", "=", "$", "environment", "->", "getDataProvider", "(", ")", ";", "$", "providerName", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getName", "(", ")", ";", "$", "modelId", "=", "$", "this", "->", "modelIdFromInput", "(", "$", "environment", "->", "getInputProvider", "(", ")", ")", ";", "$", "languages", "=", "$", "environment", "->", "getController", "(", ")", "->", "getSupportedLanguages", "(", "$", "modelId", ")", ";", "if", "(", "!", "$", "languages", ")", "{", "return", ";", "}", "// Exit out when not a multi language provider.", "if", "(", "!", "(", "$", "dataProvider", "instanceof", "MultiLanguageDataProviderInterface", ")", ")", "{", "return", ";", "}", "// If a new item, we MUST reset to the fallback as that is the first language that has to be stored", "// and set this language to session.", "if", "(", "(", "null", "===", "$", "modelId", ")", "&&", "$", "resetToFallback", ")", "{", "$", "dataProvider", "->", "setCurrentLanguage", "(", "$", "dataProvider", "->", "getFallbackLanguage", "(", "null", ")", "->", "getLocale", "(", ")", ")", ";", "$", "session", "[", "'ml_support'", "]", "[", "$", "providerName", "]", "=", "$", "dataProvider", "->", "getCurrentLanguage", "(", ")", ";", "$", "sessionStorage", "->", "set", "(", "'dc_general'", ",", "$", "session", ")", ";", "return", ";", "}", "$", "this", "->", "checkLanguageSubmit", "(", "$", "environment", ",", "$", "languages", ")", ";", "// Load language from Session.", "$", "session", "=", "(", "array", ")", "$", "sessionStorage", "->", "get", "(", "'dc_general'", ")", ";", "// Try to get the language from session.", "$", "currentLanguage", "=", "(", "$", "session", "[", "'ml_support'", "]", "[", "$", "providerName", "]", "??", "$", "GLOBALS", "[", "'TL_LANGUAGE'", "]", ")", ";", "if", "(", "!", "\\", "array_key_exists", "(", "$", "currentLanguage", ",", "$", "languages", ")", ")", "{", "$", "currentLanguage", "=", "$", "dataProvider", "->", "getFallbackLanguage", "(", "$", "modelId", ")", "->", "getLocale", "(", ")", ";", "}", "$", "session", "[", "'ml_support'", "]", "[", "$", "providerName", "]", "=", "$", "currentLanguage", ";", "$", "sessionStorage", "->", "set", "(", "'dc_general'", ",", "$", "session", ")", ";", "$", "dataProvider", "->", "setCurrentLanguage", "(", "$", "currentLanguage", ")", ";", "}" ]
Check if the data provider is multi language and prepare the data provider with the selected language. @param EnvironmentInterface $environment The environment. @param bool $resetToFallback Flag if the language must be reset to the fallback. @return void @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Check", "if", "the", "data", "provider", "is", "multi", "language", "and", "prepare", "the", "data", "provider", "with", "the", "selected", "language", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php#L96-L138
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php
LanguageFilter.checkLanguageSubmit
private function checkLanguageSubmit($environment, $languages) { $inputProvider = $environment->getInputProvider(); if ('language_switch' !== $inputProvider->getValue('FORM_SUBMIT')) { return; } // Get/Check the new language. if ($inputProvider->hasValue('language') && \array_key_exists($inputProvider->getValue('language'), $languages) ) { $session['ml_support'][$environment->getDataDefinition()->getName()] = $inputProvider->getValue('language'); $environment->getSessionStorage()->set('dc_general', $session); } $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_RELOAD, new ReloadEvent()); }
php
private function checkLanguageSubmit($environment, $languages) { $inputProvider = $environment->getInputProvider(); if ('language_switch' !== $inputProvider->getValue('FORM_SUBMIT')) { return; } // Get/Check the new language. if ($inputProvider->hasValue('language') && \array_key_exists($inputProvider->getValue('language'), $languages) ) { $session['ml_support'][$environment->getDataDefinition()->getName()] = $inputProvider->getValue('language'); $environment->getSessionStorage()->set('dc_general', $session); } $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_RELOAD, new ReloadEvent()); }
[ "private", "function", "checkLanguageSubmit", "(", "$", "environment", ",", "$", "languages", ")", "{", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "if", "(", "'language_switch'", "!==", "$", "inputProvider", "->", "getValue", "(", "'FORM_SUBMIT'", ")", ")", "{", "return", ";", "}", "// Get/Check the new language.", "if", "(", "$", "inputProvider", "->", "hasValue", "(", "'language'", ")", "&&", "\\", "array_key_exists", "(", "$", "inputProvider", "->", "getValue", "(", "'language'", ")", ",", "$", "languages", ")", ")", "{", "$", "session", "[", "'ml_support'", "]", "[", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getName", "(", ")", "]", "=", "$", "inputProvider", "->", "getValue", "(", "'language'", ")", ";", "$", "environment", "->", "getSessionStorage", "(", ")", "->", "set", "(", "'dc_general'", ",", "$", "session", ")", ";", "}", "$", "environment", "->", "getEventDispatcher", "(", ")", "->", "dispatch", "(", "ContaoEvents", "::", "CONTROLLER_RELOAD", ",", "new", "ReloadEvent", "(", ")", ")", ";", "}" ]
Check if the language has been switched. If so, the value in the session will be updated and the page reloaded. @param EnvironmentInterface $environment The environment. @param array $languages The valid languages. @return void
[ "Check", "if", "the", "language", "has", "been", "switched", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php#L150-L167
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php
LanguageFilter.modelIdFromInput
private function modelIdFromInput(InputProviderInterface $inputProvider) { if ($inputProvider->hasParameter('id') && $inputProvider->getParameter('id')) { return ModelId::fromSerialized($inputProvider->getParameter('id'))->getId(); } return null; }
php
private function modelIdFromInput(InputProviderInterface $inputProvider) { if ($inputProvider->hasParameter('id') && $inputProvider->getParameter('id')) { return ModelId::fromSerialized($inputProvider->getParameter('id'))->getId(); } return null; }
[ "private", "function", "modelIdFromInput", "(", "InputProviderInterface", "$", "inputProvider", ")", "{", "if", "(", "$", "inputProvider", "->", "hasParameter", "(", "'id'", ")", "&&", "$", "inputProvider", "->", "getParameter", "(", "'id'", ")", ")", "{", "return", "ModelId", "::", "fromSerialized", "(", "$", "inputProvider", "->", "getParameter", "(", "'id'", ")", ")", "->", "getId", "(", ")", ";", "}", "return", "null", ";", "}" ]
Obtain the model id from the input provider. @param InputProviderInterface $inputProvider The input provider. @return mixed|null
[ "Obtain", "the", "model", "id", "from", "the", "input", "provider", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Filter/LanguageFilter.php#L176-L183
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/RichTextFileUuidSubscriber.php
RichTextFileUuidSubscriber.convertUuidToFileSource
public function convertUuidToFileSource(DecodePropertyValueForWidgetEvent $event) { if (!$this->scopeDeterminator->currentScopeIsBackend()) { return; } $propertiesDefinition = $event->getEnvironment()->getDataDefinition()->getPropertiesDefinition(); $property = $propertiesDefinition->getProperty($event->getProperty()); if (!\array_key_exists('rte', $property->getExtra()) || \strpos($property->getExtra()['rte'], 'tiny') !== 0 ) { return; } $event->setValue( StringUtil::insertTagToSrc($event->getValue()) ); }
php
public function convertUuidToFileSource(DecodePropertyValueForWidgetEvent $event) { if (!$this->scopeDeterminator->currentScopeIsBackend()) { return; } $propertiesDefinition = $event->getEnvironment()->getDataDefinition()->getPropertiesDefinition(); $property = $propertiesDefinition->getProperty($event->getProperty()); if (!\array_key_exists('rte', $property->getExtra()) || \strpos($property->getExtra()['rte'], 'tiny') !== 0 ) { return; } $event->setValue( StringUtil::insertTagToSrc($event->getValue()) ); }
[ "public", "function", "convertUuidToFileSource", "(", "DecodePropertyValueForWidgetEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "scopeDeterminator", "->", "currentScopeIsBackend", "(", ")", ")", "{", "return", ";", "}", "$", "propertiesDefinition", "=", "$", "event", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", ";", "$", "property", "=", "$", "propertiesDefinition", "->", "getProperty", "(", "$", "event", "->", "getProperty", "(", ")", ")", ";", "if", "(", "!", "\\", "array_key_exists", "(", "'rte'", ",", "$", "property", "->", "getExtra", "(", ")", ")", "||", "\\", "strpos", "(", "$", "property", "->", "getExtra", "(", ")", "[", "'rte'", "]", ",", "'tiny'", ")", "!==", "0", ")", "{", "return", ";", "}", "$", "event", "->", "setValue", "(", "StringUtil", "::", "insertTagToSrc", "(", "$", "event", "->", "getValue", "(", ")", ")", ")", ";", "}" ]
Convert uuid to file source to see the right source in the rich text editor. After convert this back to the original source. @param DecodePropertyValueForWidgetEvent $event The event to handle. @return void
[ "Convert", "uuid", "to", "file", "source", "to", "see", "the", "right", "source", "in", "the", "rich", "text", "editor", ".", "After", "convert", "this", "back", "to", "the", "original", "source", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/RichTextFileUuidSubscriber.php#L119-L138
train
contao-community-alliance/dc-general
src/Panel/DefaultFilterElement.php
DefaultFilterElement.updateValue
private function updateValue() { $session = $this->getSessionStorage(); $input = $this->getInputProvider(); $value = null; if ($input->hasValue($this->getPropertyName()) && $this->getPanel()->getContainer()->updateValues()) { $value = $input->getValue($this->getPropertyName()); $this->setPersistent($value); } if ($session->has('filter')) { $persistent = $this->getPersistent(); $value = $persistent; } if (null !== $value) { $this->setValue($value); } }
php
private function updateValue() { $session = $this->getSessionStorage(); $input = $this->getInputProvider(); $value = null; if ($input->hasValue($this->getPropertyName()) && $this->getPanel()->getContainer()->updateValues()) { $value = $input->getValue($this->getPropertyName()); $this->setPersistent($value); } if ($session->has('filter')) { $persistent = $this->getPersistent(); $value = $persistent; } if (null !== $value) { $this->setValue($value); } }
[ "private", "function", "updateValue", "(", ")", "{", "$", "session", "=", "$", "this", "->", "getSessionStorage", "(", ")", ";", "$", "input", "=", "$", "this", "->", "getInputProvider", "(", ")", ";", "$", "value", "=", "null", ";", "if", "(", "$", "input", "->", "hasValue", "(", "$", "this", "->", "getPropertyName", "(", ")", ")", "&&", "$", "this", "->", "getPanel", "(", ")", "->", "getContainer", "(", ")", "->", "updateValues", "(", ")", ")", "{", "$", "value", "=", "$", "input", "->", "getValue", "(", "$", "this", "->", "getPropertyName", "(", ")", ")", ";", "$", "this", "->", "setPersistent", "(", "$", "value", ")", ";", "}", "if", "(", "$", "session", "->", "has", "(", "'filter'", ")", ")", "{", "$", "persistent", "=", "$", "this", "->", "getPersistent", "(", ")", ";", "$", "value", "=", "$", "persistent", ";", "}", "if", "(", "null", "!==", "$", "value", ")", "{", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "}", "}" ]
Update the local value property with data from either the session or from the input provider. @return void
[ "Update", "the", "local", "value", "property", "with", "data", "from", "either", "the", "session", "or", "from", "the", "input", "provider", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Panel/DefaultFilterElement.php#L114-L134
train
contao-community-alliance/dc-general
src/Panel/DefaultFilterElement.php
DefaultFilterElement.loadFilterOptions
private function loadFilterOptions() { $otherConfig = $this->getOtherConfig(); $otherConfig->setFields([$this->getPropertyName()]); $filterOptions = $this ->getEnvironment() ->getDataProvider() ->getFilterOptions($otherConfig); $options = []; foreach ($filterOptions as $filterKey => $filterValue) { $options[(string) $filterKey] = $filterValue; } $this->arrFilterOptions = $options; }
php
private function loadFilterOptions() { $otherConfig = $this->getOtherConfig(); $otherConfig->setFields([$this->getPropertyName()]); $filterOptions = $this ->getEnvironment() ->getDataProvider() ->getFilterOptions($otherConfig); $options = []; foreach ($filterOptions as $filterKey => $filterValue) { $options[(string) $filterKey] = $filterValue; } $this->arrFilterOptions = $options; }
[ "private", "function", "loadFilterOptions", "(", ")", "{", "$", "otherConfig", "=", "$", "this", "->", "getOtherConfig", "(", ")", ";", "$", "otherConfig", "->", "setFields", "(", "[", "$", "this", "->", "getPropertyName", "(", ")", "]", ")", ";", "$", "filterOptions", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataProvider", "(", ")", "->", "getFilterOptions", "(", "$", "otherConfig", ")", ";", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "filterOptions", "as", "$", "filterKey", "=>", "$", "filterValue", ")", "{", "$", "options", "[", "(", "string", ")", "$", "filterKey", "]", "=", "$", "filterValue", ";", "}", "$", "this", "->", "arrFilterOptions", "=", "$", "options", ";", "}" ]
Load the filter options from the configured property. @return void
[ "Load", "the", "filter", "options", "from", "the", "configured", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Panel/DefaultFilterElement.php#L141-L157
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php
PasteHandler.checkPermission
private function checkPermission(ActionEvent $event) { if (true === $event->getEnvironment()->getDataDefinition()->getBasicDefinition()->isEditable()) { return true; } $event->setResponse( '<div style="text-align:center; font-weight:bold; padding:40px;"> You have no permission for paste a model. </div>' ); return false; }
php
private function checkPermission(ActionEvent $event) { if (true === $event->getEnvironment()->getDataDefinition()->getBasicDefinition()->isEditable()) { return true; } $event->setResponse( '<div style="text-align:center; font-weight:bold; padding:40px;"> You have no permission for paste a model. </div>' ); return false; }
[ "private", "function", "checkPermission", "(", "ActionEvent", "$", "event", ")", "{", "if", "(", "true", "===", "$", "event", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", "->", "getBasicDefinition", "(", ")", "->", "isEditable", "(", ")", ")", "{", "return", "true", ";", "}", "$", "event", "->", "setResponse", "(", "'<div style=\"text-align:center; font-weight:bold; padding:40px;\">\n You have no permission for paste a model.\n </div>'", ")", ";", "return", "false", ";", "}" ]
Check permission for paste a model. @param ActionEvent $event The action event. @return bool
[ "Check", "permission", "for", "paste", "a", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php#L138-L151
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php
PasteHandler.needTreeModeShowAll
private function needTreeModeShowAll(BasicDefinitionInterface $definition, InputProviderInterface $input) { if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $definition->getMode()) { return false; } // If destination is not known, perform showAll. if ($input->hasParameter('after') || $input->hasParameter('into')) { return false; } return true; }
php
private function needTreeModeShowAll(BasicDefinitionInterface $definition, InputProviderInterface $input) { if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $definition->getMode()) { return false; } // If destination is not known, perform showAll. if ($input->hasParameter('after') || $input->hasParameter('into')) { return false; } return true; }
[ "private", "function", "needTreeModeShowAll", "(", "BasicDefinitionInterface", "$", "definition", ",", "InputProviderInterface", "$", "input", ")", "{", "if", "(", "BasicDefinitionInterface", "::", "MODE_HIERARCHICAL", "!==", "$", "definition", "->", "getMode", "(", ")", ")", "{", "return", "false", ";", "}", "// If destination is not known, perform showAll.", "if", "(", "$", "input", "->", "hasParameter", "(", "'after'", ")", "||", "$", "input", "->", "hasParameter", "(", "'into'", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if paste into or after parameter is present, if not, perform showAll in tree mode. This is needed, as the destination is otherwise undefined. @param BasicDefinitionInterface $definition The current definition. @param InputProviderInterface $input The input provider. @return bool
[ "Check", "if", "paste", "into", "or", "after", "parameter", "is", "present", "if", "not", "perform", "showAll", "in", "tree", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php#L163-L175
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php
PasteHandler.isSimpleCreatePaste
private function isSimpleCreatePaste(ClipboardInterface $clipboard, $provider) { $all = $clipboard->fetch(new Filter()); return ((1 === \count($all)) && $all[0]->isCreate() && (null === $all[0]->getModelId()) && $all[0]->getDataProviderName() === $provider); }
php
private function isSimpleCreatePaste(ClipboardInterface $clipboard, $provider) { $all = $clipboard->fetch(new Filter()); return ((1 === \count($all)) && $all[0]->isCreate() && (null === $all[0]->getModelId()) && $all[0]->getDataProviderName() === $provider); }
[ "private", "function", "isSimpleCreatePaste", "(", "ClipboardInterface", "$", "clipboard", ",", "$", "provider", ")", "{", "$", "all", "=", "$", "clipboard", "->", "fetch", "(", "new", "Filter", "(", ")", ")", ";", "return", "(", "(", "1", "===", "\\", "count", "(", "$", "all", ")", ")", "&&", "$", "all", "[", "0", "]", "->", "isCreate", "(", ")", "&&", "(", "null", "===", "$", "all", "[", "0", "]", "->", "getModelId", "(", ")", ")", "&&", "$", "all", "[", "0", "]", "->", "getDataProviderName", "(", ")", "===", "$", "provider", ")", ";", "}" ]
Test if the current paste action is a simple paste for the passed data provider. @param ClipboardInterface $clipboard The clipboard instance. @param string $provider The provider name. @return bool
[ "Test", "if", "the", "current", "paste", "action", "is", "a", "simple", "paste", "for", "the", "passed", "data", "provider", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php#L185-L193
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php
PasteHandler.modelIdFromParameter
private function modelIdFromParameter(InputProviderInterface $input, $name) { if ($input->hasParameter($name) && ($value = $input->getParameter($name))) { return ModelId::fromSerialized($value); } return null; }
php
private function modelIdFromParameter(InputProviderInterface $input, $name) { if ($input->hasParameter($name) && ($value = $input->getParameter($name))) { return ModelId::fromSerialized($value); } return null; }
[ "private", "function", "modelIdFromParameter", "(", "InputProviderInterface", "$", "input", ",", "$", "name", ")", "{", "if", "(", "$", "input", "->", "hasParameter", "(", "$", "name", ")", "&&", "(", "$", "value", "=", "$", "input", "->", "getParameter", "(", "$", "name", ")", ")", ")", "{", "return", "ModelId", "::", "fromSerialized", "(", "$", "value", ")", ";", "}", "return", "null", ";", "}" ]
Obtain the parameter with the given name from the input provider if it exists. @param InputProviderInterface $input The input provider. @param string $name The parameter to retrieve. @return ModelId|null
[ "Obtain", "the", "parameter", "with", "the", "given", "name", "from", "the", "input", "provider", "if", "it", "exists", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/PasteHandler.php#L203-L210
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php
ExtendedLegacyDcaDataDefinitionBuilder.loadAdditionalDefinitions
protected function loadAdditionalDefinitions(ContainerInterface $container) { if (null !== $this->getFromDca('dca_config/data_provider')) { $dataContainerName = $container->getName(); $this->getDispatcher()->addListener( PopulateEnvironmentEvent::NAME, function (PopulateEnvironmentEvent $event) use ($dataContainerName) { $environment = $event->getEnvironment(); $definition = $environment->getDataDefinition(); if ($definition->getName() !== $dataContainerName) { return; } $parentName = $definition->getBasicDefinition()->getParentDataProvider(); if ($parentName) { if ($parentName === $definition->getName()) { $parentDefinition = $definition; } else { $parentDefinition = (new DcGeneralFactory()) ->setEventDispatcher($environment->getEventDispatcher()) ->setTranslator($environment->getTranslator()) ->setContainerName($parentName) ->createDcGeneral() ->getEnvironment() ->getDataDefinition(); } $environment->setParentDataDefinition($parentDefinition); } $rootName = $definition->getBasicDefinition()->getRootDataProvider(); if ($rootName) { if ($rootName === $definition->getName()) { $rootDefinition = $definition; } else { $rootDefinition = (new DcGeneralFactory()) ->setEventDispatcher($environment->getEventDispatcher()) ->setTranslator($environment->getTranslator()) ->setContainerName($rootName) ->createDcGeneral() ->getEnvironment() ->getDataDefinition(); } $environment->setRootDataDefinition($rootDefinition); } } ); } }
php
protected function loadAdditionalDefinitions(ContainerInterface $container) { if (null !== $this->getFromDca('dca_config/data_provider')) { $dataContainerName = $container->getName(); $this->getDispatcher()->addListener( PopulateEnvironmentEvent::NAME, function (PopulateEnvironmentEvent $event) use ($dataContainerName) { $environment = $event->getEnvironment(); $definition = $environment->getDataDefinition(); if ($definition->getName() !== $dataContainerName) { return; } $parentName = $definition->getBasicDefinition()->getParentDataProvider(); if ($parentName) { if ($parentName === $definition->getName()) { $parentDefinition = $definition; } else { $parentDefinition = (new DcGeneralFactory()) ->setEventDispatcher($environment->getEventDispatcher()) ->setTranslator($environment->getTranslator()) ->setContainerName($parentName) ->createDcGeneral() ->getEnvironment() ->getDataDefinition(); } $environment->setParentDataDefinition($parentDefinition); } $rootName = $definition->getBasicDefinition()->getRootDataProvider(); if ($rootName) { if ($rootName === $definition->getName()) { $rootDefinition = $definition; } else { $rootDefinition = (new DcGeneralFactory()) ->setEventDispatcher($environment->getEventDispatcher()) ->setTranslator($environment->getTranslator()) ->setContainerName($rootName) ->createDcGeneral() ->getEnvironment() ->getDataDefinition(); } $environment->setRootDataDefinition($rootDefinition); } } ); } }
[ "protected", "function", "loadAdditionalDefinitions", "(", "ContainerInterface", "$", "container", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "getFromDca", "(", "'dca_config/data_provider'", ")", ")", "{", "$", "dataContainerName", "=", "$", "container", "->", "getName", "(", ")", ";", "$", "this", "->", "getDispatcher", "(", ")", "->", "addListener", "(", "PopulateEnvironmentEvent", "::", "NAME", ",", "function", "(", "PopulateEnvironmentEvent", "$", "event", ")", "use", "(", "$", "dataContainerName", ")", "{", "$", "environment", "=", "$", "event", "->", "getEnvironment", "(", ")", ";", "$", "definition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "if", "(", "$", "definition", "->", "getName", "(", ")", "!==", "$", "dataContainerName", ")", "{", "return", ";", "}", "$", "parentName", "=", "$", "definition", "->", "getBasicDefinition", "(", ")", "->", "getParentDataProvider", "(", ")", ";", "if", "(", "$", "parentName", ")", "{", "if", "(", "$", "parentName", "===", "$", "definition", "->", "getName", "(", ")", ")", "{", "$", "parentDefinition", "=", "$", "definition", ";", "}", "else", "{", "$", "parentDefinition", "=", "(", "new", "DcGeneralFactory", "(", ")", ")", "->", "setEventDispatcher", "(", "$", "environment", "->", "getEventDispatcher", "(", ")", ")", "->", "setTranslator", "(", "$", "environment", "->", "getTranslator", "(", ")", ")", "->", "setContainerName", "(", "$", "parentName", ")", "->", "createDcGeneral", "(", ")", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", ";", "}", "$", "environment", "->", "setParentDataDefinition", "(", "$", "parentDefinition", ")", ";", "}", "$", "rootName", "=", "$", "definition", "->", "getBasicDefinition", "(", ")", "->", "getRootDataProvider", "(", ")", ";", "if", "(", "$", "rootName", ")", "{", "if", "(", "$", "rootName", "===", "$", "definition", "->", "getName", "(", ")", ")", "{", "$", "rootDefinition", "=", "$", "definition", ";", "}", "else", "{", "$", "rootDefinition", "=", "(", "new", "DcGeneralFactory", "(", ")", ")", "->", "setEventDispatcher", "(", "$", "environment", "->", "getEventDispatcher", "(", ")", ")", "->", "setTranslator", "(", "$", "environment", "->", "getTranslator", "(", ")", ")", "->", "setContainerName", "(", "$", "rootName", ")", "->", "createDcGeneral", "(", ")", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", ";", "}", "$", "environment", "->", "setRootDataDefinition", "(", "$", "rootDefinition", ")", ";", "}", "}", ")", ";", "}", "}" ]
Load all additional definitions, like naming of parent data provider etc. @param ContainerInterface $container The container where the data shall be stored. @return void
[ "Load", "all", "additional", "definitions", "like", "naming", "of", "parent", "data", "provider", "etc", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php#L95-L143
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php
ExtendedLegacyDcaDataDefinitionBuilder.parseClassNames
protected function parseClassNames(ContainerInterface $container) { if ($container->hasDefinition(ExtendedDca::NAME)) { $definition = $container->getDefinition(ExtendedDca::NAME); if (!($definition instanceof ExtendedDca)) { throw new DcGeneralInvalidArgumentException( \sprintf( 'Definition with name %s must be an instance of ExtendedDca but instance of %s encountered.', ExtendedDca::NAME, \get_class($definition) ) ); } } else { $definition = new ExtendedDca(); $container->setDefinition(ExtendedDca::NAME, $definition); } if (null === $this->getFromDca('dca_config')) { return; } if (null !== ($class = $this->getFromDca('dca_config/controller'))) { $definition->setControllerClass($class); } if (null !== ($class = $this->getFromDca('dca_config/view'))) { $definition->setViewClass($class); } }
php
protected function parseClassNames(ContainerInterface $container) { if ($container->hasDefinition(ExtendedDca::NAME)) { $definition = $container->getDefinition(ExtendedDca::NAME); if (!($definition instanceof ExtendedDca)) { throw new DcGeneralInvalidArgumentException( \sprintf( 'Definition with name %s must be an instance of ExtendedDca but instance of %s encountered.', ExtendedDca::NAME, \get_class($definition) ) ); } } else { $definition = new ExtendedDca(); $container->setDefinition(ExtendedDca::NAME, $definition); } if (null === $this->getFromDca('dca_config')) { return; } if (null !== ($class = $this->getFromDca('dca_config/controller'))) { $definition->setControllerClass($class); } if (null !== ($class = $this->getFromDca('dca_config/view'))) { $definition->setViewClass($class); } }
[ "protected", "function", "parseClassNames", "(", "ContainerInterface", "$", "container", ")", "{", "if", "(", "$", "container", "->", "hasDefinition", "(", "ExtendedDca", "::", "NAME", ")", ")", "{", "$", "definition", "=", "$", "container", "->", "getDefinition", "(", "ExtendedDca", "::", "NAME", ")", ";", "if", "(", "!", "(", "$", "definition", "instanceof", "ExtendedDca", ")", ")", "{", "throw", "new", "DcGeneralInvalidArgumentException", "(", "\\", "sprintf", "(", "'Definition with name %s must be an instance of ExtendedDca but instance of %s encountered.'", ",", "ExtendedDca", "::", "NAME", ",", "\\", "get_class", "(", "$", "definition", ")", ")", ")", ";", "}", "}", "else", "{", "$", "definition", "=", "new", "ExtendedDca", "(", ")", ";", "$", "container", "->", "setDefinition", "(", "ExtendedDca", "::", "NAME", ",", "$", "definition", ")", ";", "}", "if", "(", "null", "===", "$", "this", "->", "getFromDca", "(", "'dca_config'", ")", ")", "{", "return", ";", "}", "if", "(", "null", "!==", "(", "$", "class", "=", "$", "this", "->", "getFromDca", "(", "'dca_config/controller'", ")", ")", ")", "{", "$", "definition", "->", "setControllerClass", "(", "$", "class", ")", ";", "}", "if", "(", "null", "!==", "(", "$", "class", "=", "$", "this", "->", "getFromDca", "(", "'dca_config/view'", ")", ")", ")", "{", "$", "definition", "->", "setViewClass", "(", "$", "class", ")", ";", "}", "}" ]
Parse all class names for view, controller and callback class. @param ContainerInterface $container The container where the data shall be stored. @return void @throws DcGeneralInvalidArgumentException When the container is of invalid type.
[ "Parse", "all", "class", "names", "for", "view", "controller", "and", "callback", "class", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php#L154-L184
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php
ExtendedLegacyDcaDataDefinitionBuilder.parseSingleDataProvider
protected function parseSingleDataProvider( ContainerInterface $container, DataProviderDefinitionInterface $providers, array $information, $name ) { if (isset($information['factory'])) { $providerInformation = (new \ReflectionClass($information['factory']))->newInstance()->build($information); } else { // Determine the name. if ($name && !$this->isSpecialName($name)) { $providerName = $name; } elseif ('default' === $name) { $providerName = $container->getName(); } elseif (isset($information['source'])) { $providerName = $information['source']; } else { $providerName = $container->getName(); } // Check config if it already exists, if not, add it. if (!$providers->hasInformation($providerName)) { $providerInformation = new ContaoDataProviderInformation(); $providerInformation->setName($providerName); $providers->addInformation($providerInformation); } else { $providerInformation = $providers->getInformation($providerName); } if (!$providerInformation->getTableName()) { if (isset($information['source'])) { $providerInformation ->setTableName($information['source']); } else { $providerInformation ->setTableName($providerName); } } if (isset($information['class'])) { $providerInformation->setClassName($information['class']); } } return $providerInformation; }
php
protected function parseSingleDataProvider( ContainerInterface $container, DataProviderDefinitionInterface $providers, array $information, $name ) { if (isset($information['factory'])) { $providerInformation = (new \ReflectionClass($information['factory']))->newInstance()->build($information); } else { // Determine the name. if ($name && !$this->isSpecialName($name)) { $providerName = $name; } elseif ('default' === $name) { $providerName = $container->getName(); } elseif (isset($information['source'])) { $providerName = $information['source']; } else { $providerName = $container->getName(); } // Check config if it already exists, if not, add it. if (!$providers->hasInformation($providerName)) { $providerInformation = new ContaoDataProviderInformation(); $providerInformation->setName($providerName); $providers->addInformation($providerInformation); } else { $providerInformation = $providers->getInformation($providerName); } if (!$providerInformation->getTableName()) { if (isset($information['source'])) { $providerInformation ->setTableName($information['source']); } else { $providerInformation ->setTableName($providerName); } } if (isset($information['class'])) { $providerInformation->setClassName($information['class']); } } return $providerInformation; }
[ "protected", "function", "parseSingleDataProvider", "(", "ContainerInterface", "$", "container", ",", "DataProviderDefinitionInterface", "$", "providers", ",", "array", "$", "information", ",", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "information", "[", "'factory'", "]", ")", ")", "{", "$", "providerInformation", "=", "(", "new", "\\", "ReflectionClass", "(", "$", "information", "[", "'factory'", "]", ")", ")", "->", "newInstance", "(", ")", "->", "build", "(", "$", "information", ")", ";", "}", "else", "{", "// Determine the name.", "if", "(", "$", "name", "&&", "!", "$", "this", "->", "isSpecialName", "(", "$", "name", ")", ")", "{", "$", "providerName", "=", "$", "name", ";", "}", "elseif", "(", "'default'", "===", "$", "name", ")", "{", "$", "providerName", "=", "$", "container", "->", "getName", "(", ")", ";", "}", "elseif", "(", "isset", "(", "$", "information", "[", "'source'", "]", ")", ")", "{", "$", "providerName", "=", "$", "information", "[", "'source'", "]", ";", "}", "else", "{", "$", "providerName", "=", "$", "container", "->", "getName", "(", ")", ";", "}", "// Check config if it already exists, if not, add it.", "if", "(", "!", "$", "providers", "->", "hasInformation", "(", "$", "providerName", ")", ")", "{", "$", "providerInformation", "=", "new", "ContaoDataProviderInformation", "(", ")", ";", "$", "providerInformation", "->", "setName", "(", "$", "providerName", ")", ";", "$", "providers", "->", "addInformation", "(", "$", "providerInformation", ")", ";", "}", "else", "{", "$", "providerInformation", "=", "$", "providers", "->", "getInformation", "(", "$", "providerName", ")", ";", "}", "if", "(", "!", "$", "providerInformation", "->", "getTableName", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "information", "[", "'source'", "]", ")", ")", "{", "$", "providerInformation", "->", "setTableName", "(", "$", "information", "[", "'source'", "]", ")", ";", "}", "else", "{", "$", "providerInformation", "->", "setTableName", "(", "$", "providerName", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "information", "[", "'class'", "]", ")", ")", "{", "$", "providerInformation", "->", "setClassName", "(", "$", "information", "[", "'class'", "]", ")", ";", "}", "}", "return", "$", "providerInformation", ";", "}" ]
Parse a single data provider information and prepare the definition object for it. @param ContainerInterface $container The container where the data shall be stored. @param DataProviderDefinitionInterface $providers The data provider container. @param array $information The information for the data provider to be parsed. @param string|null $name The name of the data provider to be used within the container. @return ContaoDataProviderInformation|null
[ "Parse", "a", "single", "data", "provider", "information", "and", "prepare", "the", "definition", "object", "for", "it", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php#L209-L254
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php
ExtendedLegacyDcaDataDefinitionBuilder.parsePalettes
protected function parsePalettes(ContainerInterface $container) { $palettesDca = $this->getFromDca('palettes'); // Skip while there is no extended palette definition. if (!\is_callable($palettesDca)) { return; } if ($container->hasDefinition(PalettesDefinitionInterface::NAME)) { $palettesDefinition = $container->getDefinition(PalettesDefinitionInterface::NAME); } else { $palettesDefinition = new DefaultPalettesDefinition(); $container->setDefinition(PalettesDefinitionInterface::NAME, $palettesDefinition); } $palettesDca($palettesDefinition, $container); }
php
protected function parsePalettes(ContainerInterface $container) { $palettesDca = $this->getFromDca('palettes'); // Skip while there is no extended palette definition. if (!\is_callable($palettesDca)) { return; } if ($container->hasDefinition(PalettesDefinitionInterface::NAME)) { $palettesDefinition = $container->getDefinition(PalettesDefinitionInterface::NAME); } else { $palettesDefinition = new DefaultPalettesDefinition(); $container->setDefinition(PalettesDefinitionInterface::NAME, $palettesDefinition); } $palettesDca($palettesDefinition, $container); }
[ "protected", "function", "parsePalettes", "(", "ContainerInterface", "$", "container", ")", "{", "$", "palettesDca", "=", "$", "this", "->", "getFromDca", "(", "'palettes'", ")", ";", "// Skip while there is no extended palette definition.", "if", "(", "!", "\\", "is_callable", "(", "$", "palettesDca", ")", ")", "{", "return", ";", "}", "if", "(", "$", "container", "->", "hasDefinition", "(", "PalettesDefinitionInterface", "::", "NAME", ")", ")", "{", "$", "palettesDefinition", "=", "$", "container", "->", "getDefinition", "(", "PalettesDefinitionInterface", "::", "NAME", ")", ";", "}", "else", "{", "$", "palettesDefinition", "=", "new", "DefaultPalettesDefinition", "(", ")", ";", "$", "container", "->", "setDefinition", "(", "PalettesDefinitionInterface", "::", "NAME", ",", "$", "palettesDefinition", ")", ";", "}", "$", "palettesDca", "(", "$", "palettesDefinition", ",", "$", "container", ")", ";", "}" ]
Parse the palette information. @param ContainerInterface $container The container where the data shall be stored. @return void
[ "Parse", "the", "palette", "information", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php#L337-L354
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php
ExtendedLegacyDcaDataDefinitionBuilder.parseConditions
protected function parseConditions(ContainerInterface $container) { if ($container->hasDefinition(ModelRelationshipDefinitionInterface::NAME)) { $definition = $container->getDefinition(ModelRelationshipDefinitionInterface::NAME); } else { $definition = new DefaultModelRelationshipDefinition(); $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition); } $this->parseRootCondition($container, $definition); $this->parseParentChildConditions($definition); }
php
protected function parseConditions(ContainerInterface $container) { if ($container->hasDefinition(ModelRelationshipDefinitionInterface::NAME)) { $definition = $container->getDefinition(ModelRelationshipDefinitionInterface::NAME); } else { $definition = new DefaultModelRelationshipDefinition(); $container->setDefinition(ModelRelationshipDefinitionInterface::NAME, $definition); } $this->parseRootCondition($container, $definition); $this->parseParentChildConditions($definition); }
[ "protected", "function", "parseConditions", "(", "ContainerInterface", "$", "container", ")", "{", "if", "(", "$", "container", "->", "hasDefinition", "(", "ModelRelationshipDefinitionInterface", "::", "NAME", ")", ")", "{", "$", "definition", "=", "$", "container", "->", "getDefinition", "(", "ModelRelationshipDefinitionInterface", "::", "NAME", ")", ";", "}", "else", "{", "$", "definition", "=", "new", "DefaultModelRelationshipDefinition", "(", ")", ";", "$", "container", "->", "setDefinition", "(", "ModelRelationshipDefinitionInterface", "::", "NAME", ",", "$", "definition", ")", ";", "}", "$", "this", "->", "parseRootCondition", "(", "$", "container", ",", "$", "definition", ")", ";", "$", "this", "->", "parseParentChildConditions", "(", "$", "definition", ")", ";", "}" ]
Parse the conditions for model relationships from the definition. This includes root entry filters, parent child relationship. @param ContainerInterface $container The container where the data shall be stored. @return void @throws DcGeneralRuntimeException If any information is missing or invalid.
[ "Parse", "the", "conditions", "for", "model", "relationships", "from", "the", "definition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php#L470-L481
train
contao-community-alliance/dc-general
src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php
ExtendedLegacyDcaDataDefinitionBuilder.parseDynamicParentTableProperty
protected function parseDynamicParentTableProperty(ContainerInterface $container) { if ((null === ($propertyName = $this->getFromDca('dca_config/parent_table_property'))) || (null === ($sourceProvider = $this->getFromDca('config/ptable'))) || (null === ($dynamicParentTable = $this->getFromDca('config/dynamicPtable'))) ) { return; } $relationship = $container->getModelRelationshipDefinition(); $childCondition = $relationship->getChildCondition($sourceProvider, $container->getName()); if (null === $childCondition) { return; } $childCondition->setFilterArray( \array_merge( $childCondition->getFilterArray(), [ [ 'local' => $propertyName, 'remote_value' => $sourceProvider, 'operation' => '=' ] ] ) ); $backendView = $container->getDefinition(Contao2BackendViewDefinition::NAME); $backendView->getListingConfig()->setParentTablePropertyName($propertyName); $container->getBasicDefinition()->setDynamicParentTable($dynamicParentTable); }
php
protected function parseDynamicParentTableProperty(ContainerInterface $container) { if ((null === ($propertyName = $this->getFromDca('dca_config/parent_table_property'))) || (null === ($sourceProvider = $this->getFromDca('config/ptable'))) || (null === ($dynamicParentTable = $this->getFromDca('config/dynamicPtable'))) ) { return; } $relationship = $container->getModelRelationshipDefinition(); $childCondition = $relationship->getChildCondition($sourceProvider, $container->getName()); if (null === $childCondition) { return; } $childCondition->setFilterArray( \array_merge( $childCondition->getFilterArray(), [ [ 'local' => $propertyName, 'remote_value' => $sourceProvider, 'operation' => '=' ] ] ) ); $backendView = $container->getDefinition(Contao2BackendViewDefinition::NAME); $backendView->getListingConfig()->setParentTablePropertyName($propertyName); $container->getBasicDefinition()->setDynamicParentTable($dynamicParentTable); }
[ "protected", "function", "parseDynamicParentTableProperty", "(", "ContainerInterface", "$", "container", ")", "{", "if", "(", "(", "null", "===", "(", "$", "propertyName", "=", "$", "this", "->", "getFromDca", "(", "'dca_config/parent_table_property'", ")", ")", ")", "||", "(", "null", "===", "(", "$", "sourceProvider", "=", "$", "this", "->", "getFromDca", "(", "'config/ptable'", ")", ")", ")", "||", "(", "null", "===", "(", "$", "dynamicParentTable", "=", "$", "this", "->", "getFromDca", "(", "'config/dynamicPtable'", ")", ")", ")", ")", "{", "return", ";", "}", "$", "relationship", "=", "$", "container", "->", "getModelRelationshipDefinition", "(", ")", ";", "$", "childCondition", "=", "$", "relationship", "->", "getChildCondition", "(", "$", "sourceProvider", ",", "$", "container", "->", "getName", "(", ")", ")", ";", "if", "(", "null", "===", "$", "childCondition", ")", "{", "return", ";", "}", "$", "childCondition", "->", "setFilterArray", "(", "\\", "array_merge", "(", "$", "childCondition", "->", "getFilterArray", "(", ")", ",", "[", "[", "'local'", "=>", "$", "propertyName", ",", "'remote_value'", "=>", "$", "sourceProvider", ",", "'operation'", "=>", "'='", "]", "]", ")", ")", ";", "$", "backendView", "=", "$", "container", "->", "getDefinition", "(", "Contao2BackendViewDefinition", "::", "NAME", ")", ";", "$", "backendView", "->", "getListingConfig", "(", ")", "->", "setParentTablePropertyName", "(", "$", "propertyName", ")", ";", "$", "container", "->", "getBasicDefinition", "(", ")", "->", "setDynamicParentTable", "(", "$", "dynamicParentTable", ")", ";", "}" ]
Parse the dynamic parent table. @param ContainerInterface $container The container where the data shall be stored. @return void
[ "Parse", "the", "dynamic", "parent", "table", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Dca/Builder/Legacy/ExtendedLegacyDcaDataDefinitionBuilder.php#L569-L600
train
contao-community-alliance/dc-general
src/Panel/DefaultLimitElement.php
DefaultLimitElement.calculateTotal
protected function calculateTotal() { $otherConfig = $this->getOtherConfig(); $total = $this ->getEnvironment() ->getDataProvider() ->fetchAll($otherConfig->setIdOnly(true)); if (\is_array($total)) { $this->intTotal = $total ? \count($total) : 0; return; } if (\is_object($total)) { $this->intTotal = $total->length(); return; } $this->intTotal = 0; }
php
protected function calculateTotal() { $otherConfig = $this->getOtherConfig(); $total = $this ->getEnvironment() ->getDataProvider() ->fetchAll($otherConfig->setIdOnly(true)); if (\is_array($total)) { $this->intTotal = $total ? \count($total) : 0; return; } if (\is_object($total)) { $this->intTotal = $total->length(); return; } $this->intTotal = 0; }
[ "protected", "function", "calculateTotal", "(", ")", "{", "$", "otherConfig", "=", "$", "this", "->", "getOtherConfig", "(", ")", ";", "$", "total", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataProvider", "(", ")", "->", "fetchAll", "(", "$", "otherConfig", "->", "setIdOnly", "(", "true", ")", ")", ";", "if", "(", "\\", "is_array", "(", "$", "total", ")", ")", "{", "$", "this", "->", "intTotal", "=", "$", "total", "?", "\\", "count", "(", "$", "total", ")", ":", "0", ";", "return", ";", "}", "if", "(", "\\", "is_object", "(", "$", "total", ")", ")", "{", "$", "this", "->", "intTotal", "=", "$", "total", "->", "length", "(", ")", ";", "return", ";", "}", "$", "this", "->", "intTotal", "=", "0", ";", "}" ]
Calculate the total amount of items. @return void
[ "Calculate", "the", "total", "amount", "of", "items", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Panel/DefaultLimitElement.php#L71-L92
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.process
private function process(EnvironmentInterface $environment) { $collection = $this->getCollection($environment); // If one item in the clipboard we don´t paste all here. if (\count($collection) < 1) { return; } $inputProvider = $environment->getInputProvider(); $clipboard = $environment->getClipboard(); $inputProvider->setParameter('pasteAll', true); $this->addDispatchDuplicateModel($environment); foreach ($collection as $collectionItem) { $this->setParameterForPaste($collectionItem, $environment); $this->callAction($environment, 'paste'); $clipboardItem = $collectionItem['item']; $clipboard->removeById($clipboardItem->getModelId()); } $clipboard->saveTo($environment); $inputProvider->unsetParameter('pasteAll'); ViewHelpers::redirectHome($environment); }
php
private function process(EnvironmentInterface $environment) { $collection = $this->getCollection($environment); // If one item in the clipboard we don´t paste all here. if (\count($collection) < 1) { return; } $inputProvider = $environment->getInputProvider(); $clipboard = $environment->getClipboard(); $inputProvider->setParameter('pasteAll', true); $this->addDispatchDuplicateModel($environment); foreach ($collection as $collectionItem) { $this->setParameterForPaste($collectionItem, $environment); $this->callAction($environment, 'paste'); $clipboardItem = $collectionItem['item']; $clipboard->removeById($clipboardItem->getModelId()); } $clipboard->saveTo($environment); $inputProvider->unsetParameter('pasteAll'); ViewHelpers::redirectHome($environment); }
[ "private", "function", "process", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "collection", "=", "$", "this", "->", "getCollection", "(", "$", "environment", ")", ";", "// If one item in the clipboard we don´t paste all here.", "if", "(", "\\", "count", "(", "$", "collection", ")", "<", "1", ")", "{", "return", ";", "}", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "clipboard", "=", "$", "environment", "->", "getClipboard", "(", ")", ";", "$", "inputProvider", "->", "setParameter", "(", "'pasteAll'", ",", "true", ")", ";", "$", "this", "->", "addDispatchDuplicateModel", "(", "$", "environment", ")", ";", "foreach", "(", "$", "collection", "as", "$", "collectionItem", ")", "{", "$", "this", "->", "setParameterForPaste", "(", "$", "collectionItem", ",", "$", "environment", ")", ";", "$", "this", "->", "callAction", "(", "$", "environment", ",", "'paste'", ")", ";", "$", "clipboardItem", "=", "$", "collectionItem", "[", "'item'", "]", ";", "$", "clipboard", "->", "removeById", "(", "$", "clipboardItem", "->", "getModelId", "(", ")", ")", ";", "}", "$", "clipboard", "->", "saveTo", "(", "$", "environment", ")", ";", "$", "inputProvider", "->", "unsetParameter", "(", "'pasteAll'", ")", ";", "ViewHelpers", "::", "redirectHome", "(", "$", "environment", ")", ";", "}" ]
Process the paste all handler. @param EnvironmentInterface $environment The environment. @return void
[ "Process", "the", "paste", "all", "handler", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L91-L120
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.getClipboardItems
protected function getClipboardItems(EnvironmentInterface $environment) { $basicDefinition = $environment->getDataDefinition()->getBasicDefinition(); $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($basicDefinition->getParentDataProvider()); } else { $filter->andHasNoParent(); } return $environment->getClipboard()->fetch($filter); }
php
protected function getClipboardItems(EnvironmentInterface $environment) { $basicDefinition = $environment->getDataDefinition()->getBasicDefinition(); $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($basicDefinition->getParentDataProvider()); } else { $filter->andHasNoParent(); } return $environment->getClipboard()->fetch($filter); }
[ "protected", "function", "getClipboardItems", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "basicDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getBasicDefinition", "(", ")", ";", "$", "filter", "=", "new", "Filter", "(", ")", ";", "$", "filter", "->", "andModelIsFromProvider", "(", "$", "basicDefinition", "->", "getDataProvider", "(", ")", ")", ";", "if", "(", "$", "basicDefinition", "->", "getParentDataProvider", "(", ")", ")", "{", "$", "filter", "->", "andParentIsFromProvider", "(", "$", "basicDefinition", "->", "getParentDataProvider", "(", ")", ")", ";", "}", "else", "{", "$", "filter", "->", "andHasNoParent", "(", ")", ";", "}", "return", "$", "environment", "->", "getClipboard", "(", ")", "->", "fetch", "(", "$", "filter", ")", ";", "}" ]
Get the items from the clipboard. @param EnvironmentInterface $environment The environment. @return array
[ "Get", "the", "items", "from", "the", "clipboard", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L129-L142
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.getCollection
protected function getCollection(EnvironmentInterface $environment) { $dataDefinition = $environment->getDataDefinition(); $relationShip = $dataDefinition->getModelRelationshipDefinition(); if (!$relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName())) { return $this->getFlatCollection($environment); } return $this->getHierarchyCollection($this->getClipboardItems($environment), $environment); }
php
protected function getCollection(EnvironmentInterface $environment) { $dataDefinition = $environment->getDataDefinition(); $relationShip = $dataDefinition->getModelRelationshipDefinition(); if (!$relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName())) { return $this->getFlatCollection($environment); } return $this->getHierarchyCollection($this->getClipboardItems($environment), $environment); }
[ "protected", "function", "getCollection", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "relationShip", "=", "$", "dataDefinition", "->", "getModelRelationshipDefinition", "(", ")", ";", "if", "(", "!", "$", "relationShip", "->", "getChildCondition", "(", "$", "dataDefinition", "->", "getName", "(", ")", ",", "$", "dataDefinition", "->", "getName", "(", ")", ")", ")", "{", "return", "$", "this", "->", "getFlatCollection", "(", "$", "environment", ")", ";", "}", "return", "$", "this", "->", "getHierarchyCollection", "(", "$", "this", "->", "getClipboardItems", "(", "$", "environment", ")", ",", "$", "environment", ")", ";", "}" ]
Get the collection. @param EnvironmentInterface $environment The environment. @return array
[ "Get", "the", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L151-L161
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.getFlatCollection
protected function getFlatCollection(EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $previousItem = null; $collection = []; foreach ($this->getClipboardItems($environment) as $clipboardItem) { if ('create' === $clipboardItem->getAction()) { continue; } $pasteAfter = $previousItem ? $previousItem->getModelId()->getSerialized() : $inputProvider->getParameter('after'); $collection[$clipboardItem->getModelId()->getSerialized()] = [ 'item' => $clipboardItem, 'pasteAfter' => $pasteAfter, 'pasteMode' => 'after' ]; $previousItem = $clipboardItem; } return $collection; }
php
protected function getFlatCollection(EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $previousItem = null; $collection = []; foreach ($this->getClipboardItems($environment) as $clipboardItem) { if ('create' === $clipboardItem->getAction()) { continue; } $pasteAfter = $previousItem ? $previousItem->getModelId()->getSerialized() : $inputProvider->getParameter('after'); $collection[$clipboardItem->getModelId()->getSerialized()] = [ 'item' => $clipboardItem, 'pasteAfter' => $pasteAfter, 'pasteMode' => 'after' ]; $previousItem = $clipboardItem; } return $collection; }
[ "protected", "function", "getFlatCollection", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "previousItem", "=", "null", ";", "$", "collection", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getClipboardItems", "(", "$", "environment", ")", "as", "$", "clipboardItem", ")", "{", "if", "(", "'create'", "===", "$", "clipboardItem", "->", "getAction", "(", ")", ")", "{", "continue", ";", "}", "$", "pasteAfter", "=", "$", "previousItem", "?", "$", "previousItem", "->", "getModelId", "(", ")", "->", "getSerialized", "(", ")", ":", "$", "inputProvider", "->", "getParameter", "(", "'after'", ")", ";", "$", "collection", "[", "$", "clipboardItem", "->", "getModelId", "(", ")", "->", "getSerialized", "(", ")", "]", "=", "[", "'item'", "=>", "$", "clipboardItem", ",", "'pasteAfter'", "=>", "$", "pasteAfter", ",", "'pasteMode'", "=>", "'after'", "]", ";", "$", "previousItem", "=", "$", "clipboardItem", ";", "}", "return", "$", "collection", ";", "}" ]
Get the flat collection. @param EnvironmentInterface $environment The environment. @return array
[ "Get", "the", "flat", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L170-L193
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.getHierarchyCollection
protected function getHierarchyCollection(array $clipboardItems, EnvironmentInterface $environment) { $dataProvider = $environment->getDataProvider(); $inputProvider = $environment->getInputProvider(); $dataDefinition = $environment->getDataDefinition(); $relationShip = $dataDefinition->getModelRelationshipDefinition(); $childCondition = $relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName()); $collection = []; $originalPasteMode = $inputProvider->hasParameter('after') ? 'after' : 'into'; $previousItem = null; foreach ($clipboardItems as $clipboardItem) { $modelId = $clipboardItem->getModelId(); if (!$modelId || \array_key_exists($modelId->getSerialized(), $collection) ) { continue; } $pasteMode = $previousItem ? 'after' : $originalPasteMode; $pasteAfter = $previousItem ? $previousItem->getModelId()->getSerialized() : $inputProvider->getParameter($pasteMode); $collection[$modelId->getSerialized()] = [ 'item' => $clipboardItem, 'pasteAfter' => $pasteAfter, 'pasteMode' => $pasteMode ]; $previousItem = $clipboardItem; $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); $itemCollection = $dataProvider->fetchAll($dataProvider->getEmptyConfig()->setFilter($childCondition->getFilter($model))); if ($itemCollection) { $collection = $this->setSubItemsToCollection( $clipboardItem, $this->getSubClipboardItems($clipboardItems, $itemCollection), $collection, $environment ); } } return $collection; }
php
protected function getHierarchyCollection(array $clipboardItems, EnvironmentInterface $environment) { $dataProvider = $environment->getDataProvider(); $inputProvider = $environment->getInputProvider(); $dataDefinition = $environment->getDataDefinition(); $relationShip = $dataDefinition->getModelRelationshipDefinition(); $childCondition = $relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName()); $collection = []; $originalPasteMode = $inputProvider->hasParameter('after') ? 'after' : 'into'; $previousItem = null; foreach ($clipboardItems as $clipboardItem) { $modelId = $clipboardItem->getModelId(); if (!$modelId || \array_key_exists($modelId->getSerialized(), $collection) ) { continue; } $pasteMode = $previousItem ? 'after' : $originalPasteMode; $pasteAfter = $previousItem ? $previousItem->getModelId()->getSerialized() : $inputProvider->getParameter($pasteMode); $collection[$modelId->getSerialized()] = [ 'item' => $clipboardItem, 'pasteAfter' => $pasteAfter, 'pasteMode' => $pasteMode ]; $previousItem = $clipboardItem; $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); $itemCollection = $dataProvider->fetchAll($dataProvider->getEmptyConfig()->setFilter($childCondition->getFilter($model))); if ($itemCollection) { $collection = $this->setSubItemsToCollection( $clipboardItem, $this->getSubClipboardItems($clipboardItems, $itemCollection), $collection, $environment ); } } return $collection; }
[ "protected", "function", "getHierarchyCollection", "(", "array", "$", "clipboardItems", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "dataProvider", "=", "$", "environment", "->", "getDataProvider", "(", ")", ";", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "relationShip", "=", "$", "dataDefinition", "->", "getModelRelationshipDefinition", "(", ")", ";", "$", "childCondition", "=", "$", "relationShip", "->", "getChildCondition", "(", "$", "dataDefinition", "->", "getName", "(", ")", ",", "$", "dataDefinition", "->", "getName", "(", ")", ")", ";", "$", "collection", "=", "[", "]", ";", "$", "originalPasteMode", "=", "$", "inputProvider", "->", "hasParameter", "(", "'after'", ")", "?", "'after'", ":", "'into'", ";", "$", "previousItem", "=", "null", ";", "foreach", "(", "$", "clipboardItems", "as", "$", "clipboardItem", ")", "{", "$", "modelId", "=", "$", "clipboardItem", "->", "getModelId", "(", ")", ";", "if", "(", "!", "$", "modelId", "||", "\\", "array_key_exists", "(", "$", "modelId", "->", "getSerialized", "(", ")", ",", "$", "collection", ")", ")", "{", "continue", ";", "}", "$", "pasteMode", "=", "$", "previousItem", "?", "'after'", ":", "$", "originalPasteMode", ";", "$", "pasteAfter", "=", "$", "previousItem", "?", "$", "previousItem", "->", "getModelId", "(", ")", "->", "getSerialized", "(", ")", ":", "$", "inputProvider", "->", "getParameter", "(", "$", "pasteMode", ")", ";", "$", "collection", "[", "$", "modelId", "->", "getSerialized", "(", ")", "]", "=", "[", "'item'", "=>", "$", "clipboardItem", ",", "'pasteAfter'", "=>", "$", "pasteAfter", ",", "'pasteMode'", "=>", "$", "pasteMode", "]", ";", "$", "previousItem", "=", "$", "clipboardItem", ";", "$", "model", "=", "$", "dataProvider", "->", "fetch", "(", "$", "dataProvider", "->", "getEmptyConfig", "(", ")", "->", "setId", "(", "$", "modelId", "->", "getId", "(", ")", ")", ")", ";", "$", "itemCollection", "=", "$", "dataProvider", "->", "fetchAll", "(", "$", "dataProvider", "->", "getEmptyConfig", "(", ")", "->", "setFilter", "(", "$", "childCondition", "->", "getFilter", "(", "$", "model", ")", ")", ")", ";", "if", "(", "$", "itemCollection", ")", "{", "$", "collection", "=", "$", "this", "->", "setSubItemsToCollection", "(", "$", "clipboardItem", ",", "$", "this", "->", "getSubClipboardItems", "(", "$", "clipboardItems", ",", "$", "itemCollection", ")", ",", "$", "collection", ",", "$", "environment", ")", ";", "}", "}", "return", "$", "collection", ";", "}" ]
Get hierarchy collection. @param array $clipboardItems The clipboard items. @param EnvironmentInterface $environment The environment. @return array
[ "Get", "hierarchy", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L203-L252
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.getSubClipboardItems
protected function getSubClipboardItems(array $clipboardItems, CollectionInterface $collection) { $subClipboardItems = []; $modelIds = $collection->getModelIds(); foreach ($clipboardItems as $clipboardItem) { if (!\in_array($clipboardItem->getModelId()->getId(), $modelIds)) { continue; } $subClipboardItems[] = $clipboardItem; } return $subClipboardItems; }
php
protected function getSubClipboardItems(array $clipboardItems, CollectionInterface $collection) { $subClipboardItems = []; $modelIds = $collection->getModelIds(); foreach ($clipboardItems as $clipboardItem) { if (!\in_array($clipboardItem->getModelId()->getId(), $modelIds)) { continue; } $subClipboardItems[] = $clipboardItem; } return $subClipboardItems; }
[ "protected", "function", "getSubClipboardItems", "(", "array", "$", "clipboardItems", ",", "CollectionInterface", "$", "collection", ")", "{", "$", "subClipboardItems", "=", "[", "]", ";", "$", "modelIds", "=", "$", "collection", "->", "getModelIds", "(", ")", ";", "foreach", "(", "$", "clipboardItems", "as", "$", "clipboardItem", ")", "{", "if", "(", "!", "\\", "in_array", "(", "$", "clipboardItem", "->", "getModelId", "(", ")", "->", "getId", "(", ")", ",", "$", "modelIds", ")", ")", "{", "continue", ";", "}", "$", "subClipboardItems", "[", "]", "=", "$", "clipboardItem", ";", "}", "return", "$", "subClipboardItems", ";", "}" ]
Get the sub items from the clipboard. @param array $clipboardItems The clipboard items. @param CollectionInterface $collection The collection. @return array
[ "Get", "the", "sub", "items", "from", "the", "clipboard", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L262-L276
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.setSubItemsToCollection
protected function setSubItemsToCollection( ItemInterface $previousItem, array $subClipboardItems, array $collection, EnvironmentInterface $environment ) { if (empty($subClipboardItems)) { return $collection; } $dataProvider = $environment->getDataProvider(); $dataDefinition = $environment->getDataDefinition(); $relationShip = $dataDefinition->getModelRelationshipDefinition(); $childCondition = $relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName()); $previousModelId = $previousItem->getModelId(); $intoItem = null; foreach ($subClipboardItems as $subClipboardItem) { $modelId = $subClipboardItem->getModelId(); $pasteAfter = $intoItem ? $intoItem->getModelId()->getSerialized() : $previousModelId->getSerialized(); $intoItem = $subClipboardItem; $collection[$modelId->getSerialized()] = [ 'item' => $subClipboardItem, 'pasteAfter' => $pasteAfter, 'pasteMode' => $intoItem ? 'after' : 'into' ]; $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); $itemCollection = $dataProvider->fetchAll($dataProvider->getEmptyConfig()->setFilter($childCondition->getFilter($model))); if ($itemCollection) { $collection = $this->setSubItemsToCollection( $subClipboardItem, $this->getSubClipboardItems($this->getClipboardItems($environment), $itemCollection), $collection, $environment ); } } return $collection; }
php
protected function setSubItemsToCollection( ItemInterface $previousItem, array $subClipboardItems, array $collection, EnvironmentInterface $environment ) { if (empty($subClipboardItems)) { return $collection; } $dataProvider = $environment->getDataProvider(); $dataDefinition = $environment->getDataDefinition(); $relationShip = $dataDefinition->getModelRelationshipDefinition(); $childCondition = $relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName()); $previousModelId = $previousItem->getModelId(); $intoItem = null; foreach ($subClipboardItems as $subClipboardItem) { $modelId = $subClipboardItem->getModelId(); $pasteAfter = $intoItem ? $intoItem->getModelId()->getSerialized() : $previousModelId->getSerialized(); $intoItem = $subClipboardItem; $collection[$modelId->getSerialized()] = [ 'item' => $subClipboardItem, 'pasteAfter' => $pasteAfter, 'pasteMode' => $intoItem ? 'after' : 'into' ]; $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); $itemCollection = $dataProvider->fetchAll($dataProvider->getEmptyConfig()->setFilter($childCondition->getFilter($model))); if ($itemCollection) { $collection = $this->setSubItemsToCollection( $subClipboardItem, $this->getSubClipboardItems($this->getClipboardItems($environment), $itemCollection), $collection, $environment ); } } return $collection; }
[ "protected", "function", "setSubItemsToCollection", "(", "ItemInterface", "$", "previousItem", ",", "array", "$", "subClipboardItems", ",", "array", "$", "collection", ",", "EnvironmentInterface", "$", "environment", ")", "{", "if", "(", "empty", "(", "$", "subClipboardItems", ")", ")", "{", "return", "$", "collection", ";", "}", "$", "dataProvider", "=", "$", "environment", "->", "getDataProvider", "(", ")", ";", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "relationShip", "=", "$", "dataDefinition", "->", "getModelRelationshipDefinition", "(", ")", ";", "$", "childCondition", "=", "$", "relationShip", "->", "getChildCondition", "(", "$", "dataDefinition", "->", "getName", "(", ")", ",", "$", "dataDefinition", "->", "getName", "(", ")", ")", ";", "$", "previousModelId", "=", "$", "previousItem", "->", "getModelId", "(", ")", ";", "$", "intoItem", "=", "null", ";", "foreach", "(", "$", "subClipboardItems", "as", "$", "subClipboardItem", ")", "{", "$", "modelId", "=", "$", "subClipboardItem", "->", "getModelId", "(", ")", ";", "$", "pasteAfter", "=", "$", "intoItem", "?", "$", "intoItem", "->", "getModelId", "(", ")", "->", "getSerialized", "(", ")", ":", "$", "previousModelId", "->", "getSerialized", "(", ")", ";", "$", "intoItem", "=", "$", "subClipboardItem", ";", "$", "collection", "[", "$", "modelId", "->", "getSerialized", "(", ")", "]", "=", "[", "'item'", "=>", "$", "subClipboardItem", ",", "'pasteAfter'", "=>", "$", "pasteAfter", ",", "'pasteMode'", "=>", "$", "intoItem", "?", "'after'", ":", "'into'", "]", ";", "$", "model", "=", "$", "dataProvider", "->", "fetch", "(", "$", "dataProvider", "->", "getEmptyConfig", "(", ")", "->", "setId", "(", "$", "modelId", "->", "getId", "(", ")", ")", ")", ";", "$", "itemCollection", "=", "$", "dataProvider", "->", "fetchAll", "(", "$", "dataProvider", "->", "getEmptyConfig", "(", ")", "->", "setFilter", "(", "$", "childCondition", "->", "getFilter", "(", "$", "model", ")", ")", ")", ";", "if", "(", "$", "itemCollection", ")", "{", "$", "collection", "=", "$", "this", "->", "setSubItemsToCollection", "(", "$", "subClipboardItem", ",", "$", "this", "->", "getSubClipboardItems", "(", "$", "this", "->", "getClipboardItems", "(", "$", "environment", ")", ",", "$", "itemCollection", ")", ",", "$", "collection", ",", "$", "environment", ")", ";", "}", "}", "return", "$", "collection", ";", "}" ]
Set the sub items to the collection. @param ItemInterface $previousItem The previous item. @param array $subClipboardItems The sub clipboard items. @param array $collection The collection. @param EnvironmentInterface $environment The environment. @return array
[ "Set", "the", "sub", "items", "to", "the", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L288-L336
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.addDispatchDuplicateModel
protected function addDispatchDuplicateModel(EnvironmentInterface $environment) { $environment->getEventDispatcher()->addListener( PostDuplicateModelEvent::NAME, function (PostDuplicateModelEvent $event) { $this->copiedModel = $event->getModel(); $this->originalModel = $event->getSourceModel(); } ); }
php
protected function addDispatchDuplicateModel(EnvironmentInterface $environment) { $environment->getEventDispatcher()->addListener( PostDuplicateModelEvent::NAME, function (PostDuplicateModelEvent $event) { $this->copiedModel = $event->getModel(); $this->originalModel = $event->getSourceModel(); } ); }
[ "protected", "function", "addDispatchDuplicateModel", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "environment", "->", "getEventDispatcher", "(", ")", "->", "addListener", "(", "PostDuplicateModelEvent", "::", "NAME", ",", "function", "(", "PostDuplicateModelEvent", "$", "event", ")", "{", "$", "this", "->", "copiedModel", "=", "$", "event", "->", "getModel", "(", ")", ";", "$", "this", "->", "originalModel", "=", "$", "event", "->", "getSourceModel", "(", ")", ";", "}", ")", ";", "}" ]
Add the event to the listeners for post duplicate model event. @param EnvironmentInterface $environment The environment. @return void
[ "Add", "the", "event", "to", "the", "listeners", "for", "post", "duplicate", "model", "event", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L345-L354
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
PasteAllHandler.setParameterForPaste
protected function setParameterForPaste(array $collectionItem, EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $clipboardItem = $collectionItem['item']; $inputProvider->unsetParameter('after'); $inputProvider->unsetParameter('into'); $inputProvider->unsetParameter('source'); $inputProvider->setParameter('source', $clipboardItem->getModelId()->getSerialized()); if (!$this->originalModel) { $inputProvider->setParameter($collectionItem['pasteMode'], $collectionItem['pasteAfter']); return; } $pasteAfterId = ModelId::fromSerialized($collectionItem['pasteAfter']); if ($pasteAfterId->getId() !== $this->originalModel->getID()) { $inputProvider->setParameter($collectionItem['pasteMode'], $collectionItem['pasteAfter']); return; } $copiedModelId = ModelId::fromModel($this->copiedModel); $inputProvider->setParameter($collectionItem['pasteMode'], $copiedModelId->getSerialized()); }
php
protected function setParameterForPaste(array $collectionItem, EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $clipboardItem = $collectionItem['item']; $inputProvider->unsetParameter('after'); $inputProvider->unsetParameter('into'); $inputProvider->unsetParameter('source'); $inputProvider->setParameter('source', $clipboardItem->getModelId()->getSerialized()); if (!$this->originalModel) { $inputProvider->setParameter($collectionItem['pasteMode'], $collectionItem['pasteAfter']); return; } $pasteAfterId = ModelId::fromSerialized($collectionItem['pasteAfter']); if ($pasteAfterId->getId() !== $this->originalModel->getID()) { $inputProvider->setParameter($collectionItem['pasteMode'], $collectionItem['pasteAfter']); return; } $copiedModelId = ModelId::fromModel($this->copiedModel); $inputProvider->setParameter($collectionItem['pasteMode'], $copiedModelId->getSerialized()); }
[ "protected", "function", "setParameterForPaste", "(", "array", "$", "collectionItem", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "clipboardItem", "=", "$", "collectionItem", "[", "'item'", "]", ";", "$", "inputProvider", "->", "unsetParameter", "(", "'after'", ")", ";", "$", "inputProvider", "->", "unsetParameter", "(", "'into'", ")", ";", "$", "inputProvider", "->", "unsetParameter", "(", "'source'", ")", ";", "$", "inputProvider", "->", "setParameter", "(", "'source'", ",", "$", "clipboardItem", "->", "getModelId", "(", ")", "->", "getSerialized", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "originalModel", ")", "{", "$", "inputProvider", "->", "setParameter", "(", "$", "collectionItem", "[", "'pasteMode'", "]", ",", "$", "collectionItem", "[", "'pasteAfter'", "]", ")", ";", "return", ";", "}", "$", "pasteAfterId", "=", "ModelId", "::", "fromSerialized", "(", "$", "collectionItem", "[", "'pasteAfter'", "]", ")", ";", "if", "(", "$", "pasteAfterId", "->", "getId", "(", ")", "!==", "$", "this", "->", "originalModel", "->", "getID", "(", ")", ")", "{", "$", "inputProvider", "->", "setParameter", "(", "$", "collectionItem", "[", "'pasteMode'", "]", ",", "$", "collectionItem", "[", "'pasteAfter'", "]", ")", ";", "return", ";", "}", "$", "copiedModelId", "=", "ModelId", "::", "fromModel", "(", "$", "this", "->", "copiedModel", ")", ";", "$", "inputProvider", "->", "setParameter", "(", "$", "collectionItem", "[", "'pasteMode'", "]", ",", "$", "copiedModelId", "->", "getSerialized", "(", ")", ")", ";", "}" ]
Set the parameter for paste. @param array $collectionItem The collection item. @param EnvironmentInterface $environment The environment. @return void
[ "Set", "the", "parameter", "for", "paste", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php#L364-L390
train
contao-community-alliance/dc-general
src/DataDefinition/Palette/Builder/Event/CreateConditionEvent.php
CreateConditionEvent.setCondition
public function setCondition($condition) { if ((!$condition instanceof PaletteConditionInterface) && (!$condition instanceof PropertyConditionInterface) ) { throw new DcGeneralInvalidArgumentException( 'The condition is invalid. ' . ' Only use PaletteConditionInterface or PropertyConditionInterface.' ); } $this->condition = $condition; return $this; }
php
public function setCondition($condition) { if ((!$condition instanceof PaletteConditionInterface) && (!$condition instanceof PropertyConditionInterface) ) { throw new DcGeneralInvalidArgumentException( 'The condition is invalid. ' . ' Only use PaletteConditionInterface or PropertyConditionInterface.' ); } $this->condition = $condition; return $this; }
[ "public", "function", "setCondition", "(", "$", "condition", ")", "{", "if", "(", "(", "!", "$", "condition", "instanceof", "PaletteConditionInterface", ")", "&&", "(", "!", "$", "condition", "instanceof", "PropertyConditionInterface", ")", ")", "{", "throw", "new", "DcGeneralInvalidArgumentException", "(", "'The condition is invalid. '", ".", "' Only use PaletteConditionInterface or PropertyConditionInterface.'", ")", ";", "}", "$", "this", "->", "condition", "=", "$", "condition", ";", "return", "$", "this", ";", "}" ]
Set the condition. @param PaletteConditionInterface|PropertyConditionInterface $condition The condition to use. @return CreateConditionEvent @throws DcGeneralInvalidArgumentException When an invalid condition has been passed.
[ "Set", "the", "condition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/Event/CreateConditionEvent.php#L66-L80
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/PanelRenderer.php
PanelRenderer.renderPanelElement
protected function renderPanelElement($element, $cssClass) { $environment = $this->getEnvironment(); $event = new GetPanelElementTemplateEvent($environment, $element); $environment->getEventDispatcher()->dispatch($event::NAME, $event); $template = $event->getTemplate(); if (null === $template) { return ''; } $template->set('rowClass', $cssClass); $element->render($template); return $template->parse(); }
php
protected function renderPanelElement($element, $cssClass) { $environment = $this->getEnvironment(); $event = new GetPanelElementTemplateEvent($environment, $element); $environment->getEventDispatcher()->dispatch($event::NAME, $event); $template = $event->getTemplate(); if (null === $template) { return ''; } $template->set('rowClass', $cssClass); $element->render($template); return $template->parse(); }
[ "protected", "function", "renderPanelElement", "(", "$", "element", ",", "$", "cssClass", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "event", "=", "new", "GetPanelElementTemplateEvent", "(", "$", "environment", ",", "$", "element", ")", ";", "$", "environment", "->", "getEventDispatcher", "(", ")", "->", "dispatch", "(", "$", "event", "::", "NAME", ",", "$", "event", ")", ";", "$", "template", "=", "$", "event", "->", "getTemplate", "(", ")", ";", "if", "(", "null", "===", "$", "template", ")", "{", "return", "''", ";", "}", "$", "template", "->", "set", "(", "'rowClass'", ",", "$", "cssClass", ")", ";", "$", "element", "->", "render", "(", "$", "template", ")", ";", "return", "$", "template", "->", "parse", "(", ")", ";", "}" ]
Render a single panel element. @param PanelElementInterface $element The element to render. @param string $cssClass The CSS class to use for this element (even, odd, first, last, ...). @return string
[ "Render", "a", "single", "panel", "element", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/PanelRenderer.php#L73-L90
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/PanelRenderer.php
PanelRenderer.isIgnoredPanel
protected function isIgnoredPanel(PanelElementInterface $element, $ignoredPanels) { if (empty($ignoredPanels)) { return false; } foreach ((array) $ignoredPanels as $class) { if ($element instanceof $class) { return true; } } return false; }
php
protected function isIgnoredPanel(PanelElementInterface $element, $ignoredPanels) { if (empty($ignoredPanels)) { return false; } foreach ((array) $ignoredPanels as $class) { if ($element instanceof $class) { return true; } } return false; }
[ "protected", "function", "isIgnoredPanel", "(", "PanelElementInterface", "$", "element", ",", "$", "ignoredPanels", ")", "{", "if", "(", "empty", "(", "$", "ignoredPanels", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "(", "array", ")", "$", "ignoredPanels", "as", "$", "class", ")", "{", "if", "(", "$", "element", "instanceof", "$", "class", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the current element is in the ignored list. @param PanelElementInterface $element A panel Element. @param string[] $ignoredPanels A list with ignored elements. @return boolean True => Element is on the ignored list. | False => Nope not in the list.
[ "Check", "if", "the", "current", "element", "is", "in", "the", "ignored", "list", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/PanelRenderer.php#L100-L113
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/PanelRenderer.php
PanelRenderer.renderPanelRow
protected function renderPanelRow($panel, $ignoredPanels) { $parsedElements = []; $index = 0; $max = (\count($panel) - 1); foreach ($panel as $element) { /** @var PanelElementInterface $element */ // If the current class in the list of ignored panels go to the next one. if ($this->isIgnoredPanel($element, $ignoredPanels)) { $max--; continue; } $parsedElements[] = $this->renderPanelElement( $element, $this->calculatePanelElementCssClass($index, $max) ); $index++; } return $parsedElements; }
php
protected function renderPanelRow($panel, $ignoredPanels) { $parsedElements = []; $index = 0; $max = (\count($panel) - 1); foreach ($panel as $element) { /** @var PanelElementInterface $element */ // If the current class in the list of ignored panels go to the next one. if ($this->isIgnoredPanel($element, $ignoredPanels)) { $max--; continue; } $parsedElements[] = $this->renderPanelElement( $element, $this->calculatePanelElementCssClass($index, $max) ); $index++; } return $parsedElements; }
[ "protected", "function", "renderPanelRow", "(", "$", "panel", ",", "$", "ignoredPanels", ")", "{", "$", "parsedElements", "=", "[", "]", ";", "$", "index", "=", "0", ";", "$", "max", "=", "(", "\\", "count", "(", "$", "panel", ")", "-", "1", ")", ";", "foreach", "(", "$", "panel", "as", "$", "element", ")", "{", "/** @var PanelElementInterface $element */", "// If the current class in the list of ignored panels go to the next one.", "if", "(", "$", "this", "->", "isIgnoredPanel", "(", "$", "element", ",", "$", "ignoredPanels", ")", ")", "{", "$", "max", "--", ";", "continue", ";", "}", "$", "parsedElements", "[", "]", "=", "$", "this", "->", "renderPanelElement", "(", "$", "element", ",", "$", "this", "->", "calculatePanelElementCssClass", "(", "$", "index", ",", "$", "max", ")", ")", ";", "$", "index", "++", ";", "}", "return", "$", "parsedElements", ";", "}" ]
Render a panel. @param PanelInterface $panel The panel to render. @param string[] $ignoredPanels Array of class names that shall be ignored. @return array
[ "Render", "a", "panel", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/PanelRenderer.php#L139-L160
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/PanelRenderer.php
PanelRenderer.render
public function render($ignoredPanels = []) { $environment = $this->getEnvironment(); // If in edit/override all mode and list all properties, the panel filter isn´t in use. if ('properties' === $environment->getInputProvider()->getParameter('select')) { return ''; } if (null === $this->view->getPanel()) { throw new DcGeneralRuntimeException('No panel information stored in data container.'); } $panels = []; foreach ($this->view->getPanel() as $panel) { $panels[] = $this->renderPanelRow($panel, $ignoredPanels); } if (\count($panels)) { $template = new ContaoBackendViewTemplate('dcbe_general_panel'); $themeEvent = new GetThemeEvent(); $environment->getEventDispatcher()->dispatch(ContaoEvents::BACKEND_GET_THEME, $themeEvent); $template ->set('action', \ampersand($environment->getInputProvider()->getRequestUrl(), true)) ->set('theme', $themeEvent->getTheme()) ->set('panel', $panels); return $template->parse(); } return ''; }
php
public function render($ignoredPanels = []) { $environment = $this->getEnvironment(); // If in edit/override all mode and list all properties, the panel filter isn´t in use. if ('properties' === $environment->getInputProvider()->getParameter('select')) { return ''; } if (null === $this->view->getPanel()) { throw new DcGeneralRuntimeException('No panel information stored in data container.'); } $panels = []; foreach ($this->view->getPanel() as $panel) { $panels[] = $this->renderPanelRow($panel, $ignoredPanels); } if (\count($panels)) { $template = new ContaoBackendViewTemplate('dcbe_general_panel'); $themeEvent = new GetThemeEvent(); $environment->getEventDispatcher()->dispatch(ContaoEvents::BACKEND_GET_THEME, $themeEvent); $template ->set('action', \ampersand($environment->getInputProvider()->getRequestUrl(), true)) ->set('theme', $themeEvent->getTheme()) ->set('panel', $panels); return $template->parse(); } return ''; }
[ "public", "function", "render", "(", "$", "ignoredPanels", "=", "[", "]", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "// If in edit/override all mode and list all properties, the panel filter isn´t in use.", "if", "(", "'properties'", "===", "$", "environment", "->", "getInputProvider", "(", ")", "->", "getParameter", "(", "'select'", ")", ")", "{", "return", "''", ";", "}", "if", "(", "null", "===", "$", "this", "->", "view", "->", "getPanel", "(", ")", ")", "{", "throw", "new", "DcGeneralRuntimeException", "(", "'No panel information stored in data container.'", ")", ";", "}", "$", "panels", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "view", "->", "getPanel", "(", ")", "as", "$", "panel", ")", "{", "$", "panels", "[", "]", "=", "$", "this", "->", "renderPanelRow", "(", "$", "panel", ",", "$", "ignoredPanels", ")", ";", "}", "if", "(", "\\", "count", "(", "$", "panels", ")", ")", "{", "$", "template", "=", "new", "ContaoBackendViewTemplate", "(", "'dcbe_general_panel'", ")", ";", "$", "themeEvent", "=", "new", "GetThemeEvent", "(", ")", ";", "$", "environment", "->", "getEventDispatcher", "(", ")", "->", "dispatch", "(", "ContaoEvents", "::", "BACKEND_GET_THEME", ",", "$", "themeEvent", ")", ";", "$", "template", "->", "set", "(", "'action'", ",", "\\", "ampersand", "(", "$", "environment", "->", "getInputProvider", "(", ")", "->", "getRequestUrl", "(", ")", ",", "true", ")", ")", "->", "set", "(", "'theme'", ",", "$", "themeEvent", "->", "getTheme", "(", ")", ")", "->", "set", "(", "'panel'", ",", "$", "panels", ")", ";", "return", "$", "template", "->", "parse", "(", ")", ";", "}", "return", "''", ";", "}" ]
Render the panels. @param array $ignoredPanels A list with ignored elements [Optional]. @throws DcGeneralRuntimeException When no information of panels can be obtained from the data container. @return string
[ "Render", "the", "panels", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/PanelRenderer.php#L171-L204
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.getPropertyDataProvider
private function getPropertyDataProvider(EnvironmentInterface $environment) { $providerName = 'property.' . $environment->getDataDefinition()->getName(); $dataProvider = new NoOpDataProvider(); $dataProvider->setBaseConfig(['name' => $providerName]); $this->setPropertyLabelFormatter($providerName, $environment); return $dataProvider; }
php
private function getPropertyDataProvider(EnvironmentInterface $environment) { $providerName = 'property.' . $environment->getDataDefinition()->getName(); $dataProvider = new NoOpDataProvider(); $dataProvider->setBaseConfig(['name' => $providerName]); $this->setPropertyLabelFormatter($providerName, $environment); return $dataProvider; }
[ "private", "function", "getPropertyDataProvider", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "providerName", "=", "'property.'", ".", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getName", "(", ")", ";", "$", "dataProvider", "=", "new", "NoOpDataProvider", "(", ")", ";", "$", "dataProvider", "->", "setBaseConfig", "(", "[", "'name'", "=>", "$", "providerName", "]", ")", ";", "$", "this", "->", "setPropertyLabelFormatter", "(", "$", "providerName", ",", "$", "environment", ")", ";", "return", "$", "dataProvider", ";", "}" ]
Return the property data provider. @param EnvironmentInterface $environment The environment. @return NoOpDataProvider @throws DcGeneralRuntimeException When no source has been defined.
[ "Return", "the", "property", "data", "provider", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L109-L119
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.setPropertyLabelFormatter
private function setPropertyLabelFormatter($providerName, EnvironmentInterface $environment) { $properties = $environment->getDataDefinition()->getPropertiesDefinition(); $labelFormatter = (new DefaultModelFormatterConfig()) ->setPropertyNames(['name', 'description']) ->setFormat('%s <span style="color:#b3b3b3; padding-left:3px">[%s]</span>'); $this->getViewSection($environment->getDataDefinition()) ->getListingConfig() ->setLabelFormatter($providerName, $labelFormatter); // If property name not exits create dummy property for it. foreach (['name', 'description'] as $dummyName) { if (!$properties->hasProperty($dummyName)) { $dummyProperty = new DefaultProperty($dummyName); $dummyProperty->setWidgetType('dummyProperty'); $properties->addProperty($dummyProperty); } } }
php
private function setPropertyLabelFormatter($providerName, EnvironmentInterface $environment) { $properties = $environment->getDataDefinition()->getPropertiesDefinition(); $labelFormatter = (new DefaultModelFormatterConfig()) ->setPropertyNames(['name', 'description']) ->setFormat('%s <span style="color:#b3b3b3; padding-left:3px">[%s]</span>'); $this->getViewSection($environment->getDataDefinition()) ->getListingConfig() ->setLabelFormatter($providerName, $labelFormatter); // If property name not exits create dummy property for it. foreach (['name', 'description'] as $dummyName) { if (!$properties->hasProperty($dummyName)) { $dummyProperty = new DefaultProperty($dummyName); $dummyProperty->setWidgetType('dummyProperty'); $properties->addProperty($dummyProperty); } } }
[ "private", "function", "setPropertyLabelFormatter", "(", "$", "providerName", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "properties", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", ";", "$", "labelFormatter", "=", "(", "new", "DefaultModelFormatterConfig", "(", ")", ")", "->", "setPropertyNames", "(", "[", "'name'", ",", "'description'", "]", ")", "->", "setFormat", "(", "'%s <span style=\"color:#b3b3b3; padding-left:3px\">[%s]</span>'", ")", ";", "$", "this", "->", "getViewSection", "(", "$", "environment", "->", "getDataDefinition", "(", ")", ")", "->", "getListingConfig", "(", ")", "->", "setLabelFormatter", "(", "$", "providerName", ",", "$", "labelFormatter", ")", ";", "// If property name not exits create dummy property for it.", "foreach", "(", "[", "'name'", ",", "'description'", "]", "as", "$", "dummyName", ")", "{", "if", "(", "!", "$", "properties", "->", "hasProperty", "(", "$", "dummyName", ")", ")", "{", "$", "dummyProperty", "=", "new", "DefaultProperty", "(", "$", "dummyName", ")", ";", "$", "dummyProperty", "->", "setWidgetType", "(", "'dummyProperty'", ")", ";", "$", "properties", "->", "addProperty", "(", "$", "dummyProperty", ")", ";", "}", "}", "}" ]
Set the label formatter for property data provider to the listing configuration. @param string $providerName The provider name. @param EnvironmentInterface $environment The environment. @return void
[ "Set", "the", "label", "formatter", "for", "property", "data", "provider", "to", "the", "listing", "configuration", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L129-L150
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.getCollection
private function getCollection(DataProviderInterface $dataProvider, EnvironmentInterface $environment) { $collection = $dataProvider->getEmptyCollection(); foreach ($environment->getDataDefinition()->getPropertiesDefinition() as $property) { if (!$this->isPropertyAllowed($property, $environment)) { continue; } $model = $dataProvider->getEmptyModel(); $model->setID($property->getName()); $model->setProperty( 'name', $property->getLabel() ?: $property->getName() ); $model->setProperty( 'description', $property->getDescription() ?: $property->getName() ); $this->handlePropertyFileTree($property); $this->handlePropertyFileTreeOrder($property, $model); $collection->offsetSet($collection->count(), $model); } return $collection; }
php
private function getCollection(DataProviderInterface $dataProvider, EnvironmentInterface $environment) { $collection = $dataProvider->getEmptyCollection(); foreach ($environment->getDataDefinition()->getPropertiesDefinition() as $property) { if (!$this->isPropertyAllowed($property, $environment)) { continue; } $model = $dataProvider->getEmptyModel(); $model->setID($property->getName()); $model->setProperty( 'name', $property->getLabel() ?: $property->getName() ); $model->setProperty( 'description', $property->getDescription() ?: $property->getName() ); $this->handlePropertyFileTree($property); $this->handlePropertyFileTreeOrder($property, $model); $collection->offsetSet($collection->count(), $model); } return $collection; }
[ "private", "function", "getCollection", "(", "DataProviderInterface", "$", "dataProvider", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "collection", "=", "$", "dataProvider", "->", "getEmptyCollection", "(", ")", ";", "foreach", "(", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", "as", "$", "property", ")", "{", "if", "(", "!", "$", "this", "->", "isPropertyAllowed", "(", "$", "property", ",", "$", "environment", ")", ")", "{", "continue", ";", "}", "$", "model", "=", "$", "dataProvider", "->", "getEmptyModel", "(", ")", ";", "$", "model", "->", "setID", "(", "$", "property", "->", "getName", "(", ")", ")", ";", "$", "model", "->", "setProperty", "(", "'name'", ",", "$", "property", "->", "getLabel", "(", ")", "?", ":", "$", "property", "->", "getName", "(", ")", ")", ";", "$", "model", "->", "setProperty", "(", "'description'", ",", "$", "property", "->", "getDescription", "(", ")", "?", ":", "$", "property", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "handlePropertyFileTree", "(", "$", "property", ")", ";", "$", "this", "->", "handlePropertyFileTreeOrder", "(", "$", "property", ",", "$", "model", ")", ";", "$", "collection", "->", "offsetSet", "(", "$", "collection", "->", "count", "(", ")", ",", "$", "model", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Return the field collection for each properties. @param DataProviderInterface $dataProvider The field data provider. @param EnvironmentInterface $environment The environment. @return CollectionInterface
[ "Return", "the", "field", "collection", "for", "each", "properties", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L160-L187
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.isPropertyAllowed
private function isPropertyAllowed(PropertyInterface $property, EnvironmentInterface $environment) { if (!$property->getWidgetType() || ('dummyProperty' === $property->getWidgetType()) ) { return false; } $translator = $environment->getTranslator(); $extra = (array) $property->getExtra(); if ($this->isPropertyAllowedByEdit($extra, $environment) || $this->isPropertyAllowedByOverride($extra, $environment) ) { Message::addInfo( \sprintf( $translator->translate('MSC.not_allowed_property_info'), $property->getLabel() ?: $property->getName(), $translator->translate('MSC.' . $environment->getInputProvider()->getParameter('mode') . 'Selected') ) ); return false; } return $this->isPropertyAllowedByIntersectProperties($property, $environment); }
php
private function isPropertyAllowed(PropertyInterface $property, EnvironmentInterface $environment) { if (!$property->getWidgetType() || ('dummyProperty' === $property->getWidgetType()) ) { return false; } $translator = $environment->getTranslator(); $extra = (array) $property->getExtra(); if ($this->isPropertyAllowedByEdit($extra, $environment) || $this->isPropertyAllowedByOverride($extra, $environment) ) { Message::addInfo( \sprintf( $translator->translate('MSC.not_allowed_property_info'), $property->getLabel() ?: $property->getName(), $translator->translate('MSC.' . $environment->getInputProvider()->getParameter('mode') . 'Selected') ) ); return false; } return $this->isPropertyAllowedByIntersectProperties($property, $environment); }
[ "private", "function", "isPropertyAllowed", "(", "PropertyInterface", "$", "property", ",", "EnvironmentInterface", "$", "environment", ")", "{", "if", "(", "!", "$", "property", "->", "getWidgetType", "(", ")", "||", "(", "'dummyProperty'", "===", "$", "property", "->", "getWidgetType", "(", ")", ")", ")", "{", "return", "false", ";", "}", "$", "translator", "=", "$", "environment", "->", "getTranslator", "(", ")", ";", "$", "extra", "=", "(", "array", ")", "$", "property", "->", "getExtra", "(", ")", ";", "if", "(", "$", "this", "->", "isPropertyAllowedByEdit", "(", "$", "extra", ",", "$", "environment", ")", "||", "$", "this", "->", "isPropertyAllowedByOverride", "(", "$", "extra", ",", "$", "environment", ")", ")", "{", "Message", "::", "addInfo", "(", "\\", "sprintf", "(", "$", "translator", "->", "translate", "(", "'MSC.not_allowed_property_info'", ")", ",", "$", "property", "->", "getLabel", "(", ")", "?", ":", "$", "property", "->", "getName", "(", ")", ",", "$", "translator", "->", "translate", "(", "'MSC.'", ".", "$", "environment", "->", "getInputProvider", "(", ")", "->", "getParameter", "(", "'mode'", ")", ".", "'Selected'", ")", ")", ")", ";", "return", "false", ";", "}", "return", "$", "this", "->", "isPropertyAllowedByIntersectProperties", "(", "$", "property", ",", "$", "environment", ")", ";", "}" ]
Is property allowed for edit multiple. @param PropertyInterface $property The property. @param EnvironmentInterface $environment The environment. @return bool
[ "Is", "property", "allowed", "for", "edit", "multiple", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L197-L223
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.isPropertyAllowedByOverride
private function isPropertyAllowedByOverride(array $extra, EnvironmentInterface $environment) { return ((true === $extra['unique']) || $extra['readonly'] || (true === $extra['doNotOverrideMultiple'])) && ('override' === $environment->getInputProvider()->getParameter('mode')); }
php
private function isPropertyAllowedByOverride(array $extra, EnvironmentInterface $environment) { return ((true === $extra['unique']) || $extra['readonly'] || (true === $extra['doNotOverrideMultiple'])) && ('override' === $environment->getInputProvider()->getParameter('mode')); }
[ "private", "function", "isPropertyAllowedByOverride", "(", "array", "$", "extra", ",", "EnvironmentInterface", "$", "environment", ")", "{", "return", "(", "(", "true", "===", "$", "extra", "[", "'unique'", "]", ")", "||", "$", "extra", "[", "'readonly'", "]", "||", "(", "true", "===", "$", "extra", "[", "'doNotOverrideMultiple'", "]", ")", ")", "&&", "(", "'override'", "===", "$", "environment", "->", "getInputProvider", "(", ")", "->", "getParameter", "(", "'mode'", ")", ")", ";", "}" ]
Is property allowed by override mode. @param array $extra The extra attributes. @param EnvironmentInterface $environment The environment. @return bool
[ "Is", "property", "allowed", "by", "override", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L247-L251
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.isPropertyAllowedByIntersectProperties
private function isPropertyAllowedByIntersectProperties( PropertyInterface $property, EnvironmentInterface $environment ) { $sessionStorage = $environment->getSessionStorage(); $inputProvider = $environment->getInputProvider(); $dataDefinition = $environment->getDataDefinition(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('mode')); return \array_key_exists($property->getName(), $session['intersectProperties']); }
php
private function isPropertyAllowedByIntersectProperties( PropertyInterface $property, EnvironmentInterface $environment ) { $sessionStorage = $environment->getSessionStorage(); $inputProvider = $environment->getInputProvider(); $dataDefinition = $environment->getDataDefinition(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $inputProvider->getParameter('mode')); return \array_key_exists($property->getName(), $session['intersectProperties']); }
[ "private", "function", "isPropertyAllowedByIntersectProperties", "(", "PropertyInterface", "$", "property", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "sessionStorage", "=", "$", "environment", "->", "getSessionStorage", "(", ")", ";", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "session", "=", "$", "sessionStorage", "->", "get", "(", "$", "dataDefinition", "->", "getName", "(", ")", ".", "'.'", ".", "$", "inputProvider", "->", "getParameter", "(", "'mode'", ")", ")", ";", "return", "\\", "array_key_exists", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "session", "[", "'intersectProperties'", "]", ")", ";", "}" ]
Is property allowed by intersect properties. @param PropertyInterface $property The property. @param EnvironmentInterface $environment The environment. @return bool
[ "Is", "property", "allowed", "by", "intersect", "properties", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L261-L272
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.handlePropertyFileTree
private function handlePropertyFileTree(PropertyInterface $property) { if ('fileTree' !== $property->getWidgetType()) { return; } $extra = $property->getExtra(); if (true === empty($extra['orderField'])) { return; } $script = '<script type="text/javascript"> $("%s").addEvent("change", function(ev) { Backend.toggleCheckboxes(ev.target, "%s"); GeneralLogger.info("The file order property is checked " + $("%s").checked) }); </script>'; $mooScript = \sprintf( $script, 'properties_' . $property->getName(), 'properties_' . $extra['orderField'], 'properties_' . $extra['orderField'] ); $GLOBALS['TL_MOOTOOLS']['cca.dc-general.fileTree-' . \md5($mooScript)] = $mooScript; }
php
private function handlePropertyFileTree(PropertyInterface $property) { if ('fileTree' !== $property->getWidgetType()) { return; } $extra = $property->getExtra(); if (true === empty($extra['orderField'])) { return; } $script = '<script type="text/javascript"> $("%s").addEvent("change", function(ev) { Backend.toggleCheckboxes(ev.target, "%s"); GeneralLogger.info("The file order property is checked " + $("%s").checked) }); </script>'; $mooScript = \sprintf( $script, 'properties_' . $property->getName(), 'properties_' . $extra['orderField'], 'properties_' . $extra['orderField'] ); $GLOBALS['TL_MOOTOOLS']['cca.dc-general.fileTree-' . \md5($mooScript)] = $mooScript; }
[ "private", "function", "handlePropertyFileTree", "(", "PropertyInterface", "$", "property", ")", "{", "if", "(", "'fileTree'", "!==", "$", "property", "->", "getWidgetType", "(", ")", ")", "{", "return", ";", "}", "$", "extra", "=", "$", "property", "->", "getExtra", "(", ")", ";", "if", "(", "true", "===", "empty", "(", "$", "extra", "[", "'orderField'", "]", ")", ")", "{", "return", ";", "}", "$", "script", "=", "'<script type=\"text/javascript\">\n $(\"%s\").addEvent(\"change\", function(ev) {\n Backend.toggleCheckboxes(ev.target, \"%s\");\n GeneralLogger.info(\"The file order property is checked \" + $(\"%s\").checked)\n });\n </script>'", ";", "$", "mooScript", "=", "\\", "sprintf", "(", "$", "script", ",", "'properties_'", ".", "$", "property", "->", "getName", "(", ")", ",", "'properties_'", ".", "$", "extra", "[", "'orderField'", "]", ",", "'properties_'", ".", "$", "extra", "[", "'orderField'", "]", ")", ";", "$", "GLOBALS", "[", "'TL_MOOTOOLS'", "]", "[", "'cca.dc-general.fileTree-'", ".", "\\", "md5", "(", "$", "mooScript", ")", "]", "=", "$", "mooScript", ";", "}" ]
Handle property file tree. @param PropertyInterface $property The property. @return void @SuppressWarnings(PHPMD.Superglobals)
[ "Handle", "property", "file", "tree", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L283-L310
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php
SelectPropertyAllHandler.handlePropertyFileTreeOrder
private function handlePropertyFileTreeOrder(PropertyInterface $property, ModelInterface $model) { if ('fileTreeOrder' !== $property->getWidgetType()) { return; } $model->setMeta($model::CSS_ROW_CLASS, 'invisible'); }
php
private function handlePropertyFileTreeOrder(PropertyInterface $property, ModelInterface $model) { if ('fileTreeOrder' !== $property->getWidgetType()) { return; } $model->setMeta($model::CSS_ROW_CLASS, 'invisible'); }
[ "private", "function", "handlePropertyFileTreeOrder", "(", "PropertyInterface", "$", "property", ",", "ModelInterface", "$", "model", ")", "{", "if", "(", "'fileTreeOrder'", "!==", "$", "property", "->", "getWidgetType", "(", ")", ")", "{", "return", ";", "}", "$", "model", "->", "setMeta", "(", "$", "model", "::", "CSS_ROW_CLASS", ",", "'invisible'", ")", ";", "}" ]
Handle property file tree order. @param PropertyInterface $property The property. @param ModelInterface $model The model. @return void
[ "Handle", "property", "file", "tree", "order", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php#L320-L327
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.excludePaletteSelectorProperty
private function excludePaletteSelectorProperty( Action $action, PropertyInterface $property, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); if (1 === \count($palettesDefinition->getPalettes())) { return false; } return $this->analyzeExcludeProperty($action, $environment, $property, $palettesDefinition); }
php
private function excludePaletteSelectorProperty( Action $action, PropertyInterface $property, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); if (1 === \count($palettesDefinition->getPalettes())) { return false; } return $this->analyzeExcludeProperty($action, $environment, $property, $palettesDefinition); }
[ "private", "function", "excludePaletteSelectorProperty", "(", "Action", "$", "action", ",", "PropertyInterface", "$", "property", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "palettesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalettesDefinition", "(", ")", ";", "if", "(", "1", "===", "\\", "count", "(", "$", "palettesDefinition", "->", "getPalettes", "(", ")", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "analyzeExcludeProperty", "(", "$", "action", ",", "$", "environment", ",", "$", "property", ",", "$", "palettesDefinition", ")", ";", "}" ]
Excluded the palette selector property. @param Action $action The action. @param PropertyInterface $property The property. @param EnvironmentInterface $environment The environment. @return bool
[ "Excluded", "the", "palette", "selector", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L97-L109
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.analyzeExcludeProperty
private function analyzeExcludeProperty( Action $action, EnvironmentInterface $environment, PropertyInterface $property, PalettesDefinitionInterface $palettesDefinition ) { $defaultPalette = $palettesDefinition->findPalette(); $defaultProperties = $defaultPalette->getProperties(); if (empty($defaultProperties)) { return false; } $emptyModel = $this->getIntersectionModel($action, $environment); $excludeProperty = false; foreach ($defaultProperties as $defaultProperty) { if ($property->getName() !== $defaultProperty->getName()) { continue; } $event = new GetPropertyOptionsEvent($environment, $emptyModel); $event->setPropertyName($property->getName()); $event->setOptions($property->getOptions()); $environment->getEventDispatcher()->dispatch(GetPropertyOptionsEvent::NAME, $event); if ((null === $event->getOptions()) || (0 > \count($event->getOptions()))) { continue; } $paletteCounter = 0; foreach (\array_keys($event->getOptions()) as $paletteName) { $palettesDefinition->hasPaletteByName($paletteName) ? ++$paletteCounter : null; } if ($paletteCounter !== \count($event->getOptions())) { continue; } $property->setOptions($event->getOptions()); $excludeProperty = true; } return $excludeProperty; }
php
private function analyzeExcludeProperty( Action $action, EnvironmentInterface $environment, PropertyInterface $property, PalettesDefinitionInterface $palettesDefinition ) { $defaultPalette = $palettesDefinition->findPalette(); $defaultProperties = $defaultPalette->getProperties(); if (empty($defaultProperties)) { return false; } $emptyModel = $this->getIntersectionModel($action, $environment); $excludeProperty = false; foreach ($defaultProperties as $defaultProperty) { if ($property->getName() !== $defaultProperty->getName()) { continue; } $event = new GetPropertyOptionsEvent($environment, $emptyModel); $event->setPropertyName($property->getName()); $event->setOptions($property->getOptions()); $environment->getEventDispatcher()->dispatch(GetPropertyOptionsEvent::NAME, $event); if ((null === $event->getOptions()) || (0 > \count($event->getOptions()))) { continue; } $paletteCounter = 0; foreach (\array_keys($event->getOptions()) as $paletteName) { $palettesDefinition->hasPaletteByName($paletteName) ? ++$paletteCounter : null; } if ($paletteCounter !== \count($event->getOptions())) { continue; } $property->setOptions($event->getOptions()); $excludeProperty = true; } return $excludeProperty; }
[ "private", "function", "analyzeExcludeProperty", "(", "Action", "$", "action", ",", "EnvironmentInterface", "$", "environment", ",", "PropertyInterface", "$", "property", ",", "PalettesDefinitionInterface", "$", "palettesDefinition", ")", "{", "$", "defaultPalette", "=", "$", "palettesDefinition", "->", "findPalette", "(", ")", ";", "$", "defaultProperties", "=", "$", "defaultPalette", "->", "getProperties", "(", ")", ";", "if", "(", "empty", "(", "$", "defaultProperties", ")", ")", "{", "return", "false", ";", "}", "$", "emptyModel", "=", "$", "this", "->", "getIntersectionModel", "(", "$", "action", ",", "$", "environment", ")", ";", "$", "excludeProperty", "=", "false", ";", "foreach", "(", "$", "defaultProperties", "as", "$", "defaultProperty", ")", "{", "if", "(", "$", "property", "->", "getName", "(", ")", "!==", "$", "defaultProperty", "->", "getName", "(", ")", ")", "{", "continue", ";", "}", "$", "event", "=", "new", "GetPropertyOptionsEvent", "(", "$", "environment", ",", "$", "emptyModel", ")", ";", "$", "event", "->", "setPropertyName", "(", "$", "property", "->", "getName", "(", ")", ")", ";", "$", "event", "->", "setOptions", "(", "$", "property", "->", "getOptions", "(", ")", ")", ";", "$", "environment", "->", "getEventDispatcher", "(", ")", "->", "dispatch", "(", "GetPropertyOptionsEvent", "::", "NAME", ",", "$", "event", ")", ";", "if", "(", "(", "null", "===", "$", "event", "->", "getOptions", "(", ")", ")", "||", "(", "0", ">", "\\", "count", "(", "$", "event", "->", "getOptions", "(", ")", ")", ")", ")", "{", "continue", ";", "}", "$", "paletteCounter", "=", "0", ";", "foreach", "(", "\\", "array_keys", "(", "$", "event", "->", "getOptions", "(", ")", ")", "as", "$", "paletteName", ")", "{", "$", "palettesDefinition", "->", "hasPaletteByName", "(", "$", "paletteName", ")", "?", "++", "$", "paletteCounter", ":", "null", ";", "}", "if", "(", "$", "paletteCounter", "!==", "\\", "count", "(", "$", "event", "->", "getOptions", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "property", "->", "setOptions", "(", "$", "event", "->", "getOptions", "(", ")", ")", ";", "$", "excludeProperty", "=", "true", ";", "}", "return", "$", "excludeProperty", ";", "}" ]
Analyze property for exclude. @param Action $action The action. @param EnvironmentInterface $environment The environment. @param PropertyInterface $property The property. @param PalettesDefinitionInterface $palettesDefinition The palettes definition. @return bool
[ "Analyze", "property", "for", "exclude", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L121-L163
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.makePropertyInvisibleByPalette
private function makePropertyInvisibleByPalette( DataDefinition\Definition\Properties\PropertyInterface $property, EnvironmentInterface $environment ) { $palettes = $environment->getDataDefinition()->getPalettesDefinition(); foreach ($palettes->getPalettes() as $palette) { foreach ($palette->getLegends() as $legend) { if (!$legend->hasProperty($property->getName())) { continue; } $visibleCondition = new PropertyTrueCondition('dummyNotVisible'); $invisibleProperty = $legend->getProperty($property->getName()); $conditions = $invisibleProperty->getVisibleCondition(); $conditions->addCondition($visibleCondition); } } }
php
private function makePropertyInvisibleByPalette( DataDefinition\Definition\Properties\PropertyInterface $property, EnvironmentInterface $environment ) { $palettes = $environment->getDataDefinition()->getPalettesDefinition(); foreach ($palettes->getPalettes() as $palette) { foreach ($palette->getLegends() as $legend) { if (!$legend->hasProperty($property->getName())) { continue; } $visibleCondition = new PropertyTrueCondition('dummyNotVisible'); $invisibleProperty = $legend->getProperty($property->getName()); $conditions = $invisibleProperty->getVisibleCondition(); $conditions->addCondition($visibleCondition); } } }
[ "private", "function", "makePropertyInvisibleByPalette", "(", "DataDefinition", "\\", "Definition", "\\", "Properties", "\\", "PropertyInterface", "$", "property", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "palettes", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalettesDefinition", "(", ")", ";", "foreach", "(", "$", "palettes", "->", "getPalettes", "(", ")", "as", "$", "palette", ")", "{", "foreach", "(", "$", "palette", "->", "getLegends", "(", ")", "as", "$", "legend", ")", "{", "if", "(", "!", "$", "legend", "->", "hasProperty", "(", "$", "property", "->", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "visibleCondition", "=", "new", "PropertyTrueCondition", "(", "'dummyNotVisible'", ")", ";", "$", "invisibleProperty", "=", "$", "legend", "->", "getProperty", "(", "$", "property", "->", "getName", "(", ")", ")", ";", "$", "conditions", "=", "$", "invisibleProperty", "->", "getVisibleCondition", "(", ")", ";", "$", "conditions", "->", "addCondition", "(", "$", "visibleCondition", ")", ";", "}", "}", "}" ]
Make the property invisible in all legends of each palette. @param DataDefinition\Definition\Properties\PropertyInterface $property The property. @param EnvironmentInterface $environment The environment. @return void
[ "Make", "the", "property", "invisible", "in", "all", "legends", "of", "each", "palette", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L173-L193
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.ensurePropertyVisibleInModel
protected function ensurePropertyVisibleInModel( Action $action, $propertyName, ModelInterface $model, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $propertyValues = $this->getPropertyValueBagFromModel($action, $model, $environment); $palette = $palettesDefinition->findPalette($model, $propertyValues); $invisible = false; foreach ($palette->getLegends() as $legend) { if ($invisible) { break; } foreach ($legend->getProperties($model, $propertyValues) as $property) { if ($invisible) { break; } if ($property->getName() !== $propertyName) { continue; } $invisible = $property->getVisibleCondition()->match($model, $propertyValues, $property, $legend); } } $findProperty = $environment->getDataDefinition()->getPropertiesDefinition()->getProperty($propertyName); return $this->matchVisibilityOfPropertyInAnyPalette($action, $findProperty, $invisible, $environment); }
php
protected function ensurePropertyVisibleInModel( Action $action, $propertyName, ModelInterface $model, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $propertyValues = $this->getPropertyValueBagFromModel($action, $model, $environment); $palette = $palettesDefinition->findPalette($model, $propertyValues); $invisible = false; foreach ($palette->getLegends() as $legend) { if ($invisible) { break; } foreach ($legend->getProperties($model, $propertyValues) as $property) { if ($invisible) { break; } if ($property->getName() !== $propertyName) { continue; } $invisible = $property->getVisibleCondition()->match($model, $propertyValues, $property, $legend); } } $findProperty = $environment->getDataDefinition()->getPropertiesDefinition()->getProperty($propertyName); return $this->matchVisibilityOfPropertyInAnyPalette($action, $findProperty, $invisible, $environment); }
[ "protected", "function", "ensurePropertyVisibleInModel", "(", "Action", "$", "action", ",", "$", "propertyName", ",", "ModelInterface", "$", "model", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "palettesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalettesDefinition", "(", ")", ";", "$", "propertyValues", "=", "$", "this", "->", "getPropertyValueBagFromModel", "(", "$", "action", ",", "$", "model", ",", "$", "environment", ")", ";", "$", "palette", "=", "$", "palettesDefinition", "->", "findPalette", "(", "$", "model", ",", "$", "propertyValues", ")", ";", "$", "invisible", "=", "false", ";", "foreach", "(", "$", "palette", "->", "getLegends", "(", ")", "as", "$", "legend", ")", "{", "if", "(", "$", "invisible", ")", "{", "break", ";", "}", "foreach", "(", "$", "legend", "->", "getProperties", "(", "$", "model", ",", "$", "propertyValues", ")", "as", "$", "property", ")", "{", "if", "(", "$", "invisible", ")", "{", "break", ";", "}", "if", "(", "$", "property", "->", "getName", "(", ")", "!==", "$", "propertyName", ")", "{", "continue", ";", "}", "$", "invisible", "=", "$", "property", "->", "getVisibleCondition", "(", ")", "->", "match", "(", "$", "model", ",", "$", "propertyValues", ",", "$", "property", ",", "$", "legend", ")", ";", "}", "}", "$", "findProperty", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", "->", "getProperty", "(", "$", "propertyName", ")", ";", "return", "$", "this", "->", "matchVisibilityOfPropertyInAnyPalette", "(", "$", "action", ",", "$", "findProperty", ",", "$", "invisible", ",", "$", "environment", ")", ";", "}" ]
Ensure if the property is visible by the model. @param Action $action The action. @param string $propertyName The property name. @param ModelInterface $model The model. @param EnvironmentInterface $environment The environment. @return bool
[ "Ensure", "if", "the", "property", "is", "visible", "by", "the", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L205-L238
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.matchVisibilityOfPropertyInAnyPalette
private function matchVisibilityOfPropertyInAnyPalette( Action $action, PropertyInterface $property, $invisible, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); if (true === $invisible || 1 === \count($palettesDefinition->getPalettes())) { return $invisible; } $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); $defaultPalette = $palettesDefinition->findPalette(); $defaultProperties = $defaultPalette->getProperties(); $intersectModel = $this->getIntersectionModel($action, $environment); $invisibleProperty = $invisible; foreach ($defaultProperties as $defaultProperty) { if (!$propertiesDefinition->hasProperty($defaultProperty->getName())) { continue; } $paletteSelectorProperty = $propertiesDefinition->getProperty($defaultProperty->getName()); if (null === $paletteSelectorProperty->getOptions()) { continue; } $invisibleProperty = $this->matchPaletteProperty($property, $intersectModel, $defaultProperty, $environment); if (true === $invisibleProperty) { continue; } break; } return $invisibleProperty; }
php
private function matchVisibilityOfPropertyInAnyPalette( Action $action, PropertyInterface $property, $invisible, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); if (true === $invisible || 1 === \count($palettesDefinition->getPalettes())) { return $invisible; } $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); $defaultPalette = $palettesDefinition->findPalette(); $defaultProperties = $defaultPalette->getProperties(); $intersectModel = $this->getIntersectionModel($action, $environment); $invisibleProperty = $invisible; foreach ($defaultProperties as $defaultProperty) { if (!$propertiesDefinition->hasProperty($defaultProperty->getName())) { continue; } $paletteSelectorProperty = $propertiesDefinition->getProperty($defaultProperty->getName()); if (null === $paletteSelectorProperty->getOptions()) { continue; } $invisibleProperty = $this->matchPaletteProperty($property, $intersectModel, $defaultProperty, $environment); if (true === $invisibleProperty) { continue; } break; } return $invisibleProperty; }
[ "private", "function", "matchVisibilityOfPropertyInAnyPalette", "(", "Action", "$", "action", ",", "PropertyInterface", "$", "property", ",", "$", "invisible", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "palettesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalettesDefinition", "(", ")", ";", "if", "(", "true", "===", "$", "invisible", "||", "1", "===", "\\", "count", "(", "$", "palettesDefinition", "->", "getPalettes", "(", ")", ")", ")", "{", "return", "$", "invisible", ";", "}", "$", "propertiesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", ";", "$", "defaultPalette", "=", "$", "palettesDefinition", "->", "findPalette", "(", ")", ";", "$", "defaultProperties", "=", "$", "defaultPalette", "->", "getProperties", "(", ")", ";", "$", "intersectModel", "=", "$", "this", "->", "getIntersectionModel", "(", "$", "action", ",", "$", "environment", ")", ";", "$", "invisibleProperty", "=", "$", "invisible", ";", "foreach", "(", "$", "defaultProperties", "as", "$", "defaultProperty", ")", "{", "if", "(", "!", "$", "propertiesDefinition", "->", "hasProperty", "(", "$", "defaultProperty", "->", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "paletteSelectorProperty", "=", "$", "propertiesDefinition", "->", "getProperty", "(", "$", "defaultProperty", "->", "getName", "(", ")", ")", ";", "if", "(", "null", "===", "$", "paletteSelectorProperty", "->", "getOptions", "(", ")", ")", "{", "continue", ";", "}", "$", "invisibleProperty", "=", "$", "this", "->", "matchPaletteProperty", "(", "$", "property", ",", "$", "intersectModel", ",", "$", "defaultProperty", ",", "$", "environment", ")", ";", "if", "(", "true", "===", "$", "invisibleProperty", ")", "{", "continue", ";", "}", "break", ";", "}", "return", "$", "invisibleProperty", ";", "}" ]
Match visibility of property in any palette. @param Action $action The action. @param PropertyInterface $property The property. @param bool $invisible The visibility. @param EnvironmentInterface $environment The environment. @return bool
[ "Match", "visibility", "of", "property", "in", "any", "palette", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L250-L288
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.findInvisiblePaletteSelectorProperty
private function findInvisiblePaletteSelectorProperty( Action $action, ModelInterface $model, array &$invisibleProperties, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); if (!empty($invisibleProperties) || 1 > \count($palettesDefinition->getPalettes())) { return; } $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); $session = $this->getSession($action, $environment); $palette = $palettesDefinition->findPalette($model); foreach ($palette->getProperties() as $paletteProperty) { if (!\array_key_exists($paletteProperty->getName(), $session['intersectValues'])) { continue; } $paletteName = $session['intersectValues'][$paletteProperty->getName()]; if (!$palettesDefinition->hasPaletteByName($paletteName)) { continue; } $invisibleProperties[$paletteProperty->getName()] = $propertiesDefinition->getProperty($paletteProperty->getName() . '.dummy'); break; } }
php
private function findInvisiblePaletteSelectorProperty( Action $action, ModelInterface $model, array &$invisibleProperties, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); if (!empty($invisibleProperties) || 1 > \count($palettesDefinition->getPalettes())) { return; } $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); $session = $this->getSession($action, $environment); $palette = $palettesDefinition->findPalette($model); foreach ($palette->getProperties() as $paletteProperty) { if (!\array_key_exists($paletteProperty->getName(), $session['intersectValues'])) { continue; } $paletteName = $session['intersectValues'][$paletteProperty->getName()]; if (!$palettesDefinition->hasPaletteByName($paletteName)) { continue; } $invisibleProperties[$paletteProperty->getName()] = $propertiesDefinition->getProperty($paletteProperty->getName() . '.dummy'); break; } }
[ "private", "function", "findInvisiblePaletteSelectorProperty", "(", "Action", "$", "action", ",", "ModelInterface", "$", "model", ",", "array", "&", "$", "invisibleProperties", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "palettesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalettesDefinition", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "invisibleProperties", ")", "||", "1", ">", "\\", "count", "(", "$", "palettesDefinition", "->", "getPalettes", "(", ")", ")", ")", "{", "return", ";", "}", "$", "propertiesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", ";", "$", "session", "=", "$", "this", "->", "getSession", "(", "$", "action", ",", "$", "environment", ")", ";", "$", "palette", "=", "$", "palettesDefinition", "->", "findPalette", "(", "$", "model", ")", ";", "foreach", "(", "$", "palette", "->", "getProperties", "(", ")", "as", "$", "paletteProperty", ")", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "paletteProperty", "->", "getName", "(", ")", ",", "$", "session", "[", "'intersectValues'", "]", ")", ")", "{", "continue", ";", "}", "$", "paletteName", "=", "$", "session", "[", "'intersectValues'", "]", "[", "$", "paletteProperty", "->", "getName", "(", ")", "]", ";", "if", "(", "!", "$", "palettesDefinition", "->", "hasPaletteByName", "(", "$", "paletteName", ")", ")", "{", "continue", ";", "}", "$", "invisibleProperties", "[", "$", "paletteProperty", "->", "getName", "(", ")", "]", "=", "$", "propertiesDefinition", "->", "getProperty", "(", "$", "paletteProperty", "->", "getName", "(", ")", ".", "'.dummy'", ")", ";", "break", ";", "}", "}" ]
Find the invisible palette selector property. @param Action $action The action. @param ModelInterface $model The model. @param array $invisibleProperties The invisible properties. @param EnvironmentInterface $environment The environment. @return void
[ "Find", "the", "invisible", "palette", "selector", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L483-L515
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.matchInvisibleProperty
private function matchInvisibleProperty( ConditionInterface $visibleCondition, array &$invisibleProperties, EnvironmentInterface $environment ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); foreach ($visibleCondition->getConditions() as $condition) { if ($condition instanceof ConditionChainInterface) { $this->matchInvisibleProperty($condition, $invisibleProperties, $environment); } if (!\method_exists($condition, 'getPropertyName')) { continue; } if (isset($invisibleProperties[$condition->getPropertyName()]) || !$propertiesDefinition->hasProperty($condition->getPropertyName() . '.dummy') ) { continue; } $invisibleProperties[$condition->getPropertyName()] = $propertiesDefinition->getProperty($condition->getPropertyName() . '.dummy'); } }
php
private function matchInvisibleProperty( ConditionInterface $visibleCondition, array &$invisibleProperties, EnvironmentInterface $environment ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); foreach ($visibleCondition->getConditions() as $condition) { if ($condition instanceof ConditionChainInterface) { $this->matchInvisibleProperty($condition, $invisibleProperties, $environment); } if (!\method_exists($condition, 'getPropertyName')) { continue; } if (isset($invisibleProperties[$condition->getPropertyName()]) || !$propertiesDefinition->hasProperty($condition->getPropertyName() . '.dummy') ) { continue; } $invisibleProperties[$condition->getPropertyName()] = $propertiesDefinition->getProperty($condition->getPropertyName() . '.dummy'); } }
[ "private", "function", "matchInvisibleProperty", "(", "ConditionInterface", "$", "visibleCondition", ",", "array", "&", "$", "invisibleProperties", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "propertiesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", ";", "foreach", "(", "$", "visibleCondition", "->", "getConditions", "(", ")", "as", "$", "condition", ")", "{", "if", "(", "$", "condition", "instanceof", "ConditionChainInterface", ")", "{", "$", "this", "->", "matchInvisibleProperty", "(", "$", "condition", ",", "$", "invisibleProperties", ",", "$", "environment", ")", ";", "}", "if", "(", "!", "\\", "method_exists", "(", "$", "condition", ",", "'getPropertyName'", ")", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "invisibleProperties", "[", "$", "condition", "->", "getPropertyName", "(", ")", "]", ")", "||", "!", "$", "propertiesDefinition", "->", "hasProperty", "(", "$", "condition", "->", "getPropertyName", "(", ")", ".", "'.dummy'", ")", ")", "{", "continue", ";", "}", "$", "invisibleProperties", "[", "$", "condition", "->", "getPropertyName", "(", ")", "]", "=", "$", "propertiesDefinition", "->", "getProperty", "(", "$", "condition", "->", "getPropertyName", "(", ")", ".", "'.dummy'", ")", ";", "}", "}" ]
Match the invisible property. @param ConditionInterface $visibleCondition The visible condition. @param array $invisibleProperties The invisible properties. @param EnvironmentInterface $environment The environment. @return void
[ "Match", "the", "invisible", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L526-L551
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.matchInvisibleSubProperties
private function matchInvisibleSubProperties( ModelInterface $model, DataDefinition\Definition\Properties\PropertyInterface $property, PropertyValueBagInterface $propertyValueBag, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $testPropertyValueBag = clone $propertyValueBag; $testPropertyValueBag->setPropertyValue('dummyNotVisible', true); $palette = $palettesDefinition->findPalette($model); $properties = []; foreach ($palette->getLegends() as $legend) { if (!$legend->hasProperty($property->getName())) { continue; } $legendProperties = (array) $legend->getProperties($model, $testPropertyValueBag); if (empty($legendProperties)) { continue; } foreach ($legendProperties as $legendProperty) { if ($property->getName() === $legendProperty->getName()) { continue; } $conditions = $legendProperty->getVisibleCondition(); if (!$conditions->match($model, $testPropertyValueBag, $legendProperty, $legend)) { continue; } $this->matchParentInvisibleProperty($conditions, $property, $legendProperty, $properties, $environment); } } return $properties; }
php
private function matchInvisibleSubProperties( ModelInterface $model, DataDefinition\Definition\Properties\PropertyInterface $property, PropertyValueBagInterface $propertyValueBag, EnvironmentInterface $environment ) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $testPropertyValueBag = clone $propertyValueBag; $testPropertyValueBag->setPropertyValue('dummyNotVisible', true); $palette = $palettesDefinition->findPalette($model); $properties = []; foreach ($palette->getLegends() as $legend) { if (!$legend->hasProperty($property->getName())) { continue; } $legendProperties = (array) $legend->getProperties($model, $testPropertyValueBag); if (empty($legendProperties)) { continue; } foreach ($legendProperties as $legendProperty) { if ($property->getName() === $legendProperty->getName()) { continue; } $conditions = $legendProperty->getVisibleCondition(); if (!$conditions->match($model, $testPropertyValueBag, $legendProperty, $legend)) { continue; } $this->matchParentInvisibleProperty($conditions, $property, $legendProperty, $properties, $environment); } } return $properties; }
[ "private", "function", "matchInvisibleSubProperties", "(", "ModelInterface", "$", "model", ",", "DataDefinition", "\\", "Definition", "\\", "Properties", "\\", "PropertyInterface", "$", "property", ",", "PropertyValueBagInterface", "$", "propertyValueBag", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "palettesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalettesDefinition", "(", ")", ";", "$", "testPropertyValueBag", "=", "clone", "$", "propertyValueBag", ";", "$", "testPropertyValueBag", "->", "setPropertyValue", "(", "'dummyNotVisible'", ",", "true", ")", ";", "$", "palette", "=", "$", "palettesDefinition", "->", "findPalette", "(", "$", "model", ")", ";", "$", "properties", "=", "[", "]", ";", "foreach", "(", "$", "palette", "->", "getLegends", "(", ")", "as", "$", "legend", ")", "{", "if", "(", "!", "$", "legend", "->", "hasProperty", "(", "$", "property", "->", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "legendProperties", "=", "(", "array", ")", "$", "legend", "->", "getProperties", "(", "$", "model", ",", "$", "testPropertyValueBag", ")", ";", "if", "(", "empty", "(", "$", "legendProperties", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "legendProperties", "as", "$", "legendProperty", ")", "{", "if", "(", "$", "property", "->", "getName", "(", ")", "===", "$", "legendProperty", "->", "getName", "(", ")", ")", "{", "continue", ";", "}", "$", "conditions", "=", "$", "legendProperty", "->", "getVisibleCondition", "(", ")", ";", "if", "(", "!", "$", "conditions", "->", "match", "(", "$", "model", ",", "$", "testPropertyValueBag", ",", "$", "legendProperty", ",", "$", "legend", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "matchParentInvisibleProperty", "(", "$", "conditions", ",", "$", "property", ",", "$", "legendProperty", ",", "$", "properties", ",", "$", "environment", ")", ";", "}", "}", "return", "$", "properties", ";", "}" ]
Match invisible sub properties. @param ModelInterface $model The model. @param DataDefinition\Definition\Properties\PropertyInterface $property The property. @param PropertyValueBagInterface $propertyValueBag The property values. @param EnvironmentInterface $environment The environment. @return array
[ "Match", "invisible", "sub", "properties", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L563-L603
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.matchParentInvisibleProperty
private function matchParentInvisibleProperty( ConditionInterface $visibleCondition, DataDefinition\Definition\Properties\PropertyInterface $property, DataDefinition\Palette\PropertyInterface $legendProperty, array &$invisibleProperties, EnvironmentInterface $environment ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); foreach ($visibleCondition->getConditions() as $condition) { if ($condition instanceof ConditionChainInterface) { $this->matchParentInvisibleProperty( $condition, $property, $legendProperty, $invisibleProperties, $environment ); } if (!\method_exists($condition, 'getPropertyName') || ($property->getName() !== $condition->getPropertyName()) ) { continue; } if (isset($invisibleProperties[$legendProperty->getName()]) || !$propertiesDefinition->hasProperty($legendProperty->getName() . '.dummy') ) { continue; } $invisibleProperties[$legendProperty->getName()] = $propertiesDefinition->getProperty($legendProperty->getName() . '.dummy'); } }
php
private function matchParentInvisibleProperty( ConditionInterface $visibleCondition, DataDefinition\Definition\Properties\PropertyInterface $property, DataDefinition\Palette\PropertyInterface $legendProperty, array &$invisibleProperties, EnvironmentInterface $environment ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); foreach ($visibleCondition->getConditions() as $condition) { if ($condition instanceof ConditionChainInterface) { $this->matchParentInvisibleProperty( $condition, $property, $legendProperty, $invisibleProperties, $environment ); } if (!\method_exists($condition, 'getPropertyName') || ($property->getName() !== $condition->getPropertyName()) ) { continue; } if (isset($invisibleProperties[$legendProperty->getName()]) || !$propertiesDefinition->hasProperty($legendProperty->getName() . '.dummy') ) { continue; } $invisibleProperties[$legendProperty->getName()] = $propertiesDefinition->getProperty($legendProperty->getName() . '.dummy'); } }
[ "private", "function", "matchParentInvisibleProperty", "(", "ConditionInterface", "$", "visibleCondition", ",", "DataDefinition", "\\", "Definition", "\\", "Properties", "\\", "PropertyInterface", "$", "property", ",", "DataDefinition", "\\", "Palette", "\\", "PropertyInterface", "$", "legendProperty", ",", "array", "&", "$", "invisibleProperties", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "propertiesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", ";", "foreach", "(", "$", "visibleCondition", "->", "getConditions", "(", ")", "as", "$", "condition", ")", "{", "if", "(", "$", "condition", "instanceof", "ConditionChainInterface", ")", "{", "$", "this", "->", "matchParentInvisibleProperty", "(", "$", "condition", ",", "$", "property", ",", "$", "legendProperty", ",", "$", "invisibleProperties", ",", "$", "environment", ")", ";", "}", "if", "(", "!", "\\", "method_exists", "(", "$", "condition", ",", "'getPropertyName'", ")", "||", "(", "$", "property", "->", "getName", "(", ")", "!==", "$", "condition", "->", "getPropertyName", "(", ")", ")", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "invisibleProperties", "[", "$", "legendProperty", "->", "getName", "(", ")", "]", ")", "||", "!", "$", "propertiesDefinition", "->", "hasProperty", "(", "$", "legendProperty", "->", "getName", "(", ")", ".", "'.dummy'", ")", ")", "{", "continue", ";", "}", "$", "invisibleProperties", "[", "$", "legendProperty", "->", "getName", "(", ")", "]", "=", "$", "propertiesDefinition", "->", "getProperty", "(", "$", "legendProperty", "->", "getName", "(", ")", ".", "'.dummy'", ")", ";", "}", "}" ]
Match the parent invisible property. @param ConditionInterface $visibleCondition The visible condition. @param DataDefinition\Definition\Properties\PropertyInterface $property The property. @param DataDefinition\Palette\PropertyInterface $legendProperty The legend property. @param array $invisibleProperties The invisible properties. @param EnvironmentInterface $environment The environment. @return void
[ "Match", "the", "parent", "invisible", "property", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L616-L652
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.getIntersectionModel
protected function getIntersectionModel(Action $action, EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $dataProvider = $environment->getDataProvider(); $dataDefinition = $environment->getDataDefinition(); $propertiesDefinition = $dataDefinition->getPropertiesDefinition(); $session = $this->getSession($action, $environment); $intersectModel = $dataProvider->getEmptyModel(); $defaultPalette = null; $legendPropertyNames = $this->getLegendPropertyNames($intersectModel, $environment, $defaultPalette); $idProperty = \method_exists($dataProvider, 'getIdProperty') ? $dataProvider->getIdProperty() : 'id'; foreach ((array) $session['intersectValues'] as $intersectProperty => $intersectValue) { if (($idProperty === $intersectProperty) || !$propertiesDefinition->hasProperty($intersectProperty) || (false === $this->useIntersectValue( $intersectProperty, $legendPropertyNames, $environment, $defaultPalette )) ) { continue; } if ($inputProvider->hasValue($intersectProperty)) { $intersectModel->setProperty($intersectProperty, $inputProvider->getValue($intersectProperty)); continue; } $intersectModel->setProperty($intersectProperty, $intersectValue); } $this->intersectModelSetPrimaryId($action, $intersectModel, $idProperty, $environment); $this->intersectModelSetParentId($intersectModel, $environment); return $intersectModel; }
php
protected function getIntersectionModel(Action $action, EnvironmentInterface $environment) { $inputProvider = $environment->getInputProvider(); $dataProvider = $environment->getDataProvider(); $dataDefinition = $environment->getDataDefinition(); $propertiesDefinition = $dataDefinition->getPropertiesDefinition(); $session = $this->getSession($action, $environment); $intersectModel = $dataProvider->getEmptyModel(); $defaultPalette = null; $legendPropertyNames = $this->getLegendPropertyNames($intersectModel, $environment, $defaultPalette); $idProperty = \method_exists($dataProvider, 'getIdProperty') ? $dataProvider->getIdProperty() : 'id'; foreach ((array) $session['intersectValues'] as $intersectProperty => $intersectValue) { if (($idProperty === $intersectProperty) || !$propertiesDefinition->hasProperty($intersectProperty) || (false === $this->useIntersectValue( $intersectProperty, $legendPropertyNames, $environment, $defaultPalette )) ) { continue; } if ($inputProvider->hasValue($intersectProperty)) { $intersectModel->setProperty($intersectProperty, $inputProvider->getValue($intersectProperty)); continue; } $intersectModel->setProperty($intersectProperty, $intersectValue); } $this->intersectModelSetPrimaryId($action, $intersectModel, $idProperty, $environment); $this->intersectModelSetParentId($intersectModel, $environment); return $intersectModel; }
[ "protected", "function", "getIntersectionModel", "(", "Action", "$", "action", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "dataProvider", "=", "$", "environment", "->", "getDataProvider", "(", ")", ";", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "propertiesDefinition", "=", "$", "dataDefinition", "->", "getPropertiesDefinition", "(", ")", ";", "$", "session", "=", "$", "this", "->", "getSession", "(", "$", "action", ",", "$", "environment", ")", ";", "$", "intersectModel", "=", "$", "dataProvider", "->", "getEmptyModel", "(", ")", ";", "$", "defaultPalette", "=", "null", ";", "$", "legendPropertyNames", "=", "$", "this", "->", "getLegendPropertyNames", "(", "$", "intersectModel", ",", "$", "environment", ",", "$", "defaultPalette", ")", ";", "$", "idProperty", "=", "\\", "method_exists", "(", "$", "dataProvider", ",", "'getIdProperty'", ")", "?", "$", "dataProvider", "->", "getIdProperty", "(", ")", ":", "'id'", ";", "foreach", "(", "(", "array", ")", "$", "session", "[", "'intersectValues'", "]", "as", "$", "intersectProperty", "=>", "$", "intersectValue", ")", "{", "if", "(", "(", "$", "idProperty", "===", "$", "intersectProperty", ")", "||", "!", "$", "propertiesDefinition", "->", "hasProperty", "(", "$", "intersectProperty", ")", "||", "(", "false", "===", "$", "this", "->", "useIntersectValue", "(", "$", "intersectProperty", ",", "$", "legendPropertyNames", ",", "$", "environment", ",", "$", "defaultPalette", ")", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "inputProvider", "->", "hasValue", "(", "$", "intersectProperty", ")", ")", "{", "$", "intersectModel", "->", "setProperty", "(", "$", "intersectProperty", ",", "$", "inputProvider", "->", "getValue", "(", "$", "intersectProperty", ")", ")", ";", "continue", ";", "}", "$", "intersectModel", "->", "setProperty", "(", "$", "intersectProperty", ",", "$", "intersectValue", ")", ";", "}", "$", "this", "->", "intersectModelSetPrimaryId", "(", "$", "action", ",", "$", "intersectModel", ",", "$", "idProperty", ",", "$", "environment", ")", ";", "$", "this", "->", "intersectModelSetParentId", "(", "$", "intersectModel", ",", "$", "environment", ")", ";", "return", "$", "intersectModel", ";", "}" ]
Get the intersection Model. If all select models has the same value by their property, then is the value set it. @param Action $action The action. @param EnvironmentInterface $environment The environment. @return ModelInterface
[ "Get", "the", "intersection", "Model", ".", "If", "all", "select", "models", "has", "the", "same", "value", "by", "their", "property", "then", "is", "the", "value", "set", "it", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L663-L703
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.useIntersectValue
private function useIntersectValue( $intersectPropertyName, array $legendPropertyNames, EnvironmentInterface $environment, PaletteInterface $defaultPalette = null ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); $useIntersectValue = (bool) $defaultPalette; if ($defaultPalette && !$propertiesDefinition->getProperty($intersectPropertyName)->getWidgetType() ) { $useIntersectValue = true; } if ($defaultPalette && (false === $useIntersectValue) && \in_array($intersectPropertyName, $legendPropertyNames) ) { $useIntersectValue = true; } return $useIntersectValue; }
php
private function useIntersectValue( $intersectPropertyName, array $legendPropertyNames, EnvironmentInterface $environment, PaletteInterface $defaultPalette = null ) { $propertiesDefinition = $environment->getDataDefinition()->getPropertiesDefinition(); $useIntersectValue = (bool) $defaultPalette; if ($defaultPalette && !$propertiesDefinition->getProperty($intersectPropertyName)->getWidgetType() ) { $useIntersectValue = true; } if ($defaultPalette && (false === $useIntersectValue) && \in_array($intersectPropertyName, $legendPropertyNames) ) { $useIntersectValue = true; } return $useIntersectValue; }
[ "private", "function", "useIntersectValue", "(", "$", "intersectPropertyName", ",", "array", "$", "legendPropertyNames", ",", "EnvironmentInterface", "$", "environment", ",", "PaletteInterface", "$", "defaultPalette", "=", "null", ")", "{", "$", "propertiesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPropertiesDefinition", "(", ")", ";", "$", "useIntersectValue", "=", "(", "bool", ")", "$", "defaultPalette", ";", "if", "(", "$", "defaultPalette", "&&", "!", "$", "propertiesDefinition", "->", "getProperty", "(", "$", "intersectPropertyName", ")", "->", "getWidgetType", "(", ")", ")", "{", "$", "useIntersectValue", "=", "true", ";", "}", "if", "(", "$", "defaultPalette", "&&", "(", "false", "===", "$", "useIntersectValue", ")", "&&", "\\", "in_array", "(", "$", "intersectPropertyName", ",", "$", "legendPropertyNames", ")", ")", "{", "$", "useIntersectValue", "=", "true", ";", "}", "return", "$", "useIntersectValue", ";", "}" ]
Use intersect value. @param string $intersectPropertyName The intersect property name. @param array $legendPropertyNames The legend names. @param EnvironmentInterface $environment The environment. @param PaletteInterface|null $defaultPalette The default palette. @return bool
[ "Use", "intersect", "value", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L716-L738
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.intersectModelSetPrimaryId
private function intersectModelSetPrimaryId( Action $action, $intersectModel, $idProperty, EnvironmentInterface $environment ) { if (null !== $intersectModel->getId()) { return; } $session = $this->getSession($action, $environment); $intersectModel->setId($session['intersectValues'][$idProperty]); $intersectModel->setProperty($idProperty, $session['intersectValues'][$idProperty]); }
php
private function intersectModelSetPrimaryId( Action $action, $intersectModel, $idProperty, EnvironmentInterface $environment ) { if (null !== $intersectModel->getId()) { return; } $session = $this->getSession($action, $environment); $intersectModel->setId($session['intersectValues'][$idProperty]); $intersectModel->setProperty($idProperty, $session['intersectValues'][$idProperty]); }
[ "private", "function", "intersectModelSetPrimaryId", "(", "Action", "$", "action", ",", "$", "intersectModel", ",", "$", "idProperty", ",", "EnvironmentInterface", "$", "environment", ")", "{", "if", "(", "null", "!==", "$", "intersectModel", "->", "getId", "(", ")", ")", "{", "return", ";", "}", "$", "session", "=", "$", "this", "->", "getSession", "(", "$", "action", ",", "$", "environment", ")", ";", "$", "intersectModel", "->", "setId", "(", "$", "session", "[", "'intersectValues'", "]", "[", "$", "idProperty", "]", ")", ";", "$", "intersectModel", "->", "setProperty", "(", "$", "idProperty", ",", "$", "session", "[", "'intersectValues'", "]", "[", "$", "idProperty", "]", ")", ";", "}" ]
Set the primaray id to the model from intersect values. @param Action $action The action. @param ModelInterface $intersectModel The intersect model. @param string $idProperty The id property. @param EnvironmentInterface $environment The environment. @return void
[ "Set", "the", "primaray", "id", "to", "the", "model", "from", "intersect", "values", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L750-L764
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.intersectModelSetParentId
private function intersectModelSetParentId(ModelInterface $intersectModel, EnvironmentInterface $environment) { $dataDefinition = $environment->getDataDefinition(); $parentDataDefinition = $environment->getParentDataDefinition(); if (null === $parentDataDefinition) { return; } $relationships = $dataDefinition->getModelRelationshipDefinition(); $childCondition = $relationships->getChildCondition($parentDataDefinition->getName(), $dataDefinition->getName()); $parentField = null; foreach ($childCondition->getSetters() as $setter) { if (!\array_key_exists('to_field', $setter)) { continue; } $parentField = $setter['to_field']; break; } if (null !== $parentField) { $intersectModel->setProperty( $parentField, ModelId::fromSerialized($environment->getInputProvider()->getParameter('pid')) ->getId() ); } }
php
private function intersectModelSetParentId(ModelInterface $intersectModel, EnvironmentInterface $environment) { $dataDefinition = $environment->getDataDefinition(); $parentDataDefinition = $environment->getParentDataDefinition(); if (null === $parentDataDefinition) { return; } $relationships = $dataDefinition->getModelRelationshipDefinition(); $childCondition = $relationships->getChildCondition($parentDataDefinition->getName(), $dataDefinition->getName()); $parentField = null; foreach ($childCondition->getSetters() as $setter) { if (!\array_key_exists('to_field', $setter)) { continue; } $parentField = $setter['to_field']; break; } if (null !== $parentField) { $intersectModel->setProperty( $parentField, ModelId::fromSerialized($environment->getInputProvider()->getParameter('pid')) ->getId() ); } }
[ "private", "function", "intersectModelSetParentId", "(", "ModelInterface", "$", "intersectModel", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "parentDataDefinition", "=", "$", "environment", "->", "getParentDataDefinition", "(", ")", ";", "if", "(", "null", "===", "$", "parentDataDefinition", ")", "{", "return", ";", "}", "$", "relationships", "=", "$", "dataDefinition", "->", "getModelRelationshipDefinition", "(", ")", ";", "$", "childCondition", "=", "$", "relationships", "->", "getChildCondition", "(", "$", "parentDataDefinition", "->", "getName", "(", ")", ",", "$", "dataDefinition", "->", "getName", "(", ")", ")", ";", "$", "parentField", "=", "null", ";", "foreach", "(", "$", "childCondition", "->", "getSetters", "(", ")", "as", "$", "setter", ")", "{", "if", "(", "!", "\\", "array_key_exists", "(", "'to_field'", ",", "$", "setter", ")", ")", "{", "continue", ";", "}", "$", "parentField", "=", "$", "setter", "[", "'to_field'", "]", ";", "break", ";", "}", "if", "(", "null", "!==", "$", "parentField", ")", "{", "$", "intersectModel", "->", "setProperty", "(", "$", "parentField", ",", "ModelId", "::", "fromSerialized", "(", "$", "environment", "->", "getInputProvider", "(", ")", "->", "getParameter", "(", "'pid'", ")", ")", "->", "getId", "(", ")", ")", ";", "}", "}" ]
Set the parent id to the inersect model. @param ModelInterface $intersectModel The intersect model. @param EnvironmentInterface $environment The environment. @return void
[ "Set", "the", "parent", "id", "to", "the", "inersect", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L774-L804
train
contao-community-alliance/dc-general
src/View/ActionHandler/AbstractPropertyVisibilityHandler.php
AbstractPropertyVisibilityHandler.getLegendPropertyNames
private function getLegendPropertyNames( ModelInterface $intersectModel, EnvironmentInterface $environment, PaletteInterface &$defaultPalette = null ) { $inputProvider = $environment->getInputProvider(); $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $legendPropertyNames = []; if ($inputProvider->hasValue('FORM_INPUTS') && (1 === \count($palettesDefinition->getPalettes()))) { return $legendPropertyNames; } $defaultPalette = $palettesDefinition->findPalette($intersectModel); foreach ($defaultPalette->getProperties($intersectModel) as $paletteProperty) { $legendPropertyNames[] = $paletteProperty->getName(); } return $legendPropertyNames; }
php
private function getLegendPropertyNames( ModelInterface $intersectModel, EnvironmentInterface $environment, PaletteInterface &$defaultPalette = null ) { $inputProvider = $environment->getInputProvider(); $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $legendPropertyNames = []; if ($inputProvider->hasValue('FORM_INPUTS') && (1 === \count($palettesDefinition->getPalettes()))) { return $legendPropertyNames; } $defaultPalette = $palettesDefinition->findPalette($intersectModel); foreach ($defaultPalette->getProperties($intersectModel) as $paletteProperty) { $legendPropertyNames[] = $paletteProperty->getName(); } return $legendPropertyNames; }
[ "private", "function", "getLegendPropertyNames", "(", "ModelInterface", "$", "intersectModel", ",", "EnvironmentInterface", "$", "environment", ",", "PaletteInterface", "&", "$", "defaultPalette", "=", "null", ")", "{", "$", "inputProvider", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "$", "palettesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalettesDefinition", "(", ")", ";", "$", "legendPropertyNames", "=", "[", "]", ";", "if", "(", "$", "inputProvider", "->", "hasValue", "(", "'FORM_INPUTS'", ")", "&&", "(", "1", "===", "\\", "count", "(", "$", "palettesDefinition", "->", "getPalettes", "(", ")", ")", ")", ")", "{", "return", "$", "legendPropertyNames", ";", "}", "$", "defaultPalette", "=", "$", "palettesDefinition", "->", "findPalette", "(", "$", "intersectModel", ")", ";", "foreach", "(", "$", "defaultPalette", "->", "getProperties", "(", "$", "intersectModel", ")", "as", "$", "paletteProperty", ")", "{", "$", "legendPropertyNames", "[", "]", "=", "$", "paletteProperty", "->", "getName", "(", ")", ";", "}", "return", "$", "legendPropertyNames", ";", "}" ]
Get legend property names. @param ModelInterface $intersectModel The intersect model. @param EnvironmentInterface $environment The environment. @param PaletteInterface|null $defaultPalette The default palette. @return array
[ "Get", "legend", "property", "names", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/View/ActionHandler/AbstractPropertyVisibilityHandler.php#L815-L834
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php
WidgetBuilder.getWidgetClass
protected function getWidgetClass(PropertyInterface $property) { if (isset(static::$widgetMapping[$property->getWidgetType()])) { return static::$widgetMapping[$property->getWidgetType()]; } if (!isset($GLOBALS['BE_FFL'][$property->getWidgetType()])) { return null; } $className = $GLOBALS['BE_FFL'][$property->getWidgetType()]; if (!\class_exists($className)) { return null; } return $className; }
php
protected function getWidgetClass(PropertyInterface $property) { if (isset(static::$widgetMapping[$property->getWidgetType()])) { return static::$widgetMapping[$property->getWidgetType()]; } if (!isset($GLOBALS['BE_FFL'][$property->getWidgetType()])) { return null; } $className = $GLOBALS['BE_FFL'][$property->getWidgetType()]; if (!\class_exists($className)) { return null; } return $className; }
[ "protected", "function", "getWidgetClass", "(", "PropertyInterface", "$", "property", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "widgetMapping", "[", "$", "property", "->", "getWidgetType", "(", ")", "]", ")", ")", "{", "return", "static", "::", "$", "widgetMapping", "[", "$", "property", "->", "getWidgetType", "(", ")", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'BE_FFL'", "]", "[", "$", "property", "->", "getWidgetType", "(", ")", "]", ")", ")", "{", "return", "null", ";", "}", "$", "className", "=", "$", "GLOBALS", "[", "'BE_FFL'", "]", "[", "$", "property", "->", "getWidgetType", "(", ")", "]", ";", "if", "(", "!", "\\", "class_exists", "(", "$", "className", ")", ")", "{", "return", "null", ";", "}", "return", "$", "className", ";", "}" ]
Try to resolve the class name for the widget. @param PropertyInterface $property The property to get the widget class name for. @return string @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Try", "to", "resolve", "the", "class", "name", "for", "the", "widget", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L135-L151
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php
WidgetBuilder.isGetOptionsAllowed
private function isGetOptionsAllowed(PropertyInterface $property): bool { $propExtra = $property->getExtra(); // Check the overwrite param. if (\is_array($propExtra) && \array_key_exists('fetchOptions', $propExtra) && (true === $propExtra['fetchOptions']) ) { return true; } // Check the class. if ('checkbox' !== $property->getWidgetType()) { return true; } // Check if multiple is active. return \array_key_exists('multiple', $propExtra) && (true === $propExtra['multiple']); }
php
private function isGetOptionsAllowed(PropertyInterface $property): bool { $propExtra = $property->getExtra(); // Check the overwrite param. if (\is_array($propExtra) && \array_key_exists('fetchOptions', $propExtra) && (true === $propExtra['fetchOptions']) ) { return true; } // Check the class. if ('checkbox' !== $property->getWidgetType()) { return true; } // Check if multiple is active. return \array_key_exists('multiple', $propExtra) && (true === $propExtra['multiple']); }
[ "private", "function", "isGetOptionsAllowed", "(", "PropertyInterface", "$", "property", ")", ":", "bool", "{", "$", "propExtra", "=", "$", "property", "->", "getExtra", "(", ")", ";", "// Check the overwrite param.", "if", "(", "\\", "is_array", "(", "$", "propExtra", ")", "&&", "\\", "array_key_exists", "(", "'fetchOptions'", ",", "$", "propExtra", ")", "&&", "(", "true", "===", "$", "propExtra", "[", "'fetchOptions'", "]", ")", ")", "{", "return", "true", ";", "}", "// Check the class.", "if", "(", "'checkbox'", "!==", "$", "property", "->", "getWidgetType", "(", ")", ")", "{", "return", "true", ";", "}", "// Check if multiple is active.", "return", "\\", "array_key_exists", "(", "'multiple'", ",", "$", "propExtra", ")", "&&", "(", "true", "===", "$", "propExtra", "[", "'multiple'", "]", ")", ";", "}" ]
Check if the current widget is allowed to get options. @param PropertyInterface $property The bag with all information. @return bool True => allowed to get options | False => doesn't get options.
[ "Check", "if", "the", "current", "widget", "is", "allowed", "to", "get", "options", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L188-L207
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php
WidgetBuilder.getTableWizard
protected function getTableWizard() { $environment = $this->getEnvironment(); $dispatcher = $environment->getEventDispatcher(); $defName = $environment->getDataDefinition()->getName(); $translator = $environment->getTranslator(); $urlEvent = new AddToUrlEvent('key=table'); $importTableEvent = new GenerateHtmlEvent( 'tablewizard.svg', $translator->translate('importTable.0', $defName), 'style="vertical-align:text-bottom;"' ); $shrinkEvent = new GenerateHtmlEvent( 'demagnify.svg', $translator->translate('shrink.0', $defName), \sprintf( 'title="%s" ' . 'style="vertical-align:text-bottom; cursor:pointer;" ' . 'onclick="Backend.tableWizardResize(0.9);"', StringUtil::specialchars($translator->translate('shrink.1', $defName)) ) ); $expandEvent = new GenerateHtmlEvent( 'magnify.svg', $translator->translate('expand.0', $defName), \sprintf( 'title="%s" ' . 'style="vertical-align:text-bottom; cursor:pointer;" ' . 'onclick="Backend.tableWizardResize(1.1);"', StringUtil::specialchars($translator->translate('expand.1', $defName)) ) ); $dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $urlEvent); $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $importTableEvent); $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $shrinkEvent); $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $expandEvent); return \sprintf( ' <a href="%s" title="%s" onclick="Backend.getScrollOffset();">%s</a> %s%s', \ampersand($urlEvent->getUrl()), StringUtil::specialchars($translator->translate('importTable.1', $defName)), $importTableEvent->getHtml(), $shrinkEvent->getHtml(), $expandEvent->getHtml() ); }
php
protected function getTableWizard() { $environment = $this->getEnvironment(); $dispatcher = $environment->getEventDispatcher(); $defName = $environment->getDataDefinition()->getName(); $translator = $environment->getTranslator(); $urlEvent = new AddToUrlEvent('key=table'); $importTableEvent = new GenerateHtmlEvent( 'tablewizard.svg', $translator->translate('importTable.0', $defName), 'style="vertical-align:text-bottom;"' ); $shrinkEvent = new GenerateHtmlEvent( 'demagnify.svg', $translator->translate('shrink.0', $defName), \sprintf( 'title="%s" ' . 'style="vertical-align:text-bottom; cursor:pointer;" ' . 'onclick="Backend.tableWizardResize(0.9);"', StringUtil::specialchars($translator->translate('shrink.1', $defName)) ) ); $expandEvent = new GenerateHtmlEvent( 'magnify.svg', $translator->translate('expand.0', $defName), \sprintf( 'title="%s" ' . 'style="vertical-align:text-bottom; cursor:pointer;" ' . 'onclick="Backend.tableWizardResize(1.1);"', StringUtil::specialchars($translator->translate('expand.1', $defName)) ) ); $dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $urlEvent); $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $importTableEvent); $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $shrinkEvent); $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $expandEvent); return \sprintf( ' <a href="%s" title="%s" onclick="Backend.getScrollOffset();">%s</a> %s%s', \ampersand($urlEvent->getUrl()), StringUtil::specialchars($translator->translate('importTable.1', $defName)), $importTableEvent->getHtml(), $shrinkEvent->getHtml(), $expandEvent->getHtml() ); }
[ "protected", "function", "getTableWizard", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "dispatcher", "=", "$", "environment", "->", "getEventDispatcher", "(", ")", ";", "$", "defName", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getName", "(", ")", ";", "$", "translator", "=", "$", "environment", "->", "getTranslator", "(", ")", ";", "$", "urlEvent", "=", "new", "AddToUrlEvent", "(", "'key=table'", ")", ";", "$", "importTableEvent", "=", "new", "GenerateHtmlEvent", "(", "'tablewizard.svg'", ",", "$", "translator", "->", "translate", "(", "'importTable.0'", ",", "$", "defName", ")", ",", "'style=\"vertical-align:text-bottom;\"'", ")", ";", "$", "shrinkEvent", "=", "new", "GenerateHtmlEvent", "(", "'demagnify.svg'", ",", "$", "translator", "->", "translate", "(", "'shrink.0'", ",", "$", "defName", ")", ",", "\\", "sprintf", "(", "'title=\"%s\" '", ".", "'style=\"vertical-align:text-bottom; cursor:pointer;\" '", ".", "'onclick=\"Backend.tableWizardResize(0.9);\"'", ",", "StringUtil", "::", "specialchars", "(", "$", "translator", "->", "translate", "(", "'shrink.1'", ",", "$", "defName", ")", ")", ")", ")", ";", "$", "expandEvent", "=", "new", "GenerateHtmlEvent", "(", "'magnify.svg'", ",", "$", "translator", "->", "translate", "(", "'expand.0'", ",", "$", "defName", ")", ",", "\\", "sprintf", "(", "'title=\"%s\" '", ".", "'style=\"vertical-align:text-bottom; cursor:pointer;\" '", ".", "'onclick=\"Backend.tableWizardResize(1.1);\"'", ",", "StringUtil", "::", "specialchars", "(", "$", "translator", "->", "translate", "(", "'expand.1'", ",", "$", "defName", ")", ")", ")", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "BACKEND_ADD_TO_URL", ",", "$", "urlEvent", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "IMAGE_GET_HTML", ",", "$", "importTableEvent", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "IMAGE_GET_HTML", ",", "$", "shrinkEvent", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "ContaoEvents", "::", "IMAGE_GET_HTML", ",", "$", "expandEvent", ")", ";", "return", "\\", "sprintf", "(", "' <a href=\"%s\" title=\"%s\" onclick=\"Backend.getScrollOffset();\">%s</a> %s%s'", ",", "\\", "ampersand", "(", "$", "urlEvent", "->", "getUrl", "(", ")", ")", ",", "StringUtil", "::", "specialchars", "(", "$", "translator", "->", "translate", "(", "'importTable.1'", ",", "$", "defName", ")", ")", ",", "$", "importTableEvent", "->", "getHtml", "(", ")", ",", "$", "shrinkEvent", "->", "getHtml", "(", ")", ",", "$", "expandEvent", "->", "getHtml", "(", ")", ")", ";", "}" ]
Get the table import wizard. @return string
[ "Get", "the", "table", "import", "wizard", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L214-L263
train