Reputation: 47
I am new to object oriented programming. I need to access contents of $key variable generated in abstract parent class in child class. How to get contents of $key variable in postAction() method?
abstract class ApiControllerAbstract extends Zend_Rest_Controller {
public function init() {
$cryptoHelper = new Application_Model_CryptoHelper;
$pass = '';
$salt = '';
$passwordIterations = 100;
$keySize = 32;
$iv = "";
$key = $cryptoHelper->getKey($pass, $salt, $passwordIterations, $keySize);
}
}
class Api_SubscribersuploadController extends ApiControllerAbstract {
public function postAction() {
// I need to access contents of key variable from here.
echo parent::$this->key;
}
}
I tried using echo parent::$this->key;
But It doesn't display anything.
Upvotes: 0
Views: 60
Reputation: 120
abstract class ApiControllerAbstract extends Zend_Rest_Controller {
public function init() {
$cryptoHelper = new Application_Model_CryptoHelper;
$pass = '';
$salt = '';
$passwordIterations = 100;
$keySize = 32;
$iv = "";
$key = $cryptoHelper->getKey($pass, $salt, $passwordIterations, $keySize);
return $key;
}
}
class Api_SubscribersuploadController extends ApiControllerAbstract {
public function postAction() {
// I need to access contents of key variable from here.
$this->init();
}
}
Upvotes: 1