1

I'm trying to import Joomla in a Yii application. It goes well, but some plugins and libraries are not loaded. Does anyone know how to achieve this? Something like

JPluginHelper::loadAllActivePlugins();

This is my code so far:

    define('_JEXEC', 1); 

    $joomlaRootFolder = \Yii::$app->params['joomlaRootFolder'];

    if (file_exists($joomlaRootFolder . '/defines.php')) {
        include_once $joomlaRootFolder . '/defines.php';
    }   

    if (!defined('_JDEFINES')) {
        define('JPATH_BASE', $joomlaRootFolder);
        require_once JPATH_BASE . '/includes/defines.php';
    }   

    require_once JPATH_BASE . '/includes/framework.php';

    // Instantiate the application.
    $app = \JFactory::getApplication('site');
    $app->initialise();

    // Breaks here!
    \MyGlobalLibrary::didNotFindClass();

The library works as expected in our Joomla code, so that's not the problem.

Edit: My solution was to manually call

    \JPluginHelper::importPlugin('system');
    \JEventDispatcher::getInstance()->trigger('onAfterInitialise');

Seems like this was not done in the $app->initialise() method.

1
  • If you have solved your own issue, please post the solution as an answer so future readers can look in "expected" places on the page for "expected" information. After you have posted a clear, complete, educational answer that can benefit others, you may award your answer the green tick so that the question is deemed to be "resolved" by the system and future researchers will know that this is a working solution. (Please minimize tabbing in your code blocks for easier reading -- less horizontal scrolling.) Sep 14, 2018 at 23:05

1 Answer 1

0

As stated in my edit of the question, the solution was to include

\JPluginHelper::importPlugin('system');
\JEventDispatcher::getInstance()->trigger('onAfterInitialise');

after

$app = \JFactory::getApplication('site');
$app->initialise();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.