diff --git a/.composer.json b/.composer.json index fc12c2ff3a7..02ffb5fff2f 100644 --- a/.composer.json +++ b/.composer.json @@ -35,7 +35,8 @@ "../../bin/behat -f progress -c Neos.ContentRepository.BehavioralTests/Tests/Behavior/behat.yml.dist", "../../bin/behat -f progress -c Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/behat.yml.dist", "../../flow doctrine:migrate --quiet; ../../flow cr:setup", - "../../bin/behat -f progress -c Neos.Neos/Tests/Behavior/behat.yml" + "../../bin/behat -f progress -c Neos.Neos/Tests/Behavior/behat.yml", + "../../bin/behat -f progress -c Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/behat.yml.dist" ], "test:behavioral:stop-on-failure": [ "../../bin/behat -vvv --stop-on-failure -f progress -c Neos.ContentRepository.BehavioralTests/Tests/Behavior/behat.yml.dist", diff --git a/Neos.CliSetup/Classes/Command/SetupCommandController.php b/Neos.CliSetup/Classes/Command/SetupCommandController.php deleted file mode 100644 index e29e5eb2ddf..00000000000 --- a/Neos.CliSetup/Classes/Command/SetupCommandController.php +++ /dev/null @@ -1,193 +0,0 @@ -databaseConnectionService->getAvailableDrivers(); - if (count($availableDrivers) == 0) { - $this->outputLine('No supported database driver found'); - $this->quit(1); - } - - if (is_null($driver)) { - $driver = $this->output->select( - sprintf('DB Driver (%s): ', $this->persistenceConfiguration['driver'] ?? '---'), - $availableDrivers, - $this->persistenceConfiguration['driver'] - ); - } - - if (is_null($host)) { - $host = $this->output->ask( - sprintf('Host (%s): ', $this->persistenceConfiguration['host'] ?? '127.0.0.1'), - $this->persistenceConfiguration['host'] ?? '127.0.0.1' - ); - } - - if (is_null($dbname)) { - $dbname = $this->output->ask( - sprintf('Database (%s): ', $this->persistenceConfiguration['dbname'] ?? '---'), - $this->persistenceConfiguration['dbname'] - ); - } - - if (is_null($user)) { - $user = $this->output->ask( - sprintf('Username (%s): ', $this->persistenceConfiguration['user'] ?? '---'), - $this->persistenceConfiguration['user'] - ); - } - - if (is_null($password)) { - $password = $this->output->ask( - sprintf('Password (%s): ', $this->persistenceConfiguration['password'] ?? '---'), - $this->persistenceConfiguration['password'] - ); - } - - $persistenceConfiguration = [ - 'driver' => $driver, - 'host' => $host, - 'dbname' => $dbname, - 'user' => $user, - 'password' => $password - ]; - - // postgres does not know utf8mb4 - if ($driver == 'pdo_pgsql') { - $persistenceConfiguration['charset'] = 'utf8'; - $persistenceConfiguration['defaultTableOptions']['charset'] = 'utf8'; - } - - $this->outputLine(); - - try { - $this->databaseConnectionService->verifyDatabaseConnectionWorks($persistenceConfiguration); - $this->outputLine(sprintf('Database %s was connected sucessfully.', $persistenceConfiguration['dbname'])); - } catch (SetupException $exception) { - try { - $this->databaseConnectionService->createDatabaseAndVerifyDatabaseConnectionWorks($persistenceConfiguration); - $this->outputLine(sprintf('Database %s was sucessfully created.', $persistenceConfiguration['dbname'])); - } catch (SetupException $exception) { - $this->outputLine(sprintf( - 'Database %s could not be created. Please check the permissions for user %s. Exception: %s', - $persistenceConfiguration['dbname'], - $persistenceConfiguration['user'], - $exception->getMessage() - )); - $this->quit(1); - } - } - - $filename = 'Configuration/Settings.Database.yaml'; - - $this->outputLine(); - $this->output(sprintf('%s',$this->writeSettings($filename, 'Neos.Flow.persistence.backendOptions',$persistenceConfiguration))); - $this->outputLine(); - $this->outputLine(sprintf('The new database settings were written to %s', $filename)); - } - - /** - * @param string|null $driver - */ - public function imageHandlerCommand(string $driver = null): void - { - $availableImageHandlers = $this->imageHandlerService->getAvailableImageHandlers(); - - if (count($availableImageHandlers) == 0) { - $this->outputLine('No supported image handler found.'); - $this->quit(1); - } - - if (is_null($driver)) { - $driver = $this->output->select( - sprintf('Select Image Handler (%s): ', array_key_last($availableImageHandlers)), - $availableImageHandlers, - array_key_last($availableImageHandlers) - ); - } - - $filename = 'Configuration/Settings.Imagehandling.yaml'; - $this->outputLine(); - $this->output(sprintf('%s', $this->writeSettings($filename, 'Neos.Imagine.driver', $driver))); - $this->outputLine(); - $this->outputLine(sprintf('The new image handler setting were written to %s', $filename)); - } - - /** - * Write the settings to the given path, existing configuration files are created or modified - * - * @param string $filename The filename the settings are stored in - * @param string $path The configuration path - * @param mixed $settings The actual settings to write - * @return string The added yaml code - */ - protected function writeSettings(string $filename, string $path, $settings): string - { - if (file_exists($filename)) { - $previousSettings = Yaml::parseFile($filename); - } else { - $previousSettings = []; - } - $newSettings = Arrays::setValueByPath($previousSettings,$path, $settings); - file_put_contents($filename, YAML::dump($newSettings, 10, 2)); - return YAML::dump(Arrays::setValueByPath([],$path, $settings), 10, 2); - } -} diff --git a/Neos.CliSetup/Classes/Command/WelcomeCommandController.php b/Neos.CliSetup/Classes/Command/WelcomeCommandController.php deleted file mode 100644 index 66ca510e539..00000000000 --- a/Neos.CliSetup/Classes/Command/WelcomeCommandController.php +++ /dev/null @@ -1,70 +0,0 @@ -output( - << - ....###### .###### - .....####### ...###### - .......####### ....###### - .........####### ....###### - ....#......#######...###### - ....##.......#######.###### - ....#####......############ - ....##### ......########## - ....##### ......######## - ....##### ......###### - .####### ........ - - Welcome to Neos. - - - The following steps will help you to configure Neos: - - 1. Configure the database connection: - ./flow setup:database - 2. Create the required database tables: - ./flow doctrine:migrate - 3. Set up and check the required dependencies for a Content Repository instance: - ./flow cr:setup - 4. Migrate the existing data from the Legacy Content Repository: - ./flow cr:migrateLegacyData --config '{"dbal": {"dbname": "YOUR-DATABASE-NAME"}, "resourcesPath": "/path/to/neos-8.0/Data/Persistent/Resources"}' - 5. Configure the image handler: - ./flow setup:imagehandler - 6. Create an admin user: - ./flow user:create --roles Administrator username password firstname lastname - 7. Create your own site package or require an existing one (choose one option): - - ./flow kickstart:site Vendor.Site - - composer require neos/demo && ./flow flow:package:rescan - 8. Import a site or create an empty one (choose one option): - - ./flow site:import Neos.Demo - - ./flow site:import Vendor.Site - - ./flow site:create sitename Vendor.Site Vendor.Site:Document.HomePage - - EOT - ); - } - -} diff --git a/Neos.CliSetup/Classes/Exception.php b/Neos.CliSetup/Classes/Exception.php deleted file mode 100644 index e792dc7c6cd..00000000000 --- a/Neos.CliSetup/Classes/Exception.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ - protected $supportedDatabaseDrivers; - - /** - * Return an array with the available database drivers - * - * @return array - */ - public function getAvailableDrivers(): array - { - $availableDrivers = []; - foreach ($this->supportedDatabaseDrivers as $driver => $description) { - if (extension_loaded($driver)) { - $availableDrivers[$driver] = $description; - } - } - return $availableDrivers; - } - - /** - * Verify the database connection settings - * - * @param array $connectionSettings - * @throws SetupException - */ - public function verifyDatabaseConnectionWorks(array $connectionSettings) - { - try { - $this->connectToDatabase($connectionSettings); - } catch (DBALException | \PDOException $exception) { - throw new SetupException(sprintf('Could not connect to database "%s". Please check the permissions for user "%s". DBAL Exception: "%s"', $connectionSettings['dbname'], $connectionSettings['user'], $exception->getMessage()), 1351000864); - } - } - - /** - * Create a database with the connection settings and verify the connection - * - * @param array $connectionSettings - * @throws SetupException - */ - public function createDatabaseAndVerifyDatabaseConnectionWorks(array $connectionSettings) - { - try { - $this->createDatabase($connectionSettings, $connectionSettings['dbname']); - } catch (DBALException | \PDOException $exception) { - throw new SetupException(sprintf('Database "%s" could not be created. Please check the permissions for user "%s". DBAL Exception: "%s"', $connectionSettings['dbname'], $connectionSettings['user'], $exception->getMessage()), 1351000841, $exception); - } - try { - $this->connectToDatabase($connectionSettings); - } catch (DBALException | \PDOException $exception) { - throw new SetupException(sprintf('Could not connect to database "%s". Please check the permissions for user "%s". DBAL Exception: "%s"', $connectionSettings['dbname'], $connectionSettings['user'], $exception->getMessage()), 1351000864); - } - } - - /** - * Tries to connect to the database using the specified $connectionSettings - * - * @param array $connectionSettings array in the format array('user' => 'dbuser', 'password' => 'dbpassword', 'host' => 'dbhost', 'dbname' => 'dbname') - * @return void - * @throws \Doctrine\DBAL\Exception | \PDOException if the connection fails - */ - protected function connectToDatabase(array $connectionSettings) - { - $connection = DriverManager::getConnection($connectionSettings); - $connection->connect(); - } - - /** - * Connects to the database using the specified $connectionSettings - * and tries to create a database named $databaseName. - * - * @param array $connectionSettings array in the format array('user' => 'dbuser', 'password' => 'dbpassword', 'host' => 'dbhost', 'dbname' => 'dbname') - * @param string $databaseName name of the database to create - * @throws \Neos\Setup\Exception - * @return void - */ - protected function createDatabase(array $connectionSettings, $databaseName) - { - unset($connectionSettings['dbname']); - $connection = DriverManager::getConnection($connectionSettings); - $databasePlatform = $connection->getSchemaManager()->getDatabasePlatform(); - $databaseName = $databasePlatform->quoteIdentifier($databaseName); - // we are not using $databasePlatform->getCreateDatabaseSQL() below since we want to specify charset and collation - if ($databasePlatform instanceof MySqlPlatform) { - $connection->executeUpdate(sprintf('CREATE DATABASE %s CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci', $databaseName)); - } elseif ($databasePlatform instanceof PostgreSqlPlatform) { - $connection->executeUpdate(sprintf('CREATE DATABASE %s WITH ENCODING = %s', $databaseName, "'UTF8'")); - } else { - throw new SetupException(sprintf('The given database platform "%s" is not supported.', $databasePlatform->getName()), 1386454885); - } - $connection->close(); - } -} diff --git a/Neos.CliSetup/Classes/Infrastructure/ImageHandler/ImageHandlerService.php b/Neos.CliSetup/Classes/Infrastructure/ImageHandler/ImageHandlerService.php deleted file mode 100644 index cc4cb6ec69f..00000000000 --- a/Neos.CliSetup/Classes/Infrastructure/ImageHandler/ImageHandlerService.php +++ /dev/null @@ -1,78 +0,0 @@ - - */ - public function getAvailableImageHandlers(): array - { - $availableImageHandlers = []; - foreach ($this->supportedImageHandlers as $driverName => $description) { - if (\extension_loaded(strtolower($driverName))) { - $unsupportedFormats = $this->findUnsupportedImageFormats($driverName); - if (\count($unsupportedFormats) === 0) { - $availableImageHandlers[$driverName] = $description; - } - } - } - return $availableImageHandlers; - } - - /** - * @param string $driver - * @return array Not supported image formats - */ - protected function findUnsupportedImageFormats(string $driver): array - { - $this->imagineFactory->injectSettings(['driver' => ucfirst($driver)]); - $imagine = $this->imagineFactory->create(); - $unsupportedFormats = []; - - foreach ($this->requiredImageFormats as $imageFormat => $testFile) { - try { - $imagine->load(file_get_contents($testFile)); - } /** @noinspection BadExceptionsProcessingInspection */ catch (\Exception $exception) { - $unsupportedFormats[] = $imageFormat; - } - } - return $unsupportedFormats; - } -} diff --git a/Neos.CliSetup/Configuration/Settings.yaml b/Neos.CliSetup/Configuration/Settings.yaml deleted file mode 100644 index a98508ce232..00000000000 --- a/Neos.CliSetup/Configuration/Settings.yaml +++ /dev/null @@ -1,24 +0,0 @@ -Neos: - CliSetup: - # - # Imagine drivers that are supported - # - supportedImageHandlers: - 'Gd': 'GD Library - generally slow, not recommended in production' - 'Gmagick': 'Gmagick php module' - 'Imagick': 'ImageMagick php module' - 'Vips': 'Vips php module - fast and memory efficient, needs rokka/imagine-vips' - # - # Images to verify that the format can be handled - # - requiredImageFormats: - 'jpg': 'resource://Neos.Neos/Private/Installer/TestImages/Test.jpg' - 'gif': 'resource://Neos.Neos/Private/Installer/TestImages/Test.gif' - 'png': 'resource://Neos.Neos/Private/Installer/TestImages/Test.png' - # - # The database drivers that are supported by migrations - # - supportedDatabaseDrivers: - 'pdo_mysql': 'MySQL/MariaDB via PDO' - 'mysqli': 'MySQL/MariaDB via mysqli' - 'pdo_pgsql': 'PostgreSQL via PDO' diff --git a/Neos.CliSetup/LICENSE b/Neos.CliSetup/LICENSE deleted file mode 100644 index 10926e87f11..00000000000 --- a/Neos.CliSetup/LICENSE +++ /dev/null @@ -1,675 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - diff --git a/Neos.CliSetup/Readme.rst b/Neos.CliSetup/Readme.rst deleted file mode 100644 index 3f58184c434..00000000000 --- a/Neos.CliSetup/Readme.rst +++ /dev/null @@ -1,20 +0,0 @@ ----------------- -The Neos package ----------------- - -.. note:: This repository is a **read-only subsplit** of a package that is part of the - Neos project (learn more on `www.neos.io `_). - -Neos is an open source Content Application Platform based on Flow. A set of -core Content Management features is resting within a larger context that allows -you to build a perfectly customized experience for your users. - -If you want to use Neos, please have a look at the `Neos documentation -`_ - -Contribute ----------- - -If you want to contribute to Neos, please have a look at -https://github.com/neos/neos-development-collection - it is the repository -used for development and all pull requests should go into it. diff --git a/Neos.CliSetup/composer.json b/Neos.CliSetup/composer.json deleted file mode 100644 index c2a4d3f756a..00000000000 --- a/Neos.CliSetup/composer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "neos/cli-setup", - "type": "neos-package", - "license": [ - "GPL-3.0-or-later" - ], - "description": "ClI setup for Neos CMS", - "require": { - "php": "^8.2", - "neos/neos": "self.version" - }, - "autoload": { - "psr-4": { - "Neos\\CliSetup\\": "Classes" - } - } -} diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php index 2f918be284f..d7d3239cd7b 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -11,12 +11,11 @@ * source code. */ -require_once(__DIR__ . '/../../../../../../Application/Neos.Behat/Tests/Behat/FlowContextTrait.php'); require_once(__DIR__ . '/ProjectionIntegrityViolationDetectionTrait.php'); use Behat\Behat\Context\Context as BehatContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; -use Neos\Behat\Tests\Behat\FlowContextTrait; +use Neos\Behat\FlowBootstrapTrait; use Neos\ContentGraph\DoctrineDbalAdapter\Tests\Behavior\Features\Bootstrap\ProjectionIntegrityViolationDetectionTrait; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; @@ -33,7 +32,7 @@ */ class FeatureContext implements BehatContext { - use FlowContextTrait; + use FlowBootstrapTrait; use ProjectionIntegrityViolationDetectionTrait; use CRTestSuiteTrait; use CRBehavioralTestsSubjectProvider; @@ -42,11 +41,8 @@ class FeatureContext implements BehatContext public function __construct() { - if (self::$bootstrap === null) { - self::$bootstrap = $this->initializeFlow(); - } - $this->objectManager = self::$bootstrap->getObjectManager(); - $this->contentRepositoryRegistry = $this->objectManager->get(ContentRepositoryRegistry::class); + self::bootstrapFlow(); + $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); $this->setupCRTestSuiteTrait(); $this->setupDbalGraphAdapterIntegrityViolationTrait(); diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php index 82a090cecb4..a318b4ea750 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php @@ -32,6 +32,8 @@ /** * Custom context trait for projection integrity violation detection specific to the Doctrine DBAL content graph adapter + * + * @todo move this class somewhere where its autoloaded */ trait ProjectionIntegrityViolationDetectionTrait { @@ -41,6 +43,14 @@ trait ProjectionIntegrityViolationDetectionTrait protected Result $lastIntegrityViolationDetectionResult; + /** + * @template T of object + * @param class-string $className + * + * @return T + */ + abstract private function getObject(string $className): object; + protected function getTableNamePrefix(): string { return DoctrineDbalContentGraphProjectionFactory::graphProjectionTableNamePrefix( @@ -50,7 +60,7 @@ protected function getTableNamePrefix(): string public function setupDbalGraphAdapterIntegrityViolationTrait() { - $this->dbalClient = $this->getObjectManager()->get(DbalClient::class); + $this->dbalClient = $this->getObject(DbalClient::class); } /** diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php index be851203b64..88477f51f32 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php @@ -23,6 +23,7 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\EventStore\EventInterface; +use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Feature\ContentStreamForking\Event\ContentStreamWasForked; use Neos\ContentRepository\Core\Feature\ContentStreamRemoval\Event\ContentStreamWasRemoved; use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Event\DimensionShineThroughWasAdded; @@ -46,7 +47,6 @@ use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; -use Neos\ContentRepository\Core\Projection\CatchUpHookFactoryInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps; use Neos\ContentRepository\Core\Projection\ProjectionInterface; use Neos\ContentRepository\Core\Projection\WithMarkStaleInterface; @@ -86,6 +86,7 @@ final class DoctrineDbalContentGraphProjection implements ProjectionInterface, W public function __construct( private readonly DbalClientInterface $dbalClient, private readonly NodeFactory $nodeFactory, + private readonly ContentRepositoryId $contentRepositoryId, private readonly NodeTypeManager $nodeTypeManager, private readonly ProjectionContentGraph $projectionContentGraph, private readonly string $tableNamePrefix, @@ -212,6 +213,7 @@ public function getState(): ContentGraph $this->contentGraph = new ContentGraph( $this->dbalClient, $this->nodeFactory, + $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNamePrefix ); @@ -233,7 +235,7 @@ public function markStale(): void private function whenRootNodeAggregateWithNodeWasCreated(RootNodeAggregateWithNodeWasCreated $event, EventEnvelope $eventEnvelope): void { $nodeRelationAnchorPoint = NodeRelationAnchorPoint::create(); - $originDimensionSpacePoint = OriginDimensionSpacePoint::fromArray([]); + $originDimensionSpacePoint = OriginDimensionSpacePoint::createWithoutDimensions(); $node = new NodeRecord( $nodeRelationAnchorPoint, $event->nodeAggregateId, @@ -272,7 +274,7 @@ private function whenRootNodeAggregateDimensionsWereUpdated(RootNodeAggregateDim ->getAnchorPointForNodeAndOriginDimensionSpacePointAndContentStream( $event->nodeAggregateId, /** the origin DSP of the root node is always the empty dimension ({@see whenRootNodeAggregateWithNodeWasCreated}) */ - OriginDimensionSpacePoint::fromArray([]), + OriginDimensionSpacePoint::createWithoutDimensions(), $event->contentStreamId ); if ($rootNodeAnchorPoint === null) { @@ -517,12 +519,6 @@ private function connectHierarchy( } /** - * @param NodeRelationAnchorPoint|null $parentAnchorPoint - * @param NodeRelationAnchorPoint|null $childAnchorPoint - * @param NodeRelationAnchorPoint|null $succeedingSiblingAnchorPoint - * @param ContentStreamId $contentStreamId - * @param DimensionSpacePoint $dimensionSpacePoint - * @return int * @throws \Doctrine\DBAL\DBALException */ private function getRelationPosition( @@ -590,6 +586,12 @@ private function getRelationPositionAfterRecalculation( $dimensionSpacePoint ); + usort( + $hierarchyRelations, + fn (HierarchyRelation $relationA, HierarchyRelation $relationB): int + => $relationA->position <=> $relationB->position + ); + foreach ($hierarchyRelations as $relation) { $offset += self::RELATION_DEFAULT_OFFSET; if ( diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php index 51373f5d428..d3022e2c290 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjectionFactory.php @@ -41,7 +41,6 @@ public function build( ); return new ContentGraphProjection( - // @phpstan-ignore-next-line new DoctrineDbalContentGraphProjection( $this->dbalClient, new NodeFactory( @@ -49,6 +48,7 @@ public function build( $projectionFactoryDependencies->nodeTypeManager, $projectionFactoryDependencies->propertyConverter ), + $projectionFactoryDependencies->contentRepositoryId, $projectionFactoryDependencies->nodeTypeManager, new ProjectionContentGraph( $this->dbalClient, diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/Feature/NodeMove.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/Feature/NodeMove.php index f2e032259f7..e32b01fb641 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/Feature/NodeMove.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Projection/Feature/NodeMove.php @@ -44,7 +44,6 @@ private function whenNodeAggregateWasMoved(NodeAggregateWasMoved $event): void $this->transactional(function () use ($event) { foreach ($event->nodeMoveMappings as $moveNodeMapping) { // for each materialized node in the DB which we want to adjust, we have one MoveNodeMapping. - /* @var \Neos\ContentRepository\Core\Feature\NodeMove\Dto\OriginNodeMoveMapping $moveNodeMapping */ $nodeToBeMoved = $this->getProjectionContentGraph()->findNodeByIds( $event->contentStreamId, $event->nodeAggregateId, diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php index 126200f98a3..3e39613f33b 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentGraph.php @@ -19,6 +19,7 @@ use Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjection; use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\NodeRelationAnchorPoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; +use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphWithRuntimeCaches\ContentSubgraphWithRuntimeCaches; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindRootNodeAggregatesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregates; @@ -56,6 +57,7 @@ final class ContentGraph implements ContentGraphInterface public function __construct( private readonly DbalClientInterface $client, private readonly NodeFactory $nodeFactory, + private readonly ContentRepositoryId $contentRepositoryId, private readonly NodeTypeManager $nodeTypeManager, private readonly string $tableNamePrefix ) { @@ -70,6 +72,7 @@ final public function getSubgraph( if (!isset($this->subgraphs[$index])) { $this->subgraphs[$index] = new ContentSubgraphWithRuntimeCaches( new ContentSubgraph( + $this->contentRepositoryId, $contentStreamId, $dimensionSpacePoint, $visibilityConstraints, diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php index f6dce5f028e..4100d614945 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/ContentSubgraph.php @@ -21,10 +21,12 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\QueryBuilder; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; +use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; +use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountBackReferencesFilter; @@ -102,6 +104,7 @@ final class ContentSubgraph implements ContentSubgraphInterface private int $dynamicParameterCount = 0; public function __construct( + private readonly ContentRepositoryId $contentRepositoryId, private readonly ContentStreamId $contentStreamId, private readonly DimensionSpacePoint $dimensionSpacePoint, private readonly VisibilityConstraints $visibilityConstraints, @@ -112,6 +115,16 @@ public function __construct( ) { } + public function getIdentity(): ContentSubgraphIdentity + { + return ContentSubgraphIdentity::create( + $this->contentRepositoryId, + $this->contentStreamId, + $this->dimensionSpacePoint, + $this->visibilityConstraints + ); + } + public function findChildNodes(NodeAggregateId $parentNodeAggregateId, FindChildNodesFilter $filter): Nodes { $queryBuilder = $this->buildChildNodesQuery($parentNodeAggregateId, $filter); diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php index 0ac6f2e1aad..c93abc75f93 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php @@ -67,7 +67,7 @@ public function mapNodeRowToNode( ? $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']) : null; - return new Node( + return Node::create( ContentSubgraphIdentity::create( $this->contentRepositoryId, ContentStreamId::fromString($nodeRow['contentstreamid']), diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Feature/NodeCreation.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Feature/NodeCreation.php index 56bd658091f..767eb7c064b 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Feature/NodeCreation.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Feature/NodeCreation.php @@ -44,7 +44,7 @@ trait NodeCreation private function whenRootNodeAggregateWithNodeWasCreated(RootNodeAggregateWithNodeWasCreated $event): void { $nodeRelationAnchorPoint = NodeRelationAnchorPoint::create(); - $originDimensionSpacePoint = OriginDimensionSpacePoint::fromArray([]); + $originDimensionSpacePoint = OriginDimensionSpacePoint::createWithoutDimensions(); $node = new NodeRecord( $nodeRelationAnchorPoint, diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php index f9037c9453a..bf8d017432b 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/HypergraphProjection.php @@ -31,6 +31,7 @@ use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\NodeFactory; use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\EventStore\EventInterface; +use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Feature\ContentStreamForking\Event\ContentStreamWasForked; use Neos\ContentRepository\Core\Feature\NodeCreation\Event\NodeAggregateWithNodeWasCreated; use Neos\ContentRepository\Core\Feature\NodeDisabling\Event\NodeAggregateWasDisabled; @@ -81,6 +82,7 @@ final class HypergraphProjection implements ProjectionInterface public function __construct( private readonly PostgresDbalClientInterface $databaseClient, private readonly NodeFactory $nodeFactory, + private readonly ContentRepositoryId $contentRepositoryId, private readonly NodeTypeManager $nodeTypeManager, private readonly string $tableNamePrefix, ) { @@ -221,6 +223,7 @@ public function getState(): ContentHypergraph $this->contentHypergraph = new ContentHypergraph( $this->databaseClient, $this->nodeFactory, + $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNamePrefix ); diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php index 124f10c7933..1d876921576 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/ProjectionHypergraph.php @@ -71,7 +71,6 @@ public function findNodeRecordByCoverage( $query = ProjectionHypergraphQuery::create($contentStreamId, $this->tableNamePrefix); $query = $query->withDimensionSpacePoint($dimensionSpacePoint) ->withNodeAggregateId($nodeAggregateId); - /** @phpstan-ignore-next-line @todo check actual return type */ $result = $query->execute($this->getDatabaseConnection())->fetchAssociative(); return $result ? NodeRecord::fromDatabaseRow($result) : null; @@ -89,7 +88,6 @@ public function findNodeRecordByOrigin( $query = $query->withOriginDimensionSpacePoint($originDimensionSpacePoint); $query = $query->withNodeAggregateId($nodeAggregateId); - /** @phpstan-ignore-next-line @todo check actual return type */ $result = $query->execute($this->getDatabaseConnection())->fetchAssociative(); return $result ? NodeRecord::fromDatabaseRow($result) : null; @@ -191,7 +189,6 @@ public function findNodeRecordsForNodeAggregate( $query = ProjectionHypergraphQuery::create($contentStreamId, $this->tableNamePrefix); $query = $query->withNodeAggregateId($nodeAggregateId); - /** @phpstan-ignore-next-line @todo check actual return type */ $result = $query->execute($this->getDatabaseConnection())->fetchAllAssociative(); return array_map(function ($row) { diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQuery.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQuery.php index 53c1efacd45..ad41c6b19d3 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQuery.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQuery.php @@ -15,7 +15,7 @@ namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Query; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\ResultStatement; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Types\Types; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; @@ -113,10 +113,7 @@ public function withNodeAggregateId(NodeAggregateId $nodeAggregateId): self return new self($query, $parameters, $this->types); } - /** - * @return ResultStatement - */ - public function execute(Connection $databaseConnection): ResultStatement + public function execute(Connection $databaseConnection): Result { return $databaseConnection->executeQuery($this->query, $this->parameters, $this->types); } diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQueryInterface.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQueryInterface.php index ff2ee1066e4..602bf71191d 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQueryInterface.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Projection/Query/ProjectionHypergraphQueryInterface.php @@ -15,7 +15,7 @@ namespace Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Query; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\ResultStatement; +use Doctrine\DBAL\Driver\Result; /** * The interface to be implemented by projection hypergraph queries @@ -24,8 +24,5 @@ */ interface ProjectionHypergraphQueryInterface { - /** - * @return ResultStatement - */ - public function execute(Connection $databaseConnection): ResultStatement; + public function execute(Connection $databaseConnection): Result; } diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php index 58244d9823b..f45b29b8e34 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentHypergraph.php @@ -23,6 +23,7 @@ use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; +use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindRootNodeAggregatesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregates; @@ -59,6 +60,7 @@ final class ContentHypergraph implements ContentGraphInterface public function __construct( PostgresDbalClientInterface $databaseClient, NodeFactory $nodeFactory, + private readonly ContentRepositoryId $contentRepositoryId, private readonly NodeTypeManager $nodeTypeManager, private readonly string $tableNamePrefix ) { @@ -74,6 +76,7 @@ public function getSubgraph( $index = $contentStreamId->value . '-' . $dimensionSpacePoint->hash . '-' . $visibilityConstraints->getHash(); if (!isset($this->subhypergraphs[$index])) { $this->subhypergraphs[$index] = new ContentSubhypergraph( + $this->contentRepositoryId, $contentStreamId, $dimensionSpacePoint, $visibilityConstraints, diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php index 172afffed67..32705839a97 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/ContentSubhypergraph.php @@ -24,9 +24,11 @@ use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\Query\QueryUtility; use Neos\ContentGraph\PostgreSQLAdapter\Infrastructure\PostgresDbalClientInterface; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; +use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; +use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindBackReferencesFilter; @@ -69,19 +71,30 @@ * * @internal but the public {@see ContentSubgraphInterface} is API */ -final class ContentSubhypergraph implements ContentSubgraphInterface +final readonly class ContentSubhypergraph implements ContentSubgraphInterface { public function __construct( - private readonly ContentStreamId $contentStreamId, - private readonly DimensionSpacePoint $dimensionSpacePoint, - private readonly VisibilityConstraints $visibilityConstraints, - private readonly PostgresDbalClientInterface $databaseClient, - private readonly NodeFactory $nodeFactory, - private readonly NodeTypeManager $nodeTypeManager, - private readonly string $tableNamePrefix + private ContentRepositoryId $contentRepositoryId, + private ContentStreamId $contentStreamId, + private DimensionSpacePoint $dimensionSpacePoint, + private VisibilityConstraints $visibilityConstraints, + private PostgresDbalClientInterface $databaseClient, + private NodeFactory $nodeFactory, + private NodeTypeManager $nodeTypeManager, + private string $tableNamePrefix ) { } + public function getIdentity(): ContentSubgraphIdentity + { + return ContentSubgraphIdentity::create( + $this->contentRepositoryId, + $this->contentStreamId, + $this->dimensionSpacePoint, + $this->visibilityConstraints + ); + } + public function findNodeById(NodeAggregateId $nodeAggregateId): ?Node { $query = HypergraphQuery::create($this->contentStreamId, $this->tableNamePrefix); diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php index 797c0001b0e..894b86cc3b2 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php @@ -75,7 +75,7 @@ public function mapNodeRowToNode( ? $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']) : null; - return new Node( + return Node::create( ContentSubgraphIdentity::create( $this->contentRepositoryId, $contentStreamId ?: ContentStreamId::fromString($nodeRow['contentstreamid']), diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php b/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php index ca4a76375ee..4c3def6eea8 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/HypergraphProjectionFactory.php @@ -43,6 +43,7 @@ public function build( $projectionFactoryDependencies->nodeTypeManager, $projectionFactoryDependencies->propertyConverter ), + $projectionFactoryDependencies->contentRepositoryId, $projectionFactoryDependencies->nodeTypeManager, $tableNamePrefix ); diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php index 31d9bc21b50..f6e7e6d0786 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php @@ -11,13 +11,13 @@ * source code. */ -require_once(__DIR__ . '/../../../../../Application/Neos.Behat/Tests/Behat/FlowContextTrait.php'); +// @todo remove this require statement require_once(__DIR__ . '/../../../../Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php'); use Behat\Behat\Context\Context as BehatContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use GuzzleHttp\Psr7\Uri; -use Neos\Behat\Tests\Behat\FlowContextTrait; +use Neos\Behat\FlowBootstrapTrait; use Neos\ContentGraph\DoctrineDbalAdapter\Tests\Behavior\Features\Bootstrap\ProjectionIntegrityViolationDetectionTrait; use Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\Dto\TraceEntryType; use Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\RedisInterleavingLogger; @@ -38,14 +38,13 @@ use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\StructureAdjustmentsTrait; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Configuration\ConfigurationManager; -use Neos\Flow\ObjectManagement\ObjectManagerInterface; /** * Features context */ class FeatureContext implements BehatContext { - use FlowContextTrait; + use FlowBootstrapTrait; use CRTestSuiteTrait; use CRBehavioralTestsSubjectProvider; use ProjectionIntegrityViolationDetectionTrait; @@ -58,22 +57,19 @@ class FeatureContext implements BehatContext public function __construct() { - if (self::$bootstrap === null) { - self::$bootstrap = $this->initializeFlow(); - } - $this->objectManager = self::$bootstrap->getObjectManager(); + self::bootstrapFlow(); - $this->dbalClient = $this->getObjectManager()->get(DbalClientInterface::class); + $this->dbalClient = $this->getObject(DbalClientInterface::class); $this->setupCRTestSuiteTrait(); $this->setUpInterleavingLogger(); - $this->contentRepositoryRegistry = $this->objectManager->get(ContentRepositoryRegistry::class); + $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); } private function setUpInterleavingLogger(): void { // prepare race tracking for debugging into the race log if (class_exists(RedisInterleavingLogger::class)) { // the class must exist (the package loaded) - $raceConditionTrackerConfig = $this->getObjectManager()->get(ConfigurationManager::class) + $raceConditionTrackerConfig = $this->getObject(ConfigurationManager::class) ->getConfiguration( ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.ContentRepository.BehavioralTests.raceConditionTracker' @@ -115,11 +111,6 @@ public function resetContentRepositoryComponents(BeforeScenarioScope $scope): vo GherkinPyStringNodeBasedNodeTypeManagerFactory::reset(); } - protected function getObjectManager(): ObjectManagerInterface - { - return $this->objectManager; - } - protected function getContentRepositoryService( ContentRepositoryServiceFactoryInterface $factory ): ContentRepositoryServiceInterface { diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/03-CreateRootNodeAggregateWithNodeAndTetheredChildren_WithoutDimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/03-CreateRootNodeAggregateWithNodeAndTetheredChildren_WithoutDimensions.feature new file mode 100644 index 00000000000..7678cbc51e4 --- /dev/null +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/03-CreateRootNodeAggregateWithNodeAndTetheredChildren_WithoutDimensions.feature @@ -0,0 +1,164 @@ +@contentrepository @adapters=DoctrineDBAL +Feature: Create a root node aggregate with tethered children + + As a user of the CR I want to create a new root node aggregate with an initial node and tethered children. + + These are the test cases without dimensions involved + + Background: + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.ContentRepository.Testing:SubSubNode': + properties: + text: + defaultValue: 'my sub sub default' + type: string + 'Neos.ContentRepository.Testing:SubNode': + childNodes: + grandchild-node: + type: 'Neos.ContentRepository.Testing:SubSubNode' + properties: + text: + defaultValue: 'my sub default' + type: string + 'Neos.ContentRepository.Testing:RootWithTetheredChildNodes': + superTypes: + 'Neos.ContentRepository:Root': true + childNodes: + child-node: + type: 'Neos.ContentRepository.Testing:SubNode' + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | workspaceTitle | "Live" | + | workspaceDescription | "The live workspace" | + | newContentStreamId | "cs-identifier" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" + And I am in dimension space point {} + And I am user identified by "initiating-user-identifier" + + Scenario: Create root node with tethered children + When the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" | + | tetheredDescendantNodeAggregateIds | {"child-node": "nody-mc-nodeface", "child-node/grandchild-node": "nodimus-prime"} | + And the graph projection is fully up to date + + Then I expect exactly 4 events to be published on stream "ContentStream:cs-identifier" + And event at index 1 is of type "RootNodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" | + | coveredDimensionSpacePoints | [[]] | + | nodeAggregateClassification | "root" | + And event at index 2 is of type "NodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nody-mc-nodeface" | + | nodeTypeName | "Neos.ContentRepository.Testing:SubNode" | + | originDimensionSpacePoint | [] | + | coveredDimensionSpacePoints | [[]] | + | parentNodeAggregateId | "lady-eleonode-rootford" | + | nodeName | "child-node" | + | initialPropertyValues | {"text": {"value": "my sub default", "type": "string"}} | + | nodeAggregateClassification | "tethered" | + And event at index 3 is of type "NodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nodimus-prime" | + | nodeTypeName | "Neos.ContentRepository.Testing:SubSubNode" | + | originDimensionSpacePoint | [] | + | coveredDimensionSpacePoints | [[]] | + | parentNodeAggregateId | "nody-mc-nodeface" | + | nodeName | "grandchild-node" | + | initialPropertyValues | {"text": {"value": "my sub sub default", "type": "string"}} | + | nodeAggregateClassification | "tethered" | + + And I expect the node aggregate "lady-eleonode-rootford" to exist + And I expect this node aggregate to be classified as "root" + And I expect this node aggregate to be of type "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" + And I expect this node aggregate to be unnamed + And I expect this node aggregate to occupy dimension space points [[]] + And I expect this node aggregate to cover dimension space points [[]] + And I expect this node aggregate to disable dimension space points [] + And I expect this node aggregate to have no parent node aggregates + And I expect this node aggregate to have the child node aggregates ["nody-mc-nodeface"] + + And I expect the node aggregate "nody-mc-nodeface" to exist + And I expect this node aggregate to be classified as "tethered" + And I expect this node aggregate to be of type "Neos.ContentRepository.Testing:SubNode" + And I expect this node aggregate to be named "child-node" + And I expect this node aggregate to occupy dimension space points [[]] + And I expect this node aggregate to cover dimension space points [[]] + And I expect this node aggregate to disable dimension space points [] + And I expect this node aggregate to have the parent node aggregates ["lady-eleonode-rootford"] + And I expect this node aggregate to have the child node aggregates ["nodimus-prime"] + + And I expect the node aggregate "nodimus-prime" to exist + And I expect this node aggregate to be classified as "tethered" + And I expect this node aggregate to be of type "Neos.ContentRepository.Testing:SubSubNode" + And I expect this node aggregate to be named "grandchild-node" + And I expect this node aggregate to occupy dimension space points [[]] + And I expect this node aggregate to cover dimension space points [[]] + And I expect this node aggregate to disable dimension space points [] + And I expect this node aggregate to have the parent node aggregates ["nody-mc-nodeface"] + And I expect this node aggregate to have no child node aggregates + + And I expect the graph projection to consist of exactly 3 nodes + And I expect a node identified by cs-identifier;lady-eleonode-rootford;{} to exist in the content graph + And I expect this node to be classified as "root" + And I expect this node to be of type "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" + And I expect this node to be unnamed + And I expect this node to have no properties + + And I expect a node identified by cs-identifier;nody-mc-nodeface;{} to exist in the content graph + And I expect this node to be classified as "tethered" + And I expect this node to be of type "Neos.ContentRepository.Testing:SubNode" + And I expect this node to be named "child-node" + And I expect this node to have the following properties: + | Key | Value | + | text | "my sub default" | + + And I expect a node identified by cs-identifier;nodimus-prime;{} to exist in the content graph + And I expect this node to be classified as "tethered" + And I expect this node to be of type "Neos.ContentRepository.Testing:SubSubNode" + And I expect this node to be named "grandchild-node" + And I expect this node to have the following properties: + | Key | Value | + | text | "my sub sub default" | + + When I am in content stream "cs-identifier" and dimension space point [] + And I expect node aggregate identifier "lady-eleonode-rootford" to lead to node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have no parent node + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | child-node | cs-identifier;nody-mc-nodeface;{} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nody-mc-nodeface" and node path "child-node" to lead to node cs-identifier;nody-mc-nodeface;{} + And I expect this node to be a child of node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | grandchild-node | cs-identifier;nodimus-prime;{} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nodimus-prime" and node path "child-node/grandchild-node" to lead to node cs-identifier;nodimus-prime;{} + And I expect this node to be a child of node cs-identifier;nody-mc-nodeface;{} + And I expect this node to have no child nodes + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/04-CreateRootNodeAggregateWithNodeAndTetheredChildren_WithDimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/04-CreateRootNodeAggregateWithNodeAndTetheredChildren_WithDimensions.feature new file mode 100644 index 00000000000..cf15c9682e6 --- /dev/null +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/04-CreateRootNodeAggregateWithNodeAndTetheredChildren_WithDimensions.feature @@ -0,0 +1,293 @@ +@contentrepository @adapters=DoctrineDBAL +Feature: Create a root node aggregate with tethered children + + As a user of the CR I want to create a new root node aggregate with an initial node and tethered children. + + These are the test cases with dimensions involved + + Background: + Given using the following content dimensions: + | Identifier | Values | Generalizations | + | language | de, en, gsw, en_US | en_US->en, gsw->de | + And using the following node types: + """yaml + 'Neos.ContentRepository.Testing:SubSubNode': + properties: + text: + defaultValue: 'my sub sub default' + type: string + 'Neos.ContentRepository.Testing:SubNode': + childNodes: + grandchild-node: + type: 'Neos.ContentRepository.Testing:SubSubNode' + properties: + text: + defaultValue: 'my sub default' + type: string + 'Neos.ContentRepository.Testing:RootWithTetheredChildNodes': + superTypes: + 'Neos.ContentRepository:Root': true + childNodes: + child-node: + type: 'Neos.ContentRepository.Testing:SubNode' + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | workspaceTitle | "Live" | + | workspaceDescription | "The live workspace" | + | newContentStreamId | "cs-identifier" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" + And I am user identified by "initiating-user-identifier" + + Scenario: Create root node with tethered children + When the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" | + | tetheredDescendantNodeAggregateIds | {"child-node": "nody-mc-nodeface", "child-node/grandchild-node": "nodimus-prime"} | + And the graph projection is fully up to date + + Then I expect exactly 6 events to be published on stream "ContentStream:cs-identifier" + And event at index 1 is of type "RootNodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" | + | coveredDimensionSpacePoints | [{"language": "de"}, {"language": "en"}, {"language": "gsw"}, {"language": "en_US"}] | + | nodeAggregateClassification | "root" | + And event at index 2 is of type "NodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nody-mc-nodeface" | + | nodeTypeName | "Neos.ContentRepository.Testing:SubNode" | + | originDimensionSpacePoint | {"language": "de"} | + | coveredDimensionSpacePoints | [{"language": "de"},{"language": "gsw"}] | + | parentNodeAggregateId | "lady-eleonode-rootford" | + | nodeName | "child-node" | + | initialPropertyValues | {"text": {"value": "my sub default", "type": "string"}} | + | nodeAggregateClassification | "tethered" | + And event at index 3 is of type "NodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nodimus-prime" | + | nodeTypeName | "Neos.ContentRepository.Testing:SubSubNode" | + | originDimensionSpacePoint | {"language": "de"} | + | coveredDimensionSpacePoints | [{"language": "de"},{"language": "gsw"}] | + | parentNodeAggregateId | "nody-mc-nodeface" | + | nodeName | "grandchild-node" | + | initialPropertyValues | {"text": {"value": "my sub sub default", "type": "string"}} | + | nodeAggregateClassification | "tethered" | + And event at index 4 is of type "NodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nody-mc-nodeface" | + | nodeTypeName | "Neos.ContentRepository.Testing:SubNode" | + | originDimensionSpacePoint | {"language": "en"} | + | coveredDimensionSpacePoints | [{"language": "en"},{"language": "en_US"}] | + | parentNodeAggregateId | "lady-eleonode-rootford" | + | nodeName | "child-node" | + | initialPropertyValues | {"text": {"value": "my sub default", "type": "string"}} | + | nodeAggregateClassification | "tethered" | + And event at index 5 is of type "NodeAggregateWithNodeWasCreated" with payload: + | Key | Expected | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nodimus-prime" | + | nodeTypeName | "Neos.ContentRepository.Testing:SubSubNode" | + | originDimensionSpacePoint | {"language": "en"} | + | coveredDimensionSpacePoints | [{"language": "en"},{"language": "en_US"}] | + | parentNodeAggregateId | "nody-mc-nodeface" | + | nodeName | "grandchild-node" | + | initialPropertyValues | {"text": {"value": "my sub sub default", "type": "string"}} | + | nodeAggregateClassification | "tethered" | + + And I expect the node aggregate "lady-eleonode-rootford" to exist + And I expect this node aggregate to be classified as "root" + And I expect this node aggregate to be of type "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" + And I expect this node aggregate to be unnamed + And I expect this node aggregate to occupy dimension space points [{}] + And I expect this node aggregate to cover dimension space points [{"language": "de"}, {"language": "en"}, {"language": "gsw"}, {"language": "en_US"}] + And I expect this node aggregate to disable dimension space points [] + And I expect this node aggregate to have no parent node aggregates + And I expect this node aggregate to have the child node aggregates ["nody-mc-nodeface"] + + And I expect the node aggregate "nody-mc-nodeface" to exist + And I expect this node aggregate to be classified as "tethered" + And I expect this node aggregate to be of type "Neos.ContentRepository.Testing:SubNode" + And I expect this node aggregate to be named "child-node" + And I expect this node aggregate to occupy dimension space points [{"language": "de"}, {"language": "en"}] + And I expect this node aggregate to cover dimension space points [{"language": "de"}, {"language": "en"}, {"language": "gsw"}, {"language": "en_US"}] + And I expect this node aggregate to disable dimension space points [] + And I expect this node aggregate to have the parent node aggregates ["lady-eleonode-rootford"] + And I expect this node aggregate to have the child node aggregates ["nodimus-prime"] + + And I expect the node aggregate "nodimus-prime" to exist + And I expect this node aggregate to be classified as "tethered" + And I expect this node aggregate to be of type "Neos.ContentRepository.Testing:SubSubNode" + And I expect this node aggregate to be named "grandchild-node" + And I expect this node aggregate to occupy dimension space points [{"language": "de"}, {"language": "en"}] + And I expect this node aggregate to cover dimension space points [{"language": "de"}, {"language": "en"}, {"language": "gsw"}, {"language": "en_US"}] + And I expect this node aggregate to disable dimension space points [] + And I expect this node aggregate to have the parent node aggregates ["nody-mc-nodeface"] + And I expect this node aggregate to have no child node aggregates + + And I expect the graph projection to consist of exactly 5 nodes + And I expect a node identified by cs-identifier;lady-eleonode-rootford;{} to exist in the content graph + And I expect this node to be classified as "root" + And I expect this node to be of type "Neos.ContentRepository.Testing:RootWithTetheredChildNodes" + And I expect this node to be unnamed + And I expect this node to have no properties + + And I expect a node identified by cs-identifier;nody-mc-nodeface;{"language": "de"} to exist in the content graph + And I expect this node to be classified as "tethered" + And I expect this node to be of type "Neos.ContentRepository.Testing:SubNode" + And I expect this node to be named "child-node" + And I expect this node to have the following properties: + | Key | Value | + | text | "my sub default" | + + And I expect a node identified by cs-identifier;nody-mc-nodeface;{"language": "en"} to exist in the content graph + And I expect this node to be classified as "tethered" + And I expect this node to be of type "Neos.ContentRepository.Testing:SubNode" + And I expect this node to be named "child-node" + And I expect this node to have the following properties: + | Key | Value | + | text | "my sub default" | + + And I expect a node identified by cs-identifier;nodimus-prime;{"language": "de"} to exist in the content graph + And I expect this node to be classified as "tethered" + And I expect this node to be of type "Neos.ContentRepository.Testing:SubSubNode" + And I expect this node to be named "grandchild-node" + And I expect this node to have the following properties: + | Key | Value | + | text | "my sub sub default" | + + And I expect a node identified by cs-identifier;nodimus-prime;{"language": "en"} to exist in the content graph + And I expect this node to be classified as "tethered" + And I expect this node to be of type "Neos.ContentRepository.Testing:SubSubNode" + And I expect this node to be named "grandchild-node" + And I expect this node to have the following properties: + | Key | Value | + | text | "my sub sub default" | + + When I am in content stream "cs-identifier" and dimension space point {"language": "de"} + And I expect node aggregate identifier "lady-eleonode-rootford" to lead to node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have no parent node + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | child-node | cs-identifier;nody-mc-nodeface;{"language": "de"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nody-mc-nodeface" and node path "child-node" to lead to node cs-identifier;nody-mc-nodeface;{"language": "de"} + And I expect this node to be a child of node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | grandchild-node | cs-identifier;nodimus-prime;{"language": "de"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nodimus-prime" and node path "child-node/grandchild-node" to lead to node cs-identifier;nodimus-prime;{"language": "de"} + And I expect this node to be a child of node cs-identifier;nody-mc-nodeface;{"language": "de"} + And I expect this node to have no child nodes + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + When I am in content stream "cs-identifier" and dimension space point {"language": "gsw"} + And I expect node aggregate identifier "lady-eleonode-rootford" to lead to node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have no parent node + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | child-node | cs-identifier;nody-mc-nodeface;{"language": "de"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nody-mc-nodeface" and node path "child-node" to lead to node cs-identifier;nody-mc-nodeface;{"language": "de"} + And I expect this node to be a child of node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | grandchild-node | cs-identifier;nodimus-prime;{"language": "de"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nodimus-prime" and node path "child-node/grandchild-node" to lead to node cs-identifier;nodimus-prime;{"language": "de"} + And I expect this node to be a child of node cs-identifier;nody-mc-nodeface;{"language": "de"} + And I expect this node to have no child nodes + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + + When I am in content stream "cs-identifier" and dimension space point {"language": "en"} + And I expect node aggregate identifier "lady-eleonode-rootford" to lead to node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have no parent node + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | child-node | cs-identifier;nody-mc-nodeface;{"language": "en"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nody-mc-nodeface" and node path "child-node" to lead to node cs-identifier;nody-mc-nodeface;{"language": "en"} + And I expect this node to be a child of node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | grandchild-node | cs-identifier;nodimus-prime;{"language": "en"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nodimus-prime" and node path "child-node/grandchild-node" to lead to node cs-identifier;nodimus-prime;{"language": "en"} + And I expect this node to be a child of node cs-identifier;nody-mc-nodeface;{"language": "en"} + And I expect this node to have no child nodes + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + + When I am in content stream "cs-identifier" and dimension space point {"language": "en_US"} + And I expect node aggregate identifier "lady-eleonode-rootford" to lead to node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have no parent node + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | child-node | cs-identifier;nody-mc-nodeface;{"language": "en"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nody-mc-nodeface" and node path "child-node" to lead to node cs-identifier;nody-mc-nodeface;{"language": "en"} + And I expect this node to be a child of node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | grandchild-node | cs-identifier;nodimus-prime;{"language": "en"} | + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + + And I expect node aggregate identifier "nodimus-prime" and node path "child-node/grandchild-node" to lead to node cs-identifier;nodimus-prime;{"language": "en"} + And I expect this node to be a child of node cs-identifier;nody-mc-nodeface;{"language": "en"} + And I expect this node to have no child nodes + And I expect this node to have no preceding siblings + And I expect this node to have no succeeding siblings + And I expect this node to have no references + And I expect this node to not be referenced + diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/03-CreateRootNodeAggregateWithNode_WithDimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/05-CreateRootNodeAggregateWithNode_WithDimensions.feature similarity index 100% rename from Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/03-CreateRootNodeAggregateWithNode_WithDimensions.feature rename to Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/01-RootNodeCreation/05-CreateRootNodeAggregateWithNode_WithDimensions.feature diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/07-NodeRemoval/01-RemoveNodeAggregate_ConstraintChecks.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/07-NodeRemoval/01-RemoveNodeAggregate_ConstraintChecks.feature index 970c803e274..53561be51c4 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/07-NodeRemoval/01-RemoveNodeAggregate_ConstraintChecks.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/07-NodeRemoval/01-RemoveNodeAggregate_ConstraintChecks.feature @@ -21,27 +21,27 @@ Feature: Remove NodeAggregate And I am in content repository "default" And I am user identified by "initiating-user-identifier" And the command CreateRootWorkspace is executed with payload: - | Key | Value | - | workspaceName | "live" | - | workspaceTitle | "Live" | - | workspaceDescription | "The live workspace" | - | newContentStreamId | "cs-identifier" | + | Key | Value | + | workspaceName | "live" | + | workspaceTitle | "Live" | + | workspaceDescription | "The live workspace" | + | newContentStreamId | "cs-identifier" | And the graph projection is fully up to date And I am in content stream "cs-identifier" and dimension space point {"language":"de"} And the command CreateRootNodeAggregateWithNode is executed with payload: - | Key | Value | + | Key | Value | | nodeAggregateId | "lady-eleonode-rootford" | - | nodeTypeName | "Neos.ContentRepository:Root" | + | nodeTypeName | "Neos.ContentRepository:Root" | And the graph projection is fully up to date And the following CreateNodeAggregateWithNode commands are executed: - | nodeAggregateId | nodeTypeName | parentNodeAggregateId | nodeName | tetheredDescendantNodeAggregateIds | - | sir-david-nodenborough | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | document | {"tethered":"nodewyn-tetherton"} | + | nodeAggregateId | nodeTypeName | parentNodeAggregateId | nodeName | tetheredDescendantNodeAggregateIds | + | sir-david-nodenborough | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | document | {"tethered":"nodewyn-tetherton"} | Scenario: Try to remove a node aggregate in a non-existing content stream When the command RemoveNodeAggregate is executed with payload and exceptions are caught: | Key | Value | - | contentStreamId | "i-do-not-exist" | - | nodeAggregateId | "sir-david-nodenborough" | + | contentStreamId | "i-do-not-exist" | + | nodeAggregateId | "sir-david-nodenborough" | | coveredDimensionSpacePoint | {"language":"de"} | | nodeVariantSelectionStrategy | "allVariants" | Then the last command should have thrown an exception of type "ContentStreamDoesNotExistYet" @@ -49,7 +49,7 @@ Feature: Remove NodeAggregate Scenario: Try to remove a non-existing node aggregate When the command RemoveNodeAggregate is executed with payload and exceptions are caught: | Key | Value | - | nodeAggregateId | "i-do-not-exist" | + | nodeAggregateId | "i-do-not-exist" | | coveredDimensionSpacePoint | {"language":"de"} | | nodeVariantSelectionStrategy | "allVariants" | Then the last command should have thrown an exception of type "NodeAggregateCurrentlyDoesNotExist" @@ -57,7 +57,7 @@ Feature: Remove NodeAggregate Scenario: Try to remove a tethered node aggregate When the command RemoveNodeAggregate is executed with payload and exceptions are caught: | Key | Value | - | nodeAggregateId | "nodewyn-tetherton" | + | nodeAggregateId | "nodewyn-tetherton" | | nodeVariantSelectionStrategy | "allVariants" | | coveredDimensionSpacePoint | {"language":"de"} | Then the last command should have thrown an exception of type "TetheredNodeAggregateCannotBeRemoved" @@ -65,23 +65,23 @@ Feature: Remove NodeAggregate Scenario: Try to remove a node aggregate in a non-existing dimension space point When the command RemoveNodeAggregate is executed with payload and exceptions are caught: | Key | Value | - | nodeAggregateId | "sir-david-nodenborough" | + | nodeAggregateId | "sir-david-nodenborough" | | coveredDimensionSpacePoint | {"undeclared": "undefined"} | | nodeVariantSelectionStrategy | "allVariants" | Then the last command should have thrown an exception of type "DimensionSpacePointNotFound" Scenario: Try to remove a node aggregate in a dimension space point the node aggregate does not cover When the command RemoveNodeAggregate is executed with payload and exceptions are caught: - | Key | Value | - | nodeAggregateId | "sir-david-nodenborough" | - | coveredDimensionSpacePoint | {"language": "en"} | - | nodeVariantSelectionStrategy | "allVariants" | + | Key | Value | + | nodeAggregateId | "sir-david-nodenborough" | + | coveredDimensionSpacePoint | {"language": "en"} | + | nodeVariantSelectionStrategy | "allVariants" | Then the last command should have thrown an exception of type "NodeAggregateDoesCurrentlyNotCoverDimensionSpacePoint" Scenario: Try to remove a node aggregate using a non-existent removalAttachmentPoint When the command RemoveNodeAggregate is executed with payload and exceptions are caught: | Key | Value | - | nodeAggregateId | "sir-david-nodenborough" | + | nodeAggregateId | "sir-david-nodenborough" | | nodeVariantSelectionStrategy | "allVariants" | | coveredDimensionSpacePoint | {"language":"de"} | | removalAttachmentPoint | "i-do-not-exist" | diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregate.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregate.feature similarity index 100% rename from Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregate.feature rename to Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregate.feature diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregateConsideringDisableStateWithoutDimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregateConsideringDisableStateWithoutDimensions.feature similarity index 100% rename from Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregateConsideringDisableStateWithoutDimensions.feature rename to Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregateConsideringDisableStateWithoutDimensions.feature diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregateWithoutDimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregateWithoutDimensions.feature similarity index 100% rename from Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregateWithoutDimensions.feature rename to Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregateWithoutDimensions.feature diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregate_NewParent_Dimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregate_NewParent_Dimensions.feature similarity index 100% rename from Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregate_NewParent_Dimensions.feature rename to Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregate_NewParent_Dimensions.feature diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregate_NoNewParent_Dimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregate_NoNewParent_Dimensions.feature similarity index 64% rename from Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregate_NoNewParent_Dimensions.feature rename to Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregate_NoNewParent_Dimensions.feature index c90dc25ff35..95e2549cd30 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeMove/MoveNodeAggregate_NoNewParent_Dimensions.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/08-NodeMove/MoveNodeAggregate_NoNewParent_Dimensions.feature @@ -19,85 +19,85 @@ Feature: Move a node with content dimensions And using identifier "default", I define a content repository And I am in content repository "default" And the command CreateRootWorkspace is executed with payload: - | Key | Value | - | workspaceName | "live" | - | workspaceTitle | "Live" | - | workspaceDescription | "The live workspace" | - | newContentStreamId | "cs-identifier" | + | Key | Value | + | workspaceName | "live" | + | workspaceTitle | "Live" | + | workspaceDescription | "The live workspace" | + | newContentStreamId | "cs-identifier" | And the graph projection is fully up to date And the command CreateRootNodeAggregateWithNode is executed with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "lady-eleonode-rootford" | - | nodeTypeName | "Neos.ContentRepository:Root" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository:Root" | And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "sir-david-nodenborough" | - | nodeTypeName | "Neos.ContentRepository.Testing:Document" | - | originDimensionSpacePoint | {"language": "mul"} | - | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | - | parentNodeAggregateId | "lady-eleonode-rootford" | - | nodeName | "document" | - | nodeAggregateClassification | "regular" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "sir-david-nodenborough" | + | nodeTypeName | "Neos.ContentRepository.Testing:Document" | + | originDimensionSpacePoint | {"language": "mul"} | + | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | + | parentNodeAggregateId | "lady-eleonode-rootford" | + | nodeName | "document" | + | nodeAggregateClassification | "regular" | And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "anthony-destinode" | - | nodeTypeName | "Neos.ContentRepository.Testing:Document" | - | originDimensionSpacePoint | {"language": "mul"} | - | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | - | parentNodeAggregateId | "sir-david-nodenborough" | - | nodeName | "child-document-a" | - | nodeAggregateClassification | "regular" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "anthony-destinode" | + | nodeTypeName | "Neos.ContentRepository.Testing:Document" | + | originDimensionSpacePoint | {"language": "mul"} | + | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | + | parentNodeAggregateId | "sir-david-nodenborough" | + | nodeName | "child-document-a" | + | nodeAggregateClassification | "regular" | And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "berta-destinode" | - | nodeTypeName | "Neos.ContentRepository.Testing:Document" | - | originDimensionSpacePoint | {"language": "mul"} | - | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | - | parentNodeAggregateId | "sir-david-nodenborough" | - | nodeName | "child-document-b" | - | nodeAggregateClassification | "regular" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "berta-destinode" | + | nodeTypeName | "Neos.ContentRepository.Testing:Document" | + | originDimensionSpacePoint | {"language": "mul"} | + | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | + | parentNodeAggregateId | "sir-david-nodenborough" | + | nodeName | "child-document-b" | + | nodeAggregateClassification | "regular" | And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "nody-mc-nodeface" | - | nodeTypeName | "Neos.ContentRepository.Testing:Document" | - | originDimensionSpacePoint | {"language": "mul"} | - | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | - | parentNodeAggregateId | "sir-david-nodenborough" | - | nodeName | "child-document-n" | - | nodeAggregateClassification | "regular" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nody-mc-nodeface" | + | nodeTypeName | "Neos.ContentRepository.Testing:Document" | + | originDimensionSpacePoint | {"language": "mul"} | + | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | + | parentNodeAggregateId | "sir-david-nodenborough" | + | nodeName | "child-document-n" | + | nodeAggregateClassification | "regular" | And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "carl-destinode" | - | nodeTypeName | "Neos.ContentRepository.Testing:Document" | - | originDimensionSpacePoint | {"language": "mul"} | - | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | - | parentNodeAggregateId | "sir-david-nodenborough" | - | nodeName | "child-document-c" | - | nodeAggregateClassification | "regular" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "carl-destinode" | + | nodeTypeName | "Neos.ContentRepository.Testing:Document" | + | originDimensionSpacePoint | {"language": "mul"} | + | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | + | parentNodeAggregateId | "sir-david-nodenborough" | + | nodeName | "child-document-c" | + | nodeAggregateClassification | "regular" | And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "sir-nodeward-nodington-iii" | - | nodeTypeName | "Neos.ContentRepository.Testing:Document" | - | originDimensionSpacePoint | {"language": "mul"} | - | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | - | parentNodeAggregateId | "lady-eleonode-rootford" | - | nodeName | "esquire" | - | nodeAggregateClassification | "regular" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "sir-nodeward-nodington-iii" | + | nodeTypeName | "Neos.ContentRepository.Testing:Document" | + | originDimensionSpacePoint | {"language": "mul"} | + | coveredDimensionSpacePoints | [{"language": "mul"}, {"language": "de"}, {"language": "en"}, {"language": "gsw"}] | + | parentNodeAggregateId | "lady-eleonode-rootford" | + | nodeName | "esquire" | + | nodeAggregateClassification | "regular" | And the graph projection is fully up to date Scenario: Move a complete node aggregate before the first of its siblings When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newParentNodeAggregateId | null | | newSucceedingSiblingNodeAggregateId | "anthony-destinode" | And the graph projection is fully up to date @@ -115,20 +115,20 @@ Feature: Move a node with content dimensions Scenario: Move a complete node aggregate before the first of its siblings - which does not exist in all variants Given the event NodeAggregateWasRemoved was published with payload: | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "anthony-destinode" | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "anthony-destinode" | | affectedOccupiedDimensionSpacePoints | [] | | affectedCoveredDimensionSpacePoints | [{"language": "gsw"}] | And the graph projection is fully up to date When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newParentNodeAggregateId | null | | newSucceedingSiblingNodeAggregateId | "anthony-destinode" | - | relationDistributionStrategy | "gatherAll" | + | relationDistributionStrategy | "gatherAll" | And the graph projection is fully up to date When I am in content stream "cs-identifier" and dimension space point {"language": "mul"} @@ -152,10 +152,10 @@ Feature: Move a node with content dimensions Scenario: Move a complete node aggregate before another of its siblings When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newParentNodeAggregateId | null | | newSucceedingSiblingNodeAggregateId | "berta-destinode" | And the graph projection is fully up to date @@ -174,17 +174,17 @@ Feature: Move a node with content dimensions Scenario: Move a complete node aggregate before another of its siblings - which does not exist in all variants Given the event NodeAggregateWasRemoved was published with payload: | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "berta-destinode" | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "berta-destinode" | | affectedOccupiedDimensionSpacePoints | [] | | affectedCoveredDimensionSpacePoints | [{"language": "gsw"}] | And the graph projection is fully up to date When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newParentNodeAggregateId | null | | newSucceedingSiblingNodeAggregateId | "berta-destinode" | And the graph projection is fully up to date @@ -213,17 +213,17 @@ Feature: Move a node with content dimensions Scenario: Move a complete node aggregate after another of its siblings - which does not exist in all variants Given the event NodeAggregateWasRemoved was published with payload: | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "carl-destinode" | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "carl-destinode" | | affectedOccupiedDimensionSpacePoints | [] | | affectedCoveredDimensionSpacePoints | [{"language": "gsw"}] | And the graph projection is fully up to date When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newParentNodeAggregateId | null | | newPrecedingSiblingNodeAggregateId | "berta-destinode" | And the graph projection is fully up to date @@ -251,17 +251,17 @@ Feature: Move a node with content dimensions Scenario: Move a complete node aggregate after the last of its siblings - with a predecessor which does not exist in all variants Given the event NodeAggregateWasRemoved was published with payload: | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "carl-destinode" | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "carl-destinode" | | affectedOccupiedDimensionSpacePoints | [] | | affectedCoveredDimensionSpacePoints | [{"language": "gsw"}] | And the graph projection is fully up to date When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newParentNodeAggregateId | null | | newSucceedingSiblingNodeAggregateId | null | And the graph projection is fully up to date @@ -287,12 +287,12 @@ Feature: Move a node with content dimensions Scenario: Move a single node before the first of its siblings When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newSucceedingSiblingNodeAggregateId | "anthony-destinode" | - | relationDistributionStrategy | "scatter" | + | relationDistributionStrategy | "scatter" | And the graph projection is fully up to date When I am in content stream "cs-identifier" and dimension space point {"language": "mul"} @@ -318,12 +318,12 @@ Feature: Move a node with content dimensions Scenario: Move a single node between two of its siblings When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "mul"} | + | dimensionSpacePoint | {"language": "mul"} | | newSucceedingSiblingNodeAggregateId | "berta-destinode" | - | relationDistributionStrategy | "scatter" | + | relationDistributionStrategy | "scatter" | And the graph projection is fully up to date When I am in content stream "cs-identifier" and dimension space point {"language": "mul"} @@ -351,8 +351,8 @@ Feature: Move a node with content dimensions Scenario: Move a single node to the end of its siblings When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "nody-mc-nodeface" | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nody-mc-nodeface" | | dimensionSpacePoint | {"language": "mul"} | | relationDistributionStrategy | "scatter" | And the graph projection is fully up to date @@ -380,12 +380,12 @@ Feature: Move a node with content dimensions Scenario: Move a node and its specializations before the first of its siblings When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "de"} | + | dimensionSpacePoint | {"language": "de"} | | newSucceedingSiblingNodeAggregateId | "anthony-destinode" | - | relationDistributionStrategy | "gatherSpecializations" | + | relationDistributionStrategy | "gatherSpecializations" | And the graph projection is fully up to date When I am in content stream "cs-identifier" and dimension space point {"language": "mul"} @@ -421,12 +421,12 @@ Feature: Move a node with content dimensions Scenario: Move a node and its specializations between two of its siblings When the command MoveNodeAggregate is executed with payload: - | Key | Value | + | Key | Value | | contentStreamId | "cs-identifier" | | nodeAggregateId | "nody-mc-nodeface" | - | dimensionSpacePoint | {"language": "de"} | + | dimensionSpacePoint | {"language": "de"} | | newSucceedingSiblingNodeAggregateId | "berta-destinode" | - | relationDistributionStrategy | "gatherSpecializations" | + | relationDistributionStrategy | "gatherSpecializations" | And the graph projection is fully up to date When I am in content stream "cs-identifier" and dimension space point {"language": "mul"} @@ -465,8 +465,8 @@ Feature: Move a node with content dimensions Scenario: Move a node and its specializations to the end of its siblings When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "nody-mc-nodeface" | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nody-mc-nodeface" | | dimensionSpacePoint | {"language": "de"} | | relationDistributionStrategy | "gatherSpecializations" | And the graph projection is fully up to date @@ -501,3 +501,85 @@ Feature: Move a node with content dimensions | cs-identifier;berta-destinode;{"language": "mul"} | | cs-identifier;anthony-destinode;{"language": "mul"} | And I expect this node to have no succeeding siblings + + Scenario: Trigger position update in DBAL graph + Given I am in content stream "cs-identifier" and dimension space point {"language": "mul"} + # distance i to x: 128 + Given the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | nodeTypeName | parentNodeAggregateId | nodeName | + | lady-nodette-nodington-i | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-i | + | lady-nodette-nodington-x | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-x | + | lady-nodette-nodington-ix | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-ix | + | lady-nodette-nodington-viii | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-viii | + | lady-nodette-nodington-vii | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-vii | + | lady-nodette-nodington-vi | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-vi | + | lady-nodette-nodington-v | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-v | + | lady-nodette-nodington-iv | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-iv | + | lady-nodette-nodington-iii | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-iii | + | lady-nodette-nodington-ii | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | nodington-ii | + # distance ii to x: 64 + When the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-ii" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + # distance iii to x: 32 + And the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-iii" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + # distance iv to x: 16 + And the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-iv" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + # distance v to x: 8 + And the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-v" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + # distance vi to x: 4 + And the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-vi" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + # distance vii to x: 2 + And the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-vii" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + # distance viii to x: 1 -> reorder -> 128 + And the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-viii" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + # distance ix to x: 64 after reorder + And the command MoveNodeAggregate is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-nodette-nodington-ix" | + | newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" | + And the graph projection is fully up to date + + Then I expect node aggregate identifier "lady-eleonode-rootford" to lead to node cs-identifier;lady-eleonode-rootford;{} + And I expect this node to have the following child nodes: + | Name | NodeDiscriminator | + | document | cs-identifier;sir-david-nodenborough;{"language": "mul"} | + | esquire | cs-identifier;sir-nodeward-nodington-iii;{"language": "mul"} | + | nodington-i | cs-identifier;lady-nodette-nodington-i;{"language": "mul"} | + | nodington-ii | cs-identifier;lady-nodette-nodington-ii;{"language": "mul"} | + | nodington-iii | cs-identifier;lady-nodette-nodington-iii;{"language": "mul"} | + | nodington-iv | cs-identifier;lady-nodette-nodington-iv;{"language": "mul"} | + | nodington-v | cs-identifier;lady-nodette-nodington-v;{"language": "mul"} | + | nodington-vi | cs-identifier;lady-nodette-nodington-vi;{"language": "mul"} | + | nodington-vii | cs-identifier;lady-nodette-nodington-vii;{"language": "mul"} | + | nodington-viii | cs-identifier;lady-nodette-nodington-viii;{"language": "mul"} | + | nodington-ix | cs-identifier;lady-nodette-nodington-ix;{"language": "mul"} | + | nodington-x | cs-identifier;lady-nodette-nodington-x;{"language": "mul"} | + + diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeRenaming/01_ChangeNodeAggregateName_ConstraintChecks.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeRenaming/01_ChangeNodeAggregateName_ConstraintChecks.feature new file mode 100644 index 00000000000..613c3bb4213 --- /dev/null +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/NodeRenaming/01_ChangeNodeAggregateName_ConstraintChecks.feature @@ -0,0 +1,73 @@ +@contentrepository @adapters=DoctrineDBAL +Feature: Change node name + + As a user of the CR I want to change the name of a hierarchical relation between two nodes (e.g. in taxonomies) + + These are the base test cases for the NodeAggregateCommandHandler to block invalid commands. + + Background: + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.ContentRepository.Testing:Content': [] + 'Neos.ContentRepository.Testing:Document': + childNodes: + tethered: + type: 'Neos.ContentRepository.Testing:Content' + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | workspaceTitle | "Live" | + | workspaceDescription | "The live workspace" | + | newContentStreamId | "cs-identifier" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" and dimension space point {} + + And the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository:Root" | + And the graph projection is fully up to date + And the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | nodeName | nodeTypeName | parentNodeAggregateId | initialPropertyValues | tetheredDescendantNodeAggregateIds | + | sir-david-nodenborough | null | Neos.ContentRepository.Testing:Document | lady-eleonode-rootford | {} | {"tethered": "nodewyn-tetherton"} | + | nody-mc-nodeface | occupied | Neos.ContentRepository.Testing:Document | sir-david-nodenborough | {} | {} | + + Scenario: Try to rename a node aggregate in a non-existing content stream + When the command ChangeNodeAggregateName is executed with payload and exceptions are caught: + | Key | Value | + | contentStreamId | "i-do-not-exist" | + | nodeAggregateId | "sir-david-nodenborough" | + | newNodeName | "new-name" | + Then the last command should have thrown an exception of type "ContentStreamDoesNotExistYet" + + Scenario: Try to rename a non-existing node aggregate + When the command ChangeNodeAggregateName is executed with payload and exceptions are caught: + | Key | Value | + | nodeAggregateId | "i-do-not-exist" | + | newNodeName | "new-name" | + Then the last command should have thrown an exception of type "NodeAggregateCurrentlyDoesNotExist" + + Scenario: Try to rename a root node aggregate + When the command ChangeNodeAggregateName is executed with payload and exceptions are caught: + | Key | Value | + | nodeAggregateId | "lady-eleonode-rootford" | + | newNodeName | "new-name" | + Then the last command should have thrown an exception of type "NodeAggregateIsRoot" + + Scenario: Try to rename a tethered node aggregate + When the command ChangeNodeAggregateName is executed with payload and exceptions are caught: + | Key | Value | + | nodeAggregateId | "nodewyn-tetherton" | + | newNodeName | "new-name" | + Then the last command should have thrown an exception of type "NodeAggregateIsTethered" + + Scenario: Try to rename a node aggregate using an already occupied name + When the command ChangeNodeAggregateName is executed with payload and exceptions are caught: + | Key | Value | + | nodeAggregateId | "nody-mc-nodeface" | + | newNodeName | "tethered" | + Then the last command should have thrown an exception of type "NodeNameIsAlreadyOccupied" diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/DisallowedChildNodesAndTetheredNodes.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/DisallowedChildNodesAndTetheredNodes.feature new file mode 100644 index 00000000000..9dc7063bf5d --- /dev/null +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/DisallowedChildNodesAndTetheredNodes.feature @@ -0,0 +1,49 @@ +@contentrepository @adapters=DoctrineDBAL +Feature: Remove disallowed Child Nodes and grandchild nodes + + As a user of the CR I want to be able to keep tethered child nodes although their type is not allowed below their parent + + Scenario: Direct constraints + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.ContentRepository:Root': + constraints: + nodeTypes: + '*': false + 'Neos.ContentRepository.Testing:Document': true + 'Neos.ContentRepository.Testing:Document': + constraints: + nodeTypes: + '*': false + childNodes: + tethered: + type: 'Neos.ContentRepository.Testing:AnotherDocument' + + 'Neos.ContentRepository.Testing:AnotherDocument': [] + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | workspaceTitle | "Live" | + | workspaceDescription | "The live workspace" | + | newContentStreamId | "cs-identifier" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" and dimension space point {} + And the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository:Root" | + And the graph projection is fully up to date + And the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | parentNodeAggregateId | nodeTypeName | + | nody-mc-nodeface | lady-eleonode-rootford | Neos.ContentRepository.Testing:Document | + + ######################## + # Actual Test + ######################## + Then I expect no needed structure adjustments for type "Neos.ContentRepository:Root" + Then I expect no needed structure adjustments for type "Neos.ContentRepository.Testing:Document" + Then I expect no needed structure adjustments for type "Neos.ContentRepository.Testing:AnotherDocument" diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/TetheredNodes.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/TetheredNodes.feature index 8f74410ec2b..6b8aa2ea3cd 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/TetheredNodes.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/TetheredNodes.feature @@ -10,6 +10,10 @@ Feature: Tethered Nodes integrity violations | language | en, de, gsw | gsw->de->en | And using the following node types: """yaml + 'Neos.ContentRepository:Root': + childNodes: + 'originally-tethered-node': + type: 'Neos.ContentRepository.Testing:Tethered' 'Neos.ContentRepository.Testing:Document': childNodes: 'tethered-node': @@ -27,59 +31,66 @@ Feature: Tethered Nodes integrity violations And using identifier "default", I define a content repository And I am in content repository "default" And the command CreateRootWorkspace is executed with payload: - | Key | Value | - | workspaceName | "live" | - | workspaceTitle | "Live" | - | workspaceDescription | "The live workspace" | - | newContentStreamId | "cs-identifier" | + | Key | Value | + | workspaceName | "live" | + | workspaceTitle | "Live" | + | workspaceDescription | "The live workspace" | + | newContentStreamId | "cs-identifier" | And the graph projection is fully up to date And the command CreateRootNodeAggregateWithNode is executed with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "lady-eleonode-rootford" | - | nodeTypeName | "Neos.ContentRepository:Root" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "lady-eleonode-rootford" | + | nodeTypeName | "Neos.ContentRepository:Root" | + | tetheredDescendantNodeAggregateIds | {"originally-tethered-node": "originode-tetherton"} | # We have to add another node since root nodes have no dimension space points and thus cannot be varied # Node /document And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "sir-david-nodenborough" | - | nodeTypeName | "Neos.ContentRepository.Testing:Document" | - | originDimensionSpacePoint | {"market":"CH", "language":"gsw"} | - | coveredDimensionSpacePoints | [{"market":"CH", "language":"gsw"}] | - | parentNodeAggregateId | "lady-eleonode-rootford" | - | nodeName | "document" | - | nodeAggregateClassification | "regular" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "sir-david-nodenborough" | + | nodeTypeName | "Neos.ContentRepository.Testing:Document" | + | originDimensionSpacePoint | {"market":"CH", "language":"gsw"} | + | coveredDimensionSpacePoints | [{"market":"CH", "language":"gsw"}] | + | parentNodeAggregateId | "lady-eleonode-rootford" | + | nodeName | "document" | + | nodeAggregateClassification | "regular" | # We add a tethered child node to provide for test cases for node aggregates of that classification # Node /document/tethered-node And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "nodewyn-tetherton" | - | nodeTypeName | "Neos.ContentRepository.Testing:Tethered" | - | originDimensionSpacePoint | {"market":"CH", "language":"gsw"} | - | coveredDimensionSpacePoints | [{"market":"CH", "language":"gsw"}] | - | parentNodeAggregateId | "sir-david-nodenborough" | - | nodeName | "tethered-node" | - | nodeAggregateClassification | "tethered" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nodewyn-tetherton" | + | nodeTypeName | "Neos.ContentRepository.Testing:Tethered" | + | originDimensionSpacePoint | {"market":"CH", "language":"gsw"} | + | coveredDimensionSpacePoints | [{"market":"CH", "language":"gsw"}] | + | parentNodeAggregateId | "sir-david-nodenborough" | + | nodeName | "tethered-node" | + | nodeAggregateClassification | "tethered" | # We add a tethered grandchild node to provide for test cases that this works recursively # Node /document/tethered-node/tethered-leaf And the event NodeAggregateWithNodeWasCreated was published with payload: - | Key | Value | - | contentStreamId | "cs-identifier" | - | nodeAggregateId | "nodimer-tetherton" | - | nodeTypeName | "Neos.ContentRepository.Testing:TetheredLeaf" | - | originDimensionSpacePoint | {"market":"CH", "language":"gsw"} | - | coveredDimensionSpacePoints | [{"market":"CH", "language":"gsw"}] | - | parentNodeAggregateId | "nodewyn-tetherton" | - | nodeName | "tethered-leaf" | - | nodeAggregateClassification | "tethered" | + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "nodimer-tetherton" | + | nodeTypeName | "Neos.ContentRepository.Testing:TetheredLeaf" | + | originDimensionSpacePoint | {"market":"CH", "language":"gsw"} | + | coveredDimensionSpacePoints | [{"market":"CH", "language":"gsw"}] | + | parentNodeAggregateId | "nodewyn-tetherton" | + | nodeName | "tethered-leaf" | + | nodeAggregateClassification | "tethered" | And the graph projection is fully up to date Then I expect no needed structure adjustments for type "Neos.ContentRepository.Testing:Document" Scenario: Adjusting the schema adding a new tethered node leads to a MissingTetheredNode integrity violation Given I change the node types in content repository "default" to: """yaml + 'Neos.ContentRepository:Root': + childNodes: + 'originally-tethered-node': + type: 'Neos.ContentRepository.Testing:Tethered' + 'tethered-node': + type: 'Neos.ContentRepository.Testing:Tethered' 'Neos.ContentRepository.Testing:Document': childNodes: 'tethered-node': @@ -97,13 +108,21 @@ Feature: Tethered Nodes integrity violations 'Neos.ContentRepository.Testing:TetheredLeaf': [] """ Then I expect the following structure adjustments for type "Neos.ContentRepository.Testing:Document": - | Type | nodeAggregateId | - | TETHERED_NODE_MISSING | sir-david-nodenborough | - + | Type | nodeAggregateId | + | TETHERED_NODE_MISSING | sir-david-nodenborough | + And I expect the following structure adjustments for type "Neos.ContentRepository:Root": + | Type | nodeAggregateId | + | TETHERED_NODE_MISSING | lady-eleonode-rootford | Scenario: Adding missing tethered nodes resolves the corresponding integrity violations Given I change the node types in content repository "default" to: """yaml + 'Neos.ContentRepository:Root': + childNodes: + 'originally-tethered-node': + type: 'Neos.ContentRepository.Testing:Tethered' + 'tethered-node': + type: 'Neos.ContentRepository.Testing:Tethered' 'Neos.ContentRepository.Testing:Document': childNodes: 'tethered-node': @@ -122,12 +141,18 @@ Feature: Tethered Nodes integrity violations """ When I adjust the node structure for node type "Neos.ContentRepository.Testing:Document" Then I expect no needed structure adjustments for type "Neos.ContentRepository.Testing:Document" + When I adjust the node structure for node type "Neos.ContentRepository:Root" + Then I expect no needed structure adjustments for type "Neos.ContentRepository:Root" When I am in the active content stream of workspace "live" and dimension space point {"market":"CH", "language":"gsw"} And I get the node at path "document/some-new-child" And I expect this node to have the following properties: | Key | Value | | foo | "my default applied" | + And I get the node at path "tethered-node" + And I expect this node to have the following properties: + | Key | Value | + | foo | "my default applied" | Scenario: Adding the same Given I change the node types in content repository "default" to: @@ -149,13 +174,14 @@ Feature: Tethered Nodes integrity violations 'Neos.ContentRepository.Testing:TetheredLeaf': [] """ When I adjust the node structure for node type "Neos.ContentRepository.Testing:Document" - Then I expect exactly 6 events to be published on stream "ContentStream:cs-identifier" + Then I expect exactly 8 events to be published on stream "ContentStream:cs-identifier" When I adjust the node structure for node type "Neos.ContentRepository.Testing:Document" - Then I expect exactly 6 events to be published on stream "ContentStream:cs-identifier" + Then I expect exactly 8 events to be published on stream "ContentStream:cs-identifier" Scenario: Adjusting the schema removing a tethered node leads to a DisallowedTetheredNode integrity violation (which can be fixed) Given I change the node types in content repository "default" to: """yaml + 'Neos.ContentRepository:Root': [] 'Neos.ContentRepository.Testing:Document': [] 'Neos.ContentRepository.Testing:Tethered': properties: @@ -168,13 +194,19 @@ Feature: Tethered Nodes integrity violations 'Neos.ContentRepository.Testing:TetheredLeaf': [] """ Then I expect the following structure adjustments for type "Neos.ContentRepository.Testing:Document": - | Type | nodeAggregateId | - | DISALLOWED_TETHERED_NODE | nodewyn-tetherton | + | Type | nodeAggregateId | + | DISALLOWED_TETHERED_NODE | nodewyn-tetherton | + Then I expect the following structure adjustments for type "Neos.ContentRepository:Root": + | Type | nodeAggregateId | + | DISALLOWED_TETHERED_NODE | originode-tetherton | When I adjust the node structure for node type "Neos.ContentRepository.Testing:Document" Then I expect no needed structure adjustments for type "Neos.ContentRepository.Testing:Document" + When I adjust the node structure for node type "Neos.ContentRepository:Root" + Then I expect no needed structure adjustments for type "Neos.ContentRepository:Root" When I am in content stream "cs-identifier" and dimension space point {"market":"CH", "language":"gsw"} Then I expect node aggregate identifier "nodewyn-tetherton" to lead to no node Then I expect node aggregate identifier "nodimer-tetherton" to lead to no node + And I expect path "tethered-node" to lead to no node Scenario: Adjusting the schema changing the type of a tethered node leads to a InvalidTetheredNodeType integrity violation Given I change the node types in content repository "default" to: @@ -194,6 +226,6 @@ Feature: Tethered Nodes integrity violations 'Neos.ContentRepository.Testing:TetheredLeaf': [] """ Then I expect the following structure adjustments for type "Neos.ContentRepository.Testing:Document": - | Type | nodeAggregateId | - | TETHERED_NODE_TYPE_WRONG | nodewyn-tetherton | + | Type | nodeAggregateId | + | TETHERED_NODE_TYPE_WRONG | nodewyn-tetherton | diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php index 8d03f3624d0..9f457b03576 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php @@ -124,6 +124,7 @@ final public function equals(self $other): bool /** * @return array> + * @deprecated should be only used for conversion from Neos <= 8.x to 9.x upwards. never use this in "modern" code. */ final public function toLegacyDimensionArray(): array { diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php index aecb51fe6f1..9a31aef29ad 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php @@ -61,10 +61,21 @@ public static function fromJsonString(string $jsonString): self return self::instance(json_decode($jsonString, true)); } + /** + * Creates a dimension space point for a zero-dimensional content repository. + * + * This applies to content repositories without any dimensions configured. + */ + public static function createWithoutDimensions(): self + { + return self::fromArray([]); + } + /** * Creates a dimension space point from a legacy dimension array in format * ['language' => ['es'], 'country' => ['ar']] * + * @deprecated should be only used for conversion from Neos <= 8.x to 9.x upwards. never use this in "modern" code. * @param array> $legacyDimensionValues */ final public static function fromLegacyDimensionArray(array $legacyDimensionValues): self diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php index 03ca96bb152..56179626e7d 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php @@ -14,9 +14,14 @@ namespace Neos\ContentRepository\Core\DimensionSpace; +use Neos\ContentRepository\Core\EventStore\EventInterface; + /** * A set of points in the dimension space. * + * In case this set is a member of an {@see EventInterface} as $coveredDimensionSpacePoints, you can be sure that it is not empty. + * There is always at least one dimension space point covered, even in a zero-dimensional content repository. {@see DimensionSpacePoint::createWithoutDimensions()}. + * * E.g.: {[language => es, country => ar], [language => es, country => es]} * @implements \IteratorAggregate * @implements \ArrayAccess @@ -89,14 +94,14 @@ public function offsetGet(mixed $offset): ?DimensionSpacePoint return $this->points[$offset] ?? null; } - public function offsetSet(mixed $offset, mixed $value): void + public function offsetSet(mixed $offset, mixed $value): never { - // not going to happen + throw new \BadMethodCallException('Cannot modify immutable DimensionSpacePointSet', 1697802335); } - public function offsetUnset(mixed $offset): void + public function offsetUnset(mixed $offset): never { - // not going to happen + throw new \BadMethodCallException('Cannot modify immutable DimensionSpacePointSet', 1697802337); } public function getUnion(DimensionSpacePointSet $other): DimensionSpacePointSet diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/InterDimensionalVariationGraph.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/InterDimensionalVariationGraph.php index 7cc294a242a..52725f6ec9e 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/InterDimensionalVariationGraph.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/InterDimensionalVariationGraph.php @@ -17,62 +17,62 @@ use Neos\ContentRepository\Core\Dimension; /** - * The inter dimensional variation graph domain model + * The interdimensional variation graph domain model * Represents the specialization and generalization mechanism between dimension space points * @api */ -class InterDimensionalVariationGraph +final class InterDimensionalVariationGraph { /** * Weighed dimension space points, indexed by identity (DSP) hash * - * @var array|null + * @var array */ - protected ?array $weightedDimensionSpacePoints = null; + private array $weightedDimensionSpacePoints; /** * Generalization dimension space point sets, indexed by specialization hash * - * @var array|null + * @var array */ - protected ?array $indexedGeneralizations = null; + private array $indexedGeneralizations; /** * Specialization dimension space point sets, indexed by generalization hash * - * @var array|null + * @var array */ - protected ?array $indexedSpecializations = null; + private array $indexedSpecializations; /** * Weighed generalizations, indexed by specialization hash and relative weight * - * @var array>|null + * @var array> */ - protected ?array $weightedGeneralizations = null; + private array $weightedGeneralizations; /** * Weighed specializations, indexed by generalization hash, relative weight and specialization hash - * @var array>>|null + * @var array>> */ - protected ?array $weightedSpecializations = null; + private array $weightedSpecializations; /** * Primary generalization dimension space points, indexed by specialization hash * * @var array */ - protected ?array $primaryGeneralizations = null; + private array $primaryGeneralizations; - protected ?int $weightNormalizationBase = null; + private int $weightNormalizationBase; public function __construct( - private Dimension\ContentDimensionSourceInterface $contentDimensionSource, - private ContentDimensionZookeeper $contentDimensionZookeeper + private readonly Dimension\ContentDimensionSourceInterface $contentDimensionSource, + private readonly ContentDimensionZookeeper $contentDimensionZookeeper ) { } - protected function initializeWeightedDimensionSpacePoints(): void + private function initializeWeightedDimensionSpacePoints(): void { $this->weightedDimensionSpacePoints = []; foreach ($this->contentDimensionZookeeper->getAllowedCombinations() as $dimensionValues) { @@ -93,13 +93,10 @@ public function getDimensionSpacePoints(): DimensionSpacePointSet */ public function getWeightedDimensionSpacePoints(): array { - if (is_null($this->weightedDimensionSpacePoints)) { + if (!isset($this->weightedDimensionSpacePoints)) { $this->initializeWeightedDimensionSpacePoints(); } - /** @var array $weighedDimensionSpacePoints */ - $weighedDimensionSpacePoints = $this->weightedDimensionSpacePoints; - - return $weighedDimensionSpacePoints; + return $this->weightedDimensionSpacePoints; } public function getWeightedDimensionSpacePointByDimensionSpacePoint( @@ -110,7 +107,7 @@ public function getWeightedDimensionSpacePointByDimensionSpacePoint( public function getWeightedDimensionSpacePointByHash(string $hash): ?WeightedDimensionSpacePoint { - if (is_null($this->weightedDimensionSpacePoints)) { + if (!isset($this->weightedDimensionSpacePoints)) { $this->initializeWeightedDimensionSpacePoints(); } @@ -134,9 +131,9 @@ public function getRootGeneralizations(): array return $rootGeneralizations; } - protected function determineWeightNormalizationBase(): int + private function determineWeightNormalizationBase(): int { - if (is_null($this->weightNormalizationBase)) { + if (!isset($this->weightNormalizationBase)) { $base = 0; foreach ($this->contentDimensionSource->getContentDimensionsOrderedByPriority() as $contentDimension) { $base = max($base, $contentDimension->getMaximumDepth()->value + 1); @@ -148,13 +145,15 @@ protected function determineWeightNormalizationBase(): int return $this->weightNormalizationBase; } - protected function initializeVariations(): void + private function initializeVariations(): void { $normalizedVariationWeights = []; $lowestVariationWeights = []; $this->weightedGeneralizations = []; + /** @var array> $indexedGeneralizations */ $indexedGeneralizations = []; + /** @var array> $indexedSpecializations */ $indexedSpecializations = []; foreach ($this->getWeightedDimensionSpacePoints() as $generalizationHash => $generalization) { @@ -165,8 +164,8 @@ protected function initializeVariations(): void foreach ($generalization->dimensionValues as $rawDimensionId => $contentDimensionValue) { $dimensionId = new Dimension\ContentDimensionId($rawDimensionId); - /** @var Dimension\ContentDimension $dimension */ $dimension = $this->contentDimensionSource->getDimension($dimensionId); + assert($dimension !== null); foreach ($dimension->getSpecializations($contentDimensionValue) as $specializedValue) { $specializedDimensionSpacePoint = $generalization->dimensionSpacePoint ->vary($dimensionId, $specializedValue->value); @@ -206,16 +205,13 @@ protected function initializeVariations(): void } } - /** @var array> $indexedGeneralizations */ foreach ($indexedGeneralizations as $specializationHash => $generalizations) { $this->indexedGeneralizations[$specializationHash] = new DimensionSpacePointSet($generalizations); } - /** @var array> $indexedSpecializations */ foreach ($indexedSpecializations as $generalizationHash => $specializations) { $this->indexedSpecializations[$generalizationHash] = new DimensionSpacePointSet($specializations); } - /** @phpstan-ignore-next-line */ foreach ($this->weightedGeneralizations as $specializationHash => &$generalizationsByWeight) { ksort($generalizationsByWeight); } @@ -225,8 +221,10 @@ protected function initializeVariations(): void * @param array $normalizedVariationWeights * @param array>& $indexedGeneralizations * @param array>& $indexedSpecializations + * @param-out array> $indexedGeneralizations + * @param-out array> $indexedSpecializations */ - protected function initializeVariationsForDimensionSpacePointPair( + private function initializeVariationsForDimensionSpacePointPair( WeightedDimensionSpacePoint $specialization, WeightedDimensionSpacePoint $generalization, array $normalizedVariationWeights, @@ -237,9 +235,9 @@ protected function initializeVariationsForDimensionSpacePointPair( if (isset($indexedGeneralizations[$generalization->getIdentityHash()])) { $generalizations = $indexedGeneralizations[$generalization->getIdentityHash()]; foreach ($generalizations as $parentGeneralizationHash => $parentGeneralization) { - /** @var WeightedDimensionSpacePoint $weighedParent */ - $weighedParent = $this->getWeightedDimensionSpacePointByHash($parentGeneralizationHash); - $generalizationsToProcess[$parentGeneralizationHash] = $weighedParent; + $weightedParent = $this->getWeightedDimensionSpacePointByHash($parentGeneralizationHash); + assert($weightedParent !== null); + $generalizationsToProcess[$parentGeneralizationHash] = $weightedParent; } } @@ -265,7 +263,7 @@ protected function initializeVariationsForDimensionSpacePointPair( */ public function getIndexedSpecializations(DimensionSpacePoint $generalization): DimensionSpacePointSet { - if (is_null($this->indexedSpecializations)) { + if (!isset($this->indexedSpecializations)) { $this->initializeVariations(); } @@ -277,7 +275,7 @@ public function getIndexedSpecializations(DimensionSpacePoint $generalization): */ public function getIndexedGeneralizations(DimensionSpacePoint $specialization): DimensionSpacePointSet { - if (is_null($this->indexedGeneralizations)) { + if (!isset($this->indexedGeneralizations)) { $this->initializeVariations(); } @@ -291,7 +289,7 @@ public function getIndexedGeneralizations(DimensionSpacePoint $specialization): */ public function getWeightedSpecializations(DimensionSpacePoint $generalization): array { - if (is_null($this->weightedSpecializations)) { + if (!isset($this->weightedSpecializations)) { $this->initializeVariations(); } @@ -305,7 +303,7 @@ public function getWeightedSpecializations(DimensionSpacePoint $generalization): */ public function getWeightedGeneralizations(DimensionSpacePoint $specialization): array { - if (is_null($this->weightedGeneralizations)) { + if (!isset($this->weightedGeneralizations)) { $this->initializeVariations(); } @@ -344,7 +342,7 @@ public function getSpecializationSet( */ public function getPrimaryGeneralization(DimensionSpacePoint $specialization): ?DimensionSpacePoint { - if (is_null($this->primaryGeneralizations)) { + if (!isset($this->primaryGeneralizations)) { $this->initializeVariations(); } @@ -360,7 +358,7 @@ public function getVariantType(DimensionSpacePoint $subject, DimensionSpacePoint return VariantType::TYPE_SAME; } - if (is_null($this->indexedGeneralizations)) { + if (!isset($this->indexedGeneralizations)) { $this->initializeVariations(); } diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php index 270547793a3..8a689481c0c 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php @@ -14,9 +14,6 @@ namespace Neos\ContentRepository\Core\DimensionSpace; -use Neos\ContentRepository\Core\DimensionSpace\AbstractDimensionSpacePoint; -use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; - /** * A node's origin dimension space point. Defines in which point in the dimension space the node originates * (= is "at home"). Every node has exactly ONE OriginDimensionSpacePoint, but one or more {@see DimensionSpacePoint}s @@ -57,6 +54,16 @@ public static function fromArray(array $data): self return self::instance($data); } + /** + * Creates a dimension space point for a zero-dimensional content repository. + * + * This applies to content repositories without any dimensions configured. + */ + public static function createWithoutDimensions(): self + { + return self::fromArray([]); + } + /** * @param string $jsonString A JSON string representation, see jsonSerialize */ diff --git a/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php b/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php index abe98671da9..0980ba6be62 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php +++ b/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php @@ -18,6 +18,7 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; use Neos\ContentRepository\Core\DimensionSpace\Exception\DimensionSpacePointNotFound; +use Neos\ContentRepository\Core\NodeType\ConstraintCheck; use Neos\ContentRepository\Core\SharedModel\Exception\RootNodeAggregateDoesNotExist; use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet; use Neos\ContentRepository\Core\SharedModel\Exception\DimensionSpacePointIsNotYetOccupied; @@ -51,7 +52,7 @@ use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName; use Neos\ContentRepository\Core\NodeType\NodeType; -use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria; +use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraintsWithSubNodeTypes; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; @@ -216,18 +217,15 @@ protected function requireNodeTypeToAllowNodesOfTypeInReference( if (is_null($propertyDeclaration)) { throw ReferenceCannotBeSet::becauseTheNodeTypeDoesNotDeclareIt($referenceName, $nodeTypeName); } - if (isset($propertyDeclaration['constraints']['nodeTypes'])) { - $nodeTypeConstraints = ExpandedNodeTypeCriteria::createFromNodeTypeDeclaration( - $propertyDeclaration['constraints']['nodeTypes'], - $this->getNodeTypeManager() + + $constraints = $propertyDeclaration['constraints']['nodeTypes'] ?? []; + + if (!ConstraintCheck::create($constraints)->isNodeTypeAllowed($nodeType)) { + throw ReferenceCannotBeSet::becauseTheConstraintsAreNotMatched( + $referenceName, + $nodeTypeName, + $nodeTypeNameInQuestion ); - if (!$nodeTypeConstraints->matches($nodeTypeNameInQuestion)) { - throw ReferenceCannotBeSet::becauseTheConstraintsAreNotMatched( - $referenceName, - $nodeTypeName, - $nodeTypeNameInQuestion - ); - } } } diff --git a/Neos.ContentRepository.Core/Classes/Feature/Common/TetheredNodeInternals.php b/Neos.ContentRepository.Core/Classes/Feature/Common/TetheredNodeInternals.php index f52aac87f55..ba8ff204f27 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/Common/TetheredNodeInternals.php +++ b/Neos.ContentRepository.Core/Classes/Feature/Common/TetheredNodeInternals.php @@ -18,6 +18,7 @@ use Neos\ContentRepository\Core\EventStore\Events; use Neos\ContentRepository\Core\Feature\NodeCreation\Event\NodeAggregateWithNodeWasCreated; use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues; +use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodePeerVariantWasCreated; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification; @@ -26,7 +27,6 @@ use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\NodeType\NodeType; use Neos\ContentRepository\Core\NodeType\NodeTypeName; -use Neos\ContentRepository\Core\SharedModel\User\UserId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; /** @@ -54,15 +54,15 @@ abstract protected function createEventsForVariations( */ protected function createEventsForMissingTetheredNode( NodeAggregate $parentNodeAggregate, - Node $parentNode, + OriginDimensionSpacePoint $originDimensionSpacePoint, NodeName $tetheredNodeName, ?NodeAggregateId $tetheredNodeAggregateId, NodeType $expectedTetheredNodeType, ContentRepository $contentRepository ): Events { $childNodeAggregates = $contentRepository->getContentGraph()->findChildNodeAggregatesByName( - $parentNode->subgraphIdentity->contentStreamId, - $parentNode->nodeAggregateId, + $parentNodeAggregate->contentStreamId, + $parentNodeAggregate->nodeAggregateId, $tetheredNodeName ); @@ -75,19 +75,53 @@ protected function createEventsForMissingTetheredNode( if (count($childNodeAggregates) === 0) { // there is no tethered child node aggregate already; let's create it! - return Events::with( - new NodeAggregateWithNodeWasCreated( - $parentNode->subgraphIdentity->contentStreamId, - $tetheredNodeAggregateId ?: NodeAggregateId::create(), - $expectedTetheredNodeType->name, - $parentNode->originDimensionSpacePoint, - $parentNodeAggregate->getCoverageByOccupant($parentNode->originDimensionSpacePoint), - $parentNode->nodeAggregateId, - $tetheredNodeName, - SerializedPropertyValues::defaultFromNodeType($expectedTetheredNodeType), - NodeAggregateClassification::CLASSIFICATION_TETHERED, - ) - ); + $nodeType = $this->nodeTypeManager->getNodeType($parentNodeAggregate->nodeTypeName); + if ($nodeType->isOfType(NodeTypeName::ROOT_NODE_TYPE_NAME)) { + $events = []; + $tetheredNodeAggregateId = $tetheredNodeAggregateId ?: NodeAggregateId::create(); + // we create in one origin DSP and vary in the others + $creationOriginDimensionSpacePoint = null; + foreach ($this->getInterDimensionalVariationGraph()->getRootGeneralizations() as $rootGeneralization) { + $rootGeneralizationOrigin = OriginDimensionSpacePoint::fromDimensionSpacePoint($rootGeneralization); + if ($creationOriginDimensionSpacePoint) { + $events[] = new NodePeerVariantWasCreated( + $parentNodeAggregate->contentStreamId, + $tetheredNodeAggregateId, + $creationOriginDimensionSpacePoint, + $rootGeneralizationOrigin, + $this->getInterDimensionalVariationGraph()->getSpecializationSet($rootGeneralization) + ); + } else { + $events[] = new NodeAggregateWithNodeWasCreated( + $parentNodeAggregate->contentStreamId, + $tetheredNodeAggregateId, + $expectedTetheredNodeType->name, + $rootGeneralizationOrigin, + $this->getInterDimensionalVariationGraph()->getSpecializationSet($rootGeneralization), + $parentNodeAggregate->nodeAggregateId, + $tetheredNodeName, + SerializedPropertyValues::defaultFromNodeType($expectedTetheredNodeType), + NodeAggregateClassification::CLASSIFICATION_TETHERED, + ); + $creationOriginDimensionSpacePoint = $rootGeneralizationOrigin; + } + } + return Events::fromArray($events); + } else { + return Events::with( + new NodeAggregateWithNodeWasCreated( + $parentNodeAggregate->contentStreamId, + $tetheredNodeAggregateId ?: NodeAggregateId::create(), + $expectedTetheredNodeType->name, + $originDimensionSpacePoint, + $parentNodeAggregate->getCoverageByOccupant($originDimensionSpacePoint), + $parentNodeAggregate->nodeAggregateId, + $tetheredNodeName, + SerializedPropertyValues::defaultFromNodeType($expectedTetheredNodeType), + NodeAggregateClassification::CLASSIFICATION_TETHERED, + ) + ); + } } elseif (count($childNodeAggregates) === 1) { /** @var NodeAggregate $childNodeAggregate */ $childNodeAggregate = current($childNodeAggregates); @@ -106,9 +140,9 @@ protected function createEventsForMissingTetheredNode( } /** @var Node $childNodeSource Node aggregates are never empty */ return $this->createEventsForVariations( - $parentNode->subgraphIdentity->contentStreamId, + $parentNodeAggregate->contentStreamId, $childNodeSource->originDimensionSpacePoint, - $parentNode->originDimensionSpacePoint, + $originDimensionSpacePoint, $parentNodeAggregate, $contentRepository ); diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/NodeCreation.php b/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/NodeCreation.php index 739a7b38a5c..07c0518e54b 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/NodeCreation.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/NodeCreation.php @@ -222,7 +222,6 @@ private function handleCreateNodeAggregateWithNodeAndSerializedProperties( ); } - $defaultPropertyValues = SerializedPropertyValues::defaultFromNodeType($nodeType); $initialPropertyValues = $defaultPropertyValues->merge($command->initialPropertyValues); diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Command/SetNodeReferences.php b/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Command/SetNodeReferences.php index d0ea7f49e90..ce969843ef1 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Command/SetNodeReferences.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Command/SetNodeReferences.php @@ -25,7 +25,7 @@ final class SetNodeReferences implements CommandInterface * @param ReferenceName $referenceName Name of the reference to set * @param NodeReferencesToWrite $references Unserialized reference(s) to set */ - public function __construct( + private function __construct( public readonly ContentStreamId $contentStreamId, public readonly NodeAggregateId $sourceNodeAggregateId, public readonly OriginDimensionSpacePoint $sourceOriginDimensionSpacePoint, diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeRemoval/Command/RemoveNodeAggregate.php b/Neos.ContentRepository.Core/Classes/Feature/NodeRemoval/Command/RemoveNodeAggregate.php index 060135a4f4e..6c3836dc81c 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeRemoval/Command/RemoveNodeAggregate.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeRemoval/Command/RemoveNodeAggregate.php @@ -33,31 +33,27 @@ final class RemoveNodeAggregate implements MatchableWithNodeIdToPublishOrDiscardInterface { /** - * @param ContentStreamId $contentStreamId + * @param ContentStreamId $contentStreamId The content stream in which the remove operation is to be performed + * @param NodeAggregateId $nodeAggregateId The identifier of the node aggregate to remove + * @param DimensionSpacePoint $coveredDimensionSpacePoint One of the dimension space points covered by the node aggregate in which the user intends to remove it + * @param NodeVariantSelectionStrategy $nodeVariantSelectionStrategy The strategy the user chose to determine which specialization variants will also be removed + * @param NodeAggregateId|null $removalAttachmentPoint Internal. It stores the document node id of the removed node, as that is what the UI needs later on for the change display. {@see self::withRemovalAttachmentPoint()} */ - public function __construct( + private function __construct( public readonly ContentStreamId $contentStreamId, public readonly NodeAggregateId $nodeAggregateId, - /** One of the dimension space points covered by the node aggregate in which the user intends to remove it */ public readonly DimensionSpacePoint $coveredDimensionSpacePoint, public readonly NodeVariantSelectionStrategy $nodeVariantSelectionStrategy, - /** - * This is usually the NodeAggregateId of the parent node of the deleted node. It is needed for instance - * in the Neos UI for the following scenario: - * - when removing a node, you still need to be able to publish the removal. - * - For this to work, the Neos UI needs to know the id of the removed Node, **on the page - * where the removal happened** (so that the user can decide to publish a single page INCLUDING the removal - * on the page) - * - Because this command will *remove* the edge, - * we cannot know the position in the tree after doing the removal anymore. - * - * That's why we need this field: For the Neos UI, it stores the document node of the removed node - * (see Remove.php), as that is what the UI needs lateron for the change display. - */ public readonly ?NodeAggregateId $removalAttachmentPoint ) { } + /** + * @param ContentStreamId $contentStreamId The content stream in which the remove operation is to be performed + * @param NodeAggregateId $nodeAggregateId The identifier of the node aggregate to remove + * @param DimensionSpacePoint $coveredDimensionSpacePoint One of the dimension space points covered by the node aggregate in which the user intends to remove it + * @param NodeVariantSelectionStrategy $nodeVariantSelectionStrategy The strategy the user chose to determine which specialization variants will also be removed + */ public static function create(ContentStreamId $contentStreamId, NodeAggregateId $nodeAggregateId, DimensionSpacePoint $coveredDimensionSpacePoint, NodeVariantSelectionStrategy $nodeVariantSelectionStrategy): self { return new self($contentStreamId, $nodeAggregateId, $coveredDimensionSpacePoint, $nodeVariantSelectionStrategy, null); @@ -80,6 +76,14 @@ public static function fromArray(array $array): self } /** + * This adds usually the NodeAggregateId of the parent document node of the deleted node. + * It is needed for instance in the Neos UI for the following scenario: + * - when removing a node, you still need to be able to publish the removal. + * - For this to work, the Neos UI needs to know the id of the removed Node, **on the page where the removal happened** + * (so that the user can decide to publish a single page INCLUDING the removal on the page) + * - Because this command will *remove* the edge, + * we cannot know the position in the tree after doing the removal anymore. + * * @param NodeAggregateId $removalAttachmentPoint * @internal */ diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeRenaming/NodeRenaming.php b/Neos.ContentRepository.Core/Classes/Feature/NodeRenaming/NodeRenaming.php index b4e3e85049c..f38e032ce57 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeRenaming/NodeRenaming.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeRenaming/NodeRenaming.php @@ -33,7 +33,6 @@ trait NodeRenaming private function handleChangeNodeAggregateName(ChangeNodeAggregateName $command, ContentRepository $contentRepository): EventsToPublish { - $this->requireContentStreamToExist($command->contentStreamId, $contentRepository); $nodeAggregate = $this->requireProjectedNodeAggregate( $command->contentStreamId, @@ -41,6 +40,19 @@ private function handleChangeNodeAggregateName(ChangeNodeAggregateName $command, $contentRepository ); $this->requireNodeAggregateToNotBeRoot($nodeAggregate, 'and Root Node Aggregates cannot be renamed'); + $this->requireNodeAggregateToBeUntethered($nodeAggregate); + foreach ($contentRepository->getContentGraph()->findParentNodeAggregates($command->contentStreamId, $command->nodeAggregateId) as $parentNodeAggregate) { + foreach ($parentNodeAggregate->occupiedDimensionSpacePoints as $occupiedParentDimensionSpacePoint) { + $this->requireNodeNameToBeUnoccupied( + $command->contentStreamId, + $command->newNodeName, + $parentNodeAggregate->nodeAggregateId, + $occupiedParentDimensionSpacePoint, + $parentNodeAggregate->coveredDimensionSpacePoints, + $contentRepository + ); + } + } $events = Events::with( new NodeAggregateNameWasChanged( diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeTypeChange/NodeTypeChange.php b/Neos.ContentRepository.Core/Classes/Feature/NodeTypeChange/NodeTypeChange.php index 16306a537e8..0f68cba7042 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeTypeChange/NodeTypeChange.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeTypeChange/NodeTypeChange.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet; use Neos\ContentRepository\Core\EventStore\Events; use Neos\ContentRepository\Core\EventStore\EventsToPublish; @@ -90,7 +91,7 @@ abstract protected function areNodeTypeConstraintsImposedByGrandparentValid( abstract protected function createEventsForMissingTetheredNode( NodeAggregate $parentNodeAggregate, - Node $parentNode, + OriginDimensionSpacePoint $originDimensionSpacePoint, NodeName $tetheredNodeName, NodeAggregateId $tetheredNodeAggregateId, NodeType $expectedTetheredNodeType, @@ -206,7 +207,7 @@ private function handleChangeNodeAggregateType( ?: NodeAggregateId::create(); array_push($events, ...iterator_to_array($this->createEventsForMissingTetheredNode( $nodeAggregate, - $node, + $node->originDimensionSpacePoint, $tetheredNodeName, $tetheredNodeAggregateId, $expectedTetheredNodeType, diff --git a/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/Command/CreateRootNodeAggregateWithNode.php b/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/Command/CreateRootNodeAggregateWithNode.php index ec57b71854f..0e2ceab99de 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/Command/CreateRootNodeAggregateWithNode.php +++ b/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/Command/CreateRootNodeAggregateWithNode.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\CommandHandler\CommandInterface; use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherContentStreamsInterface; +use Neos\ContentRepository\Core\Feature\NodeCreation\Dto\NodeAggregateIdsByNodePaths; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; @@ -28,7 +29,7 @@ * * @api commands are the write-API of the ContentRepository */ -final class CreateRootNodeAggregateWithNode implements +final readonly class CreateRootNodeAggregateWithNode implements CommandInterface, \JsonSerializable, RebasableToOtherContentStreamsInterface @@ -37,11 +38,13 @@ final class CreateRootNodeAggregateWithNode implements * @param ContentStreamId $contentStreamId The content stream in which the root node should be created in * @param NodeAggregateId $nodeAggregateId The id of the root node aggregate to create * @param NodeTypeName $nodeTypeName Name of type of the new node to create + * @param NodeAggregateIdsByNodePaths $tetheredDescendantNodeAggregateIds Predefined aggregate ids of tethered child nodes per path. For any tethered node that has no matching entry in this set, the node aggregate id is generated randomly. Since tethered nodes may have tethered child nodes themselves, this works for multiple levels ({@see self::withTetheredDescendantNodeAggregateIds()}) */ private function __construct( - public readonly ContentStreamId $contentStreamId, - public readonly NodeAggregateId $nodeAggregateId, - public readonly NodeTypeName $nodeTypeName, + public ContentStreamId $contentStreamId, + public NodeAggregateId $nodeAggregateId, + public NodeTypeName $nodeTypeName, + public NodeAggregateIdsByNodePaths $tetheredDescendantNodeAggregateIds, ) { } @@ -52,12 +55,54 @@ private function __construct( */ public static function create(ContentStreamId $contentStreamId, NodeAggregateId $nodeAggregateId, NodeTypeName $nodeTypeName): self { - return new self($contentStreamId, $nodeAggregateId, $nodeTypeName); + return new self( + $contentStreamId, + $nodeAggregateId, + $nodeTypeName, + NodeAggregateIdsByNodePaths::createEmpty() + ); } + /** + * Specify explicitly the node aggregate ids for the tethered children {@see tetheredDescendantNodeAggregateIds}. + * + * In case you want to create a batch of commands where one creates the root node and a succeeding command needs + * a tethered node aggregate id, you need to generate the child node aggregate ids in advance. + * + * _Alternatively you would need to fetch the created tethered node first from the subgraph. + * {@see ContentSubgraphInterface::findChildNodeConnectedThroughEdgeName()}_ + * + * The helper method {@see NodeAggregateIdsByNodePaths::createForNodeType()} will generate recursively + * node aggregate ids for every tethered child node: + * + * ```php + * $tetheredDescendantNodeAggregateIds = NodeAggregateIdsByNodePaths::createForNodeType( + * $command->nodeTypeName, + * $nodeTypeManager + * ); + * $command = $command->withTetheredDescendantNodeAggregateIds($tetheredDescendantNodeAggregateIds): + * ``` + * + * The generated node aggregate id for the tethered node "main" is this way known before the command is issued: + * + * ```php + * $mainNodeAggregateId = $command->tetheredDescendantNodeAggregateIds->getNodeAggregateId(NodePath::fromString('main')); + * ``` + * + * Generating the node aggregate ids from user land is totally optional. + */ + public function withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths $tetheredDescendantNodeAggregateIds): self + { + return new self( + $this->contentStreamId, + $this->nodeAggregateId, + $this->nodeTypeName, + $tetheredDescendantNodeAggregateIds, + ); + } /** - * @param array $array + * @param array $array */ public static function fromArray(array $array): self { @@ -65,6 +110,9 @@ public static function fromArray(array $array): self ContentStreamId::fromString($array['contentStreamId']), NodeAggregateId::fromString($array['nodeAggregateId']), NodeTypeName::fromString($array['nodeTypeName']), + isset($array['tetheredDescendantNodeAggregateIds']) + ? NodeAggregateIdsByNodePaths::fromArray($array['tetheredDescendantNodeAggregateIds']) + : NodeAggregateIdsByNodePaths::createEmpty() ); } @@ -82,6 +130,7 @@ public function createCopyForContentStream(ContentStreamId $target): self $target, $this->nodeAggregateId, $this->nodeTypeName, + $this->tetheredDescendantNodeAggregateIds ); } } diff --git a/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/RootNodeHandling.php b/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/RootNodeHandling.php index 844f63f7c24..20de19bc5c6 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/RootNodeHandling.php +++ b/Neos.ContentRepository.Core/Classes/Feature/RootNodeCreation/RootNodeHandling.php @@ -16,13 +16,18 @@ use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\EventStore\Events; use Neos\ContentRepository\Core\EventStore\EventsToPublish; use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName; +use Neos\ContentRepository\Core\Feature\NodeCreation\Dto\NodeAggregateIdsByNodePaths; +use Neos\ContentRepository\Core\Feature\NodeCreation\Event\NodeAggregateWithNodeWasCreated; +use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues; use Neos\ContentRepository\Core\Feature\RootNodeCreation\Command\UpdateRootNodeAggregateDimensions; use Neos\ContentRepository\Core\Feature\RootNodeCreation\Event\RootNodeAggregateDimensionsWereUpdated; use Neos\ContentRepository\Core\NodeType\NodeType; use Neos\ContentRepository\Core\NodeType\NodeTypeName; +use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet; use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateIsNotRoot; use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregatesTypeIsAmbiguous; @@ -31,8 +36,11 @@ use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound; use Neos\ContentRepository\Core\Feature\RootNodeCreation\Command\CreateRootNodeAggregateWithNode; use Neos\ContentRepository\Core\Feature\RootNodeCreation\Event\RootNodeAggregateWithNodeWasCreated; +use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification; use Neos\ContentRepository\Core\Feature\Common\NodeAggregateEventPublisher; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\ContentRepository\Core\SharedModel\Node\NodeName; use Neos\EventStore\Model\EventStream\ExpectedVersion; /** @@ -76,12 +84,33 @@ private function handleCreateRootNodeAggregateWithNode( $contentRepository ); - $events = Events::with( + $descendantNodeAggregateIds = $command->tetheredDescendantNodeAggregateIds->completeForNodeOfType( + $command->nodeTypeName, + $this->nodeTypeManager + ); + // Write the auto-created descendant node aggregate ids back to the command; + // so that when rebasing the command, it stays fully deterministic. + $command = $command->withTetheredDescendantNodeAggregateIds($descendantNodeAggregateIds); + + $events = [ $this->createRootWithNode( $command, $this->getAllowedDimensionSubspace() ) - ); + ]; + + foreach ($this->getInterDimensionalVariationGraph()->getRootGeneralizations() as $rootGeneralization) { + array_push($events, ...iterator_to_array($this->handleTetheredRootChildNodes( + $command, + $nodeType, + OriginDimensionSpacePoint::fromDimensionSpacePoint($rootGeneralization), + $this->getInterDimensionalVariationGraph()->getSpecializationSet($rootGeneralization, true), + $command->nodeAggregateId, + $command->tetheredDescendantNodeAggregateIds, + null, + $contentRepository + ))); + } $contentStreamEventStream = ContentStreamEventStreamName::fromContentStreamId( $command->contentStreamId @@ -90,7 +119,7 @@ private function handleCreateRootNodeAggregateWithNode( $contentStreamEventStream->getEventStreamName(), NodeAggregateEventPublisher::enrichWithCommand( $command, - $events + Events::fromArray($events) ), ExpectedVersion::ANY() ); @@ -147,4 +176,81 @@ private function handleUpdateRootNodeAggregateDimensions( ExpectedVersion::ANY() ); } + + /** + * @throws ContentStreamDoesNotExistYet + * @throws NodeTypeNotFoundException + */ + private function handleTetheredRootChildNodes( + CreateRootNodeAggregateWithNode $command, + NodeType $nodeType, + OriginDimensionSpacePoint $originDimensionSpacePoint, + DimensionSpacePointSet $coveredDimensionSpacePoints, + NodeAggregateId $parentNodeAggregateId, + NodeAggregateIdsByNodePaths $nodeAggregateIdsByNodePath, + ?NodePath $nodePath, + ContentRepository $contentRepository, + ): Events { + $events = []; + foreach ($this->getNodeTypeManager()->getTetheredNodesConfigurationForNodeType($nodeType) as $rawNodeName => $childNodeType) { + assert($childNodeType instanceof NodeType); + $nodeName = NodeName::fromString($rawNodeName); + $childNodePath = $nodePath + ? $nodePath->appendPathSegment($nodeName) + : NodePath::fromString($nodeName->value); + $childNodeAggregateId = $nodeAggregateIdsByNodePath->getNodeAggregateId($childNodePath) + ?? NodeAggregateId::create(); + $initialPropertyValues = SerializedPropertyValues::defaultFromNodeType($childNodeType); + + $this->requireContentStreamToExist($command->contentStreamId, $contentRepository); + $events[] = $this->createTetheredWithNodeForRoot( + $command, + $childNodeAggregateId, + $childNodeType->name, + $originDimensionSpacePoint, + $coveredDimensionSpacePoints, + $parentNodeAggregateId, + $nodeName, + $initialPropertyValues + ); + + array_push($events, ...iterator_to_array($this->handleTetheredRootChildNodes( + $command, + $childNodeType, + $originDimensionSpacePoint, + $coveredDimensionSpacePoints, + $childNodeAggregateId, + $nodeAggregateIdsByNodePath, + $childNodePath, + $contentRepository + ))); + } + + return Events::fromArray($events); + } + + private function createTetheredWithNodeForRoot( + CreateRootNodeAggregateWithNode $command, + NodeAggregateId $nodeAggregateId, + NodeTypeName $nodeTypeName, + OriginDimensionSpacePoint $originDimensionSpacePoint, + DimensionSpacePointSet $coveredDimensionSpacePoints, + NodeAggregateId $parentNodeAggregateId, + NodeName $nodeName, + SerializedPropertyValues $initialPropertyValues, + NodeAggregateId $precedingNodeAggregateId = null + ): NodeAggregateWithNodeWasCreated { + return new NodeAggregateWithNodeWasCreated( + $command->contentStreamId, + $nodeAggregateId, + $nodeTypeName, + $originDimensionSpacePoint, + $coveredDimensionSpacePoints, + $parentNodeAggregateId, + $nodeName, + $initialPropertyValues, + NodeAggregateClassification::CLASSIFICATION_TETHERED, + $precedingNodeAggregateId + ); + } } diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index d3bd1557328..7fc7d47f176 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -476,6 +476,10 @@ private function extractCommandsFromContentStreamMetadata( $commandToRebaseClass ), 1547815341); } + /** + * The "fromArray" might be declared via {@see RebasableToOtherContentStreamsInterface::fromArray()} + * or any other command can just implement it. + */ $commands[] = $commandToRebaseClass::fromArray($commandToRebasePayload); } } diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspacePublication/Command/PublishIndividualNodesFromWorkspace.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspacePublication/Command/PublishIndividualNodesFromWorkspace.php index 873d00e5925..5f4100b6e2f 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspacePublication/Command/PublishIndividualNodesFromWorkspace.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspacePublication/Command/PublishIndividualNodesFromWorkspace.php @@ -29,29 +29,13 @@ final class PublishIndividualNodesFromWorkspace implements CommandInterface /** * @param WorkspaceName $workspaceName Name of the affected workspace * @param NodeIdsToPublishOrDiscard $nodesToPublish Ids of the nodes to publish or discard - * @param ContentStreamId $contentStreamIdForMatchingPart The id of the new content stream that will contain all events to be published - * @param ContentStreamId $contentStreamIdForRemainingPart The id of the new content stream that will contain all remaining events + * @param ContentStreamId $contentStreamIdForMatchingPart The id of the new content stream that will contain all events to be published {@see self::withContentStreamIdForMatchingPart()} + * @param ContentStreamId $contentStreamIdForRemainingPart The id of the new content stream that will contain all remaining events {@see self::withContentStreamIdForRemainingPart()} */ private function __construct( public readonly WorkspaceName $workspaceName, public readonly NodeIdsToPublishOrDiscard $nodesToPublish, - /** - * during the publish process, we sort the events so that the events we want to publish - * come first. In this process, two new content streams are generated: - * - the first one contains all events which we want to publish - * - the second one is based on the first one, and contains all the remaining events (which we want to keep - * in the user workspace). - * - * This property contains the ID of the first content stream, so that this command - * can run fully deterministic - we need this for the test cases. - */ public readonly ContentStreamId $contentStreamIdForMatchingPart, - /** - * See the description of {@see $contentStreamIdForMatchingPart}. - * - * This property contains the ID of the second content stream, so that this command - * can run fully deterministic - we need this for the test cases. - */ public readonly ContentStreamId $contentStreamIdForRemainingPart ) { } @@ -70,11 +54,27 @@ public static function create(WorkspaceName $workspaceName, NodeIdsToPublishOrDi ); } + /** + * During the publish process, we sort the events so that the events we want to publish + * come first. In this process, two new content streams are generated: + * - the first one contains all events which we want to publish + * - the second one is based on the first one, and contains all the remaining events (which we want to keep + * in the user workspace). + * + * This method adds the ID of the first content stream, so that the command + * can run fully deterministic - we need this for the test cases. + */ public function withContentStreamIdForMatchingPart(ContentStreamId $contentStreamIdForMatchingPart): self { return new self($this->workspaceName, $this->nodesToPublish, $contentStreamIdForMatchingPart, $this->contentStreamIdForRemainingPart); } + /** + * See the description of {@see self::withContentStreamIdForMatchingPart()}. + * + * This property adds the ID of the second content stream, so that the command + * can run fully deterministic - we need this for the test cases. + */ public function withContentStreamIdForRemainingPart(ContentStreamId $contentStreamIdForRemainingPart): self { return new self($this->workspaceName, $this->nodesToPublish, $this->contentStreamIdForMatchingPart, $contentStreamIdForRemainingPart); diff --git a/Neos.ContentRepository.Core/Classes/NodeType/ConstraintCheck.php b/Neos.ContentRepository.Core/Classes/NodeType/ConstraintCheck.php index 91058e9b8b8..3771b1234d7 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/ConstraintCheck.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/ConstraintCheck.php @@ -6,16 +6,24 @@ * Performs node type constraint checks against a given set of constraints * @internal */ -class ConstraintCheck +final readonly class ConstraintCheck { /** - * @param array $constraints + * @param array $constraints */ - public function __construct( - private readonly array $constraints + private function __construct( + private array $constraints ) { } + /** + * @param array $constraints + */ + public static function create(array $constraints): self + { + return new self($constraints); + } + public function isNodeTypeAllowed(NodeType $nodeType): bool { $directConstraintsResult = $this->isNodeTypeAllowedByDirectConstraints($nodeType); diff --git a/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php b/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php index 1eaae89553c..f1e861f3beb 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php @@ -400,13 +400,31 @@ public function getProperties(): array } /** - * Returns the configured type of the specified property + * Check if the property is configured in the schema. + */ + public function hasProperty(string $propertyName): bool + { + $this->initialize(); + + return isset($this->fullConfiguration['properties'][$propertyName]); + } + + /** + * Returns the configured type of the specified property, and falls back to 'string'. * - * @param string $propertyName Name of the property + * @throws \InvalidArgumentException if the property is not configured */ public function getPropertyType(string $propertyName): string { $this->initialize(); + + if (!$this->hasProperty($propertyName)) { + throw new \InvalidArgumentException( + sprintf('NodeType schema has no property "%s" configured. Cannot read its type.', $propertyName), + 1695062252040 + ); + } + return $this->fullConfiguration['properties'][$propertyName]['type'] ?? 'string'; } @@ -479,7 +497,7 @@ public function getNodeTypeNameOfTetheredNode(NodeName $nodeName): NodeTypeName public function allowsChildNodeType(NodeType $nodeType): bool { $constraints = $this->getConfiguration('constraints.nodeTypes') ?: []; - return (new ConstraintCheck($constraints))->isNodeTypeAllowed($nodeType); + return ConstraintCheck::create($constraints)->isNodeTypeAllowed($nodeType); } /** diff --git a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php index ba6ec1cfd8e..69352cb5da3 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php @@ -260,7 +260,7 @@ public function isNodeTypeAllowedAsChildToTetheredNode(NodeType $parentNodeType, $constraints = Arrays::arrayMergeRecursiveOverrule($constraints, $childNodeConstraintConfiguration); - return (new ConstraintCheck($constraints))->isNodeTypeAllowed($nodeType); + return ConstraintCheck::create($constraints)->isNodeTypeAllowed($nodeType); } /** diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentGraphWithRuntimeCaches/ContentSubgraphWithRuntimeCaches.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentGraphWithRuntimeCaches/ContentSubgraphWithRuntimeCaches.php index ddfa8f4a6e8..7660d7c154d 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentGraphWithRuntimeCaches/ContentSubgraphWithRuntimeCaches.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentGraphWithRuntimeCaches/ContentSubgraphWithRuntimeCaches.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; +use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountBackReferencesFilter; @@ -52,6 +53,11 @@ public function __construct( $this->inMemoryCache = new InMemoryCache(); } + public function getIdentity(): ContentSubgraphIdentity + { + return $this->wrappedContentSubgraph->getIdentity(); + } + public function findChildNodes(NodeAggregateId $parentNodeAggregateId, FindChildNodesFilter $filter): Nodes { if (!self::isFilterEmpty($filter)) { diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentSubgraphInterface.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentSubgraphInterface.php index 55a5572edf8..5f65fb6a0f1 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentSubgraphInterface.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/ContentSubgraphInterface.php @@ -48,6 +48,15 @@ */ interface ContentSubgraphInterface extends \JsonSerializable { + /** + * Returns the subgraph's identity, i.e. the current perspective we look at content from, composed of + * * the content repository the subgraph belongs to + * * the ID of the content stream we are currently working in + * * the dimension space point we are currently looking at + * * the applied visibility constraints + */ + public function getIdentity(): ContentSubgraphIdentity; + /** * Find a single node by its aggregate id * diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/ExpandedNodeTypeCriteria.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/ExpandedNodeTypeCriteria.php index 5c85fa3c57b..99e4ac9689f 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/ExpandedNodeTypeCriteria.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/ExpandedNodeTypeCriteria.php @@ -18,7 +18,6 @@ use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\NodeType\NodeTypeNames; -use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria; /** * Implementation detail of {@see NodeTypeCriteria}, to be used inside implementations of ContentSubgraphInterface. @@ -34,50 +33,6 @@ private function __construct( ) { } - /** - * @param array $nodeTypeDeclaration - */ - public static function createFromNodeTypeDeclaration( - array $nodeTypeDeclaration, - NodeTypeManager $nodeTypeManager - ): self { - $wildCardAllowed = false; - $explicitlyAllowedNodeTypeNames = []; - $explicitlyDisallowedNodeTypeNames = []; - foreach ($nodeTypeDeclaration as $constraintName => $allowed) { - if ($constraintName === '*') { - $wildCardAllowed = $allowed; - } else { - if ($allowed) { - $explicitlyAllowedNodeTypeNames[] = $constraintName; - } else { - $explicitlyDisallowedNodeTypeNames[] = $constraintName; - } - } - } - - return new self( - $wildCardAllowed, - self::expandByIncludingSubNodeTypes( - NodeTypeNames::fromStringArray($explicitlyAllowedNodeTypeNames), - $nodeTypeManager - ), - self::expandByIncludingSubNodeTypes( - NodeTypeNames::fromStringArray($explicitlyDisallowedNodeTypeNames), - $nodeTypeManager - ) - ); - } - - public static function allowAll(): self - { - return new self( - true, - NodeTypeNames::createEmpty(), - NodeTypeNames::createEmpty(), - ); - } - public static function create(NodeTypeCriteria $nodeTypeCriteria, NodeTypeManager $nodeTypeManager): self { // in case there are no filters, we fall back to allowing every node type. @@ -138,22 +93,4 @@ public function matches(NodeTypeName $nodeTypeName): bool // otherwise, we return $wildcardAllowed. return $this->isWildCardAllowed; } - - public function toFilterString(): string - { - $parts = []; - if ($this->isWildCardAllowed) { - $parts[] = '*'; - } - - foreach ($this->explicitlyDisallowedNodeTypeNames as $nodeTypeName) { - $parts[] = '!' . $nodeTypeName->value; - } - - foreach ($this->explicitlyAllowedNodeTypeNames as $nodeTypeName) { - $parts[] = $nodeTypeName->value; - } - - return implode(',', $parts); - } } diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/NodeTypeCriteria.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/NodeTypeCriteria.php index ea8eebe9be8..8028db3d468 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/NodeTypeCriteria.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/NodeType/NodeTypeCriteria.php @@ -56,11 +56,25 @@ private function __construct( ) { } + /** + * We recommended to call this method with named arguments to better + * understand the distinction between allowed and disallowed NodeTypeNames + */ public static function create( - NodeTypeNames $explicitlyAllowedNodeTypeNames, - NodeTypeNames $explicitlyDisallowedNodeTypeNames + NodeTypeNames $allowed, + NodeTypeNames $disallowed ): self { - return new self($explicitlyAllowedNodeTypeNames, $explicitlyDisallowedNodeTypeNames); + return new self($allowed, $disallowed); + } + + public static function createWithAllowedNodeTypeNames(NodeTypeNames $nodeTypeNames): self + { + return new self($nodeTypeNames, NodeTypeNames::createEmpty()); + } + + public static function createWithDisallowedNodeTypeNames(NodeTypeNames $nodeTypeNames): self + { + return new self(NodeTypeNames::createEmpty(), $nodeTypeNames); } public static function fromFilterString(string $serializedFilters): self diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php index 6d2e63d2037..d29f4191ec9 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php @@ -37,50 +37,37 @@ final readonly class Node { /** - * @internal + * @param ContentSubgraphIdentity $subgraphIdentity This is part of the node's "Read Model" identity which is defined by: {@see self::subgraphIdentity} and {@see self::nodeAggregateId} + * @param NodeAggregateId $nodeAggregateId NodeAggregateId (identifier) of this node. This is part of the node's "Read Model" identity which is defined by: {@see self::subgraphIdentity} and {@see self::nodeAggregateId} + * @param OriginDimensionSpacePoint $originDimensionSpacePoint The DimensionSpacePoint the node originates in. Usually needed to address a Node in a NodeAggregate in order to update it. + * @param NodeAggregateClassification $classification The classification (regular, root, tethered) of this node + * @param NodeTypeName $nodeTypeName The node's node type name; always set, even if unknown to the NodeTypeManager + * @param NodeType|null $nodeType The node's node type, null if unknown to the NodeTypeManager - @deprecated Don't rely on this too much, as the capabilities of the NodeType here will probably change a lot; Ask the {@see NodeTypeManager} instead + * @param PropertyCollection $properties All properties of this node. References are NOT part of this API; To access references, {@see ContentSubgraphInterface::findReferences()} can be used; To read the serialized properties, call properties->serialized(). + * @param NodeName|null $nodeName The optional name of this node {@see ContentSubgraphInterface::findChildNodeConnectedThroughEdgeName()} + * @param Timestamps $timestamps Creation and modification timestamps of this node */ - public function __construct( + private function __construct( public ContentSubgraphIdentity $subgraphIdentity, - /** - * NodeAggregateId (identifier) of this node - * This is part of the node's "Read Model" identity, whis is defined by: - * - {@see getSubgraphIdentitity} - * - {@see getNodeAggregateId} (this method) - * - * With the above information, you can fetch a Subgraph using {@see ContentGraphInterface::getSubgraph()}. - * or {@see \Neos\ContentRepositoryRegistry\ContentRepositoryRegistry::subgraphForNode()} - */ public NodeAggregateId $nodeAggregateId, - /** - * returns the DimensionSpacePoint the node is at home in. Usually needed to address a Node in a NodeAggregate - * in order to update it. - */ public OriginDimensionSpacePoint $originDimensionSpacePoint, public NodeAggregateClassification $classification, - /** - * The node's node type name; always set, even if unknown to the NodeTypeManager - */ public NodeTypeName $nodeTypeName, - /** - * The node's node type, null if unknown to the NodeTypeManager - * @deprecated Don't rely on this too much, as the capabilities of the NodeType here will probably change a lot; - * Ask the {@see NodeTypeManager} instead - */ public ?NodeType $nodeType, - /** - * Returns all properties of this node. References are NOT part of this API; - * there you need to check getReference() and getReferences(). - * - * To read the serialized properties, call properties->serialized(). - * - * @param PropertyCollection $properties Property values, indexed by their name - */ public PropertyCollection $properties, public ?NodeName $nodeName, public Timestamps $timestamps, ) { } + /** + * @internal The signature of this method can change in the future! + */ + public static function create(ContentSubgraphIdentity $subgraphIdentity, NodeAggregateId $nodeAggregateId, OriginDimensionSpacePoint $originDimensionSpacePoint, NodeAggregateClassification $classification, NodeTypeName $nodeTypeName, ?NodeType $nodeType, PropertyCollection $properties, ?NodeName $nodeName, Timestamps $timestamps): self + { + return new self($subgraphIdentity, $nodeAggregateId, $originDimensionSpacePoint, $classification, $nodeTypeName, $nodeType, $properties, $nodeName, $timestamps); + } + /** * Returns the specified property. * diff --git a/Neos.ContentRepository.Core/Classes/Projection/ProjectionInterface.php b/Neos.ContentRepository.Core/Classes/Projection/ProjectionInterface.php index 61f96e5fee3..249683514cf 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ProjectionInterface.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ProjectionInterface.php @@ -4,14 +4,10 @@ namespace Neos\ContentRepository\Core\Projection; -use Neos\ContentRepository\Core\CommandHandler\PendingProjections; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\EventStore\EventInterface; use Neos\EventStore\CatchUp\CheckpointStorageInterface; use Neos\EventStore\Model\EventEnvelope; -use Neos\EventStore\Model\EventStream\EventStreamInterface; -use Neos\EventStore\Model\Event\SequenceNumber; -use Neos\EventStore\Model\Event; /** * Common interface for a Content Repository projection. This API is NOT exposed to the outside world, but is @@ -20,7 +16,7 @@ * If the Projection needs to be notified that a catchup is about to happen, you can additionally * implement {@see WithMarkStaleInterface}. This is useful f.e. to disable runtime caches in the ProjectionState. * - * @template TState of ProjectionStateInterface + * @template-covariant TState of ProjectionStateInterface * @api you can write custom projections */ interface ProjectionInterface diff --git a/Neos.ContentRepository.Core/Classes/Projection/Projections.php b/Neos.ContentRepository.Core/Classes/Projection/Projections.php index 4b25f31dc4d..1d5d2d6f431 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/Projections.php +++ b/Neos.ContentRepository.Core/Classes/Projection/Projections.php @@ -13,16 +13,16 @@ final class Projections implements \IteratorAggregate { /** - * @var array> + * @var array>, ProjectionInterface> */ private array $projections; /** - * @param array $projections - * @phpstan-ignore-next-line + * @param ProjectionInterface ...$projections */ private function __construct(ProjectionInterface ...$projections) { + // @phpstan-ignore-next-line $this->projections = $projections; } @@ -60,7 +60,8 @@ public static function fromArray(array $projections): self */ public function get(string $projectionClassName): ProjectionInterface { - if (!$this->has($projectionClassName)) { + $projection = $this->projections[$projectionClassName] ?? null; + if (!$projection instanceof $projectionClassName) { throw new \InvalidArgumentException( sprintf( 'a projection of type "%s" is not registered in this content repository instance.', @@ -69,8 +70,7 @@ public function get(string $projectionClassName): ProjectionInterface 1650120813 ); } - // @phpstan-ignore-next-line - return $this->projections[$projectionClassName]; + return $projection; } public function has(string $projectionClassName): bool @@ -79,8 +79,7 @@ public function has(string $projectionClassName): bool } /** - * @return \Traversable - * @phpstan-ignore-next-line + * @return \Traversable> */ public function getIterator(): \Traversable { diff --git a/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php b/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php index ed42e885124..01f89fa2401 100644 --- a/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php +++ b/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php @@ -15,6 +15,7 @@ namespace Neos\ContentRepository\Core\SharedModel\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes; /** * An immutable collection of NodeAggregateIds, indexed by their value @@ -67,13 +68,10 @@ public static function fromJsonString(string $jsonString): self return self::fromArray(\json_decode($jsonString, true)); } - /** - * @param Node[] $nodes - */ - public static function fromNodes(array $nodes): self + public static function fromNodes(Nodes $nodes): self { return self::fromArray( - array_map(fn(Node $node) => $node->nodeAggregateId, $nodes) + array_map(fn(Node $node) => $node->nodeAggregateId, iterator_to_array($nodes)) ); } @@ -85,6 +83,11 @@ public function merge(self $other): self )); } + public function contain(NodeAggregateId $nodeAggregateId): bool + { + return array_key_exists($nodeAggregateId->value, $this->nodeAggregateIds); + } + /** * @return array */ diff --git a/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php b/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php index 916e39d2043..12b5a86b7fa 100644 --- a/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php +++ b/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php @@ -71,11 +71,6 @@ public static function fromArray(array $array): self public function matches(ImageVariant $imageVariant): bool { - if (self::fromImageVariant($imageVariant)->toJson() !== $this->toJson()) { - \Neos\Flow\var_dump(self::fromImageVariant($imageVariant)->toJson()); - \Neos\Flow\var_dump($this->toJson()); - exit; - } return self::fromImageVariant($imageVariant)->toJson() === $this->toJson(); } diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php index fabefad1565..b3b7e1a11d6 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php @@ -40,13 +40,6 @@ class CrCommandController extends CommandController { - - /** - * @var array - */ - #[Flow\InjectConfiguration(package: 'Neos.Flow')] - protected array $flowSettings; - public function __construct( private readonly Connection $connection, private readonly Environment $environment, @@ -96,6 +89,7 @@ public function migrateLegacyDataCommand(bool $verbose = false, string $config = $siteRows = $connection->fetchAllAssociativeIndexed('SELECT nodename, name, siteresourcespackagekey FROM neos_neos_domain_model_site'); $siteNodeName = $this->output->select('Which site to migrate?', array_map(static fn (array $siteRow) => $siteRow['name'] . ' (' . $siteRow['siteresourcespackagekey'] . ')', $siteRows)); + assert(is_string($siteNodeName)); $siteRow = $siteRows[$siteNodeName]; $site = $this->siteRepository->findOneByNodeName($siteNodeName); @@ -208,6 +202,7 @@ private function determineResourcesPath(): string private static function defaultResourcesPath(): string { + // @phpstan-ignore-next-line return FLOW_PATH_DATA . 'Persistent/Resources'; } } diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/AssetExtractor.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/AssetExtractor.php index f7479da4c39..89ce5152c53 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/AssetExtractor.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/AssetExtractor.php @@ -12,6 +12,9 @@ final class AssetExtractor { + /** + * @var array + */ private array $processedAssetIds = []; public function __construct( @@ -19,7 +22,8 @@ public function __construct( ) {} /** - * @param iterable $nodeDataRows + * @param iterable> $nodeDataRows + * @return iterable */ public function run(iterable $nodeDataRows): iterable { @@ -48,11 +52,14 @@ public function run(iterable $nodeDataRows): iterable /** ----------------------------- */ + /** + * @return iterable + */ private function extractAssets(mixed $propertyValue): iterable { if ($propertyValue instanceof Asset) { + /** @var string|null $assetId */ $assetId = $propertyValue->getIdentifier(); - \Neos\Flow\var_dump($assetId, '$assetId'); if ($assetId === null) { // TODO exception/error return; @@ -75,7 +82,6 @@ private function extractAssets(mixed $propertyValue): iterable foreach ($matches as $match) { $assetId = $match['assetId']; $asset = ($this->findAssetByIdentifier)($assetId); - \Neos\Flow\var_dump($asset, '$asset ' . $assetId); if ($asset === null) { // TODO exception/error continue; diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/NodeDataLoader.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/NodeDataLoader.php index 52d54cdbf20..904f5700184 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/NodeDataLoader.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/Helpers/NodeDataLoader.php @@ -4,16 +4,21 @@ namespace Neos\ContentRepository\LegacyNodeMigration\Helpers; use Doctrine\DBAL\Connection; -use Traversable; +/** + * @implements \IteratorAggregate> + */ final class NodeDataLoader implements \IteratorAggregate { - public function __construct( private readonly Connection $connection, - ) {} + ) { + } - public function getIterator(): Traversable + /** + * @return \Traversable> + */ + public function getIterator(): \Traversable { $query = $this->connection->executeQuery(' SELECT diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/LegacyMigrationService.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/LegacyMigrationService.php index 2bcebc44a0e..15d1be1d8c4 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/LegacyMigrationService.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/LegacyMigrationService.php @@ -87,7 +87,7 @@ public function runAllProcessors(\Closure $outputLineFn, bool $verbose = false): }); $result = $processor->run(); if ($result->severity === Severity::ERROR) { - throw new \RuntimeException($label . ': ' . $result->message ?? ''); + throw new \RuntimeException($label . ': ' . $result->message); } $outputLineFn(' ' . $result->message); $outputLineFn(); diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToAssetsProcessor.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToAssetsProcessor.php index a1495d6174e..f96db3b58cc 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToAssetsProcessor.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToAssetsProcessor.php @@ -17,9 +17,18 @@ final class NodeDataToAssetsProcessor implements ProcessorInterface { + /** + * @var array + */ private array $processedAssetIds = []; + /** + * @var array<\Closure> + */ private array $callbacks = []; + /** + * @param iterable> $nodeDataRows + */ public function __construct( private readonly NodeTypeManager $nodeTypeManager, private readonly AssetExporter $assetExporter, @@ -35,16 +44,16 @@ public function run(): ProcessorResult { $numberOfErrors = 0; foreach ($this->nodeDataRows as $nodeDataRow) { + if ($nodeDataRow['path'] === '/sites') { + // the sites node has no properties and is unstructured + continue; + } $nodeTypeName = NodeTypeName::fromString($nodeDataRow['nodetype']); - try { - $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); - } catch (NodeTypeNotFoundException $exception) { - $numberOfErrors ++; - $this->dispatch(Severity::ERROR, '%s. Node: "%s"', $exception->getMessage(), $nodeDataRow['identifier']); + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { + $this->dispatch(Severity::ERROR, 'The node type "%s" is not available. Node: "%s"', $nodeTypeName->value, $nodeDataRow['identifier']); continue; } - // HACK the following line is required in order to fully initialize the node type - $nodeType->getFullConfiguration(); + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); try { $properties = json_decode($nodeDataRow['properties'], true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { @@ -84,12 +93,10 @@ public function run(): ProcessorResult private function extractAssetIdentifiers(string $type, mixed $value): array { if (($type === 'string' || is_subclass_of($type, \Stringable::class, true)) && is_string($value)) { - // @phpstan-ignore-next-line preg_match_all('/asset:\/\/(?[\w-]*)/i', (string)$value, $matches, PREG_SET_ORDER); return array_map(static fn(array $match) => $match['assetId'], $matches); } if (is_subclass_of($type, ResourceBasedInterface::class, true)) { - // @phpstan-ignore-next-line return isset($value['__identifier']) ? [$value['__identifier']] : []; } diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php index 9b4ed5e4189..cc3ad13609b 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php @@ -58,7 +58,9 @@ final class NodeDataToEventsProcessor implements ProcessorInterface { - + /** + * @var array<\Closure> + */ private array $callbacks = []; private NodeTypeName $sitesNodeTypeName; private ContentStreamId $contentStreamId; @@ -78,6 +80,9 @@ final class NodeDataToEventsProcessor implements ProcessorInterface */ private $eventFileResource; + /** + * @param iterable> $nodeDataRows + */ public function __construct( private readonly NodeTypeManager $nodeTypeManager, private readonly PropertyMapper $propertyMapper, @@ -156,7 +161,7 @@ private function resetRuntimeState(): void $this->nodeReferencesWereSetEvents = []; $this->numberOfExportedEvents = 0; $this->metaDataExported = false; - $this->eventFileResource = fopen('php://temp/maxmemory:5242880', 'rb+'); + $this->eventFileResource = fopen('php://temp/maxmemory:5242880', 'rb+') ?: null; Assert::resource($this->eventFileResource, null, 'Failed to create temporary event file resource'); } @@ -168,10 +173,14 @@ private function exportEvent(EventInterface $event): void json_decode($this->eventNormalizer->getEventData($event)->value, true), [] ); + assert($this->eventFileResource !== null); fwrite($this->eventFileResource, $exportedEvent->toJson() . chr(10)); $this->numberOfExportedEvents ++; } + /** + * @param array $nodeDataRow + */ private function exportMetaData(array $nodeDataRow): void { if ($this->files->fileExists('meta.json')) { @@ -187,7 +196,7 @@ private function exportMetaData(array $nodeDataRow): void } /** - * @param array $nodeDataRow + * @param array $nodeDataRow */ private function processNodeData(array $nodeDataRow): void { @@ -229,10 +238,9 @@ private function processNodeData(array $nodeDataRow): void /** - * @param NodePath $nodePath * @param OriginDimensionSpacePoint $originDimensionSpacePoint * @param NodeAggregateId $nodeAggregateId - * @param array $nodeDataRow + * @param array $nodeDataRow * @return NodeName[]|void * @throws \JsonException */ @@ -246,17 +254,26 @@ public function processNodeDataWithoutFallbackToEmptyDimension(NodeAggregateId $ } $pathParts = $nodePath->getParts(); $nodeName = end($pathParts); + assert($nodeName !== false); $nodeTypeName = NodeTypeName::fromString($nodeDataRow['nodetype']); - $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); - $serializedPropertyValuesAndReferences = $this->extractPropertyValuesAndReferences($nodeDataRow, $nodeType); + + $nodeType = $this->nodeTypeManager->hasNodeType($nodeTypeName) ? $this->nodeTypeManager->getNodeType($nodeTypeName) : null; $isSiteNode = $nodeDataRow['parentpath'] === '/sites'; - if ($isSiteNode && !$nodeType->isOfType(NodeTypeNameFactory::NAME_SITE)) { + if ($isSiteNode && !$nodeType?->isOfType(NodeTypeNameFactory::NAME_SITE)) { throw new MigrationException(sprintf( 'The site node "%s" (type: "%s") must be of type "%s"', $nodeDataRow['identifier'], $nodeTypeName->value, NodeTypeNameFactory::NAME_SITE ), 1695801620); } + if (!$nodeType) { + $this->dispatch(Severity::ERROR, 'The node type "%s" is not available. Node: "%s"', $nodeTypeName->value, $nodeDataRow['identifier']); + return; + } + + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); + $serializedPropertyValuesAndReferences = $this->extractPropertyValuesAndReferences($nodeDataRow, $nodeType); + if ($this->isAutoCreatedChildNode($parentNodeAggregate->nodeTypeName, $nodeName) && !$this->visitedNodes->containsNodeAggregate($nodeAggregateId)) { // Create tethered node if the node was not found before. // If the node was already visited, we want to create a node variant (and keep the tethering status) @@ -280,6 +297,9 @@ public function processNodeDataWithoutFallbackToEmptyDimension(NodeAggregateId $ $this->visitedNodes->add($nodeAggregateId, new DimensionSpacePointSet([$originDimensionSpacePoint->toDimensionSpacePoint()]), $nodeTypeName, $nodePath, $parentNodeAggregate->nodeAggregateId); } + /** + * @param array $nodeDataRow + */ public function extractPropertyValuesAndReferences(array $nodeDataRow, NodeType $nodeType): SerializedPropertyValuesAndReferences { $properties = []; @@ -375,7 +395,10 @@ private function createNodeVariant(NodeAggregateId $nodeAggregateId, OriginDimen // When we specialize/generalize, we create a node variant at exactly the same tree location as the source node // If the parent node aggregate id differs, we need to move the just created variant to the new location $nodeAggregate = $this->visitedNodes->getByNodeAggregateId($nodeAggregateId); - if (!$parentNodeAggregate->nodeAggregateId->equals($nodeAggregate->getVariant($variantSourceOriginDimensionSpacePoint)->parentNodeAggregateId)) { + if ( + $variantSourceOriginDimensionSpacePoint && + !$parentNodeAggregate->nodeAggregateId->equals($nodeAggregate->getVariant($variantSourceOriginDimensionSpacePoint)->parentNodeAggregateId) + ) { $this->exportEvent(new NodeAggregateWasMoved( $this->contentStreamId, $nodeAggregateId, diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php index 53b87836684..0054ab25685 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php @@ -1,15 +1,13 @@ initializeFlow(); - } - $this->objectManager = self::$bootstrap->getObjectManager(); - $this->contentRepositoryRegistry = $this->objectManager->get(ContentRepositoryRegistry::class); + self::bootstrapFlow(); + $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); $this->mockFilesystemAdapter = new InMemoryFilesystemAdapter(); $this->mockFilesystem = new Filesystem($this->mockFilesystemAdapter); @@ -120,7 +115,7 @@ public function iHaveTheFollowingNodeDataRows(TableNode $nodeDataRows): void public function iRunTheEventMigration(string $contentStream = null): void { $nodeTypeManager = $this->currentContentRepository->getNodeTypeManager(); - $propertyMapper = $this->getObjectManager()->get(PropertyMapper::class); + $propertyMapper = $this->getObject(PropertyMapper::class); $contentGraph = $this->currentContentRepository->getContentGraph(); $nodeFactory = (new \ReflectionClass($contentGraph)) ->getProperty('nodeFactory') @@ -130,7 +125,7 @@ public function iRunTheEventMigration(string $contentStream = null): void ->getValue($nodeFactory); $interDimensionalVariationGraph = $this->currentContentRepository->getVariationGraph(); - $eventNormalizer = $this->getObjectManager()->get(EventNormalizer::class); + $eventNormalizer = $this->getObject(EventNormalizer::class); $migration = new NodeDataToEventsProcessor( $nodeTypeManager, $propertyMapper, @@ -193,7 +188,7 @@ public function iExpectTheFollowingEventsToBeExported(TableNode $table): void */ public function iExpectTheFollwingErrorsToBeLogged(TableNode $table): void { - Assert::assertSame($this->loggedErrors, $table->getColumn(0), 'Expected logged errors do not match'); + Assert::assertSame($table->getColumn(0), $this->loggedErrors, 'Expected logged errors do not match'); $this->loggedErrors = []; } diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Assets.feature b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Assets.feature index bc5cf9671ea..f4ca3e07455 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Assets.feature +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Assets.feature @@ -7,7 +7,6 @@ Feature: Export of used Assets, Image Variants and Persistent Resources | language | en | en, de, ch | ch->de | And using the following node types: """yaml - 'unstructured': {} 'Neos.Neos:Site': {} 'Some.Package:Homepage': superTypes: diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Basic.feature b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Basic.feature index 3623e2fe61a..a1dea4af085 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Basic.feature +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Basic.feature @@ -5,7 +5,6 @@ Feature: Simple migrations without content dimensions Given using no content dimensions And using the following node types: """yaml - 'unstructured': {} 'Neos.Neos:Site': {} 'Some.Package:Homepage': superTypes: diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Errors.feature b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Errors.feature index 4cf57e96a4c..5058e8674d6 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Errors.feature +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Errors.feature @@ -5,7 +5,6 @@ Feature: Exceptional cases during migrations Given using no content dimensions And using the following node types: """yaml - 'unstructured': {} 'Neos.Neos:Site': {} 'Some.Package:Homepage': superTypes: @@ -101,11 +100,11 @@ Feature: Exceptional cases during migrations When I have the following node data rows: | Identifier | Path | Properties | Node Type | | sites | /sites | | | - | a | /sites/a | not json | Some.Package:SomeNodeType | + | a | /sites/a | not json | Some.Package:Homepage | And I run the event migration Then I expect a MigrationError with the message """ - Failed to decode properties "not json" of node "a" (type: "Some.Package:SomeNodeType"): Could not convert database value "not json" to Doctrine Type flow_json_array + Failed to decode properties "not json" of node "a" (type: "Some.Package:Homepage"): Could not convert database value "not json" to Doctrine Type flow_json_array """ Scenario: Node variants with the same dimension diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/References.feature b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/References.feature index 7c67812eb50..52e659f6017 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/References.feature +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/References.feature @@ -5,7 +5,6 @@ Feature: Migrations that contain nodes with "reference" or "references propertie Given using no content dimensions And using the following node types: """yaml - 'unstructured': {} 'Neos.Neos:Site': {} 'Some.Package:Homepage': superTypes: diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Variants.feature b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Variants.feature index e6285a44323..40ff8fca40a 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Variants.feature +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Features/Variants.feature @@ -7,11 +7,11 @@ Feature: Migrating nodes with content dimensions | language | en | en, de, ch | ch->de | And using the following node types: """yaml - 'unstructured': {} 'Neos.Neos:Site': {} 'Some.Package:Homepage': superTypes: 'Neos.Neos:Site': true + 'Some.Package:Thing': {} """ And using identifier "default", I define a content repository And I am in content repository "default" @@ -67,10 +67,10 @@ Feature: Migrating nodes with content dimensions | Identifier | Path | Node Type | Dimension Values | | sites | /sites | unstructured | | | site | /sites/site | Some.Package:Homepage | {"language": ["de"]} | - | a | /sites/site/a | unstructured | {"language": ["de"]} | - | a1 | /sites/site/a/a1 | unstructured | {"language": ["de"]} | - | b | /sites/site/b | unstructured | {"language": ["de"]} | - | a1 | /sites/site/b/a1 | unstructured | {"language": ["ch"]} | + | a | /sites/site/a | Some.Package:Thing | {"language": ["de"]} | + | a1 | /sites/site/a/a1 | Some.Package:Thing | {"language": ["de"]} | + | b | /sites/site/b | Some.Package:Thing | {"language": ["de"]} | + | a1 | /sites/site/b/a1 | Some.Package:Thing | {"language": ["ch"]} | And I run the event migration Then I expect the following events to be exported | Type | Payload | @@ -88,11 +88,11 @@ Feature: Migrating nodes with content dimensions | Identifier | Path | Node Type | Dimension Values | | sites | /sites | unstructured | | | site | /sites/site | Some.Package:Homepage | {"language": ["de"]} | - | a | /sites/site/a | unstructured | {"language": ["de"]} | - | a1 | /sites/site/a/a1 | unstructured | {"language": ["de"]} | - | b | /sites/site/b | unstructured | {"language": ["de"]} | - | a | /sites/site/b/a | unstructured | {"language": ["ch"]} | - | a1 | /sites/site/b/a/a1 | unstructured | {"language": ["ch"]} | + | a | /sites/site/a | Some.Package:Thing | {"language": ["de"]} | + | a1 | /sites/site/a/a1 | Some.Package:Thing | {"language": ["de"]} | + | b | /sites/site/b | Some.Package:Thing | {"language": ["de"]} | + | a | /sites/site/b/a | Some.Package:Thing | {"language": ["ch"]} | + | a1 | /sites/site/b/a/a1 | Some.Package:Thing | {"language": ["ch"]} | And I run the event migration Then I expect the following events to be exported | Type | Payload | diff --git a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ParentsOperation.php b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ParentsOperation.php index 2310ee2d59f..d0677eb075c 100644 --- a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ParentsOperation.php +++ b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ParentsOperation.php @@ -11,6 +11,10 @@ * source code. */ +use Neos\ContentRepository\Core\NodeType\NodeTypeNames; +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; +use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes; +use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\ContentRepository\Core\NodeType\NodeTypeName; @@ -65,26 +69,25 @@ public function canEvaluate($context) */ public function evaluate(FlowQuery $flowQuery, array $arguments) { - $parents = []; + $parents = Nodes::createEmpty(); + $findAncestorNodesFilter = FindAncestorNodesFilter::create( + NodeTypeConstraints::createWithDisallowedNodeTypeNames( + NodeTypeNames::fromStringArray(['Neos.ContentRepository:Root']) + ) + ); + /* @var Node $contextNode */ foreach ($flowQuery->getContext() as $contextNode) { - $node = $contextNode; - do { - $node = $this->contentRepositoryRegistry->subgraphForNode($node) - ->findParentNode($node->nodeAggregateId); - if ($node === null) { - // no parent found - break; - } - // stop at sites - if ($node->nodeTypeName === NodeTypeName::fromString('Neos.Neos:Sites')) { - break; - } - $parents[] = $node; - } while (true); + $ancestorNodes = $this->contentRepositoryRegistry + ->subgraphForNode($contextNode) + ->findAncestorNodes( + $contextNode->nodeAggregateId, + $findAncestorNodesFilter + ); + $parents = $parents->merge($ancestorNodes); } - $flowQuery->setContext($parents); + $flowQuery->setContext(iterator_to_array($parents)); if (isset($arguments[0]) && !empty($arguments[0])) { $flowQuery->pushOperation('filter', $arguments); diff --git a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/PropertyOperation.php b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/PropertyOperation.php index 127a0244727..dc3701cdda4 100644 --- a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/PropertyOperation.php +++ b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/PropertyOperation.php @@ -110,7 +110,11 @@ public function evaluate(FlowQuery $flowQuery, array $arguments): mixed return ObjectAccess::getPropertyPath($element, substr($propertyName, 1)); } - if ($element->nodeType->getPropertyType($propertyName) === 'reference') { + $propertyType = $element->nodeType->hasProperty($propertyName) + ? $element->nodeType->getPropertyType($propertyName) + : null; + + if ($propertyType === 'reference') { $subgraph = $this->contentRepositoryRegistry->subgraphForNode($element); return ( $subgraph->findReferences( @@ -120,7 +124,7 @@ public function evaluate(FlowQuery $flowQuery, array $arguments): mixed )?->node; } - if ($element->nodeType->getPropertyType($propertyName) === 'references') { + if ($propertyType === 'references') { $subgraph = $this->contentRepositoryRegistry->subgraphForNode($element); return $subgraph->findReferences( $element->nodeAggregateId, diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DimensionAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DimensionAdjustment.php index 08af46c972a..2219f0b5210 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DimensionAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DimensionAdjustment.php @@ -6,26 +6,32 @@ use Neos\ContentRepository\Core\DimensionSpace\InterDimensionalVariationGraph; use Neos\ContentRepository\Core\DimensionSpace\VariantType; +use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; +use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException; class DimensionAdjustment { - protected ProjectedNodeIterator $projectedNodeIterator; - protected InterDimensionalVariationGraph $interDimensionalVariationGraph; - public function __construct( - ProjectedNodeIterator $projectedNodeIterator, - InterDimensionalVariationGraph $interDimensionalVariationGraph + protected ProjectedNodeIterator $projectedNodeIterator, + protected InterDimensionalVariationGraph $interDimensionalVariationGraph, + protected NodeTypeManager $nodeTypeManager, ) { - $this->projectedNodeIterator = $projectedNodeIterator; - $this->interDimensionalVariationGraph = $interDimensionalVariationGraph; } /** - * @return \Generator + * @return iterable */ - public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator + public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): iterable { + try { + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); + } catch (NodeTypeNotFoundException) { + return []; + } + if ($nodeType->isOfType(NodeTypeName::ROOT_NODE_TYPE_NAME)) { + return []; + } foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { foreach ($nodeAggregate->getNodes() as $node) { foreach ( diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php index d19b762ace8..1111146fc21 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php @@ -67,7 +67,8 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat if ($parentNode !== null) { if ($this->nodeTypeManager->hasNodeType($parentNode->nodeTypeName)) { $parentNodeType = $this->nodeTypeManager->getNodeType($parentNode->nodeTypeName); - $allowedByParent = $parentNodeType->allowsChildNodeType($nodeType); + $allowedByParent = $parentNodeType->allowsChildNodeType($nodeType) + || $nodeAggregate->nodeName && $parentNodeType->hasTetheredNode($nodeAggregate->nodeName); } } diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/StructureAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/StructureAdjustment.php index d532e0232fc..b2ba0668007 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/StructureAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/StructureAdjustment.php @@ -4,8 +4,11 @@ namespace Neos\ContentRepository\StructureAdjustment\Adjustment; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\Error\Messages\Message; final class StructureAdjustment extends Message @@ -41,8 +44,10 @@ private function __construct( $this->type = $type; } - public static function createForNode( - Node $node, + public static function createForNodeIdentity( + ContentStreamId $contentStreamId, + OriginDimensionSpacePoint $originDimensionSpacePoint, + NodeAggregateId $nodeAggregateId, string $type, string $errorMessage, ?\Closure $remediation = null @@ -52,9 +57,9 @@ public static function createForNode( . ($remediation ? '' : '!!!NOT AUTO-FIXABLE YET!!! ') . $errorMessage, null, [ - 'contentStream' => $node->subgraphIdentity->contentStreamId->value, - 'dimensionSpacePoint' => $node->originDimensionSpacePoint->toJson(), - 'nodeAggregateId' => $node->nodeAggregateId->value, + 'contentStream' => $contentStreamId->value, + 'dimensionSpacePoint' => $originDimensionSpacePoint->toJson(), + 'nodeAggregateId' => $nodeAggregateId->value, 'isAutoFixable' => ($remediation !== null) ], $type, @@ -62,6 +67,22 @@ public static function createForNode( ); } + public static function createForNode( + Node $node, + string $type, + string $errorMessage, + ?\Closure $remediation = null + ): self { + return self::createForNodeIdentity( + $node->subgraphIdentity->contentStreamId, + $node->originDimensionSpacePoint, + $node->nodeAggregateId, + $type, + $errorMessage, + $remediation + ); + } + public static function createForNodeAggregate( NodeAggregate $nodeAggregate, string $type, diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php index 994672b390e..45ad49d7129 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php @@ -11,6 +11,7 @@ use Neos\ContentRepository\Core\Feature\NodeMove\Dto\CoverageNodeMoveMappings; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\Feature\NodeMove\Event\NodeAggregateWasMoved; use Neos\ContentRepository\Core\Feature\Common\TetheredNodeInternals; @@ -51,46 +52,52 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat // In case we cannot find the expected tethered nodes, this fix cannot do anything. return; } - $expectedTetheredNodes = $this->nodeTypeManager->getTetheredNodesConfigurationForNodeType($this->nodeTypeManager->getNodeType($nodeTypeName)); + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); + $expectedTetheredNodes = $this->nodeTypeManager->getTetheredNodesConfigurationForNodeType($nodeType); foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { // find missing tethered nodes $foundMissingOrDisallowedTetheredNodes = false; - foreach ($nodeAggregate->getNodes() as $node) { - assert($node instanceof Node); + $originDimensionSpacePoints = $nodeType->isOfType(NodeTypeName::ROOT_NODE_TYPE_NAME) + ? DimensionSpace\OriginDimensionSpacePointSet::fromDimensionSpacePointSet( + DimensionSpace\DimensionSpacePointSet::fromArray($this->getInterDimensionalVariationGraph()->getRootGeneralizations()) + ) + : $nodeAggregate->occupiedDimensionSpacePoints; + + foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) { foreach ($expectedTetheredNodes as $tetheredNodeName => $expectedTetheredNodeType) { $tetheredNodeName = NodeName::fromString($tetheredNodeName); $subgraph = $this->contentRepository->getContentGraph()->getSubgraph( - $node->subgraphIdentity->contentStreamId, - $node->originDimensionSpacePoint->toDimensionSpacePoint(), + $nodeAggregate->contentStreamId, + $originDimensionSpacePoint->toDimensionSpacePoint(), VisibilityConstraints::withoutRestrictions() ); $tetheredNode = $subgraph->findChildNodeConnectedThroughEdgeName( - $node->nodeAggregateId, + $nodeAggregate->nodeAggregateId, $tetheredNodeName ); if ($tetheredNode === null) { $foundMissingOrDisallowedTetheredNodes = true; // $nestedNode not found // - so a tethered node is missing in the OriginDimensionSpacePoint of the $node - yield StructureAdjustment::createForNode( - $node, + yield StructureAdjustment::createForNodeIdentity( + $nodeAggregate->contentStreamId, + $originDimensionSpacePoint, + $nodeAggregate->nodeAggregateId, StructureAdjustment::TETHERED_NODE_MISSING, 'The tethered child node "' . $tetheredNodeName->value . '" is missing.', - function () use ($nodeAggregate, $node, $tetheredNodeName, $expectedTetheredNodeType) { + function () use ($nodeAggregate, $originDimensionSpacePoint, $tetheredNodeName, $expectedTetheredNodeType) { $events = $this->createEventsForMissingTetheredNode( $nodeAggregate, - $node, + $originDimensionSpacePoint, $tetheredNodeName, null, $expectedTetheredNodeType, $this->contentRepository ); - $streamName = ContentStreamEventStreamName::fromContentStreamId( - $node->subgraphIdentity->contentStreamId - ); + $streamName = ContentStreamEventStreamName::fromContentStreamId($nodeAggregate->contentStreamId); return new EventsToPublish( $streamName->getEventStreamName(), $events, @@ -128,14 +135,13 @@ function () use ($tetheredNodeAggregate) { // find wrongly ordered tethered nodes if ($foundMissingOrDisallowedTetheredNodes === false) { - foreach ($nodeAggregate->getNodes() as $node) { - assert($node instanceof Node); + foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) { $subgraph = $this->contentRepository->getContentGraph()->getSubgraph( - $node->subgraphIdentity->contentStreamId, - $node->originDimensionSpacePoint->toDimensionSpacePoint(), + $nodeAggregate->contentStreamId, + $originDimensionSpacePoint->toDimensionSpacePoint(), VisibilityConstraints::withoutRestrictions() ); - $childNodes = $subgraph->findChildNodes($node->nodeAggregateId, FindChildNodesFilter::create()); + $childNodes = $subgraph->findChildNodes($nodeAggregate->nodeAggregateId, FindChildNodesFilter::create()); /** is indexed by node name, and the value is the tethered node itself */ $actualTetheredChildNodes = []; @@ -147,21 +153,22 @@ function () use ($tetheredNodeAggregate) { if (array_keys($actualTetheredChildNodes) !== array_keys($expectedTetheredNodes)) { // we need to re-order: We go from the last to the first - yield StructureAdjustment::createForNode( - $node, + yield StructureAdjustment::createForNodeIdentity( + $nodeAggregate->contentStreamId, + $originDimensionSpacePoint, + $nodeAggregate->nodeAggregateId, StructureAdjustment::TETHERED_NODE_WRONGLY_ORDERED, 'Tethered nodes wrongly ordered, expected: ' . implode(', ', array_keys($expectedTetheredNodes)) . ' - actual: ' . implode(', ', array_keys($actualTetheredChildNodes)), - function () use ($node, $actualTetheredChildNodes, $expectedTetheredNodes) { - return $this->reorderNodes( - $node->subgraphIdentity->contentStreamId, - $node, - $actualTetheredChildNodes, - array_keys($expectedTetheredNodes) - ); - } + fn () => $this->reorderNodes( + $nodeAggregate->contentStreamId, + $nodeAggregate->nodeAggregateId, + $originDimensionSpacePoint, + $actualTetheredChildNodes, + array_keys($expectedTetheredNodes) + ) ); } } @@ -210,7 +217,8 @@ protected function getInterDimensionalVariationGraph(): DimensionSpace\InterDime */ private function reorderNodes( ContentStreamId $contentStreamId, - Node $parentNode, + NodeAggregateId $parentNodeAggregateId, + DimensionSpace\OriginDimensionSpacePoint $originDimensionSpacePoint, array $actualTetheredChildNodes, array $expectedNodeOrdering ): EventsToPublish { @@ -240,8 +248,8 @@ private function reorderNodes( $succeedingNode->nodeAggregateId, $succeedingNode->originDimensionSpacePoint, // we only change the order, not the parent -> so we can simply use the parent here. - $parentNode->nodeAggregateId, - $parentNode->originDimensionSpacePoint + $parentNodeAggregateId, + $originDimensionSpacePoint ) ) ) diff --git a/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php b/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php index a6fe7ec2018..f816d330232 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php +++ b/Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php @@ -60,7 +60,8 @@ public function __construct( ); $this->dimensionAdjustment = new DimensionAdjustment( $projectedNodeIterator, - $interDimensionalVariationGraph + $interDimensionalVariationGraph, + $nodeTypeManager ); } diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeCreation.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeCreation.php index 9d7eb8ee253..41f04d7afff 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeCreation.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeCreation.php @@ -64,6 +64,9 @@ public function theCommandCreateRootNodeAggregateWithNodeIsExecutedWithPayload(T $nodeAggregateId, NodeTypeName::fromString($commandArguments['nodeTypeName']), ); + if (isset($commandArguments['tetheredDescendantNodeAggregateIds'])) { + $command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromArray($commandArguments['tetheredDescendantNodeAggregateIds'])); + } $this->lastCommandOrEventResult = $this->currentContentRepository->handle($command); $this->currentRootNodeAggregateId = $nodeAggregateId; diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeReferencing.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeReferencing.php index 3f9deb68f63..d43d4b26628 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeReferencing.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeReferencing.php @@ -66,7 +66,7 @@ public function theCommandSetNodeReferencesIsExecutedWithPayload(TableNode $payl ) ); - $command = new SetNodeReferences( + $command = SetNodeReferences::create( $contentStreamId, NodeAggregateId::fromString($commandArguments['sourceNodeAggregateId']), $sourceOriginDimensionSpacePoint, diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeRenaming.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeRenaming.php index 9de587eb916..bae8d6d1163 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeRenaming.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Features/NodeRenaming.php @@ -15,10 +15,11 @@ namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features; use Behat\Gherkin\Node\TableNode; -use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; +use Neos\ContentRepository\Core\Feature\NodeRenaming\Command\ChangeNodeAggregateName; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\ContentRepository\Core\SharedModel\Node\NodeName; +use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteRuntimeVariables; -use Neos\EventStore\Model\Event\StreamName; use PHPUnit\Framework\Assert; /** @@ -28,6 +29,41 @@ trait NodeRenaming { use CRTestSuiteRuntimeVariables; + /** + * @Given /^the command ChangeNodeAggregateName is executed with payload:$/ + * @param TableNode $payloadTable + * @throws \Exception + */ + public function theCommandChangeNodeAggregateNameIsExecutedWithPayload(TableNode $payloadTable) + { + $commandArguments = $this->readPayloadTable($payloadTable); + $contentStreamId = isset($commandArguments['contentStreamId']) + ? ContentStreamId::fromString($commandArguments['contentStreamId']) + : $this->currentContentStreamId; + + $command = ChangeNodeAggregateName::create( + $contentStreamId, + NodeAggregateId::fromString($commandArguments['nodeAggregateId']), + NodeName::fromString($commandArguments['newNodeName']), + ); + + $this->lastCommandOrEventResult = $this->currentContentRepository->handle($command); + } + + /** + * @Given /^the command ChangeNodeAggregateName is executed with payload and exceptions are caught:$/ + * @param TableNode $payloadTable + * @throws \Exception + */ + public function theCommandChangeNodeAggregateNameIsExecutedWithPayloadAndExceptionsAreCaught(TableNode $payloadTable) + { + try { + $this->theCommandChangeNodeAggregateNameIsExecutedWithPayload($payloadTable); + } catch (\Exception $exception) { + $this->lastCommandException = $exception; + } + } + /** * @Then /^I expect the node "([^"]*)" to have the name "([^"]*)"$/ * @param string $nodeAggregateId diff --git a/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php b/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php index ecf9d8f3160..170db769f12 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php +++ b/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php @@ -90,15 +90,15 @@ public function createMinimalNodeOfType( ); } $serializedDefaultPropertyValues = SerializedPropertyValues::fromArray($defaultPropertyValues); - return new Node( + return Node::create( ContentSubgraphIdentity::create( ContentRepositoryId::fromString('default'), ContentStreamId::fromString('cs-id'), - DimensionSpacePoint::fromArray([]), + DimensionSpacePoint::createWithoutDimensions(), VisibilityConstraints::withoutRestrictions() ), NodeAggregateId::create(), - OriginDimensionSpacePoint::fromArray([]), + OriginDimensionSpacePoint::createWithoutDimensions(), NodeAggregateClassification::CLASSIFICATION_REGULAR, $nodeType->name, $nodeType, diff --git a/Neos.ContentRepositoryRegistry/Classes/TestSuite/Behavior/CRRegistrySubjectProvider.php b/Neos.ContentRepositoryRegistry/Classes/TestSuite/Behavior/CRRegistrySubjectProvider.php index b65af14b832..fd1779fdc61 100644 --- a/Neos.ContentRepositoryRegistry/Classes/TestSuite/Behavior/CRRegistrySubjectProvider.php +++ b/Neos.ContentRepositoryRegistry/Classes/TestSuite/Behavior/CRRegistrySubjectProvider.php @@ -15,7 +15,6 @@ namespace Neos\ContentRepositoryRegistry\TestSuite\Behavior; use Doctrine\DBAL\Connection; -use Neos\Behat\Tests\Behat\FlowContextTrait; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; @@ -24,15 +23,11 @@ use Neos\ContentRepositoryRegistry\Exception\ContentRepositoryNotFoundException; use Neos\EventStore\EventStoreInterface; -require_once(__DIR__ . '/../../../../../Application/Neos.Behat/Tests/Behat/FlowContextTrait.php'); - /** * The node creation trait for behavioral tests */ trait CRRegistrySubjectProvider { - use FlowContextTrait; - protected ContentRepositoryRegistry $contentRepositoryRegistry; protected ?ContentRepository $currentContentRepository = null; @@ -42,13 +37,17 @@ trait CRRegistrySubjectProvider */ protected array $alreadySetUpContentRepositories = []; + /** + * @template T of object + * @param class-string $className + * + * @return T + */ + abstract protected function getObject(string $className): object; + protected function setUpCRRegistry(): void { - if (self::$bootstrap === null) { - self::$bootstrap = $this->initializeFlow(); - } - $this->objectManager = self::$bootstrap->getObjectManager(); - $this->contentRepositoryRegistry = $this->objectManager->get(ContentRepositoryRegistry::class); + $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); } /** diff --git a/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php b/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php index 5bb60261058..8a02bf5962b 100644 --- a/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php +++ b/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php @@ -92,8 +92,10 @@ protected function getPrivateProps(array $context): \ArrayAccess protected function render(array $context) { $this->runtime->pushContextArray($context); - $result = $this->runtime->render($this->path . '/renderer'); - $this->runtime->popContext(); - return $result; + try { + return $this->runtime->render($this->path . '/renderer'); + } finally { + $this->runtime->popContext(); + } } } diff --git a/Neos.Fusion/Classes/Service/RenderAttributesTrait.php b/Neos.Fusion/Classes/Service/RenderAttributesTrait.php index 9063bb17ed5..ca6af143c16 100644 --- a/Neos.Fusion/Classes/Service/RenderAttributesTrait.php +++ b/Neos.Fusion/Classes/Service/RenderAttributesTrait.php @@ -42,6 +42,8 @@ protected function renderAttributes(iterable $attributes, bool $allowEmpty = tru foreach ($attributeValue as $attributeValuePart) { if ($attributeValuePart instanceof \Stringable) { $attributeValuePart = $attributeValuePart->__toString(); + } elseif ($attributeValuePart instanceof \BackedEnum) { + $attributeValuePart = $attributeValuePart->value; } $joinedAttributeValue .= match (gettype($attributeValuePart)) { 'boolean', 'NULL' => '', @@ -50,6 +52,10 @@ protected function renderAttributes(iterable $attributes, bool $allowEmpty = tru }; } $attributeValue = trim($joinedAttributeValue); + } elseif ($attributeValue instanceof \Stringable) { + $attributeValue = $attributeValue->__toString(); + } elseif ($attributeValue instanceof \BackedEnum) { + $attributeValue = $attributeValue->value; } $encodedAttributeName = htmlspecialchars((string)$attributeName, ENT_COMPAT, 'UTF-8', false); if ($attributeValue === true || $attributeValue === '') { diff --git a/Neos.Fusion/Classes/ViewHelpers/FusionContextTrait.php b/Neos.Fusion/Classes/ViewHelpers/FusionContextTrait.php index 511868cc4af..29133108fb5 100644 --- a/Neos.Fusion/Classes/ViewHelpers/FusionContextTrait.php +++ b/Neos.Fusion/Classes/ViewHelpers/FusionContextTrait.php @@ -33,18 +33,19 @@ trait FusionContextTrait */ protected function getContextVariable($variableName) { - $value = null; - $view = $this->viewHelperVariableContainer->getView(); if ($view instanceof FusionAwareViewInterface) { $fusionObject = $view->getFusionObject(); $currentContext = $fusionObject->getRuntime()->getCurrentContext(); if (isset($currentContext[$variableName])) { - $value = $currentContext[$variableName]; + return $currentContext[$variableName]; + } + $fusionGlobals = $fusionObject->getRuntime()->fusionGlobals; + if ($fusionGlobals->has($variableName)) { + return $fusionGlobals->get($variableName); } } - - return $value; + return null; } /** diff --git a/Neos.Fusion/Tests/Unit/Service/HtmlAugmenterTest.php b/Neos.Fusion/Tests/Unit/Service/HtmlAugmenterTest.php index 820b2d7afe5..c2befa76c02 100644 --- a/Neos.Fusion/Tests/Unit/Service/HtmlAugmenterTest.php +++ b/Neos.Fusion/Tests/Unit/Service/HtmlAugmenterTest.php @@ -47,9 +47,14 @@ public function __toString() { return "casted value"; } } + enum BackedStringEnum: string { + case Example = "enum value"; + } '); + /** @noinspection PhpUndefinedClassInspection */ $mockObject = new \ClassWithToStringMethod(); + $mockEnum = \BackedStringEnum::Example; return [ // object values with __toString method @@ -61,7 +66,15 @@ public function __toString() { 'allowEmpty' => true, 'expectedResult' => '
' ], - + // object values with BackendEnum value + [ + 'html' => '', + 'attributes' => ['enum' => $mockEnum], + 'fallbackTagName' => null, + 'exclusiveAttributes' => null, + 'allowEmpty' => true, + 'expectedResult' => '
' + ], // empty source [ 'html' => '', @@ -344,6 +357,23 @@ public function __toString() { 'allowEmpty' => false, 'expectedResult' => '

Stringable attribute

', ], + // Adding of Enum attributes + [ + 'html' => '

Enum attribute

', + 'attributes' => ['data-enum' => $mockEnum], + 'fallbackTagName' => null, + 'exclusiveAttributes' => null, + 'allowEmpty' => true, + 'expectedResult' => '

Enum attribute

', + ], + [ + 'html' => '

Enum attribute

', + 'attributes' => ['data-enum' => $mockEnum], + 'fallbackTagName' => null, + 'exclusiveAttributes' => null, + 'allowEmpty' => false, + 'expectedResult' => '

Enum attribute

', + ], // Adding of array attributes [ 'html' => '

Array attribute

', diff --git a/Neos.Media.Browser/Classes/Controller/AssetController.php b/Neos.Media.Browser/Classes/Controller/AssetController.php index eaace83962a..7f78d961061 100644 --- a/Neos.Media.Browser/Classes/Controller/AssetController.php +++ b/Neos.Media.Browser/Classes/Controller/AssetController.php @@ -50,6 +50,7 @@ use Neos\Media\Domain\Repository\AssetRepository; use Neos\Media\Domain\Repository\TagRepository; use Neos\Media\Domain\Service\AssetService; +use Neos\Media\Domain\Service\AssetVariantGenerator; use Neos\Media\Exception\AssetServiceException; use Neos\Media\TypeConverter\AssetInterfaceConverter; use Neos\Neos\Controller\BackendUserTranslationTrait; @@ -138,6 +139,12 @@ class AssetController extends ActionController */ protected $assetSourceService; + /** + * @Flow\Inject + * @var AssetVariantGenerator + */ + protected $assetVariantGenerator; + /** * @var AssetSourceInterface[] */ @@ -467,6 +474,32 @@ public function variantsAction(string $assetSourceIdentifier, string $assetProxy } } + /** + * Create missing variants for the given image + * + * @param string $assetSourceIdentifier + * @param string $assetProxyIdentifier + * @param string $overviewAction + * @throws StopActionException + * @throws UnsupportedRequestTypeException + */ + public function createVariantsAction(string $assetSourceIdentifier, string $assetProxyIdentifier, string $overviewAction): void + { + $assetSource = $this->assetSources[$assetSourceIdentifier]; + $assetProxyRepository = $assetSource->getAssetProxyRepository(); + + $assetProxy = $assetProxyRepository->getAssetProxy($assetProxyIdentifier); + $asset = $this->persistenceManager->getObjectByIdentifier($assetProxy->getLocalAssetIdentifier(), Asset::class); + + /** @var VariantSupportInterface $originalAsset */ + $originalAsset = ($asset instanceof AssetVariantInterface ? $asset->getOriginalAsset() : $asset); + + $this->assetVariantGenerator->createVariants($originalAsset); + $this->assetRepository->update($originalAsset); + + $this->redirect('variants', null, null, ['assetSourceIdentifier' => $assetSourceIdentifier, 'assetProxyIdentifier' => $assetProxyIdentifier, 'overviewAction' => $overviewAction]); + } + /** * @return void * @throws NoSuchArgumentException diff --git a/Neos.Media.Browser/Configuration/Policy.yaml b/Neos.Media.Browser/Configuration/Policy.yaml index 24e025b8edb..a237114296c 100644 --- a/Neos.Media.Browser/Configuration/Policy.yaml +++ b/Neos.Media.Browser/Configuration/Policy.yaml @@ -6,7 +6,7 @@ privilegeTargets: 'Neos.Media.Browser:ManageAssets': label: Allowed to manage assets - matcher: 'method(Neos\Media\Browser\Controller\(Asset|Image)Controller->(index|new|show|edit|update|initializeCreate|create|replaceAssetResource|updateAssetResource|initializeUpload|upload|tagAsset|delete|createTag|editTag|updateTag|deleteTag|addAssetToCollection|relatedNodes|variants)Action()) || method(Neos\Media\Browser\Controller\ImageVariantController->(update)Action())' + matcher: 'method(Neos\Media\Browser\Controller\(Asset|Image)Controller->(index|new|show|edit|update|initializeCreate|create|replaceAssetResource|updateAssetResource|initializeUpload|upload|tagAsset|delete|createTag|editTag|updateTag|deleteTag|addAssetToCollection|relatedNodes|variants|createVariants)Action()) || method(Neos\Media\Browser\Controller\ImageVariantController->(update)Action())' 'Neos.Media.Browser:AssetUsage': label: Allowed to calculate asset usages diff --git a/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html b/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html index 0c035452335..e024a452100 100644 --- a/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html +++ b/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html @@ -24,6 +24,13 @@ + + + diff --git a/Neos.Media.Browser/Resources/Private/Translations/en/Main.xlf b/Neos.Media.Browser/Resources/Private/Translations/en/Main.xlf index 81cddf67e1e..07f3354ed02 100644 --- a/Neos.Media.Browser/Resources/Private/Translations/en/Main.xlf +++ b/Neos.Media.Browser/Resources/Private/Translations/en/Main.xlf @@ -427,6 +427,9 @@ No document node found for this node + + Create missing variants + diff --git a/Neos.Media/Classes/Domain/Service/AssetVariantGenerator.php b/Neos.Media/Classes/Domain/Service/AssetVariantGenerator.php index dcc5eaae7b7..e5700aa101a 100644 --- a/Neos.Media/Classes/Domain/Service/AssetVariantGenerator.php +++ b/Neos.Media/Classes/Domain/Service/AssetVariantGenerator.php @@ -125,6 +125,11 @@ public function createVariant(AssetInterface $asset, string $presetIdentifier, s $createdVariant = null; $preset = $this->getVariantPresets()[$presetIdentifier] ?? null; if ($preset instanceof VariantPreset && $preset->matchesMediaType($asset->getMediaType())) { + $existingVariant = $asset->getVariant($presetIdentifier, $variantIdentifier); + if ($existingVariant !== null) { + return $existingVariant; + } + $variantConfiguration = $preset->variants()[$variantIdentifier] ?? null; if ($variantConfiguration instanceof Configuration\Variant) { diff --git a/Neos.Media/Classes/Package.php b/Neos.Media/Classes/Package.php index 299f827307c..dd5b7b06fb5 100644 --- a/Neos.Media/Classes/Package.php +++ b/Neos.Media/Classes/Package.php @@ -11,8 +11,10 @@ * source code. */ +use Neos\Flow\Configuration\ConfigurationManager; use Neos\Flow\Core\Bootstrap; use Neos\Flow\Package\Package as BasePackage; +use Neos\Media\Domain\Model\AssetInterface; use Neos\Media\Domain\Model\ImportedAssetManager; use Neos\Media\Domain\Service\AssetService; use Neos\Media\Domain\Service\AssetVariantGenerator; @@ -30,7 +32,12 @@ class Package extends BasePackage public function boot(Bootstrap $bootstrap) { $dispatcher = $bootstrap->getSignalSlotDispatcher(); - $dispatcher->connect(AssetService::class, 'assetCreated', AssetVariantGenerator::class, 'createVariants'); + $dispatcher->connect(AssetService::class, 'assetCreated', function (AssetInterface $asset) use ($bootstrap) { + $configurationManager = $bootstrap->getObjectManager()->get(ConfigurationManager::class); + if ($configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Media.autoCreateImageVariantPresets')) { + $bootstrap->getObjectManager()->get(AssetVariantGenerator::class)->createVariants($asset); + } + }); $dispatcher->connect(AssetService::class, 'assetCreated', ThumbnailGenerator::class, 'createThumbnails'); $dispatcher->connect(AssetService::class, 'assetCreated', ImportedAssetManager::class, 'registerCreatedAsset'); $dispatcher->connect(AssetService::class, 'assetRemoved', ImportedAssetManager::class, 'registerRemovedAsset'); diff --git a/Neos.Media/Configuration/Settings.yaml b/Neos.Media/Configuration/Settings.yaml index e6a455cdbdb..edd86af4d72 100644 --- a/Neos.Media/Configuration/Settings.yaml +++ b/Neos.Media/Configuration/Settings.yaml @@ -65,7 +65,7 @@ Neos: # Variant presets variantPresets: [] # Automatically create asset variants for configured presets when assets are added - autoCreateImageVariantPresets: false + autoCreateImageVariantPresets: true thumbnailGenerators: diff --git a/Neos.Media/Documentation/VariantPresets.rst b/Neos.Media/Documentation/VariantPresets.rst index 02976ec41b2..d43dd11e921 100644 --- a/Neos.Media/Documentation/VariantPresets.rst +++ b/Neos.Media/Documentation/VariantPresets.rst @@ -92,14 +92,14 @@ The following example shows the required structure and possible fields of the pr options: aspectRatio: '1:1' -The automatic variant generation for new assets has to be enabled via setting as -by default this feature is disabled. +The automatic variant generation for new assets is active by default. +It can be disabled via setting: .. code-block:: yaml Neos: Media: - autoCreateImageVariantPresets: true + autoCreateImageVariantPresets: false To show and edit the variants in the media module the variants tab has to be enabled. diff --git a/Neos.Media/Documentation/conf.py b/Neos.Media/Documentation/conf.py index 6fdf4edc962..6cff3a86200 100644 --- a/Neos.Media/Documentation/conf.py +++ b/Neos.Media/Documentation/conf.py @@ -27,9 +27,9 @@ author = 'Neos Team and Contributors' # The short X.Y version. -version = 'dev-master' +version = '9.0' # The full version, including alpha/beta/rc tags. -release = 'dev-master' +release = '9.0.x' # -- General configuration --------------------------------------------------- diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php index 51b891ee38b..5adfeaa32a2 100644 --- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php +++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php @@ -198,7 +198,7 @@ public function previewAction(string $node): void * with unsafe requests from widgets or plugins that are rendered on the node * - For those the CSRF token is validated on the sub-request, so it is safe to be skipped here */ - public function showAction(string $node, bool $showInvisible = false): void + public function showAction(string $node): void { $siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest()); $contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId); @@ -208,15 +208,10 @@ public function showAction(string $node, bool $showInvisible = false): void throw new NodeNotFoundException('The requested node isn\'t accessible to the current user', 1430218623); } - $visibilityConstraints = VisibilityConstraints::frontend(); - if ($showInvisible && $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) { - $visibilityConstraints = VisibilityConstraints::withoutRestrictions(); - } - $subgraph = $contentRepository->getContentGraph()->getSubgraph( $nodeAddress->contentStreamId, $nodeAddress->dimensionSpacePoint, - $visibilityConstraints + VisibilityConstraints::frontend() ); $site = $this->nodeSiteResolvingService->findSiteNodeForNodeAddress( @@ -231,7 +226,7 @@ public function showAction(string $node, bool $showInvisible = false): void $nodeInstance = $subgraph->findNodeById($nodeAddress->nodeAggregateId); - if (is_null($nodeInstance)) { + if ($nodeInstance === null) { throw new NodeNotFoundException('The requested node does not exist', 1596191460); } diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index cc3942cdf54..26d7046e851 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -577,17 +577,7 @@ public function discardNodeAction(string $nodeAddress, WorkspaceName $selectedWo } /** - * Publishes or discards the given nodes - * - * @param array $nodes - * @throws \Exception - * @throws \Neos\Flow\Property\Exception - * @throws \Neos\Flow\Security\Exception - */ - /** @phpstan-ignore-next-line - * @param array $nodes - * @param string $action - * @param string $selectedWorkspace + * @psalm-param list $nodes * @throws IndexOutOfBoundsException * @throws InvalidFormatPlaceholderException * @throws StopActionException diff --git a/Neos.Neos/Classes/Domain/Service/NodeSearchService.php b/Neos.Neos/Classes/Domain/Service/NodeSearchService.php deleted file mode 100644 index bd3ed2bb289..00000000000 --- a/Neos.Neos/Classes/Domain/Service/NodeSearchService.php +++ /dev/null @@ -1,42 +0,0 @@ - $searchNodeTypes - */ - public function findByProperties( - string $term, - array $searchNodeTypes, - ?Node $startingPoint = null - ): never { - throw new \InvalidArgumentException('Cannot find nodes with the current set of arguments', 1651923867); - } -} diff --git a/Neos.Neos/Classes/Domain/Service/NodeSearchServiceInterface.php b/Neos.Neos/Classes/Domain/Service/NodeSearchServiceInterface.php deleted file mode 100644 index abd58aa5681..00000000000 --- a/Neos.Neos/Classes/Domain/Service/NodeSearchServiceInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - $searchNodeTypes - */ - public function findByProperties(string $term, array $searchNodeTypes): Nodes; -} diff --git a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php index 9f5e7b9a4ff..a93df26f963 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php +++ b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php @@ -48,7 +48,7 @@ public function __construct( * $siteNode = $this->siteNodeUtility->findSiteNodeBySite( * $site, * $liveWorkspace->currentContentStreamId, - * DimensionSpacePoint::fromArray([]), + * DimensionSpacePoint::createWithoutDimensions(), * VisibilityConstraints::frontend() * ); * ``` diff --git a/Neos.Neos/Classes/FrontendRouting/DimensionResolution/RequestToDimensionSpacePointContext.php b/Neos.Neos/Classes/FrontendRouting/DimensionResolution/RequestToDimensionSpacePointContext.php index f615f766c44..abec0874482 100644 --- a/Neos.Neos/Classes/FrontendRouting/DimensionResolution/RequestToDimensionSpacePointContext.php +++ b/Neos.Neos/Classes/FrontendRouting/DimensionResolution/RequestToDimensionSpacePointContext.php @@ -32,7 +32,7 @@ public static function fromUriPathAndRouteParametersAndResolvedSite(string $init $initialUriPath, $routeParameters, $initialUriPath, - DimensionSpacePoint::fromArray([]), + DimensionSpacePoint::createWithoutDimensions(), $resolvedSite, ); } diff --git a/Neos.Neos/Classes/FrontendRouting/DimensionResolution/Resolver/UriPathResolver.php b/Neos.Neos/Classes/FrontendRouting/DimensionResolution/Resolver/UriPathResolver.php index 300586962a8..d84976d2f43 100644 --- a/Neos.Neos/Classes/FrontendRouting/DimensionResolution/Resolver/UriPathResolver.php +++ b/Neos.Neos/Classes/FrontendRouting/DimensionResolution/Resolver/UriPathResolver.php @@ -83,7 +83,7 @@ public static function createForNoDimensions(): self [], [], Segments::create(), - DimensionSpacePoint::fromArray([]) + DimensionSpacePoint::createWithoutDimensions() ); } diff --git a/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php b/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php index a732ddf97d3..6e92d883fd5 100644 --- a/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php +++ b/Neos.Neos/Classes/Fusion/AbstractMenuItemsImplementation.php @@ -46,13 +46,6 @@ abstract class AbstractMenuItemsImplementation extends AbstractFusionObject */ protected $currentNode; - /** - * Internal cache for the currentLevel tsValue. - * - * @var integer - */ - protected $currentLevel; - /** * Internal cache for the renderHiddenInIndex property. * @@ -61,15 +54,28 @@ abstract class AbstractMenuItemsImplementation extends AbstractFusionObject protected $renderHiddenInIndex; /** - * Rootline of all nodes from the current node to the site root node, keys are depth of nodes. + * Internal cache for the calculateItemStates property. * - * @var array + * @var boolean */ - protected $currentNodeRootline; + protected $calculateItemStates; #[Flow\Inject] protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** + * Whether the active/current state of menu items is calculated on the server side. + * This has an effect on performance and caching + */ + public function isCalculateItemStatesEnabled(): bool + { + if ($this->calculateItemStates === null) { + $this->calculateItemStates = (bool)$this->fusionValue('calculateItemStates'); + } + + return $this->calculateItemStates; + } + /** * Should nodes that have "hiddenInIndex" set still be visible in this menu. * @@ -84,6 +90,19 @@ public function getRenderHiddenInIndex() return $this->renderHiddenInIndex; } + /** + * The node the menu is built from, all relative specifications will + * use this as a base + */ + public function getCurrentNode(): Node + { + if ($this->currentNode === null) { + $this->currentNode = $this->fusionValue('node'); + } + + return $this->currentNode; + } + /** * Main API method which sends the to-be-rendered data to Fluid * @@ -92,9 +111,6 @@ public function getRenderHiddenInIndex() public function getItems(): array { if ($this->items === null) { - $fusionContext = $this->runtime->getCurrentContext(); - $this->currentNode = $fusionContext['activeNode'] ?? $fusionContext['documentNode']; - $this->currentLevel = 1; $this->items = $this->buildItems(); } @@ -143,30 +159,14 @@ protected function isNodeHidden(Node $node) return $node->getProperty('_hiddenInIndex'); } - /** - * Get the rootline from the current node up to the site node. - * - * @return array nodes, indexed by depth - */ - protected function getCurrentNodeRootline(): array + protected function buildUri(Node $node): string { - if ($this->currentNodeRootline === null) { - $rootline = []; - $ancestors = $this->contentRepositoryRegistry->subgraphForNode($this->currentNode) - ->findAncestorNodes( - $this->currentNode->nodeAggregateId, - FindAncestorNodesFilter::create() - ); - foreach ($ancestors->reverse() as $i => $ancestor) { - if (!$ancestor->classification->isRoot()) { - $rootline[$i] = $ancestor; - } - } - $rootline[] = $this->currentNode; - - $this->currentNodeRootline = $rootline; - } - - return $this->currentNodeRootline; + $this->runtime->pushContextArray([ + 'itemNode' => $node, + 'documentNode' => $node, + ]); + $uri = $this->runtime->render($this->path . '/itemUriRenderer'); + $this->runtime->popContext(); + return $uri; } } diff --git a/Neos.Neos/Classes/Fusion/DimensionMenuItem.php b/Neos.Neos/Classes/Fusion/DimensionMenuItem.php new file mode 100644 index 00000000000..cb7ff321d1c --- /dev/null +++ b/Neos.Neos/Classes/Fusion/DimensionMenuItem.php @@ -0,0 +1,26 @@ +|null $targetDimensions + */ + public function __construct( + public ?Node $node, + public ?MenuItemState $state = null, + public ?string $label = null, + public ?array $targetDimensions = null, + public ?string $uri = null + ) { + } +} diff --git a/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php b/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php index 50871a64ebd..97fff10f134 100644 --- a/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php +++ b/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php @@ -39,12 +39,14 @@ public function getDimension(): array /** * Builds the array of Menu items for this variant menu - * @return array> + * @return array */ protected function buildItems(): array { $menuItems = []; - $contentRepositoryId = $this->currentNode->subgraphIdentity->contentRepositoryId; + $currentNode = $this->getCurrentNode(); + + $contentRepositoryId = $currentNode->subgraphIdentity->contentRepositoryId; $contentRepository = $this->contentRepositoryRegistry->get( $contentRepositoryId, ); @@ -56,28 +58,28 @@ protected function buildItems(): array assert($dimensionMenuItemsImplementationInternals instanceof DimensionsMenuItemsImplementationInternals); $interDimensionalVariationGraph = $dimensionMenuItemsImplementationInternals->interDimensionalVariationGraph; - $currentDimensionSpacePoint = $this->currentNode->subgraphIdentity->dimensionSpacePoint; + $currentDimensionSpacePoint = $currentNode->subgraphIdentity->dimensionSpacePoint; $contentDimensionIdentifierToLimitTo = $this->getContentDimensionIdentifierToLimitTo(); foreach ($interDimensionalVariationGraph->getDimensionSpacePoints() as $dimensionSpacePoint) { $variant = null; if ($this->isDimensionSpacePointRelevant($dimensionSpacePoint)) { if ($dimensionSpacePoint->equals($currentDimensionSpacePoint)) { - $variant = $this->currentNode; + $variant = $currentNode; } else { $variant = $contentRepository->getContentGraph() ->getSubgraph( - $this->currentNode->subgraphIdentity->contentStreamId, + $currentNode->subgraphIdentity->contentStreamId, $dimensionSpacePoint, - $this->currentNode->subgraphIdentity->visibilityConstraints, + $currentNode->subgraphIdentity->visibilityConstraints, ) - ->findNodeById($this->currentNode->nodeAggregateId); + ->findNodeById($currentNode->nodeAggregateId); } if (!$variant && $this->includeGeneralizations() && $contentDimensionIdentifierToLimitTo) { $variant = $this->findClosestGeneralizationMatchingDimensionValue( $dimensionSpacePoint, $contentDimensionIdentifierToLimitTo, - $this->currentNode->nodeAggregateId, + $currentNode->nodeAggregateId, $dimensionMenuItemsImplementationInternals, $contentRepository ); @@ -86,12 +88,13 @@ protected function buildItems(): array $metadata = $this->determineMetadata($dimensionSpacePoint, $dimensionMenuItemsImplementationInternals); if ($variant === null || !$this->isNodeHidden($variant)) { - $menuItems[] = [ - 'node' => $variant, - 'state' => $this->calculateItemState($variant), - 'label' => $this->determineLabel($variant, $metadata), - 'targetDimensions' => $metadata - ]; + $menuItems[] = new DimensionMenuItem( + $variant, + $this->isCalculateItemStatesEnabled() ? $this->calculateItemState($variant) : null, + $this->determineLabel($variant, $metadata), + $metadata, + $variant ? $this->buildUri($variant) : null + ); } } } @@ -100,15 +103,15 @@ protected function buildItems(): array if ($contentDimensionIdentifierToLimitTo && $valuesToRestrictTo) { $order = array_flip($valuesToRestrictTo); usort($menuItems, function ( - array $menuItemA, - array $menuItemB + DimensionMenuItem $menuItemA, + DimensionMenuItem $menuItemB ) use ( $order, $contentDimensionIdentifierToLimitTo ) { - return (int)$order[$menuItemA['node']?->subgraphIdentity->dimensionSpacePoint->getCoordinate( + return (int)$order[$menuItemA->node?->subgraphIdentity->dimensionSpacePoint->getCoordinate( $contentDimensionIdentifierToLimitTo - )] <=> (int)$order[$menuItemB['node']?->subgraphIdentity->dimensionSpacePoint->getCoordinate( + )] <=> (int)$order[$menuItemB->node?->subgraphIdentity->dimensionSpacePoint->getCoordinate( $contentDimensionIdentifierToLimitTo )]; }); @@ -218,19 +221,19 @@ protected function determineLabel(?Node $variant = null, array $metadata = []): } } - protected function calculateItemState(?Node $variant = null): string + protected function calculateItemState(?Node $variant = null): MenuItemState { if (is_null($variant)) { - return self::STATE_ABSENT; + return MenuItemState::ABSENT; } if ($variant === $this->currentNode) { - return self::STATE_CURRENT; + return MenuItemState::CURRENT; } - - return self::STATE_NORMAL; + return MenuItemState::NORMAL; } + /** * In some cases generalization of the other dimension values is feasible * to find a dimension space point in which a variant can be resolved diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php index 54384747a8b..906d9c2ebb7 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\NodeType\NodeType; use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; +use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; @@ -150,6 +151,11 @@ public function serializedNodeAddress(Node $node): string return $nodeAddressFactory->createFromNode($node)->serializeForUri(); } + public function subgraphForNode(Node $node): ContentSubgraphInterface + { + return $this->contentRepositoryRegistry->subgraphForNode($node); + } + /** * @param string $methodName * @return boolean diff --git a/Neos.Neos/Classes/Fusion/MenuItem.php b/Neos.Neos/Classes/Fusion/MenuItem.php index 86c23f1947d..59de848a70c 100644 --- a/Neos.Neos/Classes/Fusion/MenuItem.php +++ b/Neos.Neos/Classes/Fusion/MenuItem.php @@ -9,60 +9,19 @@ /** * A menu item */ -final class MenuItem +final readonly class MenuItem { - protected Node $node; - - protected ?MenuItemState $state; - - protected ?string $label; - - protected int $menuLevel; - - /** - * @var array - */ - protected array $children; - - protected ?string $uri; - /** * @param array $children */ public function __construct( - Node $node, - ?MenuItemState $state = null, - ?string $label = null, - int $menuLevel = 1, - array $children = [], - string $uri = null + public Node $node, + public ?MenuItemState $state = null, + public ?string $label = null, + public int $menuLevel = 1, + public array $children = [], + public ?string $uri = null ) { - $this->node = $node; - $this->state = $state; - $this->label = $label; - $this->menuLevel = $menuLevel; - $this->children = $children; - $this->uri = $uri; - } - - public function getNode(): Node - { - return $this->node; - } - - public function getState(): ?MenuItemState - { - return $this->state; - } - - public function getLabel(): ?string - { - return $this->label; - } - - public function getMenuLevel(): int - { - return $this->menuLevel; } /** @@ -75,7 +34,7 @@ public function getChildren(): array /** * @return array - * @deprecated Use getChildren instead + * @deprecated Use children instead */ public function getSubItems(): array { diff --git a/Neos.Neos/Classes/Fusion/MenuItemState.php b/Neos.Neos/Classes/Fusion/MenuItemState.php index 5bae271d731..2430cc3a75f 100644 --- a/Neos.Neos/Classes/Fusion/MenuItemState.php +++ b/Neos.Neos/Classes/Fusion/MenuItemState.php @@ -7,53 +7,10 @@ /** * The menu item state value object */ -final class MenuItemState +enum MenuItemState: string { - public const STATE_NORMAL = 'normal'; - public const STATE_CURRENT = 'current'; - public const STATE_ACTIVE = 'active'; - public const STATE_ABSENT = 'absent'; - - /** - * @var string - */ - protected $state; - - /** - * @param string $state - * @throws Exception\InvalidMenuItemStateException - */ - public function __construct(string $state) - { - if ( - $state !== self::STATE_NORMAL - && $state !== self::STATE_CURRENT - && $state !== self::STATE_ACTIVE - && $state !== self::STATE_ABSENT - ) { - throw new Exception\InvalidMenuItemStateException( - '"' . $state . '" is no valid menu item state', - 1519668881 - ); - } - - $this->state = $state; - } - - - /** - * @return MenuItemState - */ - public static function normal(): MenuItemState - { - return new MenuItemState(self::STATE_NORMAL); - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->state; - } + case NORMAL = 'normal'; + case CURRENT = 'current'; + case ACTIVE = 'active'; + case ABSENT = 'absent'; } diff --git a/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php b/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php index c6a6a7258cf..3560453e807 100644 --- a/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php +++ b/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php @@ -15,12 +15,17 @@ namespace Neos\Neos\Fusion; use Neos\ContentRepository\Core\NodeType\NodeTypeName; +use Neos\ContentRepository\Core\NodeType\NodeTypeNames; +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindSubtreeFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes; -use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria; -use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria; +use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; +use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraintsWithSubNodeTypes; use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds; use Neos\Fusion\Exception as FusionException; use Neos\Neos\Domain\Service\NodeTypeNameFactory; @@ -36,29 +41,28 @@ class MenuItemsImplementation extends AbstractMenuItemsImplementation /** * Internal cache for the startingPoint tsValue. - * - * @var Node */ - protected $startingPoint; + protected ?Node $startingPoint = null; /** * Internal cache for the lastLevel value. - * - * @var integer */ - protected $lastLevel; + protected ?int $lastLevel = null; /** * Internal cache for the maximumLevels tsValue. - * - * @var integer */ - protected $maximumLevels; + protected ?int $maximumLevels = null; + + /** + * Internal cache for the ancestors aggregate ids of the currentNode. + */ + protected ?NodeAggregateIds $currentNodeRootlineAggregateIds = null; /** * Runtime cache for the node type constraints to be applied */ - protected ?NodeTypeCriteria $nodeTypeCriteria = null; + protected ?NodeTypeConstraints $nodeTypeConstraints = null; /** * The last navigation level which should be rendered. @@ -70,20 +74,16 @@ class MenuItemsImplementation extends AbstractMenuItemsImplementation * -1 = one level above the current page * -2 = two levels above the current page * ... - * - * @return integer */ - public function getEntryLevel() + protected function getEntryLevel(): int { return $this->fusionValue('entryLevel'); } /** * NodeType filter for nodes displayed in menu - * - * @return string */ - public function getFilter() + protected function getFilter(): string { $filter = $this->fusionValue('filter'); if ($filter === null) { @@ -95,10 +95,8 @@ public function getFilter() /** * Maximum number of levels which should be rendered in this menu. - * - * @return integer */ - public function getMaximumLevels() + protected function getMaximumLevels(): int { if ($this->maximumLevels === null) { $this->maximumLevels = $this->fusionValue('maximumLevels'); @@ -112,10 +110,8 @@ public function getMaximumLevels() /** * Return evaluated lastLevel value. - * - * @return integer */ - public function getLastLevel(): int + protected function getLastLevel(): ?int { if ($this->lastLevel === null) { $this->lastLevel = $this->fusionValue('lastLevel'); @@ -127,7 +123,7 @@ public function getLastLevel(): int return $this->lastLevel; } - public function getStartingPoint(): ?Node + protected function getStartingPoint(): ?Node { if ($this->startingPoint === null) { $this->startingPoint = $this->fusionValue('startingPoint'); @@ -139,7 +135,7 @@ public function getStartingPoint(): ?Node /** * @return array|Nodes|null */ - public function getItemCollection(): array|Nodes|null + protected function getItemCollection(): array|Nodes|null { return $this->fusionValue('itemCollection'); } @@ -153,45 +149,89 @@ public function getItemCollection(): array|Nodes|null */ protected function buildItems(): array { - $subgraph = $this->contentRepositoryRegistry->subgraphForNode($this->currentNode); + $subgraph = $this->contentRepositoryRegistry->subgraphForNode($this->getCurrentNode()); if (!is_null($this->getItemCollection())) { $items = []; foreach ($this->getItemCollection() as $node) { - $childSubtree = $subgraph->findSubtree( - $node->nodeAggregateId, - FindSubtreeFilter::create(nodeTypes: $this->getNodeTypeCriteria(), maximumLevels: $this->getMaximumLevels()) - ); - if ($childSubtree === null) { - continue; + if ($this->getMaximumLevels() > 0) { + $childSubtree = $subgraph->findSubtree( + $node->nodeAggregateId, + FindSubtreeFilter::create(nodeTypeConstraints: $this->getNodeTypeConstraints(), maximumLevels: $this->getMaximumLevels() - 1) + ); + if ($childSubtree === null) { + continue; + } + $items[] = $this->buildMenuItemFromSubtree($childSubtree, 1); + } else { + $items[] = $this->buildMenuItemFromNode($node); } - $items[] = $this->traverseChildren($childSubtree); } return $items; } - $entryParentNode = $this->findMenuStartingPoint(); - if (!$entryParentNode) { + $entryParentNodeAggregateId = $this->findMenuStartingPointAggregateId(); + if (!$entryParentNodeAggregateId) { return []; } + $maximumLevels = $this->getMaximumLevels(); + $lastLevels = $this->getLastLevel(); + if ($lastLevels !== null) { + $depthOfEntryParentNodeAggregateId = $subgraph->countAncestorNodes( + $entryParentNodeAggregateId, + CountAncestorNodesFilter::create( + NodeTypeConstraints::createWithAllowedNodeTypeNames( + NodeTypeNames::with( + NodeTypeNameFactory::forDocument() + ) + ) + ) + ); + + if ($lastLevels > 0) { + $maxLevelsBasedOnLastLevel = max($lastLevels - $depthOfEntryParentNodeAggregateId, 0); + $maximumLevels = min($maximumLevels, $maxLevelsBasedOnLastLevel); + } elseif ($lastLevels < 0) { + $currentNodeAncestorAggregateIds = $this->getCurrentNodeRootlineAggregateIds(); + $depthOfCurrentDocument = count(iterator_to_array($currentNodeAncestorAggregateIds)) - 1; + $maxLevelsBasedOnLastLevel = max($depthOfCurrentDocument + $lastLevels - $depthOfEntryParentNodeAggregateId + 1, 0); + $maximumLevels = min($maximumLevels, $maxLevelsBasedOnLastLevel); + } + } + $childSubtree = $subgraph->findSubtree( - $entryParentNode->nodeAggregateId, - FindSubtreeFilter::create(nodeTypes: $this->getNodeTypeCriteria(), maximumLevels: $this->getMaximumLevels()) + $entryParentNodeAggregateId, + FindSubtreeFilter::create( + nodeTypeConstraints: $this->getNodeTypeConstraints(), + maximumLevels: $maximumLevels + ) ); if ($childSubtree === null) { return []; } - return $this->traverseChildren($childSubtree)->getChildren(); + return $this->buildMenuItemFromSubtree($childSubtree)->getChildren(); + } + + protected function buildMenuItemFromNode(Node $node): MenuItem + { + return new MenuItem( + $node, + $this->isCalculateItemStatesEnabled() ? $this->calculateItemState($node) : null, + $node->getLabel(), + 0, + [], + $this->buildUri($node) + ); } - protected function traverseChildren(Subtree $subtree): MenuItem + protected function buildMenuItemFromSubtree(Subtree $subtree, int $startLevel = 0): MenuItem { $children = []; foreach ($subtree->children as $childSubtree) { $node = $childSubtree->node; if (!$this->isNodeHidden($node)) { - $childNode = $this->traverseChildren($childSubtree); + $childNode = $this->buildMenuItemFromSubtree($childSubtree, $startLevel); $children[] = $childNode; } } @@ -200,9 +240,9 @@ protected function traverseChildren(Subtree $subtree): MenuItem return new MenuItem( $node, - MenuItemState::normal(), + $this->isCalculateItemStatesEnabled() ? $this->calculateItemState($node) : null, $node->getLabel(), - $subtree->level, + $subtree->level + $startLevel, $children, $this->buildUri($node) ); @@ -215,16 +255,12 @@ protected function traverseChildren(Subtree $subtree): MenuItem * * If entryLevel is configured this will be taken into account as well. * - * @return Node|null + * @return NodeAggregateId|null * @throws FusionException */ - protected function findMenuStartingPoint(): ?Node + protected function findMenuStartingPointAggregateId(): ?NodeAggregateId { - $fusionContext = $this->runtime->getCurrentContext(); - $traversalStartingPoint = $this->getStartingPoint() ?: $fusionContext['node'] ?? null; - - $contentRepositoryId = $this->currentNode->subgraphIdentity->contentRepositoryId; - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); + $traversalStartingPoint = $this->getStartingPoint() ?: $this->getCurrentNode(); if (!$traversalStartingPoint instanceof Node) { throw new FusionException( @@ -232,94 +268,59 @@ protected function findMenuStartingPoint(): ?Node 1369596980 ); } + if ($this->getEntryLevel() === 0) { - $entryParentNode = $traversalStartingPoint; + return $traversalStartingPoint->nodeAggregateId; } elseif ($this->getEntryLevel() < 0) { - $expandedNodeTypeCriteria = ExpandedNodeTypeCriteria::create( - $this->getNodeTypeCriteria(), - $contentRepository->getNodeTypeManager() - ); - $remainingIterations = abs($this->getEntryLevel()); - $entryParentNode = null; - $this->traverseUpUntilCondition( - $traversalStartingPoint, - function (Node $node) use ( - &$remainingIterations, - &$entryParentNode, - $expandedNodeTypeCriteria - ) { - if (!$expandedNodeTypeCriteria->matches($node->nodeTypeName)) { - return false; - } - - if ($remainingIterations > 0) { - $remainingIterations--; - - return true; - } else { - $entryParentNode = $node; - - return false; - } - } - ); + $ancestorNodeAggregateIds = $this->getCurrentNodeRootlineAggregateIds(); + $ancestorNodeAggregateIdArray = array_values(iterator_to_array($ancestorNodeAggregateIds)); + return $ancestorNodeAggregateIdArray[$this->getEntryLevel() * -1] ?? null; } else { - $traversedHierarchy = []; - $expandedNodeTypeCriteria = ExpandedNodeTypeCriteria::create( - $this->getNodeTypeCriteria()->withAdditionalDisallowedNodeType( - NodeTypeNameFactory::forSites() - ), - $contentRepository->getNodeTypeManager() - ); - $this->traverseUpUntilCondition( - $traversalStartingPoint, - function (Node $traversedNode) use (&$traversedHierarchy, $expandedNodeTypeCriteria) { - if (!$expandedNodeTypeCriteria->matches($traversedNode->nodeTypeName)) { - return false; - } - $traversedHierarchy[] = $traversedNode; - return true; - } - ); - $traversedHierarchy = array_reverse($traversedHierarchy); - - $entryParentNode = $traversedHierarchy[$this->getEntryLevel() - 1] ?? null; + $ancestorNodeAggregateIds = $this->getCurrentNodeRootlineAggregateIds(); + $ancestorNodeAggregateIdArray = array_reverse(array_values(iterator_to_array($ancestorNodeAggregateIds))); + return $ancestorNodeAggregateIdArray[$this->getEntryLevel() - 1] ?? null; } - - return $entryParentNode; } - protected function getNodeTypeCriteria(): NodeTypeCriteria + protected function getNodeTypeConstraints(): NodeTypeConstraints { - if (!$this->nodeTypeCriteria) { - $this->nodeTypeCriteria = NodeTypeCriteria::fromFilterString($this->getFilter()); + if (!$this->nodeTypeConstraints) { + $this->nodeTypeConstraints = NodeTypeConstraints::fromFilterString($this->getFilter()); } - - return $this->nodeTypeCriteria; + return $this->nodeTypeConstraints; } - /** - * the callback always gets the current Node passed as first parameter, - * and then its parent, and its parent etc etc. - * Until it has reached the root, or the return value of the closure is FALSE. - */ - protected function traverseUpUntilCondition(Node $node, \Closure $callback): void + protected function getCurrentNodeRootlineAggregateIds(): NodeAggregateIds { - $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); - do { - $shouldContinueTraversal = $callback($node); - $node = $subgraph->findParentNode($node->nodeAggregateId); - } while ($shouldContinueTraversal !== false && $node !== null); + if ($this->currentNodeRootlineAggregateIds instanceof NodeAggregateIds) { + return $this->currentNodeRootlineAggregateIds; + } + $subgraph = $this->contentRepositoryRegistry->subgraphForNode($this->getCurrentNode()); + $currentNodeAncestors = $subgraph->findAncestorNodes( + $this->currentNode->nodeAggregateId, + FindAncestorNodesFilter::create( + NodeTypeConstraints::createWithAllowedNodeTypeNames( + NodeTypeNames::with( + NodeTypeNameFactory::forDocument() + ) + ) + ) + ); + + $this->currentNodeRootlineAggregateIds = NodeAggregateIds::create($this->currentNode->nodeAggregateId) + ->merge(NodeAggregateIds::fromNodes($currentNodeAncestors)); + + return $this->currentNodeRootlineAggregateIds; } - protected function buildUri(Node $node): string + protected function calculateItemState(Node $node): MenuItemState { - $this->runtime->pushContextArray([ - 'itemNode' => $node, - 'documentNode' => $node, - ]); - $uri = $this->runtime->render($this->path . '/itemUriRenderer'); - $this->runtime->popContext(); - return $uri; + if ($node->nodeAggregateId->equals($this->getCurrentNode()->nodeAggregateId)) { + return MenuItemState::CURRENT; + } + if ($this->getCurrentNodeRootlineAggregateIds()->contain($node->nodeAggregateId)) { + return MenuItemState::ACTIVE; + } + return MenuItemState::NORMAL; } } diff --git a/Neos.Neos/Classes/Security/ImpersonateAspect.php b/Neos.Neos/Classes/Security/ImpersonateAspect.php index a38b05ff820..78c481acb99 100644 --- a/Neos.Neos/Classes/Security/ImpersonateAspect.php +++ b/Neos.Neos/Classes/Security/ImpersonateAspect.php @@ -34,10 +34,9 @@ class ImpersonateAspect protected bool $alreadyLoggedAuthenticateCall = false; /** - * @var ImpersonateService * @Flow\Inject */ - protected $impersonateService; + protected ImpersonateService $impersonateService; /** * @Flow\After("within(Neos\Flow\Security\Authentication\AuthenticationManagerInterface) && method(.*->authenticate())") @@ -61,8 +60,7 @@ public function logManagerAuthenticate(JoinPointInterface $joinPoint): void return; } - /** @phpstan-ignore-next-line might still be null in strange Flow DI cases */ - if ($this->impersonateService && $this->impersonateService->isActive()) { + if ($this->impersonateService->isActive()) { $impersonation = $this->impersonateService->getImpersonation(); foreach ($proxy->getSecurityContext()->getAuthenticationTokens() as $token) { $token->setAccount($impersonation); diff --git a/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php b/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php index 0dfcea7ee4d..ae7e7af173a 100644 --- a/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php +++ b/Neos.Neos/Classes/Service/EditorContentStreamZookeeper.php @@ -90,7 +90,10 @@ final class EditorContentStreamZookeeper public function relayEditorAuthentication(Authentication\TokenInterface $token): void { $requestHandler = $this->bootstrap->getActiveRequestHandler(); - assert($requestHandler instanceof HttpRequestHandlerInterface); + if (!$requestHandler instanceof HttpRequestHandlerInterface) { + // we might be in testing context + return; + } $siteDetectionResult = SiteDetectionResult::fromRequest($requestHandler->getHttpRequest()); $contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId); diff --git a/Neos.Neos/Classes/ViewHelpers/Rendering/AbstractRenderingStateViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Rendering/AbstractRenderingStateViewHelper.php deleted file mode 100644 index 8fe7291cdad..00000000000 --- a/Neos.Neos/Classes/ViewHelpers/Rendering/AbstractRenderingStateViewHelper.php +++ /dev/null @@ -1,96 +0,0 @@ -contentRepositoryRegistry->get( - $node->subgraphIdentity->contentRepositoryId - ); - return NodeAddressFactory::create($contentRepository)->createFromNode($node); - } - - $baseNode = null; - $view = $this->viewHelperVariableContainer->getView(); - if ($view instanceof FusionAwareViewInterface) { - $fusionObject = $view->getFusionObject(); - $currentContext = $fusionObject->getRuntime()->getCurrentContext(); - if (isset($currentContext['node'])) { - $baseNode = $currentContext['node']; - } - } - if ($baseNode === null) { - throw new ViewHelperException( - 'The ' . get_class($this) . ' needs a Node to determine the state.' - . ' We could not find one in your context so please provide it as "node" argument to the ViewHelper.', - 1427267133 - ); - } - /** @var Node $baseNode */ - $contentRepository = $this->contentRepositoryRegistry->get( - $baseNode->subgraphIdentity->contentRepositoryId - ); - return NodeAddressFactory::create($contentRepository)->createFromNode($baseNode); - } - - - protected function hasAccessToBackend(): bool - { - try { - return $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess'); - } catch (Exception $exception) { - return false; - } - } -} diff --git a/Neos.Neos/Classes/ViewHelpers/Rendering/InBackendViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Rendering/InBackendViewHelper.php index e7565bcdf60..cc56d427269 100644 --- a/Neos.Neos/Classes/ViewHelpers/Rendering/InBackendViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Rendering/InBackendViewHelper.php @@ -14,7 +14,9 @@ namespace Neos\Neos\ViewHelpers\Rendering; -use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; +use Neos\Fusion\ViewHelpers\FusionContextTrait; +use Neos\Neos\Domain\Model\RenderingMode; /** * ViewHelper to find out if Neos is rendering the backend. @@ -37,19 +39,9 @@ * Shown in the backend. * */ -class InBackendViewHelper extends AbstractRenderingStateViewHelper +class InBackendViewHelper extends AbstractViewHelper { - /** - * Initialize the arguments. - * - * @return void - * @throws \Neos\FluidAdaptor\Core\ViewHelper\Exception - */ - public function initializeArguments() - { - parent::initializeArguments(); - $this->registerArgument('node', Node::class, 'Node'); - } + use FusionContextTrait; /** * @return boolean @@ -57,7 +49,10 @@ public function initializeArguments() */ public function render() { - $nodeAddress = $this->getNodeAddressOfContextNode($this->arguments['node']); - return (!$nodeAddress->isInLiveWorkspace() && $this->hasAccessToBackend()); + $renderingMode = $this->getContextVariable('renderingMode'); + if ($renderingMode instanceof RenderingMode) { + return $renderingMode->isEdit || $renderingMode->isPreview; + } + return false; } } diff --git a/Neos.Neos/Classes/ViewHelpers/Rendering/InEditModeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Rendering/InEditModeViewHelper.php index 6d4f9ece5c1..3104fd71919 100644 --- a/Neos.Neos/Classes/ViewHelpers/Rendering/InEditModeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Rendering/InEditModeViewHelper.php @@ -15,6 +15,9 @@ namespace Neos\Neos\ViewHelpers\Rendering; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; +use Neos\Fusion\ViewHelpers\FusionContextTrait; +use Neos\Neos\Domain\Model\RenderingMode; /** * ViewHelper to find out if Neos is rendering an edit mode. @@ -55,8 +58,10 @@ * Shown in all other cases. * */ -class InEditModeViewHelper extends AbstractRenderingStateViewHelper +class InEditModeViewHelper extends AbstractViewHelper { + use FusionContextTrait; + /** * Initialize the arguments. * @@ -66,11 +71,6 @@ class InEditModeViewHelper extends AbstractRenderingStateViewHelper public function initializeArguments() { parent::initializeArguments(); - $this->registerArgument( - 'node', - Node::class, - 'Optional Node to use context from' - ); $this->registerArgument( 'mode', 'string', @@ -84,7 +84,14 @@ public function initializeArguments() */ public function render() { - // TODO: implement + $renderingMode = $this->getContextVariable('renderingMode'); + if ($renderingMode instanceof RenderingMode) { + $mode = $this->arguments['mode']; + if ($mode) { + return $renderingMode->isEdit && $renderingMode->name === $mode; + } + return $renderingMode->isEdit; + } return false; } } diff --git a/Neos.Neos/Classes/ViewHelpers/Rendering/InPreviewModeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Rendering/InPreviewModeViewHelper.php index 480bb4d30f8..831395f256c 100644 --- a/Neos.Neos/Classes/ViewHelpers/Rendering/InPreviewModeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Rendering/InPreviewModeViewHelper.php @@ -15,6 +15,9 @@ namespace Neos\Neos\ViewHelpers\Rendering; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; +use Neos\Fusion\ViewHelpers\FusionContextTrait; +use Neos\Neos\Domain\Model\RenderingMode; /** * ViewHelper to find out if Neos is rendering a preview mode. @@ -55,8 +58,10 @@ * Shown in all other cases. * */ -class InPreviewModeViewHelper extends AbstractRenderingStateViewHelper +class InPreviewModeViewHelper extends AbstractViewHelper { + use FusionContextTrait; + /** * Initialize the arguments. * @@ -66,11 +71,6 @@ class InPreviewModeViewHelper extends AbstractRenderingStateViewHelper public function initializeArguments() { parent::initializeArguments(); - $this->registerArgument( - 'node', - Node::class, - 'Optional Node to use context from' - ); $this->registerArgument( 'mode', 'string', @@ -80,7 +80,14 @@ public function initializeArguments() public function render(Node $node = null, string $mode = null): bool { - // TODO: implement + $renderingMode = $this->getContextVariable('renderingMode'); + if ($renderingMode instanceof RenderingMode) { + $mode = $this->arguments['mode']; + if ($mode) { + return $renderingMode->isPreview && $renderingMode->name === $mode; + } + return $renderingMode->isPreview; + } return false; } } diff --git a/Neos.Neos/Classes/ViewHelpers/Rendering/LiveViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Rendering/LiveViewHelper.php index 597221bd3ad..41e1452fc12 100644 --- a/Neos.Neos/Classes/ViewHelpers/Rendering/LiveViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Rendering/LiveViewHelper.php @@ -15,6 +15,9 @@ namespace Neos\Neos\ViewHelpers\Rendering; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; +use Neos\Fusion\ViewHelpers\FusionContextTrait; +use Neos\Neos\Domain\Model\RenderingMode; /** * ViewHelper to find out if Neos is rendering the live website. @@ -39,27 +42,19 @@ * Shown in the backend. * */ -class LiveViewHelper extends AbstractRenderingStateViewHelper +class LiveViewHelper extends AbstractViewHelper { - /** - * Initialize the arguments. - * - * @return void - * @throws \Neos\FluidAdaptor\Core\ViewHelper\Exception - */ - public function initializeArguments() - { - parent::initializeArguments(); - $this->registerArgument('node', Node::class, 'Node'); - } + use FusionContextTrait; /** * @throws \Neos\FluidAdaptor\Core\ViewHelper\Exception */ public function render(): bool { - $nodeAddress = $this->getNodeAddressOfContextNode($this->arguments['node']); - - return $nodeAddress->isInLiveWorkspace(); + $renderingMode = $this->getContextVariable('renderingMode'); + if ($renderingMode instanceof RenderingMode) { + return $renderingMode->name === RenderingMode::FRONTEND; + } + return true; } } diff --git a/Neos.Neos/Configuration/Objects.yaml b/Neos.Neos/Configuration/Objects.yaml index 6af4b7726b6..fdc548b70fe 100644 --- a/Neos.Neos/Configuration/Objects.yaml +++ b/Neos.Neos/Configuration/Objects.yaml @@ -31,10 +31,6 @@ Neos\Neos\FrontendRouting\Projection\DocumentUriPathFinder: factoryObjectName: 'Doctrine\ORM\EntityManagerInterface' factoryMethodName: 'getConnection' - -Neos\Neos\Domain\Service\NodeSearchServiceInterface: - className: Neos\Neos\Domain\Service\NodeSearchService - Neos\Neos\Service\XliffService: properties: xliffToJsonTranslationsCache: diff --git a/Neos.Neos/Documentation/Appendixes/ChangeLogs/7316.rst b/Neos.Neos/Documentation/Appendixes/ChangeLogs/7316.rst new file mode 100644 index 00000000000..512236f16b2 --- /dev/null +++ b/Neos.Neos/Documentation/Appendixes/ChangeLogs/7316.rst @@ -0,0 +1,175 @@ +`7.3.16 (2023-10-21) `_ +================================================================================================ + +Overview of merged pull requests +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`BUGFIX: Only discard nodes in same workspace `_ +--------------------------------------------------------------------------------------------------------------- + +* Resolves: `#4577 `_ + +* Packages: ``ContentRepository`` + +`BUGFIX: Load all thumbnails for an asset to skip further requests `_ +------------------------------------------------------------------------------------------------------------------------------------ + +For the usecase of images with responsive variants this change prevents additional database requests for each additional variant of an image. + +This can greatly reduce the number of queries on pages with many source tags or sources attributes for pictures and images. + +**Review instructions** + +As soon as an image is rendered in several sizes on a page the patch should skip additional db requests in the thumbnails repository. +Persistent resources and image entities are still queried as via the node property getter and to resolve the thumbnail. + + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Allow unsetting thumbnail presets `_ +------------------------------------------------------------------------------------------------------------ + +* Resolves: `#3544 `_ + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Don’t query for abstract nodetypes in nodedata repository `_ +-------------------------------------------------------------------------------------------------------------------------------------- + +As abstract nodetypes don't (shouldn't) appear in the database it makes no sense to query them. + +This is a regression that was introduced a long time ago, when the default parameter to include abstract nodetypes was added to the ``getSubNodeTypes`` method in the ``NodeTypeManager`` without adjusting the call in the ``NodeDataRepository->getNodeTypeFilterConstraintsForDql`` which relied on the previous behaviour. + +The call in the method ``getNodeTypeFilterConstraints`` was fixed some years ago, but that method seems unused. + +* Packages: ``ContentRepository`` + +`BUGFIX: Consistently initialize asset sources via `createFromConfiguration` `_ +---------------------------------------------------------------------------------------------------------------------------------------------- + +fixes: `#3965 `_ + +**The Problem** + +The case at hand was an asset source that uses a value object to validate the incoming asset source options. I expected to be able to define a promoted constructor property with said value object as its declared type: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + public function __construct( + private readonly string $assetSourceIdentifier, + private readonly Options $options + ) { + } + + /* ... */ +} +``` + +...and initialize the value object in the ``createFromConfiguration`` static factory method defined by the ``AssetSourceInterface``: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + /* ... */ + + public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): AssetSourceInterface + { + return new static( + $assetSourceIdentifier, + Options::fromArray($assetSourceOptions) + ); + } +} +``` + +This failed with a Type Error, because the ``AssetSourceService``, which is responsible for initializing asset sources, at one point does not utilize ``createFromConfiguration`` to perform initialization, but calls the asset source constructor directly: + +https://github.com/neos/neos-development-collection/blob/`a4791b623161259b31d2d11b343310bd7ef76507 `_/Neos.Media/Classes/Domain/Service/AssetSourceService.php#L178 + +**The Solution** + +I adjusted the aforementioned routine of the ``AssetSourceService`` to use the ``AssetSourceInterface``-defined ``createFromConfiguration`` static factory method instead of the asset source's constructor. + +Even though the pattern I described above only makes sense in a PHP >8.0 environment, I decided to target Neos 7.3 with this PR, because it should constitute a non-breaking bugfix. + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Guard that Fusion path cannot be empty `_ +----------------------------------------------------------------------------------------------------------------- + +Previously in php 7.4 this ``Neos\\Fusion\\Exception\\MissingFusionObjectException`` was thrown + +> No Fusion object found in path "" + +but with php 8 this ``ValueError`` is thrown which is unexpected + +> strrpos(): Argument `#3 ``_($offset) must be contained in argument ``#1 `_($haystack) + +This change takes care of throwing an explicit ``Neos\\Fusion\\Exception`` instead: + +> Fusion path cannot be empty. + + +-------- + +This error was noticed in the out of band rendering, when there is no content element wrapping: https://discuss.neos.io/t/argument-3-offset-must-be-contained-in-argument-1-haystack/6416/4 + +image + + + +**Upgrade instructions** + +**Review instructions** + + +* Packages: ``Neos`` ``Fusion`` + +`BUGFIX: Fix `NodeType` `getTypeOfAutoCreatedChildNode` and `getPropertyType` `_ +----------------------------------------------------------------------------------------------------------------------------------------------- + +resolves partially `#4333 `_ +resolves partially `#4344 `_ + +**Upgrade instructions** + +**Review instructions** + + +* Packages: ``Neos`` ``ContentRepository`` + +`TASK: Fix documentation builds `_ +------------------------------------------------------------------------------------------------- + +… by pinning updated dependencies. + +**Review instructions** + +Best is to see if the builds succeed on RTD again with this merged… + + +* Packages: ``Neos`` ``Media`` + +`TASK: Fix paths for Neos.Media RTD rendering setup `_ +--------------------------------------------------------------------------------------------------------------------- + +The paths need to be from the repo root, not relative to the ``.readthedocs.yaml`` file (it seems). + + +* Packages: ``Neos`` ``Media`` + +`TASK: Add configuration files for RTD `_ +-------------------------------------------------------------------------------------------------------- + +This add ``.readthedocs.yaml`` files for the collection (handling ``Neos.Neos``) and for ``neos.Media``, to solve failing documentation rendering. + +**Review instructions** + +This can be compared to the configuration we have in place for ``Neos.Flow`` in the Flow development collection. + + +* Packages: ``Media`` + +`Detailed log `_ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Neos.Neos/Documentation/Appendixes/ChangeLogs/8013.rst b/Neos.Neos/Documentation/Appendixes/ChangeLogs/8013.rst new file mode 100644 index 00000000000..a3f85f1db68 --- /dev/null +++ b/Neos.Neos/Documentation/Appendixes/ChangeLogs/8013.rst @@ -0,0 +1,171 @@ +`8.0.13 (2023-10-21) `_ +================================================================================================ + +Overview of merged pull requests +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`BUGFIX: Only discard nodes in same workspace `_ +--------------------------------------------------------------------------------------------------------------- + +* Resolves: `#4577 `_ + +* Packages: ``ContentRepository`` + +`BUGFIX: Load all thumbnails for an asset to skip further requests `_ +------------------------------------------------------------------------------------------------------------------------------------ + +For the usecase of images with responsive variants this change prevents additional database requests for each additional variant of an image. + +This can greatly reduce the number of queries on pages with many source tags or sources attributes for pictures and images. + +**Review instructions** + +As soon as an image is rendered in several sizes on a page the patch should skip additional db requests in the thumbnails repository. +Persistent resources and image entities are still queried as via the node property getter and to resolve the thumbnail. + + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Allow unsetting thumbnail presets `_ +------------------------------------------------------------------------------------------------------------ + +* Resolves: `#3544 `_ + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Don’t query for abstract nodetypes in nodedata repository `_ +-------------------------------------------------------------------------------------------------------------------------------------- + +As abstract nodetypes don't (shouldn't) appear in the database it makes no sense to query them. + +This is a regression that was introduced a long time ago, when the default parameter to include abstract nodetypes was added to the ``getSubNodeTypes`` method in the ``NodeTypeManager`` without adjusting the call in the ``NodeDataRepository->getNodeTypeFilterConstraintsForDql`` which relied on the previous behaviour. + +The call in the method ``getNodeTypeFilterConstraints`` was fixed some years ago, but that method seems unused. + +* Packages: ``ContentRepository`` + +`BUGFIX: Consistently initialize asset sources via `createFromConfiguration` `_ +---------------------------------------------------------------------------------------------------------------------------------------------- + +fixes: `#3965 `_ + +**The Problem** + +The case at hand was an asset source that uses a value object to validate the incoming asset source options. I expected to be able to define a promoted constructor property with said value object as its declared type: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + public function __construct( + private readonly string $assetSourceIdentifier, + private readonly Options $options + ) { + } + + /* ... */ +} +``` + +...and initialize the value object in the ``createFromConfiguration`` static factory method defined by the ``AssetSourceInterface``: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + /* ... */ + + public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): AssetSourceInterface + { + return new static( + $assetSourceIdentifier, + Options::fromArray($assetSourceOptions) + ); + } +} +``` + +This failed with a Type Error, because the ``AssetSourceService``, which is responsible for initializing asset sources, at one point does not utilize ``createFromConfiguration`` to perform initialization, but calls the asset source constructor directly: + +https://github.com/neos/neos-development-collection/blob/`a4791b623161259b31d2d11b343310bd7ef76507 `_/Neos.Media/Classes/Domain/Service/AssetSourceService.php#L178 + +**The Solution** + +I adjusted the aforementioned routine of the ``AssetSourceService`` to use the ``AssetSourceInterface``-defined ``createFromConfiguration`` static factory method instead of the asset source's constructor. + +Even though the pattern I described above only makes sense in a PHP >8.0 environment, I decided to target Neos 7.3 with this PR, because it should constitute a non-breaking bugfix. + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Guard that Fusion path cannot be empty `_ +----------------------------------------------------------------------------------------------------------------- + +Previously in php 7.4 this ``Neos\\Fusion\\Exception\\MissingFusionObjectException`` was thrown + +> No Fusion object found in path "" + +but with php 8 this ``ValueError`` is thrown which is unexpected + +> strrpos(): Argument `#3 ``_($offset) must be contained in argument ``#1 `_($haystack) + +This change takes care of throwing an explicit ``Neos\\Fusion\\Exception`` instead: + +> Fusion path cannot be empty. + + +-------- + +This error was noticed in the out of band rendering, when there is no content element wrapping: https://discuss.neos.io/t/argument-3-offset-must-be-contained-in-argument-1-haystack/6416/4 + +image + + + +**Upgrade instructions** + + +* Packages: ``Neos`` ``Fusion`` + +`BUGFIX: Fix `NodeType` `getTypeOfAutoCreatedChildNode` and `getPropertyType` `_ +----------------------------------------------------------------------------------------------------------------------------------------------- + +resolves partially `#4333 `_ +resolves partially `#4344 `_ + +**Upgrade instructions** + + +* Packages: ``Neos`` ``ContentRepository`` + +`TASK: Fix documentation builds `_ +------------------------------------------------------------------------------------------------- + +… by pinning updated dependencies. + +**Review instructions** + +Best is to see if the builds succeed on RTD again with this merged… + + +* Packages: ``Neos`` ``Media`` + +`TASK: Fix paths for Neos.Media RTD rendering setup `_ +--------------------------------------------------------------------------------------------------------------------- + +The paths need to be from the repo root, not relative to the ``.readthedocs.yaml`` file (it seems). + + +* Packages: ``Neos`` ``Media`` + +`TASK: Add configuration files for RTD `_ +-------------------------------------------------------------------------------------------------------- + +This add ``.readthedocs.yaml`` files for the collection (handling ``Neos.Neos``) and for ``neos.Media``, to solve failing documentation rendering. + +**Review instructions** + +This can be compared to the configuration we have in place for ``Neos.Flow`` in the Flow development collection. + + +* Packages: ``Media`` + +`Detailed log `_ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Neos.Neos/Documentation/Appendixes/ChangeLogs/818.rst b/Neos.Neos/Documentation/Appendixes/ChangeLogs/818.rst new file mode 100644 index 00000000000..ee60cbb6212 --- /dev/null +++ b/Neos.Neos/Documentation/Appendixes/ChangeLogs/818.rst @@ -0,0 +1,171 @@ +`8.1.8 (2023-10-21) `_ +============================================================================================== + +Overview of merged pull requests +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`BUGFIX: Only discard nodes in same workspace `_ +--------------------------------------------------------------------------------------------------------------- + +* Resolves: `#4577 `_ + +* Packages: ``ContentRepository`` + +`BUGFIX: Load all thumbnails for an asset to skip further requests `_ +------------------------------------------------------------------------------------------------------------------------------------ + +For the usecase of images with responsive variants this change prevents additional database requests for each additional variant of an image. + +This can greatly reduce the number of queries on pages with many source tags or sources attributes for pictures and images. + +**Review instructions** + +As soon as an image is rendered in several sizes on a page the patch should skip additional db requests in the thumbnails repository. +Persistent resources and image entities are still queried as via the node property getter and to resolve the thumbnail. + + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Allow unsetting thumbnail presets `_ +------------------------------------------------------------------------------------------------------------ + +* Resolves: `#3544 `_ + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Don’t query for abstract nodetypes in nodedata repository `_ +-------------------------------------------------------------------------------------------------------------------------------------- + +As abstract nodetypes don't (shouldn't) appear in the database it makes no sense to query them. + +This is a regression that was introduced a long time ago, when the default parameter to include abstract nodetypes was added to the ``getSubNodeTypes`` method in the ``NodeTypeManager`` without adjusting the call in the ``NodeDataRepository->getNodeTypeFilterConstraintsForDql`` which relied on the previous behaviour. + +The call in the method ``getNodeTypeFilterConstraints`` was fixed some years ago, but that method seems unused. + +* Packages: ``ContentRepository`` + +`BUGFIX: Consistently initialize asset sources via `createFromConfiguration` `_ +---------------------------------------------------------------------------------------------------------------------------------------------- + +fixes: `#3965 `_ + +**The Problem** + +The case at hand was an asset source that uses a value object to validate the incoming asset source options. I expected to be able to define a promoted constructor property with said value object as its declared type: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + public function __construct( + private readonly string $assetSourceIdentifier, + private readonly Options $options + ) { + } + + /* ... */ +} +``` + +...and initialize the value object in the ``createFromConfiguration`` static factory method defined by the ``AssetSourceInterface``: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + /* ... */ + + public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): AssetSourceInterface + { + return new static( + $assetSourceIdentifier, + Options::fromArray($assetSourceOptions) + ); + } +} +``` + +This failed with a Type Error, because the ``AssetSourceService``, which is responsible for initializing asset sources, at one point does not utilize ``createFromConfiguration`` to perform initialization, but calls the asset source constructor directly: + +https://github.com/neos/neos-development-collection/blob/`a4791b623161259b31d2d11b343310bd7ef76507 `_/Neos.Media/Classes/Domain/Service/AssetSourceService.php#L178 + +**The Solution** + +I adjusted the aforementioned routine of the ``AssetSourceService`` to use the ``AssetSourceInterface``-defined ``createFromConfiguration`` static factory method instead of the asset source's constructor. + +Even though the pattern I described above only makes sense in a PHP >8.0 environment, I decided to target Neos 7.3 with this PR, because it should constitute a non-breaking bugfix. + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Guard that Fusion path cannot be empty `_ +----------------------------------------------------------------------------------------------------------------- + +Previously in php 7.4 this ``Neos\\Fusion\\Exception\\MissingFusionObjectException`` was thrown + +> No Fusion object found in path "" + +but with php 8 this ``ValueError`` is thrown which is unexpected + +> strrpos(): Argument `#3 ``_($offset) must be contained in argument ``#1 `_($haystack) + +This change takes care of throwing an explicit ``Neos\\Fusion\\Exception`` instead: + +> Fusion path cannot be empty. + + +-------- + +This error was noticed in the out of band rendering, when there is no content element wrapping: https://discuss.neos.io/t/argument-3-offset-must-be-contained-in-argument-1-haystack/6416/4 + +image + + + +**Upgrade instructions** + + +* Packages: ``Neos`` ``Fusion`` + +`BUGFIX: Fix `NodeType` `getTypeOfAutoCreatedChildNode` and `getPropertyType` `_ +----------------------------------------------------------------------------------------------------------------------------------------------- + +resolves partially `#4333 `_ +resolves partially `#4344 `_ + +**Upgrade instructions** + + +* Packages: ``Neos`` ``ContentRepository`` + +`TASK: Fix documentation builds `_ +------------------------------------------------------------------------------------------------- + +… by pinning updated dependencies. + +**Review instructions** + +Best is to see if the builds succeed on RTD again with this merged… + + +* Packages: ``Neos`` ``Media`` + +`TASK: Fix paths for Neos.Media RTD rendering setup `_ +--------------------------------------------------------------------------------------------------------------------- + +The paths need to be from the repo root, not relative to the ``.readthedocs.yaml`` file (it seems). + + +* Packages: ``Neos`` ``Media`` + +`TASK: Add configuration files for RTD `_ +-------------------------------------------------------------------------------------------------------- + +This add ``.readthedocs.yaml`` files for the collection (handling ``Neos.Neos``) and for ``neos.Media``, to solve failing documentation rendering. + +**Review instructions** + +This can be compared to the configuration we have in place for ``Neos.Flow`` in the Flow development collection. + + +* Packages: ``Media`` + +`Detailed log `_ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Neos.Neos/Documentation/Appendixes/ChangeLogs/828.rst b/Neos.Neos/Documentation/Appendixes/ChangeLogs/828.rst new file mode 100644 index 00000000000..7c8c2b227a9 --- /dev/null +++ b/Neos.Neos/Documentation/Appendixes/ChangeLogs/828.rst @@ -0,0 +1,171 @@ +`8.2.8 (2023-10-21) `_ +============================================================================================== + +Overview of merged pull requests +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`BUGFIX: Only discard nodes in same workspace `_ +--------------------------------------------------------------------------------------------------------------- + +* Resolves: `#4577 `_ + +* Packages: ``ContentRepository`` + +`BUGFIX: Load all thumbnails for an asset to skip further requests `_ +------------------------------------------------------------------------------------------------------------------------------------ + +For the usecase of images with responsive variants this change prevents additional database requests for each additional variant of an image. + +This can greatly reduce the number of queries on pages with many source tags or sources attributes for pictures and images. + +**Review instructions** + +As soon as an image is rendered in several sizes on a page the patch should skip additional db requests in the thumbnails repository. +Persistent resources and image entities are still queried as via the node property getter and to resolve the thumbnail. + + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Allow unsetting thumbnail presets `_ +------------------------------------------------------------------------------------------------------------ + +* Resolves: `#3544 `_ + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Don’t query for abstract nodetypes in nodedata repository `_ +-------------------------------------------------------------------------------------------------------------------------------------- + +As abstract nodetypes don't (shouldn't) appear in the database it makes no sense to query them. + +This is a regression that was introduced a long time ago, when the default parameter to include abstract nodetypes was added to the ``getSubNodeTypes`` method in the ``NodeTypeManager`` without adjusting the call in the ``NodeDataRepository->getNodeTypeFilterConstraintsForDql`` which relied on the previous behaviour. + +The call in the method ``getNodeTypeFilterConstraints`` was fixed some years ago, but that method seems unused. + +* Packages: ``ContentRepository`` + +`BUGFIX: Consistently initialize asset sources via `createFromConfiguration` `_ +---------------------------------------------------------------------------------------------------------------------------------------------- + +fixes: `#3965 `_ + +**The Problem** + +The case at hand was an asset source that uses a value object to validate the incoming asset source options. I expected to be able to define a promoted constructor property with said value object as its declared type: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + public function __construct( + private readonly string $assetSourceIdentifier, + private readonly Options $options + ) { + } + + /* ... */ +} +``` + +...and initialize the value object in the ``createFromConfiguration`` static factory method defined by the ``AssetSourceInterface``: + +```php +final class MyAssetSource implements AssetSourceInterface +{ + /* ... */ + + public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): AssetSourceInterface + { + return new static( + $assetSourceIdentifier, + Options::fromArray($assetSourceOptions) + ); + } +} +``` + +This failed with a Type Error, because the ``AssetSourceService``, which is responsible for initializing asset sources, at one point does not utilize ``createFromConfiguration`` to perform initialization, but calls the asset source constructor directly: + +https://github.com/neos/neos-development-collection/blob/`a4791b623161259b31d2d11b343310bd7ef76507 `_/Neos.Media/Classes/Domain/Service/AssetSourceService.php#L178 + +**The Solution** + +I adjusted the aforementioned routine of the ``AssetSourceService`` to use the ``AssetSourceInterface``-defined ``createFromConfiguration`` static factory method instead of the asset source's constructor. + +Even though the pattern I described above only makes sense in a PHP >8.0 environment, I decided to target Neos 7.3 with this PR, because it should constitute a non-breaking bugfix. + +* Packages: ``Neos`` ``Media`` + +`BUGFIX: Guard that Fusion path cannot be empty `_ +----------------------------------------------------------------------------------------------------------------- + +Previously in php 7.4 this ``Neos\\Fusion\\Exception\\MissingFusionObjectException`` was thrown + +> No Fusion object found in path "" + +but with php 8 this ``ValueError`` is thrown which is unexpected + +> strrpos(): Argument `#3 ``_($offset) must be contained in argument ``#1 `_($haystack) + +This change takes care of throwing an explicit ``Neos\\Fusion\\Exception`` instead: + +> Fusion path cannot be empty. + + +-------- + +This error was noticed in the out of band rendering, when there is no content element wrapping: https://discuss.neos.io/t/argument-3-offset-must-be-contained-in-argument-1-haystack/6416/4 + +image + + + +**Upgrade instructions** + + +* Packages: ``Neos`` ``Fusion`` + +`BUGFIX: Fix `NodeType` `getTypeOfAutoCreatedChildNode` and `getPropertyType` `_ +----------------------------------------------------------------------------------------------------------------------------------------------- + +resolves partially `#4333 `_ +resolves partially `#4344 `_ + +**Upgrade instructions** + + +* Packages: ``Neos`` ``ContentRepository`` + +`TASK: Fix documentation builds `_ +------------------------------------------------------------------------------------------------- + +… by pinning updated dependencies. + +**Review instructions** + +Best is to see if the builds succeed on RTD again with this merged… + + +* Packages: ``Neos`` ``Media`` + +`TASK: Fix paths for Neos.Media RTD rendering setup `_ +--------------------------------------------------------------------------------------------------------------------- + +The paths need to be from the repo root, not relative to the ``.readthedocs.yaml`` file (it seems). + + +* Packages: ``Neos`` ``Media`` + +`TASK: Add configuration files for RTD `_ +-------------------------------------------------------------------------------------------------------- + +This add ``.readthedocs.yaml`` files for the collection (handling ``Neos.Neos``) and for ``neos.Media``, to solve failing documentation rendering. + +**Review instructions** + +This can be compared to the configuration we have in place for ``Neos.Flow`` in the Flow development collection. + + +* Packages: ``Media`` + +`Detailed log `_ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Neos.Neos/Documentation/References/NeosFusionReference.rst b/Neos.Neos/Documentation/References/NeosFusionReference.rst index af991b249d7..4a163e6d179 100644 --- a/Neos.Neos/Documentation/References/NeosFusionReference.rst +++ b/Neos.Neos/Documentation/References/NeosFusionReference.rst @@ -474,7 +474,7 @@ Example:: value = ${1+2} } -.. _Neos_Fusion__Tag: +.. _Neos_Fusion__DataStructure: Neos.Fusion:DataStructure @@ -694,7 +694,7 @@ Neos.Fusion:Link.Resource Renders a link pointing to a resource :content: (string) content of the link tag -:href: (string, default :ref:`Neos_Fusion__ResouceUri`) The href for the link tag +:href: (string, default :ref:`Neos_Fusion__ResourceUri`) The href for the link tag :[key]: (string) Other attributes for the link tag Example:: @@ -741,12 +741,10 @@ into rendering a page; responsible for rendering the ```` tag and everythi :head.titleTag: (:ref:`Neos_Fusion__Tag`) The ```` tag :head.javascripts: (:ref:`Neos_Fusion__Join`) Script includes in the head should go here :head.stylesheets: (:ref:`Neos_Fusion__Join`) Link tags for stylesheets in the head should go here -:body.templatePath: (string) Path to a fluid template for the page body :bodyTag: (:ref:`Neos_Fusion__Tag`) The opening ``<body>`` tag :bodyTag.attributes: (:ref:`Neos_Fusion__DataStructure`) Attributes for the ``<body>`` tag -:body: (:ref:`Neos_Fusion__Template`) HTML markup for the ``<body>`` tag +:body: (:ref:`Neos_Fusion__Join`) HTML markup for the ``<body>`` tag. :body.javascripts: (:ref:`Neos_Fusion__Join`) Body footer JavaScript includes -:body.[key]: (mixed) Body template variables Examples: ^^^^^^^^^ @@ -966,73 +964,50 @@ Get argument in controller action:: Neos.Neos:Menu -------------- -Render a menu with items for nodes. Extends :ref:`Neos_Fusion__Template`. - -:templatePath: (string) Override the template path -:entryLevel: (integer) Start the menu at the given depth -:maximumLevels: (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``) -:startingPoint: (Node) The parent node of the first menu level (defaults to ``node`` context variable) -:lastLevel: (integer) Restrict the menu depth by node depth (relative to site node) -:filter: (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'`` -:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` -:itemCollection: (array) Explicitly set the Node items for the menu (alternative to ``startingPoints`` and levels) -:attributes: (:ref:`Neos_Fusion__DataStructure`) Extensible attributes for the whole menu -:normal.attributes: (:ref:`Neos_Fusion__DataStructure`) Attributes for normal state -:active.attributes: (:ref:`Neos_Fusion__DataStructure`) Attributes for active state -:current.attributes: (:ref:`Neos_Fusion__DataStructure`) Attributes for current state - -.. note:: The ``items`` of the ``Menu`` are internally calculated with the prototype :ref:`Neos_Neos__MenuItems` which - you can use directly aswell. - -Menu item properties: -^^^^^^^^^^^^^^^^^^^^^ - -:node: (Node) A node instance (with resolved shortcuts) that should be used to link to the item -:originalNode: (Node) Original node for the item -:state: (string) Menu state of the item: ``'normal'``, ``'current'`` (the current node) or ``'active'`` (ancestor of current node) -:label: (string) Full label of the node -:menuLevel: (integer) Menu level the item is rendered on - -Examples: -^^^^^^^^^ +Render a menu with items for nodes. -Custom menu template: -""""""""""""""""""""" +:attributes: (:ref:`Neos_Fusion__DataStructure`) attributes for the whole menu -:: +The following properties are passed over to :ref:`Neos_Neos__MenuItems` internally: - menu = Neos.Neos:Menu { - entryLevel = 1 - maximumLevels = 3 - templatePath = 'resource://My.Site/Private/Templates/FusionObjects/MyMenu.html' - } - -Menu including site node: -""""""""""""""""""""""""" +:node: (Node) The current node used to calculate the itemStates, and ``startingPoint`` (if not defined explicitly). Defaults to ``node`` from the fusion context +:entryLevel: (integer) Define the startingPoint of the menu relatively. Non negative values specify this as n levels below root. Negative values are n steps up from ``node`` or ``startingPoint`` if defined. Defaults to ``1`` if no ``startingPoint`` is set otherwise ``0`` +:lastLevel: (optional, integer) Restrict the depth of the menu relatively. Positive values specify this as n levels below root. Negative values specify this as n steps up from ``node``. Defaults to ``null`` +:maximumLevels: (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``) +:startingPoint: (optional, Node) The node where the menu hierarchy starts. If not specified explicitly the startingPoint is calculated from (``node`` and ``entryLevel``), defaults to ``null`` +:filter: (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'``. The filter is only used for fetching subItems and is ignored for determining the ``startingPoint`` +:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` +:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false``. +:itemCollection: (optional, array of Nodes) Explicitly set the Node items for the menu (taking precedence over ``startingPoints`` and ``entryLevel`` and ``lastLevel``). The children for each ``Node`` will be fetched taking the ``maximumLevels`` property into account. -:: +Example:: menu = Neos.Neos:Menu { - itemCollection = ${q(site).add(q(site).children('[instanceof Neos.Neos:Document]')).get()} + attributes.class = 'menu' + maximumLevels = 3 } -Menu with custom starting point: -"""""""""""""""""""""""""""""""" - -:: +.. note:: The ``items`` of the ``Menu`` are internally calculated with the prototype :ref:`Neos_Neos__MenuItems` which + you can use directly aswell. - menu = Neos.Neos:Menu { - entryLevel = 2 - maximumLevels = 1 - startingPoint = ${q(site).children('[uriPathSegment="metamenu"]').get(0)} - } +.. note:: The ``rendering`` of the ``Menu`` is performed with the prototype :ref:`Neos_Neos__MenuItemListRenderer`. + If the rendering does not suit your useCase it we recommended to create your own variants of the menu and renderer prototype. .. _Neos_Neos__BreadcrumbMenu: Neos.Neos:BreadcrumbMenu ------------------------ -Render a breadcrumb (ancestor documents), based on :ref:`Neos_Neos__Menu`. +Render a breadcrumb (ancestor documents). + +:attributes: (:ref:`Neos_Fusion__DataStructure`) html attributes for the rendered list + +The following properties are passed over to :ref:`Neos_Neos__BreadcrumbMenuItems` internally: + +:node: (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context +:maximumLevels: (integer) Restrict the maximum depth of items in the menu, defaults to ``0`` +:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. +:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` Example:: @@ -1041,105 +1016,61 @@ Example:: .. note:: The ``items`` of the ``BreadcrumbMenu`` are internally calculated with the prototype :ref:`Neos_Neos__MenuItems` which you can use directly aswell. +.. note:: The ``rendering`` of the ``BreadcrumbMenu`` is performed with the prototype :ref:`Neos_Neos__MenuItemListRenderer`. + If the rendering does not suit your useCase it we recommended to create your own variants of the menu and renderer prototype. + .. _Neos_Neos__DimensionMenu: .. _Neos_Neos__DimensionsMenu: Neos.Neos:DimensionsMenu ------------------------ -Create links to other node variants (e.g. variants of the current node in other dimensions) by using this Fusion object. +Create links to other node variants (e.g. variants of the current node in other dimensions). -If the ``dimension`` setting is given, the menu will only include items for this dimension, with all other configured -dimension being set to the value(s) of the current node. Without any ``dimension`` being configured, all possible -variants will be included. +:attributes: (:ref:`Neos_Fusion__DataStructure`) attributes for the whole menu -If no node variant exists for the preset combination, a ``NULL`` node will be included in the item with a state ``absent``. +The following fusion properties are passed over to :ref:`Neos_Neos__DimensionsMenuItems` internally: +:node: (Node) The current node used to calculate the Menu. Defaults to ``documentNode`` from the fusion context :dimension: (optional, string): name of the dimension which this menu should be based on. Example: "language". :presets: (optional, array): If set, the presets rendered will be taken from this list of preset identifiers :includeAllPresets: (boolean, default **false**) If TRUE, include all presets, not only allowed combinations :renderHiddenInIndex: (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" - -In the template for the menu, each ``item`` has the following properties: - -:node: (Node) A node instance (with resolved shortcuts) that should be used to link to the item -:state: (string) Menu state of the item: ``normal``, ``current`` (the current node), ``absent`` -:label: (string) Label of the item (the dimension preset label) -:menuLevel: (integer) Menu level the item is rendered on -:dimensions: (array) Dimension values of the node, indexed by dimension name -:targetDimensions: (array) The target dimensions, indexed by dimension name and values being arrays with ``value``, ``label`` and ``isPinnedDimension`` - -.. note:: The ``DimensionMenu`` is an alias to ``DimensionsMenu``, available for compatibility reasons only. +:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` .. note:: The ``items`` of the ``DimensionsMenu`` are internally calculated with the prototype :ref:`Neos_Neos__DimensionsMenuItems` which you can use directly aswell. -Examples -^^^^^^^^ - -Minimal Example, outputting a menu with all configured dimension combinations:: - - variantMenu = Neos.Neos:DimensionsMenu - -This example will create two menus, one for the 'language' and one for the 'country' dimension:: - - languageMenu = Neos.Neos:DimensionsMenu { - dimension = 'language' - } - countryMenu = Neos.Neos:DimensionsMenu { - dimension = 'country' - } - -If you only want to render a subset of the available presets or manually define a specific order for a menu, -you can override the "presets":: - - languageMenu = Neos.Neos:DimensionsMenu { - dimension = 'language' - presets = ${['en_US', 'de_DE']} # no matter how many languages are defined, only these two are displayed. - } - -In some cases, it can be good to ignore the availability of variants when rendering a dimensions menu. Consider a -situation with two independent menus for country and language, where the following variants of a node exist -(language / country): +.. note:: The ``rendering`` of the ``DimensionsMenu`` is performed with the prototype :ref:`Neos_Neos__MenuItemListRenderer`. + If the rendering does not suit your useCase it we recommended to create your own variants of the menu and renderer prototype. -- english / Germany -- german / Germany -- english / UK +.. _Neos_Neos__MenuItemListRenderer: -If the user selects UK, only english will be linked in the language selector. German is only available again, if the -user switches back to Germany first. This can be changed by setting the ``includeAllPresets`` option:: +Neos.Neos:MenuItemListRenderer +------------------------------- - languageMenu = Neos.Neos:DimensionsMenu { - dimension = 'language' - includeAllPresets = true - } +A very basic renderer that takes a list of MenuItems and renders the result as unordered list. If item states were calculated +they are applied as classnames to the list items. -Now the language menu will try to find nodes for all languages, if needed the menu items will point to a different -country than currently selected. The menu tries to find a node to link to by using the current preset for the language -(in this example) and the default presets for any other dimensions. So if fallback rules are in place and a node can be -found, it is used. - -.. note:: The ``item.targetDimensions`` will contain the "intended" dimensions, so that information can be used to - inform the user about the potentially unexpected change of dimensions when following such a link. - -Only if the current node is not available at all (even after considering default presets with their fallback rules), -no node be assigned (so no link will be created and the items will have the ``absent`` state.) - -.. _Neos_Neos__MenuItems: +:items: (array): The MenuItems as generated by :ref:`Neos_Neos__MenuItems`, :ref:`Neos_Neos__DimensionsMenuItems`, :ref:`Neos_Neos__BreadcrumbMenuItems` +:attributes: (optional, array): The attributes to apply on the outer list Neos.Neos:MenuItems ------------------- Create a list of menu-items items for nodes. -:entryLevel: (integer) Start the menu at the given depth +:node: (Node) The current node used to calculate the itemStates, and ``startingPoint`` (if not defined explicitly). Defaults to ``node`` from the fusion context +:entryLevel: (integer) Define the startingPoint of the menu relatively. Non negative values specify this as n levels below root. Negative values are n steps up from ``node`` or ``startingPoint`` if defined. Defaults to ``1`` if no ``startingPoint`` is set otherwise ``0`` +:lastLevel: (optional, integer) Restrict the depth of the menu relatively. Positive values specify this as n levels below root. Negative values specify this as n steps up from ``node``. Defaults to ``null`` :maximumLevels: (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``) -:startingPoint: (Node) The parent node of the first menu level (defaults to ``node`` context variable) -:lastLevel: (integer) Restrict the menu depth by node depth (relative to site node) -:filter: (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'`` +:startingPoint: (optional, Node) The node where the menu hierarchy starts. If not specified explicitly the startingPoint is calculated from (``node`` and ``entryLevel``), defaults to ``null`` +:filter: (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'``. The filter is only used for fetching subItems and is ignored for determining the ``startingPoint`` :renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` -:itemCollection: (array) Explicitly set the Node items for the menu (alternative to ``startingPoints`` and levels) -:itemUriRenderer: (:ref:`Neos_Neos__NodeUri`) prototype to use for rendering the URI of each item +:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false``. +:itemCollection: (optional, array of Nodes) Explicitly set the Node items for the menu (taking precedence over ``startingPoints`` and ``entryLevel`` and ``lastLevel``). The children for each ``Node`` will be fetched taking the ``maximumLevels`` property into account. + +Note:: MenuItems item properties: ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1150,6 +1081,7 @@ MenuItems item properties: :label: (string) Full label of the node :menuLevel: (integer) Menu level the item is rendered on :uri: (string) Frontend URI of the node +:children: (array) array of ``MenuItem`` instances Examples: ^^^^^^^^^ @@ -1197,7 +1129,12 @@ Menu with absolute uris: Neos.Neos:BreadcrumbMenuItems ----------------------------- -Create a list of of menu-items for a breadcrumb (ancestor documents), based on :ref:`Neos_Neos__MenuItems`. +Create a list of of menu-items for the breadcrumb (ancestor documents). + +:node: (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context +:maximumLevels: (integer) Restrict the maximum depth of items in the menu, defaults to ``0`` +:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. +:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` Example:: @@ -1220,10 +1157,11 @@ If no node variant exists for the preset combination, a ``NULL`` node will be in :presets: (optional, array): If set, the presets rendered will be taken from this list of preset identifiers :includeAllPresets: (boolean, default **false**) If TRUE, include all presets, not only allowed combinations :renderHiddenInIndex: (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" +:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false`` Each ``item`` has the following properties: -:node: (Node) A node instance (with resolved shortcuts) that should be used to link to the item +:node: (Node) The current node used to calculate the Menu. Defaults to ``documentNode`` from the fusion context :state: (string) Menu state of the item: ``normal``, ``current`` (the current node), ``absent`` :label: (string) Label of the item (the dimension preset label) :menuLevel: (integer) Menu level the item is rendered on @@ -1470,7 +1408,7 @@ Built a URI to a controller action :argumentsToBeExcludedFromQueryString: (array) Query parameters to exclude for ``addQueryString`` :absolute: (boolean) Whether to create an absolute URI -.. note:: The use of ``Neos.Fusion:UriBuilder`` is deprecated. Use :ref:`_Neos_Fusion__ActionUri` instead. +.. note:: The use of ``Neos.Fusion:UriBuilder`` is deprecated. Use :ref:`Neos_Fusion__ActionUri` instead. Example:: @@ -1486,15 +1424,15 @@ Removed Fusion Prototypes The following Fusion Prototypes have been removed: .. _Neos_Fusion__Array: -* `Neos.Fusion:Array` replaced with :ref:`_Neos_Fusion__Join` +* `Neos.Fusion:Array` replaced with :ref:`Neos_Fusion__Join` .. _Neos_Fusion__RawArray: -* `Neos.Fusion:RawArray` replaced with :ref:`_Neos_Fusion__DataStructure` +* `Neos.Fusion:RawArray` replaced with :ref:`Neos_Fusion__DataStructure` .. _Neos_Fusion__Collection: -* `Neos.Fusion:Collection` replaced with :ref:`_Neos_Fusion__Loop` +* `Neos.Fusion:Collection` replaced with :ref:`Neos_Fusion__Loop` .. _Neos_Fusion__RawCollection: -* `Neos.Fusion:RawCollection` replaced with :ref:`_Neos_Fusion__Map` +* `Neos.Fusion:RawCollection` replaced with :ref:`Neos_Fusion__Map` .. _Neos_Fusion__Attributes: -* `Neos.Fusion:Attributes` use property `attributes` in :ref:`_Neos_Fusion__Tag` +* `Neos.Fusion:Attributes` use property `attributes` in :ref:`Neos_Fusion__Tag` diff --git a/Neos.Neos/Documentation/References/ViewHelpers/FluidAdaptor.rst b/Neos.Neos/Documentation/References/ViewHelpers/FluidAdaptor.rst index 73a54d7040a..735234dcc58 100644 --- a/Neos.Neos/Documentation/References/ViewHelpers/FluidAdaptor.rst +++ b/Neos.Neos/Documentation/References/ViewHelpers/FluidAdaptor.rst @@ -2167,9 +2167,9 @@ Examples Header <f:renderChildren arguments="{foo: 'bar'}" /> Footer - + <-- in the outer template, using the widget --> - + <x:widget.someWidget> Foo: {foo} </x:widget.someWidget> diff --git a/Neos.Neos/NodeTypes/Unstructured.yaml b/Neos.Neos/NodeTypes/Unstructured.yaml deleted file mode 100644 index 91b17e7d48e..00000000000 --- a/Neos.Neos/NodeTypes/Unstructured.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# legacy type for nodes without type -'unstructured': - constraints: - nodeTypes: - '*': true diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenu.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenu.fusion index 2e7903596d6..0da25707ac1 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenu.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenu.fusion @@ -1,17 +1,45 @@ # Neos.Neos:BreadcrumbMenu provides a breadcrumb navigation based on menu items. # -prototype(Neos.Neos:BreadcrumbMenu) < prototype(Neos.Neos:Menu) { - templatePath = 'resource://Neos.Neos/Private/Templates/FusionObjects/BreadcrumbMenu.html' - - itemCollection = ${q(documentNode).parents('[instanceof Neos.Neos:Document]').get()} - // Show always the current node, event when it is hidden in index - items.@process.addCurrent = Neos.Fusion:Value { - currentItem = Neos.Neos:MenuItems { - renderHiddenInIndex = true - itemCollection = ${[documentNode]} - } - value = ${Array.concat(this.currentItem, value)} +prototype(Neos.Neos:BreadcrumbMenu) < prototype(Neos.Fusion:Component) { + + # (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context + node = ${documentNode} + + # html attributes for the rendered list + attributes = Neos.Fusion:DataStructure + + # (integer) Restrict the maximum depth of items in the menu, defaults to ``0`` + maximumLevels = 0 + + # (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. + renderHiddenInIndex = true + + # (boolean) activate the *expensive* calculation of item states defaults to ``false`` + calculateItemStates = false + + @private { + items = Neos.Neos:BreadcrumbMenuItems { + node = ${props.node} + maximumLevels = ${props.maximumLevels} + renderHiddenInIndex = ${props.renderHiddenInIndex} + calculateItemStates = ${props.calculateItemStates} + } + } + + renderer = Neos.Neos:MenuItemListRenderer { + items = ${private.items} + attributes = ${props.attributes} } - attributes.class = 'breadcrumb' + @exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\ContextDependentHandler' + + @cache { + mode = 'cached' + entryIdentifier { + documentNode = ${Neos.Caching.entryIdentifierForNode(documentNode)} + } + entryTags { + 1 = ${Neos.Caching.nodeTypeTag('Neos.Neos:Document', documentNode)} + } + } } diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenuItems.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenuItems.fusion index e06d3b8790e..8b128ba4eb8 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenuItems.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/BreadcrumbMenuItems.fusion @@ -1,15 +1,34 @@ -prototype(Neos.Neos:BreadcrumbMenuItems) < prototype(Neos.Neos:MenuItems) { - itemCollection = ${q(documentNode).parents('[instanceof Neos.Neos:Document]').get()} - @process { - // Show always the current node, event when it is hidden in index - addCurrent = Neos.Fusion:Value { - currentItem = Neos.Neos:MenuItems { - renderHiddenInIndex = true - itemCollection = ${[documentNode]} - } - value = ${Array.concat(this.currentItem, value)} - } - - reverseOrder = ${Array.reverse(value)} +prototype(Neos.Neos:BreadcrumbMenuItems) < prototype(Neos.Fusion:Component) { + + # (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context + node = ${documentNode} + + # (integer) Restrict the maximum depth of items in the menu, defaults to ``0`` + maximumLevels = 0 + + # (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``. + renderHiddenInIndex = true + + # (boolean) activate the *expensive* calculation of item states defaults to ``false`` + calculateItemStates = false + + renderer = Neos.Fusion:Value { + parentItems = Neos.Neos:MenuItems { + node = ${props.node} + calculateItemStates = ${props.calculateItemStates} + renderHiddenInIndex = ${props.renderHiddenInIndex} + maximumLevels = ${props.maximumLevels} + itemCollection = ${Array.reverse(q(documentNode).parents('[instanceof Neos.Neos:Document]').get())} + } + + currentItem = Neos.Neos:MenuItems { + node = ${props.node} + calculateItemStates = ${props.calculateItemStates} + renderHiddenInIndex = true + maximumLevels = ${props.maximumLevels} + itemCollection = ${[documentNode]} } + + value = ${Array.concat(this.parentItems, this.currentItem)} + } } diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenu.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenu.fusion index f5ded703887..d5a75fb9ff6 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenu.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenu.fusion @@ -1,34 +1,52 @@ # Neos.Neos:DimensionsMenu provides dimension (e.g. language) menu rendering -prototype(Neos.Neos:DimensionsMenu) < prototype(Neos.Neos:Menu) { - templatePath = 'resource://Neos.Neos/Private/Templates/FusionObjects/DimensionsMenu.html' +prototype(Neos.Neos:DimensionsMenu) < prototype(Neos.Fusion:Component) { + # (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context + node = ${documentNode} - # the "absent" state is assigned to items for dimension (combinations) for which no node variant exists - absent.attributes = Neos.Fusion:DataStructure { - class = 'normal' - } + # html attributes for the rendered list + attributes = Neos.Fusion:DataStructure - # if documents which are hidden in index should be rendered or not + # (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" renderHiddenInIndex = true - # name of the dimension to use (optional) + # (optional, string): name of the dimension which this menu should be based on. Example: "language". dimension = null - # list of presets, if the default order should be overridden, only used with "dimension" set + # (optional, array): If set, the presets rendered will be taken from this list of preset identifiers presets = null - # if true, items for all presets will be included, ignoring dimension constraints + # (boolean, default **false**) If TRUE, include all presets, not only allowed combinations includeAllPresets = false - @context { - dimension = ${this.dimension} - presets = ${this.presets} - includeAllPresets = ${this.includeAllPresets} + # (boolean) activate the *expensive* calculation of item states defaults to ``false`` + calculateItemStates = false + + @private { + items = Neos.Neos:DimensionsMenuItems { + node = ${props.node} + renderHiddenInIndex = ${props.renderHiddenInIndex} + dimension = ${props.dimension} + presets = ${props.presets} + includeAllPresets = ${props.includeAllPresets} + calculateItemStates = ${props.calculateItemStates} + } + } + + renderer = Neos.Neos:MenuItemListRenderer { + items = ${private.items} + attributes = ${props.attributes} } - items = Neos.Neos:DimensionsMenuItems { - includeAllPresets = ${includeAllPresets} - dimension = ${dimension} - presets = ${presets} + @exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\ContextDependentHandler' + + @cache { + mode = 'cached' + entryIdentifier { + documentNode = ${Neos.Caching.entryIdentifierForNode(documentNode)} + } + entryTags { + 1 = ${Neos.Caching.nodeTypeTag('Neos.Neos:Document', documentNode)} + } } } diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenuItems.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenuItems.fusion index 21578fad44d..55629907ada 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenuItems.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/DimensionsMenuItems.fusion @@ -1,15 +1,27 @@ -prototype(Neos.Neos:DimensionsMenuItems) < prototype(Neos.Neos:MenuItems) { - @class = 'Neos\\Neos\\Fusion\\DimensionsMenuItemsImplementation' +prototype(Neos.Neos:DimensionsMenuItems) { + @class = 'Neos\\Neos\\Fusion\\DimensionsMenuItemsImplementation' - # if documents which are hidden in index should be rendered or not + # (Node) The current node. Defaults to ``node`` from the fusion context + node = ${documentNode} + + # (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index" renderHiddenInIndex = true - # name of the dimension to use (optional) + # (optional, string): name of the dimension which this menu should be based on. Example: "language". dimension = null - # list of presets, if the default order should be overridden, only used with "dimension" set + # (optional, array): If set, the presets rendered will be taken from this list of preset identifiers presets = null - # if true, items for all presets will be included, ignoring dimension constraints + # (boolean, default **false**) If TRUE, include all presets, not only allowed combinations includeAllPresets = false + + # (boolean) activate the *expensive* calculation of item states defaults to ``false`` + calculateItemStates = false + + // This property is used internally by `MenuItemsImplementation` to render each items uri. + // It can be modified to change behaviour for all rendered uris. + itemUriRenderer = Neos.Neos:NodeUri { + node = ${itemNode} + } } diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/Menu.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/Menu.fusion index 570b9af36d0..c435eb45e3c 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/Menu.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/Menu.fusion @@ -1,48 +1,54 @@ # Neos.Neos:Menu provides basic menu rendering # -prototype(Neos.Neos:Menu) < prototype(Neos.Fusion:Template) { - templatePath = 'resource://Neos.Neos/Private/Templates/FusionObjects/Menu.html' +prototype(Neos.Neos:Menu) < prototype(Neos.Fusion:Component) { + # html attributes for the rendered list + attributes = Neos.Fusion:DataStructure + + # (Node) The current node used to calculate the itemStates, and ``startingPoint`` (if not defined explicitly). Defaults to ``documentNode`` from the fusion context + node = ${documentNode} + # (integer) Define the startingPoint of the menu relatively. Non negative values specify this as n levels below root. Negative values are n steps up from ``node`` or ``startingPoint`` if defined. Defaults to ``1`` if no ``startingPoint`` is set otherwise ``0`` entryLevel = ${this.startingPoint ? 0 : 1} + + # (optional, integer) Restrict the depth of the menu relatively. Positive values specify this as n levels below root. Negative values specify this as n steps up from ``node``. Defaults to ``null`` + lastLevel = null + + # (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``) maximumLevels = 2 + + # (optional, Node) The node where the menu hierarchy starts. If not specified explicitly the startingPoint is calculated from (``node`` and ``entryLevel``), defaults to ``null`` startingPoint = null - lastLevel = null + + # (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'``. The filter is only used for fetching subItems and is ignored for determining the ``startingPoint`` filter = 'Neos.Neos:Document' + + # (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` renderHiddenInIndex = false - itemCollection = null - node = ${node} + # (boolean) activate the *expensive* calculation of item states defaults to ``false``. + calculateItemStates = false - attributes = Neos.Fusion:DataStructure + # (optional, array of Nodes) Explicitly set the Node items for the menu (taking precedence over ``startingPoints`` and ``entryLevel`` and ``lastLevel``). The children for each ``Node`` will be fetched taking the ``maximumLevels`` property into account. + itemCollection = null - active.attributes = Neos.Fusion:DataStructure { - class = 'active' - } - current.attributes = Neos.Fusion:DataStructure { - class = 'current' - } - normal.attributes = Neos.Fusion:DataStructure { - class = 'normal' - } - @context { - entryLevel = ${this.entryLevel} - maximumLevels = ${this.maximumLevels} - startingPoint = ${this.startingPoint} - lastLevel = ${this.lastLevel} - filter = ${this.filter} - renderHiddenInIndex = ${this.renderHiddenInIndex} - itemCollection = ${this.itemCollection} + @private { + items = Neos.Neos:MenuItems { + node = ${props.node} + entryLevel = ${props.entryLevel} + lastLevel = ${props.lastLevel} + maximumLevels = ${props.maximumLevels} + startingPoint = ${props.startingPoint} + filter = ${props.filter} + renderHiddenInIndex = ${props.renderHiddenInIndex} + calculateItemStates = ${props.calculateItemStates} + itemCollection = ${props.itemCollection} + } } - items = Neos.Neos:MenuItems { - entryLevel = ${entryLevel} - maximumLevels = ${maximumLevels} - startingPoint = ${startingPoint} - lastLevel = ${lastLevel} - filter = ${filter} - renderHiddenInIndex = ${renderHiddenInIndex} - itemCollection = ${itemCollection} + renderer = Neos.Neos:MenuItemListRenderer { + items = ${private.items} + attributes = ${props.attributes} } @exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\ContextDependentHandler' diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItemListRenderer.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItemListRenderer.fusion new file mode 100644 index 00000000000..54203902617 --- /dev/null +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItemListRenderer.fusion @@ -0,0 +1,17 @@ +# Neos.Neos:MenuItemListRenderer provides basic menu rendering +# +prototype(Neos.Neos:MenuItemListRenderer) < prototype(Neos.Fusion:Component) { + items = null + attributes = Neos.Fusion:DataStructure + + renderer = afx` + <ul {...props.attributes}> + <Neos.Fusion:Loop items={props.items} itemName="item"> + <li class={item.state}> + <Neos.Fusion:Tag tagName={item.uri ? 'a' : 'span'} attributes.href={item.uri} attributes.title={item.label}>{item.label}</Neos.Fusion:Tag> + <Neos.Neos:MenuItemListRenderer @if={item.children} items={item.children} /> + </li> + </Neos.Fusion:Loop> + </ul> + ` +} diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItems.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItems.fusion index 01dbeb06484..edf6bc37c60 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItems.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItems.fusion @@ -1,13 +1,31 @@ prototype(Neos.Neos:MenuItems) { @class = 'Neos\\Neos\\Fusion\\MenuItemsImplementation' - node = ${node} + # (Node) The current node used to calculate the itemStates, and ``startingPoint`` (if not defined explicitly). Defaults to ``documentNode`` from the fusion context + node = ${documentNode} + + # (integer) Define the startingPoint of the menu relatively. Non negative values specify this as n levels below root. Negative values are n steps up from ``node`` or ``startingPoint`` if defined. Defaults to ``1`` if no ``startingPoint`` is set otherwise ``0`` entryLevel = ${this.startingPoint ? 0 : 1} + + # (optional, integer) Restrict the depth of the menu relatively. Positive values specify this as n levels below root. Negative values specify this as n steps up from ``node``. Defaults to ``null`` + lastLevel = null + + # (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``) maximumLevels = 2 + + # (optional, Node) The node where the menu hierarchy starts. If not specified explicitly the startingPoint is calculated from (``node`` and ``entryLevel``), defaults to ``null`` startingPoint = null - lastLevel = null + + # (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'``. The filter is only used for fetching subItems and is ignored for determining the ``startingPoint`` filter = 'Neos.Neos:Document' + + # (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false`` renderHiddenInIndex = false + + # (boolean) activate the *expensive* calculation of item states defaults to ``false``. + calculateItemStates = false + + # (optional, array of Nodes) Explicitly set the Node items for the menu (taking precedence over ``startingPoints`` and ``entryLevel`` and ``lastLevel``). The children for each ``Node`` will be fetched taking the ``maximumLevels`` property into account. itemCollection = null // This property is used internally by `MenuItemsImplementation` to render each items uri. diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/Page.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/Page.fusion index b0cdf9685c0..b60602bcf73 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/Page.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/Page.fusion @@ -68,15 +68,12 @@ prototype(Neos.Neos:Page) < prototype(Neos.Fusion:Http.Message) { } # Content of the body tag. To be defined by the integrator. - body = Neos.Fusion:Template { + body = Neos.Fusion:Join { @position = 'after bodyTag' - node = ${node} - site = ${site} - # Script includes before the closing body tag should go here + # Scripts before the closing body tag javascripts = Neos.Fusion:Join - # This processor appends the rendered javascripts Array to the rendered template - @process.appendJavaScripts = ${value + this.javascripts} + javascripts.@position = 'end 100' } closingBodyTag = '</body>' diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/Shortcut.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/Shortcut.fusion index 0039b2efbd1..7ffe67d67e5 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/Shortcut.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/Shortcut.fusion @@ -1,15 +1,96 @@ # Neos.Neos.Shortcut is given a representation for editing purposes # -prototype(Neos.Neos:Shortcut) < prototype(Neos.Fusion:Template) { - templatePath = 'resource://Neos.Neos/Private/Templates/FusionObjects/Shortcut.html' +prototype(Neos.Neos:Shortcut) < prototype(Neos.Neos:Page) { + head.stylesheets { + shortcut = afx` + <link rel="stylesheet" href={StaticResource.uri('Neos.Neos', 'Public/Styles/Shortcut.css')} /> + ` + } + body = afx` + <div id="neos-shortcut"> + <p> + <Neos.Neos:Shortcut.Link /> + </p> + </div> + ` +} + +/** @internal */ +prototype(Neos.Neos:Shortcut.Link) < prototype(Neos.Fusion:Component) { targetMode = ${q(node).property('targetMode')} firstChildNode = ${q(node).children('[instanceof Neos.Neos:Document]').get(0)} target = ${q(node).property('target')} targetConverted = ${Neos.Link.hasSupportedScheme(this.target) ? Neos.Link.convertUriToObject(this.target, node) : null} targetSchema = ${Neos.Link.getScheme(this.target)} - node = ${node} + i18n = ${I18n.id(null).package('Neos.Neos').source('Main').locale(Neos.Backend.interfaceLanguage())} + + renderer = Neos.Fusion:Match { + @subject = ${props.targetMode} + + selectedTarget = Neos.Fusion:Join { + @glue = '<br/>' + mainMessage = ${props.i18n.id('shortcut.toSpecificTarget').translate()} + targetSelected = Neos.Fusion:Match { + @if.isTarget = ${props.target} + + @subject = ${props.targetSchema} + + node = Neos.Fusion:Value { + targetUriTag = Neos.Neos:NodeLink { + node = ${props.targetConverted} + } + value = ${props.i18n.id('shortcut.clickToContinueToPage').arguments([this.targetUriTag]).translate()} + } + + asset = Neos.Fusion:Value { + targetUriTag = Neos.Fusion:Tag { + tagName = 'a' + attributes { + target = '_blank' + href = Neos.Fusion:ResourceUri { + resource = ${props.targetConverted.resource} + } + } + content = ${props.targetConverted.label} + } + value = ${props.i18n.id('shortcut.clickToContinueToAsset').arguments([this.targetUriTag]).translate()} + } + + @default = Neos.Fusion:Value { + targetUriTag = afx` + <a href={props.target} target='_blank'>{props.target}</a> + ` + value = ${props.i18n.id('shortcut.clickToContinueToExternalUrl').arguments([this.targetUriTag]).translate()} + } + } + + noTargetSelected = ${props.i18n.id('shortcut.noTargetSelected').translate()} + noTargetSelected.@if.isNotTarget = ${!props.target} + } + + firstChildNode = Neos.Fusion:Value { + targetUriTag = Neos.Neos:NodeLink { + node = ${props.firstChildNode} + } + value = ${props.i18n.id('shortcut.clickToContinueToFirstChildNode').arguments([this.targetUriTag]).translate()} + } + + parentNode = Neos.Fusion:Value { + targetUriTag = Neos.Neos:NodeLink { + node = ${q(node).parent().get(0)} + } + value = ${props.i18n.id('shortcut.clickToContinueToParentNode').arguments([this.targetUriTag]).translate()} + } + } + + @cache { + mode = "uncached" + context { + 0 = "node" + } + } @exceptionHandler = 'Neos\\Neos\\Fusion\\ExceptionHandlers\\NodeWrappingHandler' } diff --git a/Neos.Neos/Resources/Private/Fusion/RootCase.fusion b/Neos.Neos/Resources/Private/Fusion/RootCase.fusion index ea6596c38e7..7a7f304c411 100644 --- a/Neos.Neos/Resources/Private/Fusion/RootCase.fusion +++ b/Neos.Neos/Resources/Private/Fusion/RootCase.fusion @@ -6,13 +6,11 @@ root = Neos.Fusion:Case root { shortcut { - prototype(Neos.Neos:Page) { - body = Neos.Neos:Shortcut - } - + # this code path will only be taken for backend views, as the node controller + # will take care of resolving the shortcut in the frontend @position = 'start' condition = ${q(node).is('[instanceof Neos.Neos:Shortcut]')} - type = 'Neos.Neos:Page' + renderer = Neos.Neos:Shortcut } editPreviewMode { diff --git a/Neos.Neos/Resources/Private/Styles/Neos.scss b/Neos.Neos/Resources/Private/Styles/Main.scss similarity index 100% rename from Neos.Neos/Resources/Private/Styles/Neos.scss rename to Neos.Neos/Resources/Private/Styles/Main.scss diff --git a/Neos.Neos/Resources/Private/Styles/Shortcut.scss b/Neos.Neos/Resources/Private/Styles/Shortcut.scss new file mode 100644 index 00000000000..5a80bb6f8bb --- /dev/null +++ b/Neos.Neos/Resources/Private/Styles/Shortcut.scss @@ -0,0 +1,32 @@ +#neos-shortcut { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: $grayMedium; + z-index: 9999; + @include font; + + p { + position: relative; + margin: 0 auto; + width: 500px; + height: 60px; + top: 50%; + margin-top: -30px; + color: #fff; + font-size: 22px; + line-height: 1.4; + text-align: center; + + a { + color: $blue; + text-decoration: none; + + &:hover { + color: $blueLight; + } + } + } +} diff --git a/Neos.Neos/Resources/Private/Styles/_Global.scss b/Neos.Neos/Resources/Private/Styles/_Global.scss index 76d8bea161c..b44a7102229 100644 --- a/Neos.Neos/Resources/Private/Styles/_Global.scss +++ b/Neos.Neos/Resources/Private/Styles/_Global.scss @@ -5,36 +5,3 @@ .neos-rendering-exception { word-wrap: break-word; } - -#neos-shortcut { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: $grayMedium; - z-index: 9999; - @include font; - - p { - position: relative; - margin: 0 auto; - width: 500px; - height: 60px; - top: 50%; - margin-top: -30px; - color: #fff; - font-size: 22px; - line-height: 1.4; - text-align: center; - - a { - color: $blue; - text-decoration: none; - - &:hover { - color: $blueLight; - } - } - } -} diff --git a/Neos.Neos/Resources/Private/Templates/FusionObjects/BreadcrumbMenu.html b/Neos.Neos/Resources/Private/Templates/FusionObjects/BreadcrumbMenu.html deleted file mode 100644 index f96b3e7c63c..00000000000 --- a/Neos.Neos/Resources/Private/Templates/FusionObjects/BreadcrumbMenu.html +++ /dev/null @@ -1,18 +0,0 @@ -{namespace neos=Neos\Neos\ViewHelpers} -{namespace ts=Neos\Fusion\ViewHelpers} -<f:if condition="{items}"> - <ul{attributes -> f:format.raw()}> - <f:for each="{items}" as="item" reverse="TRUE"> - <li{ts:render(path: '{item.state}.attributes', context: {item: item}) -> f:format.raw()}> - <f:if condition="{item.state} === 'current'"> - <f:then> - {item.label} - </f:then> - <f:else> - <a href="{item.uri}" title="{item.label}">{item.label}</a> - </f:else> - </f:if> - </li> - </f:for> - </ul> -</f:if> diff --git a/Neos.Neos/Resources/Private/Templates/FusionObjects/DimensionsMenu.html b/Neos.Neos/Resources/Private/Templates/FusionObjects/DimensionsMenu.html deleted file mode 100644 index 4b646319db0..00000000000 --- a/Neos.Neos/Resources/Private/Templates/FusionObjects/DimensionsMenu.html +++ /dev/null @@ -1,22 +0,0 @@ -{namespace neos=Neos\Neos\ViewHelpers} -{namespace ts=Neos\Fusion\ViewHelpers} -<ul{attributes -> f:format.raw()}> -<f:for each="{items}" as="item"> - <li{ts:render(path: '{item.state}.attributes', context: {item: item}) -> f:format.raw()}> - <f:if condition="{item.node}"> - <f:then> - <neos:link.node node="{item.node}"> - <f:render section="itemLabel" arguments="{item:item}"/> - </neos:link.node> - </f:then> - <f:else> - <f:render section="itemLabel" arguments="{item:item}"/> - </f:else> - </f:if> - </li> -</f:for> -</ul> - -<f:section name="itemLabel"> - {item.label} -</f:section> diff --git a/Neos.Neos/Resources/Private/Templates/FusionObjects/Menu.html b/Neos.Neos/Resources/Private/Templates/FusionObjects/Menu.html deleted file mode 100644 index 27f33b88ebe..00000000000 --- a/Neos.Neos/Resources/Private/Templates/FusionObjects/Menu.html +++ /dev/null @@ -1,18 +0,0 @@ -{namespace neos=Neos\Neos\ViewHelpers} -{namespace ts=Neos\Fusion\ViewHelpers} -<ul{attributes -> f:format.raw()}> - <f:render section="itemsList" arguments="{items: items}" /> -</ul> - -<f:section name="itemsList"> - <f:for each="{items}" as="item"> - <li{ts:render(path: '{item.state}.attributes', context: {item: item}) -> f:format.raw()}> - <a href="{item.uri}" title="{item.label}">{item.label}</a> - <f:if condition="{item.subItems}"> - <ul> - <f:render section="itemsList" arguments="{items: item.subItems}" /> - </ul> - </f:if> - </li> - </f:for> -</f:section> diff --git a/Neos.Neos/Resources/Private/Templates/FusionObjects/Shortcut.html b/Neos.Neos/Resources/Private/Templates/FusionObjects/Shortcut.html deleted file mode 100644 index 6fa8120681a..00000000000 --- a/Neos.Neos/Resources/Private/Templates/FusionObjects/Shortcut.html +++ /dev/null @@ -1,44 +0,0 @@ -{namespace neos=Neos\Neos\ViewHelpers} -<div id="neos-shortcut"> - <p> - <f:switch expression="{targetMode}"> - <f:case value="selectedTarget"> - {neos:backend.translate(id: 'shortcut.toSpecificTarget', value: 'This is a shortcut to a specific target:')}<br /> - <f:if condition="{target}"> - <f:then> - <f:switch expression="{targetSchema}"> - <f:case value="node"> - <f:format.raw><neos:backend.translate id="shortcut.clickToContinueToPage" arguments="{0: '{neos:link.node(node: targetConverted)}'}"> - Click <neos:link.node node="{targetConverted}" /> to continue to the page. - </neos:backend.translate></f:format.raw> - </f:case> - <f:case value="asset"> - <f:format.raw><neos:backend.translate id="shortcut.clickToContinueToAsset" arguments="{0: '<a href=\"{f:uri.resource(resource: targetConverted.resource)}\" target=\"_blank\">{targetConverted.label}</a>'}"> - Click <a href="{f:uri.resource(resource: targetConverted.resource)}" target="_blank">{targetConverted.label}</a> to see the file. - </neos:backend.translate></f:format.raw> - </f:case> - <f:defaultCase> - <f:format.raw><neos:backend.translate id="shortcut.clickToContinueToExternalUrl" arguments="{0: '<a href=\"{target}\" target=\"_blank\">{target}</a>'}"> - Click <a href="{target}" target="_blank">{target}</a> to open the link. - </neos:backend.translate></f:format.raw> - </f:defaultCase> - </f:switch> - </f:then> - <f:else>{neos:backend.translate(id: 'shortcut.noTargetSelected', value: '(no target has been selected)')}</f:else> - </f:if> - </f:case> - <f:case value="firstChildNode"> - <f:format.raw><neos:backend.translate id="shortcut.clickToContinueToFirstChildNode" arguments="{0: '{neos:link.node(node: firstChildNode)}'}"> - This is a shortcut to the first child page.<br /> - Click <neos:link.node node="{firstChildNode}" /> to continue to the page. - </neos:backend.translate></f:format.raw> - </f:case> - <f:case value="parentNode"> - <f:format.raw><neos:backend.translate id="shortcut.clickToContinueToParentNode" arguments="{0: '{neos:link.node(node: node.parent)}'}"> - This is a shortcut to the parent page.<br /> - Click <neos:link.node node="{node.parent}" /> to continue to the page. - </neos:backend.translate></f:format.raw> - </f:case> - </f:switch> - </p> -</div> diff --git a/Neos.Neos/Resources/Public/Styles/Shortcut.css b/Neos.Neos/Resources/Public/Styles/Shortcut.css new file mode 100644 index 00000000000..4b7c4b242cf --- /dev/null +++ b/Neos.Neos/Resources/Public/Styles/Shortcut.css @@ -0,0 +1 @@ +#neos-shortcut {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: #323232;z-index: 9999;font-family: "Noto Sans", sans-serif;-webkit-font-smoothing: antialiased;}#neos-shortcut p {position: relative;margin: 0 auto;width: 500px;height: 60px;top: 50%;margin-top: -30px;color: #fff;font-size: 22px;line-height: 1.4;text-align: center;}#neos-shortcut p a {color: #00b5ff;text-decoration: none;}#neos-shortcut p a:hover {color: #39c6ff;} diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/BrowserTrait.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/BrowserTrait.php index 1d28e3260b0..030bde9ea19 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/BrowserTrait.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/BrowserTrait.php @@ -34,14 +34,17 @@ trait BrowserTrait use CRTestSuiteRuntimeVariables; /** - * @return \Neos\Flow\ObjectManagement\ObjectManagerInterface + * @var \Neos\Flow\Http\Client\Browser */ - abstract protected function getObjectManager(); + protected $browser; /** - * @var \Neos\Flow\Http\Client\Browser + * @template T of object + * @param class-string<T> $className + * + * @return T */ - protected $browser; + abstract private function getObject(string $className): object; /** * @BeforeScenario @@ -50,11 +53,11 @@ public function setupBrowserForEveryScenario() { // we reset the security context at the beginning of every scenario; such that we start with a clean session at // every scenario and SHARE the session throughout the scenario! - $this->getObjectManager()->get(\Neos\Flow\Security\Context::class)->clearContext(); + $this->getObject(\Neos\Flow\Security\Context::class)->clearContext(); $this->browser = new \Neos\Flow\Http\Client\Browser(); $this->browser->setRequestEngine(new \Neos\Neos\Testing\CustomizedInternalRequestEngine()); - $bootstrap = $this->getObjectManager()->get(\Neos\Flow\Core\Bootstrap::class); + $bootstrap = $this->getObject(\Neos\Flow\Core\Bootstrap::class); $requestHandler = new \Neos\Flow\Tests\FunctionalTestRequestHandler($bootstrap); $serverRequestFactory = new ServerRequestFactory(new UriFactory()); @@ -229,7 +232,7 @@ protected function replacePlaceholders($nodeAddressString) */ public function iSendTheFollowingChanges(TableNode $changeDefinition) { - $this->getObjectManager()->get(\Neos\Neos\Ui\Domain\Model\FeedbackCollection::class)->reset(); + $this->getObject(\Neos\Neos\Ui\Domain\Model\FeedbackCollection::class)->reset(); $changes = []; foreach ($changeDefinition->getHash() as $singleChange) { @@ -244,7 +247,7 @@ public function iSendTheFollowingChanges(TableNode $changeDefinition) } $server = [ - 'HTTP_X_FLOW_CSRFTOKEN' => $this->getObjectManager()->get(\Neos\Flow\Security\Context::class)->getCsrfProtectionToken(), + 'HTTP_X_FLOW_CSRFTOKEN' => $this->getObject(\Neos\Flow\Security\Context::class)->getCsrfProtectionToken(), ]; $this->currentResponse = $this->browser->request('http://localhost/neos/ui-services/change', 'POST', ['changes' => $changes], [], $server); $this->currentResponseContents = $this->currentResponse->getBody()->getContents(); @@ -257,7 +260,7 @@ public function iSendTheFollowingChanges(TableNode $changeDefinition) */ public function iPublishTheFollowingNodes(string $targetWorkspaceName, TableNode $nodesToPublish) { - $this->getObjectManager()->get(\Neos\Neos\Ui\Domain\Model\FeedbackCollection::class)->reset(); + $this->getObject(\Neos\Neos\Ui\Domain\Model\FeedbackCollection::class)->reset(); $nodeContextPaths = []; foreach ($nodesToPublish->getHash() as $singleChange) { @@ -265,7 +268,7 @@ public function iPublishTheFollowingNodes(string $targetWorkspaceName, TableNode } $server = [ - 'HTTP_X_FLOW_CSRFTOKEN' => $this->getObjectManager()->get(\Neos\Flow\Security\Context::class)->getCsrfProtectionToken(), + 'HTTP_X_FLOW_CSRFTOKEN' => $this->getObject(\Neos\Flow\Security\Context::class)->getCsrfProtectionToken(), ]; $payload = [ 'nodeContextPaths' => $nodeContextPaths, diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php index 733c0ee5373..49bb60e0909 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -12,7 +12,8 @@ use Behat\Behat\Context\Context as BehatContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; -use Neos\Behat\Tests\Behat\FlowContextTrait; +use Neos\Behat\FlowBootstrapTrait; +use Neos\Behat\FlowEntitiesTrait; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; @@ -24,19 +25,18 @@ use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\MigrationsTrait; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Utility\Environment; -use Neos\Utility\Files; - -require_once(__DIR__ . '/../../../../../../Application/Neos.Behat/Tests/Behat/FlowContextTrait.php'); class FeatureContext implements BehatContext { - use FlowContextTrait; + use FlowBootstrapTrait; + use FlowEntitiesTrait; use BrowserTrait; use CRTestSuiteTrait; use CRBehavioralTestsSubjectProvider; use RoutingTrait; use MigrationsTrait; + use FusionTrait; protected Environment $environment; @@ -44,12 +44,9 @@ class FeatureContext implements BehatContext public function __construct() { - if (self::$bootstrap === null) { - self::$bootstrap = $this->initializeFlow(); - } - $this->objectManager = self::$bootstrap->getObjectManager(); - $this->environment = $this->objectManager->get(Environment::class); - $this->contentRepositoryRegistry = $this->objectManager->get(ContentRepositoryRegistry::class); + self::bootstrapFlow(); + $this->environment = $this->getObject(Environment::class); + $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); $this->setupCRTestSuiteTrait(true); } @@ -71,13 +68,13 @@ public function resetPersistenceManagerAndFeedbackCollection() // FIXME: we have some strange race condition between the scenarios; my theory is that // somehow projectors still run in the background when we start from scratch... sleep(2); - $this->getObjectManager()->get(\Neos\Flow\Persistence\PersistenceManagerInterface::class)->clearState(); + $this->getObject(\Neos\Flow\Persistence\PersistenceManagerInterface::class)->clearState(); // FIXME: FeedbackCollection is a really ugly, hacky SINGLETON; so it needs to be RESET! - $this->getObjectManager()->get(\Neos\Neos\Ui\Domain\Model\FeedbackCollection::class)->reset(); + $this->getObject(\Neos\Neos\Ui\Domain\Model\FeedbackCollection::class)->reset(); // The UserService has a runtime cache - which we need to reset as well as our users get new IDs. // Did I already mention I LOVE in memory caches? ;-) ;-) ;-) - $userService = $this->getObjectManager()->get(\Neos\Neos\Domain\Service\UserService::class); + $userService = $this->getObject(\Neos\Neos\Domain\Service\UserService::class); \Neos\Utility\ObjectAccess::setProperty($userService, 'runtimeUserCache', [], true); } diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/FusionTrait.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FusionTrait.php new file mode 100644 index 00000000000..c883c4d76ca --- /dev/null +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FusionTrait.php @@ -0,0 +1,196 @@ +<?php +declare(strict_types=1); + +/* + * This file is part of the Neos.ContentRepository package. + * + * (c) Contributors of the Neos Project - www.neos.io + * + * This package is Open Source Software. For the full copyright and license + * information, please view the LICENSE file which was distributed with this + * source code. + */ + +use Behat\Gherkin\Node\PyStringNode; +use Behat\Gherkin\Node\TableNode; +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteRuntimeVariables; +use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\ProjectedNodeTrait; +use Neos\Flow\Mvc\ActionRequest; +use Neos\Flow\Tests\FunctionalTestRequestHandler; +use Neos\Fusion\Core\ExceptionHandlers\ThrowingHandler; +use Neos\Fusion\Core\FusionGlobals; +use Neos\Fusion\Core\FusionSourceCodeCollection; +use Neos\Fusion\Core\Parser; +use Neos\Fusion\Core\RuntimeFactory; +use Neos\Neos\Domain\Model\RenderingMode; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; +use Neos\Fusion\Exception\RuntimeException; +use PHPUnit\Framework\Assert; +use Psr\Http\Message\ServerRequestFactoryInterface; + +/** + * @internal only for behat tests within the Neos.Neos package + */ +trait FusionTrait +{ + use RoutingTrait; + use ProjectedNodeTrait; + use CRTestSuiteRuntimeVariables; + + private array $fusionGlobalContext = []; + private array $fusionContext = []; + + private ?string $renderingResult = null; + + private ?string $fusionCode = null; + + private ?\Throwable $lastRenderingException = null; + + /** + * @template T of object + * @param class-string<T> $className + * + * @return T + */ + abstract private function getObject(string $className): object; + + /** + * @BeforeScenario + */ + public function setupFusionContext(): void + { + $this->fusionGlobalContext = []; + $this->fusionContext = []; + $this->fusionCode = null; + $this->renderingResult = null; + } + + /** + * @When I am in Fusion rendering mode: + */ + public function iAmInFusionRenderingMode(TableNode $renderingModeData): void + { + $data = $renderingModeData->getHash()[0]; + $this->fusionGlobalContext['renderingMode'] = new RenderingMode($data['name'] ?? 'Testing', strtolower($data['isEdit'] ?? 'false') === 'true', strtolower($data['isPreview'] ?? 'false') === 'true', $data['title'] ?? 'Testing', $data['fusionPath'] ?? 'root', []); + } + + /** + * @When the Fusion context node is :nodeAggregateId + */ + public function theFusionContextNodeIs(string $nodeAggregateId): void + { + $subgraph = $this->getCurrentSubgraph(); + $this->fusionContext['node'] = $subgraph->findNodeById(NodeAggregateId::fromString($nodeAggregateId)); + if ($this->fusionContext['node'] === null) { + throw new InvalidArgumentException(sprintf('Node with aggregate id "%s" could not be found in the current subgraph', $nodeAggregateId), 1696700222); + } + $this->fusionContext['documentNode'] = $subgraph->findClosestNode(NodeAggregateId::fromString($nodeAggregateId), FindClosestNodeFilter::create('Neos.Neos:Document')); + if ($this->fusionContext['documentNode'] === null) { + throw new \RuntimeException(sprintf('Failed to find closest document node for node with aggregate id "%s"', $nodeAggregateId), 1697790940); + } + $this->fusionContext['site'] = $subgraph->findClosestNode($this->fusionContext['documentNode']->nodeAggregateId, FindClosestNodeFilter::create(nodeTypeConstraints: NodeTypeNameFactory::NAME_SITE)); + if ($this->fusionContext['site'] === null) { + throw new \RuntimeException(sprintf('Failed to resolve site node for node with aggregate id "%s"', $nodeAggregateId), 1697790963); + } + } + + /** + * @When the Fusion context request URI is :requestUri + */ + public function theFusionContextRequestIs(string $requestUri = null): void + { + $httpRequest = $this->getObject(ServerRequestFactoryInterface::class)->createServerRequest('GET', $requestUri); + $httpRequest = $this->addRoutingParameters($httpRequest); + + $this->fusionGlobalContext['request'] = ActionRequest::fromHttpRequest($httpRequest); + } + + /** + * @When I have the following Fusion setup: + */ + public function iHaveTheFollowingFusionSetup(PyStringNode $fusionCode): void + { + $this->fusionCode = $fusionCode->getRaw(); + } + + /** + * @When I execute the following Fusion code: + * @When I execute the following Fusion code on path :path: + */ + public function iExecuteTheFollowingFusionCode(PyStringNode $fusionCode, string $path = 'test'): void + { + if (isset($this->fusionGlobalContext['request'])) { + $requestHandler = new FunctionalTestRequestHandler(self::$bootstrap); + $requestHandler->setHttpRequest($this->fusionGlobalContext['request']->getHttpRequest()); + } + $this->throwExceptionIfLastRenderingLedToAnError(); + $this->renderingResult = null; + $fusionAst = (new Parser())->parseFromSource(FusionSourceCodeCollection::fromString($this->fusionCode . chr(10) . $fusionCode->getRaw())); + + $fusionGlobals = FusionGlobals::fromArray($this->fusionGlobalContext); + + $fusionRuntime = (new RuntimeFactory())->createFromConfiguration($fusionAst, $fusionGlobals); + $fusionRuntime->overrideExceptionHandler($this->getObject(ThrowingHandler::class)); + $fusionRuntime->pushContextArray($this->fusionContext); + try { + $this->renderingResult = $fusionRuntime->render($path); + } catch (\Throwable $exception) { + if ($exception instanceof RuntimeException) { + $this->lastRenderingException = $exception->getPrevious(); + } else { + $this->lastRenderingException = $exception; + } + } + $fusionRuntime->popContext(); + } + + /** + * @Then I expect the following Fusion rendering result: + */ + public function iExpectTheFollowingFusionRenderingResult(PyStringNode $expectedResult): void + { + Assert::assertSame($expectedResult->getRaw(), $this->renderingResult); + } + + /** + * @Then I expect the following Fusion rendering result as HTML: + */ + public function iExpectTheFollowingFusionRenderingResultAsHtml(PyStringNode $expectedResult): void + { + Assert::assertIsString($this->renderingResult, 'Previous Fusion rendering did not produce a string'); + $stripWhitespace = static fn (string $input): string => preg_replace(['/>[^\S ]+/s', '/[^\S ]+</s', '/(\s)+/s', '/> </s'], ['>', '<', '\\1', '><'], $input); + + $expectedDom = new DomDocument(); + $expectedDom->preserveWhiteSpace = false; + $expectedDom->loadHTML($stripWhitespace($expectedResult->getRaw())); + + $actualDom = new DomDocument(); + $actualDom->preserveWhiteSpace = false; + $actualDom->loadHTML($stripWhitespace($this->renderingResult)); + + Assert::assertSame($expectedDom->saveHTML(), $actualDom->saveHTML()); + } + + /** + * @Then I expect the following Fusion rendering error: + */ + public function iExpectTheFollowingFusionRenderingError(PyStringNode $expectedError): void + { + Assert::assertNotNull($this->lastRenderingException, 'The previous rendering did not lead to an error'); + Assert::assertSame($expectedError->getRaw(), $this->lastRenderingException->getMessage()); + $this->lastRenderingException = null; + } + + /** + * @AfterScenario + */ + public function throwExceptionIfLastRenderingLedToAnError(): void + { + if ($this->lastRenderingException !== null) { + throw new \RuntimeException(sprintf('The last rendering led to an error: %s', $this->lastRenderingException->getMessage()), 1698319254, $this->lastRenderingException); + } + } + +} diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php index ede2f285b75..ed45891c0b7 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php @@ -57,7 +57,7 @@ use Symfony\Component\Yaml\Yaml; /** - * Routing related Behat steps. This trait is pure (no side effects). + * Routing related Behat steps. This trait is impure and resets the SiteRepository * * Requires the {@see \Neos\Flow\Core\Bootstrap::getActiveRequestHandler()} to be a {@see FunctionalTestRequestHandler}. * For this the {@see BrowserTrait} can be used. @@ -74,9 +74,12 @@ trait RoutingTrait private $requestUrl; /** - * @return ObjectManagerInterface + * @template T of object + * @param class-string<T> $className + * + * @return T */ - abstract protected function getObjectManager(); + abstract private function getObject(string $className): object; /** * @Given A site exists for node name :nodeName @@ -84,10 +87,8 @@ abstract protected function getObjectManager(); */ public function theSiteExists(string $nodeName, string $domain = null): void { - /** @var SiteRepository $siteRepository */ - $siteRepository = $this->getObjectManager()->get(SiteRepository::class); - /** @var PersistenceManagerInterface $persistenceManager */ - $persistenceManager = $this->getObjectManager()->get(PersistenceManagerInterface::class); + $siteRepository = $this->getObject(SiteRepository::class); + $persistenceManager = $this->getObject(PersistenceManagerInterface::class); $site = new Site($nodeName); $site->setSiteResourcesPackageKey('Neos.Neos'); @@ -102,7 +103,7 @@ public function theSiteExists(string $nodeName, string $domain = null): void $domainModel->setScheme($domainUri->getScheme()); $domainModel->setSite($site); /** @var DomainRepository $domainRepository */ - $domainRepository = $this->getObjectManager()->get(DomainRepository::class); + $domainRepository = $this->getObject(DomainRepository::class); $domainRepository->add($domainModel); } @@ -117,7 +118,7 @@ public function theSiteExists(string $nodeName, string $domain = null): void */ public function theSiteConfigurationIs(\Behat\Gherkin\Node\PyStringNode $configYaml): void { - $entityManager = $this->getObjectManager()->get(EntityManagerInterface::class); + $entityManager = $this->getObject(EntityManagerInterface::class); // clean up old PostLoad Hook if ($this->routingTraitSiteConfigurationPostLoadHook !== null) { $entityManager->getEventManager()->removeEventListener('postLoad', $this->routingTraitSiteConfigurationPostLoadHook); @@ -148,9 +149,9 @@ public function postLoad(LifecycleEventArgs $lifecycleEventArgs) public function anAssetExists(string $assetIdentifier, string $fileName, string $content): void { /** @var ResourceManager $resourceManager */ - $resourceManager = $this->getObjectManager()->get(ResourceManager::class); + $resourceManager = $this->getObject(ResourceManager::class); /** @var AssetRepository $assetRepository */ - $assetRepository = $this->getObjectManager()->get(AssetRepository::class); + $assetRepository = $this->getObject(AssetRepository::class); $resource = $resourceManager->importResourceFromContent($content, $fileName); $asset = new Asset($resource); @@ -158,7 +159,7 @@ public function anAssetExists(string $assetIdentifier, string $fileName, string $assetRepository->add($asset); /** @var PersistenceManagerInterface $persistenceManager */ - $persistenceManager = $this->getObjectManager()->get(PersistenceManagerInterface::class); + $persistenceManager = $this->getObject(PersistenceManagerInterface::class); $persistenceManager->persistAll(); $persistenceManager->clearState(); } @@ -236,8 +237,8 @@ public function theUrlShouldMatchTheNodeInContentStreamAndDimension(string $url, private function match(UriInterface $uri): ?NodeAddress { - $router = $this->getObjectManager()->get(RouterInterface::class); - $serverRequestFactory = $this->getObjectManager()->get(ServerRequestFactoryInterface::class); + $router = $this->getObject(RouterInterface::class); + $serverRequestFactory = $this->getObject(ServerRequestFactoryInterface::class); $httpRequest = $serverRequestFactory->createServerRequest('GET', $uri); $httpRequest = $this->addRoutingParameters($httpRequest); @@ -288,7 +289,7 @@ public function theNodeShouldNotResolve(string $nodeAggregateId, string $content public function tableContainsExactly(TableNode $expectedRows): void { /** @var Connection $dbal */ - $dbal = $this->getObjectManager()->get(EntityManagerInterface::class)->getConnection(); + $dbal = $this->getObject(EntityManagerInterface::class)->getConnection(); $columns = implode(', ', array_keys($expectedRows->getHash()[0])); $tablePrefix = DocumentUriPathProjectionFactory::projectionTableNamePrefix( $this->currentContentRepository->id @@ -315,7 +316,7 @@ private function resolveUrl(string $nodeAggregateId, string $contentStreamId, st : NodeAggregateId::fromString($nodeAggregateId), WorkspaceName::forLive() ); - $httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', $this->requestUrl); + $httpRequest = $this->getObject(ServerRequestFactoryInterface::class)->createServerRequest('GET', $this->requestUrl); $httpRequest = $this->addRoutingParameters($httpRequest); $actionRequest = ActionRequest::fromHttpRequest($httpRequest); return NodeUriBuilder::fromRequest($actionRequest)->uriFor($nodeAddress); @@ -339,7 +340,7 @@ public function iInvokeTheDimensionResolverWithOptions(PyStringNode $rawSiteConf $rawSiteConfiguration = Yaml::parse($rawSiteConfigurationYaml->getRaw()) ?? []; $siteConfiguration = SiteConfiguration::fromArray($rawSiteConfiguration); - $dimensionResolverFactory = $this->getObjectManager()->get($siteConfiguration->contentDimensionResolverFactoryClassName); + $dimensionResolverFactory = $this->getObject($siteConfiguration->contentDimensionResolverFactoryClassName); assert($dimensionResolverFactory instanceof DimensionResolverFactoryInterface); $dimensionResolver = $dimensionResolverFactory->create($siteConfiguration->contentRepositoryId, $siteConfiguration); diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Basic.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Basic.feature index 7a0099230e5..da5635f69db 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Basic.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Basic.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Basic routing functionality (match & resolve document nodes in one dimension) Background: diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Dimensions.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Dimensions.feature index 8983d4561d9..c6a9da1b7bf 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Dimensions.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Dimensions.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Routing functionality with multiple content dimensions Background: diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/DisableNodes.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/DisableNodes.feature index bd6b2db93ed..8912929e8f3 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/DisableNodes.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/DisableNodes.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Routing behavior of removed, disabled and re-enabled nodes Background: diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Lowlevel_ProjectionTests.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Lowlevel_ProjectionTests.feature index c1d7464cf09..2cdc69e6bcb 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Lowlevel_ProjectionTests.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Lowlevel_ProjectionTests.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Low level tests covering the inner behavior of the routing projection Background: diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MultiSiteLinking.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MultiSiteLinking.feature index d15849c36a1..33b0b36b404 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MultiSiteLinking.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/MultiSiteLinking.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Linking between multiple websites Background: diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/RouteCache.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/RouteCache.feature index 0831200f2fd..4a5df7fc03d 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/RouteCache.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/RouteCache.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Route cache invalidation Background: diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Shortcuts.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Shortcuts.feature index 4f4b7491880..3bba3d61557 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Shortcuts.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/Shortcuts.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Routing behavior of shortcut nodes Background: diff --git a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/TetheredSiteChildDocuments.feature b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/TetheredSiteChildDocuments.feature index 1ddfba54ec5..5b644025b96 100644 --- a/Neos.Neos/Tests/Behavior/Features/FrontendRouting/TetheredSiteChildDocuments.feature +++ b/Neos.Neos/Tests/Behavior/Features/FrontendRouting/TetheredSiteChildDocuments.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities @contentrepository Feature: Tests for site node child documents. These are special in that they have the first non-dimension uri path segment. Background: diff --git a/Neos.Neos/Tests/Behavior/Features/Fusion/ContentCase.feature b/Neos.Neos/Tests/Behavior/Features/Fusion/ContentCase.feature new file mode 100644 index 00000000000..3c18ebada65 --- /dev/null +++ b/Neos.Neos/Tests/Behavior/Features/Fusion/ContentCase.feature @@ -0,0 +1,96 @@ +@flowEntities +Feature: Tests for the "Neos.Neos:ContentCase" Fusion prototype + + Background: + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.ContentRepository:Root': {} + 'Neos.Neos:Sites': + superTypes: + 'Neos.ContentRepository:Root': true + 'Neos.Neos:Document': + properties: + title: + type: string + uriPathSegment: + type: string + 'Neos.Neos:Site': + superTypes: + 'Neos.Neos:Document': true + 'Neos.Neos:Test.DocumentType1': + superTypes: + 'Neos.Neos:Document': true + 'Neos.Neos:Test.DocumentType2': + superTypes: + 'Neos.Neos:Document': true + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And I am user identified by "initiating-user-identifier" + + When the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | newContentStreamId | "cs-identifier" | + And the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "root" | + | nodeTypeName | "Neos.Neos:Sites" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" and dimension space point {} + And the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | parentNodeAggregateId | nodeTypeName | + | a | root | Neos.Neos:Site | + | a1 | a | Neos.Neos:Test.DocumentType2 | + And A site exists for node name "a" and domain "http://localhost" + And the sites configuration is: + """yaml + Neos: + Neos: + sites: + '*': + contentRepository: default + contentDimensions: + resolver: + factoryClassName: Neos\Neos\FrontendRouting\DimensionResolution\Resolver\NoopResolverFactory + """ + And the Fusion context node is "a1" + And the Fusion context request URI is "http://localhost" + + Scenario: ContentCase without corresponding implementation + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ContentCase + """ + Then I expect the following Fusion rendering error: + """ + The Fusion object "Neos.Neos:Test.DocumentType2" cannot be rendered: + Most likely you mistyped the prototype name or did not define + the Fusion prototype with "prototype(Neos.Neos:Test.DocumentType2) < prototype(...)". + Other possible reasons are a missing parent-prototype or + a missing "@class" annotation for prototypes without parent. + It is also possible your Fusion file is not read because + of a missing "include:" statement. + """ + + Scenario: ContentCase with corresponding implementation + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + prototype(Neos.Neos:Test.DocumentType2) < prototype(Neos.Fusion:Value) { + value = 'implementation for DocumentType2' + } + + test = Neos.Neos:ContentCase + """ + Then I expect the following Fusion rendering result: + """ + implementation for DocumentType2 + """ diff --git a/Neos.Neos/Tests/Behavior/Features/Fusion/ContentCollection.feature b/Neos.Neos/Tests/Behavior/Features/Fusion/ContentCollection.feature new file mode 100644 index 00000000000..c834e9cb06e --- /dev/null +++ b/Neos.Neos/Tests/Behavior/Features/Fusion/ContentCollection.feature @@ -0,0 +1,143 @@ +@flowEntities +Feature: Tests for the "Neos.Neos:ContentCollection" Fusion prototype + + Background: + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.ContentRepository:Root': {} + 'Neos.Neos:ContentCollection': {} + 'Neos.Neos:Content': {} + 'Neos.Neos:Sites': + superTypes: + 'Neos.ContentRepository:Root': true + 'Neos.Neos:Document': + properties: + title: + type: string + uriPathSegment: + type: string + 'Neos.Neos:Site': + superTypes: + 'Neos.Neos:Document': true + childNodes: + main: + type: 'Neos.Neos:ContentCollection' + 'Neos.Neos:Test.DocumentType': + superTypes: + 'Neos.Neos:Document': true + childNodes: + main: + type: 'Neos.Neos:ContentCollection' + 'Neos.Neos:Test.ContentType': + superTypes: + 'Neos.Neos:Content': true + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And I am user identified by "initiating-user-identifier" + + When the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | newContentStreamId | "cs-identifier" | + And the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "root" | + | nodeTypeName | "Neos.Neos:Sites" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" and dimension space point {} + And the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | parentNodeAggregateId | nodeTypeName | + | a | root | Neos.Neos:Site | + And A site exists for node name "a" and domain "http://localhost" + And the sites configuration is: + """yaml + Neos: + Neos: + sites: + '*': + contentRepository: default + contentDimensions: + resolver: + factoryClassName: Neos\Neos\FrontendRouting\DimensionResolution\Resolver\NoopResolverFactory + """ + And the Fusion context node is "a" + And the Fusion context request URI is "http://localhost" + + Scenario: missing Neos.Neos.ContentCollection node + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ContentCollection + """ + Then I expect the following Fusion rendering error: + """ + No content collection of type Neos.Neos:ContentCollection could be found in the current node (/[root]) or at the path "to-be-set-by-user". You might want to adjust your node type configuration and create the missing child node through the "flow structureadjustments:fix --node-type Neos.Neos:Site" command. + """ + + Scenario: invalid nodePath + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ContentCollection { + nodePath = 'invalid' + } + """ + Then I expect the following Fusion rendering error: + """ + No content collection of type Neos.Neos:ContentCollection could be found in the current node (/[root]) or at the path "invalid". You might want to adjust your node type configuration and create the missing child node through the "flow structureadjustments:fix --node-type Neos.Neos:Site" command. + """ + + Scenario: empty ContentCollection + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ContentCollection { + nodePath = 'main' + } + """ + Then I expect the following Fusion rendering result as HTML: + """ + <div class="neos-contentcollection"></div> + """ + + Scenario: + When the command CreateNodeAggregateWithNodeAndSerializedProperties is executed with payload: + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "a1" | + | nodeTypeName | "Neos.Neos:Test.DocumentType" | + | parentNodeAggregateId | "a" | + | initialPropertyValues | {} | + | tetheredDescendantNodeAggregateIds | { "main": "a1-main"} | + And the graph projection is fully up to date + When the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | parentNodeAggregateId | nodeTypeName | + | content1 | a1-main | Neos.Neos:Test.ContentType | + | content2 | a1-main | Neos.Neos:Test.ContentType | + And the Fusion context node is "a1" + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + prototype(Neos.Neos:Test.ContentType) < prototype(Neos.Fusion:Value) { + value = ${node.nodeAggregateId.value + ' (' + node.nodeType.name.value + ') '} + } + + test = Neos.Neos:ContentCollection { + nodePath = 'main' + } + """ + Then I expect the following Fusion rendering result as HTML: + """ + <div class="neos-contentcollection">content1 (Neos.Neos:Test.ContentType) content2 (Neos.Neos:Test.ContentType) </div> + """ diff --git a/Neos.Neos/Tests/Behavior/Features/Fusion/ConvertUris.feature b/Neos.Neos/Tests/Behavior/Features/Fusion/ConvertUris.feature new file mode 100644 index 00000000000..f9b0575cabe --- /dev/null +++ b/Neos.Neos/Tests/Behavior/Features/Fusion/ConvertUris.feature @@ -0,0 +1,193 @@ +@flowEntities +Feature: Tests for the "Neos.Neos:ConvertUris" Fusion prototype + + Background: + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.ContentRepository:Root': {} + 'Neos.Neos:Sites': + superTypes: + 'Neos.ContentRepository:Root': true + 'Neos.Neos:Document': + properties: + title: + type: string + uriPathSegment: + type: string + 'Neos.Neos:Site': + superTypes: + 'Neos.Neos:Document': true + 'Neos.Neos:Test.DocumentType': + superTypes: + 'Neos.Neos:Document': true + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And I am user identified by "initiating-user-identifier" + + When the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | newContentStreamId | "cs-identifier" | + And the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "root" | + | nodeTypeName | "Neos.Neos:Sites" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" and dimension space point {} + And the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | parentNodeAggregateId | nodeTypeName |initialPropertyValues | nodeName | + | a | root | Neos.Neos:Site |{"title": "Node a"} | a | + | a1 | a | Neos.Neos:Test.DocumentType |{"uriPathSegment": "a1", "title": "Node a1"} | a1 | + And A site exists for node name "a" and domain "http://localhost" + And the sites configuration is: + """yaml + Neos: + Neos: + sites: + '*': + contentRepository: default + contentDimensions: + resolver: + factoryClassName: Neos\Neos\FrontendRouting\DimensionResolution\Resolver\NoopResolverFactory + """ + And the Fusion context node is "a" + And the Fusion context request URI is "http://localhost" + + Scenario: Default output + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ConvertUris + """ + Then I expect the following Fusion rendering result: + """ + """ + + Scenario: Without URI + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ConvertUris { + value = 'Some value without URI' + } + """ + Then I expect the following Fusion rendering result: + """ + Some value without URI + """ + +# NOTE: This scenario currently breaks because it leads to an exception "Could not resolve a route and its corresponding URI for the given parameters" +# Scenario: URI to non-existing node +# When I execute the following Fusion code: +# """fusion +# include: resource://Neos.Fusion/Private/Fusion/Root.fusion +# include: resource://Neos.Neos/Private/Fusion/Root.fusion +# +# test = Neos.Neos:ConvertUris { +# value = 'Some value with node URI to non-existing node: node://non-existing.' +# } +# """ +# Then I expect the following Fusion rendering result: +# """ +# Some value with node URI to non-existing node: . +# """ + + Scenario: URI to existing node + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ConvertUris { + value = 'Some value with node URI: node://a1.' + } + """ + Then I expect the following Fusion rendering result: + """ + Some value with node URI: /a1. + """ + +# NOTE: This scenario currently breaks because the rel attribute is just "noopener" instead of "noopener external" +# Scenario: Anchor tag without node or asset URI +# When I execute the following Fusion code: +# """fusion +# include: resource://Neos.Fusion/Private/Fusion/Root.fusion +# include: resource://Neos.Neos/Private/Fusion/Root.fusion +# +# test = Neos.Neos:ConvertUris { +# value = 'some <a href="https://neos.io">Link</a>' +# } +# """ +# Then I expect the following Fusion rendering result: +# """ +# some <a target="_blank" rel="noopener external" href="https://neos.io">Link</a> +# """ + +# NOTE: This scenario currently breaks because it leads to an exception "Could not resolve a route and its corresponding URI for the given parameters" +# Scenario: Anchor tag with node URI to non-existing node +# When I execute the following Fusion code: +# """fusion +# include: resource://Neos.Fusion/Private/Fusion/Root.fusion +# include: resource://Neos.Neos/Private/Fusion/Root.fusion +# +# test = Neos.Neos:ConvertUris { +# value = 'some <a href="node://non-existing">Link</a>' +# } +# """ +# Then I expect the following Fusion rendering result: +# """ +# some Link +# """ + + Scenario: Anchor tag with URI to existing node + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ConvertUris { + value = 'some <a href="node://a1">Link</a>' + } + """ + Then I expect the following Fusion rendering result: + """ + some <a href="/a1">Link</a> + """ + + Scenario: URI to non-existing asset + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:ConvertUris { + value = 'Some value with node URI to non-existing asset: asset://non-existing.' + } + """ + Then I expect the following Fusion rendering result: + """ + Some value with node URI to non-existing asset: . + """ + +# Scenario: URI to existing asset +# When an asset exists with id "362f3049-b9bb-454d-8769-6b35167e471e" +# And I execute the following Fusion code: +# """fusion +# include: resource://Neos.Fusion/Private/Fusion/Root.fusion +# include: resource://Neos.Neos/Private/Fusion/Root.fusion +# +# test = Neos.Neos:ConvertUris { +# value = 'Some value with node URI: asset://362f3049-b9bb-454d-8769-6b35167e471e.' +# } +# """ +# Then I expect the following Fusion rendering result: +# """ +# Some value with node URI: http://localhost/_Resources/Testing/Persistent/d0a1342bcb0e515bea83269427d8341d5f62a43d/test.svg. +# """ diff --git a/Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature b/Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature new file mode 100644 index 00000000000..9d94f027ac5 --- /dev/null +++ b/Neos.Neos/Tests/Behavior/Features/Fusion/Menu.feature @@ -0,0 +1,541 @@ +@flowEntities @contentrepository +Feature: Tests for the "Neos.Neos:Menu" and related Fusion prototypes + + Background: + Given using no content dimensions + And using the following node types: + """yaml + 'Neos.ContentRepository:Root': {} + 'Neos.Neos:Sites': + superTypes: + 'Neos.ContentRepository:Root': true + 'Neos.Neos:Document': + properties: + title: + type: string + uriPathSegment: + type: string + _hiddenInIndex: + type: bool + 'Neos.Neos:Site': + superTypes: + 'Neos.Neos:Document': true + 'Neos.Neos:Content': + properties: + title: + type: string + 'Neos.Neos:Test.DocumentType1': + superTypes: + 'Neos.Neos:Document': true + 'Neos.Neos:Test.DocumentType2': + superTypes: + 'Neos.Neos:Document': true + 'Neos.Neos:Test.DocumentType2a': + superTypes: + 'Neos.Neos:Test.DocumentType2': true + 'Neos.Neos:Test.Content': + superTypes: + 'Neos.Neos:Content': true + + """ + And using identifier "default", I define a content repository + And I am in content repository "default" + And I am user identified by "initiating-user-identifier" + + When the command CreateRootWorkspace is executed with payload: + | Key | Value | + | workspaceName | "live" | + | newContentStreamId | "cs-identifier" | + And the command CreateRootNodeAggregateWithNode is executed with payload: + | Key | Value | + | contentStreamId | "cs-identifier" | + | nodeAggregateId | "root" | + | nodeTypeName | "Neos.Neos:Sites" | + And the graph projection is fully up to date + And I am in content stream "cs-identifier" and dimension space point {} + And the following CreateNodeAggregateWithNode commands are executed: + | nodeAggregateId | parentNodeAggregateId | nodeTypeName | initialPropertyValues | nodeName | + | a | root | Neos.Neos:Site | {"title": "Node a"} | a | + | a1 | a | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1", "title": "Node a1"} | a1 | + | a1a | a1 | Neos.Neos:Test.DocumentType2a | {"uriPathSegment": "a1a", "title": "Node a1a"} | a1a | + | a1b | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1b", "title": "Node a1b"} | a1b | + | a1b1 | a1b | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1b1", "title": "Node a1b1"} | a1b1 | + | a1b1a | a1b1 | Neos.Neos:Test.DocumentType2a | {"uriPathSegment": "a1b1a", "title": "Node a1b1a"} | a1b1a | + | a1b1b | a1b1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1b1b", "title": "Node a1b1b"} | a1b1b | + | a1b2 | a1b | Neos.Neos:Test.DocumentType2 | {"uriPathSegment": "a1b2", "title": "Node a1b2"} | a1b2 | + | a1b3 | a1b | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1b3", "title": "Node a1b3"} | a1b3 | + | a1c | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1c", "title": "Node a1c", "_hiddenInIndex": true} | a1c | + | a1c1 | a1c | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1c1", "title": "Node a1c1"} | a1c1 | + And A site exists for node name "a" and domain "http://localhost" + And the sites configuration is: + """yaml + Neos: + Neos: + sites: + '*': + contentRepository: default + contentDimensions: + resolver: + factoryClassName: Neos\Neos\FrontendRouting\DimensionResolution\Resolver\NoopResolverFactory + """ + And the Fusion context node is "a1a" + And the Fusion context request URI is "http://localhost" + And I have the following Fusion setup: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + prototype(Neos.Neos:Test.Menu.ItemStateIndicator) < prototype(Neos.Fusion:Component) { + state = null + renderer = Neos.Fusion:Match { + @subject = ${props.state} + @default = '?' + normal = '' + current = '*' + active = '.' + absent = 'x' + } + } + + prototype(Neos.Neos:Test.Menu) < prototype(Neos.Fusion:Component) { + items = ${[]} + renderer = Neos.Fusion:Loop { + items = ${props.items} + itemRenderer = afx` + {item.node.nodeAggregateId.value}<Neos.Neos:Test.Menu.ItemStateIndicator state={item.state.value} /> ({item.menuLevel}){String.chr(10)} + <Neos.Neos:Test.Menu items={item.subItems} @if={item.subItems} /> + ` + } + } + + # Always calculate menu item state to get Neos < 9 behavior + prototype(Neos.Neos:MenuItems) { + calculateItemStates = true + } + + """ + + Scenario: MenuItems (default) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + + """ + + Scenario: MenuItems (default on home page) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems + } + """ + And the Fusion context node is "a" + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + + """ + + Scenario: MenuItems (maximumLevels = 3) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + maximumLevels = 3 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + a1b1 (3) + a1b2 (3) + a1b3 (3) + + """ + + Scenario: MenuItems (entryLevel = -5) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + entryLevel = -5 + } + } + """ + Then I expect the following Fusion rendering result: + """ + + """ + + + Scenario: MenuItems (entryLevel = -1) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + entryLevel = -1 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1a* (1) + a1b (1) + a1b1 (2) + a1b2 (2) + a1b3 (2) + + """ + + Scenario: MenuItems (entryLevel = 0) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + entryLevel = 0 + } + } + """ + Then I expect the following Fusion rendering result: + """ + + """ + + Scenario: MenuItems (entryLevel = 2) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + entryLevel = 2 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1a* (1) + a1b (1) + a1b1 (2) + a1b2 (2) + a1b3 (2) + + """ + + Scenario: MenuItems (entryLevel = 5) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + entryLevel = 5 + } + } + """ + Then I expect the following Fusion rendering result: + """ + + """ + + Scenario: MenuItems (lastLevel = -5) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + lastLevel = -5 + } + } + """ + Then I expect the following Fusion rendering result: + """ + + """ + + Scenario: MenuItems (lastLevel = -1) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + lastLevel = -1 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + + """ + + Scenario: MenuItems (lastLevel = 0) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + lastLevel = 0 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + + """ + + Scenario: MenuItems (lastLevel = 1) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + lastLevel = 1 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + + """ + + Scenario: MenuItems (filter non existing node type) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + filter = 'Non.Existing:NodeType' + } + } + """ + Then I expect the following Fusion rendering result: + """ + """ + + Scenario: MenuItems (filter = DocumentType1) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + filter = 'Neos.Neos:Test.DocumentType1' + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1b (2) + + """ + + Scenario: MenuItems (filter = DocumentType2) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + filter = 'Neos.Neos:Test.DocumentType2' + } + } + """ + Then I expect the following Fusion rendering result: + """ + + """ + + Scenario: MenuItems (renderHiddenInIndex) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + renderHiddenInIndex = true + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + a1c (2) + + """ + + Scenario: MenuItems (empty itemCollection) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + itemCollection = ${[]} + } + } + """ + Then I expect the following Fusion rendering result: + """ + """ + + Scenario: MenuItems (itemCollection document nodes) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + itemCollection = ${q(site).filter('[instanceof Neos.Neos:Document]').get()} + } + } + """ + Then I expect the following Fusion rendering result: + """ + a. (1) + a1. (2) + + """ + + Scenario: MenuItems (startingPoint a1b1) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + startingPoint = ${q(node).children('[instanceof Neos.Neos:Document]').children('[instanceof Neos.Neos:Document]').get(0)} + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + + """ + + Scenario: MenuItems (startingPoint a1b1, negative entryLevel) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + startingPoint = ${q(node).children('[instanceof Neos.Neos:Document]').children('[instanceof Neos.Neos:Document]').get(0)} + entryLevel = -1 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1a* (1) + a1b (1) + a1b1 (2) + a1b2 (2) + a1b3 (2) + + """ + + Scenario: MenuItems (startingPoint a1b1, negative lastLevel) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + startingPoint = ${q(node).children('[instanceof Neos.Neos:Document]').children('[instanceof Neos.Neos:Document]').get(0)} + lastLevel = -1 + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1. (1) + a1a* (2) + a1b (2) + + """ + + Scenario: MenuItems (startingPoint a1b, filter DocumentType2a) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + startingPoint = ${q(node).children('[instanceof Neos.Neos:Document]').get(0)} + filter = 'Neos.Neos:Test.DocumentType2a' + } + } + """ + Then I expect the following Fusion rendering result: + """ + + """ + + Scenario: MenuItems (startingPoint a1c, renderHiddenInIndex) + When I execute the following Fusion code: + """fusion + test = Neos.Neos:Test.Menu { + items = Neos.Neos:MenuItems { + startingPoint = ${q(node).find('#a1c').get(0)} + renderHiddenInIndex = true + } + } + """ + Then I expect the following Fusion rendering result: + """ + a1c1 (1) + + """ + + Scenario: Menu + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:Menu { + # calculate menu item state to get Neos < 9 behavior + calculateItemStates = true + } + """ + Then I expect the following Fusion rendering result as HTML: + """html + <ul> + <li class="active"> + <a href="/a1" title="Neos.Neos:Test.DocumentType1">Neos.Neos:Test.DocumentType1</a> + <ul> + <li class="current"> + <a href="/a1/a1a" title="Neos.Neos:Test.DocumentType2a">Neos.Neos:Test.DocumentType2a</a> + </li> + <li class="normal"> + <a href="/a1/a1b" title="Neos.Neos:Test.DocumentType1">Neos.Neos:Test.DocumentType1</a> + </li> + </ul> + </li> + </ul> + """ + + Scenario: BreadcrumbMenu + When I execute the following Fusion code: + """fusion + include: resource://Neos.Fusion/Private/Fusion/Root.fusion + include: resource://Neos.Neos/Private/Fusion/Root.fusion + + test = Neos.Neos:BreadcrumbMenu { + # calculate menu item state to get Neos < 9 behavior + calculateItemStates = true + } + """ + Then I expect the following Fusion rendering result as HTML: + """html + <ul> + <li class="active"> + <a href="/" title="Neos.Neos:Site">Neos.Neos:Site</a> + </li> + <li class="active"> + <a href="/a1" title="Neos.Neos:Test.DocumentType1">Neos.Neos:Test.DocumentType1</a> + </li> + <li class="current"> + <a href="/a1/a1a" title="Neos.Neos:Test.DocumentType2a">Neos.Neos:Test.DocumentType2a</a> + </li> + </ul> + """ diff --git a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php index 7ae29c33826..08a59dd2c37 100644 --- a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php +++ b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php @@ -156,15 +156,15 @@ protected function setUp(): void $now = new \DateTimeImmutable(); - $this->textNode = new Node( + $this->textNode = Node::create( ContentSubgraphIdentity::create( $contentRepositoryId, ContentStreamId::fromString("cs"), - DimensionSpacePoint::fromArray([]), + DimensionSpacePoint::createWithoutDimensions(), VisibilityConstraints::withoutRestrictions() ), NodeAggregateId::fromString("na"), - OriginDimensionSpacePoint::fromArray([]), + OriginDimensionSpacePoint::createWithoutDimensions(), NodeAggregateClassification::CLASSIFICATION_REGULAR, $nodeTypeName, $textNodeType, diff --git a/Neos.Neos/composer.json b/Neos.Neos/composer.json index 0d6897fc4ca..b3b7ee16dc2 100644 --- a/Neos.Neos/composer.json +++ b/Neos.Neos/composer.json @@ -12,11 +12,11 @@ "neos/media-browser": "self.version", "neos/party": "*", "neos/twitter-bootstrap": "*", - "neos/contentrepository-core": "~9.0.0", - "neos/contentrepositoryregistry": "~9.0.0", - "neos/contentrepository-nodeaccess": "~9.0.0", - "neos/fusion": "*", - "neos/fusion-afx": "*", + "neos/contentrepository-core": "self.version", + "neos/contentrepositoryregistry": "self.version", + "neos/contentrepository-nodeaccess": "self.version", + "neos/fusion": "self.version", + "neos/fusion-afx": "self.version", "neos/fusion-form": "^1.0 || ^2.0", "neos/fluid-adaptor": "~9.0.0", "behat/transliterator": "~1.0", diff --git a/Neos.Neos/webpack.styles.config.js b/Neos.Neos/webpack.styles.config.js index 15fc8667b8f..057d95fecd5 100644 --- a/Neos.Neos/webpack.styles.config.js +++ b/Neos.Neos/webpack.styles.config.js @@ -6,13 +6,14 @@ const stylesConfig = { context: __dirname, devtool: "source-map", entry: { - Main: ["./Resources/Private/Styles/Neos.scss"], + Main: ["./Resources/Private/Styles/Main.scss"], Lite: ["./Resources/Private/Styles/Lite.scss"], Minimal: ["./Resources/Private/Styles/Minimal.scss"], Login: ["./Resources/Private/Styles/Login.scss"], Error: ["./Resources/Private/Styles/Error.scss"], RawContentMode: ["./Resources/Private/Styles/RawContentMode.scss"], Welcome: ["./Resources/Private/Styles/Welcome.scss"], + Shortcut: ["./Resources/Private/Styles/Shortcut.scss"], }, output: { path: __dirname + "/Resources/Public/Styles", diff --git a/Neos.NodeTypes.Html/Resources/Private/Fusion/Html.fusion b/Neos.NodeTypes.Html/Resources/Private/Fusion/Html.fusion index 97f769333b2..a3f12bbe256 100644 --- a/Neos.NodeTypes.Html/Resources/Private/Fusion/Html.fusion +++ b/Neos.NodeTypes.Html/Resources/Private/Fusion/Html.fusion @@ -1,4 +1,21 @@ -prototype(Neos.NodeTypes.Html:Html) < prototype(Neos.Neos:Content) { - templatePath = "resource://Neos.NodeTypes.Html/Private/Templates/NodeTypes/Html.html" - source = ${q(node).property('source')} +prototype(Neos.NodeTypes.Html:Html) < prototype(Neos.Neos:ContentComponent) { + source = ${q(node).property('source')} + + attributes = Neos.Fusion:DataStructure + attributes.class = '' + + # The following is used to automatically append a class attribute that reflects the underlying node type of a Fusion object, + # for example "neos-nodetypes-form", "neos-nodetypes-headline", "neos-nodetypes-html", "neos-nodetypes-image", "neos-nodetypes-menu" and "neos-nodetypes-text" + # You can disable the following line with: + # prototype(Neos.Neos:Content) { + # attributes.class.@process.nodeType > + # } + # in your site's Fusion if you don't need that behavior. + attributes.class.@process.nodeType = ${Array.push(value, String.toLowerCase(String.pregReplace(node.nodeTypeName.value, '/[[:^alnum:]]/', '-')))} + + renderer = afx` + <div {...props.attributes}> + {props.source} + </div> + ` } diff --git a/Neos.NodeTypes.Html/Resources/Private/Templates/NodeTypes/Html.html b/Neos.NodeTypes.Html/Resources/Private/Templates/NodeTypes/Html.html deleted file mode 100644 index 66457545e79..00000000000 --- a/Neos.NodeTypes.Html/Resources/Private/Templates/NodeTypes/Html.html +++ /dev/null @@ -1,3 +0,0 @@ -<div{attributes -> f:format.raw()}> - {source -> f:format.raw()} -</div> diff --git a/composer.json b/composer.json index 7348c34a7bb..383619b9a74 100644 --- a/composer.json +++ b/composer.json @@ -8,21 +8,22 @@ "require": { "neos/flow-development-collection": "9.0.x-dev", "neos/neos-setup": "^2.0", - "php": "^8.2", + "league/flysystem-memory": "^3", "doctrine/dbal": "^2.8", "doctrine/migrations": "*", "neos/eventstore": "*", "neos/eventstore-doctrineadapter": "*", + "php": "^8.2", "neos/error-messages": "*", "neos/utility-objecthandling": "*", "neos/utility-arrays": "*", "symfony/serializer": "*", "psr/clock": "^1", "behat/transliterator": "~1.0", + "ramsey/uuid": "^3.0 || ^4.0", "league/flysystem": "^3", "webmozart/assert": "^1.11", "neos/flow": "*", - "neos/neos-ui": "*", "behat/behat": "^3.5", "phpunit/phpunit": "^9.0", "symfony/property-access": "*", @@ -41,8 +42,7 @@ "neos/twitter-bootstrap": "*", "neos/fusion-form": "^1.0 || ^2.0", "neos/form": "*", - "neos/kickstarter": "~9.0.0", - "league/flysystem-memory": "^3" + "neos/kickstarter": "~9.0.0" }, "replace": { "packagefactory/atomicfusion-afx": "*", @@ -51,7 +51,6 @@ "typo3/neos": "self.version", "typo3/neos-nodetypes": "self.version", "typo3/neos-kickstarter": "self.version", - "neos/cli-setup": "self.version", "neos/contentgraph-doctrinedbaladapter": "self.version", "neos/contentgraph-postgresqladapter": "self.version", "neos/contentrepository-behavioraltests": "self.version", @@ -111,7 +110,8 @@ "../../bin/behat -f progress -c Neos.ContentRepository.BehavioralTests/Tests/Behavior/behat.yml.dist", "../../bin/behat -f progress -c Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/behat.yml.dist", "../../flow doctrine:migrate --quiet; ../../flow cr:setup", - "../../bin/behat -f progress -c Neos.Neos/Tests/Behavior/behat.yml" + "../../bin/behat -f progress -c Neos.Neos/Tests/Behavior/behat.yml", + "../../bin/behat -f progress -c Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/behat.yml.dist" ], "test:behavioral:stop-on-failure": [ "../../bin/behat -vvv --stop-on-failure -f progress -c Neos.ContentRepository.BehavioralTests/Tests/Behavior/behat.yml.dist", @@ -128,9 +128,6 @@ }, "autoload": { "psr-4": { - "Neos\\CliSetup\\": [ - "Neos.CliSetup/Classes" - ], "Neos\\ContentGraph\\DoctrineDbalAdapter\\": [ "Neos.ContentGraph.DoctrineDbalAdapter/src" ], @@ -271,7 +268,6 @@ "phpstan/phpstan": "^1.8", "squizlabs/php_codesniffer": "^3.6", "phpunit/phpunit": "^9.0", - "neos/behat": "*", - "league/flysystem-memory": "^3" + "neos/behat": "*" } } diff --git a/phpstan.neon b/phpstan.neon index f86c15823ee..94edcc099fe 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,6 +6,7 @@ parameters: - Neos.ContentRepository.BehavioralTests/Classes - Neos.ContentRepository.TestSuite/Classes - Neos.ContentRepository.Core/Classes + - Neos.ContentRepository.LegacyNodeMigration/Classes - Neos.Neos/Classes excludePaths: analyse: