joomla Jfactory does not instantiate itselft in a joomla webapp ( joomla 2.5 )

Go To StackoverFlow.com

1

I am trying to building an external webApp to upload some products in Joomla! with virtuemart.
All works as expected but I have still a problem with Jfactory::getApplication.

I have followed this tutorial:

http://docs.joomla.org/How_to_create_a_stand-alone_application_using_the_Joomla!_Platform

But when I go calling the VmModel on the __construct method it calls a parent::__construct($config):

$this->_cidName = $cidName;
// Get the pagination request variables
$mainframe = JFactory::getApplication() ;
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');

That raises the following error:

vCall to undefined method JException::getUserStateFromRequest()

If could help there is also:

vNotice: Trying to get property of non-object in /home/giuseppe/homeProj/ModaNuovo/libraries/joomla/application/application.php on line 201

raised by:

public static function getInstance($client, $config = array(), $prefix = 'J')
{
    if (empty(self::$instances[$client]))
    {
        // Load the router object.
        $info = JApplicationHelper::getClientInfo($client, true);

        $path = $info->path . '/includes/application.php';
        if (file_exists($path))
2012-04-05 16:11
by giuseppe
The problem is that JApplicationWeb does not extend JApplication, and also trying make it extend those methods are protected - giuseppe 2012-04-06 09:09
this could be better way in Joomla3.x. $app = JFactory::getApplication('site'); // Initialise the application. $app->initialise() - Anant 2016-10-21 08:50


0

The solution is to instantiate the main app together with your one, and if needed also login the following way:

$app = JFactory::getApplication('administrator');

// create a form token
$user = JFactory::getUser(42);
$session = JFactory::getSession();
$hash = JApplication::getHash($user->get('id', 0) . $session->getToken(true));

If needed you have also to perform login to validate this hash.

2012-04-20 07:20
by giuseppe
Ads