0

I am currently trying to get a extension working in Typo3 v10, which enables the user to show, edit, update, disable and enable other user accounts.

Unfortunately, I am running into the issue that I cannot use disabled users as arguments for the actions:

/**
 * Save user changes
 *
 * @param \Company\MyExtension\Domain\FeUser $feuser
 * @return void
 */
public function updateAction(\Company\MyExtension\Domain\FeUser $feuser): void {}

It would resulting in the error following error: Object of type \Company\MyExtension\Domain\FeUser with identity "3" not found.

From what I have gathered, extbase does not rely on the repository's default query settings to create the objects but instead uses PersistenceManager::createQueryForType to get the query settings via QueryFactory::create. This is an issue also listed in a few bug reports.

There's a suggestions as to how to use a custom QueryFactory to set different default QuerySettings for my extension, however this does not seem to work in Typo3 v10 anymore, at least my custom QueryFactory isn't being used after registering it... Also, if this were to work, wouldn't it use the new QueryFactory for all objects instantiated through a controller action and not just this extension?

How can I properly handle hidden users my extension with Typo3 v10.4?

P.S. Another suggestion was to fetch object early through initializeAction, but this only works well if it is about the unmodified model and not when setting new values for the object, as it would just load the database values in the end...

Ceremony
  • 198
  • 2
  • 13
  • Passing objects via params assumes that your FeUser is not deleted or hidden (or disabled in anyw way like start/ed time) Instead of fetching the user as an action param, pass his UID and write a custom finder in the repository that avoids using the restrictions for disabled/deleted objects. – biesior Jun 22 '21 at 17:19
  • Finding the object manually would require me to manually map the changed values to the fetched object, skipping the functionality of extbase... – Ceremony Jun 23 '21 at 11:14

2 Answers2

0

Checkout the extension "news" how it is handled here:

        if ($news === null || $this->settings['isShortcut']) {
            $previewNewsId = ((int)$this->settings['singleNews'] > 0) ? $this->settings['singleNews'] : 0;
            if ($this->request->hasArgument('news_preview')) {
                $previewNewsId = (int)$this->request->getArgument('news_preview');
            }

            if ($previewNewsId > 0) {
                if ($this->isPreviewOfHiddenRecordsEnabled()) {
                    $news = $this->newsRepository->findByUid($previewNewsId, false);
                } else {
                    $news = $this->newsRepository->findByUid($previewNewsId);
                }
            }
        }

https://github.com/georgringer/news/blob/master/Classes/Controller/NewsController.php#L338

Georg Ringer
  • 7,779
  • 1
  • 16
  • 34
  • This skips the functionality extbase basically, thus the automatic mapping of changed values in the case of the updateAction would have to be reimplemented... not really a good solution. – Ceremony Jun 23 '21 at 11:12
0

I am assuming you need the URL as well. I gave an answer here if you wanna take a look.

Show, edit and update hidden records in FrontEnd (TYPO3)

You can adjust it to your own needs as well.

Best regards

Aristeidis Karavas
  • 1,891
  • 10
  • 29
  • I also found your suggestion, but as I described in the P.S. above, this doesn't do well when updating an object, as it just loads the entry in the database instead and doesn't carry over the changed new (sub)values of the object – Ceremony Jun 23 '21 at 07:22
  • actually it does. I used it myself to update the Ad i wanted the user to edit and then let the user to re enable the ad – Aristeidis Karavas Jun 23 '21 at 07:52
  • When I tried your suggestion, assigning the (hidden) object to $ad only made it available within the same context (initializeShowAction) and it did not carry over to the showAction method. I had to set the object via $this->request->setArgument("ad", $ad) instead to make it available in the showAction. Which is why I loose the changes as well... So what am I doing wrong? – Ceremony Jun 23 '21 at 08:14