Text.php 963 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options;
  7. /**
  8. * Block Class for Text Swatch
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Text extends AbstractSwatch
  14. {
  15. /**
  16. * @var string
  17. */
  18. protected $_template = 'Magento_Swatches::catalog/product/attribute/text.phtml';
  19. /**
  20. * Return json config for text option JS initialization
  21. *
  22. * @return array
  23. * @since 100.1.0
  24. */
  25. public function getJsonConfig()
  26. {
  27. $values = [];
  28. foreach ($this->getOptionValues() as $value) {
  29. $values[] = $value->getData();
  30. }
  31. $data = [
  32. 'attributesData' => $values,
  33. 'isSortable' => (int)(!$this->getReadOnly() && !$this->canManageOptionDefaultOnly()),
  34. 'isReadOnly' => (int)$this->getReadOnly()
  35. ];
  36. return json_encode($data);
  37. }
  38. }