vendor/pimcore/pimcore/lib/Extension/Config.php line 50

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Pimcore
  5. *
  6. * This source file is available under two different licenses:
  7. * - GNU General Public License version 3 (GPLv3)
  8. * - Pimcore Commercial License (PCL)
  9. * Full copyright and license information is available in
  10. * LICENSE.md which is distributed with this source code.
  11. *
  12. * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13. * @license http://www.pimcore.org/license GPLv3 and PCL
  14. */
  15. namespace Pimcore\Extension;
  16. use Pimcore\Config as PimcoreConfig;
  17. use Pimcore\File;
  18. /**
  19. * @internal
  20. *
  21. * @deprecated
  22. */
  23. class Config
  24. {
  25. /**
  26. * @var PimcoreConfig\Config|null
  27. */
  28. private ?PimcoreConfig\Config $config = null;
  29. /**
  30. * @var string|null
  31. */
  32. private ?string $file = null;
  33. /**
  34. * @return PimcoreConfig\Config
  35. */
  36. public function loadConfig(): PimcoreConfig\Config
  37. {
  38. if (!$this->config) {
  39. if ($this->configFileExists()) {
  40. $this->config = new PimcoreConfig\Config(include $this->locateConfigFile(), true);
  41. if (isset($this->config->bundle) && $this->config->bundle->count() > 0) {
  42. trigger_deprecation(
  43. 'pimcore/pimcore',
  44. '10.5',
  45. 'Registering bundles through extensions.php is deprecated and will not work on Pimcore 11. Use config/bundles.php to register/deregister bundles.'
  46. );
  47. }
  48. }
  49. if (!$this->config) {
  50. $this->config = new PimcoreConfig\Config([], true);
  51. }
  52. }
  53. return $this->config;
  54. }
  55. /**
  56. * @param PimcoreConfig\Config $config
  57. */
  58. public function saveConfig(PimcoreConfig\Config $config)
  59. {
  60. $this->config = $config;
  61. File::putPhpFile(
  62. $this->locateConfigFile(),
  63. to_php_data_file_format($config->toArray())
  64. );
  65. }
  66. /**
  67. * @return string
  68. */
  69. public function locateConfigFile(): string
  70. {
  71. if (null === $this->file) {
  72. $this->file = PimcoreConfig::locateConfigFile('extensions.php');
  73. }
  74. return $this->file;
  75. }
  76. /**
  77. * @return bool
  78. */
  79. public function configFileExists(): bool
  80. {
  81. $file = $this->locateConfigFile();
  82. return file_exists($file);
  83. }
  84. }