PHP code example of maddoger / yii2-cms-core

1. Go to this page and download the library: Download maddoger/yii2-cms-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maddoger / yii2-cms-core example snippets


'log' => [
    'traceLevel' => YII_DEBUG ? 3 : 0,
    'targets' => [

        'db' => [
            'class' => 'yii\log\DbTarget',
            'levels' => ['error', 'warning'],
            'except'=>['yii\web\HttpException:*', 'yii\i18n\I18N\*'],
            'prefix'=>function () {
                $url = !Yii::$app->request->isConsoleRequest ? Yii::$app->request->getUrl() : null;
                return sprintf('[%s][%s]', Yii::$app->id, $url);
            },
            'logTable' => '{{%core_log}}',
        ],
    ],
],

'configurationBehavior' => [
    'class' => ConfigurationBehavior::className(),
    'key' => $this->id.'_custom', //owner class by default

    //Reading
    'attributes' => [
        //Default values
        'logoText' => $this->logoText,
        'logoImageUrl' => $this->logoImageUrl,
        'sortNumber' => $this->sortNumber,
    ],
    'saveToOwnerProperties' => true, // if true all attributes will be written in owner properties
                                     // otherwise configuration model/array will be available through getConfiguration()

    //Editing
    'view' => $this->getViewPath() . DIRECTORY_SEPARATOR . 'configuration.php',
    //Model for user
    'modelClass' => 'maddoger\admin\model\Configuration.php',
    //OR
    'dynamicModel' => [
        'formName' => $this->id,
        'rules' => [
            [['logoText', 'logoImageUrl'], 'string'],
            [['logoText', 'logoImageUrl', 'sortNumber'], 'default', ['value' => null]],
        ],
    ]
]