protected function parsePanels(IMetaModelDataDefinition $container)
{
// Check if we have a BackendViewDef.
if ($container->hasDefinition(Contao2BackendViewDefinitionInterface::NAME)) {
/** @var Contao2BackendViewDefinitionInterface $view */
$view = $container->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
} else {
return;
}
// Get the panel layout.
$inputScreen = $this->getInputScreenDetails();
$panelLayout = $inputScreen->getPanelLayout();
// Check if we have a layout.
if (empty($panelLayout)) {
return;
}
// Get the layout from the dca.
$arrRows = trimsplit(';', $panelLayout);
// Create a new panel container.
$panel = $view->getPanelLayout();
$panelRows = $panel->getRows();
foreach ($arrRows as $rowNo => $rowElements) {
// Get the row, if we have one or create a new one.
if ($panelRows->getRowCount() < $rowNo + 1) {
$panelRow = $panelRows->addRow();
} else {
$panelRow = $panelRows->getRow($rowNo);
}
// Get the fields.
$fields = trimsplit(',', $rowElements);
$fields = array_reverse($fields);
$this->parsePanelRow($fields, $panelRow);
// If we have no entries for this row, remove it.
if ($panelRow->getCount() == 0) {
$panelRows->deleteRow($rowNo);
}
}
$this->ensureSubmitElement($panelRows);
}