OrangeComponent.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright 2005-2011, 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 2005-2011, Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  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\Event\EventInterface;
  18. /**
  19. * OrangeComponent class
  20. *
  21. * @property BananaComponent $Banana
  22. */
  23. class OrangeComponent extends Component
  24. {
  25. /**
  26. * components property
  27. *
  28. * @var array
  29. */
  30. protected array $components = ['Banana'];
  31. /**
  32. * controller property
  33. *
  34. * @var Controller
  35. */
  36. public $Controller;
  37. /**
  38. * initialize method
  39. *
  40. * @param array $config
  41. * @return void
  42. */
  43. public function initialize(array $config): void
  44. {
  45. $this->Controller = $this->_registry->getController();
  46. $this->Banana->testField = 'OrangeField';
  47. }
  48. /**
  49. * startup method
  50. *
  51. * @return void
  52. */
  53. public function startup(EventInterface $event): void
  54. {
  55. $this->Controller->foo = 'pass';
  56. }
  57. }