Deprecation: #100071 - Magic repository findBy() methods
See forge#100071
Description
Extbase repositories come with a magic __
method to allow calling
the following methods without implementing them:
find
By [Property Name] ($property Value) find
One By [Property Name] ($property Value) count
By [Property Name] ($property Value)
These have now been marked as deprecated, as they are "magic", meaning that proper IDE support is not possible, and other PHP-related tool functionality such as PhpStorm.
In addition, it is not possible for Extbase repositories to build their own magic method functionality as the logic is already in use.
Impact
As these methods are widely used in almost all Extbase-based extensions, they are marked as deprecated in TYPO3 v12, but will only trigger a deprecation notice in TYPO3 v13, as they will be removed in TYPO3 v14.
This way, migration towards the new API methods can be made without pressure.
Affected installations
All installations with third-party extensions that use those magic methods.
Migration
A new set of methods without all the downsides have been added:
find
By (array $criteria, ...): Query Result Interface find
One By (array $criteria, ...): object |null count
(array $criteria, ...): int
The naming of the methods follows those of doctrine/
and only
count
differs from the formerly count
. While all magic
methods only allow for a single comparison (property
= property
),
those methods allow for multiple comparisons, called constraints.
find
can be replaced with a call to find
:
$this->blogRepository->findBy(['propertyName' => $propertyValue]);
find
can be replaced with a call to find
:
$this->blogRepository->findOneBy(['propertyName' => $propertyValue]);
count
can be replaced with a call to count
:
$this->blogRepository->count(['propertyName' => $propertyValue]);