Taxvat.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block\Widget;
  7. use Magento\Customer\Api\CustomerMetadataInterface;
  8. /**
  9. * Customer Value Added Tax Widget
  10. *
  11. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  12. */
  13. class Taxvat extends AbstractWidget
  14. {
  15. /**
  16. * Constructor.
  17. *
  18. * @param \Magento\Framework\View\Element\Template\Context $context
  19. * @param \Magento\Customer\Helper\Address $addressHelper
  20. * @param CustomerMetadataInterface $customerMetadata
  21. * @param array $data
  22. */
  23. public function __construct(
  24. \Magento\Framework\View\Element\Template\Context $context,
  25. \Magento\Customer\Helper\Address $addressHelper,
  26. CustomerMetadataInterface $customerMetadata,
  27. array $data = []
  28. ) {
  29. parent::__construct($context, $addressHelper, $customerMetadata, $data);
  30. $this->_isScopePrivate = true;
  31. }
  32. /**
  33. * Sets the template
  34. *
  35. * @return void
  36. */
  37. public function _construct()
  38. {
  39. parent::_construct();
  40. $this->setTemplate('Magento_Customer::widget/taxvat.phtml');
  41. }
  42. /**
  43. * Get is enabled.
  44. *
  45. * @return bool
  46. */
  47. public function isEnabled()
  48. {
  49. return $this->_getAttribute('taxvat') ? (bool)$this->_getAttribute('taxvat')->isVisible() : false;
  50. }
  51. /**
  52. * Get is required.
  53. *
  54. * @return bool
  55. */
  56. public function isRequired()
  57. {
  58. return $this->_getAttribute('taxvat') ? (bool)$this->_getAttribute('taxvat')->isRequired() : false;
  59. }
  60. /**
  61. * Retrieve store attribute label
  62. *
  63. * @param string $attributeCode
  64. *
  65. * @return string
  66. */
  67. public function getStoreLabel($attributeCode)
  68. {
  69. $attribute = $this->_getAttribute($attributeCode);
  70. return $attribute ? __($attribute->getStoreLabel()) : '';
  71. }
  72. }