yii\base\ErrorException 使用未定义常量标志 - 假定 'logo'(这将在 PHP 的未来版本中引发错误)

yii\base\ErrorException Use of undefined constant logo - assumed 'logo' (this will throw an Error in a future version of PHP)

我安装了用于图书馆管理的网络应用程序,当我尝试为图书馆上传徽标时,它给我这样的错误

Unknown Property – yii\base\UnknownPropertyException Use of undefined constant logo - assumed 'logo' (this will throw an Error in a future version of PHP)

这是我的堆栈跟踪:

1. in /otka/app/src/web/backend/modules/setting/umum/controllers/DataPerpustakaanController.php at line 44
// $model->NamaLokasiPerpustakaan = Yii::$app->config->get('NamaLokasiPerpustakaan');

$model->JenisPerpustakaan = Yii::$app->config->get('JenisPerpustakaan');
$model->IsUseKop = Yii::$app->config->get('IsUseKop');


if ($model->load(Yii::$app->request->post())) {
    $model->logo = UploadedFile::getInstance($model, 'logo');

    $temp_logo = ($model->logo != "" ? logo : kop);

    $model->image = UploadedFile::getInstance($model, $temp_logo);
    if($model->image!='')
        {
            $files_uploaded = '../uploaded_files/aplikasi/' . "temp_image" . '.' . "png";
            $model->image->saveAs($files_uploaded,false);
            $mimetype=DirectoryHelpers::mimeType($files_uploaded);
            if ($mimetype){
                unlink($files_uploaded);
2.  in /otka/app/src/web/backend/modules/setting/umum/controllers/DataPerpustakaanController.php at line 44– yii\base\ErrorHandler::handleError(2, 'Use of undefined constant logo -...', '/otka/app/src/web/backend/module...', 44, ...)
3. backend\modules\setting\umum\controllers\DataPerpustakaanController::actionIndex()
4. in /otka/app/src/web/vendor/yiisoft/yii2/base/InlineAction.php at line 55- call_user_func_array([backend\modules\setting\umum\controllers\DataPerpustakaanController, 'actionIndex'], [])
5. in /otka/app/src/web/vendor/yiisoft/yii2/base/Controller.php at line 154– yii\base\InlineAction::runWithParams([])
6. in /otka/app/src/web/vendor/yiisoft/yii2/base/Module.php at line 454– yii\base\Controller::runAction('index', [])
7. in /otka/app/src/web/vendor/yiisoft/yii2/web/Application.php at line 84– yii\base\Module::runAction('setting/umum/data-perpustakaan/i...', [])
8. in /otka/app/src/web/vendor/yiisoft/yii2/base/Application.php at line 375– yii\web\Application::handleRequest(yii\web\Request)

这是DataPerpustakaanController.php

中的函数行
<?php
namespace backend\modules\setting\umum\controllers;

use Yii;
use yii\base\DynamicModel;
use yii\web\UploadedFile;
use common\components\DirectoryHelpers;

class DataPerpustakaanController extends \yii\web\Controller
{
    public function actionIndex()
    {
        $model = new DynamicModel([
            'NamaPerpustakaan',
            //'NamaLokasiPerpustakaan',
            'JenisPerpustakaan',
            'IsUseKop',
            'logo',
            'kop',
            'image',
        ]);
        $model->addRule([
            'NamaPerpustakaan',
            //'NamaLokasiPerpustakaan',
            'JenisPerpustakaan', 'IsUseKop',], 'required'
        );

        $model->NamaPerpustakaan = Yii::$app->config->get('NamaPerpustakaan');
        // $model->NamaLokasiPerpustakaan = Yii::$app->config->get('NamaLokasiPerpustakaan');

        $model->JenisPerpustakaan = Yii::$app->config->get('JenisPerpustakaan');
        $model->IsUseKop = Yii::$app->config->get('IsUseKop');
        if ($model->load(Yii::$app->request->post())) {
            $model->logo = UploadedFile::getInstance($model, 'logo');
         
            $temp_logo = ($model->logo != "" ? logo : kop); //**This is line 44**

            $model->image = UploadedFile::getInstance($model, $temp_logo);
            if($model->image!='')
            {
                $files_uploaded = '../uploaded_files/aplikasi/' . "temp_image" . '.' . "png";
                $model->image->saveAs($files_uploaded,false);
                $mimetype=DirectoryHelpers::mimeType($files_uploaded);
                if ($mimetype){
                    unlink($files_uploaded);
                        if ($model->logo != "") {
                            $model->image->saveAs('../uploaded_files/aplikasi/' . "logo_perpusnas_2015" . '.' . "png");                        
                        } else{
                            $model->image->saveAs('../uploaded_files/aplikasi/' . "kop" . '.' . "png");
                        }
                }
                else {
                Yii::$app->getSession()->setFlash('error', [
                        'type' => 'error',
                        'duration' => 500,
                        'icon' => 'fa fa-info-circle',
                        'message' => Yii::t('app', 'Failed Save'),
                        'title' => 'Info',
                        'positonY' => Yii::$app->params['flashMessagePositionY'],
                        'positonX' => Yii::$app->params['flashMessagePositionX']
                    ]);

                }
            }
            
                if ($model->validate()) {
                    Yii::$app->config->set('NamaPerpustakaan', Yii::$app->request->post('DynamicModel')['NamaPerpustakaan']);
                    //Yii::$app->config->set('NamaLokasiPerpustakaan', Yii::$app->request->post('DynamicModel')['NamaLokasiPerpustakaan']);
                    Yii::$app->config->set('JenisPerpustakaan', Yii::$app->request->post('DynamicModel')['JenisPerpustakaan']);
                    Yii::$app->config->set('IsUseKop', Yii::$app->request->post('DynamicModel')['IsUseKop']);


                    Yii::$app->getSession()->setFlash('success', [
                        'type' => 'info',
                        'duration' => 500,
                        'icon' => 'fa fa-info-circle',
                        'message' => Yii::t('app', 'Success Save'),
                        'title' => 'Info',
                        'positonY' => Yii::$app->params['flashMessagePositionY'],
                        'positonX' => Yii::$app->params['flashMessagePositionX']
                    ]);
                } 
                else {
                Yii::$app->getSession()->setFlash('error', [
                        'type' => 'error',
                        'duration' => 500,
                        'icon' => 'fa fa-info-circle',
                        'message' => Yii::t('app', 'Failed Save'),
                        'title' => 'Info',
                        'positonY' => Yii::$app->params['flashMessagePositionY'],
                        'positonX' => Yii::$app->params['flashMessagePositionX']
                    ]);
                }
            return $this->redirect(['index']);
        } else {
            return $this->render('index', [
                'model' => $model,]);
        }
    }

}

如何解决这个问题?

我解决了这个问题,所以第44行有代码

$temp_logo = ($model->logo != "" ? logo : kop);

改成这样

$temp_logo = ($model->logo != "" ? 'logo' : 'kop');