src/ChangeSet.php
public function addObject(DataObject $object)
    {
        if (!$this->isInDB()) {
            throw new BadMethodCallException("ChangeSet must be saved before adding items");
        }

        if (!$object->isInDB()) {
            throw new BadMethodCallException("Items must be saved before adding to a changeset");
        }

        $references = [
            'ObjectID' => $object->ID,
            'ObjectClass' => $object->baseClass(),
        ];

        // Get existing item in case already added
        $item = $this->Changes()->filter($references)->first();

        if (!$item) {
            $item = new ChangeSetItem($references);
            $this->Changes()->add($item);
        }

        $item->ReferencedBy()->removeAll();

        $item->Added = ChangeSetItem::EXPLICITLY;
        $item->write();

        $this->sync();
    }
public function addObject(DataObject $object)
    {
        if (!$this->isInDB()) {
            throw new BadMethodCallException("ChangeSet must be saved before adding items");
        }

        if (!$object->isInDB()) {
            throw new BadMethodCallException("Items must be saved before adding to a changeset");
        }

        $references = [
            'ObjectID' => $object->ID,
            'ObjectClass' => $object->baseClass(),
        ];

        // Get existing item in case already added
        $item = $this->Changes()->filter($references)->first();

        if (!$item) {
            $item = new ChangeSetItem($references);
            $this->Changes()->add($item);
        }

        $item->ReferencedBy()->removeAll();

        $item->Added = ChangeSetItem::EXPLICITLY;
        $item->write();

        $this->sync();
    }
public function addObject ( DataObject $ object ) { if ( ! $ this -> isInDB ( ) ) { throw new BadMethodCallException ( "ChangeSet must be saved before adding items" ) ; } if ( ! $ object -> isInDB ( ) ) { throw new BadMethodCallException ( "Items must be saved before adding to a changeset" ) ; } $ references = [ 'ObjectID' => $ object -> ID , 'ObjectClass' => $ object -> baseClass ( ) , ] ; // Get existing item in case already added $ item = $ this -> Changes ( ) -> filter ( $ references ) -> first ( ) ; if ( ! $ item ) { $ item = new ChangeSetItem ( $ references ) ; $ this -> Changes ( ) -> add ( $ item ) ; } $ item -> ReferencedBy ( ) -> removeAll ( ) ; $ item -> Added = ChangeSetItem :: EXPLICITLY ; $ item -> write ( ) ; $ this -> sync ( ) ; }
Add a new change to this changeset. Will automatically include all owned
changes as those are dependencies of this item.

@param DataObject $object
Add a new change to this changeset . Will automatically include all owned changes as those are dependencies of this item .