-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TASK] Add new page repository alias #1738
[TASK] Add new page repository alias #1738
Conversation
Because PageRepository has been moved with TYPO3 11 the class alias is created based on class existence.
Although this does solve the problem, using class_alias() this way will pollute the class namespaces - I suggest a different solution that doesn't require aliasing, perhaps best solved by making a class that resolves the right instance based on TYPO3 version and then use that class everywhere that PageRepository is used. PageRepository probably won't be the last class that gets moved or renamed, so having a version-sensitive way of resolving such classes imho makes sense. |
@NamelessCoder I've found this https://github.com/TYPO3/class-alias-loader in the core, would this be a solution that you accept? |
Use class alias loader to create composer autoload entry's for deprecated classes.
@tobsnti Does this also work for non-composer installs of TYPO3, starting from 8.7? If it does then I'm OK with this solution. We should then also make sure that the new class name is used throughout the code. |
@NamelessCoder It's not working for non-composer installations. The config could be something like that: Another solution, which I would consider a bit dirty, would be a PHP file that is included based on the core version, which creates the removed FQCN with an extend on the current class.
|
Sorry for the delay here, @tobsnti - I've been very busy elsewhere. Re: this PR, I would very much prefer to have a Factory that gives us the right instance based on presence of one class or the other. Something like this (freestyle): class InstanceFactory {
/**
* @return \TYPO3\CMS\Frontend\Page\PageRepository|\TYPO3\CMS\Core\Domain\Repository\PageRepository
*/
public function getPageRepository()
{
if (class_exists(\TYPO3\CMS\Frontend\Page\PageRepository::class)) {
return GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
}
return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Domain\Repository\PageRepository::class);
}
} And then use this factory in all places where we need a PageRepository. Even though at first this |
I guess this will not properly work in the long run, at least IMHO
Here ->init() is called which is protected in v11, thus not callable. So this would need a workaround as well. I will llok after the holidays |
Because PageRepository has been moved with TYPO3 11 the class alias is created based on class existence.