[TYPO3-mvc] How to use an own storage backend / repository

chris Wolff chris at connye.com
Tue Sep 17 13:50:08 CEST 2013


Hi Stefano,

you could switch the storage backen on an per page basis. via
typoscript. but currently there is no offical way to support
storageBackends on per extension or model level.

for one of my clients i had hacked such a think but i wasn't able to
release the code as its currently hackish and client specific. if i
find the time i might releas it at a later point.

but i can give you an overview of my concept. maybe this helps you get
started with:

i implemented a Proxy StorageBackend (StorageBackendSwitcher) wich
selects the right backend for every model.
and set this StorageBackendSwitcher as the defaultStorageBacken in
extbase via typoscript:

config.tx_extbase.objects {
  # Setting the extbase storage backend implentation to use
  Tx_Extbase_Persistence_Storage_BackendInterface.className =
Tx_UserKimBase_Persistence_Storage_StorageBackendSwitcher
  # give my StorageBackendSwitcher an defaultStorage Backend so every
extbase extension would work as bevore
  Tx_UserKimBase_Persistence_Storage_StorageBackendSwitcher.defaultStorageBackend
= Tx_Extbase_Persistence_Storage_Typo3DbBackend
}


if i have a model wich needs a different storage backend i define it
also via typoscript by encoding the storagebackend name into the table
name:

config.tx_extbase.persistence.classes.Tx_UserKimAersignup_Domain_Model_KimSignup.mapping
{
  tableName = Tx_UserKimBase_Persistence_Storage_KimDbBackend->tblOnlineAnmeld
}


as there is no clean way to define such a thing.

the StorageBackendSwitcher then simply looks if the table name
contains an "->" if so it splits the table name in parts. and created
the backend class provided.
if not present the defaultStoragBackend is used.

this makes it possible to use multiple extbase plugins with different
storagebackends on the same page.
be aware that this solution has drawbacks! its no longer possible to
create relations between models in different storage backends.
as this soloution is not well tested there might be other problems arising.

regards chris









2013/9/17 Stefano Kowalke <blueduck at gmx.net>:
> Hey list,
>
> I write an extbase extension were no database is needed. Actually its just
> an frontend for a webapi.
>
> The extension consist of a searchform with a few filters and fires requests
> to the webapi (No SOAP, no Rest).
>
> In the background its just put together the api url with an api token, the
> current timestamp and the search paramenters and get XML as response.
>
> As far as I understand MVC this would be the job for an repository and and
> own storageBackend in Extbase.
>
> How can I replace the current storageBackend with my custom storageBackend
> which talks with the api?
>
> Thanks in advance
>
> Stefano
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



-- 
christian wolff - webdeveloper, tech-loving geek and typo3 enthusiast
telefon: +49 30 347 244 88
mobil:  +49 179 49 44 758
email: chris at connye.com
adresse: friedelstraße 31 - 12047 berlin

xing-profil: http://www.xing.com/profile/Christian_Wolff43
google+: https://plus.google.com/u/0/115669673917212236875/posts?hl=de
facebook: https://www.facebook.com/1stMachine
flattr: https://flattr.com/profile/1stmachine


More information about the TYPO3-project-typo3v4mvc mailing list