PHP Classes
elePHPant
Icontem

File: src/Factory/Request.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu  >  Jaxon Sentry  >  src/Factory/Request.php  >  Download  
File: src/Factory/Request.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon Sentry
Common classes for Jaxon based Ajax applications
Author: By
Last change: Moved the Armada class from Jaxon\Sentry\Classes\ to Jaxon\Sentry\.
Replaced Jaxon\Sentry\Classes\Base with Jaxon\Sentry\Classes\Armada.
Date: 2 years ago
Size: 1,746 bytes
 

 

Contents

Class file image Download
<?php

/**
 * Factory.php - Jaxon Request Factory
 *
 * Create Jaxon client side requests to a given class.
 *
 * @package jaxon-core
 * @author Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @copyright 2016 Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
 * @link https://github.com/jaxon-php/jaxon-sentry
 */

namespace Jaxon\Sentry\Factory;

use
Jaxon\Sentry\Armada;

class
Request
{
   
/**
     * The class instance this request factory is attached to
     *
     * @var Jaxon\Sentry\Armada
     */
   
private $instance = null;

   
/**
     * The reflection class
     *
     * @var ReflectionClass
     */
    // private $reflectionClass;

    /**
     * Create a new Factory instance.
     *
     * @return void
     */
   
public function __construct(Armada $instance)
    {
       
$this->instance = $instance;
       
// $this->reflectionClass = new \ReflectionClass(get_class($instance));
   
}

   
/**
     * Generate the corresponding javascript code for a call to any method
     *
     * @return string
     */
   
public function __call($sMethod, $aArguments)
    {
       
// Check if the method exists in the class, and is public
        /*if(!$this->reflectionClass->hasMethod($sMethod))
        {
            // Todo: throw an exception
        }
        if(!$this->reflectionClass->getMethod($sMethod)->isPublic())
        {
            // Todo: throw an exception
        }*/
        // Prepend the class name to the method name
       
$sMethod = $this->instance->getJaxonClassName() . '.' . $sMethod;
       
// Make the request
       
return call_user_func_array('\Jaxon\Request\Factory::call', array_merge(array($sMethod), $aArguments));
    }
}