AbstractEntity.php 977 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Model\ResourceModel\Entity;
  7. abstract class AbstractEntity
  8. {
  9. /**
  10. * @var string
  11. */
  12. protected $_name = null;
  13. /**
  14. * Configuration object
  15. *
  16. * @var \Magento\Framework\Simplexml\Config
  17. */
  18. protected $_config = [];
  19. /**
  20. * Set config
  21. *
  22. * @param \Magento\Framework\Simplexml\Config $config
  23. */
  24. public function __construct($config)
  25. {
  26. $this->_config = $config;
  27. }
  28. /**
  29. * Get config by key
  30. *
  31. * @param string $key
  32. * @return \Magento\Framework\Simplexml\Config|string|false
  33. */
  34. public function getConfig($key = '')
  35. {
  36. if ('' === $key) {
  37. return $this->_config;
  38. } elseif (isset($this->_config->{$key})) {
  39. return $this->_config->{$key};
  40. } else {
  41. return false;
  42. }
  43. }
  44. }