[TYPO3-dev] [TYPO3-DEV] 4.5: How to read constraint(s) in query

Maxime Roussin-Bélanger mroussin at hotmail.com
Fri May 23 17:19:16 CEST 2014


I need to use a REST service in order to get some data to a plugin. In order to do so, I have overriden the normal backend interface in typoscript with the following command :

objects.Tx_Extbase_Persistence_Storage_BackendInterface.className = Tx_extensionname_Persistence_Storage_RestBackend

This BackendInterface then returns Query Objects in my repository when I use to following:

Ex:

$query = $this->createQuery();
$query = $query->execute()->toArray();

Here, $query holds the response from the service as a TYPO3 Tx_Extbase_Persistence_QueryInterface object.

The problem is that I need to be able to do a call to the service while passing an ID parameter (appending to the endpoint with /ID). Ideally, I would do it in such a way that this repo function (called in the controller) would return what I want :

public function findById( $id ) {
    $query = $this->createQuery();

    $query->matching($query->equals('id', $id));

    return $query->execute()->toArray();
}

The problem is that I need to be able to access the query constraint within my Tx_extensionname_Persistence_Storage_RestBackend. Normally, I would use the '$query->getConstraint()' method. However, we are using typo3 4.5 and this function is not yet defined for Tx_Extbase_Persistence_QueryInterface.

Modifying the typo3 core to add this function is not an option.

I tried to extend the Query Interface to add this functionnality in a subclass in order to then override the class in typoscript but then realized this wouldn't be portable enough. I need to be able to access the query constraint only using typo3 4.5 native functionnalities.

Here the stackoverflow question with <pre> tags 




More information about the TYPO3-dev mailing list