Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access shell methods in controller? Cake PHP 1.3

I wrote a shell method in CakePHP 1.3 that has a return value.

I'd like to be able to access that method from within a controller, so that I can pass its return value into the View.

I'm not sure how to access those methods appropriately from within the controller. Have I done it wrong?

I could easily duplicate the code, but I'd like to "keep it DRY", and the actual functionality, I believe, doesn't belong with this particular controller - I just need it's return value in this particular view.

EDIT:

I realize I'm sort of asking the wrong question here, since the Shell itself shouldn't necessarily return a value. I've changed the code so that the Shell is only using the return value I want, and now I wonder - what is the appropriate place for extra classes/code that needs to be accessed from a Shell and a Controller?

It seems like Component code, but I'm not sure how to access Components from the Shell. It's not a Plugin, as I understand them. Where does this go?

like image 608
anonymous coward Avatar asked Dec 03 '25 17:12

anonymous coward


1 Answers

In one of the projects we imported shell tasks, ex:


App::import('Core', 'Shell');
App::Import('Vendor','shells/tasks/sometask');

$returndata = TasknameTask::execute($somevalue);


like image 145
openprojdevel Avatar answered Dec 06 '25 07:12

openprojdevel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!