TYPO3 V11: "PHP warning: undefined array key", $this->request->getArguments() is empty
P粉807471604
P粉807471604 2023-11-12 21:35:09
0
1
964

I'm a new user of typo3, I made a plugin to display users and use the search bar to filter them, but when I want to display my page I get this error:

(1/1) #1476107295 TYPO3CMSCoreErrorException
PHP Warning: Undefined array key "word" in MyPath/Controller/UserlistController.php line 44

In my controller I try to get the parameter to use it in my filter like this:

public function listAction(int $currentPage = 1)
{
   $arguments = $this->request->getArguments();
   $users = $this->userlistRepository->findBySearch($arguments['word'] ? $arguments['word'] : '');

somecode ...

}

I tried dumping $arguments but it was empty

There is a section in my repository:

/**
     * @param string $word
     * @return object[]|TYPO3CMSExtbasePersistenceQueryResultInterface
     * @throws TYPO3CMSExtbasePersistenceExceptionInvalidQueryException
     */
    public function findBySearch(string $word) {
        $query = $this->persistenceManager->createQueryForType(TYPO3CMSExtbaseDomainModelFrontendUser::class);
        $querySettings = $query->getQuerySettings();
        $querySettings->setStoragePageIds([26]);
        $query->setQuerySettings($querySettings);

        $query->setOrderings([
            'lastName' => QueryInterface::ORDER_ASCENDING
        ]);

Does anyone know why I can't get the parameters? Thanks

If you need more parts of the code, please let me know

P粉807471604
P粉807471604

reply all(1)
P粉817354783

If you just call the List operation without sending the filter form, the parameter is empty.

You should test each expected parameter before accessing it, like this:

if($this->request->hasArgument('word')) {
        $searchOption = $this->request->getArgument('word'));
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!