Compiled.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Framework\App\ObjectManager\ConfigLoader;
  8. use Magento\Framework\App\Filesystem\DirectoryList;
  9. use Magento\Framework\ObjectManager\ConfigLoaderInterface;
  10. use Magento\Framework\Serialize\SerializerInterface;
  11. use Magento\Framework\Serialize\Serializer\Serialize;
  12. class Compiled implements ConfigLoaderInterface
  13. {
  14. /**
  15. * Global config
  16. *
  17. * @var array
  18. */
  19. private $configCache = [];
  20. /**
  21. * {inheritdoc}
  22. */
  23. public function load($area)
  24. {
  25. if (isset($this->configCache[$area])) {
  26. return $this->configCache[$area];
  27. }
  28. $diConfiguration = include(self::getFilePath($area));
  29. $this->configCache[$area] = $diConfiguration;
  30. return $this->configCache[$area];
  31. }
  32. /**
  33. * Returns path to compiled configuration
  34. *
  35. * @param string $area
  36. * @return string
  37. */
  38. public static function getFilePath($area)
  39. {
  40. $diPath = DirectoryList::getDefaultConfig()[DirectoryList::GENERATED_METADATA][DirectoryList::PATH];
  41. return BP . '/' . $diPath . '/' . $area . '.php';
  42. }
  43. }