From f543e688aa9d94f554812bc593482b9319c6b51d Mon Sep 17 00:00:00 2001 From: Francisco Rodriguez Date: Wed, 31 Jul 2019 11:53:50 -0400 Subject: [PATCH] Profile commands with @DrupalCommand annotations can now be discovered and translated. --- src/Extension/Manager.php | 10 ++++++++-- src/Utils/TranslatorManager.php | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Extension/Manager.php b/src/Extension/Manager.php index 2208ef2bd..332308ef7 100644 --- a/src/Extension/Manager.php +++ b/src/Extension/Manager.php @@ -192,9 +192,15 @@ private function getExtensions( $name = $extension->getName(); $isInstalled = false; - if (property_exists($extension, 'status')) { - $isInstalled = ($extension->status)?true:false; + if ($type == 'profile') { + $isInstalled = \Drupal::installProfile() == $name; } + else { + if (property_exists($extension, 'status')) { + $isInstalled = ($extension->status) ? TRUE : FALSE; + } + } + if (!$showInstalled && $isInstalled) { continue; } diff --git a/src/Utils/TranslatorManager.php b/src/Utils/TranslatorManager.php index 835433c50..8822191e3 100644 --- a/src/Utils/TranslatorManager.php +++ b/src/Utils/TranslatorManager.php @@ -50,6 +50,22 @@ private function addResourceTranslationsByExtensionPath($extensionPath) } } + /** + * @param $profile + */ + private function addResourceTranslationsByProfile($profile) + { + // No "profile handler" service exists yet, so we have to get + // paths the old fashioned way. + if (\Drupal::installProfile() != $profile) { + return; + } + $extensionPath = drupal_get_path('profile', $profile); + $this->addResourceTranslationsByExtensionPath( + $extensionPath + ); + } + /** * @param $module */ @@ -99,6 +115,10 @@ public function addResourceTranslationsByExtension($extension, $type) } $this->extensions[] = $extension; + if ($type == 'profile') { + $this->addResourceTranslationsByProfile($extension); + return; + } if ($type == 'module') { $this->addResourceTranslationsByModule($extension); return;