The purpose of this code is just separate the config data. If i use the $config array directly in the example.php all works properly. However in the code below i get different values.
facebook.php
<?php
class Facebook extends AppController{
public function __construct() {
$config = array();
$config['appId'] = '400xxx6'; //YOUR_APP_ID
$config['secret'] = 'f70f01e76xxx7e'; //YOUR_APP_SECRET
$config['cookie'] = false;
return $config;
}
}
?>
example.php
<?php
App::import('Config', 'Facebook');
$a = new Facebook();
var_dump($a);
?>
Why $var_dump($a); return something like this?
object(Facebook)[50]
protected 'appId' => null
protected 'apiSecret' => null
protected 'user' => null
protected 'signedRequest' => null
protected 'state' => string 'e4ac55f1xxx87a88' (length=32)
protected 'accessToken' => null
protected 'fileUploadSupport' => boolean false
What I want is the original array. What is the mistake?
array
'appId' => string '400xxx6' (length=15)
'secret' => string 'f70f01e76xxx7e' (length=32)
'cookie' => boolean false
I’m pretty sure that when you do:
the class being instantiated is not the one you created. I believe you use Facebook PHP SDK, and their class name is also
Facebook. You have conflicting class names.Change your class name for something else like
FacebookConfigand you’ll be fine.Also, it would make more sense to store your array in the class instance, something like: