[TYPO3-dev] Extbase Default Getter of 1:n Relation

Philipp Schiffmann p.schiffmann at bitmotion.de
Wed Oct 15 09:09:10 CEST 2014


Hi Till,

if fluid encounters {book.introduction} in a template it resolves the
corresponding method with a simple naming convention: 'get' .
ucfirst($attribute)
You can access any method that conforms to this convention, even if your
model doesn't have an according property. You can do whatever you like in
these getters, for example:

public function getIntroduction() {
  foreach ($this->chapters as $chapter) {
    if ($chapter->getName() == 'introduction') return $chapter;
  }
  return NULL;
}

Note that your getter methods mustn't have parameters, like:
public function getChapter($chapterName) { /* ... */ }

Cheers,
Philipp



More information about the TYPO3-dev mailing list