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/Subscriber/WidgetBuilder.php | WidgetBuilder.getListWizard | protected function getListWizard()
{
$environment = $this->getEnvironment();
$dispatcher = $environment->getEventDispatcher();
$defName = $environment->getDataDefinition()->getName();
$translator = $environment->getTranslator();
$urlEvent = new AddToUrlEvent('key=list');
$importListEvent = new GenerateHtmlEvent(
'tablewizard.svg',
$translator->translate('importList.0', $defName),
'style="vertical-align:text-bottom;"'
);
$dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $urlEvent);
$dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $importListEvent);
return \sprintf(
' <a href="%s" title="%s" onclick="Backend.getScrollOffset();">%s</a>',
\ampersand($urlEvent->getUrl()),
StringUtil::specialchars($translator->translate('importList.1', $defName)),
$importListEvent->getHtml()
);
} | php | protected function getListWizard()
{
$environment = $this->getEnvironment();
$dispatcher = $environment->getEventDispatcher();
$defName = $environment->getDataDefinition()->getName();
$translator = $environment->getTranslator();
$urlEvent = new AddToUrlEvent('key=list');
$importListEvent = new GenerateHtmlEvent(
'tablewizard.svg',
$translator->translate('importList.0', $defName),
'style="vertical-align:text-bottom;"'
);
$dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $urlEvent);
$dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $importListEvent);
return \sprintf(
' <a href="%s" title="%s" onclick="Backend.getScrollOffset();">%s</a>',
\ampersand($urlEvent->getUrl()),
StringUtil::specialchars($translator->translate('importList.1', $defName)),
$importListEvent->getHtml()
);
} | [
"protected",
"function",
"getListWizard",
"(",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"dispatcher",
"=",
"$",
"environment",
"->",
"getEventDispatcher",
"(",
")",
";",
"$",
"defName",
"=",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"translator",
"=",
"$",
"environment",
"->",
"getTranslator",
"(",
")",
";",
"$",
"urlEvent",
"=",
"new",
"AddToUrlEvent",
"(",
"'key=list'",
")",
";",
"$",
"importListEvent",
"=",
"new",
"GenerateHtmlEvent",
"(",
"'tablewizard.svg'",
",",
"$",
"translator",
"->",
"translate",
"(",
"'importList.0'",
",",
"$",
"defName",
")",
",",
"'style=\"vertical-align:text-bottom;\"'",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"BACKEND_ADD_TO_URL",
",",
"$",
"urlEvent",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"IMAGE_GET_HTML",
",",
"$",
"importListEvent",
")",
";",
"return",
"\\",
"sprintf",
"(",
"' <a href=\"%s\" title=\"%s\" onclick=\"Backend.getScrollOffset();\">%s</a>'",
",",
"\\",
"ampersand",
"(",
"$",
"urlEvent",
"->",
"getUrl",
"(",
")",
")",
",",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"translator",
"->",
"translate",
"(",
"'importList.1'",
",",
"$",
"defName",
")",
")",
",",
"$",
"importListEvent",
"->",
"getHtml",
"(",
")",
")",
";",
"}"
]
| Get the list import wizard.
@return string | [
"Get",
"the",
"list",
"import",
"wizard",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L270-L294 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php | WidgetBuilder.getHelpWizard | protected function getHelpWizard($propInfo)
{
$helpWizard = '';
$environment = $this->getEnvironment();
$translator = $environment->getTranslator();
// Add the help wizard.
if ($propInfo->getExtra() && \array_key_exists('helpwizard', $propInfo->getExtra())) {
$event = new GenerateHtmlEvent(
'about.svg',
$translator->translate('helpWizard', 'MSC'),
'style="vertical-align:text-bottom;"'
);
$environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $event);
$helpWizard .= \sprintf(
' <a href="contao/help?table=%s&field=%s" ' .
'title="%s" ' .
'onclick="Backend.openWindow(this, 600, 500); return false;">%s</a>',
$environment->getDataDefinition()->getName(),
$propInfo->getName(),
StringUtil::specialchars($translator->translate('helpWizard', 'MSC')),
$event->getHtml()
);
}
return $helpWizard;
} | php | protected function getHelpWizard($propInfo)
{
$helpWizard = '';
$environment = $this->getEnvironment();
$translator = $environment->getTranslator();
// Add the help wizard.
if ($propInfo->getExtra() && \array_key_exists('helpwizard', $propInfo->getExtra())) {
$event = new GenerateHtmlEvent(
'about.svg',
$translator->translate('helpWizard', 'MSC'),
'style="vertical-align:text-bottom;"'
);
$environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $event);
$helpWizard .= \sprintf(
' <a href="contao/help?table=%s&field=%s" ' .
'title="%s" ' .
'onclick="Backend.openWindow(this, 600, 500); return false;">%s</a>',
$environment->getDataDefinition()->getName(),
$propInfo->getName(),
StringUtil::specialchars($translator->translate('helpWizard', 'MSC')),
$event->getHtml()
);
}
return $helpWizard;
} | [
"protected",
"function",
"getHelpWizard",
"(",
"$",
"propInfo",
")",
"{",
"$",
"helpWizard",
"=",
"''",
";",
"$",
"environment",
"=",
"$",
"this",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"translator",
"=",
"$",
"environment",
"->",
"getTranslator",
"(",
")",
";",
"// Add the help wizard.",
"if",
"(",
"$",
"propInfo",
"->",
"getExtra",
"(",
")",
"&&",
"\\",
"array_key_exists",
"(",
"'helpwizard'",
",",
"$",
"propInfo",
"->",
"getExtra",
"(",
")",
")",
")",
"{",
"$",
"event",
"=",
"new",
"GenerateHtmlEvent",
"(",
"'about.svg'",
",",
"$",
"translator",
"->",
"translate",
"(",
"'helpWizard'",
",",
"'MSC'",
")",
",",
"'style=\"vertical-align:text-bottom;\"'",
")",
";",
"$",
"environment",
"->",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"IMAGE_GET_HTML",
",",
"$",
"event",
")",
";",
"$",
"helpWizard",
".=",
"\\",
"sprintf",
"(",
"' <a href=\"contao/help?table=%s&field=%s\" '",
".",
"'title=\"%s\" '",
".",
"'onclick=\"Backend.openWindow(this, 600, 500); return false;\">%s</a>'",
",",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getName",
"(",
")",
",",
"$",
"propInfo",
"->",
"getName",
"(",
")",
",",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"translator",
"->",
"translate",
"(",
"'helpWizard'",
",",
"'MSC'",
")",
")",
",",
"$",
"event",
"->",
"getHtml",
"(",
")",
")",
";",
"}",
"return",
"$",
"helpWizard",
";",
"}"
]
| Get the help wizard.
@param PropertyInterface $propInfo The property for which the wizard shall be generated.
@return string | [
"Get",
"the",
"help",
"wizard",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L348-L375 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php | WidgetBuilder.buildWidget | public function buildWidget(
PropertyInterface $property,
ModelInterface $model
) {
if (static::$scopeDeterminator->currentScopeIsUnknown()
|| !static::$scopeDeterminator->currentScopeIsBackend()
) {
throw new DcGeneralRuntimeException(
\sprintf(
'WidgetBuilder only supports the backend mode. Running in mode "%s".',
static::$scopeDeterminator->currentScopeIsUnknown() ? 'unknown' : 'frontend'
)
);
}
$environment = $this->getEnvironment();
$class = $this->getWidgetClass($property);
$prepareAttributes = $this->prepareWidgetAttributes($model, $property);
$widget = new $class($prepareAttributes, new DcCompat($environment, $model, $property->getName()));
// OH: what is this? source: DataContainer 232.
$widget->currentRecord = $model->getId();
$widget->xlabel .= $this->getXLabel($property);
$event = new ManipulateWidgetEvent($environment, $model, $property, $widget);
$environment->getEventDispatcher()->dispatch(ManipulateWidgetEvent::NAME, $event);
return $widget;
} | php | public function buildWidget(
PropertyInterface $property,
ModelInterface $model
) {
if (static::$scopeDeterminator->currentScopeIsUnknown()
|| !static::$scopeDeterminator->currentScopeIsBackend()
) {
throw new DcGeneralRuntimeException(
\sprintf(
'WidgetBuilder only supports the backend mode. Running in mode "%s".',
static::$scopeDeterminator->currentScopeIsUnknown() ? 'unknown' : 'frontend'
)
);
}
$environment = $this->getEnvironment();
$class = $this->getWidgetClass($property);
$prepareAttributes = $this->prepareWidgetAttributes($model, $property);
$widget = new $class($prepareAttributes, new DcCompat($environment, $model, $property->getName()));
// OH: what is this? source: DataContainer 232.
$widget->currentRecord = $model->getId();
$widget->xlabel .= $this->getXLabel($property);
$event = new ManipulateWidgetEvent($environment, $model, $property, $widget);
$environment->getEventDispatcher()->dispatch(ManipulateWidgetEvent::NAME, $event);
return $widget;
} | [
"public",
"function",
"buildWidget",
"(",
"PropertyInterface",
"$",
"property",
",",
"ModelInterface",
"$",
"model",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"scopeDeterminator",
"->",
"currentScopeIsUnknown",
"(",
")",
"||",
"!",
"static",
"::",
"$",
"scopeDeterminator",
"->",
"currentScopeIsBackend",
"(",
")",
")",
"{",
"throw",
"new",
"DcGeneralRuntimeException",
"(",
"\\",
"sprintf",
"(",
"'WidgetBuilder only supports the backend mode. Running in mode \"%s\".'",
",",
"static",
"::",
"$",
"scopeDeterminator",
"->",
"currentScopeIsUnknown",
"(",
")",
"?",
"'unknown'",
":",
"'frontend'",
")",
")",
";",
"}",
"$",
"environment",
"=",
"$",
"this",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getWidgetClass",
"(",
"$",
"property",
")",
";",
"$",
"prepareAttributes",
"=",
"$",
"this",
"->",
"prepareWidgetAttributes",
"(",
"$",
"model",
",",
"$",
"property",
")",
";",
"$",
"widget",
"=",
"new",
"$",
"class",
"(",
"$",
"prepareAttributes",
",",
"new",
"DcCompat",
"(",
"$",
"environment",
",",
"$",
"model",
",",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
";",
"// OH: what is this? source: DataContainer 232.",
"$",
"widget",
"->",
"currentRecord",
"=",
"$",
"model",
"->",
"getId",
"(",
")",
";",
"$",
"widget",
"->",
"xlabel",
".=",
"$",
"this",
"->",
"getXLabel",
"(",
"$",
"property",
")",
";",
"$",
"event",
"=",
"new",
"ManipulateWidgetEvent",
"(",
"$",
"environment",
",",
"$",
"model",
",",
"$",
"property",
",",
"$",
"widget",
")",
";",
"$",
"environment",
"->",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"ManipulateWidgetEvent",
"::",
"NAME",
",",
"$",
"event",
")",
";",
"return",
"$",
"widget",
";",
"}"
]
| Build a widget for a given property.
@param PropertyInterface $property The property.
@param ModelInterface $model The current model.
@return Widget
@throws DcGeneralRuntimeException When not running in TL_MODE BE.
@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName) | [
"Build",
"a",
"widget",
"for",
"a",
"given",
"property",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L390-L420 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php | WidgetBuilder.valueToWidget | private function valueToWidget(ModelInterface $model, PropertyInterface $property)
{
$environment = $this->getEnvironment();
$event = new DecodePropertyValueForWidgetEvent($environment, $model);
$event
->setProperty($property->getName())
->setValue($model->getProperty($property->getName()));
$environment->getEventDispatcher()->dispatch($event::NAME, $event);
$value = $event->getValue();
$propExtra = $property->getExtra();
if ((0 === (int) $value)
&& \is_numeric($value)
&& empty($propExtra['mandatory'])
&& (isset($propExtra['rgxp']) && \in_array($propExtra['rgxp'], ['date', 'time', 'datim']))
) {
$value = '';
}
return $value;
} | php | private function valueToWidget(ModelInterface $model, PropertyInterface $property)
{
$environment = $this->getEnvironment();
$event = new DecodePropertyValueForWidgetEvent($environment, $model);
$event
->setProperty($property->getName())
->setValue($model->getProperty($property->getName()));
$environment->getEventDispatcher()->dispatch($event::NAME, $event);
$value = $event->getValue();
$propExtra = $property->getExtra();
if ((0 === (int) $value)
&& \is_numeric($value)
&& empty($propExtra['mandatory'])
&& (isset($propExtra['rgxp']) && \in_array($propExtra['rgxp'], ['date', 'time', 'datim']))
) {
$value = '';
}
return $value;
} | [
"private",
"function",
"valueToWidget",
"(",
"ModelInterface",
"$",
"model",
",",
"PropertyInterface",
"$",
"property",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"event",
"=",
"new",
"DecodePropertyValueForWidgetEvent",
"(",
"$",
"environment",
",",
"$",
"model",
")",
";",
"$",
"event",
"->",
"setProperty",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
")",
"->",
"setValue",
"(",
"$",
"model",
"->",
"getProperty",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"environment",
"->",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
"::",
"NAME",
",",
"$",
"event",
")",
";",
"$",
"value",
"=",
"$",
"event",
"->",
"getValue",
"(",
")",
";",
"$",
"propExtra",
"=",
"$",
"property",
"->",
"getExtra",
"(",
")",
";",
"if",
"(",
"(",
"0",
"===",
"(",
"int",
")",
"$",
"value",
")",
"&&",
"\\",
"is_numeric",
"(",
"$",
"value",
")",
"&&",
"empty",
"(",
"$",
"propExtra",
"[",
"'mandatory'",
"]",
")",
"&&",
"(",
"isset",
"(",
"$",
"propExtra",
"[",
"'rgxp'",
"]",
")",
"&&",
"\\",
"in_array",
"(",
"$",
"propExtra",
"[",
"'rgxp'",
"]",
",",
"[",
"'date'",
",",
"'time'",
",",
"'datim'",
"]",
")",
")",
")",
"{",
"$",
"value",
"=",
"''",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Decode the value for the widget.
@param ModelInterface $model The model.
@param PropertyInterface $property The property name.
@return mixed | [
"Decode",
"the",
"value",
"for",
"the",
"widget",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L430-L453 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php | WidgetBuilder.prepareWidgetAttributes | private function prepareWidgetAttributes(ModelInterface $model, PropertyInterface $property)
{
$environment = $this->getEnvironment();
$defName = $environment->getDataDefinition()->getName();
$propExtra = $property->getExtra();
$value = $this->valueToWidget($model, $property);
$propExtra['required'] = ('' === $value) && !empty($propExtra['mandatory']);
$widgetConfig = [
'inputType' => $property->getWidgetType(),
'label' => [
$property->getLabel(),
$property->getDescription()
],
'options' => $this->getOptionsForWidget($property, $model),
'eval' => $propExtra,
// 'foreignKey' => null
];
if (isset($propExtra['reference'])) {
$widgetConfig['reference'] = $propExtra['reference'];
}
$event = new GetAttributesFromDcaEvent(
$widgetConfig,
$property->getName(),
$value,
$property->getName(),
$defName,
new DcCompat($environment, $model, $property->getName())
);
$environment->getEventDispatcher()->dispatch(ContaoEvents::WIDGET_GET_ATTRIBUTES_FROM_DCA, $event);
$prepareAttributes = $event->getResult();
if (('checkbox' === $widgetConfig['inputType'])
&& $widgetConfig['eval']['submitOnChange']
&& isset($GLOBALS['TL_DCA'][$defName]['subpalettes'])
&& \is_array($GLOBALS['TL_DCA'][$defName]['subpalettes'])
&& \array_key_exists($property->getName(), $GLOBALS['TL_DCA'][$defName]['subpalettes'])
) {
// We have to override the onclick, do not append to it as Contao adds it's own code here in
// Widget::getAttributesFromDca() which kills our sub palette handling!
$prepareAttributes['onclick'] = "Backend.autoSubmit('" . $defName . "');";
}
return $prepareAttributes;
} | php | private function prepareWidgetAttributes(ModelInterface $model, PropertyInterface $property)
{
$environment = $this->getEnvironment();
$defName = $environment->getDataDefinition()->getName();
$propExtra = $property->getExtra();
$value = $this->valueToWidget($model, $property);
$propExtra['required'] = ('' === $value) && !empty($propExtra['mandatory']);
$widgetConfig = [
'inputType' => $property->getWidgetType(),
'label' => [
$property->getLabel(),
$property->getDescription()
],
'options' => $this->getOptionsForWidget($property, $model),
'eval' => $propExtra,
// 'foreignKey' => null
];
if (isset($propExtra['reference'])) {
$widgetConfig['reference'] = $propExtra['reference'];
}
$event = new GetAttributesFromDcaEvent(
$widgetConfig,
$property->getName(),
$value,
$property->getName(),
$defName,
new DcCompat($environment, $model, $property->getName())
);
$environment->getEventDispatcher()->dispatch(ContaoEvents::WIDGET_GET_ATTRIBUTES_FROM_DCA, $event);
$prepareAttributes = $event->getResult();
if (('checkbox' === $widgetConfig['inputType'])
&& $widgetConfig['eval']['submitOnChange']
&& isset($GLOBALS['TL_DCA'][$defName]['subpalettes'])
&& \is_array($GLOBALS['TL_DCA'][$defName]['subpalettes'])
&& \array_key_exists($property->getName(), $GLOBALS['TL_DCA'][$defName]['subpalettes'])
) {
// We have to override the onclick, do not append to it as Contao adds it's own code here in
// Widget::getAttributesFromDca() which kills our sub palette handling!
$prepareAttributes['onclick'] = "Backend.autoSubmit('" . $defName . "');";
}
return $prepareAttributes;
} | [
"private",
"function",
"prepareWidgetAttributes",
"(",
"ModelInterface",
"$",
"model",
",",
"PropertyInterface",
"$",
"property",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"getEnvironment",
"(",
")",
";",
"$",
"defName",
"=",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"propExtra",
"=",
"$",
"property",
"->",
"getExtra",
"(",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"valueToWidget",
"(",
"$",
"model",
",",
"$",
"property",
")",
";",
"$",
"propExtra",
"[",
"'required'",
"]",
"=",
"(",
"''",
"===",
"$",
"value",
")",
"&&",
"!",
"empty",
"(",
"$",
"propExtra",
"[",
"'mandatory'",
"]",
")",
";",
"$",
"widgetConfig",
"=",
"[",
"'inputType'",
"=>",
"$",
"property",
"->",
"getWidgetType",
"(",
")",
",",
"'label'",
"=>",
"[",
"$",
"property",
"->",
"getLabel",
"(",
")",
",",
"$",
"property",
"->",
"getDescription",
"(",
")",
"]",
",",
"'options'",
"=>",
"$",
"this",
"->",
"getOptionsForWidget",
"(",
"$",
"property",
",",
"$",
"model",
")",
",",
"'eval'",
"=>",
"$",
"propExtra",
",",
"// 'foreignKey' => null",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"propExtra",
"[",
"'reference'",
"]",
")",
")",
"{",
"$",
"widgetConfig",
"[",
"'reference'",
"]",
"=",
"$",
"propExtra",
"[",
"'reference'",
"]",
";",
"}",
"$",
"event",
"=",
"new",
"GetAttributesFromDcaEvent",
"(",
"$",
"widgetConfig",
",",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"value",
",",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"defName",
",",
"new",
"DcCompat",
"(",
"$",
"environment",
",",
"$",
"model",
",",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"environment",
"->",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"WIDGET_GET_ATTRIBUTES_FROM_DCA",
",",
"$",
"event",
")",
";",
"$",
"prepareAttributes",
"=",
"$",
"event",
"->",
"getResult",
"(",
")",
";",
"if",
"(",
"(",
"'checkbox'",
"===",
"$",
"widgetConfig",
"[",
"'inputType'",
"]",
")",
"&&",
"$",
"widgetConfig",
"[",
"'eval'",
"]",
"[",
"'submitOnChange'",
"]",
"&&",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"defName",
"]",
"[",
"'subpalettes'",
"]",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"defName",
"]",
"[",
"'subpalettes'",
"]",
")",
"&&",
"\\",
"array_key_exists",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"defName",
"]",
"[",
"'subpalettes'",
"]",
")",
")",
"{",
"// We have to override the onclick, do not append to it as Contao adds it's own code here in",
"// Widget::getAttributesFromDca() which kills our sub palette handling!",
"$",
"prepareAttributes",
"[",
"'onclick'",
"]",
"=",
"\"Backend.autoSubmit('\"",
".",
"$",
"defName",
".",
"\"');\"",
";",
"}",
"return",
"$",
"prepareAttributes",
";",
"}"
]
| Prepare the attributes for the widget.
@param ModelInterface $model The model.
@param PropertyInterface $property The property for the widget.
@return array
@SuppressWarnings(PHPMD.Superglobals) | [
"Prepare",
"the",
"attributes",
"for",
"the",
"widget",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php#L465-L515 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.__isset | public function __isset($strKey)
{
switch ($strKey) {
case 'subTemplate':
return isset($this->subTemplate);
case 'thumbnailHeight':
return isset($this->thumbnailHeight);
case 'thumbnailWidth':
return isset($this->thumbnailWidth);
case 'placeholderImage':
return isset($this->placeholderImage);
default:
return parent::__get($strKey);
}
} | php | public function __isset($strKey)
{
switch ($strKey) {
case 'subTemplate':
return isset($this->subTemplate);
case 'thumbnailHeight':
return isset($this->thumbnailHeight);
case 'thumbnailWidth':
return isset($this->thumbnailWidth);
case 'placeholderImage':
return isset($this->placeholderImage);
default:
return parent::__get($strKey);
}
} | [
"public",
"function",
"__isset",
"(",
"$",
"strKey",
")",
"{",
"switch",
"(",
"$",
"strKey",
")",
"{",
"case",
"'subTemplate'",
":",
"return",
"isset",
"(",
"$",
"this",
"->",
"subTemplate",
")",
";",
"case",
"'thumbnailHeight'",
":",
"return",
"isset",
"(",
"$",
"this",
"->",
"thumbnailHeight",
")",
";",
"case",
"'thumbnailWidth'",
":",
"return",
"isset",
"(",
"$",
"this",
"->",
"thumbnailWidth",
")",
";",
"case",
"'placeholderImage'",
":",
"return",
"isset",
"(",
"$",
"this",
"->",
"placeholderImage",
")",
";",
"default",
":",
"return",
"parent",
"::",
"__get",
"(",
"$",
"strKey",
")",
";",
"}",
"}"
]
| Check whether an object property exists
@param string $strKey The property name.
@return boolean True if the property exists | [
"Check",
"whether",
"an",
"object",
"property",
"exists"
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L200-L218 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.setUp | private function setUp()
{
// Load the fonts for the drag hint (see #4838)
$GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true;
$this->rootDir = \dirname(System::getContainer()->getParameter('kernel.root_dir'));
if (!$this->dataContainer || !$this->orderField) {
return;
}
$value = $this->dataContainer->getModel()->getProperty($this->orderField);
// support serialized values.
if (!\is_array($value)) {
$value = StringUtil::deserialize($value, true);
}
$this->orderId = $this->orderField . \str_replace($this->strField, '', $this->strId);
$this->orderFieldValue = (!empty($value) && \is_array($value)) ? \array_filter($value) : [];
} | php | private function setUp()
{
// Load the fonts for the drag hint (see #4838)
$GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true;
$this->rootDir = \dirname(System::getContainer()->getParameter('kernel.root_dir'));
if (!$this->dataContainer || !$this->orderField) {
return;
}
$value = $this->dataContainer->getModel()->getProperty($this->orderField);
// support serialized values.
if (!\is_array($value)) {
$value = StringUtil::deserialize($value, true);
}
$this->orderId = $this->orderField . \str_replace($this->strField, '', $this->strId);
$this->orderFieldValue = (!empty($value) && \is_array($value)) ? \array_filter($value) : [];
} | [
"private",
"function",
"setUp",
"(",
")",
"{",
"// Load the fonts for the drag hint (see #4838)",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
"'loadGoogleFonts'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"rootDir",
"=",
"\\",
"dirname",
"(",
"System",
"::",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'kernel.root_dir'",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"dataContainer",
"||",
"!",
"$",
"this",
"->",
"orderField",
")",
"{",
"return",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"dataContainer",
"->",
"getModel",
"(",
")",
"->",
"getProperty",
"(",
"$",
"this",
"->",
"orderField",
")",
";",
"// support serialized values.",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"orderId",
"=",
"$",
"this",
"->",
"orderField",
".",
"\\",
"str_replace",
"(",
"$",
"this",
"->",
"strField",
",",
"''",
",",
"$",
"this",
"->",
"strId",
")",
";",
"$",
"this",
"->",
"orderFieldValue",
"=",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"?",
"\\",
"array_filter",
"(",
"$",
"value",
")",
":",
"[",
"]",
";",
"}"
]
| Setup the file tree widget.
@return void
@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName) | [
"Setup",
"the",
"file",
"tree",
"widget",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L228-L248 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.renderList | private function renderList(array &$icons, Collection $collection = null, $followSubDirs = false)
{
if (!$collection) {
return;
}
foreach ($collection->getModels() as $model) {
// File system and database seem not in sync
if (!\file_exists($this->rootDir . '/' . $model->path)) {
continue;
}
if (('folder' === $model->type) && $followSubDirs) {
$this->renderList($icons, FilesModel::findByPid($model->uuid));
continue;
}
if (false !== ($icon = $this->renderIcon($model, $this->isGallery, $this->isDownloads))) {
$icons[\md5($model->uuid)] = ['uuid' => $model->uuid, 'image' => $icon];
}
}
} | php | private function renderList(array &$icons, Collection $collection = null, $followSubDirs = false)
{
if (!$collection) {
return;
}
foreach ($collection->getModels() as $model) {
// File system and database seem not in sync
if (!\file_exists($this->rootDir . '/' . $model->path)) {
continue;
}
if (('folder' === $model->type) && $followSubDirs) {
$this->renderList($icons, FilesModel::findByPid($model->uuid));
continue;
}
if (false !== ($icon = $this->renderIcon($model, $this->isGallery, $this->isDownloads))) {
$icons[\md5($model->uuid)] = ['uuid' => $model->uuid, 'image' => $icon];
}
}
} | [
"private",
"function",
"renderList",
"(",
"array",
"&",
"$",
"icons",
",",
"Collection",
"$",
"collection",
"=",
"null",
",",
"$",
"followSubDirs",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"collection",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"collection",
"->",
"getModels",
"(",
")",
"as",
"$",
"model",
")",
"{",
"// File system and database seem not in sync",
"if",
"(",
"!",
"\\",
"file_exists",
"(",
"$",
"this",
"->",
"rootDir",
".",
"'/'",
".",
"$",
"model",
"->",
"path",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"(",
"'folder'",
"===",
"$",
"model",
"->",
"type",
")",
"&&",
"$",
"followSubDirs",
")",
"{",
"$",
"this",
"->",
"renderList",
"(",
"$",
"icons",
",",
"FilesModel",
"::",
"findByPid",
"(",
"$",
"model",
"->",
"uuid",
")",
")",
";",
"continue",
";",
"}",
"if",
"(",
"false",
"!==",
"(",
"$",
"icon",
"=",
"$",
"this",
"->",
"renderIcon",
"(",
"$",
"model",
",",
"$",
"this",
"->",
"isGallery",
",",
"$",
"this",
"->",
"isDownloads",
")",
")",
")",
"{",
"$",
"icons",
"[",
"\\",
"md5",
"(",
"$",
"model",
"->",
"uuid",
")",
"]",
"=",
"[",
"'uuid'",
"=>",
"$",
"model",
"->",
"uuid",
",",
"'image'",
"=>",
"$",
"icon",
"]",
";",
"}",
"}",
"}"
]
| Render the file list.
@param array $icons The generated icons.
@param Collection|null $collection The files collection.
@param bool $followSubDirs If true subfolders get rendered.
@return void | [
"Render",
"the",
"file",
"list",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L284-L304 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.renderFileInfo | protected function renderFileInfo(File $file)
{
return \sprintf(
'%s <span class="tl_gray">(%s%s)</span>',
$file->path,
static::getReadableSize($file->size),
(($file->isGdImage || $file->isSvgImage) ? ', ' . $file->width . 'x' . $file->height . ' px' : '')
);
} | php | protected function renderFileInfo(File $file)
{
return \sprintf(
'%s <span class="tl_gray">(%s%s)</span>',
$file->path,
static::getReadableSize($file->size),
(($file->isGdImage || $file->isSvgImage) ? ', ' . $file->width . 'x' . $file->height . ' px' : '')
);
} | [
"protected",
"function",
"renderFileInfo",
"(",
"File",
"$",
"file",
")",
"{",
"return",
"\\",
"sprintf",
"(",
"'%s <span class=\"tl_gray\">(%s%s)</span>'",
",",
"$",
"file",
"->",
"path",
",",
"static",
"::",
"getReadableSize",
"(",
"$",
"file",
"->",
"size",
")",
",",
"(",
"(",
"$",
"file",
"->",
"isGdImage",
"||",
"$",
"file",
"->",
"isSvgImage",
")",
"?",
"', '",
".",
"$",
"file",
"->",
"width",
".",
"'x'",
".",
"$",
"file",
"->",
"height",
".",
"' px'",
":",
"''",
")",
")",
";",
"}"
]
| Render the file info.
@param File $file The file.
@return string | [
"Render",
"the",
"file",
"info",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L325-L333 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.renderIcon | protected function renderIcon($model, $imagesOnly = false, $downloads = false)
{
if ('folder' === $model->type) {
if ($imagesOnly || $downloads) {
return false;
}
return Image::getHtml('folderC.svg') . ' ' . $model->path;
}
$file = new File($model->path);
$info = $this->renderFileInfo($file);
if ($imagesOnly && !$file->isImage) {
return false;
}
if ($downloads) {
if ($this->isAllowedDownload($file->extension)) {
return Image::getHtml($file->icon) . ' ' . $info;
}
return false;
}
if (!$file->isImage) {
return Image::getHtml($file->icon) . ' ' . $info;
}
return $this->generateGalleryImage($model, $file, $info);
} | php | protected function renderIcon($model, $imagesOnly = false, $downloads = false)
{
if ('folder' === $model->type) {
if ($imagesOnly || $downloads) {
return false;
}
return Image::getHtml('folderC.svg') . ' ' . $model->path;
}
$file = new File($model->path);
$info = $this->renderFileInfo($file);
if ($imagesOnly && !$file->isImage) {
return false;
}
if ($downloads) {
if ($this->isAllowedDownload($file->extension)) {
return Image::getHtml($file->icon) . ' ' . $info;
}
return false;
}
if (!$file->isImage) {
return Image::getHtml($file->icon) . ' ' . $info;
}
return $this->generateGalleryImage($model, $file, $info);
} | [
"protected",
"function",
"renderIcon",
"(",
"$",
"model",
",",
"$",
"imagesOnly",
"=",
"false",
",",
"$",
"downloads",
"=",
"false",
")",
"{",
"if",
"(",
"'folder'",
"===",
"$",
"model",
"->",
"type",
")",
"{",
"if",
"(",
"$",
"imagesOnly",
"||",
"$",
"downloads",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Image",
"::",
"getHtml",
"(",
"'folderC.svg'",
")",
".",
"' '",
".",
"$",
"model",
"->",
"path",
";",
"}",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"model",
"->",
"path",
")",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"renderFileInfo",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"imagesOnly",
"&&",
"!",
"$",
"file",
"->",
"isImage",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"downloads",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAllowedDownload",
"(",
"$",
"file",
"->",
"extension",
")",
")",
"{",
"return",
"Image",
"::",
"getHtml",
"(",
"$",
"file",
"->",
"icon",
")",
".",
"' '",
".",
"$",
"info",
";",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"file",
"->",
"isImage",
")",
"{",
"return",
"Image",
"::",
"getHtml",
"(",
"$",
"file",
"->",
"icon",
")",
".",
"' '",
".",
"$",
"info",
";",
"}",
"return",
"$",
"this",
"->",
"generateGalleryImage",
"(",
"$",
"model",
",",
"$",
"file",
",",
"$",
"info",
")",
";",
"}"
]
| Render the image of a file.
@param FilesModel $model The file model.
@param bool $imagesOnly If true only images are rendered.
@param bool $downloads If true file extension has to be in the allowed downloads list.
@return false|string | [
"Render",
"the",
"image",
"of",
"a",
"file",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L344-L373 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.generateGalleryImage | private function generateGalleryImage($model, File $file, $info)
{
$image = $this->placeholderImage;
if ($file->isSvgImage
|| (($file->height <= Config::get('gdMaxImgHeight')) && ($file->width <= Config::get('gdMaxImgWidth')))
) {
$width = \min($file->width, $this->thumbnailWidth);
$height = \min($file->height, $this->thumbnailHeight);
$image = Image::get($model->path, $width, $height, 'center_center');
}
return Image::getHtml(
$image,
'',
'class="gimage removable" title="' . StringUtil::specialchars($info) . '"'
);
} | php | private function generateGalleryImage($model, File $file, $info)
{
$image = $this->placeholderImage;
if ($file->isSvgImage
|| (($file->height <= Config::get('gdMaxImgHeight')) && ($file->width <= Config::get('gdMaxImgWidth')))
) {
$width = \min($file->width, $this->thumbnailWidth);
$height = \min($file->height, $this->thumbnailHeight);
$image = Image::get($model->path, $width, $height, 'center_center');
}
return Image::getHtml(
$image,
'',
'class="gimage removable" title="' . StringUtil::specialchars($info) . '"'
);
} | [
"private",
"function",
"generateGalleryImage",
"(",
"$",
"model",
",",
"File",
"$",
"file",
",",
"$",
"info",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"placeholderImage",
";",
"if",
"(",
"$",
"file",
"->",
"isSvgImage",
"||",
"(",
"(",
"$",
"file",
"->",
"height",
"<=",
"Config",
"::",
"get",
"(",
"'gdMaxImgHeight'",
")",
")",
"&&",
"(",
"$",
"file",
"->",
"width",
"<=",
"Config",
"::",
"get",
"(",
"'gdMaxImgWidth'",
")",
")",
")",
")",
"{",
"$",
"width",
"=",
"\\",
"min",
"(",
"$",
"file",
"->",
"width",
",",
"$",
"this",
"->",
"thumbnailWidth",
")",
";",
"$",
"height",
"=",
"\\",
"min",
"(",
"$",
"file",
"->",
"height",
",",
"$",
"this",
"->",
"thumbnailHeight",
")",
";",
"$",
"image",
"=",
"Image",
"::",
"get",
"(",
"$",
"model",
"->",
"path",
",",
"$",
"width",
",",
"$",
"height",
",",
"'center_center'",
")",
";",
"}",
"return",
"Image",
"::",
"getHtml",
"(",
"$",
"image",
",",
"''",
",",
"'class=\"gimage removable\" title=\"'",
".",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"info",
")",
".",
"'\"'",
")",
";",
"}"
]
| Generate a image for use as gallery listing.
@param FilesModel $model The file model in use.
@param File $file The image file being rendered.
@param string $info The image information.
@return string | [
"Generate",
"a",
"image",
"for",
"use",
"as",
"gallery",
"listing",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L384-L401 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.applySorting | private function applySorting($icons)
{
if (('' !== $this->orderField) && \is_array($this->orderFieldValue)) {
$ordered = [];
foreach ($this->orderFieldValue as $uuid) {
$iconKey = \md5($uuid);
if (isset($icons[$iconKey])) {
$ordered[$iconKey] = $icons[$iconKey];
unset($icons[$iconKey]);
}
}
foreach ($icons as $uuid => $icon) {
$ordered[\md5($uuid)] = $icon;
}
$icons = $ordered;
}
return $icons;
} | php | private function applySorting($icons)
{
if (('' !== $this->orderField) && \is_array($this->orderFieldValue)) {
$ordered = [];
foreach ($this->orderFieldValue as $uuid) {
$iconKey = \md5($uuid);
if (isset($icons[$iconKey])) {
$ordered[$iconKey] = $icons[$iconKey];
unset($icons[$iconKey]);
}
}
foreach ($icons as $uuid => $icon) {
$ordered[\md5($uuid)] = $icon;
}
$icons = $ordered;
}
return $icons;
} | [
"private",
"function",
"applySorting",
"(",
"$",
"icons",
")",
"{",
"if",
"(",
"(",
"''",
"!==",
"$",
"this",
"->",
"orderField",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"orderFieldValue",
")",
")",
"{",
"$",
"ordered",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"orderFieldValue",
"as",
"$",
"uuid",
")",
"{",
"$",
"iconKey",
"=",
"\\",
"md5",
"(",
"$",
"uuid",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"icons",
"[",
"$",
"iconKey",
"]",
")",
")",
"{",
"$",
"ordered",
"[",
"$",
"iconKey",
"]",
"=",
"$",
"icons",
"[",
"$",
"iconKey",
"]",
";",
"unset",
"(",
"$",
"icons",
"[",
"$",
"iconKey",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"icons",
"as",
"$",
"uuid",
"=>",
"$",
"icon",
")",
"{",
"$",
"ordered",
"[",
"\\",
"md5",
"(",
"$",
"uuid",
")",
"]",
"=",
"$",
"icon",
";",
"}",
"$",
"icons",
"=",
"$",
"ordered",
";",
"}",
"return",
"$",
"icons",
";",
"}"
]
| Apply the sorting to the icons.
@param array $icons The file icons.
@return array | [
"Apply",
"the",
"sorting",
"to",
"the",
"icons",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L410-L431 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/Widget/FileTree.php | FileTree.generateLink | private function generateLink()
{
$extras = ['fieldType' => $this->fieldType];
if ($this->files) {
$extras['files'] = (bool) $this->files;
}
if ($this->filesOnly) {
$extras['filesOnly'] = (bool) $this->filesOnly;
}
if ($this->path) {
$extras['path'] = (string) $this->path;
}
if ($this->extensions) {
$extras['extensions'] = (string) $this->extensions;
}
return System::getContainer()->get('contao.picker.builder')->getUrl('file', $extras);
} | php | private function generateLink()
{
$extras = ['fieldType' => $this->fieldType];
if ($this->files) {
$extras['files'] = (bool) $this->files;
}
if ($this->filesOnly) {
$extras['filesOnly'] = (bool) $this->filesOnly;
}
if ($this->path) {
$extras['path'] = (string) $this->path;
}
if ($this->extensions) {
$extras['extensions'] = (string) $this->extensions;
}
return System::getContainer()->get('contao.picker.builder')->getUrl('file', $extras);
} | [
"private",
"function",
"generateLink",
"(",
")",
"{",
"$",
"extras",
"=",
"[",
"'fieldType'",
"=>",
"$",
"this",
"->",
"fieldType",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"files",
")",
"{",
"$",
"extras",
"[",
"'files'",
"]",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"files",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"filesOnly",
")",
"{",
"$",
"extras",
"[",
"'filesOnly'",
"]",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"filesOnly",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"path",
")",
"{",
"$",
"extras",
"[",
"'path'",
"]",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"path",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"extensions",
")",
"{",
"$",
"extras",
"[",
"'extensions'",
"]",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"extensions",
";",
"}",
"return",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'contao.picker.builder'",
")",
"->",
"getUrl",
"(",
"'file'",
",",
"$",
"extras",
")",
";",
"}"
]
| Generate the adjust selection link.
@return string | [
"Generate",
"the",
"adjust",
"selection",
"link",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/Widget/FileTree.php#L438-L459 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ContaoBackendViewTemplate.php | ContaoBackendViewTemplate.getBackButton | public function getBackButton()
{
$container = $GLOBALS['container'];
$dataContainer = $container['dc-general.data-definition-container'];
$dataDefinition = $dataContainer->getDefinition($this->table);
$environment = new DefaultEnvironment();
$environment->setDataDefinition($dataDefinition);
$environment->setTranslator($container['translator']);
$environment->setEventDispatcher($container['event-dispatcher']);
$environment->setInputProvider(new InputProvider());
$environment->setClipboard(new Clipboard());
$renderer = new GlobalButtonRenderer($environment);
return $renderer->render();
} | php | public function getBackButton()
{
$container = $GLOBALS['container'];
$dataContainer = $container['dc-general.data-definition-container'];
$dataDefinition = $dataContainer->getDefinition($this->table);
$environment = new DefaultEnvironment();
$environment->setDataDefinition($dataDefinition);
$environment->setTranslator($container['translator']);
$environment->setEventDispatcher($container['event-dispatcher']);
$environment->setInputProvider(new InputProvider());
$environment->setClipboard(new Clipboard());
$renderer = new GlobalButtonRenderer($environment);
return $renderer->render();
} | [
"public",
"function",
"getBackButton",
"(",
")",
"{",
"$",
"container",
"=",
"$",
"GLOBALS",
"[",
"'container'",
"]",
";",
"$",
"dataContainer",
"=",
"$",
"container",
"[",
"'dc-general.data-definition-container'",
"]",
";",
"$",
"dataDefinition",
"=",
"$",
"dataContainer",
"->",
"getDefinition",
"(",
"$",
"this",
"->",
"table",
")",
";",
"$",
"environment",
"=",
"new",
"DefaultEnvironment",
"(",
")",
";",
"$",
"environment",
"->",
"setDataDefinition",
"(",
"$",
"dataDefinition",
")",
";",
"$",
"environment",
"->",
"setTranslator",
"(",
"$",
"container",
"[",
"'translator'",
"]",
")",
";",
"$",
"environment",
"->",
"setEventDispatcher",
"(",
"$",
"container",
"[",
"'event-dispatcher'",
"]",
")",
";",
"$",
"environment",
"->",
"setInputProvider",
"(",
"new",
"InputProvider",
"(",
")",
")",
";",
"$",
"environment",
"->",
"setClipboard",
"(",
"new",
"Clipboard",
"(",
")",
")",
";",
"$",
"renderer",
"=",
"new",
"GlobalButtonRenderer",
"(",
"$",
"environment",
")",
";",
"return",
"$",
"renderer",
"->",
"render",
"(",
")",
";",
"}"
]
| Get the back button.
@return string
@SuppressWarnings(PHPMD.Superglobals) | [
"Get",
"the",
"back",
"button",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ContaoBackendViewTemplate.php#L127-L143 | train |
contao-community-alliance/dc-general | src/DataDefinition/Builder/AbstractEventDrivenDataDefinitionBuilder.php | AbstractEventDrivenDataDefinitionBuilder.process | public static function process(BuildDataDefinitionEvent $event, $eventName, $dispatcher)
{
$builder = new static();
$builder->eventName = $eventName;
$builder->dispatcher = $dispatcher;
/** @var DataDefinitionBuilderInterface $builder */
$builder->build($event->getContainer(), $event);
} | php | public static function process(BuildDataDefinitionEvent $event, $eventName, $dispatcher)
{
$builder = new static();
$builder->eventName = $eventName;
$builder->dispatcher = $dispatcher;
/** @var DataDefinitionBuilderInterface $builder */
$builder->build($event->getContainer(), $event);
} | [
"public",
"static",
"function",
"process",
"(",
"BuildDataDefinitionEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"$",
"dispatcher",
")",
"{",
"$",
"builder",
"=",
"new",
"static",
"(",
")",
";",
"$",
"builder",
"->",
"eventName",
"=",
"$",
"eventName",
";",
"$",
"builder",
"->",
"dispatcher",
"=",
"$",
"dispatcher",
";",
"/** @var DataDefinitionBuilderInterface $builder */",
"$",
"builder",
"->",
"build",
"(",
"$",
"event",
"->",
"getContainer",
"(",
")",
",",
"$",
"event",
")",
";",
"}"
]
| Creates an instance of itself and processes the event.
The attached data definition {@link ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface}
will be populated with the information from the builder's data source.
@param BuildDataDefinitionEvent $event The event to process.
@param string $eventName The name of the event to process.
@param EventDispatcherInterface $dispatcher The event dispatcher calling us.
@return void | [
"Creates",
"an",
"instance",
"of",
"itself",
"and",
"processes",
"the",
"event",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Builder/AbstractEventDrivenDataDefinitionBuilder.php#L88-L96 | train |
contao-community-alliance/dc-general | src/Contao/Callback/ModelOperationButtonCallbackListener.php | ModelOperationButtonCallbackListener.buildHref | protected function buildHref(CommandInterface $command)
{
$arrParameters = (array) $command->getParameters();
$strHref = '';
foreach ($arrParameters as $key => $value) {
$strHref .= \sprintf('&%s=%s', $key, $value);
}
return $strHref;
} | php | protected function buildHref(CommandInterface $command)
{
$arrParameters = (array) $command->getParameters();
$strHref = '';
foreach ($arrParameters as $key => $value) {
$strHref .= \sprintf('&%s=%s', $key, $value);
}
return $strHref;
} | [
"protected",
"function",
"buildHref",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"$",
"arrParameters",
"=",
"(",
"array",
")",
"$",
"command",
"->",
"getParameters",
"(",
")",
";",
"$",
"strHref",
"=",
"''",
";",
"foreach",
"(",
"$",
"arrParameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"strHref",
".=",
"\\",
"sprintf",
"(",
"'&%s=%s'",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"strHref",
";",
"}"
]
| Build reduced href required by legacy callbacks.
@param CommandInterface $command The command for which the href shall get built.
@return string | [
"Build",
"reduced",
"href",
"required",
"by",
"legacy",
"callbacks",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Callback/ModelOperationButtonCallbackListener.php#L123-L133 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php | FilterBuilderWithChildren.first | public function first()
{
$this->index = \count($this->children) ? 0 : (-1);
if ($this->index === -1) {
return null;
}
return $this->current();
} | php | public function first()
{
$this->index = \count($this->children) ? 0 : (-1);
if ($this->index === -1) {
return null;
}
return $this->current();
} | [
"public",
"function",
"first",
"(",
")",
"{",
"$",
"this",
"->",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"children",
")",
"?",
"0",
":",
"(",
"-",
"1",
")",
";",
"if",
"(",
"$",
"this",
"->",
"index",
"===",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"current",
"(",
")",
";",
"}"
]
| Rewind the Iterator to the first element and return it.
@return BaseFilterBuilder | [
"Rewind",
"the",
"Iterator",
"to",
"the",
"first",
"element",
"and",
"return",
"it",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php#L162-L171 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php | FilterBuilderWithChildren.indexOf | public function indexOf($filter)
{
foreach ($this->children as $i => $child) {
if ($child === $filter) {
return $i;
}
}
return -1;
} | php | public function indexOf($filter)
{
foreach ($this->children as $i => $child) {
if ($child === $filter) {
return $i;
}
}
return -1;
} | [
"public",
"function",
"indexOf",
"(",
"$",
"filter",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"i",
"=>",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"===",
"$",
"filter",
")",
"{",
"return",
"$",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
]
| Get the position index of a given filter builder in this instance.
@param BaseFilterBuilder $filter The filter builder to search.
@return int | [
"Get",
"the",
"position",
"index",
"of",
"a",
"given",
"filter",
"builder",
"in",
"this",
"instance",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php#L247-L256 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php | FilterBuilderWithChildren.add | public function add($filter)
{
$index = $this->indexOf($filter);
if ($index === -1) {
$this->children[] = $filter;
$filter->setBuilder($this->builder)->setParent($this);
}
return $this;
} | php | public function add($filter)
{
$index = $this->indexOf($filter);
if ($index === -1) {
$this->children[] = $filter;
$filter->setBuilder($this->builder)->setParent($this);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"filter",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"indexOf",
"(",
"$",
"filter",
")",
";",
"if",
"(",
"$",
"index",
"===",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"children",
"[",
"]",
"=",
"$",
"filter",
";",
"$",
"filter",
"->",
"setBuilder",
"(",
"$",
"this",
"->",
"builder",
")",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a given filter builder to this instance.
@param BaseFilterBuilder $filter The filter builder to add.
@return FilterBuilderWithChildren The current builder. | [
"Add",
"a",
"given",
"filter",
"builder",
"to",
"this",
"instance",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php#L265-L275 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php | FilterBuilderWithChildren.remove | public function remove($filter)
{
$index = $this->indexOf($filter);
if ($index > -1) {
$this->offsetUnset($index);
}
return $this;
} | php | public function remove($filter)
{
$index = $this->indexOf($filter);
if ($index > -1) {
$this->offsetUnset($index);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"filter",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"indexOf",
"(",
"$",
"filter",
")",
";",
"if",
"(",
"$",
"index",
">",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"offsetUnset",
"(",
"$",
"index",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Remove a given filter builder from this instance.
@param BaseFilterBuilder $filter The filter builder to remove.
@return FilterBuilderWithChildren The current builder. | [
"Remove",
"a",
"given",
"filter",
"builder",
"from",
"this",
"instance",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/FilterBuilderWithChildren.php#L284-L293 | train |
contao-community-alliance/dc-general | src/Panel/AbstractElement.php | AbstractElement.getOtherConfig | protected function getOtherConfig()
{
if (!isset($this->objOtherConfig)) {
$this->objOtherConfig = $this
->getEnvironment()
->getBaseConfigRegistry()
->getBaseConfig();
$this
->getPanel()
->getContainer()
->initialize($this->objOtherConfig, $this);
}
return $this->objOtherConfig;
} | php | protected function getOtherConfig()
{
if (!isset($this->objOtherConfig)) {
$this->objOtherConfig = $this
->getEnvironment()
->getBaseConfigRegistry()
->getBaseConfig();
$this
->getPanel()
->getContainer()
->initialize($this->objOtherConfig, $this);
}
return $this->objOtherConfig;
} | [
"protected",
"function",
"getOtherConfig",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"objOtherConfig",
")",
")",
"{",
"$",
"this",
"->",
"objOtherConfig",
"=",
"$",
"this",
"->",
"getEnvironment",
"(",
")",
"->",
"getBaseConfigRegistry",
"(",
")",
"->",
"getBaseConfig",
"(",
")",
";",
"$",
"this",
"->",
"getPanel",
"(",
")",
"->",
"getContainer",
"(",
")",
"->",
"initialize",
"(",
"$",
"this",
"->",
"objOtherConfig",
",",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"objOtherConfig",
";",
"}"
]
| Let all other elements initialize and apply themselves to this config.
@return ConfigInterface | [
"Let",
"all",
"other",
"elements",
"initialize",
"and",
"apply",
"themselves",
"to",
"this",
"config",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Panel/AbstractElement.php#L104-L119 | train |
contao-community-alliance/dc-general | src/Data/DefaultDataProviderDBalUtils.php | DefaultDataProviderDBalUtils.addField | public static function addField(ConfigInterface $config, $idProperty, QueryBuilder $queryBuilder)
{
if ($config->getIdOnly()) {
$queryBuilder->select($idProperty);
return;
}
if (null !== $config->getFields()) {
$connection = $queryBuilder->getConnection();
$fields = implode(
', ',
array_map(
function ($field) use ($connection) {
return $connection->quoteIdentifier($field);
},
$config->getFields()
)
);
if (false !== stripos($fields, 'DISTINCT') || \in_array($idProperty, $config->getFields(), true)) {
$queryBuilder->select($fields);
return;
}
$queryBuilder->select($idProperty . ', ' . $fields);
return;
}
$queryBuilder->select('*');
} | php | public static function addField(ConfigInterface $config, $idProperty, QueryBuilder $queryBuilder)
{
if ($config->getIdOnly()) {
$queryBuilder->select($idProperty);
return;
}
if (null !== $config->getFields()) {
$connection = $queryBuilder->getConnection();
$fields = implode(
', ',
array_map(
function ($field) use ($connection) {
return $connection->quoteIdentifier($field);
},
$config->getFields()
)
);
if (false !== stripos($fields, 'DISTINCT') || \in_array($idProperty, $config->getFields(), true)) {
$queryBuilder->select($fields);
return;
}
$queryBuilder->select($idProperty . ', ' . $fields);
return;
}
$queryBuilder->select('*');
} | [
"public",
"static",
"function",
"addField",
"(",
"ConfigInterface",
"$",
"config",
",",
"$",
"idProperty",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"getIdOnly",
"(",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"select",
"(",
"$",
"idProperty",
")",
";",
"return",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"config",
"->",
"getFields",
"(",
")",
")",
"{",
"$",
"connection",
"=",
"$",
"queryBuilder",
"->",
"getConnection",
"(",
")",
";",
"$",
"fields",
"=",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"function",
"(",
"$",
"field",
")",
"use",
"(",
"$",
"connection",
")",
"{",
"return",
"$",
"connection",
"->",
"quoteIdentifier",
"(",
"$",
"field",
")",
";",
"}",
",",
"$",
"config",
"->",
"getFields",
"(",
")",
")",
")",
";",
"if",
"(",
"false",
"!==",
"stripos",
"(",
"$",
"fields",
",",
"'DISTINCT'",
")",
"||",
"\\",
"in_array",
"(",
"$",
"idProperty",
",",
"$",
"config",
"->",
"getFields",
"(",
")",
",",
"true",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"select",
"(",
"$",
"fields",
")",
";",
"return",
";",
"}",
"$",
"queryBuilder",
"->",
"select",
"(",
"$",
"idProperty",
".",
"', '",
".",
"$",
"fields",
")",
";",
"return",
";",
"}",
"$",
"queryBuilder",
"->",
"select",
"(",
"'*'",
")",
";",
"}"
]
| Add the field list.
Returns all values from $objConfig->getFields() as comma separated list.
@param ConfigInterface $config The configuration to use.
@param string $idProperty The name of the id property.
@param QueryBuilder $queryBuilder The query builder.
@return void | [
"Add",
"the",
"field",
"list",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderDBalUtils.php#L42-L71 | train |
contao-community-alliance/dc-general | src/Data/DefaultDataProviderDBalUtils.php | DefaultDataProviderDBalUtils.addSorting | public static function addSorting(ConfigInterface $config, QueryBuilder $queryBuilder)
{
if (empty($config->getSorting()) || !is_array($config->getSorting())) {
return;
}
foreach ($config->getSorting() as $sort => $order) {
// array could be a simple field list or list of field => direction combinations.
if (!empty($order)) {
$order = strtoupper($order);
if (!in_array($order, [DCGE::MODEL_SORTING_ASC, DCGE::MODEL_SORTING_DESC])) {
$sort = $order;
$order = DCGE::MODEL_SORTING_ASC;
}
} else {
$order = DCGE::MODEL_SORTING_ASC;
}
$queryBuilder->addOrderBy($sort, $order);
}
} | php | public static function addSorting(ConfigInterface $config, QueryBuilder $queryBuilder)
{
if (empty($config->getSorting()) || !is_array($config->getSorting())) {
return;
}
foreach ($config->getSorting() as $sort => $order) {
// array could be a simple field list or list of field => direction combinations.
if (!empty($order)) {
$order = strtoupper($order);
if (!in_array($order, [DCGE::MODEL_SORTING_ASC, DCGE::MODEL_SORTING_DESC])) {
$sort = $order;
$order = DCGE::MODEL_SORTING_ASC;
}
} else {
$order = DCGE::MODEL_SORTING_ASC;
}
$queryBuilder->addOrderBy($sort, $order);
}
} | [
"public",
"static",
"function",
"addSorting",
"(",
"ConfigInterface",
"$",
"config",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
"->",
"getSorting",
"(",
")",
")",
"||",
"!",
"is_array",
"(",
"$",
"config",
"->",
"getSorting",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"config",
"->",
"getSorting",
"(",
")",
"as",
"$",
"sort",
"=>",
"$",
"order",
")",
"{",
"// array could be a simple field list or list of field => direction combinations.",
"if",
"(",
"!",
"empty",
"(",
"$",
"order",
")",
")",
"{",
"$",
"order",
"=",
"strtoupper",
"(",
"$",
"order",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"order",
",",
"[",
"DCGE",
"::",
"MODEL_SORTING_ASC",
",",
"DCGE",
"::",
"MODEL_SORTING_DESC",
"]",
")",
")",
"{",
"$",
"sort",
"=",
"$",
"order",
";",
"$",
"order",
"=",
"DCGE",
"::",
"MODEL_SORTING_ASC",
";",
"}",
"}",
"else",
"{",
"$",
"order",
"=",
"DCGE",
"::",
"MODEL_SORTING_ASC",
";",
"}",
"$",
"queryBuilder",
"->",
"addOrderBy",
"(",
"$",
"sort",
",",
"$",
"order",
")",
";",
"}",
"}"
]
| Add the order by part of a query.
@param ConfigInterface $config The configuration to use.
@param QueryBuilder $queryBuilder The query builder.
@return void | [
"Add",
"the",
"order",
"by",
"part",
"of",
"a",
"query",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderDBalUtils.php#L96-L116 | train |
contao-community-alliance/dc-general | src/Data/DefaultDataProviderDBalUtils.php | DefaultDataProviderDBalUtils.determineFilterComparing | private static function determineFilterComparing(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['=', '>', '>=', '<', '<=', '<>'])) {
return null;
}
return static::filterComparing($filter, $queryBuilder);
} | php | private static function determineFilterComparing(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['=', '>', '>=', '<', '<=', '<>'])) {
return null;
}
return static::filterComparing($filter, $queryBuilder);
} | [
"private",
"static",
"function",
"determineFilterComparing",
"(",
"array",
"$",
"filter",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"filter",
"[",
"'operation'",
"]",
",",
"[",
"'='",
",",
"'>'",
",",
"'>='",
",",
"'<'",
",",
"'<='",
",",
"'<>'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"static",
"::",
"filterComparing",
"(",
"$",
"filter",
",",
"$",
"queryBuilder",
")",
";",
"}"
]
| Determine sql filter for comparing.
@param array $filter The query filter.
@param QueryBuilder $queryBuilder The query builder.
@return string|null | [
"Determine",
"sql",
"filter",
"for",
"comparing",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderDBalUtils.php#L231-L238 | train |
contao-community-alliance/dc-general | src/Data/DefaultDataProviderDBalUtils.php | DefaultDataProviderDBalUtils.determineFilterInOrNotInList | private static function determineFilterInOrNotInList(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['IN', 'NOT IN'])) {
return null;
}
return static::filterInOrNotInList($filter, $queryBuilder);
} | php | private static function determineFilterInOrNotInList(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['IN', 'NOT IN'])) {
return null;
}
return static::filterInOrNotInList($filter, $queryBuilder);
} | [
"private",
"static",
"function",
"determineFilterInOrNotInList",
"(",
"array",
"$",
"filter",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"filter",
"[",
"'operation'",
"]",
",",
"[",
"'IN'",
",",
"'NOT IN'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"static",
"::",
"filterInOrNotInList",
"(",
"$",
"filter",
",",
"$",
"queryBuilder",
")",
";",
"}"
]
| Determine sql filter for in or not in list.
@param array $filter The query filter.
@param QueryBuilder $queryBuilder The query builder.
@return string|null | [
"Determine",
"sql",
"filter",
"for",
"in",
"or",
"not",
"in",
"list",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderDBalUtils.php#L248-L255 | train |
contao-community-alliance/dc-general | src/Data/DefaultDataProviderDBalUtils.php | DefaultDataProviderDBalUtils.determineFilterLikeOrNotLike | private static function determineFilterLikeOrNotLike(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['LIKE', 'NOT LIKE'])) {
return null;
}
return static::filterLikeOrNotLike($filter, $queryBuilder);
} | php | private static function determineFilterLikeOrNotLike(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['LIKE', 'NOT LIKE'])) {
return null;
}
return static::filterLikeOrNotLike($filter, $queryBuilder);
} | [
"private",
"static",
"function",
"determineFilterLikeOrNotLike",
"(",
"array",
"$",
"filter",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"filter",
"[",
"'operation'",
"]",
",",
"[",
"'LIKE'",
",",
"'NOT LIKE'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"static",
"::",
"filterLikeOrNotLike",
"(",
"$",
"filter",
",",
"$",
"queryBuilder",
")",
";",
"}"
]
| Determine sql filter for like or not like.
@param array $filter The query filter.
@param QueryBuilder $queryBuilder The query builder.
@return string|null | [
"Determine",
"sql",
"filter",
"for",
"like",
"or",
"not",
"like",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderDBalUtils.php#L265-L272 | train |
contao-community-alliance/dc-general | src/Data/DefaultDataProviderDBalUtils.php | DefaultDataProviderDBalUtils.determineFilterIsNullOrIsNotNull | private static function determineFilterIsNullOrIsNotNull(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['IS NULL', 'IS NOT NULL'])) {
return null;
}
return static::filterIsNullOrIsNotNull($filter, $queryBuilder);
} | php | private static function determineFilterIsNullOrIsNotNull(array $filter, QueryBuilder $queryBuilder)
{
if (!\in_array($filter['operation'], ['IS NULL', 'IS NOT NULL'])) {
return null;
}
return static::filterIsNullOrIsNotNull($filter, $queryBuilder);
} | [
"private",
"static",
"function",
"determineFilterIsNullOrIsNotNull",
"(",
"array",
"$",
"filter",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"filter",
"[",
"'operation'",
"]",
",",
"[",
"'IS NULL'",
",",
"'IS NOT NULL'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"static",
"::",
"filterIsNullOrIsNotNull",
"(",
"$",
"filter",
",",
"$",
"queryBuilder",
")",
";",
"}"
]
| Determine sql filter for is null or is not null.
@param array $filter The query filter.
@param QueryBuilder $queryBuilder The query builder.
@return string|null | [
"Determine",
"sql",
"filter",
"for",
"is",
"null",
"or",
"is",
"not",
"null",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Data/DefaultDataProviderDBalUtils.php#L282-L289 | train |
contao-community-alliance/dc-general | src/Factory/DcGeneralFactory.php | DcGeneralFactory.deriveEmptyFromEnvironment | public static function deriveEmptyFromEnvironment(EnvironmentInterface $environment)
{
$factory = new DcGeneralFactory();
$factory->setEventDispatcher($environment->getEventDispatcher());
$factory->setTranslator($environment->getTranslator());
$factory->setEnvironmentClassName(\get_class($environment));
$factory->setContainerClassName(\get_class($environment->getDataDefinition()));
return $factory;
} | php | public static function deriveEmptyFromEnvironment(EnvironmentInterface $environment)
{
$factory = new DcGeneralFactory();
$factory->setEventDispatcher($environment->getEventDispatcher());
$factory->setTranslator($environment->getTranslator());
$factory->setEnvironmentClassName(\get_class($environment));
$factory->setContainerClassName(\get_class($environment->getDataDefinition()));
return $factory;
} | [
"public",
"static",
"function",
"deriveEmptyFromEnvironment",
"(",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"factory",
"=",
"new",
"DcGeneralFactory",
"(",
")",
";",
"$",
"factory",
"->",
"setEventDispatcher",
"(",
"$",
"environment",
"->",
"getEventDispatcher",
"(",
")",
")",
";",
"$",
"factory",
"->",
"setTranslator",
"(",
"$",
"environment",
"->",
"getTranslator",
"(",
")",
")",
";",
"$",
"factory",
"->",
"setEnvironmentClassName",
"(",
"\\",
"get_class",
"(",
"$",
"environment",
")",
")",
";",
"$",
"factory",
"->",
"setContainerClassName",
"(",
"\\",
"get_class",
"(",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
")",
")",
";",
"return",
"$",
"factory",
";",
"}"
]
| Create a new factory with basic settings from the environment.
This factory can be used to create a new Container, Environment, DcGeneral with the same base settings as the
given environment.
@param EnvironmentInterface $environment The environment to use as base.
@return DcGeneralFactory | [
"Create",
"a",
"new",
"factory",
"with",
"basic",
"settings",
"from",
"the",
"environment",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Factory/DcGeneralFactory.php#L54-L62 | train |
contao-community-alliance/dc-general | src/Factory/DcGeneralFactory.php | DcGeneralFactory.deriveFromEnvironment | public static function deriveFromEnvironment(EnvironmentInterface $environment)
{
$factory = static::deriveEmptyFromEnvironment($environment);
$factory->setContainerName($environment->getDataDefinition()->getName());
return $factory;
} | php | public static function deriveFromEnvironment(EnvironmentInterface $environment)
{
$factory = static::deriveEmptyFromEnvironment($environment);
$factory->setContainerName($environment->getDataDefinition()->getName());
return $factory;
} | [
"public",
"static",
"function",
"deriveFromEnvironment",
"(",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"factory",
"=",
"static",
"::",
"deriveEmptyFromEnvironment",
"(",
"$",
"environment",
")",
";",
"$",
"factory",
"->",
"setContainerName",
"(",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"return",
"$",
"factory",
";",
"}"
]
| Create a new factory with basic settings and same container name as the given environment is build for.
This factory can be used to create a second Container, Environment, DcGeneral for the same container.
@param EnvironmentInterface $environment The environment to use as base.
@return DcGeneralFactory | [
"Create",
"a",
"new",
"factory",
"with",
"basic",
"settings",
"and",
"same",
"container",
"name",
"as",
"the",
"given",
"environment",
"is",
"build",
"for",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Factory/DcGeneralFactory.php#L73-L78 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php | BaseFilterBuilder.setParent | public function setParent(FilterBuilderWithChildren $parent)
{
if ($this->parent && $this->parent !== $parent) {
$this->parent->remove($this);
}
$this->parent = $parent;
$this->parent->add($this);
return $this;
} | php | public function setParent(FilterBuilderWithChildren $parent)
{
if ($this->parent && $this->parent !== $parent) {
$this->parent->remove($this);
}
$this->parent = $parent;
$this->parent->add($this);
return $this;
} | [
"public",
"function",
"setParent",
"(",
"FilterBuilderWithChildren",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"&&",
"$",
"this",
"->",
"parent",
"!==",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"parent",
"->",
"remove",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"parent",
"=",
"$",
"parent",
";",
"$",
"this",
"->",
"parent",
"->",
"add",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the parent and return self.
@param FilterBuilderWithChildren $parent The new parent.
@return FilterBuilderWithChildren | [
"Set",
"the",
"parent",
"and",
"return",
"self",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php#L78-L88 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php | BaseFilterBuilder.andRemotePropertyEquals | public function andRemotePropertyEquals($property, $remoteProperty, $remoteIsValue = false)
{
$this->getBuilder()->checkNotRoot();
return $this->andEncapsulate(
new PropertyEqualsFilterBuilder($property, $remoteProperty, true, !$remoteIsValue)
);
} | php | public function andRemotePropertyEquals($property, $remoteProperty, $remoteIsValue = false)
{
$this->getBuilder()->checkNotRoot();
return $this->andEncapsulate(
new PropertyEqualsFilterBuilder($property, $remoteProperty, true, !$remoteIsValue)
);
} | [
"public",
"function",
"andRemotePropertyEquals",
"(",
"$",
"property",
",",
"$",
"remoteProperty",
",",
"$",
"remoteIsValue",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"checkNotRoot",
"(",
")",
";",
"return",
"$",
"this",
"->",
"andEncapsulate",
"(",
"new",
"PropertyEqualsFilterBuilder",
"(",
"$",
"property",
",",
"$",
"remoteProperty",
",",
"true",
",",
"!",
"$",
"remoteIsValue",
")",
")",
";",
"}"
]
| Ensure that the given property also equals the given remote property.
@param string $property The name of the property.
@param string $remoteProperty The name of the remote property.
@param bool $remoteIsValue True if the passed remote value is a value, false if it is a property name.
@return PropertyEqualsFilterBuilder The newly created filter. | [
"Ensure",
"that",
"the",
"given",
"property",
"also",
"equals",
"the",
"given",
"remote",
"property",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php#L259-L266 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php | BaseFilterBuilder.andRemotePropertyGreaterThan | public function andRemotePropertyGreaterThan($property, $remoteProperty, $remoteIsValue = false)
{
$this->getBuilder()->checkNotRoot();
return $this->andEncapsulate(
new PropertyGreaterThanFilterBuilder($property, $remoteProperty, true, !$remoteIsValue)
);
} | php | public function andRemotePropertyGreaterThan($property, $remoteProperty, $remoteIsValue = false)
{
$this->getBuilder()->checkNotRoot();
return $this->andEncapsulate(
new PropertyGreaterThanFilterBuilder($property, $remoteProperty, true, !$remoteIsValue)
);
} | [
"public",
"function",
"andRemotePropertyGreaterThan",
"(",
"$",
"property",
",",
"$",
"remoteProperty",
",",
"$",
"remoteIsValue",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"checkNotRoot",
"(",
")",
";",
"return",
"$",
"this",
"->",
"andEncapsulate",
"(",
"new",
"PropertyGreaterThanFilterBuilder",
"(",
"$",
"property",
",",
"$",
"remoteProperty",
",",
"true",
",",
"!",
"$",
"remoteIsValue",
")",
")",
";",
"}"
]
| Ensure that the given property also is greater than the given remote property.
@param string $property The name of the property.
@param string $remoteProperty The name of the remote property.
@param bool $remoteIsValue True if the passed remote value is a value, false if it is a property name.
@return PropertyGreaterThanFilterBuilder The newly created filter. | [
"Ensure",
"that",
"the",
"given",
"property",
"also",
"is",
"greater",
"than",
"the",
"given",
"remote",
"property",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php#L290-L297 | train |
contao-community-alliance/dc-general | src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php | BaseFilterBuilder.andRemotePropertyLessThan | public function andRemotePropertyLessThan($property, $remoteProperty, $remoteIsValue = false)
{
$this->getBuilder()->checkNotRoot();
return $this->andEncapsulate(
new PropertyLessThanFilterBuilder($property, $remoteProperty, true, !$remoteIsValue)
);
} | php | public function andRemotePropertyLessThan($property, $remoteProperty, $remoteIsValue = false)
{
$this->getBuilder()->checkNotRoot();
return $this->andEncapsulate(
new PropertyLessThanFilterBuilder($property, $remoteProperty, true, !$remoteIsValue)
);
} | [
"public",
"function",
"andRemotePropertyLessThan",
"(",
"$",
"property",
",",
"$",
"remoteProperty",
",",
"$",
"remoteIsValue",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"checkNotRoot",
"(",
")",
";",
"return",
"$",
"this",
"->",
"andEncapsulate",
"(",
"new",
"PropertyLessThanFilterBuilder",
"(",
"$",
"property",
",",
"$",
"remoteProperty",
",",
"true",
",",
"!",
"$",
"remoteIsValue",
")",
")",
";",
"}"
]
| Ensure that the given property also is less than the given remote property.
@param string $property The name of the property.
@param string $remoteProperty The name of the remote property.
@param bool $remoteIsValue True if the passed remote value is a value, false if it is a property name.
@return PropertyLessThanFilterBuilder The newly created filter. | [
"Ensure",
"that",
"the",
"given",
"property",
"also",
"is",
"less",
"than",
"the",
"given",
"remote",
"property",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/ModelRelationship/FilterBuilder/BaseFilterBuilder.php#L321-L328 | train |
contao-community-alliance/dc-general | src/EventListener/ModelRelationship/TreeEnforcingListener.php | TreeEnforcingListener.handleInto | private function handleInto(
ModelId $into,
RelationshipManager $relationships,
ModelCollector $collector,
ModelInterface $model
) {
// If we have a null, it means insert into the tree root.
if (0 === $into->getId() || null === $parent = $collector->getModel($into)) {
$relationships->setRoot($model);
return;
}
$relationships->setParent($model, $parent);
} | php | private function handleInto(
ModelId $into,
RelationshipManager $relationships,
ModelCollector $collector,
ModelInterface $model
) {
// If we have a null, it means insert into the tree root.
if (0 === $into->getId() || null === $parent = $collector->getModel($into)) {
$relationships->setRoot($model);
return;
}
$relationships->setParent($model, $parent);
} | [
"private",
"function",
"handleInto",
"(",
"ModelId",
"$",
"into",
",",
"RelationshipManager",
"$",
"relationships",
",",
"ModelCollector",
"$",
"collector",
",",
"ModelInterface",
"$",
"model",
")",
"{",
"// If we have a null, it means insert into the tree root.",
"if",
"(",
"0",
"===",
"$",
"into",
"->",
"getId",
"(",
")",
"||",
"null",
"===",
"$",
"parent",
"=",
"$",
"collector",
"->",
"getModel",
"(",
"$",
"into",
")",
")",
"{",
"$",
"relationships",
"->",
"setRoot",
"(",
"$",
"model",
")",
";",
"return",
";",
"}",
"$",
"relationships",
"->",
"setParent",
"(",
"$",
"model",
",",
"$",
"parent",
")",
";",
"}"
]
| Handle paste into.
@param ModelId $into The id of the new parenting model.
@param RelationshipManager $relationships The relationship manager.
@param ModelCollector $collector The model collector.
@param ModelInterface $model The model.
@return void | [
"Handle",
"paste",
"into",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/EventListener/ModelRelationship/TreeEnforcingListener.php#L93-L106 | train |
contao-community-alliance/dc-general | src/EventListener/ModelRelationship/TreeEnforcingListener.php | TreeEnforcingListener.handleAfter | private function handleAfter(
ModelId $after,
RelationshipManager $relationships,
ModelCollector $collector,
ModelInterface $model
) {
$sibling = $collector->getModel($after);
if (!$sibling || $relationships->isRoot($sibling)) {
$relationships->setRoot($model);
return;
}
$parent = $collector->searchParentOf($sibling);
$relationships->setParent($model, $parent);
} | php | private function handleAfter(
ModelId $after,
RelationshipManager $relationships,
ModelCollector $collector,
ModelInterface $model
) {
$sibling = $collector->getModel($after);
if (!$sibling || $relationships->isRoot($sibling)) {
$relationships->setRoot($model);
return;
}
$parent = $collector->searchParentOf($sibling);
$relationships->setParent($model, $parent);
} | [
"private",
"function",
"handleAfter",
"(",
"ModelId",
"$",
"after",
",",
"RelationshipManager",
"$",
"relationships",
",",
"ModelCollector",
"$",
"collector",
",",
"ModelInterface",
"$",
"model",
")",
"{",
"$",
"sibling",
"=",
"$",
"collector",
"->",
"getModel",
"(",
"$",
"after",
")",
";",
"if",
"(",
"!",
"$",
"sibling",
"||",
"$",
"relationships",
"->",
"isRoot",
"(",
"$",
"sibling",
")",
")",
"{",
"$",
"relationships",
"->",
"setRoot",
"(",
"$",
"model",
")",
";",
"return",
";",
"}",
"$",
"parent",
"=",
"$",
"collector",
"->",
"searchParentOf",
"(",
"$",
"sibling",
")",
";",
"$",
"relationships",
"->",
"setParent",
"(",
"$",
"model",
",",
"$",
"parent",
")",
";",
"}"
]
| Handle paste after.
@param ModelId $after The id of the sibling model.
@param RelationshipManager $relationships The relationship manager.
@param ModelCollector $collector The model collector.
@param ModelInterface $model The model.
@return void | [
"Handle",
"paste",
"after",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/EventListener/ModelRelationship/TreeEnforcingListener.php#L118-L133 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.renderButtonsForCollection | public function renderButtonsForCollection(CollectionInterface $collection)
{
// Generate buttons.
foreach ($collection as $i => $model) {
$previous = $collection->get($i - 1);
$next = $collection->get($i + 1);
/** @var ModelInterface $model */
$this->renderButtonsFor($model, $previous, $next);
}
} | php | public function renderButtonsForCollection(CollectionInterface $collection)
{
// Generate buttons.
foreach ($collection as $i => $model) {
$previous = $collection->get($i - 1);
$next = $collection->get($i + 1);
/** @var ModelInterface $model */
$this->renderButtonsFor($model, $previous, $next);
}
} | [
"public",
"function",
"renderButtonsForCollection",
"(",
"CollectionInterface",
"$",
"collection",
")",
"{",
"// Generate buttons.",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"i",
"=>",
"$",
"model",
")",
"{",
"$",
"previous",
"=",
"$",
"collection",
"->",
"get",
"(",
"$",
"i",
"-",
"1",
")",
";",
"$",
"next",
"=",
"$",
"collection",
"->",
"get",
"(",
"$",
"i",
"+",
"1",
")",
";",
"/** @var ModelInterface $model */",
"$",
"this",
"->",
"renderButtonsFor",
"(",
"$",
"model",
",",
"$",
"previous",
",",
"$",
"next",
")",
";",
"}",
"}"
]
| Render the operation buttons for the passed models.
@param CollectionInterface $collection The collection containing the models.
@return void | [
"Render",
"the",
"operation",
"buttons",
"for",
"the",
"passed",
"models",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L146-L155 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.renderButtonsFor | private function renderButtonsFor(
ModelInterface $model,
ModelInterface $previous = null,
ModelInterface $next = null
) {
$modelId = ModelId::fromModel($model)->getSerialized();
if ($this->clipboardItems) {
$isCircular = \in_array(ModelId::fromModel($model)->getSerialized(), $this->circularModelIds);
} else {
$isCircular = false;
}
$childIds = $this->getChildIds($model);
$buttons = [];
foreach ($this->commands->getCommands() as $command) {
$buttons[$command->getName()] =
$this->buildCommand($command, $model, $previous, $next, $isCircular, $childIds);
}
if ($this->hasPasteNewButton()) {
$buttons['pasteNew'] = $this->renderPasteNewFor($modelId);
}
// Add paste into/after icons.
if ($this->hasPasteButtons()) {
$urlAfter = $this->addToUrl(\sprintf('act=paste&after=%s&', $modelId));
$urlInto = $this->addToUrl(\sprintf('act=paste&into=%s&', $modelId));
$buttonEvent = new GetPasteButtonEvent($this->environment);
$buttonEvent
->setModel($model)
->setCircularReference($isCircular)
->setPrevious($previous)
->setNext($next)
->setHrefAfter($urlAfter)
->setHrefInto($urlInto)
// Check if the id is in the ignore list.
->setPasteAfterDisabled($isCircular)
->setPasteIntoDisabled($isCircular)
->setContainedModels($this->clipboardModels);
$this->eventDispatcher->dispatch(GetPasteButtonEvent::NAME, $buttonEvent);
$buttons['pasteafter'] = $this->renderPasteAfterButton($buttonEvent);
if ($this->isHierarchical()) {
$buttons['pasteinto'] = $this->renderPasteIntoButton($buttonEvent);
}
}
$model->setMeta(
$model::OPERATION_BUTTONS,
\implode(' ', $buttons)
);
} | php | private function renderButtonsFor(
ModelInterface $model,
ModelInterface $previous = null,
ModelInterface $next = null
) {
$modelId = ModelId::fromModel($model)->getSerialized();
if ($this->clipboardItems) {
$isCircular = \in_array(ModelId::fromModel($model)->getSerialized(), $this->circularModelIds);
} else {
$isCircular = false;
}
$childIds = $this->getChildIds($model);
$buttons = [];
foreach ($this->commands->getCommands() as $command) {
$buttons[$command->getName()] =
$this->buildCommand($command, $model, $previous, $next, $isCircular, $childIds);
}
if ($this->hasPasteNewButton()) {
$buttons['pasteNew'] = $this->renderPasteNewFor($modelId);
}
// Add paste into/after icons.
if ($this->hasPasteButtons()) {
$urlAfter = $this->addToUrl(\sprintf('act=paste&after=%s&', $modelId));
$urlInto = $this->addToUrl(\sprintf('act=paste&into=%s&', $modelId));
$buttonEvent = new GetPasteButtonEvent($this->environment);
$buttonEvent
->setModel($model)
->setCircularReference($isCircular)
->setPrevious($previous)
->setNext($next)
->setHrefAfter($urlAfter)
->setHrefInto($urlInto)
// Check if the id is in the ignore list.
->setPasteAfterDisabled($isCircular)
->setPasteIntoDisabled($isCircular)
->setContainedModels($this->clipboardModels);
$this->eventDispatcher->dispatch(GetPasteButtonEvent::NAME, $buttonEvent);
$buttons['pasteafter'] = $this->renderPasteAfterButton($buttonEvent);
if ($this->isHierarchical()) {
$buttons['pasteinto'] = $this->renderPasteIntoButton($buttonEvent);
}
}
$model->setMeta(
$model::OPERATION_BUTTONS,
\implode(' ', $buttons)
);
} | [
"private",
"function",
"renderButtonsFor",
"(",
"ModelInterface",
"$",
"model",
",",
"ModelInterface",
"$",
"previous",
"=",
"null",
",",
"ModelInterface",
"$",
"next",
"=",
"null",
")",
"{",
"$",
"modelId",
"=",
"ModelId",
"::",
"fromModel",
"(",
"$",
"model",
")",
"->",
"getSerialized",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"clipboardItems",
")",
"{",
"$",
"isCircular",
"=",
"\\",
"in_array",
"(",
"ModelId",
"::",
"fromModel",
"(",
"$",
"model",
")",
"->",
"getSerialized",
"(",
")",
",",
"$",
"this",
"->",
"circularModelIds",
")",
";",
"}",
"else",
"{",
"$",
"isCircular",
"=",
"false",
";",
"}",
"$",
"childIds",
"=",
"$",
"this",
"->",
"getChildIds",
"(",
"$",
"model",
")",
";",
"$",
"buttons",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"->",
"getCommands",
"(",
")",
"as",
"$",
"command",
")",
"{",
"$",
"buttons",
"[",
"$",
"command",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"buildCommand",
"(",
"$",
"command",
",",
"$",
"model",
",",
"$",
"previous",
",",
"$",
"next",
",",
"$",
"isCircular",
",",
"$",
"childIds",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasPasteNewButton",
"(",
")",
")",
"{",
"$",
"buttons",
"[",
"'pasteNew'",
"]",
"=",
"$",
"this",
"->",
"renderPasteNewFor",
"(",
"$",
"modelId",
")",
";",
"}",
"// Add paste into/after icons.",
"if",
"(",
"$",
"this",
"->",
"hasPasteButtons",
"(",
")",
")",
"{",
"$",
"urlAfter",
"=",
"$",
"this",
"->",
"addToUrl",
"(",
"\\",
"sprintf",
"(",
"'act=paste&after=%s&'",
",",
"$",
"modelId",
")",
")",
";",
"$",
"urlInto",
"=",
"$",
"this",
"->",
"addToUrl",
"(",
"\\",
"sprintf",
"(",
"'act=paste&into=%s&'",
",",
"$",
"modelId",
")",
")",
";",
"$",
"buttonEvent",
"=",
"new",
"GetPasteButtonEvent",
"(",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"buttonEvent",
"->",
"setModel",
"(",
"$",
"model",
")",
"->",
"setCircularReference",
"(",
"$",
"isCircular",
")",
"->",
"setPrevious",
"(",
"$",
"previous",
")",
"->",
"setNext",
"(",
"$",
"next",
")",
"->",
"setHrefAfter",
"(",
"$",
"urlAfter",
")",
"->",
"setHrefInto",
"(",
"$",
"urlInto",
")",
"// Check if the id is in the ignore list.",
"->",
"setPasteAfterDisabled",
"(",
"$",
"isCircular",
")",
"->",
"setPasteIntoDisabled",
"(",
"$",
"isCircular",
")",
"->",
"setContainedModels",
"(",
"$",
"this",
"->",
"clipboardModels",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"GetPasteButtonEvent",
"::",
"NAME",
",",
"$",
"buttonEvent",
")",
";",
"$",
"buttons",
"[",
"'pasteafter'",
"]",
"=",
"$",
"this",
"->",
"renderPasteAfterButton",
"(",
"$",
"buttonEvent",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isHierarchical",
"(",
")",
")",
"{",
"$",
"buttons",
"[",
"'pasteinto'",
"]",
"=",
"$",
"this",
"->",
"renderPasteIntoButton",
"(",
"$",
"buttonEvent",
")",
";",
"}",
"}",
"$",
"model",
"->",
"setMeta",
"(",
"$",
"model",
"::",
"OPERATION_BUTTONS",
",",
"\\",
"implode",
"(",
"' '",
",",
"$",
"buttons",
")",
")",
";",
"}"
]
| Render the operation buttons for the passed model.
@param ModelInterface $model The model to render the buttons for.
@param ModelInterface $previous The previous model in the collection.
@param ModelInterface $next The next model in the collection.
@return void | [
"Render",
"the",
"operation",
"buttons",
"for",
"the",
"passed",
"model",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L166-L220 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.isHierarchical | private function isHierarchical()
{
$dataDefinition = $this->environment->getDataDefinition();
$basicDefinition = $dataDefinition->getBasicDefinition();
return $basicDefinition::MODE_HIERARCHICAL === $basicDefinition->getMode();
} | php | private function isHierarchical()
{
$dataDefinition = $this->environment->getDataDefinition();
$basicDefinition = $dataDefinition->getBasicDefinition();
return $basicDefinition::MODE_HIERARCHICAL === $basicDefinition->getMode();
} | [
"private",
"function",
"isHierarchical",
"(",
")",
"{",
"$",
"dataDefinition",
"=",
"$",
"this",
"->",
"environment",
"->",
"getDataDefinition",
"(",
")",
";",
"$",
"basicDefinition",
"=",
"$",
"dataDefinition",
"->",
"getBasicDefinition",
"(",
")",
";",
"return",
"$",
"basicDefinition",
"::",
"MODE_HIERARCHICAL",
"===",
"$",
"basicDefinition",
"->",
"getMode",
"(",
")",
";",
"}"
]
| If the view is hierarchical.
@return bool | [
"If",
"the",
"view",
"is",
"hierarchical",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L227-L233 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.hasPasteButtons | private function hasPasteButtons()
{
return ((true === (bool) ViewHelpers::getManualSortingProperty($this->environment))
&& false === empty($this->clipboardItems));
} | php | private function hasPasteButtons()
{
return ((true === (bool) ViewHelpers::getManualSortingProperty($this->environment))
&& false === empty($this->clipboardItems));
} | [
"private",
"function",
"hasPasteButtons",
"(",
")",
"{",
"return",
"(",
"(",
"true",
"===",
"(",
"bool",
")",
"ViewHelpers",
"::",
"getManualSortingProperty",
"(",
"$",
"this",
"->",
"environment",
")",
")",
"&&",
"false",
"===",
"empty",
"(",
"$",
"this",
"->",
"clipboardItems",
")",
")",
";",
"}"
]
| Determining if into and after buttons shall be examined.
@return bool | [
"Determining",
"if",
"into",
"and",
"after",
"buttons",
"shall",
"be",
"examined",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L240-L244 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.hasPasteNewButton | private function hasPasteNewButton()
{
$environment = $this->environment;
$basicDefinition = $environment->getDataDefinition()->getBasicDefinition();
return ((true === (bool) ViewHelpers::getManualSortingProperty($environment))
&& (true === empty($this->clipboardItems))
&& (false === $this->isHierarchical())
&& ($basicDefinition->isEditable() && $basicDefinition->isCreatable()));
} | php | private function hasPasteNewButton()
{
$environment = $this->environment;
$basicDefinition = $environment->getDataDefinition()->getBasicDefinition();
return ((true === (bool) ViewHelpers::getManualSortingProperty($environment))
&& (true === empty($this->clipboardItems))
&& (false === $this->isHierarchical())
&& ($basicDefinition->isEditable() && $basicDefinition->isCreatable()));
} | [
"private",
"function",
"hasPasteNewButton",
"(",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"environment",
";",
"$",
"basicDefinition",
"=",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getBasicDefinition",
"(",
")",
";",
"return",
"(",
"(",
"true",
"===",
"(",
"bool",
")",
"ViewHelpers",
"::",
"getManualSortingProperty",
"(",
"$",
"environment",
")",
")",
"&&",
"(",
"true",
"===",
"empty",
"(",
"$",
"this",
"->",
"clipboardItems",
")",
")",
"&&",
"(",
"false",
"===",
"$",
"this",
"->",
"isHierarchical",
"(",
")",
")",
"&&",
"(",
"$",
"basicDefinition",
"->",
"isEditable",
"(",
")",
"&&",
"$",
"basicDefinition",
"->",
"isCreatable",
"(",
")",
")",
")",
";",
"}"
]
| Determining if paste new buttons shall be examined.
@return bool | [
"Determining",
"if",
"paste",
"new",
"buttons",
"shall",
"be",
"examined",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L251-L260 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.buildCommand | private function buildCommand($command, $model, $previous, $next, $isCircularReference, $childIds)
{
$extra = (array) $command->getExtra();
$attributes = '';
if (!empty($extra['attributes'])) {
$attributes .= \sprintf($extra['attributes'], $model->getID());
}
$icon = $extra['icon'];
if ($command instanceof ToggleCommandInterface) {
$iconDisabled = ($extra['icon_disabled'] ?? 'invisible.svg');
$attributes .= \sprintf(
' onclick="Backend.getScrollOffset(); return BackendGeneral.toggleVisibility(this, \'%s\', \'%s\');"',
$icon,
$iconDisabled
);
if (!$this->isTogglerInActiveState($command, $model)) {
$icon = $iconDisabled;
}
}
$buttonEvent = new GetOperationButtonEvent($this->environment);
$buttonEvent
->setKey($command->getName())
->setCommand($command)
->setObjModel($model)
->setAttributes($attributes)
->setLabel($this->getCommandLabel($command))
->setTitle(\sprintf($this->translate((string) $command->getDescription()), $model->getID()))
->setHref($this->calculateHref($command, $model))
->setChildRecordIds($childIds)
->setCircularReference($isCircularReference)
->setPrevious($previous)
->setNext($next)
->setDisabled($command->isDisabled());
$this->eventDispatcher->dispatch(GetOperationButtonEvent::NAME, $buttonEvent);
if (null !== ($html = $buttonEvent->getHtml())) {
// If the event created a button, use it.
return \trim($html);
}
if ($buttonEvent->isDisabled()) {
$iconDisabledSuffix = '_1';
// Check wheter icon is part of contao
if ($icon !== Image::getPath($icon)) {
$iconDisabledSuffix = '_';
}
return $this->renderImageAsHtml(
\substr_replace($icon, $iconDisabledSuffix, \strrpos($icon, '.'), 0),
$buttonEvent->getLabel()
);
}
return \sprintf(
' <a class="%s" href="%s" title="%s" %s>%s</a>',
$command->getName(),
$buttonEvent->getHref(),
StringUtil::specialchars($buttonEvent->getTitle()),
\ltrim($buttonEvent->getAttributes()),
$this->renderImageAsHtml($icon, $buttonEvent->getLabel())
);
} | php | private function buildCommand($command, $model, $previous, $next, $isCircularReference, $childIds)
{
$extra = (array) $command->getExtra();
$attributes = '';
if (!empty($extra['attributes'])) {
$attributes .= \sprintf($extra['attributes'], $model->getID());
}
$icon = $extra['icon'];
if ($command instanceof ToggleCommandInterface) {
$iconDisabled = ($extra['icon_disabled'] ?? 'invisible.svg');
$attributes .= \sprintf(
' onclick="Backend.getScrollOffset(); return BackendGeneral.toggleVisibility(this, \'%s\', \'%s\');"',
$icon,
$iconDisabled
);
if (!$this->isTogglerInActiveState($command, $model)) {
$icon = $iconDisabled;
}
}
$buttonEvent = new GetOperationButtonEvent($this->environment);
$buttonEvent
->setKey($command->getName())
->setCommand($command)
->setObjModel($model)
->setAttributes($attributes)
->setLabel($this->getCommandLabel($command))
->setTitle(\sprintf($this->translate((string) $command->getDescription()), $model->getID()))
->setHref($this->calculateHref($command, $model))
->setChildRecordIds($childIds)
->setCircularReference($isCircularReference)
->setPrevious($previous)
->setNext($next)
->setDisabled($command->isDisabled());
$this->eventDispatcher->dispatch(GetOperationButtonEvent::NAME, $buttonEvent);
if (null !== ($html = $buttonEvent->getHtml())) {
// If the event created a button, use it.
return \trim($html);
}
if ($buttonEvent->isDisabled()) {
$iconDisabledSuffix = '_1';
// Check wheter icon is part of contao
if ($icon !== Image::getPath($icon)) {
$iconDisabledSuffix = '_';
}
return $this->renderImageAsHtml(
\substr_replace($icon, $iconDisabledSuffix, \strrpos($icon, '.'), 0),
$buttonEvent->getLabel()
);
}
return \sprintf(
' <a class="%s" href="%s" title="%s" %s>%s</a>',
$command->getName(),
$buttonEvent->getHref(),
StringUtil::specialchars($buttonEvent->getTitle()),
\ltrim($buttonEvent->getAttributes()),
$this->renderImageAsHtml($icon, $buttonEvent->getLabel())
);
} | [
"private",
"function",
"buildCommand",
"(",
"$",
"command",
",",
"$",
"model",
",",
"$",
"previous",
",",
"$",
"next",
",",
"$",
"isCircularReference",
",",
"$",
"childIds",
")",
"{",
"$",
"extra",
"=",
"(",
"array",
")",
"$",
"command",
"->",
"getExtra",
"(",
")",
";",
"$",
"attributes",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"extra",
"[",
"'attributes'",
"]",
")",
")",
"{",
"$",
"attributes",
".=",
"\\",
"sprintf",
"(",
"$",
"extra",
"[",
"'attributes'",
"]",
",",
"$",
"model",
"->",
"getID",
"(",
")",
")",
";",
"}",
"$",
"icon",
"=",
"$",
"extra",
"[",
"'icon'",
"]",
";",
"if",
"(",
"$",
"command",
"instanceof",
"ToggleCommandInterface",
")",
"{",
"$",
"iconDisabled",
"=",
"(",
"$",
"extra",
"[",
"'icon_disabled'",
"]",
"??",
"'invisible.svg'",
")",
";",
"$",
"attributes",
".=",
"\\",
"sprintf",
"(",
"' onclick=\"Backend.getScrollOffset(); return BackendGeneral.toggleVisibility(this, \\'%s\\', \\'%s\\');\"'",
",",
"$",
"icon",
",",
"$",
"iconDisabled",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isTogglerInActiveState",
"(",
"$",
"command",
",",
"$",
"model",
")",
")",
"{",
"$",
"icon",
"=",
"$",
"iconDisabled",
";",
"}",
"}",
"$",
"buttonEvent",
"=",
"new",
"GetOperationButtonEvent",
"(",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"buttonEvent",
"->",
"setKey",
"(",
"$",
"command",
"->",
"getName",
"(",
")",
")",
"->",
"setCommand",
"(",
"$",
"command",
")",
"->",
"setObjModel",
"(",
"$",
"model",
")",
"->",
"setAttributes",
"(",
"$",
"attributes",
")",
"->",
"setLabel",
"(",
"$",
"this",
"->",
"getCommandLabel",
"(",
"$",
"command",
")",
")",
"->",
"setTitle",
"(",
"\\",
"sprintf",
"(",
"$",
"this",
"->",
"translate",
"(",
"(",
"string",
")",
"$",
"command",
"->",
"getDescription",
"(",
")",
")",
",",
"$",
"model",
"->",
"getID",
"(",
")",
")",
")",
"->",
"setHref",
"(",
"$",
"this",
"->",
"calculateHref",
"(",
"$",
"command",
",",
"$",
"model",
")",
")",
"->",
"setChildRecordIds",
"(",
"$",
"childIds",
")",
"->",
"setCircularReference",
"(",
"$",
"isCircularReference",
")",
"->",
"setPrevious",
"(",
"$",
"previous",
")",
"->",
"setNext",
"(",
"$",
"next",
")",
"->",
"setDisabled",
"(",
"$",
"command",
"->",
"isDisabled",
"(",
")",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"GetOperationButtonEvent",
"::",
"NAME",
",",
"$",
"buttonEvent",
")",
";",
"if",
"(",
"null",
"!==",
"(",
"$",
"html",
"=",
"$",
"buttonEvent",
"->",
"getHtml",
"(",
")",
")",
")",
"{",
"// If the event created a button, use it.",
"return",
"\\",
"trim",
"(",
"$",
"html",
")",
";",
"}",
"if",
"(",
"$",
"buttonEvent",
"->",
"isDisabled",
"(",
")",
")",
"{",
"$",
"iconDisabledSuffix",
"=",
"'_1'",
";",
"// Check wheter icon is part of contao",
"if",
"(",
"$",
"icon",
"!==",
"Image",
"::",
"getPath",
"(",
"$",
"icon",
")",
")",
"{",
"$",
"iconDisabledSuffix",
"=",
"'_'",
";",
"}",
"return",
"$",
"this",
"->",
"renderImageAsHtml",
"(",
"\\",
"substr_replace",
"(",
"$",
"icon",
",",
"$",
"iconDisabledSuffix",
",",
"\\",
"strrpos",
"(",
"$",
"icon",
",",
"'.'",
")",
",",
"0",
")",
",",
"$",
"buttonEvent",
"->",
"getLabel",
"(",
")",
")",
";",
"}",
"return",
"\\",
"sprintf",
"(",
"' <a class=\"%s\" href=\"%s\" title=\"%s\" %s>%s</a>'",
",",
"$",
"command",
"->",
"getName",
"(",
")",
",",
"$",
"buttonEvent",
"->",
"getHref",
"(",
")",
",",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"buttonEvent",
"->",
"getTitle",
"(",
")",
")",
",",
"\\",
"ltrim",
"(",
"$",
"buttonEvent",
"->",
"getAttributes",
"(",
")",
")",
",",
"$",
"this",
"->",
"renderImageAsHtml",
"(",
"$",
"icon",
",",
"$",
"buttonEvent",
"->",
"getLabel",
"(",
")",
")",
")",
";",
"}"
]
| Render a command button.
@param CommandInterface $command The command to render the button for.
@param ModelInterface $model The model to which the command shall get applied.
@param ModelInterface $previous The previous model in the collection.
@param ModelInterface $next The next model in the collection.
@param bool $isCircularReference Determinator if there exists a circular reference between the model
and the model(s) contained in the clipboard.
@param string[] $childIds The ids of all child models.
@return string | [
"Render",
"a",
"command",
"button",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L275-L342 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.getChildIds | private function getChildIds(ModelInterface $model)
{
if (null === ($childCollections = $model->getMeta($model::CHILD_COLLECTIONS))) {
return [];
}
$ids = [ModelId::fromModel($model)->getSerialized()];
$childIds = [];
foreach ($childCollections as $collection) {
foreach ($collection as $child) {
$childIds[] = $this->getChildIds($child);
}
}
return \array_merge($ids, ...$childIds);
} | php | private function getChildIds(ModelInterface $model)
{
if (null === ($childCollections = $model->getMeta($model::CHILD_COLLECTIONS))) {
return [];
}
$ids = [ModelId::fromModel($model)->getSerialized()];
$childIds = [];
foreach ($childCollections as $collection) {
foreach ($collection as $child) {
$childIds[] = $this->getChildIds($child);
}
}
return \array_merge($ids, ...$childIds);
} | [
"private",
"function",
"getChildIds",
"(",
"ModelInterface",
"$",
"model",
")",
"{",
"if",
"(",
"null",
"===",
"(",
"$",
"childCollections",
"=",
"$",
"model",
"->",
"getMeta",
"(",
"$",
"model",
"::",
"CHILD_COLLECTIONS",
")",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"ids",
"=",
"[",
"ModelId",
"::",
"fromModel",
"(",
"$",
"model",
")",
"->",
"getSerialized",
"(",
")",
"]",
";",
"$",
"childIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"childCollections",
"as",
"$",
"collection",
")",
"{",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"child",
")",
"{",
"$",
"childIds",
"[",
"]",
"=",
"$",
"this",
"->",
"getChildIds",
"(",
"$",
"child",
")",
";",
"}",
"}",
"return",
"\\",
"array_merge",
"(",
"$",
"ids",
",",
"...",
"$",
"childIds",
")",
";",
"}"
]
| Recursively determine all child ids of the passed model.
@param ModelInterface $model The model to fetch the ids from.
@return string[] | [
"Recursively",
"determine",
"all",
"child",
"ids",
"of",
"the",
"passed",
"model",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L351-L367 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.calculateParameters | private function calculateParameters(CommandInterface $command, $serializedModelId)
{
$parameters = (array) $command->getParameters();
if ($command instanceof ToggleCommandInterface) {
// Toggle has to trigger the javascript.
$parameters['act'] = $command->getName();
$parameters['id'] = $serializedModelId;
return $parameters;
}
if (($command instanceof CutCommandInterface) || ($command instanceof CopyCommandInterface)) {
// Cut & copy need some special information.
$parameters = [];
$parameters['act'] = $command->getName();
$inputProvider = $this->environment->getInputProvider();
// If we have a pid add it, used for mode 4 and all parent -> current views.
if ($inputProvider->hasParameter('pid')) {
$parameters['pid'] = $inputProvider->getParameter('pid');
}
// Source is the id of the element which should move.
$parameters['source'] = $serializedModelId;
return $parameters;
}
$extra = (array) $command->getExtra();
$parameters[($extra['idparam'] ?? null) ?: 'id'] = $serializedModelId;
return $parameters;
} | php | private function calculateParameters(CommandInterface $command, $serializedModelId)
{
$parameters = (array) $command->getParameters();
if ($command instanceof ToggleCommandInterface) {
// Toggle has to trigger the javascript.
$parameters['act'] = $command->getName();
$parameters['id'] = $serializedModelId;
return $parameters;
}
if (($command instanceof CutCommandInterface) || ($command instanceof CopyCommandInterface)) {
// Cut & copy need some special information.
$parameters = [];
$parameters['act'] = $command->getName();
$inputProvider = $this->environment->getInputProvider();
// If we have a pid add it, used for mode 4 and all parent -> current views.
if ($inputProvider->hasParameter('pid')) {
$parameters['pid'] = $inputProvider->getParameter('pid');
}
// Source is the id of the element which should move.
$parameters['source'] = $serializedModelId;
return $parameters;
}
$extra = (array) $command->getExtra();
$parameters[($extra['idparam'] ?? null) ?: 'id'] = $serializedModelId;
return $parameters;
} | [
"private",
"function",
"calculateParameters",
"(",
"CommandInterface",
"$",
"command",
",",
"$",
"serializedModelId",
")",
"{",
"$",
"parameters",
"=",
"(",
"array",
")",
"$",
"command",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"$",
"command",
"instanceof",
"ToggleCommandInterface",
")",
"{",
"// Toggle has to trigger the javascript.",
"$",
"parameters",
"[",
"'act'",
"]",
"=",
"$",
"command",
"->",
"getName",
"(",
")",
";",
"$",
"parameters",
"[",
"'id'",
"]",
"=",
"$",
"serializedModelId",
";",
"return",
"$",
"parameters",
";",
"}",
"if",
"(",
"(",
"$",
"command",
"instanceof",
"CutCommandInterface",
")",
"||",
"(",
"$",
"command",
"instanceof",
"CopyCommandInterface",
")",
")",
"{",
"// Cut & copy need some special information.",
"$",
"parameters",
"=",
"[",
"]",
";",
"$",
"parameters",
"[",
"'act'",
"]",
"=",
"$",
"command",
"->",
"getName",
"(",
")",
";",
"$",
"inputProvider",
"=",
"$",
"this",
"->",
"environment",
"->",
"getInputProvider",
"(",
")",
";",
"// If we have a pid add it, used for mode 4 and all parent -> current views.",
"if",
"(",
"$",
"inputProvider",
"->",
"hasParameter",
"(",
"'pid'",
")",
")",
"{",
"$",
"parameters",
"[",
"'pid'",
"]",
"=",
"$",
"inputProvider",
"->",
"getParameter",
"(",
"'pid'",
")",
";",
"}",
"// Source is the id of the element which should move.",
"$",
"parameters",
"[",
"'source'",
"]",
"=",
"$",
"serializedModelId",
";",
"return",
"$",
"parameters",
";",
"}",
"$",
"extra",
"=",
"(",
"array",
")",
"$",
"command",
"->",
"getExtra",
"(",
")",
";",
"$",
"parameters",
"[",
"(",
"$",
"extra",
"[",
"'idparam'",
"]",
"??",
"null",
")",
"?",
":",
"'id'",
"]",
"=",
"$",
"serializedModelId",
";",
"return",
"$",
"parameters",
";",
"}"
]
| Calculate the special parameters for certain operations.
@param CommandInterface $command The command.
@param string $serializedModelId The model id to use.
@return string[] | [
"Calculate",
"the",
"special",
"parameters",
"for",
"certain",
"operations",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L377-L409 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.renderPasteNewFor | private function renderPasteNewFor($modelId)
{
$label = \sprintf($this->translate('pastenew.1'), ModelId::fromSerialized($modelId)->getId());
return \sprintf(
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a>',
$this->addToUrl('act=create&after=' . $modelId),
StringUtil::specialchars($label),
$this->renderImageAsHtml('new.svg', $label)
);
} | php | private function renderPasteNewFor($modelId)
{
$label = \sprintf($this->translate('pastenew.1'), ModelId::fromSerialized($modelId)->getId());
return \sprintf(
'<a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a>',
$this->addToUrl('act=create&after=' . $modelId),
StringUtil::specialchars($label),
$this->renderImageAsHtml('new.svg', $label)
);
} | [
"private",
"function",
"renderPasteNewFor",
"(",
"$",
"modelId",
")",
"{",
"$",
"label",
"=",
"\\",
"sprintf",
"(",
"$",
"this",
"->",
"translate",
"(",
"'pastenew.1'",
")",
",",
"ModelId",
"::",
"fromSerialized",
"(",
"$",
"modelId",
")",
"->",
"getId",
"(",
")",
")",
";",
"return",
"\\",
"sprintf",
"(",
"'<a href=\"%s\" title=\"%s\" onclick=\"Backend.getScrollOffset()\">%s</a>'",
",",
"$",
"this",
"->",
"addToUrl",
"(",
"'act=create&after='",
".",
"$",
"modelId",
")",
",",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"label",
")",
",",
"$",
"this",
"->",
"renderImageAsHtml",
"(",
"'new.svg'",
",",
"$",
"label",
")",
")",
";",
"}"
]
| Render the "paste new" button.
@param string $modelId The model id for which to create the paste new button.
@return string | [
"Render",
"the",
"paste",
"new",
"button",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L418-L427 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.renderPasteIntoButton | private function renderPasteIntoButton(GetPasteButtonEvent $event)
{
if (null !== ($value = $event->getHtmlPasteInto())) {
return $value;
}
$label = $this->translate('pasteinto.0');
if ($event->isPasteIntoDisabled()) {
return $this->renderImageAsHtml('pasteinto_.svg', $label, 'class="blink"');
}
if ('pasteinto.1' !== ($opDesc = $this->translate('pasteinto.1'))) {
$title = \sprintf($opDesc, $event->getModel()->getId());
} else {
$title = \sprintf('%s id %s', $label, $event->getModel()->getId());
}
return \sprintf(
' <a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a>',
$event->getHrefInto(),
StringUtil::specialchars($title),
$this->renderImageAsHtml('pasteinto.svg', $label, 'class="blink"')
);
} | php | private function renderPasteIntoButton(GetPasteButtonEvent $event)
{
if (null !== ($value = $event->getHtmlPasteInto())) {
return $value;
}
$label = $this->translate('pasteinto.0');
if ($event->isPasteIntoDisabled()) {
return $this->renderImageAsHtml('pasteinto_.svg', $label, 'class="blink"');
}
if ('pasteinto.1' !== ($opDesc = $this->translate('pasteinto.1'))) {
$title = \sprintf($opDesc, $event->getModel()->getId());
} else {
$title = \sprintf('%s id %s', $label, $event->getModel()->getId());
}
return \sprintf(
' <a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a>',
$event->getHrefInto(),
StringUtil::specialchars($title),
$this->renderImageAsHtml('pasteinto.svg', $label, 'class="blink"')
);
} | [
"private",
"function",
"renderPasteIntoButton",
"(",
"GetPasteButtonEvent",
"$",
"event",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"value",
"=",
"$",
"event",
"->",
"getHtmlPasteInto",
"(",
")",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"label",
"=",
"$",
"this",
"->",
"translate",
"(",
"'pasteinto.0'",
")",
";",
"if",
"(",
"$",
"event",
"->",
"isPasteIntoDisabled",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderImageAsHtml",
"(",
"'pasteinto_.svg'",
",",
"$",
"label",
",",
"'class=\"blink\"'",
")",
";",
"}",
"if",
"(",
"'pasteinto.1'",
"!==",
"(",
"$",
"opDesc",
"=",
"$",
"this",
"->",
"translate",
"(",
"'pasteinto.1'",
")",
")",
")",
"{",
"$",
"title",
"=",
"\\",
"sprintf",
"(",
"$",
"opDesc",
",",
"$",
"event",
"->",
"getModel",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"title",
"=",
"\\",
"sprintf",
"(",
"'%s id %s'",
",",
"$",
"label",
",",
"$",
"event",
"->",
"getModel",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"}",
"return",
"\\",
"sprintf",
"(",
"' <a href=\"%s\" title=\"%s\" onclick=\"Backend.getScrollOffset()\">%s</a>'",
",",
"$",
"event",
"->",
"getHrefInto",
"(",
")",
",",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"title",
")",
",",
"$",
"this",
"->",
"renderImageAsHtml",
"(",
"'pasteinto.svg'",
",",
"$",
"label",
",",
"'class=\"blink\"'",
")",
")",
";",
"}"
]
| Render the paste into button.
@param GetPasteButtonEvent $event The event that has been triggered.
@return string | [
"Render",
"the",
"paste",
"into",
"button",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L436-L459 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.renderPasteAfterButton | private function renderPasteAfterButton(GetPasteButtonEvent $event)
{
if (null !== ($value = $event->getHtmlPasteAfter())) {
return $value;
}
$label = $this->translate('pasteafter.0');
if ($event->isPasteAfterDisabled()) {
return $this->renderImageAsHtml('pasteafter_.svg', $label, 'class="blink"');
}
if ('pasteafter.1' !== ($opDesc = $this->translate('pasteafter.1'))) {
$title = \sprintf($opDesc, $event->getModel()->getId());
} else {
$title = \sprintf('%s id %s', $label, $event->getModel()->getId());
}
return \sprintf(
' <a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a>',
$event->getHrefAfter(),
StringUtil::specialchars($title),
$this->renderImageAsHtml('pasteafter.svg', $label, 'class="blink"')
);
} | php | private function renderPasteAfterButton(GetPasteButtonEvent $event)
{
if (null !== ($value = $event->getHtmlPasteAfter())) {
return $value;
}
$label = $this->translate('pasteafter.0');
if ($event->isPasteAfterDisabled()) {
return $this->renderImageAsHtml('pasteafter_.svg', $label, 'class="blink"');
}
if ('pasteafter.1' !== ($opDesc = $this->translate('pasteafter.1'))) {
$title = \sprintf($opDesc, $event->getModel()->getId());
} else {
$title = \sprintf('%s id %s', $label, $event->getModel()->getId());
}
return \sprintf(
' <a href="%s" title="%s" onclick="Backend.getScrollOffset()">%s</a>',
$event->getHrefAfter(),
StringUtil::specialchars($title),
$this->renderImageAsHtml('pasteafter.svg', $label, 'class="blink"')
);
} | [
"private",
"function",
"renderPasteAfterButton",
"(",
"GetPasteButtonEvent",
"$",
"event",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"value",
"=",
"$",
"event",
"->",
"getHtmlPasteAfter",
"(",
")",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"label",
"=",
"$",
"this",
"->",
"translate",
"(",
"'pasteafter.0'",
")",
";",
"if",
"(",
"$",
"event",
"->",
"isPasteAfterDisabled",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderImageAsHtml",
"(",
"'pasteafter_.svg'",
",",
"$",
"label",
",",
"'class=\"blink\"'",
")",
";",
"}",
"if",
"(",
"'pasteafter.1'",
"!==",
"(",
"$",
"opDesc",
"=",
"$",
"this",
"->",
"translate",
"(",
"'pasteafter.1'",
")",
")",
")",
"{",
"$",
"title",
"=",
"\\",
"sprintf",
"(",
"$",
"opDesc",
",",
"$",
"event",
"->",
"getModel",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"title",
"=",
"\\",
"sprintf",
"(",
"'%s id %s'",
",",
"$",
"label",
",",
"$",
"event",
"->",
"getModel",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"}",
"return",
"\\",
"sprintf",
"(",
"' <a href=\"%s\" title=\"%s\" onclick=\"Backend.getScrollOffset()\">%s</a>'",
",",
"$",
"event",
"->",
"getHrefAfter",
"(",
")",
",",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"title",
")",
",",
"$",
"this",
"->",
"renderImageAsHtml",
"(",
"'pasteafter.svg'",
",",
"$",
"label",
",",
"'class=\"blink\"'",
")",
")",
";",
"}"
]
| Render the paste after button.
@param GetPasteButtonEvent $event The event that has been triggered.
@return string | [
"Render",
"the",
"paste",
"after",
"button",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L468-L491 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.calculateClipboardItems | private function calculateClipboardItems()
{
$dataDefinition = $this->environment->getDataDefinition();
$basicDefinition = $dataDefinition->getBasicDefinition();
$clipboard = $this->environment->getClipboard();
$filter = new Filter();
$filter->andModelIsFromProvider($basicDefinition->getDataProvider());
if ($parentDataProviderName = $basicDefinition->getParentDataProvider()) {
$filter->andParentIsFromProvider($parentDataProviderName);
} else {
$filter->andHasNoParent();
}
return $clipboard->fetch($filter);
} | php | private function calculateClipboardItems()
{
$dataDefinition = $this->environment->getDataDefinition();
$basicDefinition = $dataDefinition->getBasicDefinition();
$clipboard = $this->environment->getClipboard();
$filter = new Filter();
$filter->andModelIsFromProvider($basicDefinition->getDataProvider());
if ($parentDataProviderName = $basicDefinition->getParentDataProvider()) {
$filter->andParentIsFromProvider($parentDataProviderName);
} else {
$filter->andHasNoParent();
}
return $clipboard->fetch($filter);
} | [
"private",
"function",
"calculateClipboardItems",
"(",
")",
"{",
"$",
"dataDefinition",
"=",
"$",
"this",
"->",
"environment",
"->",
"getDataDefinition",
"(",
")",
";",
"$",
"basicDefinition",
"=",
"$",
"dataDefinition",
"->",
"getBasicDefinition",
"(",
")",
";",
"$",
"clipboard",
"=",
"$",
"this",
"->",
"environment",
"->",
"getClipboard",
"(",
")",
";",
"$",
"filter",
"=",
"new",
"Filter",
"(",
")",
";",
"$",
"filter",
"->",
"andModelIsFromProvider",
"(",
"$",
"basicDefinition",
"->",
"getDataProvider",
"(",
")",
")",
";",
"if",
"(",
"$",
"parentDataProviderName",
"=",
"$",
"basicDefinition",
"->",
"getParentDataProvider",
"(",
")",
")",
"{",
"$",
"filter",
"->",
"andParentIsFromProvider",
"(",
"$",
"parentDataProviderName",
")",
";",
"}",
"else",
"{",
"$",
"filter",
"->",
"andHasNoParent",
"(",
")",
";",
"}",
"return",
"$",
"clipboard",
"->",
"fetch",
"(",
"$",
"filter",
")",
";",
"}"
]
| Calculate all clipboard items for the current view.
@return ItemInterface[] | [
"Calculate",
"all",
"clipboard",
"items",
"for",
"the",
"current",
"view",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L498-L513 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.renderImageAsHtml | private function renderImageAsHtml($src, $alt, $attributes = '')
{
/** @var GenerateHtmlEvent $imageEvent */
$imageEvent = $this->eventDispatcher->dispatch(
ContaoEvents::IMAGE_GET_HTML,
new GenerateHtmlEvent($src, $alt, $attributes)
);
return $imageEvent->getHtml();
} | php | private function renderImageAsHtml($src, $alt, $attributes = '')
{
/** @var GenerateHtmlEvent $imageEvent */
$imageEvent = $this->eventDispatcher->dispatch(
ContaoEvents::IMAGE_GET_HTML,
new GenerateHtmlEvent($src, $alt, $attributes)
);
return $imageEvent->getHtml();
} | [
"private",
"function",
"renderImageAsHtml",
"(",
"$",
"src",
",",
"$",
"alt",
",",
"$",
"attributes",
"=",
"''",
")",
"{",
"/** @var GenerateHtmlEvent $imageEvent */",
"$",
"imageEvent",
"=",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"IMAGE_GET_HTML",
",",
"new",
"GenerateHtmlEvent",
"(",
"$",
"src",
",",
"$",
"alt",
",",
"$",
"attributes",
")",
")",
";",
"return",
"$",
"imageEvent",
"->",
"getHtml",
"(",
")",
";",
"}"
]
| Render an image as HTML string.
@param string $src The image path.
@param string $alt An optional alt attribute.
@param string $attributes A string of other attributes.
@return string | [
"Render",
"an",
"image",
"as",
"HTML",
"string",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L541-L550 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.addToUrl | private function addToUrl($parameters)
{
/** @var AddToUrlEvent $urlAfter */
$urlAfter = $this->eventDispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, new AddToUrlEvent($parameters));
return $urlAfter->getUrl();
} | php | private function addToUrl($parameters)
{
/** @var AddToUrlEvent $urlAfter */
$urlAfter = $this->eventDispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, new AddToUrlEvent($parameters));
return $urlAfter->getUrl();
} | [
"private",
"function",
"addToUrl",
"(",
"$",
"parameters",
")",
"{",
"/** @var AddToUrlEvent $urlAfter */",
"$",
"urlAfter",
"=",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"BACKEND_ADD_TO_URL",
",",
"new",
"AddToUrlEvent",
"(",
"$",
"parameters",
")",
")",
";",
"return",
"$",
"urlAfter",
"->",
"getUrl",
"(",
")",
";",
"}"
]
| Add some url parameters to the current URL.
@param string $parameters The parameters to add.
@return string | [
"Add",
"some",
"url",
"parameters",
"to",
"the",
"current",
"URL",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L559-L565 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.isTogglerInActiveState | private function isTogglerInActiveState($command, $model)
{
$dataProvider = $this->environment->getDataProvider($model->getProviderName());
$propModel = $model;
if ($command instanceof TranslatedToggleCommandInterface
&& $dataProvider instanceof MultiLanguageDataProviderInterface
) {
$language = $dataProvider->getCurrentLanguage();
$dataProvider->setCurrentLanguage($command->getLanguage());
$propModel = $dataProvider->fetch(
$dataProvider
->getEmptyConfig()
->setId($model->getId())
->setFields([$command->getToggleProperty()])
);
$dataProvider->setCurrentLanguage($language);
}
if ($command->isInverse()) {
return !$propModel->getProperty($command->getToggleProperty());
}
return (bool) $propModel->getProperty($command->getToggleProperty());
} | php | private function isTogglerInActiveState($command, $model)
{
$dataProvider = $this->environment->getDataProvider($model->getProviderName());
$propModel = $model;
if ($command instanceof TranslatedToggleCommandInterface
&& $dataProvider instanceof MultiLanguageDataProviderInterface
) {
$language = $dataProvider->getCurrentLanguage();
$dataProvider->setCurrentLanguage($command->getLanguage());
$propModel = $dataProvider->fetch(
$dataProvider
->getEmptyConfig()
->setId($model->getId())
->setFields([$command->getToggleProperty()])
);
$dataProvider->setCurrentLanguage($language);
}
if ($command->isInverse()) {
return !$propModel->getProperty($command->getToggleProperty());
}
return (bool) $propModel->getProperty($command->getToggleProperty());
} | [
"private",
"function",
"isTogglerInActiveState",
"(",
"$",
"command",
",",
"$",
"model",
")",
"{",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"environment",
"->",
"getDataProvider",
"(",
"$",
"model",
"->",
"getProviderName",
"(",
")",
")",
";",
"$",
"propModel",
"=",
"$",
"model",
";",
"if",
"(",
"$",
"command",
"instanceof",
"TranslatedToggleCommandInterface",
"&&",
"$",
"dataProvider",
"instanceof",
"MultiLanguageDataProviderInterface",
")",
"{",
"$",
"language",
"=",
"$",
"dataProvider",
"->",
"getCurrentLanguage",
"(",
")",
";",
"$",
"dataProvider",
"->",
"setCurrentLanguage",
"(",
"$",
"command",
"->",
"getLanguage",
"(",
")",
")",
";",
"$",
"propModel",
"=",
"$",
"dataProvider",
"->",
"fetch",
"(",
"$",
"dataProvider",
"->",
"getEmptyConfig",
"(",
")",
"->",
"setId",
"(",
"$",
"model",
"->",
"getId",
"(",
")",
")",
"->",
"setFields",
"(",
"[",
"$",
"command",
"->",
"getToggleProperty",
"(",
")",
"]",
")",
")",
";",
"$",
"dataProvider",
"->",
"setCurrentLanguage",
"(",
"$",
"language",
")",
";",
"}",
"if",
"(",
"$",
"command",
"->",
"isInverse",
"(",
")",
")",
"{",
"return",
"!",
"$",
"propModel",
"->",
"getProperty",
"(",
"$",
"command",
"->",
"getToggleProperty",
"(",
")",
")",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"propModel",
"->",
"getProperty",
"(",
"$",
"command",
"->",
"getToggleProperty",
"(",
")",
")",
";",
"}"
]
| Determine the toggle state of a toggle command.
@param ToggleCommandInterface $command The toggle command.
@param ModelInterface $model The model in scope.
@return bool | [
"Determine",
"the",
"toggle",
"state",
"of",
"a",
"toggle",
"command",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L575-L599 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.calculateHref | private function calculateHref(CommandInterface $command, $model)
{
$parameters = $this->calculateParameters($command, ModelId::fromModel($model)->getSerialized());
$href = '';
foreach ($parameters as $key => $value) {
$href .= \sprintf('&%s=%s', $key, $value);
}
return $this->addToUrl($href);
} | php | private function calculateHref(CommandInterface $command, $model)
{
$parameters = $this->calculateParameters($command, ModelId::fromModel($model)->getSerialized());
$href = '';
foreach ($parameters as $key => $value) {
$href .= \sprintf('&%s=%s', $key, $value);
}
return $this->addToUrl($href);
} | [
"private",
"function",
"calculateHref",
"(",
"CommandInterface",
"$",
"command",
",",
"$",
"model",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"calculateParameters",
"(",
"$",
"command",
",",
"ModelId",
"::",
"fromModel",
"(",
"$",
"model",
")",
"->",
"getSerialized",
"(",
")",
")",
";",
"$",
"href",
"=",
"''",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"href",
".=",
"\\",
"sprintf",
"(",
"'&%s=%s'",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addToUrl",
"(",
"$",
"href",
")",
";",
"}"
]
| Calculate the href for a command.
@param CommandInterface $command The command.
@param ModelInterface $model The current model.
@return string | [
"Calculate",
"the",
"href",
"for",
"a",
"command",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L609-L618 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ButtonRenderer.php | ButtonRenderer.getCommandLabel | private function getCommandLabel(CommandInterface $command)
{
if (null === $label = $command->getLabel()) {
$label = $command->getName();
}
$label = $this->translate($label);
return \is_array($label) ? $label[0] : $label;
} | php | private function getCommandLabel(CommandInterface $command)
{
if (null === $label = $command->getLabel()) {
$label = $command->getName();
}
$label = $this->translate($label);
return \is_array($label) ? $label[0] : $label;
} | [
"private",
"function",
"getCommandLabel",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"label",
"=",
"$",
"command",
"->",
"getLabel",
"(",
")",
")",
"{",
"$",
"label",
"=",
"$",
"command",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"label",
"=",
"$",
"this",
"->",
"translate",
"(",
"$",
"label",
")",
";",
"return",
"\\",
"is_array",
"(",
"$",
"label",
")",
"?",
"$",
"label",
"[",
"0",
"]",
":",
"$",
"label",
";",
"}"
]
| Get the correct label for a command button.
@param CommandInterface $command The command.
@return string | [
"Get",
"the",
"correct",
"label",
"for",
"a",
"command",
"button",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ButtonRenderer.php#L627-L636 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/Event/AddConditionEvent.php | AddConditionEvent.setTarget | public function setTarget($target)
{
if ((!$target instanceof PaletteInterface) && (!$target instanceof PropertyInterface)) {
throw new DcGeneralInvalidArgumentException();
}
$this->target = $target;
return $this;
} | php | public function setTarget($target)
{
if ((!$target instanceof PaletteInterface) && (!$target instanceof PropertyInterface)) {
throw new DcGeneralInvalidArgumentException();
}
$this->target = $target;
return $this;
} | [
"public",
"function",
"setTarget",
"(",
"$",
"target",
")",
"{",
"if",
"(",
"(",
"!",
"$",
"target",
"instanceof",
"PaletteInterface",
")",
"&&",
"(",
"!",
"$",
"target",
"instanceof",
"PropertyInterface",
")",
")",
"{",
"throw",
"new",
"DcGeneralInvalidArgumentException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"target",
"=",
"$",
"target",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the target.
@param PaletteInterface|PropertyInterface $target The target property or palette.
@return AddConditionEvent
@throws DcGeneralInvalidArgumentException When an invalid target has been passed. | [
"Set",
"the",
"target",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/Event/AddConditionEvent.php#L109-L117 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.modelIsFromProvider | private function modelIsFromProvider($conjunction, $modelProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $modelProviderName;
$this->compiled = null;
return $this;
} | php | private function modelIsFromProvider($conjunction, $modelProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $modelProviderName;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"modelIsFromProvider",
"(",
"$",
"conjunction",
",",
"$",
"modelProviderName",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"MODEL_IS_FROM_PROVIDER_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"modelProviderName",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add model is from provider fragment.
@param string $conjunction AND or OR.
@param string $modelProviderName The provider name.
@return static | [
"Add",
"model",
"is",
"from",
"provider",
"fragment",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L181-L193 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.modelIsNotFromProvider | private function modelIsNotFromProvider($conjunction, $modelProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_NOT_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $modelProviderName;
$this->compiled = null;
return $this;
} | php | private function modelIsNotFromProvider($conjunction, $modelProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_NOT_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $modelProviderName;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"modelIsNotFromProvider",
"(",
"$",
"conjunction",
",",
"$",
"modelProviderName",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"MODEL_IS_NOT_FROM_PROVIDER_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"modelProviderName",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add model is not from provider.
@param string $conjunction AND or OR.
@param string $modelProviderName The provider name.
@return static | [
"Add",
"model",
"is",
"not",
"from",
"provider",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L231-L243 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.modelIs | private function modelIs($conjunction, ModelId $modelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_EXPRESSION, $index);
$this->variables[] = $modelId;
$this->compiled = null;
return $this;
} | php | private function modelIs($conjunction, ModelId $modelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_EXPRESSION, $index);
$this->variables[] = $modelId;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"modelIs",
"(",
"$",
"conjunction",
",",
"ModelId",
"$",
"modelId",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"MODEL_IS_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"modelId",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add model is.
@param string $conjunction AND or OR.
@param ModelId $modelId The model id.
@return static | [
"Add",
"model",
"is",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L281-L293 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.modelIsNot | private function modelIsNot($conjunction, ModelId $modelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_NOT_EXPRESSION, $index);
$this->variables[] = $modelId;
$this->compiled = null;
return $this;
} | php | private function modelIsNot($conjunction, ModelId $modelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::MODEL_IS_NOT_EXPRESSION, $index);
$this->variables[] = $modelId;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"modelIsNot",
"(",
"$",
"conjunction",
",",
"ModelId",
"$",
"modelId",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"MODEL_IS_NOT_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"modelId",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add model is not.
@param string $conjunction AND or OR.
@param ModelId $modelId The model id.
@return static | [
"Add",
"model",
"is",
"not",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L331-L343 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.parentIsFromProvider | private function parentIsFromProvider($conjunction, $parentProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $parentProviderName;
$this->compiled = null;
return $this;
} | php | private function parentIsFromProvider($conjunction, $parentProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $parentProviderName;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"parentIsFromProvider",
"(",
"$",
"conjunction",
",",
"$",
"parentProviderName",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"PARENT_IS_FROM_PROVIDER_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"parentProviderName",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add parent is from provider.
@param string $conjunction AND or OR.
@param string $parentProviderName The parent provider name.
@return static | [
"Add",
"parent",
"is",
"from",
"provider",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L381-L393 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.parentIsNotFromProvider | private function parentIsNotFromProvider($conjunction, $parentProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_NOT_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $parentProviderName;
$this->compiled = null;
return $this;
} | php | private function parentIsNotFromProvider($conjunction, $parentProviderName)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_NOT_FROM_PROVIDER_EXPRESSION, $index);
$this->variables[] = $parentProviderName;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"parentIsNotFromProvider",
"(",
"$",
"conjunction",
",",
"$",
"parentProviderName",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"PARENT_IS_NOT_FROM_PROVIDER_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"parentProviderName",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| And parent is not from provider.
@param string $conjunction AND or OR.
@param string $parentProviderName The parent provider name.
@return static | [
"And",
"parent",
"is",
"not",
"from",
"provider",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L431-L443 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.hasNoParent | private function hasNoParent($conjunction)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$this->expression[] = self::HAS_NO_PARENT_EXPRESSION;
$this->compiled = null;
return $this;
} | php | private function hasNoParent($conjunction)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$this->expression[] = self::HAS_NO_PARENT_EXPRESSION;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"hasNoParent",
"(",
"$",
"conjunction",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"self",
"::",
"HAS_NO_PARENT_EXPRESSION",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add has no parent.
@param string $conjunction AND or OR.
@return static | [
"Add",
"has",
"no",
"parent",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L476-L486 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.parentIs | private function parentIs($conjunction, ModelId $parentModelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_EXPRESSION, $index);
$this->variables[] = $parentModelId;
$this->compiled = null;
return $this;
} | php | private function parentIs($conjunction, ModelId $parentModelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_EXPRESSION, $index);
$this->variables[] = $parentModelId;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"parentIs",
"(",
"$",
"conjunction",
",",
"ModelId",
"$",
"parentModelId",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"PARENT_IS_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"parentModelId",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add parent is.
@param string $conjunction AND or OR.
@param ModelId $parentModelId The parent id.
@return static | [
"Add",
"parent",
"is",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L524-L536 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.parentIsIn | private function parentIsIn($conjunction, array $parentModelIds)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($parentModelIds as $parentModelId) {
$index = \count($this->variables);
$expression[] = \sprintf(self::PARENT_IS_EXPRESSION, $index);
$this->variables[] = $parentModelId;
}
$this->expression[] = '(' . \implode(' or ', $expression) . ')';
$this->compiled = null;
return $this;
} | php | private function parentIsIn($conjunction, array $parentModelIds)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($parentModelIds as $parentModelId) {
$index = \count($this->variables);
$expression[] = \sprintf(self::PARENT_IS_EXPRESSION, $index);
$this->variables[] = $parentModelId;
}
$this->expression[] = '(' . \implode(' or ', $expression) . ')';
$this->compiled = null;
return $this;
} | [
"private",
"function",
"parentIsIn",
"(",
"$",
"conjunction",
",",
"array",
"$",
"parentModelIds",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"expression",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parentModelIds",
"as",
"$",
"parentModelId",
")",
"{",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"PARENT_IS_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"parentModelId",
";",
"}",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"'('",
".",
"\\",
"implode",
"(",
"' or '",
",",
"$",
"expression",
")",
".",
"')'",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add parent is in.
@param string $conjunction AND or OR.
@param array|ModelId[] $parentModelIds The parent ids.
@return static | [
"Add",
"parent",
"is",
"in",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L574-L590 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.parentIsNot | private function parentIsNot($conjunction, ModelId $parentModelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_NOT_EXPRESSION, $index);
$this->variables[] = $parentModelId;
$this->compiled = null;
return $this;
} | php | private function parentIsNot($conjunction, ModelId $parentModelId)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::PARENT_IS_NOT_EXPRESSION, $index);
$this->variables[] = $parentModelId;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"parentIsNot",
"(",
"$",
"conjunction",
",",
"ModelId",
"$",
"parentModelId",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"PARENT_IS_NOT_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"parentModelId",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add parent is not.
@param string $conjunction AND or OR.
@param ModelId $parentModelId The parent id.
@return static | [
"Add",
"parent",
"is",
"not",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L628-L640 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.parentIsNotIn | private function parentIsNotIn($conjunction, array $parentModelIds)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($parentModelIds as $parentModelId) {
$index = \count($this->variables);
$expression[] = \sprintf(self::PARENT_IS_NOT_EXPRESSION, $index);
$this->variables[] = $parentModelId;
}
$this->expression[] = '(' . \implode(' and ', $expression) . ')';
$this->compiled = null;
return $this;
} | php | private function parentIsNotIn($conjunction, array $parentModelIds)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($parentModelIds as $parentModelId) {
$index = \count($this->variables);
$expression[] = \sprintf(self::PARENT_IS_NOT_EXPRESSION, $index);
$this->variables[] = $parentModelId;
}
$this->expression[] = '(' . \implode(' and ', $expression) . ')';
$this->compiled = null;
return $this;
} | [
"private",
"function",
"parentIsNotIn",
"(",
"$",
"conjunction",
",",
"array",
"$",
"parentModelIds",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"expression",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parentModelIds",
"as",
"$",
"parentModelId",
")",
"{",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"PARENT_IS_NOT_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"parentModelId",
";",
"}",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"'('",
".",
"\\",
"implode",
"(",
"' and '",
",",
"$",
"expression",
")",
".",
"')'",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add parent is not in.
@param string $conjunction AND or OR.
@param array|ModelId[] $parentModelIds The parent ids.
@return static | [
"Add",
"parent",
"is",
"not",
"in",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L678-L694 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.actionIsIn | private function actionIsIn($conjunction, array $actions)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($actions as $action) {
$index = \count($this->variables);
$expression[] = \sprintf(self::ACTION_IS_EXPRESSION, $index);
$this->variables[] = $action;
}
$this->expression[] = '(' . \implode(' or ', $expression) . ')';
$this->compiled = null;
return $this;
} | php | private function actionIsIn($conjunction, array $actions)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($actions as $action) {
$index = \count($this->variables);
$expression[] = \sprintf(self::ACTION_IS_EXPRESSION, $index);
$this->variables[] = $action;
}
$this->expression[] = '(' . \implode(' or ', $expression) . ')';
$this->compiled = null;
return $this;
} | [
"private",
"function",
"actionIsIn",
"(",
"$",
"conjunction",
",",
"array",
"$",
"actions",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"expression",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"ACTION_IS_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"action",
";",
"}",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"'('",
".",
"\\",
"implode",
"(",
"' or '",
",",
"$",
"expression",
")",
".",
"')'",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add action is in.
@param string $conjunction AND or OR.
@param array|string[] $actions The action names.
@return static | [
"Add",
"action",
"is",
"in",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L782-L798 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.actionIsNotIn | private function actionIsNotIn($conjunction, array $actions)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($actions as $action) {
$index = \count($this->variables);
$expression[] = \sprintf(self::ACTION_IS_NOT_EXPRESSION, $index);
$this->variables[] = $action;
}
$this->expression[] = '(' . \implode(' and ', $expression) . ')';
$this->compiled = null;
return $this;
} | php | private function actionIsNotIn($conjunction, array $actions)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$expression = [];
foreach ($actions as $action) {
$index = \count($this->variables);
$expression[] = \sprintf(self::ACTION_IS_NOT_EXPRESSION, $index);
$this->variables[] = $action;
}
$this->expression[] = '(' . \implode(' and ', $expression) . ')';
$this->compiled = null;
return $this;
} | [
"private",
"function",
"actionIsNotIn",
"(",
"$",
"conjunction",
",",
"array",
"$",
"actions",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"expression",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"ACTION_IS_NOT_EXPRESSION",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"action",
";",
"}",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"'('",
".",
"\\",
"implode",
"(",
"' and '",
",",
"$",
"expression",
")",
".",
"')'",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add action is not in.
@param string $conjunction AND or OR.
@param array|string[] $actions The action names.
@return static | [
"Add",
"action",
"is",
"not",
"in",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L886-L902 | train |
contao-community-alliance/dc-general | src/Clipboard/Filter.php | Filter.sub | private function sub($conjunction, FilterInterface $filter)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::SUB_FILTER, $index);
$this->variables[] = $filter;
$this->compiled = null;
return $this;
} | php | private function sub($conjunction, FilterInterface $filter)
{
if (!empty($this->expression)) {
$this->expression[] = $conjunction;
}
$index = \count($this->variables);
$this->expression[] = \sprintf(self::SUB_FILTER, $index);
$this->variables[] = $filter;
$this->compiled = null;
return $this;
} | [
"private",
"function",
"sub",
"(",
"$",
"conjunction",
",",
"FilterInterface",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"expression",
")",
")",
"{",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"$",
"conjunction",
";",
"}",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"variables",
")",
";",
"$",
"this",
"->",
"expression",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"self",
"::",
"SUB_FILTER",
",",
"$",
"index",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"]",
"=",
"$",
"filter",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Add sub filter.
@param string $conjunction AND or OR.
@param FilterInterface $filter The sub filter.
@return static | [
"Add",
"sub",
"filter",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Clipboard/Filter.php#L940-L952 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/GlobalButtonRenderer.php | GlobalButtonRenderer.render | public function render()
{
/** @var CommandInterface[] $commands */
$commands = $this
->environment
->getDataDefinition()
->getDefinition(Contao2BackendViewDefinitionInterface::NAME)
->getGlobalCommands()
->getCommands();
if (!\is_array($commands)) {
$commands = [];
}
$buttons = [];
foreach ($commands as $command) {
if ($command->isDisabled()) {
continue;
}
$buttons[$command->getName()] = $this->renderButton($command);
}
$buttonsEvent = new GetGlobalButtonsEvent($this->environment);
$buttonsEvent->setButtons($buttons);
$this->dispatcher->dispatch(GetGlobalButtonsEvent::NAME, $buttonsEvent);
return '<div id="tl_buttons">' . \implode('', $buttonsEvent->getButtons()) . '</div>';
} | php | public function render()
{
/** @var CommandInterface[] $commands */
$commands = $this
->environment
->getDataDefinition()
->getDefinition(Contao2BackendViewDefinitionInterface::NAME)
->getGlobalCommands()
->getCommands();
if (!\is_array($commands)) {
$commands = [];
}
$buttons = [];
foreach ($commands as $command) {
if ($command->isDisabled()) {
continue;
}
$buttons[$command->getName()] = $this->renderButton($command);
}
$buttonsEvent = new GetGlobalButtonsEvent($this->environment);
$buttonsEvent->setButtons($buttons);
$this->dispatcher->dispatch(GetGlobalButtonsEvent::NAME, $buttonsEvent);
return '<div id="tl_buttons">' . \implode('', $buttonsEvent->getButtons()) . '</div>';
} | [
"public",
"function",
"render",
"(",
")",
"{",
"/** @var CommandInterface[] $commands */",
"$",
"commands",
"=",
"$",
"this",
"->",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getDefinition",
"(",
"Contao2BackendViewDefinitionInterface",
"::",
"NAME",
")",
"->",
"getGlobalCommands",
"(",
")",
"->",
"getCommands",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"commands",
")",
")",
"{",
"$",
"commands",
"=",
"[",
"]",
";",
"}",
"$",
"buttons",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"command",
"->",
"isDisabled",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"buttons",
"[",
"$",
"command",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"renderButton",
"(",
"$",
"command",
")",
";",
"}",
"$",
"buttonsEvent",
"=",
"new",
"GetGlobalButtonsEvent",
"(",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"buttonsEvent",
"->",
"setButtons",
"(",
"$",
"buttons",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"GetGlobalButtonsEvent",
"::",
"NAME",
",",
"$",
"buttonsEvent",
")",
";",
"return",
"'<div id=\"tl_buttons\">'",
".",
"\\",
"implode",
"(",
"''",
",",
"$",
"buttonsEvent",
"->",
"getButtons",
"(",
")",
")",
".",
"'</div>'",
";",
"}"
]
| Generate all global operation buttons for a view.
@return string | [
"Generate",
"all",
"global",
"operation",
"buttons",
"for",
"a",
"view",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/GlobalButtonRenderer.php#L79-L106 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/GlobalButtonRenderer.php | GlobalButtonRenderer.renderButton | private function renderButton(CommandInterface $command)
{
$extra = $command->getExtra();
$label = $this->translate($command->getLabel());
if (isset($extra['href'])) {
$href = $extra['href'];
} else {
$href = '';
foreach ($command->getParameters() as $key => $value) {
$href .= '&' . $key . '=' . $value;
}
/** @var AddToUrlEvent $event */
$event = $this->dispatcher->dispatch(
ContaoEvents::BACKEND_ADD_TO_URL,
new AddToUrlEvent(
$href
)
);
$href = $event->getUrl();
}
if (null === $label) {
$label = $command->getName();
}
$buttonEvent = new GetGlobalButtonEvent($this->environment);
$buttonEvent
->setAccessKey(isset($extra['accesskey']) ? \trim($extra['accesskey']) : null)
->setAttributes(' ' . \ltrim($extra['attributes']))
->setClass($extra['class'])
->setKey($command->getName())
->setHref($href)
->setLabel($label)
->setTitle($this->translate((string) $command->getDescription()));
$this->dispatcher->dispatch(GetGlobalButtonEvent::NAME, $buttonEvent);
// Allow to override the button entirely - if someone sets empty string, we keep it.
if (null !== ($html = $buttonEvent->getHtml())) {
return $html;
}
// Use the view native button building.
return \sprintf(
'<a href="%s" class="%s" title="%s"%s>%s</a> ',
$buttonEvent->getHref(),
$buttonEvent->getClass(),
StringUtil::specialchars($buttonEvent->getTitle()),
$buttonEvent->getAttributes(),
$buttonEvent->getLabel()
);
} | php | private function renderButton(CommandInterface $command)
{
$extra = $command->getExtra();
$label = $this->translate($command->getLabel());
if (isset($extra['href'])) {
$href = $extra['href'];
} else {
$href = '';
foreach ($command->getParameters() as $key => $value) {
$href .= '&' . $key . '=' . $value;
}
/** @var AddToUrlEvent $event */
$event = $this->dispatcher->dispatch(
ContaoEvents::BACKEND_ADD_TO_URL,
new AddToUrlEvent(
$href
)
);
$href = $event->getUrl();
}
if (null === $label) {
$label = $command->getName();
}
$buttonEvent = new GetGlobalButtonEvent($this->environment);
$buttonEvent
->setAccessKey(isset($extra['accesskey']) ? \trim($extra['accesskey']) : null)
->setAttributes(' ' . \ltrim($extra['attributes']))
->setClass($extra['class'])
->setKey($command->getName())
->setHref($href)
->setLabel($label)
->setTitle($this->translate((string) $command->getDescription()));
$this->dispatcher->dispatch(GetGlobalButtonEvent::NAME, $buttonEvent);
// Allow to override the button entirely - if someone sets empty string, we keep it.
if (null !== ($html = $buttonEvent->getHtml())) {
return $html;
}
// Use the view native button building.
return \sprintf(
'<a href="%s" class="%s" title="%s"%s>%s</a> ',
$buttonEvent->getHref(),
$buttonEvent->getClass(),
StringUtil::specialchars($buttonEvent->getTitle()),
$buttonEvent->getAttributes(),
$buttonEvent->getLabel()
);
} | [
"private",
"function",
"renderButton",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"$",
"extra",
"=",
"$",
"command",
"->",
"getExtra",
"(",
")",
";",
"$",
"label",
"=",
"$",
"this",
"->",
"translate",
"(",
"$",
"command",
"->",
"getLabel",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"extra",
"[",
"'href'",
"]",
")",
")",
"{",
"$",
"href",
"=",
"$",
"extra",
"[",
"'href'",
"]",
";",
"}",
"else",
"{",
"$",
"href",
"=",
"''",
";",
"foreach",
"(",
"$",
"command",
"->",
"getParameters",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"href",
".=",
"'&'",
".",
"$",
"key",
".",
"'='",
".",
"$",
"value",
";",
"}",
"/** @var AddToUrlEvent $event */",
"$",
"event",
"=",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"BACKEND_ADD_TO_URL",
",",
"new",
"AddToUrlEvent",
"(",
"$",
"href",
")",
")",
";",
"$",
"href",
"=",
"$",
"event",
"->",
"getUrl",
"(",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"label",
")",
"{",
"$",
"label",
"=",
"$",
"command",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"buttonEvent",
"=",
"new",
"GetGlobalButtonEvent",
"(",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"buttonEvent",
"->",
"setAccessKey",
"(",
"isset",
"(",
"$",
"extra",
"[",
"'accesskey'",
"]",
")",
"?",
"\\",
"trim",
"(",
"$",
"extra",
"[",
"'accesskey'",
"]",
")",
":",
"null",
")",
"->",
"setAttributes",
"(",
"' '",
".",
"\\",
"ltrim",
"(",
"$",
"extra",
"[",
"'attributes'",
"]",
")",
")",
"->",
"setClass",
"(",
"$",
"extra",
"[",
"'class'",
"]",
")",
"->",
"setKey",
"(",
"$",
"command",
"->",
"getName",
"(",
")",
")",
"->",
"setHref",
"(",
"$",
"href",
")",
"->",
"setLabel",
"(",
"$",
"label",
")",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"translate",
"(",
"(",
"string",
")",
"$",
"command",
"->",
"getDescription",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"GetGlobalButtonEvent",
"::",
"NAME",
",",
"$",
"buttonEvent",
")",
";",
"// Allow to override the button entirely - if someone sets empty string, we keep it.",
"if",
"(",
"null",
"!==",
"(",
"$",
"html",
"=",
"$",
"buttonEvent",
"->",
"getHtml",
"(",
")",
")",
")",
"{",
"return",
"$",
"html",
";",
"}",
"// Use the view native button building.",
"return",
"\\",
"sprintf",
"(",
"'<a href=\"%s\" class=\"%s\" title=\"%s\"%s>%s</a> '",
",",
"$",
"buttonEvent",
"->",
"getHref",
"(",
")",
",",
"$",
"buttonEvent",
"->",
"getClass",
"(",
")",
",",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"buttonEvent",
"->",
"getTitle",
"(",
")",
")",
",",
"$",
"buttonEvent",
"->",
"getAttributes",
"(",
")",
",",
"$",
"buttonEvent",
"->",
"getLabel",
"(",
")",
")",
";",
"}"
]
| Render a single header button.
@param CommandInterface $command The command definition.
@return string | [
"Render",
"a",
"single",
"header",
"button",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/GlobalButtonRenderer.php#L115-L168 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php | ToggleHandler.checkPermission | private function checkPermission(ActionEvent $event)
{
$environment = $event->getEnvironment();
if (true === $environment->getDataDefinition()->getBasicDefinition()->isEditable()) {
return true;
}
$event->setResponse(
\sprintf(
'<div style="text-align:center; font-weight:bold; padding:40px;">
You have no permission for toggle %s.
</div>',
$this->getOperation($event->getAction(), $environment)->getToggleProperty()
)
);
return false;
} | php | private function checkPermission(ActionEvent $event)
{
$environment = $event->getEnvironment();
if (true === $environment->getDataDefinition()->getBasicDefinition()->isEditable()) {
return true;
}
$event->setResponse(
\sprintf(
'<div style="text-align:center; font-weight:bold; padding:40px;">
You have no permission for toggle %s.
</div>',
$this->getOperation($event->getAction(), $environment)->getToggleProperty()
)
);
return false;
} | [
"private",
"function",
"checkPermission",
"(",
"ActionEvent",
"$",
"event",
")",
"{",
"$",
"environment",
"=",
"$",
"event",
"->",
"getEnvironment",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getBasicDefinition",
"(",
")",
"->",
"isEditable",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"event",
"->",
"setResponse",
"(",
"\\",
"sprintf",
"(",
"'<div style=\"text-align:center; font-weight:bold; padding:40px;\">\n You have no permission for toggle %s.\n </div>'",
",",
"$",
"this",
"->",
"getOperation",
"(",
"$",
"event",
"->",
"getAction",
"(",
")",
",",
"$",
"environment",
")",
"->",
"getToggleProperty",
"(",
")",
")",
")",
";",
"return",
"false",
";",
"}"
]
| Check permission for toggle property.
@param ActionEvent $event The action event.
@return bool | [
"Check",
"permission",
"for",
"toggle",
"property",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php#L150-L168 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php | ToggleHandler.getModelId | private function getModelId(EnvironmentInterface $environment)
{
$inputProvider = $environment->getInputProvider();
if ($inputProvider->hasParameter('id') && $inputProvider->getParameter('id')) {
$modelId = ModelId::fromSerialized($inputProvider->getParameter('id'));
}
if (!(isset($modelId)
&& ($environment->getDataDefinition()->getName() === $modelId->getDataProviderName()))
) {
return null;
}
return $modelId;
} | php | private function getModelId(EnvironmentInterface $environment)
{
$inputProvider = $environment->getInputProvider();
if ($inputProvider->hasParameter('id') && $inputProvider->getParameter('id')) {
$modelId = ModelId::fromSerialized($inputProvider->getParameter('id'));
}
if (!(isset($modelId)
&& ($environment->getDataDefinition()->getName() === $modelId->getDataProviderName()))
) {
return null;
}
return $modelId;
} | [
"private",
"function",
"getModelId",
"(",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"inputProvider",
"=",
"$",
"environment",
"->",
"getInputProvider",
"(",
")",
";",
"if",
"(",
"$",
"inputProvider",
"->",
"hasParameter",
"(",
"'id'",
")",
"&&",
"$",
"inputProvider",
"->",
"getParameter",
"(",
"'id'",
")",
")",
"{",
"$",
"modelId",
"=",
"ModelId",
"::",
"fromSerialized",
"(",
"$",
"inputProvider",
"->",
"getParameter",
"(",
"'id'",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"modelId",
")",
"&&",
"(",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getName",
"(",
")",
"===",
"$",
"modelId",
"->",
"getDataProviderName",
"(",
")",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"modelId",
";",
"}"
]
| Retrieve the model id from the input provider and validate it.
@param EnvironmentInterface $environment The environment.
@return ModelIdInterface|null | [
"Retrieve",
"the",
"model",
"id",
"from",
"the",
"input",
"provider",
"and",
"validate",
"it",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php#L177-L192 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php | ToggleHandler.getOperation | private function getOperation(Action $action, EnvironmentInterface $environment)
{
/** @var Contao2BackendViewDefinitionInterface $definition */
$definition = $environment->getDataDefinition()->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
$name = $action->getName();
$commands = $definition->getModelCommands();
if (!$commands->hasCommandNamed($name)) {
return null;
}
return $commands->getCommandNamed($name);
} | php | private function getOperation(Action $action, EnvironmentInterface $environment)
{
/** @var Contao2BackendViewDefinitionInterface $definition */
$definition = $environment->getDataDefinition()->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
$name = $action->getName();
$commands = $definition->getModelCommands();
if (!$commands->hasCommandNamed($name)) {
return null;
}
return $commands->getCommandNamed($name);
} | [
"private",
"function",
"getOperation",
"(",
"Action",
"$",
"action",
",",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"/** @var Contao2BackendViewDefinitionInterface $definition */",
"$",
"definition",
"=",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getDefinition",
"(",
"Contao2BackendViewDefinitionInterface",
"::",
"NAME",
")",
";",
"$",
"name",
"=",
"$",
"action",
"->",
"getName",
"(",
")",
";",
"$",
"commands",
"=",
"$",
"definition",
"->",
"getModelCommands",
"(",
")",
";",
"if",
"(",
"!",
"$",
"commands",
"->",
"hasCommandNamed",
"(",
"$",
"name",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"commands",
"->",
"getCommandNamed",
"(",
"$",
"name",
")",
";",
"}"
]
| Retrieve the toggle operation being executed.
@param Action $action The action.
@param EnvironmentInterface $environment The environment.
@return CommandInterface | [
"Retrieve",
"the",
"toggle",
"operation",
"being",
"executed",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php#L202-L214 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php | ToggleHandler.determineNewState | private function determineNewState(InputProviderInterface $inputProvider, $isInverse)
{
$state = 1 === (int) $inputProvider->getParameter('state');
if ($isInverse) {
return $state ? '' : '1';
}
return $state ? '1' : '';
} | php | private function determineNewState(InputProviderInterface $inputProvider, $isInverse)
{
$state = 1 === (int) $inputProvider->getParameter('state');
if ($isInverse) {
return $state ? '' : '1';
}
return $state ? '1' : '';
} | [
"private",
"function",
"determineNewState",
"(",
"InputProviderInterface",
"$",
"inputProvider",
",",
"$",
"isInverse",
")",
"{",
"$",
"state",
"=",
"1",
"===",
"(",
"int",
")",
"$",
"inputProvider",
"->",
"getParameter",
"(",
"'state'",
")",
";",
"if",
"(",
"$",
"isInverse",
")",
"{",
"return",
"$",
"state",
"?",
"''",
":",
"'1'",
";",
"}",
"return",
"$",
"state",
"?",
"'1'",
":",
"''",
";",
"}"
]
| Determine the new state from the input data.
@param InputProviderInterface $inputProvider The input provider.
@param bool $isInverse Flag if the state shall be evaluated as inverse toggler.
@return string | [
"Determine",
"the",
"new",
"state",
"from",
"the",
"input",
"data",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/ToggleHandler.php#L224-L233 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.buildFieldSets | private function buildFieldSets(Action $action, \ArrayObject $renderInformation, EnvironmentInterface $environment)
{
$formInputs = $environment->getInputProvider()->getValue('FORM_INPUTS');
$collection = $this->getCollectionFromSession($action, $environment);
$fieldSets = [];
$errors = [];
while ($collection->count() > 0) {
$model = $collection->shift();
$modelId = ModelId::fromModel($model);
$editPropertyValuesBag = $this->getPropertyValueBagFromModel($action, $model, $environment);
if ($formInputs) {
$this->handleEditCollection($action, $editPropertyValuesBag, $model, $renderInformation, $environment);
}
$fields = $this->renderEditFields(
$action,
new ContaoWidgetManager($environment, $model),
$model,
$editPropertyValuesBag,
$environment
);
if (\count($fields) < 1) {
continue;
}
$fieldSets[] = [
'label' => $modelId->getSerialized(),
'model' => $model,
'legend' => \str_replace('::', '____', $modelId->getSerialized()),
'class' => 'tl_box',
'palette' => \implode('', $fields)
];
}
$renderInformation->offsetSet('fieldsets', $this->handleLegendCollapsed($fieldSets));
$renderInformation->offsetSet('error', $errors);
} | php | private function buildFieldSets(Action $action, \ArrayObject $renderInformation, EnvironmentInterface $environment)
{
$formInputs = $environment->getInputProvider()->getValue('FORM_INPUTS');
$collection = $this->getCollectionFromSession($action, $environment);
$fieldSets = [];
$errors = [];
while ($collection->count() > 0) {
$model = $collection->shift();
$modelId = ModelId::fromModel($model);
$editPropertyValuesBag = $this->getPropertyValueBagFromModel($action, $model, $environment);
if ($formInputs) {
$this->handleEditCollection($action, $editPropertyValuesBag, $model, $renderInformation, $environment);
}
$fields = $this->renderEditFields(
$action,
new ContaoWidgetManager($environment, $model),
$model,
$editPropertyValuesBag,
$environment
);
if (\count($fields) < 1) {
continue;
}
$fieldSets[] = [
'label' => $modelId->getSerialized(),
'model' => $model,
'legend' => \str_replace('::', '____', $modelId->getSerialized()),
'class' => 'tl_box',
'palette' => \implode('', $fields)
];
}
$renderInformation->offsetSet('fieldsets', $this->handleLegendCollapsed($fieldSets));
$renderInformation->offsetSet('error', $errors);
} | [
"private",
"function",
"buildFieldSets",
"(",
"Action",
"$",
"action",
",",
"\\",
"ArrayObject",
"$",
"renderInformation",
",",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"formInputs",
"=",
"$",
"environment",
"->",
"getInputProvider",
"(",
")",
"->",
"getValue",
"(",
"'FORM_INPUTS'",
")",
";",
"$",
"collection",
"=",
"$",
"this",
"->",
"getCollectionFromSession",
"(",
"$",
"action",
",",
"$",
"environment",
")",
";",
"$",
"fieldSets",
"=",
"[",
"]",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"collection",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"model",
"=",
"$",
"collection",
"->",
"shift",
"(",
")",
";",
"$",
"modelId",
"=",
"ModelId",
"::",
"fromModel",
"(",
"$",
"model",
")",
";",
"$",
"editPropertyValuesBag",
"=",
"$",
"this",
"->",
"getPropertyValueBagFromModel",
"(",
"$",
"action",
",",
"$",
"model",
",",
"$",
"environment",
")",
";",
"if",
"(",
"$",
"formInputs",
")",
"{",
"$",
"this",
"->",
"handleEditCollection",
"(",
"$",
"action",
",",
"$",
"editPropertyValuesBag",
",",
"$",
"model",
",",
"$",
"renderInformation",
",",
"$",
"environment",
")",
";",
"}",
"$",
"fields",
"=",
"$",
"this",
"->",
"renderEditFields",
"(",
"$",
"action",
",",
"new",
"ContaoWidgetManager",
"(",
"$",
"environment",
",",
"$",
"model",
")",
",",
"$",
"model",
",",
"$",
"editPropertyValuesBag",
",",
"$",
"environment",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"fields",
")",
"<",
"1",
")",
"{",
"continue",
";",
"}",
"$",
"fieldSets",
"[",
"]",
"=",
"[",
"'label'",
"=>",
"$",
"modelId",
"->",
"getSerialized",
"(",
")",
",",
"'model'",
"=>",
"$",
"model",
",",
"'legend'",
"=>",
"\\",
"str_replace",
"(",
"'::'",
",",
"'____'",
",",
"$",
"modelId",
"->",
"getSerialized",
"(",
")",
")",
",",
"'class'",
"=>",
"'tl_box'",
",",
"'palette'",
"=>",
"\\",
"implode",
"(",
"''",
",",
"$",
"fields",
")",
"]",
";",
"}",
"$",
"renderInformation",
"->",
"offsetSet",
"(",
"'fieldsets'",
",",
"$",
"this",
"->",
"handleLegendCollapsed",
"(",
"$",
"fieldSets",
")",
")",
";",
"$",
"renderInformation",
"->",
"offsetSet",
"(",
"'error'",
",",
"$",
"errors",
")",
";",
"}"
]
| Build the field sets for each model.
Return error if their given.
@param Action $action The action.
@param \ArrayObject $renderInformation The render information.
@param EnvironmentInterface $environment The environment.
@return void | [
"Build",
"the",
"field",
"sets",
"for",
"each",
"model",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L117-L156 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.handleLegendCollapsed | private function handleLegendCollapsed(array $fieldSets)
{
$editInformation = $GLOBALS['container']['dc-general.edit-information'];
if (!$editInformation->hasAnyModelError()) {
return $fieldSets;
}
foreach (\array_keys($fieldSets) as $index) {
if ($editInformation->getModelError($fieldSets[$index]['model'])) {
continue;
}
$fieldSets[$index]['class'] .= ' collapsed';
}
return $fieldSets;
} | php | private function handleLegendCollapsed(array $fieldSets)
{
$editInformation = $GLOBALS['container']['dc-general.edit-information'];
if (!$editInformation->hasAnyModelError()) {
return $fieldSets;
}
foreach (\array_keys($fieldSets) as $index) {
if ($editInformation->getModelError($fieldSets[$index]['model'])) {
continue;
}
$fieldSets[$index]['class'] .= ' collapsed';
}
return $fieldSets;
} | [
"private",
"function",
"handleLegendCollapsed",
"(",
"array",
"$",
"fieldSets",
")",
"{",
"$",
"editInformation",
"=",
"$",
"GLOBALS",
"[",
"'container'",
"]",
"[",
"'dc-general.edit-information'",
"]",
";",
"if",
"(",
"!",
"$",
"editInformation",
"->",
"hasAnyModelError",
"(",
")",
")",
"{",
"return",
"$",
"fieldSets",
";",
"}",
"foreach",
"(",
"\\",
"array_keys",
"(",
"$",
"fieldSets",
")",
"as",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"editInformation",
"->",
"getModelError",
"(",
"$",
"fieldSets",
"[",
"$",
"index",
"]",
"[",
"'model'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"fieldSets",
"[",
"$",
"index",
"]",
"[",
"'class'",
"]",
".=",
"' collapsed'",
";",
"}",
"return",
"$",
"fieldSets",
";",
"}"
]
| Handle legend how are open if errors available.
@param array $fieldSets The field sets.
@return array
@SuppressWarnings(PHPMD.Superglobals) | [
"Handle",
"legend",
"how",
"are",
"open",
"if",
"errors",
"available",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L167-L183 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.renderEditFields | private function renderEditFields(
Action $action,
ContaoWidgetManager $widgetManager,
ModelInterface $model,
PropertyValueBagInterface $propertyValuesBag,
EnvironmentInterface $environment
) {
$properties = $environment->getDataDefinition()->getPropertiesDefinition();
$selectProperties = (array) $this->getPropertiesFromSession($action, $environment);
$modelId = ModelId::fromModel($model);
$dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
$editModel = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));
$visibleModel = $this->getVisibleModel($action, $editModel, $dataProvider, $environment);
$fields = [];
foreach ($selectProperties as $selectProperty) {
if (!$this->ensurePropertyVisibleInModel(
$action,
$selectProperty->getName(),
$visibleModel,
$environment
)) {
$fields[] =
$this->injectSelectParentPropertyInformation($action, $selectProperty, $editModel, $environment);
continue;
}
$editProperty = $this->buildEditProperty($selectProperty, $modelId);
$properties->addProperty($editProperty);
$this->setPropertyValue($editModel, $selectProperty, $propertyValuesBag);
$this->markEditErrors($editProperty, $selectProperty, $propertyValuesBag);
$this->markModelErrors(
$action,
$model,
$model,
$editProperty,
$selectProperty,
$propertyValuesBag,
$environment
);
$fields[] = $widgetManager->renderWidget($editProperty->getName(), false, $propertyValuesBag);
$fields[] = $this->injectSelectSubPropertiesInformation(
$selectProperty,
$editModel,
$propertyValuesBag,
$environment
);
}
if (null === $fields[0]) {
$fields[] = \sprintf(
'<p> </p><strong>%s</strong><p> </p>',
$environment->getTranslator()->translate('MSC.no_properties_available')
);
}
return $fields;
} | php | private function renderEditFields(
Action $action,
ContaoWidgetManager $widgetManager,
ModelInterface $model,
PropertyValueBagInterface $propertyValuesBag,
EnvironmentInterface $environment
) {
$properties = $environment->getDataDefinition()->getPropertiesDefinition();
$selectProperties = (array) $this->getPropertiesFromSession($action, $environment);
$modelId = ModelId::fromModel($model);
$dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
$editModel = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));
$visibleModel = $this->getVisibleModel($action, $editModel, $dataProvider, $environment);
$fields = [];
foreach ($selectProperties as $selectProperty) {
if (!$this->ensurePropertyVisibleInModel(
$action,
$selectProperty->getName(),
$visibleModel,
$environment
)) {
$fields[] =
$this->injectSelectParentPropertyInformation($action, $selectProperty, $editModel, $environment);
continue;
}
$editProperty = $this->buildEditProperty($selectProperty, $modelId);
$properties->addProperty($editProperty);
$this->setPropertyValue($editModel, $selectProperty, $propertyValuesBag);
$this->markEditErrors($editProperty, $selectProperty, $propertyValuesBag);
$this->markModelErrors(
$action,
$model,
$model,
$editProperty,
$selectProperty,
$propertyValuesBag,
$environment
);
$fields[] = $widgetManager->renderWidget($editProperty->getName(), false, $propertyValuesBag);
$fields[] = $this->injectSelectSubPropertiesInformation(
$selectProperty,
$editModel,
$propertyValuesBag,
$environment
);
}
if (null === $fields[0]) {
$fields[] = \sprintf(
'<p> </p><strong>%s</strong><p> </p>',
$environment->getTranslator()->translate('MSC.no_properties_available')
);
}
return $fields;
} | [
"private",
"function",
"renderEditFields",
"(",
"Action",
"$",
"action",
",",
"ContaoWidgetManager",
"$",
"widgetManager",
",",
"ModelInterface",
"$",
"model",
",",
"PropertyValueBagInterface",
"$",
"propertyValuesBag",
",",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"properties",
"=",
"$",
"environment",
"->",
"getDataDefinition",
"(",
")",
"->",
"getPropertiesDefinition",
"(",
")",
";",
"$",
"selectProperties",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getPropertiesFromSession",
"(",
"$",
"action",
",",
"$",
"environment",
")",
";",
"$",
"modelId",
"=",
"ModelId",
"::",
"fromModel",
"(",
"$",
"model",
")",
";",
"$",
"dataProvider",
"=",
"$",
"environment",
"->",
"getDataProvider",
"(",
"$",
"modelId",
"->",
"getDataProviderName",
"(",
")",
")",
";",
"$",
"editModel",
"=",
"$",
"dataProvider",
"->",
"fetch",
"(",
"$",
"dataProvider",
"->",
"getEmptyConfig",
"(",
")",
"->",
"setId",
"(",
"$",
"modelId",
"->",
"getId",
"(",
")",
")",
")",
";",
"$",
"visibleModel",
"=",
"$",
"this",
"->",
"getVisibleModel",
"(",
"$",
"action",
",",
"$",
"editModel",
",",
"$",
"dataProvider",
",",
"$",
"environment",
")",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"selectProperties",
"as",
"$",
"selectProperty",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ensurePropertyVisibleInModel",
"(",
"$",
"action",
",",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
",",
"$",
"visibleModel",
",",
"$",
"environment",
")",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"$",
"this",
"->",
"injectSelectParentPropertyInformation",
"(",
"$",
"action",
",",
"$",
"selectProperty",
",",
"$",
"editModel",
",",
"$",
"environment",
")",
";",
"continue",
";",
"}",
"$",
"editProperty",
"=",
"$",
"this",
"->",
"buildEditProperty",
"(",
"$",
"selectProperty",
",",
"$",
"modelId",
")",
";",
"$",
"properties",
"->",
"addProperty",
"(",
"$",
"editProperty",
")",
";",
"$",
"this",
"->",
"setPropertyValue",
"(",
"$",
"editModel",
",",
"$",
"selectProperty",
",",
"$",
"propertyValuesBag",
")",
";",
"$",
"this",
"->",
"markEditErrors",
"(",
"$",
"editProperty",
",",
"$",
"selectProperty",
",",
"$",
"propertyValuesBag",
")",
";",
"$",
"this",
"->",
"markModelErrors",
"(",
"$",
"action",
",",
"$",
"model",
",",
"$",
"model",
",",
"$",
"editProperty",
",",
"$",
"selectProperty",
",",
"$",
"propertyValuesBag",
",",
"$",
"environment",
")",
";",
"$",
"fields",
"[",
"]",
"=",
"$",
"widgetManager",
"->",
"renderWidget",
"(",
"$",
"editProperty",
"->",
"getName",
"(",
")",
",",
"false",
",",
"$",
"propertyValuesBag",
")",
";",
"$",
"fields",
"[",
"]",
"=",
"$",
"this",
"->",
"injectSelectSubPropertiesInformation",
"(",
"$",
"selectProperty",
",",
"$",
"editModel",
",",
"$",
"propertyValuesBag",
",",
"$",
"environment",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"fields",
"[",
"0",
"]",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'<p> </p><strong>%s</strong><p> </p>'",
",",
"$",
"environment",
"->",
"getTranslator",
"(",
")",
"->",
"translate",
"(",
"'MSC.no_properties_available'",
")",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
]
| Render the edit fields.
@param Action $action The action.
@param ContaoWidgetManager $widgetManager The widget manager.
@param ModelInterface $model The model.
@param PropertyValueBagInterface $propertyValuesBag The property values.
@param EnvironmentInterface $environment The environment.
@return array
@SuppressWarnings(PHPMD.Superglobals) | [
"Render",
"the",
"edit",
"fields",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L198-L261 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.getVisibleModel | private function getVisibleModel(
Action $action,
ModelInterface $editModel,
DataProviderInterface $dataProvider,
EnvironmentInterface $environment
) {
$selectProperties = (array) $this->getPropertiesFromSession($action, $environment);
$visibleModel = $dataProvider->getEmptyModel();
$visibleModel->setId($editModel->getId());
$widgetManager = new ContaoWidgetManager($environment, $editModel);
$propertyValueBag = new PropertyValueBag();
foreach (\array_keys($selectProperties) as $visiblePropertyName) {
$visiblePropertyValue = $editModel->getProperty($visiblePropertyName);
$propertyValueBag->setPropertyValue($visiblePropertyName, $visiblePropertyValue);
$visibleModel->setProperty(
$visiblePropertyName,
$widgetManager->encodeValue(
$visiblePropertyName,
$widgetManager->decodeValue($visiblePropertyName, $visiblePropertyValue),
$propertyValueBag
)
);
}
return $visibleModel;
} | php | private function getVisibleModel(
Action $action,
ModelInterface $editModel,
DataProviderInterface $dataProvider,
EnvironmentInterface $environment
) {
$selectProperties = (array) $this->getPropertiesFromSession($action, $environment);
$visibleModel = $dataProvider->getEmptyModel();
$visibleModel->setId($editModel->getId());
$widgetManager = new ContaoWidgetManager($environment, $editModel);
$propertyValueBag = new PropertyValueBag();
foreach (\array_keys($selectProperties) as $visiblePropertyName) {
$visiblePropertyValue = $editModel->getProperty($visiblePropertyName);
$propertyValueBag->setPropertyValue($visiblePropertyName, $visiblePropertyValue);
$visibleModel->setProperty(
$visiblePropertyName,
$widgetManager->encodeValue(
$visiblePropertyName,
$widgetManager->decodeValue($visiblePropertyName, $visiblePropertyValue),
$propertyValueBag
)
);
}
return $visibleModel;
} | [
"private",
"function",
"getVisibleModel",
"(",
"Action",
"$",
"action",
",",
"ModelInterface",
"$",
"editModel",
",",
"DataProviderInterface",
"$",
"dataProvider",
",",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"selectProperties",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getPropertiesFromSession",
"(",
"$",
"action",
",",
"$",
"environment",
")",
";",
"$",
"visibleModel",
"=",
"$",
"dataProvider",
"->",
"getEmptyModel",
"(",
")",
";",
"$",
"visibleModel",
"->",
"setId",
"(",
"$",
"editModel",
"->",
"getId",
"(",
")",
")",
";",
"$",
"widgetManager",
"=",
"new",
"ContaoWidgetManager",
"(",
"$",
"environment",
",",
"$",
"editModel",
")",
";",
"$",
"propertyValueBag",
"=",
"new",
"PropertyValueBag",
"(",
")",
";",
"foreach",
"(",
"\\",
"array_keys",
"(",
"$",
"selectProperties",
")",
"as",
"$",
"visiblePropertyName",
")",
"{",
"$",
"visiblePropertyValue",
"=",
"$",
"editModel",
"->",
"getProperty",
"(",
"$",
"visiblePropertyName",
")",
";",
"$",
"propertyValueBag",
"->",
"setPropertyValue",
"(",
"$",
"visiblePropertyName",
",",
"$",
"visiblePropertyValue",
")",
";",
"$",
"visibleModel",
"->",
"setProperty",
"(",
"$",
"visiblePropertyName",
",",
"$",
"widgetManager",
"->",
"encodeValue",
"(",
"$",
"visiblePropertyName",
",",
"$",
"widgetManager",
"->",
"decodeValue",
"(",
"$",
"visiblePropertyName",
",",
"$",
"visiblePropertyValue",
")",
",",
"$",
"propertyValueBag",
")",
")",
";",
"}",
"return",
"$",
"visibleModel",
";",
"}"
]
| Get the visible model.
@param Action $action The action.
@param ModelInterface $editModel The edit model.
@param DataProviderInterface $dataProvider The data provider.
@param EnvironmentInterface $environment The environment.
@return ModelInterface | [
"Get",
"the",
"visible",
"model",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L273-L303 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.markEditErrors | private function markEditErrors(
PropertyInterface $editProperty,
PropertyInterface $selectProperty,
PropertyValueBagInterface $propertyValuesBag
) {
if (($editErrors = $propertyValuesBag->getInvalidPropertyErrors())
&& \array_key_exists($selectProperty->getName(), $editErrors)
) {
$propertyValuesBag->markPropertyValueAsInvalid(
$editProperty->getName(),
$editErrors[$selectProperty->getName()]
);
}
} | php | private function markEditErrors(
PropertyInterface $editProperty,
PropertyInterface $selectProperty,
PropertyValueBagInterface $propertyValuesBag
) {
if (($editErrors = $propertyValuesBag->getInvalidPropertyErrors())
&& \array_key_exists($selectProperty->getName(), $editErrors)
) {
$propertyValuesBag->markPropertyValueAsInvalid(
$editProperty->getName(),
$editErrors[$selectProperty->getName()]
);
}
} | [
"private",
"function",
"markEditErrors",
"(",
"PropertyInterface",
"$",
"editProperty",
",",
"PropertyInterface",
"$",
"selectProperty",
",",
"PropertyValueBagInterface",
"$",
"propertyValuesBag",
")",
"{",
"if",
"(",
"(",
"$",
"editErrors",
"=",
"$",
"propertyValuesBag",
"->",
"getInvalidPropertyErrors",
"(",
")",
")",
"&&",
"\\",
"array_key_exists",
"(",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
",",
"$",
"editErrors",
")",
")",
"{",
"$",
"propertyValuesBag",
"->",
"markPropertyValueAsInvalid",
"(",
"$",
"editProperty",
"->",
"getName",
"(",
")",
",",
"$",
"editErrors",
"[",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"}"
]
| Mark edit errors.
@param PropertyInterface $editProperty The edit property.
@param PropertyInterface $selectProperty The select property.
@param PropertyValueBagInterface $propertyValuesBag The property values.
@return void | [
"Mark",
"edit",
"errors",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L336-L349 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.markModelErrors | private function markModelErrors(
Action $action,
ModelInterface $model,
ModelInterface $editModel,
PropertyInterface $editProperty,
PropertyInterface $selectProperty,
PropertyValueBagInterface $propertyValuesBag,
EnvironmentInterface $environment
) {
$editInformation = $GLOBALS['container']['dc-general.edit-information'];
$sessionValues = $this->getEditPropertiesByModelId($action, ModelId::fromModel($model), $environment);
$modelError = $editInformation->getModelError($editModel);
if ($modelError && isset($modelError[$selectProperty->getName()])) {
$propertyValuesBag->setPropertyValue(
$editProperty->getName(),
$sessionValues[$selectProperty->getName()]
);
$propertyValuesBag->setPropertyValue(
$selectProperty->getName(),
$sessionValues[$selectProperty->getName()]
);
$propertyValuesBag->markPropertyValueAsInvalid(
$editProperty->getName(),
$modelError[$selectProperty->getName()]
);
}
} | php | private function markModelErrors(
Action $action,
ModelInterface $model,
ModelInterface $editModel,
PropertyInterface $editProperty,
PropertyInterface $selectProperty,
PropertyValueBagInterface $propertyValuesBag,
EnvironmentInterface $environment
) {
$editInformation = $GLOBALS['container']['dc-general.edit-information'];
$sessionValues = $this->getEditPropertiesByModelId($action, ModelId::fromModel($model), $environment);
$modelError = $editInformation->getModelError($editModel);
if ($modelError && isset($modelError[$selectProperty->getName()])) {
$propertyValuesBag->setPropertyValue(
$editProperty->getName(),
$sessionValues[$selectProperty->getName()]
);
$propertyValuesBag->setPropertyValue(
$selectProperty->getName(),
$sessionValues[$selectProperty->getName()]
);
$propertyValuesBag->markPropertyValueAsInvalid(
$editProperty->getName(),
$modelError[$selectProperty->getName()]
);
}
} | [
"private",
"function",
"markModelErrors",
"(",
"Action",
"$",
"action",
",",
"ModelInterface",
"$",
"model",
",",
"ModelInterface",
"$",
"editModel",
",",
"PropertyInterface",
"$",
"editProperty",
",",
"PropertyInterface",
"$",
"selectProperty",
",",
"PropertyValueBagInterface",
"$",
"propertyValuesBag",
",",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"editInformation",
"=",
"$",
"GLOBALS",
"[",
"'container'",
"]",
"[",
"'dc-general.edit-information'",
"]",
";",
"$",
"sessionValues",
"=",
"$",
"this",
"->",
"getEditPropertiesByModelId",
"(",
"$",
"action",
",",
"ModelId",
"::",
"fromModel",
"(",
"$",
"model",
")",
",",
"$",
"environment",
")",
";",
"$",
"modelError",
"=",
"$",
"editInformation",
"->",
"getModelError",
"(",
"$",
"editModel",
")",
";",
"if",
"(",
"$",
"modelError",
"&&",
"isset",
"(",
"$",
"modelError",
"[",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"propertyValuesBag",
"->",
"setPropertyValue",
"(",
"$",
"editProperty",
"->",
"getName",
"(",
")",
",",
"$",
"sessionValues",
"[",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
"]",
")",
";",
"$",
"propertyValuesBag",
"->",
"setPropertyValue",
"(",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
",",
"$",
"sessionValues",
"[",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
"]",
")",
";",
"$",
"propertyValuesBag",
"->",
"markPropertyValueAsInvalid",
"(",
"$",
"editProperty",
"->",
"getName",
"(",
")",
",",
"$",
"modelError",
"[",
"$",
"selectProperty",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"}"
]
| Mark model errors.
@param Action $action The action.
@param ModelInterface $model The model.
@param ModelInterface $editModel The edit model.
@param PropertyInterface $editProperty The edit property.
@param PropertyInterface $selectProperty The select property.
@param PropertyValueBagInterface $propertyValuesBag The properties values.
@param EnvironmentInterface $environment The environment.
@return void
@SuppressWarnings(PHPMD.Superglobals) | [
"Mark",
"model",
"errors",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L366-L395 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.handleEditCollection | private function handleEditCollection(
Action $action,
PropertyValueBagInterface $editPropertyValuesBag,
ModelInterface $model,
\ArrayObject $renderInformation,
EnvironmentInterface $environment
) {
$dataProvider = $environment->getDataProvider($model->getProviderName());
$editCollection = $dataProvider->getEmptyCollection();
$revertCollection = $dataProvider->getEmptyCollection();
$editCollection->push($model);
$revertModel = clone $model;
$revertModel->setId($model->getId());
$revertCollection->push($model);
$this->editCollection($action, $editCollection, $editPropertyValuesBag, $renderInformation, $environment);
$this->revertValuesByErrors($action, $revertCollection, $environment);
} | php | private function handleEditCollection(
Action $action,
PropertyValueBagInterface $editPropertyValuesBag,
ModelInterface $model,
\ArrayObject $renderInformation,
EnvironmentInterface $environment
) {
$dataProvider = $environment->getDataProvider($model->getProviderName());
$editCollection = $dataProvider->getEmptyCollection();
$revertCollection = $dataProvider->getEmptyCollection();
$editCollection->push($model);
$revertModel = clone $model;
$revertModel->setId($model->getId());
$revertCollection->push($model);
$this->editCollection($action, $editCollection, $editPropertyValuesBag, $renderInformation, $environment);
$this->revertValuesByErrors($action, $revertCollection, $environment);
} | [
"private",
"function",
"handleEditCollection",
"(",
"Action",
"$",
"action",
",",
"PropertyValueBagInterface",
"$",
"editPropertyValuesBag",
",",
"ModelInterface",
"$",
"model",
",",
"\\",
"ArrayObject",
"$",
"renderInformation",
",",
"EnvironmentInterface",
"$",
"environment",
")",
"{",
"$",
"dataProvider",
"=",
"$",
"environment",
"->",
"getDataProvider",
"(",
"$",
"model",
"->",
"getProviderName",
"(",
")",
")",
";",
"$",
"editCollection",
"=",
"$",
"dataProvider",
"->",
"getEmptyCollection",
"(",
")",
";",
"$",
"revertCollection",
"=",
"$",
"dataProvider",
"->",
"getEmptyCollection",
"(",
")",
";",
"$",
"editCollection",
"->",
"push",
"(",
"$",
"model",
")",
";",
"$",
"revertModel",
"=",
"clone",
"$",
"model",
";",
"$",
"revertModel",
"->",
"setId",
"(",
"$",
"model",
"->",
"getId",
"(",
")",
")",
";",
"$",
"revertCollection",
"->",
"push",
"(",
"$",
"model",
")",
";",
"$",
"this",
"->",
"editCollection",
"(",
"$",
"action",
",",
"$",
"editCollection",
",",
"$",
"editPropertyValuesBag",
",",
"$",
"renderInformation",
",",
"$",
"environment",
")",
";",
"$",
"this",
"->",
"revertValuesByErrors",
"(",
"$",
"action",
",",
"$",
"revertCollection",
",",
"$",
"environment",
")",
";",
"}"
]
| Handle edit collection of models.
@param Action $action The action.
@param PropertyValueBagInterface $editPropertyValuesBag The property values.
@param ModelInterface $model The model.
@param \ArrayObject $renderInformation The render information.
@param EnvironmentInterface $environment The environment.
@return void | [
"Handle",
"edit",
"collection",
"of",
"models",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L408-L428 | train |
contao-community-alliance/dc-general | src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php | EditAllHandler.buildEditProperty | private function buildEditProperty(PropertyInterface $originalProperty, ModelIdInterface $modelId)
{
$editPropertyClass = \get_class($originalProperty);
$editPropertyName = \str_replace('::', '____', $modelId->getSerialized()) . '_' . $originalProperty->getName();
$editProperty = new $editPropertyClass($editPropertyName);
$editProperty->setLabel($originalProperty->getLabel());
$editProperty->setDescription($originalProperty->getDescription());
$editProperty->setDefaultValue($editProperty->getDefaultValue());
$editProperty->setExcluded($originalProperty->isExcluded());
$editProperty->setSearchable($originalProperty->isSearchable());
$editProperty->setFilterable($originalProperty->isFilterable());
$editProperty->setWidgetType($originalProperty->getWidgetType());
$editProperty->setOptions($originalProperty->getOptions());
$editProperty->setExplanation($originalProperty->getExplanation());
$editProperty->setExtra($originalProperty->getExtra());
return $editProperty;
} | php | private function buildEditProperty(PropertyInterface $originalProperty, ModelIdInterface $modelId)
{
$editPropertyClass = \get_class($originalProperty);
$editPropertyName = \str_replace('::', '____', $modelId->getSerialized()) . '_' . $originalProperty->getName();
$editProperty = new $editPropertyClass($editPropertyName);
$editProperty->setLabel($originalProperty->getLabel());
$editProperty->setDescription($originalProperty->getDescription());
$editProperty->setDefaultValue($editProperty->getDefaultValue());
$editProperty->setExcluded($originalProperty->isExcluded());
$editProperty->setSearchable($originalProperty->isSearchable());
$editProperty->setFilterable($originalProperty->isFilterable());
$editProperty->setWidgetType($originalProperty->getWidgetType());
$editProperty->setOptions($originalProperty->getOptions());
$editProperty->setExplanation($originalProperty->getExplanation());
$editProperty->setExtra($originalProperty->getExtra());
return $editProperty;
} | [
"private",
"function",
"buildEditProperty",
"(",
"PropertyInterface",
"$",
"originalProperty",
",",
"ModelIdInterface",
"$",
"modelId",
")",
"{",
"$",
"editPropertyClass",
"=",
"\\",
"get_class",
"(",
"$",
"originalProperty",
")",
";",
"$",
"editPropertyName",
"=",
"\\",
"str_replace",
"(",
"'::'",
",",
"'____'",
",",
"$",
"modelId",
"->",
"getSerialized",
"(",
")",
")",
".",
"'_'",
".",
"$",
"originalProperty",
"->",
"getName",
"(",
")",
";",
"$",
"editProperty",
"=",
"new",
"$",
"editPropertyClass",
"(",
"$",
"editPropertyName",
")",
";",
"$",
"editProperty",
"->",
"setLabel",
"(",
"$",
"originalProperty",
"->",
"getLabel",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setDescription",
"(",
"$",
"originalProperty",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setDefaultValue",
"(",
"$",
"editProperty",
"->",
"getDefaultValue",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setExcluded",
"(",
"$",
"originalProperty",
"->",
"isExcluded",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setSearchable",
"(",
"$",
"originalProperty",
"->",
"isSearchable",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setFilterable",
"(",
"$",
"originalProperty",
"->",
"isFilterable",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setWidgetType",
"(",
"$",
"originalProperty",
"->",
"getWidgetType",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setOptions",
"(",
"$",
"originalProperty",
"->",
"getOptions",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setExplanation",
"(",
"$",
"originalProperty",
"->",
"getExplanation",
"(",
")",
")",
";",
"$",
"editProperty",
"->",
"setExtra",
"(",
"$",
"originalProperty",
"->",
"getExtra",
"(",
")",
")",
";",
"return",
"$",
"editProperty",
";",
"}"
]
| Build edit property from the original property.
@param PropertyInterface $originalProperty The original property.
@param ModelIdInterface $modelId The model id.
@return PropertyInterface | [
"Build",
"edit",
"property",
"from",
"the",
"original",
"property",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/EditAllHandler.php#L438-L457 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setPaletteCollectionClassName | public function setPaletteCollectionClassName($paletteCollectionClassName)
{
$event = new SetPaletteCollectionClassNameEvent($paletteCollectionClassName, $this);
$this->dispatchEvent($event);
$paletteCollectionClassName = $event->getPaletteCollectionClassName();
$this->paletteCollectionClassName = (string) $paletteCollectionClassName;
$this->paletteCollectionClass = new \ReflectionClass($this->paletteCollectionClassName);
return $this;
} | php | public function setPaletteCollectionClassName($paletteCollectionClassName)
{
$event = new SetPaletteCollectionClassNameEvent($paletteCollectionClassName, $this);
$this->dispatchEvent($event);
$paletteCollectionClassName = $event->getPaletteCollectionClassName();
$this->paletteCollectionClassName = (string) $paletteCollectionClassName;
$this->paletteCollectionClass = new \ReflectionClass($this->paletteCollectionClassName);
return $this;
} | [
"public",
"function",
"setPaletteCollectionClassName",
"(",
"$",
"paletteCollectionClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetPaletteCollectionClassNameEvent",
"(",
"$",
"paletteCollectionClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"paletteCollectionClassName",
"=",
"$",
"event",
"->",
"getPaletteCollectionClassName",
"(",
")",
";",
"$",
"this",
"->",
"paletteCollectionClassName",
"=",
"(",
"string",
")",
"$",
"paletteCollectionClassName",
";",
"$",
"this",
"->",
"paletteCollectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"paletteCollectionClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the palette collection class name.
@param string $paletteCollectionClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"palette",
"collection",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L316-L325 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setPaletteClassName | public function setPaletteClassName($paletteClassName)
{
$event = new SetPaletteClassNameEvent($paletteClassName, $this);
$this->dispatchEvent($event);
$paletteClassName = $event->getPaletteClassName();
$this->paletteClassName = (string) $paletteClassName;
$this->paletteClass = new \ReflectionClass($this->paletteClassName);
return $this;
} | php | public function setPaletteClassName($paletteClassName)
{
$event = new SetPaletteClassNameEvent($paletteClassName, $this);
$this->dispatchEvent($event);
$paletteClassName = $event->getPaletteClassName();
$this->paletteClassName = (string) $paletteClassName;
$this->paletteClass = new \ReflectionClass($this->paletteClassName);
return $this;
} | [
"public",
"function",
"setPaletteClassName",
"(",
"$",
"paletteClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetPaletteClassNameEvent",
"(",
"$",
"paletteClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"paletteClassName",
"=",
"$",
"event",
"->",
"getPaletteClassName",
"(",
")",
";",
"$",
"this",
"->",
"paletteClassName",
"=",
"(",
"string",
")",
"$",
"paletteClassName",
";",
"$",
"this",
"->",
"paletteClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"paletteClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the palette class name.
@param string $paletteClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"palette",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L344-L353 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setLegendClassName | public function setLegendClassName($legendClassName)
{
$event = new SetLegendClassNameEvent($legendClassName, $this);
$this->dispatchEvent($event);
$legendClassName = $event->getLegendClassName();
$this->legendClassName = (string) $legendClassName;
$this->legendClass = new \ReflectionClass($this->legendClassName);
return $this;
} | php | public function setLegendClassName($legendClassName)
{
$event = new SetLegendClassNameEvent($legendClassName, $this);
$this->dispatchEvent($event);
$legendClassName = $event->getLegendClassName();
$this->legendClassName = (string) $legendClassName;
$this->legendClass = new \ReflectionClass($this->legendClassName);
return $this;
} | [
"public",
"function",
"setLegendClassName",
"(",
"$",
"legendClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetLegendClassNameEvent",
"(",
"$",
"legendClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"legendClassName",
"=",
"$",
"event",
"->",
"getLegendClassName",
"(",
")",
";",
"$",
"this",
"->",
"legendClassName",
"=",
"(",
"string",
")",
"$",
"legendClassName",
";",
"$",
"this",
"->",
"legendClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"legendClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the legend class name.
@param string $legendClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"legend",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L372-L381 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setPropertyClassName | public function setPropertyClassName($propertyClassName)
{
$event = new SetPropertyClassNameEvent($propertyClassName, $this);
$this->dispatchEvent($event);
$propertyClassName = $event->getPropertyClassName();
$this->propertyClassName = (string) $propertyClassName;
$this->propertyClass = new \ReflectionClass($this->propertyClassName);
return $this;
} | php | public function setPropertyClassName($propertyClassName)
{
$event = new SetPropertyClassNameEvent($propertyClassName, $this);
$this->dispatchEvent($event);
$propertyClassName = $event->getPropertyClassName();
$this->propertyClassName = (string) $propertyClassName;
$this->propertyClass = new \ReflectionClass($this->propertyClassName);
return $this;
} | [
"public",
"function",
"setPropertyClassName",
"(",
"$",
"propertyClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetPropertyClassNameEvent",
"(",
"$",
"propertyClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"propertyClassName",
"=",
"$",
"event",
"->",
"getPropertyClassName",
"(",
")",
";",
"$",
"this",
"->",
"propertyClassName",
"=",
"(",
"string",
")",
"$",
"propertyClassName",
";",
"$",
"this",
"->",
"propertyClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"propertyClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the property class name.
@param string $propertyClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"property",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L400-L409 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setPaletteConditionChainClassName | public function setPaletteConditionChainClassName($paletteConditionChainClassName)
{
$event = new SetPaletteConditionChainClassNameEvent($paletteConditionChainClassName, $this);
$this->dispatchEvent($event);
$paletteConditionChainClassName = $event->getPaletteConditionChainClassName();
$this->paletteConditionChainClassName = (string) $paletteConditionChainClassName;
$this->paletteConditionChainClass = new \ReflectionClass($this->paletteConditionChainClassName);
return $this;
} | php | public function setPaletteConditionChainClassName($paletteConditionChainClassName)
{
$event = new SetPaletteConditionChainClassNameEvent($paletteConditionChainClassName, $this);
$this->dispatchEvent($event);
$paletteConditionChainClassName = $event->getPaletteConditionChainClassName();
$this->paletteConditionChainClassName = (string) $paletteConditionChainClassName;
$this->paletteConditionChainClass = new \ReflectionClass($this->paletteConditionChainClassName);
return $this;
} | [
"public",
"function",
"setPaletteConditionChainClassName",
"(",
"$",
"paletteConditionChainClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetPaletteConditionChainClassNameEvent",
"(",
"$",
"paletteConditionChainClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"paletteConditionChainClassName",
"=",
"$",
"event",
"->",
"getPaletteConditionChainClassName",
"(",
")",
";",
"$",
"this",
"->",
"paletteConditionChainClassName",
"=",
"(",
"string",
")",
"$",
"paletteConditionChainClassName",
";",
"$",
"this",
"->",
"paletteConditionChainClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"paletteConditionChainClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the palette condition chain class name.
@param string $paletteConditionChainClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"palette",
"condition",
"chain",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L428-L437 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setDefaultPaletteConditionClassName | public function setDefaultPaletteConditionClassName($defaultPaletteConditionClassName)
{
$event = new SetDefaultPaletteConditionClassNameEvent($defaultPaletteConditionClassName, $this);
$this->dispatchEvent($event);
$defaultPaletteConditionClassName = $event->getDefaultPaletteConditionClassName();
$this->defaultPaletteConditionClassName = (string) $defaultPaletteConditionClassName;
$this->defaultPaletteConditionClass = new \ReflectionClass($this->defaultPaletteConditionClassName);
return $this;
} | php | public function setDefaultPaletteConditionClassName($defaultPaletteConditionClassName)
{
$event = new SetDefaultPaletteConditionClassNameEvent($defaultPaletteConditionClassName, $this);
$this->dispatchEvent($event);
$defaultPaletteConditionClassName = $event->getDefaultPaletteConditionClassName();
$this->defaultPaletteConditionClassName = (string) $defaultPaletteConditionClassName;
$this->defaultPaletteConditionClass = new \ReflectionClass($this->defaultPaletteConditionClassName);
return $this;
} | [
"public",
"function",
"setDefaultPaletteConditionClassName",
"(",
"$",
"defaultPaletteConditionClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetDefaultPaletteConditionClassNameEvent",
"(",
"$",
"defaultPaletteConditionClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"defaultPaletteConditionClassName",
"=",
"$",
"event",
"->",
"getDefaultPaletteConditionClassName",
"(",
")",
";",
"$",
"this",
"->",
"defaultPaletteConditionClassName",
"=",
"(",
"string",
")",
"$",
"defaultPaletteConditionClassName",
";",
"$",
"this",
"->",
"defaultPaletteConditionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"defaultPaletteConditionClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the default palette condition class name.
@param string $defaultPaletteConditionClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"default",
"palette",
"condition",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L466-L475 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setPalettePropertyValueConditionClassName | public function setPalettePropertyValueConditionClassName($palettePropertyValueConditionClassName)
{
$event = new SetPalettePropertyValueConditionClassNameEvent($palettePropertyValueConditionClassName, $this);
$this->dispatchEvent($event);
$palettePropertyValueConditionClassName = $event->getPalettePropertyValueConditionClassName();
$this->palettePropertyValueConditionClassName = (string) $palettePropertyValueConditionClassName;
$this->palettePropertyValueConditionClass = new \ReflectionClass(
$this->palettePropertyValueConditionClassName
);
return $this;
} | php | public function setPalettePropertyValueConditionClassName($palettePropertyValueConditionClassName)
{
$event = new SetPalettePropertyValueConditionClassNameEvent($palettePropertyValueConditionClassName, $this);
$this->dispatchEvent($event);
$palettePropertyValueConditionClassName = $event->getPalettePropertyValueConditionClassName();
$this->palettePropertyValueConditionClassName = (string) $palettePropertyValueConditionClassName;
$this->palettePropertyValueConditionClass = new \ReflectionClass(
$this->palettePropertyValueConditionClassName
);
return $this;
} | [
"public",
"function",
"setPalettePropertyValueConditionClassName",
"(",
"$",
"palettePropertyValueConditionClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetPalettePropertyValueConditionClassNameEvent",
"(",
"$",
"palettePropertyValueConditionClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"palettePropertyValueConditionClassName",
"=",
"$",
"event",
"->",
"getPalettePropertyValueConditionClassName",
"(",
")",
";",
"$",
"this",
"->",
"palettePropertyValueConditionClassName",
"=",
"(",
"string",
")",
"$",
"palettePropertyValueConditionClassName",
";",
"$",
"this",
"->",
"palettePropertyValueConditionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"palettePropertyValueConditionClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the palette property value condition class name.
@param string $palettePropertyValueConditionClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"palette",
"property",
"value",
"condition",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L494-L505 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setPropertyConditionChainClassName | public function setPropertyConditionChainClassName($propertyConditionChainClassName)
{
$event = new SetPropertyConditionChainClassNameEvent($propertyConditionChainClassName, $this);
$this->dispatchEvent($event);
$propertyConditionChainClassName = $event->getPalettePropertyConditionChainClassName();
$this->propertyConditionChainClassName = (string) $propertyConditionChainClassName;
$this->propertyConditionChainClass = new \ReflectionClass($this->propertyConditionChainClassName);
return $this;
} | php | public function setPropertyConditionChainClassName($propertyConditionChainClassName)
{
$event = new SetPropertyConditionChainClassNameEvent($propertyConditionChainClassName, $this);
$this->dispatchEvent($event);
$propertyConditionChainClassName = $event->getPalettePropertyConditionChainClassName();
$this->propertyConditionChainClassName = (string) $propertyConditionChainClassName;
$this->propertyConditionChainClass = new \ReflectionClass($this->propertyConditionChainClassName);
return $this;
} | [
"public",
"function",
"setPropertyConditionChainClassName",
"(",
"$",
"propertyConditionChainClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetPropertyConditionChainClassNameEvent",
"(",
"$",
"propertyConditionChainClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"propertyConditionChainClassName",
"=",
"$",
"event",
"->",
"getPalettePropertyConditionChainClassName",
"(",
")",
";",
"$",
"this",
"->",
"propertyConditionChainClassName",
"=",
"(",
"string",
")",
"$",
"propertyConditionChainClassName",
";",
"$",
"this",
"->",
"propertyConditionChainClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"propertyConditionChainClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the property condition chain class name.
@param string $propertyConditionChainClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"property",
"condition",
"chain",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L524-L533 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.setPropertyValueConditionClassName | public function setPropertyValueConditionClassName($propertyValueConditionClassName)
{
$event = new SetPropertyValueConditionClassNameEvent($propertyValueConditionClassName, $this);
$this->dispatchEvent($event);
$propertyValueConditionClassName = $event->getPropertyValueConditionClassName();
$this->propertyValueConditionClassName = (string) $propertyValueConditionClassName;
$this->propertyValueConditionClass = new \ReflectionClass($this->propertyValueConditionClassName);
return $this;
} | php | public function setPropertyValueConditionClassName($propertyValueConditionClassName)
{
$event = new SetPropertyValueConditionClassNameEvent($propertyValueConditionClassName, $this);
$this->dispatchEvent($event);
$propertyValueConditionClassName = $event->getPropertyValueConditionClassName();
$this->propertyValueConditionClassName = (string) $propertyValueConditionClassName;
$this->propertyValueConditionClass = new \ReflectionClass($this->propertyValueConditionClassName);
return $this;
} | [
"public",
"function",
"setPropertyValueConditionClassName",
"(",
"$",
"propertyValueConditionClassName",
")",
"{",
"$",
"event",
"=",
"new",
"SetPropertyValueConditionClassNameEvent",
"(",
"$",
"propertyValueConditionClassName",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"propertyValueConditionClassName",
"=",
"$",
"event",
"->",
"getPropertyValueConditionClassName",
"(",
")",
";",
"$",
"this",
"->",
"propertyValueConditionClassName",
"=",
"(",
"string",
")",
"$",
"propertyValueConditionClassName",
";",
"$",
"this",
"->",
"propertyValueConditionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"propertyValueConditionClassName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the property value condition class name.
@param string $propertyValueConditionClassName The class name.
@return PaletteBuilder | [
"Set",
"the",
"property",
"value",
"condition",
"class",
"name",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L552-L561 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.usePaletteCollection | public function usePaletteCollection(PaletteCollectionInterface $paletteCollection)
{
if ($this->paletteCollection) {
$this->finishPaletteCollection();
}
$event = new UsePaletteCollectionEvent($paletteCollection, $this);
$this->dispatchEvent($event);
$this->paletteCollection = $paletteCollection;
return $this;
} | php | public function usePaletteCollection(PaletteCollectionInterface $paletteCollection)
{
if ($this->paletteCollection) {
$this->finishPaletteCollection();
}
$event = new UsePaletteCollectionEvent($paletteCollection, $this);
$this->dispatchEvent($event);
$this->paletteCollection = $paletteCollection;
return $this;
} | [
"public",
"function",
"usePaletteCollection",
"(",
"PaletteCollectionInterface",
"$",
"paletteCollection",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"paletteCollection",
")",
"{",
"$",
"this",
"->",
"finishPaletteCollection",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"UsePaletteCollectionEvent",
"(",
"$",
"paletteCollection",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"paletteCollection",
"=",
"$",
"paletteCollection",
";",
"return",
"$",
"this",
";",
"}"
]
| Reuse an existing palette collection.
@param PaletteCollectionInterface $paletteCollection The palette collection to reuse.
@return PaletteBuilder | [
"Reuse",
"an",
"existing",
"palette",
"collection",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L620-L631 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.createPaletteCollection | public function createPaletteCollection()
{
if ($this->paletteCollection) {
$this->finishPaletteCollection();
}
$paletteCollection = $this->paletteCollectionClass->newInstance();
$event = new CreatePaletteCollectionEvent($paletteCollection, $this);
$this->dispatchEvent($event);
$this->paletteCollection = $event->getPaletteCollection();
return $this;
} | php | public function createPaletteCollection()
{
if ($this->paletteCollection) {
$this->finishPaletteCollection();
}
$paletteCollection = $this->paletteCollectionClass->newInstance();
$event = new CreatePaletteCollectionEvent($paletteCollection, $this);
$this->dispatchEvent($event);
$this->paletteCollection = $event->getPaletteCollection();
return $this;
} | [
"public",
"function",
"createPaletteCollection",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"paletteCollection",
")",
"{",
"$",
"this",
"->",
"finishPaletteCollection",
"(",
")",
";",
"}",
"$",
"paletteCollection",
"=",
"$",
"this",
"->",
"paletteCollectionClass",
"->",
"newInstance",
"(",
")",
";",
"$",
"event",
"=",
"new",
"CreatePaletteCollectionEvent",
"(",
"$",
"paletteCollection",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"paletteCollection",
"=",
"$",
"event",
"->",
"getPaletteCollection",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Start a new palette collection.
@return PaletteBuilder | [
"Start",
"a",
"new",
"palette",
"collection",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L638-L651 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.finishPaletteCollection | public function finishPaletteCollection(&$collection = null)
{
if (!$this->paletteCollection) {
throw new DcGeneralRuntimeException(
'Palette collection is missing, please create a palette collection first'
);
}
if ($this->palette) {
$this->finishPalette();
}
$event = new FinishPaletteCollectionEvent($this->paletteCollection, $this);
$this->dispatchEvent($event);
$collection = $event->getPaletteCollection();
$this->paletteCollection = null;
return $this;
} | php | public function finishPaletteCollection(&$collection = null)
{
if (!$this->paletteCollection) {
throw new DcGeneralRuntimeException(
'Palette collection is missing, please create a palette collection first'
);
}
if ($this->palette) {
$this->finishPalette();
}
$event = new FinishPaletteCollectionEvent($this->paletteCollection, $this);
$this->dispatchEvent($event);
$collection = $event->getPaletteCollection();
$this->paletteCollection = null;
return $this;
} | [
"public",
"function",
"finishPaletteCollection",
"(",
"&",
"$",
"collection",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"paletteCollection",
")",
"{",
"throw",
"new",
"DcGeneralRuntimeException",
"(",
"'Palette collection is missing, please create a palette collection first'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"palette",
")",
"{",
"$",
"this",
"->",
"finishPalette",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"FinishPaletteCollectionEvent",
"(",
"$",
"this",
"->",
"paletteCollection",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"collection",
"=",
"$",
"event",
"->",
"getPaletteCollection",
"(",
")",
";",
"$",
"this",
"->",
"paletteCollection",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Finish the current palette collection.
@param PaletteCollectionInterface $collection Return the final palette collection.
@return PaletteBuilder
@throws DcGeneralRuntimeException When no collection is stored. | [
"Finish",
"the",
"current",
"palette",
"collection",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L662-L681 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.usePalette | public function usePalette(PaletteInterface $palette)
{
if ($this->palette) {
$this->finishPalette();
}
$event = new UsePaletteEvent($palette, $this);
$this->dispatchEvent($event);
$this->palette = $palette;
return $this;
} | php | public function usePalette(PaletteInterface $palette)
{
if ($this->palette) {
$this->finishPalette();
}
$event = new UsePaletteEvent($palette, $this);
$this->dispatchEvent($event);
$this->palette = $palette;
return $this;
} | [
"public",
"function",
"usePalette",
"(",
"PaletteInterface",
"$",
"palette",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"palette",
")",
"{",
"$",
"this",
"->",
"finishPalette",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"UsePaletteEvent",
"(",
"$",
"palette",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"palette",
"=",
"$",
"palette",
";",
"return",
"$",
"this",
";",
"}"
]
| Reuse an existing palette.
@param PaletteInterface $palette The palette to reuse.
@return PaletteBuilder | [
"Reuse",
"an",
"existing",
"palette",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L690-L701 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.createPalette | public function createPalette($name = null)
{
if ($this->palette) {
$this->finishPalette();
}
$palette = $this->paletteClass->newInstance();
if ($name) {
$palette->setName($name);
}
$event = new CreatePaletteEvent($palette, $this);
$this->dispatchEvent($event);
$this->palette = $event->getPalette();
return $this;
} | php | public function createPalette($name = null)
{
if ($this->palette) {
$this->finishPalette();
}
$palette = $this->paletteClass->newInstance();
if ($name) {
$palette->setName($name);
}
$event = new CreatePaletteEvent($palette, $this);
$this->dispatchEvent($event);
$this->palette = $event->getPalette();
return $this;
} | [
"public",
"function",
"createPalette",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"palette",
")",
"{",
"$",
"this",
"->",
"finishPalette",
"(",
")",
";",
"}",
"$",
"palette",
"=",
"$",
"this",
"->",
"paletteClass",
"->",
"newInstance",
"(",
")",
";",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"palette",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"$",
"event",
"=",
"new",
"CreatePaletteEvent",
"(",
"$",
"palette",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"palette",
"=",
"$",
"event",
"->",
"getPalette",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Start a new palette.
@param string|null $name Only for backwards compatibility, We will remove palette names in the future
(deprecated).
@return PaletteBuilder | [
"Start",
"a",
"new",
"palette",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L711-L728 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.finishPalette | public function finishPalette(&$palette = null)
{
if (!$this->palette) {
throw new DcGeneralRuntimeException('Palette is missing, please create a palette first');
}
if ($this->legend) {
$this->finishLegend();
}
if ($this->condition) {
$this->finishCondition();
}
$event = new FinishPaletteEvent($this->palette, $this);
$this->dispatchEvent($event);
$palette = $event->getPalette();
if ($this->paletteCollection) {
$this->paletteCollection->addPalette($palette);
}
$this->palette = null;
return $this;
} | php | public function finishPalette(&$palette = null)
{
if (!$this->palette) {
throw new DcGeneralRuntimeException('Palette is missing, please create a palette first');
}
if ($this->legend) {
$this->finishLegend();
}
if ($this->condition) {
$this->finishCondition();
}
$event = new FinishPaletteEvent($this->palette, $this);
$this->dispatchEvent($event);
$palette = $event->getPalette();
if ($this->paletteCollection) {
$this->paletteCollection->addPalette($palette);
}
$this->palette = null;
return $this;
} | [
"public",
"function",
"finishPalette",
"(",
"&",
"$",
"palette",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"palette",
")",
"{",
"throw",
"new",
"DcGeneralRuntimeException",
"(",
"'Palette is missing, please create a palette first'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"legend",
")",
"{",
"$",
"this",
"->",
"finishLegend",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"condition",
")",
"{",
"$",
"this",
"->",
"finishCondition",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"FinishPaletteEvent",
"(",
"$",
"this",
"->",
"palette",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"palette",
"=",
"$",
"event",
"->",
"getPalette",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"paletteCollection",
")",
"{",
"$",
"this",
"->",
"paletteCollection",
"->",
"addPalette",
"(",
"$",
"palette",
")",
";",
"}",
"$",
"this",
"->",
"palette",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Finish the current palette.
@param PaletteInterface $palette Return the final palette.
@return PaletteBuilder
@throws DcGeneralRuntimeException When no palette is stored in the builder. | [
"Finish",
"the",
"current",
"palette",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L739-L763 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.useLegend | public function useLegend(LegendInterface $legend)
{
if ($this->legend) {
$this->finishLegend();
}
$event = new UseLegendEvent($legend, $this);
$this->dispatchEvent($event);
$this->legend = $legend;
return $this;
} | php | public function useLegend(LegendInterface $legend)
{
if ($this->legend) {
$this->finishLegend();
}
$event = new UseLegendEvent($legend, $this);
$this->dispatchEvent($event);
$this->legend = $legend;
return $this;
} | [
"public",
"function",
"useLegend",
"(",
"LegendInterface",
"$",
"legend",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"legend",
")",
"{",
"$",
"this",
"->",
"finishLegend",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"UseLegendEvent",
"(",
"$",
"legend",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"legend",
"=",
"$",
"legend",
";",
"return",
"$",
"this",
";",
"}"
]
| Reuse an existing legend.
@param LegendInterface $legend The legend.
@return PaletteBuilder | [
"Reuse",
"an",
"existing",
"legend",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L772-L783 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.createLegend | public function createLegend($name)
{
if ($this->legend) {
$this->finishLegend();
}
$legend = $this->legendClass->newInstance($name);
$event = new CreateLegendEvent($legend, $this);
$this->dispatchEvent($event);
$this->legend = $event->getLegend();
return $this;
} | php | public function createLegend($name)
{
if ($this->legend) {
$this->finishLegend();
}
$legend = $this->legendClass->newInstance($name);
$event = new CreateLegendEvent($legend, $this);
$this->dispatchEvent($event);
$this->legend = $event->getLegend();
return $this;
} | [
"public",
"function",
"createLegend",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"legend",
")",
"{",
"$",
"this",
"->",
"finishLegend",
"(",
")",
";",
"}",
"$",
"legend",
"=",
"$",
"this",
"->",
"legendClass",
"->",
"newInstance",
"(",
"$",
"name",
")",
";",
"$",
"event",
"=",
"new",
"CreateLegendEvent",
"(",
"$",
"legend",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"legend",
"=",
"$",
"event",
"->",
"getLegend",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Start a new legend.
@param string $name Name of the legend.
@return PaletteBuilder | [
"Start",
"a",
"new",
"legend",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L792-L805 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.finishLegend | public function finishLegend(&$legend = null)
{
if (!$this->legend) {
throw new DcGeneralRuntimeException('Legend is missing, please create a legend first');
}
if ($this->property) {
$this->finishProperty();
}
$event = new FinishLegendEvent($this->legend, $this);
$this->dispatchEvent($event);
$legend = $event->getLegend();
if ($this->palette) {
$this->palette->addLegend($legend);
}
$this->legend = null;
return $this;
} | php | public function finishLegend(&$legend = null)
{
if (!$this->legend) {
throw new DcGeneralRuntimeException('Legend is missing, please create a legend first');
}
if ($this->property) {
$this->finishProperty();
}
$event = new FinishLegendEvent($this->legend, $this);
$this->dispatchEvent($event);
$legend = $event->getLegend();
if ($this->palette) {
$this->palette->addLegend($legend);
}
$this->legend = null;
return $this;
} | [
"public",
"function",
"finishLegend",
"(",
"&",
"$",
"legend",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"legend",
")",
"{",
"throw",
"new",
"DcGeneralRuntimeException",
"(",
"'Legend is missing, please create a legend first'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"property",
")",
"{",
"$",
"this",
"->",
"finishProperty",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"FinishLegendEvent",
"(",
"$",
"this",
"->",
"legend",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"legend",
"=",
"$",
"event",
"->",
"getLegend",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"palette",
")",
"{",
"$",
"this",
"->",
"palette",
"->",
"addLegend",
"(",
"$",
"legend",
")",
";",
"}",
"$",
"this",
"->",
"legend",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Finish the current legend.
@param LegendInterface $legend Return the final legend.
@return PaletteBuilder
@throws DcGeneralRuntimeException When no legend is stored in the builder. | [
"Finish",
"the",
"current",
"legend",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L816-L837 | train |
contao-community-alliance/dc-general | src/DataDefinition/Palette/Builder/PaletteBuilder.php | PaletteBuilder.useProperty | public function useProperty($property, $_ = null)
{
if ($this->property) {
$this->finishProperty();
}
$properties = \func_get_args();
$this->property = [];
foreach ($properties as $property) {
$event = new UsePropertyEvent($property, $this);
$this->dispatchEvent($event);
$this->property[] = $property;
}
if (1 === \count($this->property)) {
$this->property = \array_shift($this->property);
}
return $this;
} | php | public function useProperty($property, $_ = null)
{
if ($this->property) {
$this->finishProperty();
}
$properties = \func_get_args();
$this->property = [];
foreach ($properties as $property) {
$event = new UsePropertyEvent($property, $this);
$this->dispatchEvent($event);
$this->property[] = $property;
}
if (1 === \count($this->property)) {
$this->property = \array_shift($this->property);
}
return $this;
} | [
"public",
"function",
"useProperty",
"(",
"$",
"property",
",",
"$",
"_",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"property",
")",
"{",
"$",
"this",
"->",
"finishProperty",
"(",
")",
";",
"}",
"$",
"properties",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"property",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"event",
"=",
"new",
"UsePropertyEvent",
"(",
"$",
"property",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"property",
"[",
"]",
"=",
"$",
"property",
";",
"}",
"if",
"(",
"1",
"===",
"\\",
"count",
"(",
"$",
"this",
"->",
"property",
")",
")",
"{",
"$",
"this",
"->",
"property",
"=",
"\\",
"array_shift",
"(",
"$",
"this",
"->",
"property",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Reuse an existing property or set of properties.
@param PropertyInterface $property The first property.
@param PropertyInterface $_ Any more subsequent properties to be used.
@return PaletteBuilder
@SuppressWarnings(PHPMD.UnusedFormalParameter)
@SuppressWarnings(PHPMD.ShortVariable)
@SuppressWarnings(PHPMD.CamelCaseParameterName) | [
"Reuse",
"an",
"existing",
"property",
"or",
"set",
"of",
"properties",
"."
]
| bf59fc2085cc848c564e40324dee14ef2897faa6 | https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/DataDefinition/Palette/Builder/PaletteBuilder.php#L851-L872 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.