/**
  * Headers Management Class Constructor
  */
 public function __construct()
 {
     parent::__construct();
     // Setting Up Headers Lists
     $this->headers = new Lists();
     // Extend Object Headers' List
     $this->extend(new Invoker($this, $this->headers));
 }
Exemple #2
0
 /**
  * Datatype Constructor
  *
  * @param mixed|optional $value
  *   Value to set
  *
  * @throws InvalidArgumentException
  *   Given argument ois not acceptable by concrete datatype class
  */
 public function __construct($value = NULL)
 {
     parent::__construct();
     // If a value was defined...
     if (!is_null($value)) {
         // ... let's cCheck its acceptance before set
         if ($this->accept($value) === FALSE) {
             throw new \InvalidArgumentException('Argument is not a ' . $this);
         }
     }
     // Prototyping (even without value)...
     $this->prototype($value);
     $this->value =& $value;
 }
 /**
  * Controller Constructor
  *
  * <p>
  *     If an Application Object is provided, the Controller will
  *     be configured.
  * </p>
  *
  * <p>
  *     An Application is NOT passed only in concrete classes extending
  *     Next\Application\AbstractApplication, when building
  *     Application Chain
  * </p>
  *
  * @param Next\Application\Application|optional $application
  *
  *   <p>Application Object</p>
  *
  *   <p>
  *       With Standard Router, used only when
  *       <em>DEVELOPMENT_MODE<em> is not <strong>2</strong>
  *   </p>
  */
 public final function __construct(Application $application = NULL)
 {
     parent::__construct();
     // If we an Application (dispatching process), let's handle it
     if (!is_null($application)) {
         // Request Object
         $this->_application =& $application;
         // Application's View Engine
         $this->view = $application->getView();
         // HTTP GET Params (a.k.a. Dynamic Params) as Template Variables
         $this->view->assign($application->getRequest()->getQuery());
         // Executing Extra Initialization Routines
         $this->init();
     }
 }
Exemple #4
0
 /**
  * Table Manager Constructor
  *
  * @param Next\DB\Driver\Driver $driver
  *   Connection Driver
  *
  * @param Next\DB\Table\Table $table
  *   Table Object
  */
 public function __construct(Driver $driver, Table $table)
 {
     parent::__construct();
     // Setting Up resources
     $this->driver =& $driver;
     $this->table =& $table;
     /**
      * @internal Data Source
      *
      * By default Table Manager will work with original Table Fields.
      *
      * When a UPDATE Statement is executed, however, the Manager will
      * work with Row/RowSet Fields computed from the difference between
      * original fields and modified fields
      */
     $this->source = $table->getFields();
     // Extend Object Context to QueryBuilder Class
     $this->extend(new Invoker($this, new Builder($driver->getRenderer())));
 }
Exemple #5
0
 /**
  * Request Constructor
  *
  * If only one argument is provided, it'll be checked against
  * Next\HTTP\Stream\Adapter\Adapter.
  *
  * If it passes, it will be used and Request URI will be retrieved
  * from it
  *
  * Otherwise, this argument will be THE Request URI
  *
  * The second argument is the Request Method, also optional.
  *
  * If no arguments are entered (case of Routed Requests), default
  * values will take place: REQUEST_URI from $_SERVER and GET as
  * Request Method
  */
 public function __construct()
 {
     parent::__construct();
     // Cookies Management Object
     $this->cookies = new Cookies();
     // Request Headers Management Object
     $this->headers = new Headers\RequestHeaders();
     // Extend Object Context to Headers', Cookies and Browser Classes
     $this->extend(new Invoker($this, $this->headers))->extend(new Invoker($this, $this->cookies))->extend(new Invoker($this, new Request\Browser()));
     // Initializing Data Properties with superglobals
     $this->queryData = $_GET;
     $this->postData = $_POST;
     //---------------------------
     list($mixed, $method) = func_get_args() + array($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
     // Setting Up Basic Informations
     // Do we have an HTTP Stream Adapter?
     if ($mixed instanceof Adapter) {
         $this->adapter =& $mixed;
         // If so, let's use its file/url as URI
         $this->uri = $mixed->getFilename();
     } else {
         // No? So let's use first argument as URI
         $this->uri =& $mixed;
     }
     // Request Method
     $this->method = strtoupper($method);
     //---------------------------
     // Server Protocol
     $this->protocol = new \stdClass();
     $data = parse_url($this->uri);
     if (array_key_exists('scheme', $data)) {
         // Protocol... "name"
         $this->protocol->name = $data['scheme'];
         // URI Basepath
         /**
          * @internal
          * This implementation can be reliable because
          * an external request without HTTP Scheme (e.g. http://)
          * will not be opened successfully anyway
          */
         if (array_key_exists('path', $data)) {
             $this->basepath = ltrim($data['path'], '/');
         }
     } else {
         // Protocol... "name"
         preg_match(self::PROTOCOL_REGEXP, $_SERVER['SERVER_PROTOCOL'], $match);
         if (array_key_exists('protocol', $match)) {
             $this->protocol->name = strtolower($match['protocol']);
         }
         if (array_key_exists('version', $match)) {
             $this->protocol->version = $match['version'];
         }
         // URI Basepath
         /**
          * @internal
          * By default, the basepath is the basename of directory name
          * index.php is located
          */
         $this->basepath = basename(dirname($_SERVER['SCRIPT_FILENAME']));
         // Default Request Headers. Internal Requests only.
         if (defined('TURBO_MODE') && TURBO_MODE === FALSE) {
             $this->addDefaultHeaders();
         }
     }
 }
Exemple #6
0
 /**
  * Response Constructor
  *
  * @param string|optional $data
  *   Response Data
  *
  * @param array|optional $metaData
  *   Response Meta Data
  */
 public function __construct($data = NULL, array $metaData = array())
 {
     parent::__construct();
     // Headers Management Object
     $this->headers = new Headers\ResponseHeaders();
     // Extend Object Context to Headers', Cookies and Browser Classes
     $this->extend(new Invoker($this, $this->headers));
     /**
      * @internal
      * When dealing with Routed (internal) Requests, no data will
      * be available because the Front Controller did not send the
      * Response yet.
      *
      * In External Requests, the Response is not sent anyways,
      * so we condition the buffer length to not hide any output
      * manually added, like a debugging purposes var_dump()
      */
     if (empty($data) || ob_get_length()) {
         if (defined('TURBO_MODE') && TURBO_MODE === FALSE) {
             if (function_exists('apache_response_headers')) {
                 try {
                     $this->headers->addHeader(apache_response_headers());
                 } catch (FieldsException $e) {
                     /**
                      * @internal
                      * We're silencing the FieldsException in order to not
                      * break the Response Flow
                      *
                      * However, if this Exception is caught, no Response
                      * Headers will be available
                      */
                 }
             } else {
                 $headers = headers_list();
                 foreach ($headers as $data) {
                     list($header, $value) = explode(':', $data, 2);
                     try {
                         $this->headers->addHeader($header, $value);
                     } catch (FieldsException $e) {
                         // Same explanation as above
                     }
                 }
             }
         }
     } else {
         $this->appendBody($data);
         if (count($metaData) != 0 && (defined('TURBO_MODE') && TURBO_MODE === FALSE)) {
             $this->addResponseData($metaData);
         }
     }
 }
 /**
  * Decorator Constructor
  *
  *  @param string $message
  *    Resource to decorate
  */
 public function __construct($resource)
 {
     parent::__construct();
     $this->resource =& $resource;
 }