Created
July 5, 2012 10:25
-
-
Save econic/3052834 to your computer and use it in GitHub Desktop.
Fake bidirectional MM table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tx_ext_Domain_Model_Category extends Tx_Extbase_DomainObject_AbstractEntity { | |
/** | |
* returns all the FAQs linked with this Category | |
* | |
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_ext_Domain_Model_Faq> | |
*/ | |
public function getFaqs() { | |
return t3lib_div::makeInstance('Tx_ext_Domain_Repository_FaqRepository')->byCategory($this); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tx_ext_Domain_Model_Faq extends Tx_Extbase_DomainObject_AbstractEntity { | |
/** | |
* Categories | |
* | |
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_ext_Domain_Model_Category> | |
*/ | |
protected $categories; | |
/** | |
* Returns the categories | |
* | |
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_ext_Domain_Model_Category> $categories | |
*/ | |
public function getCategories() { | |
return $this->categories; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tx_ext_Domain_Repository_FaqRepository extends Tx_Extbase_Persistence_Repository { | |
public function byCategory(Tx_ext_Domain_Model_Category $category) { | |
$query = $this->createQuery(); | |
$query->matching( $query->contains('categories', $category) ); | |
return $query->execute(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
your FAQ {faq} has the categories {faq.categories} | |
your Category {category} has the FAQs {category.faqs} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment