/**
  * Called when a client connects, sends a message, or disconnects.  Creates
  * a new Front Controller and dispatches to the controller.
  *
  * @param string $event
  * @param A_Socket_Message $data
  */
 public function onEvent($event, $message)
 {
     $Request = new A_Socket_Request($message);
     $Locator = $this->locator;
     $Config = $Locator->get('Config');
     $Locator->set('Request', $Request);
     $front = new A_Controller_Front($Config->get('APP'), $Config->get('DEFAULT_ACTION'), $Config->get('ERROR_ACTION'));
     $front->run($Locator);
 }
Beispiel #2
0
<?php

/**
 * This is the simplest bootstrap and controller. 
 * No Response object is used and controllers echo their output. 
 * URLs are in the form index.php?module=&controller=home&action=index (but params are defaults so not necessary)
 */
$ConfigArray['PATH'] = dirname(__FILE__) . '/';
include $ConfigArray['PATH'] . '../../A/Locator.php';
$Locator = new A_Locator();
$Locator->autoload();
$Request = new A_Http_Request();
$Locator->set('Request', $Request);
$Front = new A_Controller_Front($ConfigArray['PATH'], array('', 'home', ''), array('', 'home', ''));
$Front->run($Locator);
Beispiel #3
0
<?php

error_reporting(E_ALL);
require 'config.php';
require dirname(__FILE__) . '/../../A/Locator.php';
#require_once('A/Http/Request.php');
#require_once('A/Http/Response.php');
#require_once('A/Controller/Front.php');
#require_once('A/Controller/Mapper.php');
// create Registry/Loader and initialize autoloading
$Locator = new A_Locator();
$Locator->autoload();
$Response = new A_Http_Response();
$Locator->set('Request', new A_Http_Request());
$Locator->set('Response', $Response);
$DefaultAction = array('', 'home', 'index');
$ErrorAction = 'error';
$Mapper = new A_Controller_Mapper('', $DefaultAction);
#$Mapper->setParams('action', '');		// add this line to run 0.3.x code
#$Mapper->setDefaultMethod('execute');	// add this line to run 0.4.x and 0.3.x code
#$Mapper->setDefaultMethod('run');		// add this line to run 0.7.x code
#$Mapper->setDefaultDir('default');		// add this for a default module directory
$Controller = new A_Controller_Front($Mapper, $ErrorAction);
#$Controller = new A_Controller_Front('', $ErrorAction, $DefaultAction);	// have FC create Mapper
$Controller->run($Locator);
$Response->out();
if ($Controller->isError()) {
    echo '<br/><br/>Front Controller errors: ' . $Controller->getErrorMsg();
}