Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Using Components (or whole Controllers) in a cake-shell
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
leberle  
View profile   Translate to Translated (View Original)
 More options 21 Oct, 11:44
From: leberle <leberkne...@gmx.de>
Date: Wed, 21 Oct 2009 03:44:43 -0700 (PDT)
Local: Wed 21 Oct 2009 11:44
Subject: Using Components (or whole Controllers) in a cake-shell
Hi, i'm currently working on a cake-shell cron, and i got some trouble
using one of the components from my App.
I need to use a method from a component that is usally used in my
Orders-Controller, i tried:

---------------------

App::import('Component','OrderProcess');

class OrdersCronShell extends Shell
{
        var $uses                       = array('Order');
        var $OrderProcess       = false;

        function main()
        {
                $this->OrderProcess = new OrderProcessComponent();
                $res = $this->Order->findAllByStatus('3');
                $order_ids = Set::extract('/Order/id',$res);

                $this->out("got ".count($order_ids)." pending orders");

                for ($x = 0; $x < count($order_ids); $x++) {
                        $transfer_result = $this->OrderProcess->transferOrder($order_ids
[$x]);

                        if (!($transfer_result === true)) {
                                $this->out("failed transfering order ".$order_ids[$x]."\r\n");
                        }
                }
        }

}

---------------------

which results in:
Fatal error: Call to a member function loadOrder() on a non-object in
<app_path>/controllers/components/order_process.php on line 181

The amazing thing here: transferOrder IS called (so i guess there is a
component-object), but the call to the components loadOrder function
(called from within transferOrder) fails... o_O

Then i tried wrapping the whole component-using to a Shell-Task class
(acording to the "using the mail component in a shell"-article from
the bakery) but the same error occured.....

i even tried to load the controller instead of just the component:

---------------------

App::import('Core', 'Controller');
App::import('Controller', 'Orders');

class OrdersCronShell extends Shell
{
        var $uses                       = array('Order');
        var $Orders;

        function main()
        {
                $this->Orders = new OrdersController();
                $this->Orders->constructClasses();

                $res = $this->Order->findAllByStatus('3');
                $order_ids = Set::extract('/Order/id',$res);

                $this->out("got ".count($order_ids)." pending orders");

                for ($x = 0; $x < count($order_ids); $x++) {
                        $transfer_result = $this->Orders->OrderProcess->transferOrder
($order_ids[$x]);

                        if (!($transfer_result === true)) {
                                $this->out("failed transfering order ".$order_ids[$x]."\r\n");
                        }
                }
        }

}

---------------------

..same error....any help?


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
leberle  
View profile   Translate to Translated (View Original)
 More options 21 Oct, 12:29
From: leberle <leberkne...@gmx.de>
Date: Wed, 21 Oct 2009 04:29:48 -0700 (PDT)
Local: Wed 21 Oct 2009 12:29
Subject: Re: Using Components (or whole Controllers) in a cake-shell
Solved :)

For some reason the initialization of the component failed, even if
the controllers constructClasses() is called...
solved by:

$this->Orders = new OrdersController();
$this->Orders->constructClasses();
$this->Orders->OrderProcess->initialize(&$this->Orders);

:)

On 21 Okt., 12:44, leberle <leberkne...@gmx.de> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RoBo  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 06:31
From: RoBo <reuben...@gmail.com>
Date: Wed, 4 Nov 2009 22:31:59 -0800 (PST)
Local: Thurs 5 Nov 2009 06:31
Subject: Re: Using Components (or whole Controllers) in a cake-shell
Hey, did you still have to use App::import for your fix?

On Oct 21, 9:29 pm, leberle <leberkne...@gmx.de> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google