Exemplo n.º 1
0
 /**
  * Loads a list of related objects.
  *
  * @param string $relationName name of the desired relation
  * @param GenericCriterionObject $criterion criterion object
  *
  * @return GenericORMapperDataObject[] List of objects that are related with the current object or null.
  * @throws GenericORMapperException In case the data component is not initialized.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 15.04.2008<br />
  * Version 0.2, 15.06.2008 (If data component is not initialized, the method now returns null)<br />
  * Version 0.3, 16.06.2008 (Caching of objects disabled, due to recursion errors)<br />
  * Version 0.4, 25.06.2008 (Added a second parameter to have influence on the loaded list)<br />
  */
 public function loadRelatedObjects($relationName, GenericCriterionObject $criterion = null)
 {
     // check weather data component is there
     if ($this->dataComponent === null) {
         throw new GenericORMapperException('[GenericDomainObject::loadRelatedObjects()] ' . 'The data component is not initialized, so related objects cannot be loaded! ' . 'Please use the or mapper\'s loadRelatedObjects() method or call ' . 'setDataComponent($orm), where $orm is an instance of the or mapper, on this ' . 'object first!', E_USER_ERROR);
     }
     // return objects that are related to the current object
     return $this->dataComponent->loadRelatedObjects($this, $relationName, $criterion);
 }
Exemplo n.º 2
0
 /**
  * Deletes the given entry from the database.
  *
  * @param Entry $domEntry The guestbook entry to delete.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 21.05.2009<br />
  */
 public function deleteEntry(Entry $domEntry)
 {
     $entry = new GenericDomainObject('Entry');
     $entry->setProperty('EntryID', $domEntry->getId());
     // Delete the attributes of the entry, so that the object
     // itself can be deleted. If we don't do this, the ORM
     // will not be glad, because the entry still has child objects!
     $attributes = $this->orm->loadRelatedObjects($entry, 'Entry2LangDepValues');
     foreach ($attributes as $attribute) {
         $this->orm->deleteObject($attribute);
     }
     // delete associated users, because we don't need them anymore.
     $users = $this->orm->loadRelatedObjects($entry, 'Editor2Entry');
     foreach ($users as $user) {
         $this->orm->deleteObject($user);
     }
     // now delete entry object (associations are deleted automatically)
     $this->orm->deleteObject($entry);
 }