TestAuthComponent.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://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. (http://cakefoundation.org)
  10. * @link http://cakephp.org CakePHP(tm) Project
  11. * @since 3.0.0
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace TestApp\Controller\Component;
  15. use Cake\Controller\Component\AuthComponent;
  16. use Cake\Event\Event;
  17. /**
  18. * TestAuthComponent class
  19. *
  20. */
  21. class TestAuthComponent extends AuthComponent
  22. {
  23. public function authCheck(Event $event)
  24. {
  25. if (isset($this->earlyAuthTest)) {
  26. if ($this->_config['checkAuthIn'] !== $event->name()) {
  27. return;
  28. }
  29. $this->authCheckCalledFrom = $event->name();
  30. return;
  31. }
  32. return parent::authCheck($event);
  33. }
  34. /**
  35. * Helper method to add/set an authenticate object instance
  36. *
  37. * @param int $index The index at which to add/set the object
  38. * @param Object $object The object to add/set
  39. * @return void
  40. */
  41. public function setAuthenticateObject($index, $object)
  42. {
  43. $this->_authenticateObjects[$index] = $object;
  44. }
  45. /**
  46. * Helper method to add/set an authorize object instance
  47. *
  48. * @param int $index The index at which to add/set the object
  49. * @param Object $object The object to add/set
  50. * @return void
  51. */
  52. public function setAuthorizeObject($index, $object)
  53. {
  54. $this->_authorizeObjects[$index] = $object;
  55. }
  56. }