MetaModels\DcGeneral\Dca\Builder\Builder::parsePanels PHP Method

parsePanels() protected method

Parse the panels, if we have some one.
protected parsePanels ( MetaModels\DcGeneral\DataDefinition\IMetaModelDataDefinition $container ) : void
$container MetaModels\DcGeneral\DataDefinition\IMetaModelDataDefinition The panel container.
return void
    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);
    }