Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Patched for cakePHP3: #34

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Patched for cakePHP3: #34

wants to merge 8 commits into from

Conversation

manierim
Copy link

A few changes I made to actually be able to let Jobs be correctly executed as CakePHP 3 Shells.
These goes together with the PR#92 on Cake-Resque

Main things:

  • no longer look for a perform method in the Shell but use the runCommand method
  • to be able to do this, CakeResque/Resque_Job_Creator now returns an array with instance and method name
  • a few namespacing issues fixed

- Resque_Job_Creator can return an array containing the class instance, the class method to invoke and the arguments to be passed to it, and the beforePerform and tearDown methods' names

Improved Exceptions message expliciting "Resque_Job_Creator not loaded"
…antiated by the Resque_Job_Creator class

(for CakePHP the args property equals the argv from the CLI that include as 0th element the script file name, this must be mocked inside the Resque_Job_Creator class)
$instance = $this->getInstance();
if (is_array($instance))
{
if (isset($instance[4]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this sorcery? These seem to be magic numbers. I've no idea what these things mean :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are a way to allow helper class Resque_Job_Creator to be more flexible and use variable names for "perform" , "setUP" and "tearDown" methods to better match underneat job classes
For example to use CakePHP shells as jobs: wa0x6e/Cake-Resque#92

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you're saying that if Resque_Job_Creator returns an array, then it'll override some settings?

I'm not sure if this is the way you want to go about things... I mean - why not just have something like

public function setUp() 
{
    return $this->realSetUp();
}

public function perform($args) 
{
    return $this->realPerform($args);
}

I'm really not a fan of this, and think it goes significantly against the original design of resque.

Can I see a use case for when this would actually be useful? Because I can only think of horrendously convoluted examples.

oanhnn pushed a commit to rikkeisoft/php-resque-ex that referenced this pull request Mar 16, 2016
oanhnn pushed a commit to rikkeisoft/php-resque-ex that referenced this pull request Mar 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants