Propel Data Load - “默认”上下文不存在

时间:2011-07-20 18:15:36

标签: php symfony1 propel

当我尝试使用The "default" context does not exist.

命令构建我的数据模型时,我目前停留在错误symfony propel:build --application=frontend --all --and-load --no-confirmation

经过大量的谷歌搜索后,看来这个错误是由于在模型或表单中使用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",

非常感谢你的时间,


不确定我能提供哪些信息,是否还有其他任何问题?

3 个答案:

答案 0 :(得分:1)

我通过执行以下操作解决了这个问题。

首先在模型文件中查找对sfContext的所有引用,并找到另一种方法来获取所需的sfContext(例如将其传递给方法)。

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

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

我的案例中的问题是我的save方法使用了另一个使用sfContext来获取当前用户的库,这在将数据插入模型时显然不存在

答案 1 :(得分:1)

今天刚刚通过数据加载遇到了这个问题。而不是修改功能签名,这就是我所做的。

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

答案 2 :(得分:1)

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

相关问题