eZ Community » Forums » Developer » Configuring extension siteaccess for...
expandshrink

Configuring extension siteaccess for cronjob

Configuring extension siteaccess for cronjob

Monday 29 April 2013 11:10:24 am - 3 replies

I'm trying to set siteaccess inside a custom extension. This extension can run using both web browser with a view and a cronjob, and can be launched from web view using admin siteaccess.

I have 2 custom ini files inside:

myextension/settings/siteaccess/admin_dev/myextension.ini.append.php

myextension/settings/siteaccess/admin_test/myextension.ini.append.php

Now the problem is: when i run the extension from web view, like

admin.dev.mysite.it/myextension/myview
admin.test.mysite.it/myextension/myview 

it works in both environment, but it doesn't work when it run using runcronjobs. In other words, it cannot find ini when it execute from cli php.

After that i understand why, i have to specify with -s the siteaccess like this:

php runcronjobs.php -s admin_dev nodeimport
php runcronjobs.php -s admin_test nodeimport

Now the question: how can i configure cronjob that every time executes use automatically a siteaccess that is different from the default one?

Wednesday 01 May 2013 11:23:14 am

As always, I recommedn to take a look at the code of ezcontentstaging extension for all needs related to content import  export.

Look at https://github.com/gggeek/ezcontentstaging/blob/master/classes/models/field.php and serach for "edzmedia" to see how I serialize/deserialize binary file data

(in other words: for some datatypes fromstring()/tostring() are good, for some others not really enough

Modified on Wednesday 01 May 2013 11:24:08 am by Gaetano Giunta

Wednesday 01 May 2013 4:18:12 pm

It's actually possible to switch siteaccess on the fly, using something like this:

 eZSiteAccess::load( array( 'name' => $siteAccess, 'type' => eZSiteAccess::TYPE_HTTP_HOST ) );

However, there's no guarantee for which ini settings are actually reread because of this (ini settings are read at different times during the process of a script/page view). And I've never tried using it in a cronjob. So this requires lots of testing.

PS1: Now I wonder why you would need something like this? Might be there are better solutions?

PS2: Gaetano, I suspect you replied to the wrong post? happy.gif Emoticon

Wednesday 01 May 2013 7:16:52 pm

Arne, you are right of course - I was answering to another post from Ruben

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from