-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[2.2-dev] Move functions.php into Framework #16800
[2.2-dev] Move functions.php into Framework #16800
Conversation
Hi @fooman. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
338a7c0
to
4fcb412
Compare
Updated the PR to fix the noted short name violation of __.php (squashed into 1 commit) |
4fcb412
to
e8f5186
Compare
* | ||
* @return \Magento\Framework\Phrase | ||
*/ | ||
function __() |
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.
Wasn't idea to put this function in Magento/Framework/Phrase/ - \Magento\Framework\Phrase
namespace?
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 don't think that was proposed so far. Wouldn't namespacing the function mean all existing templates would need to be adjusted?
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.
Let's wait @orlangur for review
@orlangur any thing else to do here before it can be merged? |
@orlangur or @ihor-sviziev anything else needed here? |
@fooman sorry for delay, started review almost immediately but didn't finish it. Will do now. |
@@ -0,0 +1,22 @@ | |||
<?php |
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.
Which rule was violated by __.php
name?
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.
It was actually the function name itself __()
which triggered the violation. As this was previously not occurring I assumed it was related to the file name. It turned out that wasn't the case and that __() was always in violation but making the changes brought this up.
If you have a strong preference I can change the filename __function.php back to __.php.
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.
Please do so.
@@ -0,0 +1,4 @@ | |||
<?php | |||
if (!function_exists('__')) { | |||
require '__function.php'; |
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.
What is the use for such registration 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.
The main idea of splitting this out is the following:
The standard way of installing Magento 2 should be through Composer. In this case you will get the __function.php included directly through the Composer autoloader - no further requires needed. Also this registration file would not be loaded.
Only if you clone from Github app/etc/NonComposerComponentRegistration.php
will kick in and find this registration file which in turn will require __function.php.
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.
@orlangur we could mark this file deprecated as well as it should get removed at the same time as app/functions.php
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.
Such file is a bit confusing, please just include __.php
in registration.php
of Magento Framework.
@@ -45,7 +45,8 @@ | |||
"Magento\\Framework\\": "" | |||
}, | |||
"files": [ | |||
"registration.php" | |||
"registration.php", | |||
"Phrase/__function.php" |
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 meant to just require __.php
in registration of framework.
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.
To me the final goal should be to use Composer to supply autoloaded files. Using registration.php is an intermediate step which we could do without. It also keeps the purpose of the registration 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.
Using registration.php is an intermediate
There is no need to do something differently until we get rid of them.
So, instead of including __.php
separately just do it within registration.php
.
app/functions.php
Outdated
if (!empty($argc) && is_array($argc[0])) { | ||
$argc = $argc[0]; | ||
$vendorDir = require VENDOR_PATH; | ||
if (!function_exists('__')) { |
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.
Why not simply move such logic into __.php
? It's better to mark app/functions.php
as deprecated without any changes.
03a3aa7
to
c8860f5
Compare
@orlangur okay changed this to how you suggested so that we can get this merged |
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.
@fooman great! Even simpler than I thought it will be 👍
Hi @orlangur, thank you for the review. |
Hi @fooman. Thank you for your contribution. Please, consider to port this solution to 2.3 release line. |
See discussion and comments in #16705 - this is a pull request for 2.2
Contribution checklist