Reputation: 501
I'm trying to update my Cake 1.3 app to 2.0. In some of the Model methods I'm loading the Session and Email components like this:
App::uses('SessionComponent', 'Controller/Component');
App::uses('EmailComponent', 'Controller/Component');
$Session = new SessionComponent();
$Email = new EmailComponent();
However when I load those pages I get this error:
Warning (4096): Argument 1 passed to Component::__construct() must be an instance of ComponentCollection, none given, called in /Users/username/Sites/cake2app/app/Model/User.php on line 183 and defined [CORE/Cake/Controller/Component.php, line 77]
Notice (8): Undefined variable: collection [CORE/Cake/Controller/Component.php, line 78]
What's the proper way to load and use Components in Cake 2.0 like we could with Cake 1.3?
Upvotes: 0
Views: 1706
Reputation: 9964
The EmailComponent
has been replaced by the CakeEmail
class, see http://book.cakephp.org/2.0/en/core-utility-libraries/email.html for more information about how this class is used.
And instead of the SessionComponent
you have to use the CakeSession
class when you want to access the session in your model. You can include this class with:
App::uses('CakeSession', 'Model/Datasource');
It is not necessary to instantiate this class.
Upvotes: 1