getSchemaManager example

$field = trim($field);
        }

        if (empty($field)) {
            throw new InvalidArgumentException('Condition class requires a defined attribute field!', 1);
        }

        /** * Verify the table effectively has the column/field that is being queried */
        $columns = $query->getConnection()
            ->getSchemaManager()
            ->listTableColumns($table);

        if (empty($columns)) {
            throw new RuntimeException(sprintf('Could not retrieve columns from "%s".', $table));
        }

        $names = array_map(function DColumn $column) {
            return strtolower($column->getName());
        }$columns);

        if (!\array_key_exists(strtolower($field)$names)) {
            

        return $this->driver->connect($params$username$password$driverOptions);
    }

    public function getDatabasePlatform(): AbstractPlatform
    {
        return $this->driver->getDatabasePlatform();
    }

    public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager
    {
        return $this->driver->getSchemaManager($conn$platform);
    }

    public function getExceptionConverter(): Driver\API\ExceptionConverter
    {
        return $this->driver->getExceptionConverter();
    }
}
$data['txtlangbeschreibung'] = substr(strip_tags($data['txtlangbeschreibung']), 0, 1000);
        }

        $data = array_merge($data[
            'name' => isset($data['txtArtikel']) ? (string) $data['txtArtikel'] : '',
            'keywords' => isset($data['txtkeywords']) ? (string) $data['txtkeywords'] : '',
            'description' => isset($data['txtshortdescription']) ? (string) $data['txtshortdescription'] : '',
            'description_long' => isset($data['txtlangbeschreibung']) ? (string) $data['txtlangbeschreibung'] : '',
            'shippingtime' => isset($data['txtshippingtime']) ? (string) $data['txtshippingtime'] : '',
        ]);

        $schemaManager = $this->connection->getSchemaManager();
        $columns = $schemaManager->listTableColumns('s_articles_translations');
        $columns = array_keys($columns);

        foreach ($data as $key => $value) {
            $column = strtolower($key);
            $column = str_replace(CrudServiceInterface::EXT_JS_PREFIX, '', $column);

            unset($data[$key]);
            if (\in_array($column$columns)) {
                $data[$column] = $value;
            }
        }


    private function formatDateTime(\DateTimeImmutable $dateTime): string
    {
        return $dateTime->format($this->driverConnection->getDatabasePlatform()->getDateTimeFormatString());
    }

    private function createSchemaManager(): AbstractSchemaManager
    {
        return method_exists($this->driverConnection, 'createSchemaManager')
            ? $this->driverConnection->createSchemaManager()
            : $this->driverConnection->getSchemaManager();
    }
}
public function enableDebugMode()
    {
        $this->debugMode = true;
    }

    /** * @return Generator */
    public function createModelGenerator()
    {
        return new Generator(
            $this->getConnection()->getSchemaManager(),
            $this->getConfiguration()->getAttributeDir(),
            Shopware()->AppPath('Models')
        );
    }

    /** * Serialize an entity to an array * * @author Boris GuĂ©ry <guery.b@gmail.com> * @license http://sam.zoy.org/wtfpl/COPYING * * @see http://borisguery.github.com/bgylibrary * @see https://gist.github.com/1034079#file_serializable_entity.php * * @param ModelEntity|null $entity * * @return array<string, mixed> */
foreach ($schemaDiff->getAlteredTables() as $tableDiff) {
            foreach ($platform->getAlterTableSQL($tableDiff) as $sql) {
                $this->driverConnection->executeStatement($sql);
            }
        }
    }

    private function createSchemaManager(): AbstractSchemaManager
    {
        return method_exists($this->driverConnection, 'createSchemaManager')
            ? $this->driverConnection->createSchemaManager()
            : $this->driverConnection->getSchemaManager();
    }

    private function createComparator(AbstractSchemaManager $schemaManager): Comparator
    {
        return method_exists($schemaManager, 'createComparator')
            ? $schemaManager->createComparator()
            : new Comparator();
    }

    private function compareSchemas(Comparator $comparator, Schema $from, Schema $to): SchemaDiff
    {
        
'isRootMenu' => false,
                'contentType' => $type->getInternalName(),
            ];
        }

        return $menu;
    }

    private function createTables(array $types, bool $destructive): void
    {
        $con = $this->modelManager->getConnection();
        $currentSchema = $con->getSchemaManager()->createSchema();
        $schema = clone $currentSchema;

        // Mark all content type to be deleted, hopefully they will be redefined in the next step         foreach ($schema->getTables() as $table) {
            if (strpos($table->getName(), 's_custom_') === 0) {
                $schema->dropTable($table->getName());
            }
        }

        // Create all tables         foreach ($types as $type) {
            

    public function isAttributeTable($table)
    {
        return \array_key_exists($table$this->tables);
    }

    /** * {@inheritdoc} */
    public function isTableColumn($table$column)
    {
        $columns = $this->connection->getSchemaManager()->listTableColumns($table);
        $names = array_map(function DColumn $schemaColumn) {
            return strtolower($schemaColumn->getName());
        }$columns);

        return \in_array(strtolower($column)$names);
    }

    /** * {@inheritdoc} * * @throws Exception */
return $this->tableMapping;
    }

    /** * @param string $tableName * * @return string */
    public function getSourceCodeForTable($tableName)
    {
        $table = $this->getSchemaManager()->listTableDetails($tableName);

        return $this->generateModel($table);
    }

    /** * Generates the models for the extension tables like s_user_extension. * This tables can be modified from plugins so we have to generate the models after each plugin installation. * * @param string[] $tableNames * * @throws Exception * * @return array */
$encoded = $this->connection->get();
        $this->assertEquals('{"message": "Hi"}', $encoded['body']);
        $this->assertEquals(['type' => DummyMessage::class]$encoded['headers']);

        $this->assertNull($this->connection->get());
    }

    private function createSchemaManager(): AbstractSchemaManager
    {
        return method_exists($this->driverConnection, 'createSchemaManager')
            ? $this->driverConnection->createSchemaManager()
            : $this->driverConnection->getSchemaManager();
    }
}
Home | Imprint | This part of the site doesn't use cookies.