Config.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ImportExport\Model\Import;
  7. use Magento\Framework\Serialize\SerializerInterface;
  8. /**
  9. * Provides import configuration
  10. */
  11. class Config extends \Magento\Framework\Config\Data implements \Magento\ImportExport\Model\Import\ConfigInterface
  12. {
  13. /**
  14. * Constructor
  15. *
  16. * @param Config\Reader $reader
  17. * @param \Magento\Framework\Config\CacheInterface $cache
  18. * @param string|null $cacheId
  19. * @param SerializerInterface|null $serializer
  20. */
  21. public function __construct(
  22. \Magento\ImportExport\Model\Import\Config\Reader $reader,
  23. \Magento\Framework\Config\CacheInterface $cache,
  24. $cacheId = 'import_config_cache',
  25. SerializerInterface $serializer = null
  26. ) {
  27. parent::__construct($reader, $cache, $cacheId, $serializer);
  28. }
  29. /**
  30. * Retrieve import entities configuration
  31. *
  32. * @return array
  33. */
  34. public function getEntities()
  35. {
  36. return $this->get('entities');
  37. }
  38. /**
  39. * Retrieve import entity types configuration
  40. *
  41. * @param string $entity
  42. * @return array
  43. */
  44. public function getEntityTypes($entity)
  45. {
  46. $entities = $this->getEntities();
  47. return isset($entities[$entity]) ? $entities[$entity]['types'] : [];
  48. }
  49. /**
  50. * Retrieve a list of indexes which are affected by import of the specified entity.
  51. *
  52. * @param string $entity
  53. * @return array
  54. */
  55. public function getRelatedIndexers($entity)
  56. {
  57. $entities = $this->getEntities();
  58. return isset($entities[$entity]) ? $entities[$entity]['relatedIndexers'] : [];
  59. }
  60. }