protected function _saveRevision(Entity $entity)
    {
        if ($entity->isNew()) {
            return;
        }

        try {
            $prev = TableRegistry::get('Content.Contents')->get($entity->id);
            $hash = $this->_calculateHash($prev);
            $exists = $this->ContentRevisions->exists([
                'ContentRevisions.content_id' => $entity->id,
                'ContentRevisions.hash' => $hash,
            ]);

            if (!$exists) {
                $revision = $this->ContentRevisions->newEntity([
                    'content_id' => $prev->id,
                    'summary' => $entity->get('edit_summary'),
                    'data' => $prev,
                    'hash' => $hash,
                ]);

                if (!$this->ContentRevisions->hasBehavior('Timestamp')) {
                    $this->ContentRevisions->addBehavior('Timestamp');
                }
                $this->ContentRevisions->save($revision);
            }
        } catch (\Exception $ex) {
            // unable to create content's review
        }
    }
protected function _saveRevision(Entity $entity)
    {
        if ($entity->isNew()) {
            return;
        }

        try {
            $prev = TableRegistry::get('Content.Contents')->get($entity->id);
            $hash = $this->_calculateHash($prev);
            $exists = $this->ContentRevisions->exists([
                'ContentRevisions.content_id' => $entity->id,
                'ContentRevisions.hash' => $hash,
            ]);

            if (!$exists) {
                $revision = $this->ContentRevisions->newEntity([
                    'content_id' => $prev->id,
                    'summary' => $entity->get('edit_summary'),
                    'data' => $prev,
                    'hash' => $hash,
                ]);

                if (!$this->ContentRevisions->hasBehavior('Timestamp')) {
                    $this->ContentRevisions->addBehavior('Timestamp');
                }
                $this->ContentRevisions->save($revision);
            }
        } catch (\Exception $ex) {
            // unable to create content's review
        }
    }
protected function _saveRevision ( Entity $ entity ) { if ( $ entity -> isNew ( ) ) { return ; } try { $ prev = TableRegistry :: get ( 'Content.Contents' ) -> get ( $ entity -> id ) ; $ hash = $ this -> _calculateHash ( $ prev ) ; $ exists = $ this -> ContentRevisions -> exists ( [ 'ContentRevisions.content_id' => $ entity -> id , 'ContentRevisions.hash' => $ hash , ] ) ; if ( ! $ exists ) { $ revision = $ this -> ContentRevisions -> newEntity ( [ 'content_id' => $ prev -> id , 'summary' => $ entity -> get ( 'edit_summary' ) , 'data' => $ prev , 'hash' => $ hash , ] ) ; if ( ! $ this -> ContentRevisions -> hasBehavior ( 'Timestamp' ) ) { $ this -> ContentRevisions -> addBehavior ( 'Timestamp' ) ; } $ this -> ContentRevisions -> save ( $ revision ) ; } } catch ( \ Exception $ ex ) { // unable to create content's review } }
Tries to create a revision for the given content.

@param \Cake\ORM\Entity $entity The content
@return void
Tries to create a revision for the given content .