src/Charcoal/Object/ObjectRevision.php
public function createFromObject(RevisionableInterface $obj)
    {
        $prevRev = $this->lastObjectRevision($obj);

        $this->setTargetType($obj->objType());
        $this->setTargetId($obj->id());
        $this->setRevNum($prevRev->revNum() + 1);
        $this->setRevTs('now');

        if (is_callable([$obj, 'lastModifiedBy'])) {
            $this->setRevUser($obj->lastModifiedBy());
        }

        $this->setDataObj($obj->data());
        $this->setDataPrev($prevRev->dataObj());

        $diff = $this->createDiff();
        $this->setDataDiff($diff);

        return $this;
    }
public function createFromObject(RevisionableInterface $obj)
    {
        $prevRev = $this->lastObjectRevision($obj);

        $this->setTargetType($obj->objType());
        $this->setTargetId($obj->id());
        $this->setRevNum($prevRev->revNum() + 1);
        $this->setRevTs('now');

        if (is_callable([$obj, 'lastModifiedBy'])) {
            $this->setRevUser($obj->lastModifiedBy());
        }

        $this->setDataObj($obj->data());
        $this->setDataPrev($prevRev->dataObj());

        $diff = $this->createDiff();
        $this->setDataDiff($diff);

        return $this;
    }
Create a new revision from an object

1. Load the last revision
2. Load the current item from DB
3. Create diff from (1) and (2).

@param RevisionableInterface $obj The object to create the revision from.
@return ObjectRevision Chainable