This package provides Rector rules for migrating code from older versions of the TYPO3 extension schema.
Note: If you don't know already, you can also migrate TYPO3 core-specific code with Rector for TYPO3.
The package can be installed with composer:
composer req --dev brotkrueml/schema-rector
Caution: Never run this tool on production, only on development environment where code is under version control (e.g. git). Always review and test automatic changes before releasing to production.
Create a rector.php
file in the project's root folder:
<?php
declare(strict_types=1);
use Brotkrueml\SchemaRector\Rules\RenameSchemaManagerSetMainEntityOfWebPageRector;use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameSchemaManagerSetMainEntityOfWebPageRector::class);
};
Afterwards you can start a dry-run to see the possible changes
(assuming the extensions of your projects are available under the
packages
folder):
vendor/bin/rector process packages --dry-run
If everything is okay for you than you can omit the dry-run
option
to write the changes to your code.
The following rules are available:
This Rector migrates the deprecated SchemaManager->setMainEntityOfWebPage()
method call to the new SchemaManager->addMainEntityOfWebPage()
.
🔧 configure it!
use Brotkrueml\SchemaRector\Rules\RenameSchemaManagerSetMainEntityOfWebPageRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameSchemaManagerSetMainEntityOfWebPageRector::class);
};
↓
$schemaManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Brotkrueml\Schema\Manager\SchemaManager::class);
$type = new \Brotkrueml\Schema\Model\Type\Thing();
-$schemaManager->setMainEntityOfPage($type);
+$schemaManager->addMainEntityOfPage($type);