I have several Controllers like those: CategoryController and NewsController As well as the domain models for category and news and reposirtories for both.
In the NewsController I do a dependencyInjection like this (the same way as in categoryController):
/**
* categoryRepository
*
* @var Tx_MyExtension_Domain_Repository_CategoryRepository
*/
protected $categoryRepository;
/**
* injectCategoryRepository
*
* @param Tx_MyExtension_Domain_Repository_CategoryRepository $CategoryRepository
* @return void
*/
public function injectCategoryRepository(Tx_MyExtension_Domain_Repository_CategoryRepository $categoryRepository) {
$this->categoryRepository = $categoryRepository;
}
When I'm trying now in a function something like this:
/**
* action getCategoriesAjax
*
* @param Tx_MyExtension_Domain_Model_News
* @return void
*/
public function getCategoriesAjaxAction() {
$categories = $this->categoryRepository->findAll();
$this->view->assign('categories',$categories);
}
I get an empty result back.
The strange thing for me is, that if I'm doing this in the CategoryController, the same function works like charm and returns all elements in the database and even stranger for me is, that if I do a $this->categoryRepository->findByUid(1) I get the correct element as result.
I also added to my categoryRepository a test function:
public function test(){
$query = $this->createQuery();
$result = $query->execute();
$amount = $result.count();
}
If I call this function from categoryController, I get back the correct amount of elements. If I'm calling this from my newsController I get "0" back...
I don't get it...
What do I miss??? Where is my mistake?