From c8860f529bc377072fece7ebe74d7f7dbea98d73 Mon Sep 17 00:00:00 2001 From: "Kristof Ringleff, Fooman" Date: Sat, 14 Jul 2018 19:57:25 +1200 Subject: [PATCH] Move functions.php into Framework --- app/bootstrap.php | 2 -- app/functions.php | 23 +++++++++++-------- dev/tests/unit/framework/bootstrap.php | 1 - lib/internal/Magento/Framework/Phrase/__.php | 22 ++++++++++++++++++ .../Magento/Framework/registration.php | 4 ++++ 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 lib/internal/Magento/Framework/Phrase/__.php diff --git a/app/bootstrap.php b/app/bootstrap.php index 70b632537a75b..8e901cac9bfb8 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -31,8 +31,6 @@ // Sets default autoload mappings, may be overridden in Bootstrap::create \Magento\Framework\App\Bootstrap::populateAutoloader(BP, []); -require_once BP . '/app/functions.php'; - /* Custom umask value may be provided in optional mage_umask file in root */ $umaskFile = BP . '/magento_umask'; $mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002; diff --git a/app/functions.php b/app/functions.php index 0b5fa4de4100e..4b00d01819f70 100644 --- a/app/functions.php +++ b/app/functions.php @@ -6,17 +6,22 @@ /** * Create value-object \Magento\Framework\Phrase - * + * @deprecated The global function __() is now loaded via Magento Framework, the below require is only + * for backwards compatibility reasons and this file will be removed in a future version + * @see Magento\Framework\Phrase\__.php + * @SuppressWarnings(PHPMD.ShortMethodName) * @return \Magento\Framework\Phrase */ -function __() -{ - $argc = func_get_args(); +if (!function_exists('__')) { + function __() + { + $argc = func_get_args(); - $text = array_shift($argc); - if (!empty($argc) && is_array($argc[0])) { - $argc = $argc[0]; - } + $text = array_shift($argc); + if (!empty($argc) && is_array($argc[0])) { + $argc = $argc[0]; + } - return new \Magento\Framework\Phrase($text, $argc); + return new \Magento\Framework\Phrase($text, $argc); + } } diff --git a/dev/tests/unit/framework/bootstrap.php b/dev/tests/unit/framework/bootstrap.php index 68dba4e2ce00c..06aee53dafb14 100644 --- a/dev/tests/unit/framework/bootstrap.php +++ b/dev/tests/unit/framework/bootstrap.php @@ -11,7 +11,6 @@ } require_once __DIR__ . '/autoload.php'; -require BP . '/app/functions.php'; setCustomErrorHandler(); diff --git a/lib/internal/Magento/Framework/Phrase/__.php b/lib/internal/Magento/Framework/Phrase/__.php new file mode 100644 index 0000000000000..a8d69ec622e90 --- /dev/null +++ b/lib/internal/Magento/Framework/Phrase/__.php @@ -0,0 +1,22 @@ +