I have the following class that has a constructor that set values for private variables:
class APISession {
//Definidas en el constructor
private $db;
private $logDB;
private $logWS;
//Definidas acorde a la funcion
private $userID;
public function __construct($instanceDB, $instanceDBLog, $instanceWSLog) {
$this->db = $instanceDB;
$this->logDB = $instanceDBLog;
$this->logWS = $instanceWSLog;
}
}
And then I have a child Class that inherits from previous one
require_once 'claseAPISession.php';
class FBSession extends APISession {
private $fbAppId = '99999999999999';
private $fbAppSecret = 'xxxxxxxxxxxxxxx';
//Instancia de la App
private $FBApp;
public function __construct($instanceDB, $instanceDBLog, $instanceWSLog) {
parent::__construct($instanceDB, $instanceDBLog, $instanceWSLog);
//Genera la instancia de la APP de Facebook
$fb = new Facebook\Facebook([
'app_id' => $this->fbAppId,
'app_secret' => $this->fbAppSecret,
'default_graph_version' => 'v2.5',
]);
$this->FBApp = $fb;
}
public function verifyRegister($accessToken) {
//$oAuth2Client = $this->FBApp->getOAuth2Client();
//$tokenMetadata = $oAuth2Client->debugToken($accessToken);
//$tokenMetadata->validateAppId($this->fbAppId);
$params = ["access_token" => $accessToken];
return $this->makeGETAPIRequest($params);
}
private function makeGETAPIRequest($params){
$request = $this->FBApp->request('GET', '/me', $params);
try {
$response = $this->FBApp->getClient()->sendRequest($request);
} catch (Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo "Facebook Graph API retorno error " . $e->getMessage();
$this->logDB->error('Graph returned an error: ' . $e->getMessage());
exit();
} catch (Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo "Facebook SDK retorno error " . $e->getMessage();
$this->logDB->error('Facebook SDK returned an error: ' . $e->getMessage());
exit();
}
//$graphNode = $response->getGraphNode();
return $graphNode;
}
}
And I call the second class like this
$session = new FBSession($this->db, $this->logDB, $this->logWS);
$v = $session->verifyRegister($httpBody['accessTokenFB']);
The error I get when calling the second class is this
Notice: Undefined property: FBSession::$logDB in C:\wamp\www\recomendado\api\clases\claseFBSession.php
So that means it isn't inheriting variables from constructor, how could I manage to do this?