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. class TestAuthComponent extends AuthComponent
  21. {
  22. public function authCheck(Event $event)
  23. {
  24. if (isset($this->earlyAuthTest)) {
  25. if ($this->_config['checkAuthIn'] !== $event->name()) {
  26. return;
  27. }
  28. $this->authCheckCalledFrom = $event->name();
  29. return;
  30. }
  31. return parent::authCheck($event);
  32. }
  33. /**
  34. * Helper method to add/set an authenticate object instance
  35. *
  36. * @param int $index The index at which to add/set the object
  37. * @param Object $object The object to add/set
  38. * @return void
  39. */
  40. public function setAuthenticateObject($index, $object)
  41. {
  42. $this->_authenticateObjects[$index] = $object;
  43. }
  44. /**
  45. * Helper method to add/set an authorize object instance
  46. *
  47. * @param int $index The index at which to add/set the object
  48. * @param Object $object The object to add/set
  49. * @return void
  50. */
  51. public function setAuthorizeObject($index, $object)
  52. {
  53. $this->_authorizeObjects[$index] = $object;
  54. }
  55. }