2013-10-31 19 views
1

我看到http://symfony.com/doc/current/bundles/SensioGeneratorBundle/index.html繼承Sensio公司發生器管束

如果我在app /資源/ SensioGeneratorBundle /骨架我重寫模板/ ...

它的確定與樹枝標籤

{% extends 'skeleton/bundle/Bundle.php.twig' %}

和重寫塊

但如果我創建我自己的GeneratorBundle「繼承」SensioGeneratorBundle與

public function getParent() { return 'SensioGeneratorBundle'; }

,把我覆蓋骨架模板BUNDLE_PATH /資源/ SensioGeneratorBundle /像文檔骨架說這一點兒也不工作

我需要創建自己的套件用於覆蓋命令

我會混合兩者嗎? 「繼承」捆綁覆蓋命令和覆蓋模板在應用程序/資源

或我可以說是「繼承」捆綁包,並重載包中的命令和骨架模板?

的答覆

THX

編輯

我開一個問題SensioGeneratorBundle:

https://github.com/sensiolabs/SensioGeneratorBundle/issues/233

的GeneratorBundleCommand不把我的繼承束在方法getGenerator參數()

回答

0

顯然,骨架文件夾不能被重寫喜歡這裏所描述的其它覆蓋模板:

http://symfony.com/doc/current/cookbook/bundles/inheritance.html

告訴我,如果我錯了

和BUNDLE_PATH中描述:

http://symfony.com/doc/current/bundles/SensioGeneratorBundle/index.html

對應於任何束中,我認爲,對應於我的繼承SENSIO發生器管束。

,所以我把我的骨架APP_PATH

編輯:pull請求是打開此功能:https://github.com/sensiolabs/SensioGeneratorBundle/pull/235

-1

請閱讀Symfony 2 documentation。通過這個重寫getParent()之後,你可以替換命令。請記住在AppKernel中的父包之後放置子包Bundle

骨架模板不能被傳統的包繼承重寫。每個包可以提供自己的控制器和原則模板。要覆蓋全局框架(就像bundle),你必須把它放在app/Resources中。

要overrite:資源/ SensioGeneratorBundle/template_name.twig

延長:資源/ SesnsioGeneratorBundle /骨架/ template_name.twig

+0

THX答覆 是我做的!我的目錄是: src/Vendor/Bundle/GeneratorBundle/Resources/skeleton/... 但是不起作用! 例如: ' {#SRC /供應商/捆綁/ GeneratorBundle /資源/骨架/束/ Bundle.php.twig#} {% '延伸骨架/束/ Bundle.php.twig' %} {%block use_statements%} 使用Symfony \ Component \ HttpKernel作爲HttpKernel; {%末端嵌段use_statements%} {%塊class_definition%} 類{{束}}延伸HttpKernel \捆綁\捆綁 {%末端嵌段class_definition%} ' – L0rD59

+0

當起初試圖繼承通過的getParent()的symfony找到應用程序中的資源(Resource/ChildBundleName),接下來是在子包上,接下來是在父包上。試試把你的資源放到app/GeneratorBundle/... – zulus

+0

如果我把我的資源放到app/Resources/SensioGeneratorBundle中,就像我在我的第一條評論中說的那樣,可能我會混合使用繼承bundle來覆蓋命令並覆蓋骨架在應用程序/資源,但我想重寫包中的骨架太 – L0rD59