PropertyMapper.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Default entity attribute mapper
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Eav\Model\Entity\Setup;
  9. use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
  10. class PropertyMapper extends PropertyMapperAbstract
  11. {
  12. /**
  13. * Map input attribute properties to storage representation
  14. *
  15. * @param array $input
  16. * @param int $entityTypeId
  17. * @return array
  18. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  19. */
  20. public function map(array $input, $entityTypeId)
  21. {
  22. return [
  23. 'attribute_model' => $this->_getValue($input, 'attribute_model'),
  24. 'backend_model' => $this->_getValue($input, 'backend'),
  25. 'backend_type' => $this->_getValue($input, 'type', 'varchar'),
  26. 'backend_table' => $this->_getValue($input, 'table'),
  27. 'frontend_model' => $this->_getValue($input, 'frontend'),
  28. 'frontend_input' => $this->_getValue($input, 'input', 'text'),
  29. 'frontend_label' => $this->_getValue($input, 'label'),
  30. 'frontend_class' => $this->_getValue($input, 'frontend_class'),
  31. 'source_model' => $this->_getValue($input, 'source'),
  32. 'is_required' => $this->_getValue($input, 'required', 1),
  33. 'is_user_defined' => $this->_getValue($input, 'user_defined', 0),
  34. 'default_value' => $this->_getValue($input, 'default'),
  35. 'is_unique' => $this->_getValue($input, 'unique', 0),
  36. 'note' => $this->_getValue($input, 'note'),
  37. 'is_global' => $this->_getValue(
  38. $input,
  39. 'global',
  40. \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL
  41. )
  42. ];
  43. }
  44. }