Skip to content

Commit

Permalink
Append Elasticsuite version to adminhtml footer.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Jul 26, 2022
1 parent 84bd00f commit a769c24
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 2 deletions.
88 changes: 88 additions & 0 deletions src/module-elasticsuite-core/Block/Adminhtml/System/Version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteCore
* @author Romain Ruaud <[email protected]>
* @copyright 2020 Smile
* @license Open Software License ("OSL") v. 3.0
*/

namespace Smile\ElasticsuiteCore\Block\Adminhtml\System;

/**
* Version block to display in footer.
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName) The property _template is inherited
*
* @category Smile
* @package Smile\ElasticsuiteCore
* @author Romain Ruaud <[email protected]>
*/
class Version extends \Magento\Backend\Block\Template
{
/**
* @var string
*/
protected $_template = 'Smile_ElasticsuiteCore::system/version.phtml';

/**
* @var \Smile\ElasticsuiteCore\Model\ProductMetadata
*/
protected $productMetadata;

/**
* @param \Magento\Backend\Block\Template\Context $context Block context
* @param \Smile\ElasticsuiteCore\Model\ProductMetadata $productMetadata Product Metadata
* @param array $data Block data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Smile\ElasticsuiteCore\Model\ProductMetadata $productMetadata,
array $data = []
) {
$this->productMetadata = $productMetadata;
parent::__construct($context, $data);
}

/**
* Get Elasticsuite product version
*
* @return string
*/
public function getElasticsuiteVersion()
{
return $this->productMetadata->getVersion();
}

/**
* Get Elasticsuite product edition
*
* @return string
*/
public function getElasticsuiteEdition()
{
return $this->productMetadata->getEdition();
}

/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
protected function _construct()
{
$this->setShowProfiler(true);
}

/**
* {@inheritDoc}
*/
protected function getCacheLifetime()
{
return 3600 * 24 * 10;
}
}
3 changes: 1 addition & 2 deletions src/module-elasticsuite-core/Model/ProductMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Magento\Framework\App\Config;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Composer\ComposerFactory;
use \Smile\ElasticsuiteCore\Model\ProductMetadata\ComposerInformation;
use Magento\Framework\Composer\ComposerJsonFinder;
Expand All @@ -29,7 +28,7 @@
* @package Smile\ElasticsuiteCore
* @author Romain Ruaud <[email protected]>
*/
class ProductMetadata implements ProductMetadataInterface
class ProductMetadata
{
/**
* Elasticsuite product edition
Expand Down
28 changes: 28 additions & 0 deletions src/module-elasticsuite-core/view/adminhtml/layout/default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!--
/**
* Adminhtml default layout
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteCore
* @author Romain RUAUD <[email protected]>
* @copyright 2020 Smile
* @license Open Software License ("OSL") v. 3.0
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="footer">
<referenceContainer name="legal">
<referenceContainer name="legal.system">
<block class="Smile\ElasticsuiteCore\Block\Adminhtml\System\Version" after="version" name="es-version" as="es-version" />
</referenceContainer>
</referenceContainer>
</referenceContainer>
</body>
</page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Version footer block
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteCore
* @author Romain Ruaud <[email protected]>
* @copyright 2022 Smile
* @license Open Software License ("OSL") v. 3.0
*/
?>
<p class="magento-version">
<strong><a href="https://elasticsuite.io"><?= $block->escapeHtml(__('ElasticSuite')) ?></a></strong>
<?= $block->escapeHtml($block->getElasticsuiteEdition()) ?>
<?= $block->escapeHtml(__('ver. %1', $block->getElasticsuiteVersion())) ?>
</p>

0 comments on commit a769c24

Please sign in to comment.