loaded. The shell by default does not load much more than is necessary
to run the shell commands. So I've found that most of the time you
need to build up the shell environment to support what you will be
using.
I would try adding this to the top of your shell
App::import('Core', array('Controller','Component',
'View','Model','Router','Validation', 'Behavior'));
Also in my shells I've had to instantiate many of the objects. In
other words the cake magic just doesn't exists. So in my shell's
Initialize I have the following: (this shell deals with a controller a
couple models and a view to send some emails on a cron job.
function initialize() {
//$this->Controller =& new Controller();
//$this->Component =& new Component();
$this->ProfileController =& new ProfilesController();
$this->ProfileController->uses = array('Profile','User');
$this->ProfileController->Profile =& new Profile();
$this->ProfileController->Project =& new Project();
$this->ProfileController->Email =& new EmailComponent();
$this->ProfileController->Email->initialize($this-
>ProfileController);
$this->_loadModels();
}
You could also verify that the Behaviors are loaded by dumping $this-
>Issue->Behaviors or checking to see if it is null. If it is null then
you will not have any validation available.
In the Model class the chunk of code that does the check your
referring to follows the following stack You could add some debug code
to these functions to identify what is different in the environment
between accessing via the web vs the shell.
save(), validation(), invalidFields(), exists()
You might also want to take a look at this page in the manual as the
path environment is also important especially to the imports. Your
shell may not know where to find the right path to import the
behaviors etc.
http://book.cakephp.org/view/846/Running-Shells-as-cronjobs
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment