protected function saveBlock($fullClassName)
    {
        // ensure all classes start with trailing slash class name definition like `\foo\bar\Class`
        $fullClassName = '\\'  . ltrim($fullClassName, '\\');
        $model = Block::find()->where(['class' => $fullClassName])->one();
        
        $blockObject = $this->createBlockObject($fullClassName);
        
        $blockGroupId = $this->getBlockGroupId($blockObject);
        
        if (!in_array($blockGroupId, $this->blockGroupIds)) {
            $this->blockGroupIds[] = $blockGroupId;
        }
        
        $log = "block {$fullClassName}: ";
        if (!$model) {
            $model = new Block();
            $model->group_id = $blockGroupId;
            $model->class = $fullClassName;
            if ($model->save()) {
                $log .= "Added to database";
            } else {
                $log .= "Error while saving";
            }
        } elseif ($model->group_id != $blockGroupId) {
            $log .= 'Updated group id"';
            $model->updateAttributes(['group_id' => $blockGroupId]);
        } else {
            $log .= 'remains the same, nothing to update';
        }
        $this->addLog($log);
        
        return $model->id;
    }
protected function saveBlock($fullClassName)
    {
        // ensure all classes start with trailing slash class name definition like `\foo\bar\Class`
        $fullClassName = '\\'  . ltrim($fullClassName, '\\');
        $model = Block::find()->where(['class' => $fullClassName])->one();
        
        $blockObject = $this->createBlockObject($fullClassName);
        
        $blockGroupId = $this->getBlockGroupId($blockObject);
        
        if (!in_array($blockGroupId, $this->blockGroupIds)) {
            $this->blockGroupIds[] = $blockGroupId;
        }
        
        $log = "block {$fullClassName}: ";
        if (!$model) {
            $model = new Block();
            $model->group_id = $blockGroupId;
            $model->class = $fullClassName;
            if ($model->save()) {
                $log .= "Added to database";
            } else {
                $log .= "Error while saving";
            }
        } elseif ($model->group_id != $blockGroupId) {
            $log .= 'Updated group id"';
            $model->updateAttributes(['group_id' => $blockGroupId]);
        } else {
            $log .= 'remains the same, nothing to update';
        }
        $this->addLog($log);
        
        return $model->id;
    }
protected function saveBlock ( $ fullClassName ) { // ensure all classes start with trailing slash class name definition like `\foo\bar\Class` $ fullClassName = '\\' . ltrim ( $ fullClassName , '\\' ) ; $ model = Block :: find ( ) -> where ( [ 'class' => $ fullClassName ] ) -> one ( ) ; $ blockObject = $ this -> createBlockObject ( $ fullClassName ) ; $ blockGroupId = $ this -> getBlockGroupId ( $ blockObject ) ; if ( ! in_array ( $ blockGroupId , $ this -> blockGroupIds ) ) { $ this -> blockGroupIds [ ] = $ blockGroupId ; } $ log = "block {$fullClassName}: " ; if ( ! $ model ) { $ model = new Block ( ) ; $ model -> group_id = $ blockGroupId ; $ model -> class = $ fullClassName ; if ( $ model -> save ( ) ) { $ log .= "Added to database" ; } else { $ log .= "Error while saving" ; } } elseif ( $ model -> group_id != $ blockGroupId ) { $ log .= 'Updated group id"' ; $ model -> updateAttributes ( [ 'group_id' => $ blockGroupId ] ) ; } else { $ log .= 'remains the same, nothing to update' ; } $ this -> addLog ( $ log ) ; return $ model -> id ; }
Save a block by its given full class name.

Example full class name: luya\cms\blocks\ModuleBlock

@param string $fullClassName
@return number
Save a block by its given full class name .