OrangeComponent.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright 2005-2011, Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (https://cakefoundation.org)
  10. * @link https://cakephp.org CakePHP(tm) Project
  11. * @since 3.0.0
  12. * @license https://opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace TestApp\Controller\Component;
  15. use Cake\Controller\Component;
  16. use Cake\Controller\Controller;
  17. use Cake\Event\Event;
  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. public $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)
  44. {
  45. $this->Controller = $this->_registry->getController();
  46. $this->Banana->testField = 'OrangeField';
  47. }
  48. /**
  49. * startup method
  50. *
  51. * @param Event $event
  52. * @return void
  53. */
  54. public function startup(Event $event)
  55. {
  56. $this->Controller->foo = 'pass';
  57. }
  58. }