0

I have a Typo3 Extension (Typo3 CMS 6.2) and I want to access the repository globalSettingsRepository from a PHP file which is located in /Resource/PHP/.

The dependency injection does not work although I cleared the cache:

/**
 * globalSettingsRepository
 *
 * @var \TYPO3\Institutsvideoverwaltung\Domain\Repository\GlobalSettingsRepository
 * @inject
 */
public $globalSettingsRepository = NULL;

The namespace of the PHP is the same as my controllers.

I have also tried this in order to create an instance of the globalSettingsRepository:

$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');

Which does not work either because /TYPO3/CMS/... was not found.

Does anyone have a solution? Is there even a way to access a repository from /Resources?

Thanks alot.

lorenz
  • 4,538
  • 1
  • 27
  • 45
arifCee
  • 509
  • 2
  • 12
  • i am not getting you exactly but i think your are looking for this.http://stackoverflow.com/questions/30839907/how-to-get-typo3-settings-in-the-utility-files/30839969#30839969 – Vishal Tanna Dec 10 '15 at 11:40
  • @Vishal Thanks for your answer but actually I am trying the option with \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager'); which does not work :( – arifCee Dec 10 '15 at 13:55

1 Answers1

0

There are some things that should be fixed in your extension.

First of all, you should not use TYPO3 as vendor for your extension. This is only for the core and official extensions.

Second, you must stick to conventions.

\TYPO3\Institutsvideoverwaltung\Domain\Repository\GlobalSettingsRepository

This means that you must have a class called \TYPO3\Institutsvideoverwaltung\Domain\Repository\GlobalSettingsRepository at the following path: /typo3conf/ext/institutsvideoverwaltung/Classes/Domain/Repository/GlobalSettingsRepository.php.

It seems that you don't and instead put it in Resources/PHP.

If you want to use a class from Resources/PHP, you need to either include it manually using require_once() or you need to make sure that your class is autoloaded properly. The requirements for autoloading changed from version 6 to 7, so you need to state which version you're using. Nevertheless it doesn't make sense to break convention and then have a lot of effort of there is a simple way.

lorenz
  • 4,538
  • 1
  • 27
  • 45
  • The GlobalSettingsRepository is located at the path you just posted. One file is located in the folder Repository (the GlobalSettingsRepo.php) and the other one (also a PHP file) is at Resources/Private/PHP/. And I think my problem is to build a connection between these two locations. The version is as is posted Typo3 CMS 6.2 with Extbase 6.2. – arifCee Dec 10 '15 at 13:57