我試圖覆蓋任務但我不能讓它工作,但:
您可以創建自己的任務,繼承學說的任務,做你的東西:在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