Skip to content

Commit f3bd984

Browse files
authored
Merge pull request #892 from sdinteractive/app-assurance-changes
Check if the Magento is installed in Adobe cloud
2 parents 92c7655 + 8c0aa09 commit f3bd984

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

app/code/Meta/BusinessExtension/Model/Api/AdobeCloudConfig.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,51 @@
2121
namespace Meta\BusinessExtension\Model\Api;
2222

2323
use Meta\BusinessExtension\Api\AdobeCloudConfigInterface;
24+
use Magento\Framework\Filesystem\DirectoryList;
2425

2526
class AdobeCloudConfig implements AdobeCloudConfigInterface
2627
{
28+
/**
29+
* List of files and directories unique to an Adobe Commerce Cloud deployment.
30+
* Their presence indicates the site is running on the cloud infrastructure.
31+
*/
32+
public const CLOUD_FILES = [
33+
'.magento.app.yaml',
34+
'/vendor/magento/ece-tools/composer.json'
35+
];
36+
37+
/**
38+
* @var DirectoryList
39+
*/
40+
private $directoryList;
41+
42+
/**
43+
* Class constructor
44+
*
45+
* @param DirectoryList $directoryList
46+
*/
47+
public function __construct(
48+
DirectoryList $directoryList
49+
) {
50+
$this->directoryList = $directoryList;
51+
}
52+
2753
/**
2854
* Detect if the current seller's service is on hosted Adobe Cloud
2955
*
3056
* @return bool
3157
*/
3258
public function isSellerOnAdobeCloud(): bool
3359
{
34-
// Need to grab the env var in someway, and getenv() function also generates linter error
35-
// phpcs:ignore
36-
return isset($_ENV['MAGENTO_CLOUD_ENVIRONMENT']);
60+
$rootPath = $this->directoryList->getRoot();
61+
62+
foreach (self::CLOUD_FILES as $file) {
63+
if (file_exists($rootPath . '/' . $file)) {
64+
return true;
65+
}
66+
}
67+
68+
return false;
3769
}
3870

3971
/**

0 commit comments

Comments
 (0)