collections.plugin.php 941 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Collections
  4. *
  5. * DESCRIPTION
  6. *
  7. * This plugin inject JS to handle proper working of close buttons in Resource's panel (OnDocFormPrerender)
  8. * This plugin handles setting proper show_in_tree parameter (OnBeforeDocFormSave, OnResourceSort)
  9. *
  10. * @var modX $modx
  11. * @var array $scriptProperties
  12. */
  13. $corePath = $modx->getOption('collections.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/collections/');
  14. /** @var Collections $collections */
  15. $collections = $modx->getService(
  16. 'collections',
  17. 'Collections',
  18. $corePath . 'model/collections/',
  19. array(
  20. 'core_path' => $corePath
  21. )
  22. );
  23. if (!($collections instanceof Collections)) return '';
  24. $className = "\\Collections\\Events\\{$modx->event->name}";
  25. if (class_exists($className)) {
  26. /** @var \Collections\Events\Event $handler */
  27. $handler = new $className($modx, $scriptProperties);
  28. $handler->run();
  29. }
  30. return;