0
votes

I followed Creating a first extension but I'm getting 500 error and:

[Tue Mar 14 09:45:42 2017] [warn] mod_fcgid: stderr: PHP Fatal error:
Call to a member function createQueryForType() on null in /var/typo3_src/typo3_src-6.2.29/typo3/sysext/extbase/Classes/Persistence/Repository.php on line 251

Server PHP 5.6 and Typo3 6.2.29

Repository code:

<?php
namespace MyVendor\MyExt\Domain\Repository;

use \TYPO3\CMS\Extbase\Persistence\Repository;

class UserRepository extends Repository {
    public function __construct() {
    }
}

Controller action:

public function getOnlineUsersAction() {
    $userRepository = GeneralUtility::makeInstance(UserRepository::class);
    $users = $userRepository->findAll();
    // todo
}
1

1 Answers

1
votes

Try:

Repository code:

<?php
namespace MyVendor\MyExt\Domain\Repository;

use \TYPO3\CMS\Extbase\Persistence\Repository;

class UserRepository extends Repository {
    // Remove the __construct (or add parent::__construct)
}

Controller code:

/**
 * @var MyVendor\MyExt\Domain\Repository\UserRepository
 * @inject
 */
$protected $userRepository;

public function getOnlineUsersAction() {
    $users = $this->userRepository->findAll();
    // todo
}