--- /dev/null
+.. include:: ../../Includes.txt
+
+=====================================================================================
+Deprecation: #83093 - Replace @cascade with @TYPO3\CMS\Extbase\Annotation\ORM\Cascade
+=====================================================================================
+
+See :issue:`83093`
+
+Description
+===========
+
+The `@cascade` annotation has been deprecated and must be replaced with the doctrine annotation `@TYPO3\CMS\Extbase\Annotation\ORM\Cascade`.
+
+
+Impact
+======
+
+From version 9.0 on, `@cascade` is deprecated and will be removed in version 10.
+
+
+Affected Installations
+======================
+
+All extensions that use `@cascade`
+
+
+Migration
+=========
+
+Use `@TYPO3\CMS\Extbase\Annotation\ORM\Cascade` instead.
+
+A tyical example has been `@cascade remove` which is now `@TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")`
+
+.. index:: PHP-API, ext:extbase, FullyScanned
--- /dev/null
+.. include:: ../../Includes.txt
+
+=================================================================================
+Feature: #83093 - Replace @cascade with @TYPO3\CMS\Extbase\Annotation\ORM\Cascade
+=================================================================================
+
+See :issue:`83093`
+
+Description
+===========
+
+As a successor to the `@cascade` annotation, the doctrine annotation `@TYPO3\CMS\Extbase\Annotation\ORM\Cascade` has been introduced.
+
+Example:
+
+.. code-block:: php
+
+ /**
+ * @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
+ */
+ public $property;
+
+Doctrine annotations are actual defined classes, therefore you can also use the annotation with a use statement.
+
+Example:
+
+.. code-block:: php
+
+ use TYPO3\CMS\Extbase\Annotation\ORM\Cascade;
+
+.. code-block:: php
+
+ /**
+ * @Cascade("remove")
+ */
+ public $property;
+
+Used annotations can also be aliased which the core will most likely be using a lot in the future.
+
+Example:
+
+.. code-block:: php
+
+ use TYPO3\CMS\Extbase\Annotation as Extbase;
+
+.. code-block:: php
+
+ /**
+ * @Extbase\ORM\Cascade("remove")
+ */
+ public $property;
+
+
+Impact
+======
+
+In 9.x there is no actual impact. Both the simple `@cascade` and `@TYPO3\CMS\Extbase\Annotation\ORM\Cascade` can be used side by side. However, `@cascade` is deprecated in 9.x and will be removed in version 10.
+
+.. index:: PHP-API, ext:extbase, FullyScanned
--- /dev/null
+<?php
+declare(strict_types=1);
+
+namespace TYPO3\CMS\Extbase\Annotation\ORM;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY"})
+ */
+class Cascade
+{
+ /**
+ * @Enum({"remove"})
+ *
+ * Currently, Extbase does only support "remove".
+ *
+ * Other possible cascade operations would be: "persist", "merge", "detach", "refresh", "all"
+ * @see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#transitive-persistence-cascade-operations
+ */
+ public $value;
+
+ /**
+ * @param array $values
+ */
+ public function __construct(array $values)
+ {
+ if (isset($values['value'])) {
+ $this->value = $values['value'];
+ }
+ }
+}
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\ClassNamingUtility;
use TYPO3\CMS\Extbase\Annotation\Inject;
+use TYPO3\CMS\Extbase\Annotation\ORM\Cascade;
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
use TYPO3\CMS\Extbase\Annotation\ORM\Transient;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
} catch (\Exception $e) {
}
+ if ($this->properties[$propertyName]['annotations']['cascade'] !== null) {
+ trigger_error(
+ 'Tagging properties with @cascade is deprecated and will be removed in TYPO3 v10.0.',
+ E_USER_DEPRECATED
+ );
+ }
+
+ if (($annotation = $annotationReader->getPropertyAnnotation($reflectionProperty, Cascade::class)) instanceof Cascade) {
+ /** @var Cascade $annotation */
+ $this->properties[$propertyName]['annotations']['cascade'] = $annotation->value;
+ }
+
try {
$type = TypeHandlingUtility::parseType(implode(' ', $docCommentParser->getTagValues('var')));
} catch (\Exception $e) {
*/
use TYPO3\CMS\Extbase\Annotation\Inject;
+use TYPO3\CMS\Extbase\Annotation\ORM\Cascade;
use TYPO3\CMS\Extbase\Annotation\ORM\Transient;
/**
/**
* @var DummyClassWithAllTypesOfProperties
- * @cascade remove
+ * @Cascade("remove")
*/
public $propertyWithCascadeAnnotation;
/**
- * @cascade remove
+ * @Cascade("remove")
*/
public $propertyWithCascadeAnnotationWithoutVarAnnotation;
$classSchema = new ClassSchema(Fixture\DummyClassWithLazyProperty::class);
static::assertTrue($classSchema->getProperty('propertyWithLazyAnnotation')['annotations']['lazy']);
}
+
+ public function testClassSchemaDetectsCascadeProperty()
+ {
+ $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
+
+ $propertyDefinition = $classSchema->getProperty('propertyWithCascadeAnnotation');
+ static::assertSame('remove', $propertyDefinition['annotations']['cascade']);
+ }
+
+ public function testClassSchemaDetectsCascadePropertyOnlyWithVarAnnotation()
+ {
+ $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
+
+ $propertyDefinition = $classSchema->getProperty('propertyWithCascadeAnnotationWithoutVarAnnotation');
+ static::assertNull($propertyDefinition['annotations']['cascade']);
+ }
}
* @transient
*/
public $propertyWithTransientAnnotation;
+
+ /**
+ * @var DummyClassWithAllTypesOfProperties
+ * @cascade remove
+ */
+ public $propertyWithCascadeAnnotation;
+
+ /**
+ * @cascade remove
+ */
+ public $propertyWithCascadeAnnotationWithoutVarAnnotation;
}
'Deprecation-83092-ReplaceTransientWithTYPO3CMSExtbaseAnnotationORMTransient.rst',
],
],
+ '@cascade' => [
+ 'restFiles' => [
+ 'Feature-83093-ReplaceCascadeWithTYPO3CMSExtbaseAnnotationORMCascade.rst',
+ 'Deprecation-83093-ReplaceCascadeWithTYPO3CMSExtbaseAnnotationORMCascade.rst',
+ ],
+ ],
];