|
Verfasst am: 03. 08. 2010 [14:29]
|
|
steini18778
Themenersteller
Dabei seit: 03.08.2010
Beiträge: 2
|
Hallo liebe Typo3 Gemeinde,
ich sitze nun schon eine ganze Weile an einem für mich seltsamen Problem. Ich habe eine Tabelle mit Autoren und eine Tabelle mit Institutionen. Dabei kann wird in der Autoren Tabelle die ID der Institution gespeichert.
Mittels des Backendes kann ich problemlos alles anlegen und mittels des Wizards verknüpfen. Ich gehe also vorerst davon aus, das mein Model richtig ist (habs mit dem Kickstarter gebaut).
Nun habe ich das Problem, das wenn ich über das Repository einen Autor anlegen will, die Institution nicht angelegt wird.
Ich habe mir auch das schon das Blog Beispiel angesehen und die Relation zwischen Post und Author ist eigentlich identisch, wobei der Post meinem Autor entspricht.
Folgendender Code sollte eine Institution anlegen.
$author = new Tx_Tanmarkongress_Domain_Model_Author();
$author->setName('Name');
$author->setMail('maol@google.de');
$institution = new Tx_Tanmarkongress_Domain_Model_Institution();
$institution->setName('HU Berlin');
$institution->setDescription('Test');
$author->setInstitutions($institution);
$authorRepository = t3lib_div::makeInstance('Tx_Tanmarkongress_Domain_Repository_AuthorRepository');
$authorRepository->add($author);
[Dieser Beitrag wurde 1mal bearbeitet, zuletzt am 03.08.2010 um 14:30.]
|
|
Verfasst am: 03. 08. 2010 [14:46]
|
|
steini18778
Themenersteller
Dabei seit: 03.08.2010
Beiträge: 2
|
Einzeln angelegt würde es funktionieren, nur das ich über "set" nicht beide gleichzeitig anlegen kann.
Hier mal beide Modelle
class Tx_Tanmarkongress_Domain_Model_Author extends Tx_Extbase_DomainObject_AbstractValueObject {
/**
* Name des Authors
* @var string
*/
protected $name;
/**
* E-Mail Adresse des Authors
* @var string
*/
protected $mail;
/**
* @var Tx_Tanmarkongress_Domain_Model_Institution
*/
protected $institutions;
/**
* Setter for Name
*
* @param string $Name Name des Authors
* @return void
*/
public function setName($Name) {
$this->name = $Name;
}
/**
* Getter for Name
*
* @return string Name des Authors
*/
public function getName() {
return $this->name;
}
/**
* Setter for Mail
*
* @param string $Mail E-Mail Adresse des Authors
* @return void
*/
public function setMail($Mail) {
$this->mail = $Mail;
}
/**
* Getter for Mail
*
* @return string E-Mail Adresse des Authors
*/
public function getMail() {
return $this->mail;
}
/**
* Setter for Institutions
*
* @param Tx_Tanmarkongress_Domain_Model_Institution $Institutions
* @return void
*/
public function setInstitutions(Tx_Tanmarkongress_Domain_Model_Institution $Institutions) {
$this->institutions = $Institutions;
}
/**
* Getter for Institutions
*
* @return Institutions
*/
public function getInstitutions() {
return $this->institutions;
}
}
class Tx_Tanmarkongress_Domain_Model_Institution extends Tx_Extbase_DomainObject_AbstractEntity {
/**
* Name der Institution
* @var string
*/
protected $name;
/**
* Kurzbeschreibung der Institution
* @var string
*/
protected $description;
/**
* Setter for Name
*
* @param string $Name Name der Institution
* @return void
*/
public function setName($Name) {
$this->name = $Name;
}
/**
* Getter for Name
*
* @return string Name der Institution
*/
public function getName() {
return $this->name;
}
/**
* Setter for description
*
* @param string $description Kurzbeschreibung der Institution
* @return void
*/
public function setDescription($description) {
$this->description = $description;
}
/**
* Getter for description
*
* @return string Kurzbeschreibung der Institution
*/
public function getDescription() {
return $this->description;
}
}
|
|
Verfasst am: 16. 08. 2010 [15:01]
|
|
super-mario
Dabei seit: 26.02.2007
Beiträge: 46
|
$author = new Tx_Tanmarkongress_Domain_Model_Author();
$author->setName('Name');
$author->setMail('maol@google.de');
$institution = new Tx_Tanmarkongress_Domain_Model_Institution();
$institution->setName('HU Berlin');
$institution->setDescription('Test');
// hier sollte erst die institution hinzugefügt werden, oder?
$institutionRepository = t3lib_div::makeInstance('Tx_Tanmarkongress_Domain_Repository_Institution');
$institutionRepository->add($institution);
//vlt. noch ne save methode aufrufen?
//
$author->setInstitutions($institution);
$authorRepository = t3lib_div::makeInstance('Tx_Tanmarkongress_Domain_Repository_AuthorRepository');
$authorRepository->add($author);
sollte doch eher so aussehen oder?
|