public function addOrCreateBlame(&$blame = null, $user = null)
    {
        if (!is_string($this->multiBlamesClass)) {
            throw new InvalidConfigException
            ('$multiBlamesClass must be specified if you want to use multiple blameable features.');
        }
        if (is_array($blame) || $blame === null) {
            if ($user == null) {
                $user = $this->host;
            }
            $blame = static::getOrCreateBlame($blame, $user);
            if (!$blame->save()) {
                return false;
            }
            return $this->addBlame($blame->getGUID());
        }
        $blameGuid = '';
        if (is_string($blame)) {
            $blameGuid = $blame;
        }
        if ($blame instanceof $this->multiBlamesClass) {
            $blameGuid = $blame->getGUID();
        }
        if (($mbi = static::getBlame($blameGuid)) !== null) {
            return $this->addBlame($mbi);
        }
        return false;
    }
public function addOrCreateBlame(&$blame = null, $user = null)
    {
        if (!is_string($this->multiBlamesClass)) {
            throw new InvalidConfigException
            ('$multiBlamesClass must be specified if you want to use multiple blameable features.');
        }
        if (is_array($blame) || $blame === null) {
            if ($user == null) {
                $user = $this->host;
            }
            $blame = static::getOrCreateBlame($blame, $user);
            if (!$blame->save()) {
                return false;
            }
            return $this->addBlame($blame->getGUID());
        }
        $blameGuid = '';
        if (is_string($blame)) {
            $blameGuid = $blame;
        }
        if ($blame instanceof $this->multiBlamesClass) {
            $blameGuid = $blame->getGUID();
        }
        if (($mbi = static::getBlame($blameGuid)) !== null) {
            return $this->addBlame($mbi);
        }
        return false;
    }
public function addOrCreateBlame ( & $ blame = null , $ user = null ) { if ( ! is_string ( $ this -> multiBlamesClass ) ) { throw new InvalidConfigException ( '$multiBlamesClass must be specified if you want to use multiple blameable features.' ) ; } if ( is_array ( $ blame ) || $ blame === null ) { if ( $ user == null ) { $ user = $ this -> host ; } $ blame = static :: getOrCreateBlame ( $ blame , $ user ) ; if ( ! $ blame -> save ( ) ) { return false ; } return $ this -> addBlame ( $ blame -> getGUID ( ) ) ; } $ blameGuid = '' ; if ( is_string ( $ blame ) ) { $ blameGuid = $ blame ; } if ( $ blame instanceof $ this -> multiBlamesClass ) { $ blameGuid = $ blame -> getGUID ( ) ; } if ( ( $ mbi = static :: getBlame ( $ blameGuid ) ) !== null ) { return $ this -> addBlame ( $ mbi ) ; } return false ; }
Add specified blame, or create it before adding if doesn't exist.
But you should save the blame instance before adding it, or the operation
will fail.
@param {$this->multiBlamesClass}|string|array $blame
It will be regarded as blame's guid if it is a string. And assign the
reference parameter $blame the instance if it existed, or create one if not
found.
If it is {$this->multiBlamesClass} instance and existed, then will add it, or
false will be given if it is not found in database. So if you want to add
blame instance, you should save it before adding.
If it is a array, it will be regarded as configuration array of blame.
Notice! This parameter passed by reference, so it must be a variable!
@param BaseUserModel $user whose blame.
If null, it will take this blameable model's user.
@return false|array false if blame created failed or not enable this feature.
blames guid array if created and added successfully.
@throws InvalidConfigException
@throws InvalidParamException
@see addBlame()
Add specified blame or create it before adding if doesn t exist . But you should save the blame instance before adding it or the operation will fail .