1

I want to save deployment version in DB from where I can get the currently deployed version?

2 Answers 2

4

I found a way to get the current deployed version. Thanks @Black

<?php

namespace MyModule\MyVendor\Model;

use Magento\Framework\App\View\Deployment\Version\StorageInterface;

class DeploymentVersion
{
    /**
     * @var StorageInterface
     */
    protected $storage;

    /**
     * @var int|boolean|null
     */
    protected $deployedVersion;

    /**
     * constructor
     * @param StorageInterface $storage
     */
    public function __construct(
        StorageInterface $storage
    ) {
        $this->storage = $storage;
    }

    public function getDeploymentId()
    {
        if (!isset($this->deployedVersion)) {
            $this->deployedVersion = $this->storage->load();
        }

        return $this->deployedVersion;
    }
}
1

It is stored in pub/static/deployed_version.txt

3
  • Thanks, but Is Magento have anything to get current version ? Aug 31, 2020 at 14:27
  • 1
    Do you mean a function?
    – Black
    Aug 31, 2020 at 14:33
  • Thanks @Black I have added an answer! Aug 31, 2020 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.