Generator.php 930 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Deploy\Model\DeploymentConfig\Hash;
  7. use Magento\Framework\Serialize\SerializerInterface;
  8. /**
  9. * Hash generator of config data.
  10. */
  11. class Generator
  12. {
  13. /**
  14. * Serializes data into string.
  15. *
  16. * @var SerializerInterface
  17. */
  18. private $serializer;
  19. /**
  20. * @param SerializerInterface $serializer the serializer that serializes data into string
  21. */
  22. public function __construct(SerializerInterface $serializer)
  23. {
  24. $this->serializer = $serializer;
  25. }
  26. /**
  27. * Generates and retrieves hash of deployment configuration data.
  28. *
  29. * @param array|string $data the deployment configuration data from files
  30. * @return string the hash
  31. */
  32. public function generate($data)
  33. {
  34. return sha1($this->serializer->serialize($data));
  35. }
  36. }