Build up meta data

@return \ViKon\DbExporter\Meta\Model[]
554016
protected function createModels()
    {
        $path           = $this->option('path');
        $namespace      = $this->option('namespace');
        $connectionName = $this->option('connection');

        $tableNames = $this->getDatabaseTableNames($connectionName);

        /** @var \ViKon\DbExporter\Meta\Model[] $models */
        $models = [];
        foreach ($tableNames as $tableName) {
            if ($this->skipTable($tableName)) {
                continue;
            }

            $models[$tableName] = new Model($connectionName, $tableName);
            $models[$tableName]->setPath($path);
            $models[$tableName]->setNamespace($namespace);
            $models[$tableName]->map();
        }

        return $models;
    }
801298
public function toArray()
    {
        return
            [
            'fields' => $this->getFieldsToArray(),
            'relations' => $this->getRelationsToArray(),
            'indexes' => $this->getIndexesToArray(),
            'auto-manage-created-and-updated-at' => $this->isCreateAndUpdateAtManaged(),
            'table-name' => $this->getTableName(),
            'protection' => $this->getRawProtections(),
        ];
    }
821094
public function to_array()
	{
		$output = array();

		// Attributes
		foreach ($this->attributes as $property => $value) {
			$output[$this->get_alias($property)] = $value;
		}

		// Meta
		foreach ($this->meta as $key => $value) {
			$alias = $this->get_alias('meta_' . $key);
			if ( $alias !=  'meta_' . $key) {
				$output[$alias] = $value;
			}
		}

		// Functions
		foreach ($this->aliases as $alias => $property) {
			if ( preg_match( '/func_/', $property ) ) {
				$function_name = preg_replace( '/func_/', '', $property );
				$output[$alias] = $this->$function_name();
			}
		}

		// Hidden
		foreach ( $this->hidden as $key ) {
			unset( $output[$key] );
		}

		return $output;
	}
716168
public function toArray()
    {
        return [
            'id' => $this->id,
            'modelType' => $this->model_type,
            'modelId' => $this->model_id,
            'name' => $this->name,
            'price' => $this->price,
            'image' => $this->image,
            'quantity' => $this->quantity,
        ];
    }
563102
public function toArray(): array
    {
        $data = [
            'meta'          => $this->getMetadata(),
            'links'         => $this->linksToArray(),
            'attributes'    => $this->getAttributes(),
            'relationships' => $this->relationshipsToArray()
        ];

        return array_merge(
            $this->resourceToArray(),
            array_filter($data, 'count')
        );
    }
927543
public function meta()
    {
        return [
            'Connection' => e($this->meta['queue']->connection),
            'Queue' => e($this->meta['queue']->tube),
            'Driver' => e($this->meta['queue']->driver),
            'Your threshold' => e($this->meta['queue']->alert_pending_jobs_greater_than),
            'Actual pending job count' => e($this->meta['pending_job_count']),
        ];
    }
151201
public function meta()
    {
        return array_merge([
            'resourceName' => $this->resourceName,
            'label' => forward_static_call([$this->resourceClass, 'label']),
            'singularLabel' => $this->singularLabel
                ?? $this->name
                ?? forward_static_call([$this->resourceClass, 'singularLabel']),
            'belongsToRelationship' => $this->belongsToRelationship,
            'belongsToId' => $this->belongsToId,
            'searchable' => $this->searchable,
            'viewable' => $this->viewable,
            'reverse' => false,
        ], $this->meta);
    }
648160
protected function buildDatabase(): DatabaseAdapter {
		$dbName = $this->determineDbName();
		$database = new PgsqlDatabase($dbName, $this->determineDbCharset($dbName), 
				$this->getPersistedMetaEntities($dbName), $this->determineDbAttrs($dbName));
		
		foreach ($database->getMetaEntities() as $metaEntity) {
			if (!$metaEntity instanceof Table) continue;
			
			$this->metaEntityBuilder->applyIndexesForTable($dbName, $metaEntity);
		}
		
		return $database;
	}
101740
private function buildCacheData()
    {
        $metadata = $this->driver->getMetadataForUser();

        return serialize(
            array_map(function (\ReflectionProperty $property) {
                return $property->getName();
            }, $metadata)
        );
    }
315191
public function generateAlteredMeta()
    {
        //get unmanaged converted to managed
        $managed = array_intersect(
            $this->oldUnmanagedKeys,
            $this->newModelKeys
        );

        //get managed converted to unmanaged
        $unmanaged = array_intersect(
            $this->oldModelKeys,
            $this->newUnmanagedKeys
        );

        $modelsToCheck = array_merge(
            $this->keptProxyKeys,
            $this->keptUnmanagedKeys,
            $managed,
            $unmanaged
        );

        $modelsToCheck = array_unique($modelsToCheck);

        /* @var $oldState ModelState */
        /* @var $newState ModelState */
        foreach ($modelsToCheck as $modelName) {
            $oldModelName = $this->getOldModelName($modelName);
            $oldState = $this->fromState->getModelState($oldModelName);
            $newState = $this->toState->getModelState($modelName);

            $oldMeta = [];

            if ($oldState->getMeta()) {
                foreach ($oldState->getMeta() as $name => $opt) {
                    if (AlterModelMeta::isAlterableOption($name)) {
                        $oldMeta[$name] = $opt;
                    }
                }
            }

            $newMeta = [];
            if ($newState->getMeta()) {
                foreach ($newState->getMeta() as $name => $opt) {
                    if (AlterModelMeta::isAlterableOption($name)) {
                        $newMeta[$name] = $opt;
                    }
                }
            }

            if ($oldMeta !== $newMeta) {
                $this->addOperation(
                    $newMeta->getAppName(),
                    AlterModelMeta::createObject(
                        [
                            'name' => $modelName,
                            'meta' => $newMeta,
                        ]
                    )
                );
            }
        }
    }
1309528
public function meta()
    {
        return [
            'Connection' => e($this->meta['queue']->connection),
            'Queue' => e($this->meta['queue']->tube),
            'Driver' => e($this->meta['queue']->driver),
            'Your threshold' => e($this->meta['queue']->alert_heartbeat_greater_than).'s',
            'Last heartbeat' => e($this->meta['queue']->last_heartbeat),
        ];
    }
174102
protected function buildIndex(): array
    {
        $file = $this->getFile($this->getStoragePath());
        $modified = $file->modified();

        $this->data = (array) $file->content();

        $list = [];
        foreach ($this->data as $key => $info) {
            $list[$key] = [
                'storage_key' => $key,
                'storage_timestamp' => $modified
            ];
        }

        return $list;
    }
439068
protected function getTemplateData()
	{
		if ( $this->method == 'create' ) {
			$up = (new AddToTable($this->file, $this->compiler))->run($this->fields, $this->table, $this->connection, 'create');
			$down = (new DroppedTable)->drop($this->table, $this->connection);
		}

		if ( $this->method == 'table' ) {
			$up = (new AddForeignKeysToTable($this->file, $this->compiler))->run($this->fields, $this->table, $this->connection);
			$down = (new RemoveForeignKeysFromTable($this->file, $this->compiler))->run($this->fields, $this->table, $this->connection);
		}

		return [
			'CLASS' => ucwords(camel_case($this->migrationName)),
			'UP'    => $up,
			'DOWN'  => $down
		];
	}
648502
protected function _buildUpdate()
        {
            $query = [];
            $query[] = "UPDATE {$this->_quoteIdentifier($this->_table_name)} SET";

            $field_list = [];

            foreach ($this->_dirty_fields as $key => $value) {
                if(!Arrays::exists($key, $this->_expr_fields)) {
                    $value = '?';
                }

                $field_list[] = "{$this->_quoteIdentifier($key)} = $value";
            }

            $query[] = join(", ", $field_list);
            $this->_addIdColumnConditions($query);

            return join(" ", $query);
        }
654227
protected function collectMetaDataFromConnector()
    {
        $ret = array();

        $storeMeta = $this->getStoreMeta();

        // Std meta tags
        foreach ($storeMeta['meta'] as $metaKey => $metaValue) {
            if ($metaValue === null) {
                // Remove meta
                unset($this->tsSetupSeo[$metaKey]);
            } elseif (!empty($metaValue)) {
                $this->tsSetupSeo[$metaKey] = trim($metaValue);
            }
        }

        // Custom meta tags
        foreach ($storeMeta['custom'] as $metaKey => $metaValue) {
            if ($metaValue === null) {
                // Remove meta
                unset($ret[$metaKey]);
            } elseif (!empty($metaValue)) {
                $ret[$metaKey] = trim($metaValue);
            }
        }

        return $ret;
    }
530103
public function getExportFields()
    {
        $fields = array();
        foreach (DataObject::getSchema()->databaseFields($this->modelClass) as $field => $spec) {
            $fields[$field] = $field;
        }
        return $fields;
    }
700097
public function getAllMetadata()
    {
        $schema   = $this->schemaGenerator->parse($this->jsonConfig->getFile($this->config));
        $filePath = Installer::getDirectory(Installer::TMP) . 'schema.json';

        file_put_contents($filePath, $schema->toString());

        $collection = new MetaDataCollection();

        if ($this->isFirstLevelIsDto($schema) === true) {
            $metadata = $this->createMetadata('master');
            $metadata = $this->hydrateProperties($schema->getProperties(), $metadata, $collection);
            $collection->append($metadata);
        } else {
            // each proporties is considered as metadata
            foreach ($schema->getProperties() as $propName => $prop) {
                if (count($prop->getProperties()) === 0) { // No column, the relation replace column
                    foreach ($prop->getItems() as $itemValue) {
                        /* @var $itemValue \JSONSchema\Structure\Item */
                        $metadata = $this->createMetadata($propName);
                        $metadata = $this->hydrateProperties($itemValue->getProperties(), $metadata, $collection);
                        $collection->append($metadata);
                    }
                } else { // have column, hydrate them
                    $metadata = $this->createMetadata($propName);
                    $metadata = $this->hydrateProperties($prop->getProperties(), $metadata, $collection);
                    $metadata = $this->hydrateItems($propName, $prop->getItems(), $metadata, $collection);
                    $collection->append($metadata);
                }
            }
        }

        return $collection;
    }