Not sure if I am going the best way about this, I am trying to implement ZENDAMF with codeigniter. One of the problems I have had is that I want to be able to check if the user is logged in before allowing them to make any requests to the servrices behind the zendamf gateway. I did ask a previous question about how to get it to do the check in the construct, but I found out that was not possible.
My next line of thought was to create the gateway as a controller that way I would be able to access my authentication library before the request was posted to the zend amf server. But when I make a call to the service is is not recognizing any of the CodeIgniter methods.
at the moment I am not doing the logged in check as I want to get the amf server working first, so the example I have choosen is to try and return my UserDetails.
here is my gateway.php controller
<?php
// Set up debug
class Gateway extends CI_Controller
{
function __construct()
{
parent::__construct();
error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", "on");
ini_set("include_path",
ini_get('include_path') . ':'
. '/Applications/MAMP/htdocs/app/application/libraries/');
require_once("Zend/Amf/Server.php");
// Start Server
$server = new Zend_Amf_Server();
// Zend_Amf_Server require.
// Require the ZendAmfServiceBrowser class
require_once("Zend/browser/ZendAmfServiceBrowser.php");
// Class requires.
require_once("services/Testservice.php");
//require_once( "services/ReturnTests.php" );
// Register Demo Classes
$server->setClass("Testservice");
//$server->setClass( "ReturnTests" );
//$server->setResponse('test');
// Add the ZamfBrowser service class so ZamfBrowser can retrieve method information.
$server->setClass("ZendAmfServiceBrowser");
// Set a reference to the Zend_Amf_Server object so ZendAmfServiceBrowser class can retrieve method information.
ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server;
$server->setProduction(false);
// Handle ZendAMF request
echo ($server->handle());
redirect(base_url().'Gateway');
}
}
and this is my testservice
<?php
class Testservice extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function UserDetails()
{
$this->load->model('users_model');
// Grab user info
$user_id = 3;//$this->session->userdata('user_id');
$this->user = $this->users_model->get_user_by_id($user_id);
$this->data['user'] = $this->user;
return $this->data;
}
}
when I implement all of this I get the following response:
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined property: Testservice::$users_model</p>
<p>Filename: services/Testservice.php</p>
<p>Line Number: 90</p>
If I am extending CI_Controller I would have though that it should allow me to access all my models.
Any ideas I am really stumped on this now.
Thanks In Advance