So jetzt noch mal von vorn, in der Hoffnung, dass es jetzt verständlicher ist.
Ich möchte über die symmetrische Relation folgendes erreichen. Wenn ich einer Person A eine Beziehung zu einer Person B zuweise, soll automatisch auch eine Beziehung von Person B nach Person A angelegt werden.
Funktioniert auch prima im Backend. Im Frontend wird folgender Fehler angezeigt:
Unknown column 'tx_osw_domain_model_person.beziehung_von' in 'where clause'
Mein Model:
class Person extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* name
*
* @var string
* @validate NotEmpty
*/
protected $name = '';
/**
* beziehung
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Osw\Osw\Domain\Model\Person>
*/
protected $beziehung = NULL;
/**
* __construct
*/
public function __construct() {
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Initializes all ObjectStorage properties
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*
* @return void
*/
protected function initStorageObjects() {
$this->beziehung = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
/**
* Returns the name
*
* @return string $name
*/
public function getName() {
return $this->name;
}
/**
* Sets the name
*
* @param string $name
* @return void
*/
public function setName($name) {
$this->name = $name;
}
/**
* Adds a beziehung
*
* @param \Osw\Osw\Domain\Model\Person $beziehung
* @return void
*/
public function addBeziehung(\Osw\Osw\Domain\Model\Person $beziehung) {
$this->beziehung->attach($beziehung);
}
/**
* Removes a beziehung
*
* @param \Osw\Osw\Domain\Model\Person $beziehungToRemove The Person to be removed
* @return void
*/
public function removeBeziehung(\Osw\Osw\Domain\Model\Person $beziehungToRemove) {
$this->beziehung->detach($beziehungToRemove);
}
/**
* Returns the beziehung
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Osw\Osw\Domain\Model\Person> $beziehung
*/
public function getBeziehung() {
return $this->beziehung;
}
/**
* Sets the beziehung
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Osw\Osw\Domain\Model\Person> $beziehung
* @return void
*/
public function setBeziehung(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $beziehung) {
$this->beziehung = $beziehung;
}
}
TCA der Person:
$GLOBALS['TCA']['tx_osw_domain_model_person'] = array(
'ctrl' => $GLOBALS['TCA']['tx_osw_domain_model_person']['ctrl'],
'interface' => array(...),
'types' => array(...),
'palettes' => array(...),
),
'columns' => array(
'name' => array(
'exclude' => 1,
'label' => 'LLL:EXT:osw/Resources/Private/Language/locallang_db.xlf:tx_osw_domain_model_person.name',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim,required'
),
),
'beziehung' => array(
'exclude' => 1,
'label' => 'LLL:EXT:osw/Resources/Private/Language/locallang_db.xlf:tx_osw_domain_model_person.beziehung',
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_osw_person_symmetric_mm',
'foreign_field' => 'beziehung_von',
'foreign_sortby' => 'sorting_beziehung_von',
'symmetric_field' => 'beziehung_zu',
'symmetric_sortby' => 'sorting_beziehung_zu',
),
),
),
);
TCA der Zwischentabelle:
$GLOBALS['TCA']['tx_osw_person_symmetric_mm'] = array(
'ctrl' => $GLOBALS['TCA']['tx_osw_person_symmetric_mm']['ctrl'],
'interface' => array(...),
'types' => array(...),
'palettes' => array(...),
),
'columns' => array(
'beziehung_von' => array(
'exclude' => 0,
'label' => 'beziehung_von',
'config' => array(
'type' => 'input',
'foreign_table' => 'tx_osw_domain_model_person',
'minitems' => 0,
'maxitems' => 1,
),
),
'sorting_person' => array(
'exclude' => 0,
'config' => array(
'type' => 'passthrough',
),
),
'beziehung_zu' => array(
'exclude' => 0,
'label' => 'beziehung_zu',
'config' => array(
'type' => 'input',
'foreign_table' => 'tx_osw_domain_model_person',
'minitems' => 0,
'maxitems' => 1,
),
),
'sorting_beziehung_zu' => array(
'exclude' => 0,
'config' => array(
'type' => 'passthrough',
),
),
),
);