[TYPO3-mvc] Map parameters to Extbase controller action even if record is hidden

Jonas Eberle jonas.eberle at d-mind.de
Thu Dec 11 16:13:37 CET 2014


Hi Helmut!

Am 11.12.2014 um 13:45 schrieb Helmut Hummel:
>> I have an edit-action that should be able to edit hidden records.
>
>> Do you have an idea how I could get property mapping also for deleted
>> records?
Sorry, I just realized i mixed up deleted and hidden here. I only mean 
HIDDEN records.

> If you also need hidden records to be mapped directly to your action 
> method, you currently need to create your own TypeConverter that 
> fetches such records from persistence.
>
> I would suggest to subclass PersistentObject converter, give your own 
> TypeConverter a higher priority and override the 
> fetchObjectFromPersistence[1] method to fit your needs.
>
> [1]https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/extbase/Classes/Property/TypeConverter/PersistentObjectConverter.php#L202 
>
>
Thank you for that clear answer! I was hoping for something simpler, 
though but that is totally not your fault. You know what you are talking 
about here and I wish I was into it as much as you.

It is not clear to me how I should alter this line in my 
reimplementation of PersistentObjectConverter
$object = $this->persistenceManager->getObjectByIdentifier($identity, 
$targetType);
to return hidden records.

-----

I might go back from all automatic Extbase parameter mapping to just 
plain uids. As a bonus I might get just a bit more control over my code 
if I write it more explicitely instead of the implicit stuff that 
Extbase does.

What I could do now is this:

     /**
      * @param int $someModelUid
      *
      * @return void
      */
     public function editAction( $someModelUid ) {
         // fetch object
         $q = $this->repo->createQuery();
         $q->getQuerySettings()->setIgnoreEnableFields( true );
         $constraints = $q->equals('uid', (int) $someModelUid);
         $someModel = $q->matching($constraints)->execute()->getFirst();
         ... access checks for the editAction()
         ...
     }

<rant>
It would totally defeat the goal of using Extbase in the beginning and 
mixing coding paradigms is totally bad style, but in the case of 
parameter mapping I just don't see Extbase making me any more efficient 
any more. I just went through forms with file-uploads and editable n:m 
properties and the amount of initializeXXXAction() plus TypeConverters 
and UploadViewhelpers I wrote is kind of ridiculous compared to the 
things they achieve.
I really guess I'll stay away from all annotation-based Extbase stuff - 
it just feels that if you just need something a tiny bit different you 
need to go deep into the stack. All while writing explicit code would 
only take 4 lines.
</rant>

Cordially,
Jonas


More information about the TYPO3-project-typo3v4mvc mailing list