-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
kernel.projectDir must be set when initializing the kernel #29
Conversation
Couldn’t we just use |
What if classes are combined for caching etc?
|
I think since PHP 7 there is no need for caching PHP files by combining them. But even then, the caching script should handle the |
src/HttpKernel/ContaoKernel.php
Outdated
@@ -64,6 +91,8 @@ public function getRootDir() | |||
* Sets the application root dir. | |||
* | |||
* @param string $dir | |||
* | |||
* @deprecated Deprecated since version 4.4, to be removed in 5.0. | |||
*/ | |||
public function setRootDir($dir) | |||
{ |
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.
Should we add a @trigger_error(, E_USER_DEPRECATED)
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.
Valid point, added in b1702b9
b1702b9
to
59ab613
Compare
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 we want to go with the constructor argument, I think the following places have to be updated too:
- src/Resources/system/initialize.php:22
- bin/contao-console:43
- tests/HttpKernel/ContaoKernelTest.php:53
But I would still prefer the dirname()
solution.
Also, isn’t changing the constructor arguments a BC break? E.g. what is if I use a custom app_dev.php in my project that uses the ContaoKernel
, wouldn’t that break with an update?
59ab613
to
202d263
Compare
I have fixed the remaining uses of |
Of course it is. You can only add arguments that are optional. |
6baced7
to
0b0344e
Compare
3cf9523
to
c71190f
Compare
I have updated the PR so it is backwards compatible. Please review again. |
src/HttpKernel/ContaoKernel.php
Outdated
public function getProjectDir() | ||
{ | ||
if (null === $this->projectDir) { | ||
$this->projectDir = dirname(dirname(dirname(dirname(dirname(__DIR__))))); |
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.
With this line, the ContaoKernel now finds the path to the project dir itself. Why do we need the constructor argument then?
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.
For the unit tests I guess.
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 the unit tests we could compare the project dir path against the path of the ContaoKernel.php file.
c71190f
to
5f8a609
Compare
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.
One parameter doccomment is wrong IMO, the rest looks good to me 👍
src/HttpKernel/ContaoKernel.php
Outdated
@@ -37,6 +42,20 @@ class ContaoKernel extends Kernel | |||
private $bundleLoader; | |||
|
|||
/** | |||
* Constructor. | |||
* | |||
* @param string|null $projectDir |
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 think null
should not be allowed here.
fixes #28