public function trigger($config = array())
    {
        // Can't put arguments through KObjectConfig as it loses referenced variables
        $attributes = isset($config['attributes']) ? $config['attributes'] : array();
        $config     = new KObjectConfig($config);
        $config->append(array(
            'name'         => null,
            'import_group' => null
        ));

        if (empty($config->name)) {
            throw new InvalidArgumentException('Event name is required');
        }

        if(!(count($attributes) > 1)) {
            throw new InvalidArgumentException('Event requires at least 2 attributes');
        }

        if ($config->import_group) {
            JPluginHelper::importPlugin($config->import_group);
        }

        $results = JEventDispatcher::getInstance()->trigger($config->name, $attributes);

        if($config->name == 'onContentPrepare')
        {
            if(isset($attributes[1]) && isset($attributes[1]->text)) {
                $result = $attributes[1]->text;
            }
        }
        else $result = trim(implode("\n", $results));

        // Leave third party JavaScript as-is
        $result = str_replace('<script', '<script data-inline', $result);

        return $result;
    }