TestAuthComponent.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. $this->authCheckCalledFrom = $event->name;
  27. return;
  28. }
  29. return parent::_authCheck($event);
  30. }
  31. /**
  32. * Helper method to add/set an authenticate object instance
  33. *
  34. * @param int $index The index at which to add/set the object
  35. * @param Object $object The object to add/set
  36. * @return void
  37. */
  38. public function setAuthenticateObject($index, $object)
  39. {
  40. $this->_authenticateObjects[$index] = $object;
  41. }
  42. /**
  43. * Helper method to add/set an authorize object instance
  44. *
  45. * @param int $index The index at which to add/set the object
  46. * @param Object $object The object to add/set
  47. * @return void
  48. */
  49. public function setAuthorizeObject($index, $object)
  50. {
  51. $this->_authorizeObjects[$index] = $object;
  52. }
  53. }