PostCodesPatternsAttributeData.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Customer\Block\DataProviders;
  8. use Magento\Framework\Serialize\SerializerInterface;
  9. use Magento\Framework\View\Element\Block\ArgumentInterface;
  10. use Magento\Directory\Model\Country\Postcode\Config as PostCodeConfig;
  11. /**
  12. * Provides postcodes patterns into template.
  13. */
  14. class PostCodesPatternsAttributeData implements ArgumentInterface
  15. {
  16. /**
  17. * @var PostCodeConfig
  18. */
  19. private $postCodeConfig;
  20. /**
  21. * @var SerializerInterface
  22. */
  23. private $serializer;
  24. /**
  25. * Constructor
  26. *
  27. * @param PostCodeConfig $postCodeConfig
  28. * @param SerializerInterface $serializer
  29. */
  30. public function __construct(PostCodeConfig $postCodeConfig, SerializerInterface $serializer)
  31. {
  32. $this->postCodeConfig = $postCodeConfig;
  33. $this->serializer = $serializer;
  34. }
  35. /**
  36. * Get serialized post codes
  37. *
  38. * @return string
  39. */
  40. public function getSerializedPostCodes(): string
  41. {
  42. return $this->serializer->serialize($this->postCodeConfig->getPostCodes());
  43. }
  44. }