Reputation: 1028
I'm currently trying to extend the BaseAuthenticate class within CakepPHP (in the cake\lib\Cake\Controller\Component\Auth
folder) via the FormAuthenticate class and I'm having trouble extending the construct function.
I'm trying to extend the construct function to declare a new object that can then be used throughout the class.
//BaseAuthenticate.php
public function __construct(ComponentCollection $collection, $settings) {
$this->_Collection = $collection;
$this->settings = Hash::merge($this->settings, $settings);
}
//ExtendedFormAuthenticate.php
public function __construct()
{
parent::__construct(ComponentCollection $collection, $settings);
}
If I use the above __construct in ExtendedFormAuthenticate.php I get the error message syntax error, unexpected T_VARIABLE
public function __construct()
{
parent::__construct($collection, $settings);
}
If I use the above __construct in ExtendedFormAuthenticate.php I get undefined variable
error messages because I'm not populating those variables, but I don't know what to populate them with.
Does anyone know how I can successfully extend the BaseAuthenticate.php construct function? Or alternatively, does anyone know how to declare an object to be used within a class without it being in the __construct function?
Upvotes: 0
Views: 946
Reputation: 1772
Try changing this:
public function __construct()
{
parent::__construct(ComponentCollection $collection, $settings);
}
to this:
public function __construct(ComponentCollection $collection, $settings)
{
parent::__construct($collection, $settings);
}
Upvotes: 5