Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Index.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
13 
17 class Index extends Action implements HttpGetActionInterface
18 {
22  protected $productMetadata;
23 
29  {
30  $this->productMetadata = $productMetadata;
31  parent::__construct($context);
32  }
33 
40  public function execute()
41  {
42  $version = $this->productMetadata->getVersion();
43  $versionParts = explode('.', $version);
44  if ((!isset($versionParts[0]) || !isset($versionParts[1]))
45  || $this->isGitBasedInstallation($version)
46  ) {
47  return;
48  }
49  $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
50  $this->getResponse()->setBody(
51  $this->productMetadata->getName() . '/' .
52  $majorMinorVersion . ' (' .
53  $this->productMetadata->getEdition() . ')'
54  );
55  }
56 
63  private function isGitBasedInstallation($fullVersion)
64  {
65  $versionParts = explode('-', $fullVersion);
66  return (isset($versionParts[0]) && $versionParts[0] == 'dev');
67  }
68 }
__construct(Context $context, ProductMetadataInterface $productMetadata)
Definition: Index.php:28