Create instance of ORM SchemaBuilder.

@param bool $locate Set to true to automatically locate available records and record sources
sources in a project files (based on tokenizer scope).

@return SchemaBuilder

@throws SchemaException
192943
public function schemaBuilder(bool $locate = true): SchemaBuilder
    {
        /**
         * @var SchemaBuilder $builder
         */
        $builder = $this->getFactory()->make(SchemaBuilder::class, ['manager' => $this->manager]);

        if ($locate) {
            foreach ($this->locator->locateSchemas() as $schema) {
                $builder->addSchema($schema);
            }

            foreach ($this->locator->locateSources() as $class => $source) {
                $builder->addSource($class, $source);
            }
        }

        return $builder;
    }
979635
public function setup($checkexisting = true) {
        $fields = \search_solr\document::get_default_fields_definition();

        // Field id is already there.
        unset($fields['id']);

        $this->check_index();

        $return = $this->add_fields($fields, $checkexisting);

        // Tell the engine we are now using the latest schema version.
        $this->engine->record_applied_schema_version(document::SCHEMA_VERSION);

        return $return;
    }
611166
private function createDeleteForm(Located $located)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('ecommerce_located_delete', array('id' => $located->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
99846
public function addSchema(SchemaInterface $schema): SchemaBuilder
    {
        $this->schemas[$schema->getClass()] = $schema;

        return $this;
    }
396068
public function create($schema, $meta, $type = "migration")
    {
        if ($type == "migration") {

            $up = $this->createSchemaForUpMethod($schema, $meta);
            $down = $this->createSchemaForDownMethod($schema, $meta);
            return compact('up', 'down');


        } else if ($type == "controller") {

            $fieldsc = $this->createSchemaForControllerMethod($schema, $meta);
            return $fieldsc;


        } else if ($type == "view-index-header") {

            $fieldsc = $this->createSchemaForViewMethod($schema, $meta, 'index-header');
            return $fieldsc;

        } else if ($type == "view-index-content") {

            $fieldsc = $this->createSchemaForViewMethod($schema, $meta, 'index-content');
            return $fieldsc;

        } else if ($type == "view-show-content") {

            $fieldsc = $this->createSchemaForViewMethod($schema, $meta, 'show-content');
            return $fieldsc;

        } else if ($type == "view-edit-content") {

            $fieldsc = $this->createSchemaForViewMethod($schema, $meta, 'edit-content');
            return $fieldsc;

        } else if ($type == "view-create-content") {

            $fieldsc = $this->createSchemaForViewMethod($schema, $meta, 'create-content');
            return $fieldsc;

        } else {
            throw new \Exception("Type not found in syntaxBuilder");
        }
    }
718058
public function create(Schema $schema)
    {
        $currentDbSchema = $this->connection->getSchemaManager()->createSchema();

        $dbSchema = new DBALSchema(
            $currentDbSchema->getTables(),
            $currentDbSchema->getSequences(),
            $this->connection->getSchemaManager()->createSchemaConfig()
        );

        foreach ($schema->types() as $type) {
            $tableName = $this->tableName($schema->name(), $type->name());

            if ($dbSchema->hasTable($tableName)) {
                throw DoctrineStorageException::tableAlreadyExists($tableName);
            }

            $this->createTable($dbSchema, $schema->name(), $type);
        }

        $queries = $dbSchema->toSql($this->connection->getDatabasePlatform());

        $this->executeQueries($queries);
    }
240493
public function create($schema, $ifNotExists = true, $options = [])
    {
        $defaultOptions = [
            'auto_increment' => 1,
            'engine' => 'InnoDB',
            'charset' => 'utf8mb4',
            'collate' => 'utf8mb4_unicode_ci'
        ];

        $options = array_merge($defaultOptions, $options);
        $schema = $this->callSchema($schema);
        $columns = [];
        $primary = [];

        foreach ($schema->getColumns() as $column) {
            $column = $this->prepareColumn($column);

            $columns[$column->getName()] = MysqlGrammar::build(
                $column->getType() . $column->getLength(),
                $column->getSigned() ? '' : 'UNSIGNED',
                $column->getAllowNull() ? '' : 'NOT NULL',
                $column->getDefault() !== false
                    ? 'DEFAULT ' . $this->db->getQuery(true)->validValue($column->getDefault())
                    : '',
                $column->getAutoIncrement() ? 'AUTO_INCREMENT' : '',
                $column->getComment() ? 'COMMENT ' . $this->db->quote($column->getComment()) : '',
                $column->getSuffix()
            );

            // Primary
            if ($column->isPrimary()) {
                $primary[] = $column->getName();
            }
        }

        $keys = [];

        foreach ($schema->getIndexes() as $index) {
            $name = $index->getName();
            $keys[$name] = [
                'type' => $index->getType(),
                'name' => $name,
                'columns' => $index->getColumns(),
                'comment' => $index->getComment() ? 'COMMENT ' . $this->db->quote($index->getComment()) : '',
            ];
        }

        $query = MysqlGrammar::createTable(
            $this->getName(),
            $columns,
            $primary,
            $keys,
            $options['auto_increment'],
            $ifNotExists,
            $options['engine'],
            $options['charset'],
            $options['collate']
        );

        $this->db->setQuery($query)->execute();

        return $this->reset();
    }
602424
public function update(array $metadata, $saveMode=false)
    {
        $fromSchema = $this->schemaManager->createSchema();
        $toSchema = $this->getSchemaFromMetadata($metadata);

        $comparator = new Comparator;
        $schemaDiff = $comparator->compare($fromSchema, $toSchema);

        if ($saveMode) {
            $statements = $schemaDiff->toSaveSql($this->platform);
        } else {
            $statements = $schemaDiff->toSql($this->platform);
        }

        $this->build($statements);

        return $statements;
    }
981027
public function compileExpression(QueryBuilder $queryBuilder, Expr $expr, bool $subSelectAlias = false)
    {
        switch (true) {
            case $expr instanceof Expression\Count:
                return $this->doctrinePlatform->getCountExpression('*');

            case $expr instanceof Expression\SimpleAggregate:
                return $this->compileSimpleAggregate($queryBuilder, $expr);

            case $expr instanceof Expression\BinOp:
                return (string)$this->compileBinOp($queryBuilder, $expr);

            case $expr instanceof Expression\ColumnExpr:
                return ''
                . $this->doctrinePlatform->quoteSingleIdentifier($expr->getTable())
                . '.'
                . $this->doctrinePlatform->quoteSingleIdentifier($expr->getName());

            case $expr instanceof Expression\Parameter:
                return $queryBuilder->createPositionalParameter($this->platform->mapValueToDbFormat($expr->getType(), $expr->getValue()));

            case $expr instanceof Expression\Tuple:
                return $this->compileExpressions($queryBuilder, $expr->getExpressions());

            case $expr instanceof Expression\UnaryOp:
                return $this->compileUnaryOp($queryBuilder, $expr);

            case $expr instanceof Expression\SubSelect:
                return $this->compileSubSelect($queryBuilder, $expr, $subSelectAlias);
        }

        throw InvalidArgumentException::format('Unknown expression type: ' . get_class($expr));
    }
662249
private static function schemaCache(...$args)
    {
        if (count($args) == 1) {
            $key = array_pop($args);
            if (isset(static::$schema_cache[$key])) {
                return static::$schema_cache[$key];
            }

            return false;
        }

        list($key, $value) = $args;

        static::$schema_cache[$key] = $value;
    }
448473
public function prepare(Location $location)
    {
        if (!$this->formatter) {
            throw new BuildException("No formatter specified (use type or classname attribute)", $location);
        }

        $out = $this->getOutputWriter();

        $this->parentTask->log("Setting output writer to: " . get_class($out), Project::MSG_VERBOSE);
        $this->formatter->setOutput($out);

        if ($this->formatter instanceof PlainPDOResultFormatter) {
            // set any options that apply to the plain formatter
            $this->formatter->setShowheaders($this->showheaders);
            $this->formatter->setRowdelim($this->rowdelimiter);
            $this->formatter->setColdelim($this->coldelimiter);
        } elseif ($this->formatter instanceof XMLPDOResultFormatter) {
            // set any options that apply to the xml formatter
            $this->formatter->setEncoding($this->encoding);
            $this->formatter->setFormatOutput($this->formatoutput);
        }

        foreach ($this->formatterParams as $param) {
            $param = new Parameter();
            $method = 'set' . $param->getName();
            if (!method_exists($this->formatter, $param->getName())) {
                throw new BuildException(
                    "Formatter " . get_class(
                        $this->formatter
                    ) . " does not have a $method method.",
                    $location
                );
            }
            call_user_func([$this->formatter, $method], $param->getValue());
        }
    }
146480
public function createRelevanceConfigTable(SchemaSetupInterface $setup)
    {
        $connection = $setup->getConnection();

        /**
         * Create table 'smile_elasticsuite_relevance_config_data'
         */
        $table = $connection->newTable(
            $setup->getTable('smile_elasticsuite_relevance_config_data')
        )->addColumn(
            'config_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
            'Config Id'
        )->addColumn(
            'scope',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            30,
            ['nullable' => false, 'default' => 'default'],
            'Config Scope'
        )->addColumn(
            'scope_code',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            30,
            ['nullable' => false, 'default' => 'default'],
            'Config Scope Code'
        )->addColumn(
            'path',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            255,
            ['nullable' => false, 'default' => 'general'],
            'Config Path'
        )->addColumn(
            'value',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            '64k',
            [],
            'Config Value'
        )->addIndex(
            $setup->getIdxName(
                'smile_elasticsuite_relevance_config_data',
                ['scope', 'scope_id', 'path'],
                \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
            ),
            ['scope', 'scope_code', 'path'],
            ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
        )->setComment(
            'Smile ElasticSuite Relevance Config Data'
        );
        $connection->createTable($table);
    }
1310996
protected function createQueryBuilder($joins = null)
    {
        $this->queryBuilder = $this->em->createQueryBuilder()
            ->from($this->entityName, $this->encodeAlias($this->entityName));

        $this->assignJoins($this->queryBuilder, $joins);

        if (null !== $this->ids) {
            $this->in($this->idField, !empty($this->ids) ? $this->ids : [null]);
        }

        if (null !== $this->excludedIds && !empty($this->excludedIds)) {
            $this->notIn($this->idField, $this->excludedIds);
        }

        // set expressions
        if (!empty($this->expressions)) {
            foreach ($this->expressions as $expression) {
                $this->queryBuilder->andWhere('(' . $expression->getStatement($this->queryBuilder) . ')');
            }
        }

        $this->assignGroupBy($this->queryBuilder);

        if (null !== $this->search) {
            $searchParts = [];
            foreach ($this->searchFields as $searchField) {
                $searchParts[] = $searchField->getSearch();
            }

            $this->queryBuilder->andWhere('(' . implode(' OR ', $searchParts) . ')');
            $this->queryBuilder->setParameter('search', '%' . str_replace('*', '%', $this->search) . '%');
        }

        return $this->queryBuilder;
    }
1253638
protected function registerSchemaBuilder()
    {
        $app = $this->app;

        $app->singleton('datamapper.schema.builder', function ($app) {
            $connection = $app['db']->connection();

            return new SchemaBuilder($connection);
        });
    }
756304
public function buildPropelGlobalSchema()
    {
        $fs = new Filesystem();

        // TODO: caching rules ?
        if ($fs->exists($this->getPropelSchemaDir())) {
            return;
        }

        $hash = '';

        $fs->mkdir($this->getPropelSchemaDir());

        $schemaCombiner = new SchemaCombiner(
            $this->schemaLocator->findForActiveModules()
        );

        foreach ($schemaCombiner->getDatabases() as $database) {
            $databaseSchemaCache = new ConfigCache(
                "{$this->getPropelSchemaDir()}{$database}.schema.xml",
                $this->debug
            );

            $databaseSchemaResources = [];
            foreach ($schemaCombiner->getSourceDocuments($database) as $sourceDocument) {
                $databaseSchemaResources[] = new FileResource($sourceDocument->baseURI);
            }

            $databaseSchemaCache->write(
                $schemaCombiner->getCombinedDocument($database)->saveXML(),
                $databaseSchemaResources
            );

            $hash .= md5(file_get_contents($this->getPropelSchemaDir() . $database .'.schema.xml'));
        }

        $fs->dumpFile($this->getPropelCacheDir() . 'hash', $hash);
    }
400720
public static function make($dados)
    {
        if (!array_key_exists(
                'property',
                $dados
        )
        ) {
            throw new SchemaException(
                    __CLASS__,
                    __METHOD__,
                    "'property' field has not been found for defining schema entry",
                    400
            );
        }

        if (!array_key_exists(
                'alias',
                $dados
        )
        ) {
            throw new SchemaException(
                    __CLASS__,
                    __METHOD__,
                    "'alias' field has not been found for defining schema entry ",
                    400
            );
        }

        if (!array_key_exists(
                'type',
                $dados
        )
        ) {
            throw new SchemaException(
                    __CLASS__,
                    __METHOD__,
                    "'type' field has not been found for defining schema entry ",
                    400
            );
        }

        $instance = new self(
                $dados['alias'],
                $dados['property'],
                $dados['type']
        );

        if (array_key_exists(
                'format',
                $dados
        )) {
            $format = [];
            foreach ($dados['format'] as $item) {
                $format[] = DinamycFunction::make($item);
            }
            $instance->setFormat($format);
        }

        if (array_key_exists(
                'description',
                $dados
        )) {
            $instance->setDescription($dados['description']);
        }

        if (array_key_exists(
                'default',
                $dados
        )) {
            $instance->setDefault($dados['default']);
        }

        if (array_key_exists(
                'composition',
                $dados
        )) {
            $instance->setComposition(Composition::make($dados['composition']));
        }

        if (array_key_exists(
                'allowedValues',
                $dados
        )) {
            $allowedValues = !is_array($dados['allowedValues']) ? [$dados['allowedValues']] : $dados['allowedValues'];
            foreach ($allowedValues as $allowedValue) {
                if (!is_null($allowedValue)) {
                    $instance->addIntoAllowedValues($allowedValue);
                }
            }
        }

        $instance->setField(
                array_key_exists(
                        'field',
                        $dados
                ) ? $dados['field'] : $dados['property']
        );

        $instance->setBehavior(Behavior::make($dados));

        return $instance;
    }
191261
public function create($sure): Database
    {
        if (true !== $sure) {
            $this->throwUnsure();
        }
        $link = $this->connect();
        $sql  = 'CREATE DATABASE IF NOT EXISTS `'
                . $this->config->get(ConfigInterface::PARAM_DB_NAME)
                . '` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci';
        if (true !== mysqli_query($link, $sql)) {
            throw new DoctrineStaticMetaException(
                'Failed to create the database '
                . $this->config->get(ConfigInterface::PARAM_DB_NAME)
            );
        }

        return $this;
    }