CConsoleCommandBehavior.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * CConsoleCommandBehavior class file.
  4. *
  5. * @author Evgeny Blinov <e.a.blinov@gmail.com>
  6. * @link http://www.yiiframework.com/
  7. * @copyright 2008-2013 Yii Software LLC
  8. * @license http://www.yiiframework.com/license/
  9. */
  10. /**
  11. * CConsoleCommandBehavior is a base class for behaviors that are attached to a console command component.
  12. *
  13. * @property CConsoleCommand $owner The owner model that this behavior is attached to.
  14. *
  15. * @author Evgeny Blinov <e.a.blinov@gmail.com>
  16. * @package system.console
  17. * @since 1.1.11
  18. */
  19. class CConsoleCommandBehavior extends CBehavior
  20. {
  21. /**
  22. * Declares events and the corresponding event handler methods.
  23. * The default implementation returns 'onAfterConstruct', 'onBeforeValidate' and 'onAfterValidate' events and handlers.
  24. * If you override this method, make sure you merge the parent result to the return value.
  25. * @return array events (array keys) and the corresponding event handler methods (array values).
  26. * @see CBehavior::events
  27. */
  28. public function events()
  29. {
  30. return array(
  31. 'onBeforeAction' => 'beforeAction',
  32. 'onAfterAction' => 'afterAction'
  33. );
  34. }
  35. /**
  36. * Responds to {@link CConsoleCommand::onBeforeAction} event.
  37. * Override this method and make it public if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
  38. * @param CConsoleCommandEvent $event event parameter
  39. */
  40. protected function beforeAction($event)
  41. {
  42. }
  43. /**
  44. * Responds to {@link CConsoleCommand::onAfterAction} event.
  45. * Override this method and make it public if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
  46. * @param CConsoleCommandEvent $event event parameter
  47. */
  48. protected function afterAction($event)
  49. {
  50. }
  51. }