Using jobs within a package

Permalink
I've seen that I can create a job within my own package. That's nice, I think it wasn't always like that..

However, I can't find the proper method to access it. getByID simply ignores the package which might return the wrong job in case you have two jobs with the same handle in two packages..

Did I miss something?

final static function getByHandle( $jHandle='' ){
      $db = Loader::db(); 
      $jobData = $db->getRow( 'SELECT * FROM Jobs WHERE jHandle=?', array($jHandle) );
      if( !$jobData || !$jobData['jHandle']  ) return NULL; 
      return Job::getJobObjByHandle( $jobData['jHandle'], $jobData );
   }

Remo
 
andrew replied on at Permalink Best Answer Reply
andrew
You can't have two jobs with the same handle in two packages. Packages aren't namespaces - if you try and have two blocks with the same handle in two packages you'll have problems. So when in doubt, just put your package's handle as part of your job/blocktype/etc... and then use Job::getByHandle()

e.g.

if your package is "my_package" and your job is "Clean Stuff" just give it the handle "my_package_clean_stuff" and reference it as

$j = Job::getByHandle('my_package_clean_stuff');

Also - most of the time you won't need to call the job yourself - you can just install it and let the admins choose when/how to run it.
Remo replied on at Permalink Reply
Remo
hmm no idea what's going on with my brain, I should probably take off a day /-:

Thanks!