gpt4 book ai didi

php - lithium 弃用 __init() 方法,需要手动调用它

转载 作者:搜寻专家 更新时间:2023-10-31 21:10:27 25 4
gpt4 key购买 nike

我最近更新了锂库,我遇到了这个问题。我收到此错误:

运行时异常


弃用 `app\models\StoreCategories::__init()` 方法,需要手动调用。

来源

/works/minhna/public_html/CMP/V0/libraries/lithium/core/Libraries.php: 505

500 
501 if ($path && include $path) {
502 static::$_cachedPaths[$class] = $path;
503 if (method_exists($class, '__init')) {
504 $msg = "Deprecated `{$class}::__init()` method, needs to be called it manually.";
505 throw new RuntimeException($msg);
506 }
507 } elseif ($require) {
508 throw new RuntimeException("Failed to load class `{$class}` from path `{$path}`.");
509 }
510 }

在 StoreCategories 模型中,我有一个简单的函数

public static function __init(array $options = array()){
static::config($options);
static::applyFilter('save', function ($self, $params, $chain) {
if(!$params['entity']->_id){
//set created date
$params['entity']->created = strtotime(gmdate('Y-m-d H:i:s'));
}
}
}

我使用 composer 并在 boostrap libraries.php 中加载 li3_socialauth 库:

/**
* load the socialauth library
*/
Libraries::add('li3_socialauth');
// Add the composer autoloader if not already done
require_once(LITHIUM_LIBRARY_PATH . '/autoload.php') ;

提前谢谢你。

最佳答案

Lithium 摆脱了静态对象中的 __init(),参见 this commit .

关于php - lithium 弃用 __init() 方法,需要手动调用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21064764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com