Skip to content

Instantly share code, notes, and snippets.

@loicfrering
Created January 19, 2011 19:11
Show Gist options
  • Save loicfrering/786657 to your computer and use it in GitHub Desktop.
Save loicfrering/786657 to your computer and use it in GitHub Desktop.
<?php
/** @Service */
class ItemRepository extends LoSo_Doctrine_ORM_Tools_Dao_GenericDao
{
$this->entityName = 'Application_Model_User';
// Particular finder implemented with a DQL query
public function findByCategory($category)
{
$q = $this->createQueryBuilder('i')
->where(':category MEMBER OF i.categories')
->getQuery();
return $q->execute(array('category' => $category));
}
}
<?php
/** @Service */
class OrderService
{
/** @Inject */
private $userRepository;
public function setUserRepository($userRepository)
{
$this->userRepository = $userRepository;
return $this;
}
/** @Inject */
private $itemRepository;
public function setItemRepository($itemRepository)
{
$this->itemRepository = $itemRepository;
return $this;
}
/**
* Add business methods which may use the two injected
* repositories and manage transactions.
*/
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment