无法更改模型构建器选项 [英] Can't change model builder options

查看:115
本文介绍了无法更改模型构建器选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用一个名为 jsDoctrineRecord 的自定义类,而不是其模型使用 sfDoctrineRecord 。以下是覆盖类的代码:

I'm trying to get symfony to use a custom class called jsDoctrineRecord instead of sfDoctrineRecord for its models. Here's the code for the overriding class:

<?php
abstract class jsDoctrineRecord extends sfDoctrineRecord
{
  public function foo()
  {
    echo 'foo';exit;
  }
}

这是我在 config / ProjectConfiguration.class.php ,按照说明这里

<?php

require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->enablePlugins('sfDoctrinePlugin');
    $this->enablePlugins('sfDoctrineGuardPlugin');
    $this->enablePlugins('jsDoctrineSchemaOverriderPlugin');
  }

  public function configureDoctrine(Doctrine_Manager $manager)
  {
    $options = array('baseClassName' => 'jsDoctrineRecord');
    sfConfig::set('doctrine_model_builder_options', $options);
  }
}

不幸的是,这不行。我的模型继续从 sfDoctrineRecord 而不是 jsDoctrineRecord 继承。 foo()方法无法识别。我清楚我的缓存时仍然有问题。

Unfortunately, this doesn't work. My models continue to inherit from sfDoctrineRecord instead of jsDoctrineRecord. The foo() method is not recognized. I still have the problem when I clear my cache.

我很确定我按照正确的说明,可能会出错?

I'm pretty sure I'm following the instructions right, so what could be going wrong?

推荐答案

您需要重建模型,以便Base记录类扩展您的新记录类。运行原则:构建模型。

You need to rebuild the model so that the Base record classes extend your new record class. Run doctrine:build-model.

这篇关于无法更改模型构建器选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆