ConfiguredComponent.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.3.6
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace TestApp\Controller\Component;
  16. use Cake\Controller\Component;
  17. use Cake\Controller\ComponentRegistry;
  18. /**
  19. * A test component that makes a copy of the configuration.
  20. */
  21. class ConfiguredComponent extends Component
  22. {
  23. /**
  24. * @var array
  25. */
  26. public $configCopy;
  27. /**
  28. * components property
  29. *
  30. * @var array
  31. */
  32. protected $components = [];
  33. /**
  34. * Constructor
  35. *
  36. * @param ComponentRegistry $registry A ComponentRegistry this component can use to lazy load its components
  37. * @param array $config Array of configuration settings.
  38. * @param array $components Array of child components.
  39. */
  40. public function __construct(ComponentRegistry $registry, array $config, array $components = [])
  41. {
  42. $this->components = $components;
  43. parent::__construct($registry, $config);
  44. }
  45. /**
  46. * @param array $config
  47. */
  48. public function initialize(array $config): void
  49. {
  50. $this->configCopy = $config;
  51. parent::initialize($config);
  52. }
  53. }