This snippet can do the work.
File: test.php (put in your webroot)
Call with http://yourwebroot/test.php?id=x were x is a valid id for
your table
constructClasses();
}
function hello( $id ) {
$this->User->id = $id;
die( pr( $this->User->read() ) );
}
}
$myTest = new TestController;
$myTest->hello( $_GET['id'] );
?>
As a real example this is a method that I have used to do soap webservices
in cake (using nusoap).
It is only an example but the code is not so hard to listen.
I am very busy at this time but i would to write a bakery article on this.
I put all my files in a subfolder (ws) of webroot for this reason you read
(require "../index.php";)
HTH Marco AKA LazyCoder.
http://tempuri.org/";>
Hello @[name]
@[error]
EOF_BODY;
// ALL the magic is here
//
$_GET['url'] = 'favicon.ico';
require "../index.php";
Configure::write('debug', 0);
class SoapController extends Controller {
var $autoRender = false;
var $name = 'Soap';
var $uses = array('User');
/*
* Class init
*/
function __construct() {
parent::__construct();
$this->constructClasses();
}
/*
* Execute WebService
*/
function myService( $data=null ) {
global $messageReturn;
$errorMessage = "";
if(!is_array($data)) {
str_replace('@[error]', 'Error: Data is not an array.',
$messageReturn);
return $messageReturn;
}
$this->User->id = $data['user_id'];
$userData = $this->User->read();
str_replace('@[name]', $userData['User']['name'], $messageReturn);
str_replace('@[error]', '', $messageReturn);
return $messageReturn;
}
/*
* Init WebService
*/
function service() {
require_once('nusoap.php');
$server = new soap_server;
$server->register('SoapController.myService', array(), array(), false,
false, "document", "literal");
global $HTTP_RAW_POST_DATA;
$data = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($data);
}
}
$wsSoap = new SoapController;
$wsSoap->service();
?>
> -Messaggio originale-
> Da: cake-php@googlegroups.com
> [mailto:[EMAIL PROTECTED] Per conto di Geoff Ford
> Inviato: lunedì 24 settembre 2007 6.45
> A: Cake PHP
> Oggetto: Re: How to access a controller action from an
> application not in cakephp structure
>
>
> This all depends on the other application. The basic premise
> is the same - just include the file you need and if the other
> app has a whole hierachy of includes etc you need to include
> those as well. THen instantiate your foreign app class and
> start using it as a normal
> class (not cake style), Vendors was built for this sort of
> situation.
>
> Geoff
> --
> http://lemoncake.wordpress.com
>
> On Sep 24, 4:46 am, zonium <[EMAIL PROTECTED]> wrote:
> > I have 2 applications:
> > - appA is built with cakephp 1.2 and
> > - appB is an old good application.
> >
> > I want to make use of some business logic code in appA for appB.
> > That business logic code is in controller actions (e.g methods) of
> > appA.
> >
> > Previously when appA was not in cake, I just used a normal
> include to
> > have functions declared in appA available in appB. But now I don't
> > think I can do such an include because appA is in cake structure.
> >
> > I know requestAction() allows for accessing an action from an
> > arbitrary controller but it's required that all
> applications have to
> > be in cake platform.
> >
> > Any suggestion how I can get through this? (restriction: converting
> > appB to use cake is not an available option)
> >
> > Thanks a lot,
> > Zonium
>
>
> >
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---