我试图覆盖任务但我不能让它工作,但:
您可以创建自己的任务,继承学说的任务,做你的东西:在LIB /任务添加sfDoctrineBuildSchemaCustomTask.class.php:
class sfDoctrineBuildSchemaCustomTask extends sfDoctrineBuildSchemaTask
{
/**
* @see sfTask
*/
protected function configure()
{
$this->addOptions(array(
new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
));
$this->namespace = 'doctrine';
$this->name = 'build-schema-custom';
$this->briefDescription = 'Creates a schema from an existing database';
$this->detailedDescription = <<<EOF
The [doctrine:build-schema|INFO] task introspects a database to create a schema:
[./symfony doctrine:build-schema|INFO]
The task creates a yml file in [config/doctrine|COMMENT]
EOF;
}
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
// do your stuff before original call
parent::execute($arguments,$options);
// do your stuff after original call
}
}
然后,你可以调用php symfony doctrine:build-schema-custom,然后去吧!
或者,也许,你可以编辑位于LIB /供应商提供的原始任务/ symfony的/ lib目录/插件/ sfDoctrinePlugin/lib中/任务/ sfDoctrineBuildSchemaTask.class.php
我会说*是*。但最后你想达到什么目的? – j0k
...我想添加一些其他选项到database.yml,所以当我运行build-schema命令时,它“使用”新选项 – ilSavo
我从来不这样做,但我认为你将不得不深入研究教义一代覆盖你想要的。但是,也许你可以在你关于'database.yml'中添加什么的问题中添加更多信息。 – j0k