-
-
Notifications
You must be signed in to change notification settings - Fork 424
Generate a different controller when Twig is not installed #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
private function isTwigInstalled() | ||
{ | ||
return class_exists('Symfony\Bundle\TwigBundle\TwigBundle') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the class
constant here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean this? class_exists(TwigBundle::class)
and the use ...
import or class_exists(Symfony\Bundle\TwigBundle\TwigBundle::class)
? I don't like it because the editor shows a "not found class" error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's we do in the core too. So why do we want to change that here? Indeed, the error is not so nice, but that's related to the IDE/editor. And the end user will probably not look into this class anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is what Symfony does, there's nothing more to discuss 😄 Consistency is the most important thing.
|
||
private function isTwigInstalled() | ||
{ | ||
return class_exists(Symfony\Bundle\TwigBundle\TwigBundle::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a use Symfony\Bundle\TwigBundle\TwigBundle
statement and then use TwigBundle::class
here.
public function index() | ||
{ | ||
// replace this line with your own code! | ||
return $this->render('@Maker/demoPage.html.twig', [ 'path' => str_replace($this->getParameter('kernel.project_dir').'/', '', __FILE__) ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use demo.html.twig
as a template name instead. @Maker
won't work anyway and we don't recommend using @App
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a separate PR I'm going to propose to remove this code and the demo template entirely. We don't need it in a generator bundle (it's useful only after creating a new project, but we already have that covered).
I'm having some tech issues updating this PR ... so I've created another PR: #8. |
This fixes #6.