Example #1
0
        return;
    }
    if (!in_array("{$plugin->name}\\", array_keys($classLoader->getPrefixesPsr4()))) {
        $classLoader->addPsr4("{$plugin->name}\\", normalizePath("{$plugin->path}/src/"), true);
    }
    if (!in_array("{$plugin->name}\\Test\\", array_keys($classLoader->getPrefixesPsr4()))) {
        $classLoader->addPsr4("{$plugin->name}\\Test\\", normalizePath("{$plugin->path}/tests/"), true);
    }
    $info = ['autoload' => false, 'bootstrap' => true, 'routes' => true, 'path' => normalizePath("{$plugin->path}/"), 'classBase' => 'src', 'ignoreMissing' => true];
    Plugin::load($plugin->name, $info);
    foreach ($plugin->eventListeners as $fullClassName) {
        if (class_exists($fullClassName)) {
            if (str_ends_with($fullClassName, 'Shortcode')) {
                EventDispatcher::instance('Shortcode')->eventManager()->on(new $fullClassName());
            } else {
                EventDispatcher::instance()->eventManager()->on(new $fullClassName());
            }
        }
    }
    $pluginsPath[] = $info['path'];
});
if (empty($pluginsPath)) {
    die("Ops, something went wrong. Try to clear your site's snapshot and verify write permissions on /tmp directory.");
}
/**
 * Initialize Aspects
 */
AppAspect::getInstance()->init(['debug' => Configure::read('debug'), 'cacheDir' => TMP . 'aop', 'includePaths' => array_unique(array_merge($pluginsPath, [ROOT . DS . 'plugins', QUICKAPPS_CORE, CAKE])), 'excludePaths' => [TMP . 'aop'], 'features' => \Go\Aop\Features::INTERCEPT_FUNCTIONS]);
/**
 * Connect middleware/dispatcher filters.
 */
 /**
  * Invokes shortcode lister method for the given shortcode.
  *
  * @param array $m Shortcode as preg array
  * @return string
  * @author WordPress
  */
 protected static function _doShortcode($m)
 {
     // allow {{foo}} syntax for escaping a tag
     if ($m[1] == '{' && $m[6] == '}') {
         return substr($m[0], 1, -1);
     }
     $tag = $m[2];
     $atts = static::_parseAttributes($m[3]);
     $listeners = EventDispatcher::instance('Shortcode')->eventManager()->listeners($tag);
     if (!empty($listeners)) {
         $options = ['atts' => (array) $atts, 'content' => null, 'tag' => $tag];
         if (isset($m[5])) {
             $options['content'] = $m[5];
         }
         $result = EventDispatcher::instance('Shortcode')->triggerArray([$tag, static::cache('context')], $options)->result;
         return $m[1] . $result . $m[6];
     }
     return '';
 }
 /**
  * Retrieves the number of times an event was triggered, or the complete list
  * of events that were triggered.
  *
  * @param string|null $eventName The name of the event, if null returns the
  *  entire list of event that were fired
  * @return int|array
  * @see CMS\Event\EventDispatcher::triggered()
  */
 public function triggered($eventName = null)
 {
     return EventDispatcher::instance()->triggered($eventName);
 }