diff --git a/src/module-elasticsuite-core/Block/Adminhtml/System/Version.php b/src/module-elasticsuite-core/Block/Adminhtml/System/Version.php new file mode 100644 index 000000000..de27b45e7 --- /dev/null +++ b/src/module-elasticsuite-core/Block/Adminhtml/System/Version.php @@ -0,0 +1,88 @@ + + * @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 + */ +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; + } +} diff --git a/src/module-elasticsuite-core/Model/ProductMetadata.php b/src/module-elasticsuite-core/Model/ProductMetadata.php index 0f11c070f..ee5f076ec 100644 --- a/src/module-elasticsuite-core/Model/ProductMetadata.php +++ b/src/module-elasticsuite-core/Model/ProductMetadata.php @@ -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; @@ -29,7 +28,7 @@ * @package Smile\ElasticsuiteCore * @author Romain Ruaud */ -class ProductMetadata implements ProductMetadataInterface +class ProductMetadata { /** * Elasticsuite product edition diff --git a/src/module-elasticsuite-core/view/adminhtml/layout/default.xml b/src/module-elasticsuite-core/view/adminhtml/layout/default.xml new file mode 100644 index 000000000..6f97e7b6a --- /dev/null +++ b/src/module-elasticsuite-core/view/adminhtml/layout/default.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + diff --git a/src/module-elasticsuite-core/view/adminhtml/templates/system/version.phtml b/src/module-elasticsuite-core/view/adminhtml/templates/system/version.phtml new file mode 100644 index 000000000..d5d26a9f5 --- /dev/null +++ b/src/module-elasticsuite-core/view/adminhtml/templates/system/version.phtml @@ -0,0 +1,21 @@ + + * @copyright 2022 Smile + * @license Open Software License ("OSL") v. 3.0 + */ +?> +

+ escapeHtml(__('ElasticSuite')) ?> + escapeHtml($block->getElasticsuiteEdition()) ?> + escapeHtml(__('ver. %1', $block->getElasticsuiteVersion())) ?> +