Goutam.A.S
Goutam.A.S

Reputation: 47

Get the contents of parent class

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

Answers (1)

MrChux
MrChux

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

Related Questions