[TYPO3-mvc] Get repository object from table name

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Jan 27 12:07:31 CET 2011


Hey Thomas,

>> resolve the correct repository based on the table name and then fetch it.
>
> Hey ho!
>
> That's exactly what I need to know - is there a method/function
> which returns me the repository object when providing the table name, like:
>
> $repository = Magic::happens('tx_ext_domain_model_anytable');

you could give it a try - the Magic class is very powerful ;)

But to answer your question - I don't know of such a method (yet). In 
extbase code like this is used:

$modelClassName = t3lib_div::underscoredToUpperCamelCase($tableName);
$repositoryClassName = str_replace('_Model_', '_Repository_', 
$modelClassName) . 'Repository';


There might be such a method in future, because I think I might need it 
for the group support - but I'm not sure because the DataMapper doesn't 
use repositories to fetch related objects (but that could also change - 
there is a feature request IIRC).

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list