Maps data from database to layout values.

@return \Netgen\BlockManager\Persistence\Values\Layout\Layout[]
979109
public function mapLayouts(array $data): array
    {
        $layouts = [];

        foreach ($data as $dataItem) {
            $layoutId = (int) $dataItem['id'];
            $locale = $dataItem['locale'];

            if (!isset($layouts[$layoutId])) {
                $layouts[$layoutId] = [
                    'id' => $layoutId,
                    'type' => $dataItem['type'],
                    'name' => $dataItem['name'],
                    'description' => $dataItem['description'],
                    'created' => (int) $dataItem['created'],
                    'modified' => (int) $dataItem['modified'],
                    'status' => (int) $dataItem['status'],
                    'shared' => (bool) $dataItem['shared'],
                    'mainLocale' => $dataItem['main_locale'],
                ];
            }

            $layouts[$layoutId]['availableLocales'][] = $locale;
        }

        return array_values(
            array_map(
                static function (array $layoutData): Layout {
                    sort($layoutData['availableLocales']);

                    return Layout::fromArray($layoutData);
                },
                $layouts
            )
        );
    }
110708
public function ColumnsList()
    {
        $list = new ArrayList();

        foreach ($this->columns as $key => $column) {
            $header     = $this->array_get($column, self::KEY_HEADER);
            $required   = $this->array_get($column, self::KEY_REQUIRED);
            $type       = $this->array_get($column, self::KEY_TYPE,
                self::TYPE_TEXT);
            $values     = $this->array_get($column, self::KEY_OPTIONS);
            $valuesList = null;

            $size = null;

            if ($type == self::TYPE_CURRENCY) {
                $type = 'text';
                $size = 7;
            }

            if ($values && is_array($values)) {
                $valuesList = new ArrayList();
                foreach ($values as $k => $v) {
                    $valuesList->push(new ArrayData(array('Name' => $k, 'Value' => $v)));
                }
            }

            $rowData = array(
                'Key' => $key,
                'Size' => $size,
                'Header' => $header,
                'Values' => $valuesList,
                'Type' => $type,
                'Required' => $required ? 'true' : 'false'
            );
            $list->push(new ArrayData($rowData));
        }
        return $list;
    }
1138436
public function tabs(): array
    {
        if ( ! $this->layout || ! count($this->layout)) {
            return [];
        }

        $tabs = [];

        foreach ($this->layout as $key => $value) {

            if ($value instanceof ModelFormTabDataInterface) {
                $tabs[ $key ] = $value;
            }
        }

        return $tabs;
    }
1286100
public function inputLayouts()
    {
        $supported = $this->supportedInputLayouts();
        $layouts   = [];
        foreach ($supported as $layout) {
            $layouts[$layout] = ($layout === $this->inputLayout());
        }

        return $layouts;
    }
509674
public function getCMSFields()
    {
        $fields = $this->scaffoldFormFields(
            array(
                // Don't allow has_many/many_many relationship editing before the record is first saved
                'includeRelations' => ($this->ID > 0),
                'tabbed' => true,
                'ajaxSafe' => true
            )
        );
        $fields->removeByName(
            array(
                'Title',
                'Instance',
                'Style',
                'Objects'
            )
        );
        if (!$this->IsMain) {
            $fields->addFieldsToTab(
                'Root.Main',
                array(
                    TextField::create(
                        'Title',
                        _t('PlaceableObject_Preset.TITLE', 'Title')
                    ),
                    DropdownField::create(
                        'Instance',
                        _t('PlaceableObject_Preset.INSTANCE', 'Instance'),
                        singleton('PlaceableObject_Preset')->dbObject('Instance')->enumValues()
                    )
                )
            );
        }
        if ($this->Styles) {
            $fields->addFieldToTab(
                'Root.Main',
                DropdownField::create(
                    'Style',
                    _t('PlaceableObject_Preset.STYLE', 'Style'),
                    $this->Styles
                )->setEmptyString(_t('PlaceableObject_Preset.DEFAULTSTYLE', 'Default'))
            );
        }
        $fields->addFieldsToTab(
            'Root.Objects',
            array(
                LabelField::create(
                    'ObjectsDescription',
                    _t('PlaceableObject_Preset.OBJECTSDESCRIPTION', 'List of all objects that use this use this preset.')
                ),
                GridField::create(
                    'Objects',
                    _t('PlaceableObject_Preset.OBJECTS', 'Objects'),
                    $this->Objects(),
                    GridFieldConfig_Base::create()
                )
            )
        );
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
903733
private function getDatatableColumns(): array
    {
        $result = $this->getDisplayColumns();

        if (!$this->getGroupByField()) {
            $result[] = Utility::MENU_PROPERTY_NAME;
        }

        if (!$this->getGroupByField() && $this->batch) {
            $table = TableRegistry::get($this->entity->get('model'));
            // add primary key in FIRST position
            foreach ((array)$table->getPrimaryKey() as $primaryKey) {
                array_unshift($result, $table->aliasField($primaryKey));
            }
        }

        return $result;
    }
692593
protected static function getBinds() {

		$db = Database::getInstance();
		$columns = $db->describeTable(static::TABLE_NAME);
		
		$maps = [];

		foreach ($columns as $col) {
			
			// get a camelCase name, with first low case
			$property = lcfirst(str_replace(' ', '', ucwords(str_replace(['_','\\'], ' ', $col->Field))));
			$maps[$property] = $col->Field;
			
		}

		return $maps;
		
	}
144453
public function layout($value = null)
    {
        if (null === $value)
            return $this->layout;
        else
            $this->layout = $value;
    }
604377
public function loadLayoutsData(array $layoutIds, bool $includeDrafts): array
    {
        $query = $this->getLayoutSelectQuery();

        if ($includeDrafts) {
            $query->leftJoin(
                'l',
                'ngbm_layout',
                'l2',
                $query->expr()->andX(
                    $query->expr()->eq('l.id', 'l2.id'),
                    $query->expr()->eq('l2.status', ':status')
                )
            );
        }

        $query->where(
            $query->expr()->in('l.id', [':layout_ids'])
        );

        $statusExpr = $query->expr()->eq('l.status', ':status');
        if ($includeDrafts) {
            $statusExpr = $query->expr()->orX(
                $statusExpr,
                $query->expr()->isNull('l2.id')
            );
        }

        $query->andWhere($statusExpr);

        $query->setParameter('layout_ids', $layoutIds, Connection::PARAM_INT_ARRAY);
        $query->setParameter('status', Value::STATUS_PUBLISHED, Type::INTEGER);

        $query->orderBy('l.name', 'ASC');

        return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
    }
74280
function listLayout(): array
    {
        if(!$this->layoutBuilt) {
            $this->buildListLayout();
            $this->layoutBuilt = true;
        }

        return collect($this->columns)->map(function(EntityListLayoutColumn $column) {
            return $column->toArray();
        })->all();
    }
749998
public function getMappedFields()
    {
        $mapped = array();

        foreach ($this->fields as $key => $value) {
            if (array_key_exists($key, $this->mappings)) {
                $map = $this->mappings[$key];
                $mapped[$map] = $value;
            }
        }

        return $mapped;
    }
819856
public function getFieldLayouts(&$context)
    {
        $context['fieldLayouts'] = [];

        foreach ($context['fields'] as $field) {

            $layouts = [];
            foreach ($this->_getRelatedLayoutIds($field) as $row) {
                $layouts[] = $this->_getLayoutData($row);
            }

            $context['fieldLayouts'][] = [
                'field'   => $field,
                'layouts' => $layouts,
            ];
        }
    }
59037
public function layout(): array
    {
        return [

            MetricsExample::class,
            ChartLineExample::class,

            Layout::columns([
                ChartPieExample::class,
                ChartBarExample::class,
            ]),

            Layout::tabs([
                'Example Tab Table' => TableExample::class,
                'Example Tab Rows'  => RowExample::class,
            ]),

            Layout::modals([
                'exampleModal' => Layout::rows([
                    Input::make('user.password')
                        ->type('test')
                        ->title(__('Example'))
                        ->placeholder(__('Example')),
                ]),
            ]),

        ];
    }
206621
public function getColumnObjectsMapping()
    {
        $mapping = array();
        $localTable = $this->getTable();
        $foreignTable = $this->getForeignTable();
        for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
            $mapping[]= array(
                'local'   => $localTable->getColumn($this->localColumns[$i]),
                'foreign' => $foreignTable->getColumn($this->foreignColumns[$i]),
            );
        }

        return $mapping;
    }
737193
public function mapLayout(PersistenceLayout $layout): Layout
    {
        try {
            $layoutType = $this->layoutTypeRegistry->getLayoutType($layout->type);
        } catch (LayoutTypeException $e) {
            $layoutType = new NullLayoutType($layout->type);
        }

        $layoutData = [
            'id' => $layout->id,
            'layoutType' => $layoutType,
            'name' => $layout->name,
            'description' => $layout->description,
            'created' => DateTimeUtils::createFromTimestamp($layout->created),
            'modified' => DateTimeUtils::createFromTimestamp($layout->modified),
            'status' => $layout->status,
            'shared' => $layout->shared,
            'mainLocale' => $layout->mainLocale,
            'availableLocales' => $layout->availableLocales,
            'zones' => new LazyCollection(
                function () use ($layout): array {
                    return array_map(
                        function (PersistenceZone $zone): Zone {
                            return $this->mapZone($zone);
                        },
                        $this->layoutHandler->loadLayoutZones($layout)
                    );
                }
            ),
        ];

        return Layout::fromArray($layoutData);
    }
382389
public function toArray(): array
	{
		$columns = $this->columns;

		// Removes protected columns from the array

		if(!empty($this->protected))
		{
			$columns = array_diff_key($columns, array_flip($this->protected));
		}

		// Mutate column values if needed

		foreach($columns as $name => $value)
		{
			$value = $this->getColumnValue($name);

			if($value instanceof DateTimeInterface)
			{
				$value = $value->format($this->dateOutputFormat);
			}

			$columns[$name] = $value;
		}

		// Merge in related records

		foreach($this->related as $relation => $related)
		{
			if(in_array($relation, $this->protected))
			{
				continue;
			}

			$columns += [$relation => ($related === false ? $related : $related->toArray())];
		}

		// Returns array representation of the record

		return $columns;
	}
60344
public function toArray()
    {
        $this->init();
        $values = [];
        foreach (array_keys($this->structureMetadata->getProperties()) as $childName) {
            $values[$childName] = $this->normalize($this->getProperty($childName)->getValue());
        }

        return $values;
    }