public function render($action = null, $layout = null, $file = null)
 {
     if (!$this->testView) {
         $this->renderedAction = $action;
     } else {
         return parent::render($action, $layout, $file);
     }
 }
Esempio n. 2
0
<?php

// Fixing Comments
require_once 'controller/ContactsController.php';
$controller = new ContactsController();
$controller->handleRequest();
Esempio n. 3
0
 /**
  * @param Server $app
  *
  * @return ControllerCollection
  */
 public function connect(Server $app)
 {
     $_controllers = new ControllerCollection();
     //*************************************************************************
     //* GET
     //*************************************************************************
     $_controllers->get('/{id}', function (Application $app, $id) {
         if (!isset($id)) {
             throw new \InvalidArgumentException('You must specify an "id".');
         }
         //	Have to base64 encode id cuz it's funky
         $_id = base64_decode(urldecode($id));
         \Kisma\Utility\Log::trace('get /contact/' . $_id);
         $_controller = new ContactsController();
         if (null !== ($_result = $_controller->findById($_id))) {
             return $_controller->createResponse($_id, $_result);
         }
         return new Response('you suck Not found');
     });
     //*************************************************************************
     //* POST
     //*************************************************************************
     $_controllers->post('/', function (Application $app) {
         $_returnUrl = $app['request']->get('return_url');
         $_id = $app['request']->get('id');
         if (!isset($_id)) {
             throw new \InvalidArgumentException('You must specify an "id".');
         }
         $_id = base64_decode(urldecode($_id));
         \Kisma\Utility\Log::trace('post /contact/' . ($_id ?: '[NEW]') . print_r($_POST, true));
         $_controller = new ContactsController();
         if (null === ($_result = $_controller->findById($_id))) {
             //	Ajax request? Return a JSON response
             if ('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH']) {
                 return $_controller->createResponse($_id, 'Contact not found!', 404);
             }
             return 'Contact not found!';
         }
         //	Copy to id as well
         $_POST['id'] = $_id;
         try {
             $_result = $_controller->updateContact(new \Teledini\Components\Contacts\GenericContact($_POST));
             \Kisma\Utility\Log::trace('post result: ' . print_r($_result, true));
             $_SESSION['contact_post_result'] = $_result;
         } catch (\Exception $_ex) {
             //	Error
             \Kisma\Utility\Log::error('Exception saving contact: ' . $_ex->getMessage());
         }
         //	Ajax request? Return a JSON response
         if ('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH']) {
             return $_controller->createResponse($_id, 'Contact updated.');
         }
         if ($_returnUrl) {
             //	Redirect
             header('Location: ' . $_returnUrl);
             die;
         }
     });
     //*************************************************************************
     //* DELETE
     //*************************************************************************
     $_controllers->delete('/{id}', function (Application $app, $id) {
         $_returnUrl = $app['request']->get('return_url');
         $_id = $app['request']->get('id');
         if (!isset($_id)) {
             throw new \InvalidArgumentException('You must specify an "id".');
         }
         $_id = base64_decode(urldecode($_id));
         \Kisma\Utility\Log::trace('post /contact/' . ($_id ?: '[NEW]') . print_r($_POST, true));
         $_controller = new ContactsController();
         if (null === ($_result = $_controller->findById($_id))) {
             //	Ajax request? Return a JSON response
             if ('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH']) {
                 return $_controller->createResponse($_id, 'Contact not found!', 404);
             }
             return 'Contact not found!';
         }
         //	Copy to id as well
         $_POST['id'] = $_id;
         try {
             $_result = $_controller->updateContact(new \Teledini\Components\Contacts\GenericContact($_POST));
             \Kisma\Utility\Log::trace('post result: ' . print_r($_result, true));
             $_SESSION['contact_post_result'] = $_result;
         } catch (\Exception $_ex) {
             //	Error
             \Kisma\Utility\Log::error('Exception saving contact: ' . $_ex->getMessage());
         }
         //	Ajax request? Return a JSON response
         if ('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH']) {
             return $_controller->createResponse($_id, 'Contact updated.');
         }
         if ($_returnUrl) {
             //	Redirect
             header('Location: ' . $_returnUrl);
             die;
         }
     });
     return $_controllers;
 }
Esempio n. 4
0
File: index.php Progetto: jahur/CRUD
<?php

require_once 'controller/ContactsController.php';
$controller = new ContactsController();
$controller->handleRequest();
$controller->urltrack();