src/Model/ChangeLog.php
public function add(
        $sVerb,
        $sArticle,
        $sItem,
        $iItemId,
        $sTitle,
        $sUrl = null,
        $sField = null,
        $mOldValue = null,
        $mNewValue = null,
        $bStrict = true
    ) {
        /**
         * if the old_value and the new_value are the same then why are you logging
         * a change!? Lazy [read: efficient] dev.
         */

        if (!is_null($sField)) {

            if (!is_string($mNewValue)) {
                $mNewValue = print_r($mNewValue, true);
            }

            if (!is_string($mOldValue)) {
                $mOldValue = print_r($mOldValue, true);
            }

            $mNewValue = trim($mNewValue);
            $mOldValue = trim($mOldValue);

            if ($bStrict && $mNewValue === $mOldValue) {
                return false;
            } elseif ($mNewValue == $mOldValue) {
                return false;
            }
        }

        // --------------------------------------------------------------------------

        /**
         * Define the key for this change; keys should be common across identical
         * items so we can group changes of the same item together.
         */
        $key = md5(activeUser('id') . '|' . $sVerb . '|' . $sArticle . '|' . $sItem . '|' . $iItemId . '|' . $sTitle . '|' . $sUrl);

        if (empty($this->aChanges[$key])) {
            $this->aChanges[$key] = [
                'user_id' => activeUser('id') ? activeUser('id') : null,
                'verb'    => $sVerb,
                'article' => $sArticle,
                'item'    => $sItem,
                'item_id' => $iItemId,
                'title'   => $sTitle,
                'url'     => $sUrl,
                'changes' => [],
            ];
        }

        // --------------------------------------------------------------------------

        /**
         * Generate a subkey, so that multiple calls to the same field overwrite
         * each other
         */
        if ($sField) {
            $this->aChanges[$key]['changes'][md5($sField)] = (object) [
                'field'     => $sField,
                'old_value' => $mOldValue,
                'new_value' => $mNewValue,
            ];
        }

        // --------------------------------------------------------------------------

        //  If we're not saving  in batches then save now
        if (!$this->bBatchSave) {
            $this->save();
        }

        return true;
    }
public function add(
        $sVerb,
        $sArticle,
        $sItem,
        $iItemId,
        $sTitle,
        $sUrl = null,
        $sField = null,
        $mOldValue = null,
        $mNewValue = null,
        $bStrict = true
    ) {
        /**
         * if the old_value and the new_value are the same then why are you logging
         * a change!? Lazy [read: efficient] dev.
         */

        if (!is_null($sField)) {

            if (!is_string($mNewValue)) {
                $mNewValue = print_r($mNewValue, true);
            }

            if (!is_string($mOldValue)) {
                $mOldValue = print_r($mOldValue, true);
            }

            $mNewValue = trim($mNewValue);
            $mOldValue = trim($mOldValue);

            if ($bStrict && $mNewValue === $mOldValue) {
                return false;
            } elseif ($mNewValue == $mOldValue) {
                return false;
            }
        }

        // --------------------------------------------------------------------------

        /**
         * Define the key for this change; keys should be common across identical
         * items so we can group changes of the same item together.
         */
        $key = md5(activeUser('id') . '|' . $sVerb . '|' . $sArticle . '|' . $sItem . '|' . $iItemId . '|' . $sTitle . '|' . $sUrl);

        if (empty($this->aChanges[$key])) {
            $this->aChanges[$key] = [
                'user_id' => activeUser('id') ? activeUser('id') : null,
                'verb'    => $sVerb,
                'article' => $sArticle,
                'item'    => $sItem,
                'item_id' => $iItemId,
                'title'   => $sTitle,
                'url'     => $sUrl,
                'changes' => [],
            ];
        }

        // --------------------------------------------------------------------------

        /**
         * Generate a subkey, so that multiple calls to the same field overwrite
         * each other
         */
        if ($sField) {
            $this->aChanges[$key]['changes'][md5($sField)] = (object) [
                'field'     => $sField,
                'old_value' => $mOldValue,
                'new_value' => $mNewValue,
            ];
        }

        // --------------------------------------------------------------------------

        //  If we're not saving  in batches then save now
        if (!$this->bBatchSave) {
            $this->save();
        }

        return true;
    }
Adds a new changelog item

@param string  $sVerb     The verb, e.g "created"
@param string  $sArticle
@param string  $sItem
@param integer $iItemId   The item's ID (e.g the blog post's ID)
@param string  $sTitle    The title of the item (e.g the blog post's title)
@param string  $sUrl      The url to the item (e.g the blog post's URL)
@param string  $sField
@param mixed   $mOldValue The old value
@param mixed   $mNewValue The new value
@param boolean $bStrict   whether or not to compare $mOldValue and $mNewValue strictly

@return bool
@throws \Nails\Common\Exception\FactoryException
@throws \Nails\Common\Exception\ModelException