PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/Extensions/Event/ExtensionsEventHandler.php

https://github.com/kareypowell/croogo
PHP | 67 lines | 40 code | 7 blank | 20 comment | 2 complexity | 44c0498727d88d59cab5d64c92d516b4 MD5 | raw file
  1. <?php
  2. App::uses('CakeEventListener', 'Event');
  3. /**
  4. * ExtensionsEventHandler
  5. *
  6. * @package Croogo.Extensions.Event
  7. * @author Rachman Chavik <rchavik@gmail.com>
  8. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  9. * @link http://www.croogo.org
  10. */
  11. class ExtensionsEventHandler implements CakeEventListener {
  12. /**
  13. * implementedEvents
  14. */
  15. public function implementedEvents() {
  16. return array(
  17. 'Croogo.bootstrapComplete' => array(
  18. 'callable' => 'onBootstrapComplete',
  19. ),
  20. 'Croogo.beforeSetupAdminData' => array(
  21. 'callable' => 'onBeforeSetupAdminData',
  22. ),
  23. 'Croogo.setupAdminData' => array(
  24. 'callable' => 'onSetupAdminData',
  25. ),
  26. );
  27. }
  28. /**
  29. * Before Setup admin data
  30. */
  31. public function onBeforeSetupAdminData($event) {
  32. $plugins = CakePlugin::loaded();
  33. $config = 'Config' . DS . 'admin.php';
  34. foreach ($plugins as $plugin) {
  35. $file = CakePlugin::path($plugin) . $config;
  36. if (file_exists($file)) {
  37. require $file;
  38. }
  39. }
  40. }
  41. /**
  42. * Setup admin data
  43. */
  44. public function onSetupAdminData($event) {
  45. $plugins = CakePlugin::loaded();
  46. $config = 'Config' . DS . 'admin_menu.php';
  47. foreach ($plugins as $plugin) {
  48. $file = CakePlugin::path($plugin) . $config;
  49. if (file_exists($file)) {
  50. require $file;
  51. }
  52. }
  53. }
  54. /**
  55. * onBootstrapComplete
  56. */
  57. public function onBootstrapComplete($event) {
  58. CroogoPlugin::cacheDependencies();
  59. }
  60. }