/** * Get the ChangeSetItems that reference a passed DataObject * * @param int $objectID The ID of the object * @param string $objectClass The class of the object (or any parent class) * @return DataList */ public static function get_for_object_by_id($objectID, $objectClass) { return ChangeSetItem::get()->filter(['ObjectID' => $objectID, 'ObjectClass' => static::getSchema()->baseDataClass($objectClass)]); }
/** * Remove an item from this changeset. Will automatically remove all changes * which own (and thus depend on) the removed item. * * @param DataObject $object */ public function removeObject(DataObject $object) { $item = ChangeSetItem::get()->filter(['ObjectID' => $object->ID, 'ObjectClass' => $object->baseClass(), 'ChangeSetID' => $this->ID])->first(); if ($item) { // TODO: Handle case of implicit added item being removed. $item->delete(); } $this->sync(); }