ReadOnlyTestInstanceConfig.php 708 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace TestApp\Config;
  3. use Cake\Core\InstanceConfigTrait;
  4. use Exception;
  5. class ReadOnlyTestInstanceConfig
  6. {
  7. use InstanceConfigTrait;
  8. /**
  9. * _defaultConfig
  10. *
  11. * Some default config
  12. *
  13. * @var array
  14. */
  15. protected $_defaultConfig = [
  16. 'some' => 'string',
  17. 'a' => [
  18. 'nested' => 'value',
  19. 'other' => 'value',
  20. ],
  21. ];
  22. /**
  23. * Example of how to prevent modifying config at run time
  24. *
  25. * @throws \Exception
  26. * @param array|string $key
  27. * @param mixed $value
  28. */
  29. protected function _configWrite($key, $value): void
  30. {
  31. throw new Exception('This Instance is readonly');
  32. }
  33. }