Propel Data Load - "default"上下文不存在


Propel Data Load - "default" context does not exist

当我试图用命令symfony propel:build --application=frontend --all --and-load --no-confirmation构建我的数据模型时,我目前被困在错误The "default" context does not exist.

经过大量的谷歌搜索似乎这个错误是由使用sfContext内的模型或表单造成的,所以我已经找到了这些,并把它们注释出来(见下文),错误仍然发生,其他人知道修复吗?

>> file-     /var/www/html/dev/meeting/config/generated-sfGuardPlugin-schema.xml
>> file-     /var/www/html/dev/meeting/config/generated-schema.xml
>> propel    load data from "/var/www/html/dev/meeting/data/fixtures"
>> propel    load data from "/var/www/html/dev/meeting/plugins/sfGuardPlugin/data/fixtures"
  The "default" context does not exist. 

grep -R sfContext lib/model/*
lib/model/MeetingMeetings.php:    return "";//sfContext::getInstance()->getController()->genUrl('meeting/show?id='.$this->getId(), $full);
lib/model/sfGuardUserProfile.php:    //if(!is_null(sfContext::getInstance())&&($useYou||$useYourself)&&$this->getUserId()==sfContext::getInstance()->getUser()->getId()) {
grep -R sfContext lib/form/*
lib/form/MeetingMeetingsForm.class.php:      //sfContext::getInstance()->getUser()->setFlash("info",

非常感谢你的时间,


不知道我能提供什么信息,还有谁有其他问题吗?

我通过以下方法解决了这个问题。

首先在你的模型文件中找到对sfContext的所有引用,并找到一种替代方法来获得sfContext所需要的东西(例如将其传递给方法)。

检查所有模型中提到的使用sfContext的库文件,重复上述解决方案。

对必须存在的sfContexts使用is_null检查,因此它只在需要时才会这样做。

在我的情况下的问题是我的保存方法使用另一个库使用sfContext来获取当前用户,这显然不存在插入数据到模型

今天在数据加载中遇到了这个问题。我没有修改函数签名,而是这样做的:

if(!sfContext::hasInstance())
  $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'cache', true);
else
  $configuration = sfContext::getInstance()->getConfiguration();

然后我可以在我的模型类中运行这样的东西。

$configuration->loadHelpers('Texturizer');

我不确定'cache'参数在getApplicationConfiguration中做什么,但我发现Jobeet书的那一行在这里http://www.symfony-project.org/jobeet/1_4/Propel/en/21

为了快速解决问题,注释代码/lib/form/baseForm.class.php,生成模块,并恢复代码