evoWeb / store_finder

Store finder extension for TYPO3
GNU General Public License v2.0
2 stars 9 forks source link

Problem with dependency injection #41

Closed itx-stefanie-doell closed 1 year ago

itx-stefanie-doell commented 1 year ago

Hi, first of all - thanks a lot for your extension, we use it several years now. Right now I'm working on an update to TYPO3 11 (PHP 8.1) - in my project I wrote a custom import, which uses the GeocodeService to calculate the long&lat for importet stores. Because of the update I changed my code to include the geocodeService via dependency injection. This results in the following error: Class "TYPO3\CMS\Core\Cache\Frontend\Frontend" does not exist. Reflection failed. caused by the dependency injections of the coordinatesCache class.

My suggestion for a solution would be:

And afterwards use $this->cacheFrontend in the getInstance() Function as well.

For now I will overwrite the Coordinates Cache class, but I would be really happy to know If you have other suggestions to solve this problem.

Thanks a lot!

garbast commented 1 year ago

You need to rebuild the autoload of the system, after that the cache should work. There are configurations in the Services.yaml that need to be loaded.

https://github.com/evoWeb/store_finder/blob/fcda9815f77ceb8017de26efe67b8e455aeb0fc6/Configuration/Services.yaml#L11

itx-stefanie-doell commented 1 year ago

I already rebuild the autoload system, but I think that does not change that I don't have the Frontend variable present for injection in the backend, or is this a misunderstanding?

garbast commented 1 year ago

If you take a close look you'll see that it asks for TYPO3\CMS\Core\Cache\Frontend\Frontend which is a core class.

A cache consists of a backend and a frontend. The backend accesses the database or the file system and the frontend provides the api to access the cache.

Cache\Frontend\Frontend has nothing to do with the website frontend.