iwato Posted November 16, 2018 Share Posted November 16, 2018 BACKGROUND: While implementing Peppe Occhi's CRON Scheduler I have come across several lines of code that I am not entirely familiar. In particular I am concerned with the following: $scheduler->php('script.php')->hourly(); found under the heading Schedules execution time. It appears to be of this format $some_instance->some_methodA(arguments)->method_B(arguments); QUESTION: Is the above expression equivalent to the following: $some_instance->some_methodA(arguments); $some_instance->method_B(arguments); In other words, the following is correct: $scheduler->php( 'path_to_folder/script.php', 'path_to_php_version/ea-php72', ['-c' => 'ignore','--merge' => null,], 'file_name' ); $scheduler->hourly(); Please advise. Roddy Link to comment Share on other sites More sharing options...
Ingolme Posted November 16, 2018 Share Posted November 16, 2018 No, it's not equivalent, there are actually two objects there: One is the scheduler and the other is whatever thing the scheduler's php() method is returning. The above code is equivalent to this: $thing = $scheduler->php('script.php'); $thing->hourly(); I don't know what type of object $thing is, since I haven't read the documentation. The concept of chaining is not native to any language, it only happens if somebody designed the objects to work that way. 1 Link to comment Share on other sites More sharing options...
iwato Posted November 17, 2018 Author Share Posted November 17, 2018 FOLLOW-UP QUESTION: In light of the above does the following make sense: $matomo_api = new Scheduler(); $matomo_freq = $matomo_api->php('.../fetch_and_store.php','.../bin/ea-php72',['-c' => 'ignore','--merge' => null,],'matomo_api'); $matomo_freq->hourly(); $matomo_api->run(); Roddy Link to comment Share on other sites More sharing options...
Ingolme Posted November 17, 2018 Share Posted November 17, 2018 That will probably work. You should test it to make sure. Run the code and see if it does what you expected it to. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now