[TYPO3-mvc] How is the repository ment to be used?

Philipp philippwrann at gmx.at
Tue Mar 26 16:24:50 CET 2013


Hi, my very first TYPO3 extension is growing and getting more and more complicated. In my Repos i do querys  (for example) like this

/**
 * Find all having categories in a rectangle
 * @param mixed $categories
 * @param string $categoryMode
 * @param \Vendor\RegionalObject\Domain\Model\Geo\CoordsInterface $northWest
 * @param \Vendor\RegionalObject\Domain\Model\Geo\CoordsInterface $southEast
 * @param bool $excludeAllreadyDisplayed
 * @param int $limit
 */
public function findAllByCategoriesInRectangle($categories, $categoryMode, \Vendor\RegionalObject\Domain\Model\Geo\CoordsInterface $northWest, \Vendor\RegionalObject\Domain\Model\Geo\CoordsInterface $southEast, $excludeAllreadyDisplayed=FALSE,$limit=10) {
	$query = $this->createQuery();
	$constraints = array();
	$this->addFeaturesConstraints('catgegories', $categories, $constraints, $query, $categoryMode);
	$this->addRectangleConstraints($northWest, $southEast, $constraints, $query);
	$query->setLimit($limit);
	return $this->executeQuery($constraints, $query);
}

and i have many private (protected indeed) methods for extending my constraints. So far so good.
When having just a few very different queries its okay that way and i have a clean separated structure.

But in my case (the extension grows and grows and gets more "special cases" every day many of my public query methods look pretty much the same. Wouldnt it be better to make my method public and do it from controller side like

$query = $this->repo->getQuery();
..
$repo->addBlaConstraint();

Or would it be event better to only use one generic query, that takes one array parameter which could have every possible combination of constraints? That would be hard to extend i think.... 

Whats the most IDEAL approach, what would you suggest?

- i hate repeating myself over and over again -


More information about the TYPO3-project-typo3v4mvc mailing list