Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into feature/4582-site-conf…
Browse files Browse the repository at this point in the history
…ig-presets
mhsdesign committed Jan 13, 2024
2 parents 7a220de + ebe1e7e commit c4fe7a5
Showing 148 changed files with 5,497 additions and 5,574 deletions.
1 change: 1 addition & 0 deletions .composer.json
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
"license": ["GPL-3.0-or-later"],
"type": "neos-package-collection",
"require": {
"neos/flow-development-collection": "9.0.x-dev"
},
"replace": {
},
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.2']
php-versions: ['8.2', '8.3']
dependencies: ['highest']
composer-arguments: [''] # to run --ignore-platform-reqs in experimental builds

Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ private function setupTables(): SetupResult
throw new \RuntimeException('Failed to retrieve Schema Manager', 1625653914);
}

$schema = (new DoctrineDbalContentGraphSchemaBuilder($this->tableNamePrefix))->buildSchema();
$schema = (new DoctrineDbalContentGraphSchemaBuilder($this->tableNamePrefix))->buildSchema($schemaManager);

$schemaDiff = (new Comparator())->compare($schemaManager->createSchema(), $schema);
foreach ($schemaDiff->toSaveSql($connection->getDatabasePlatform()) as $statement) {
@@ -807,7 +807,7 @@ function (NodeRecord $node) use ($eventEnvelope) {
'nodeanchorpoint' => $nodeAnchorPoint?->value,
'destinationnodeaggregateid' => $reference->targetNodeAggregateId->value,
'properties' => $reference->properties
? \json_encode($reference->properties, JSON_THROW_ON_ERROR)
? \json_encode($reference->properties, JSON_THROW_ON_ERROR & JSON_FORCE_OBJECT)
: null
]);
$position++;
Original file line number Diff line number Diff line change
@@ -2,144 +2,107 @@

namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Neos\ContentRepository\Core\Infrastructure\DbalSchemaFactory;

/**
* @internal
*/
class DoctrineDbalContentGraphSchemaBuilder
{
private const DEFAULT_TEXT_COLLATION = 'utf8mb4_unicode_520_ci';

public function __construct(
private readonly string $tableNamePrefix,
private readonly string $tableNamePrefix
) {
}

public function buildSchema(): Schema
public function buildSchema(AbstractSchemaManager $schemaManager): Schema
{
$schema = new Schema();

$this->createNodeTable($schema);
$this->createHierarchyRelationTable($schema);
$this->createReferenceRelationTable($schema);
$this->createRestrictionRelationTable($schema);

return $schema;
return DbalSchemaFactory::createSchemaWithTables($schemaManager, [
$this->createNodeTable(),
$this->createHierarchyRelationTable(),
$this->createReferenceRelationTable(),
$this->createRestrictionRelationTable()
]);
}

private function createNodeTable(Schema $schema): void
private function createNodeTable(): Table
{
$table = new Table($this->tableNamePrefix . '_node', [
DbalSchemaFactory::columnForNodeAnchorPoint('relationanchorpoint'),
DbalSchemaFactory::columnForNodeAggregateId('nodeaggregateid')->setNotnull(false),
DbalSchemaFactory::columnForDimensionSpacePoint('origindimensionspacepoint')->setNotnull(false),
DbalSchemaFactory::columnForDimensionSpacePointHash('origindimensionspacepointhash')->setNotnull(false),
DbalSchemaFactory::columnForNodeTypeName('nodetypename'),
(new Column('properties', Type::getType(Types::TEXT)))->setNotnull(true)->setCustomSchemaOption('collation', self::DEFAULT_TEXT_COLLATION),
(new Column('classification', Type::getType(Types::STRING)))->setLength(20)->setNotnull(true)->setCustomSchemaOption('charset', 'binary'),
(new Column('created', Type::getType(Types::DATETIME_IMMUTABLE)))->setDefault('CURRENT_TIMESTAMP')->setNotnull(true),
(new Column('originalcreated', Type::getType(Types::DATETIME_IMMUTABLE)))->setDefault('CURRENT_TIMESTAMP')->setNotnull(true),
(new Column('lastmodified', Type::getType(Types::DATETIME_IMMUTABLE)))->setNotnull(false)->setDefault(null),
(new Column('originallastmodified', Type::getType(Types::DATETIME_IMMUTABLE)))->setNotnull(false)->setDefault(null)
]);

$table = $schema->createTable($this->tableNamePrefix . '_node');
$table->addColumn('relationanchorpoint', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('nodeaggregateid', Types::STRING)
->setLength(64)
->setNotnull(false);
$table->addColumn('origindimensionspacepoint', Types::TEXT)
->setNotnull(false);
$table->addColumn('origindimensionspacepointhash', Types::STRING)
->setLength(255)
->setNotnull(false);
$table->addColumn('nodetypename', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('properties', Types::TEXT) // TODO longtext?
->setNotnull(true);
$table->addColumn('classification', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('created', Types::DATETIME_IMMUTABLE)
->setDefault('CURRENT_TIMESTAMP')
->setNotnull(true);
$table->addColumn('originalcreated', Types::DATETIME_IMMUTABLE)
->setDefault('CURRENT_TIMESTAMP')
->setNotnull(true);
$table->addColumn('lastmodified', Types::DATETIME_IMMUTABLE)
->setNotnull(false)
->setDefault(null);
$table->addColumn('originallastmodified', Types::DATETIME_IMMUTABLE)
->setNotnull(false)
->setDefault(null);
$table
return $table
->setPrimaryKey(['relationanchorpoint'])
->addIndex(['nodeaggregateid'])
->addIndex(['nodetypename']);
}

private function createHierarchyRelationTable(Schema $schema): void
private function createHierarchyRelationTable(): Table
{
$table = $schema->createTable($this->tableNamePrefix . '_hierarchyrelation');
$table->addColumn('name', Types::STRING)
->setLength(255)
->setNotnull(false);
$table->addColumn('position', Types::INTEGER)
->setNotnull(true);
$table->addColumn('contentstreamid', Types::STRING)
->setLength(40)
->setNotnull(true);
$table->addColumn('dimensionspacepoint', Types::TEXT)
->setNotnull(true);
$table->addColumn('dimensionspacepointhash', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('parentnodeanchor', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('childnodeanchor', Types::STRING)
->setLength(255)
->setNotnull(true);
$table
$table = new Table($this->tableNamePrefix . '_hierarchyrelation', [
(new Column('name', Type::getType(Types::STRING)))->setLength(255)->setNotnull(false)->setCustomSchemaOption('collation', self::DEFAULT_TEXT_COLLATION),
(new Column('position', Type::getType(Types::INTEGER)))->setNotnull(true),
DbalSchemaFactory::columnForContentStreamId('contentstreamid')->setNotnull(true),
DbalSchemaFactory::columnForDimensionSpacePoint('dimensionspacepoint')->setNotnull(true),
DbalSchemaFactory::columnForDimensionSpacePointHash('dimensionspacepointhash')->setNotnull(true),
DbalSchemaFactory::columnForNodeAnchorPoint('parentnodeanchor'),
DbalSchemaFactory::columnForNodeAnchorPoint('childnodeanchor')
]);

return $table
->addIndex(['childnodeanchor'])
->addIndex(['contentstreamid'])
->addIndex(['parentnodeanchor'])
->addIndex(['contentstreamid', 'childnodeanchor', 'dimensionspacepointhash'])
->addIndex(['contentstreamid', 'dimensionspacepointhash']);
}

private function createReferenceRelationTable(Schema $schema): void
private function createReferenceRelationTable(): Table
{
$table = $schema->createTable($this->tableNamePrefix . '_referencerelation');
$table->addColumn('name', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('position', Types::INTEGER)
->setNotnull(true);
$table->addColumn('nodeanchorpoint', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('properties', Types::TEXT)
->setNotnull(false);
$table->addColumn('destinationnodeaggregateid', Types::STRING)
->setLength(64)
->setNotnull(true);
$table = new Table($this->tableNamePrefix . '_referencerelation', [
(new Column('name', Type::getType(Types::STRING)))->setLength(255)->setNotnull(true)->setCustomSchemaOption('charset', 'ascii')->setCustomSchemaOption('collation', 'ascii_general_ci'),
(new Column('position', Type::getType(Types::INTEGER)))->setNotnull(true),
DbalSchemaFactory::columnForNodeAnchorPoint('nodeanchorpoint'),
(new Column('properties', Type::getType(Types::TEXT)))->setNotnull(false)->setCustomSchemaOption('collation', self::DEFAULT_TEXT_COLLATION),
DbalSchemaFactory::columnForNodeAggregateId('destinationnodeaggregateid')->setNotnull(true)
]);

$table
return $table
->setPrimaryKey(['name', 'position', 'nodeanchorpoint']);
}

private function createRestrictionRelationTable(Schema $schema): void
private function createRestrictionRelationTable(): Table
{
$table = $schema->createTable($this->tableNamePrefix . '_restrictionrelation');
$table->addColumn('contentstreamid', Types::STRING)
->setLength(40)
->setNotnull(true);
$table->addColumn('dimensionspacepointhash', Types::STRING)
->setLength(255)
->setNotnull(true);
$table->addColumn('originnodeaggregateid', Types::STRING)
->setLength(64)
->setNotnull(true);
$table->addColumn('affectednodeaggregateid', Types::STRING)
->setLength(64)
->setNotnull(true);
$table = new Table($this->tableNamePrefix . '_restrictionrelation', [
DbalSchemaFactory::columnForContentStreamId('contentstreamid')->setNotnull(true),
DbalSchemaFactory::columnForDimensionSpacePointHash('dimensionspacepointhash')->setNotnull(true),
DbalSchemaFactory::columnForNodeAggregateId('originnodeaggregateid')->setNotnull(false),
DbalSchemaFactory::columnForNodeAggregateId('affectednodeaggregateid')->setNotnull(false),
]);

$table
->setPrimaryKey([
'contentstreamid',
'dimensionspacepointhash',
'originnodeaggregateid',
'affectednodeaggregateid'
]);
return $table->setPrimaryKey([
'contentstreamid',
'dimensionspacepointhash',
'originnodeaggregateid',
'affectednodeaggregateid'
]);
}
}
Loading

0 comments on commit c4fe7a5

Please sign in to comment.