org-puremvc-php-multicore
[ class tree: org-puremvc-php-multicore ] [ index: org-puremvc-php-multicore ] [ all elements ]

Source for file Proxy.php

Documentation is available at Proxy.php

  1. <?php
  2. /**
  3.  * PureMVC Multicore Port to PHP
  4.  *
  5.  * Partly based on PureMVC Port to PHP by:
  6.  * - Omar Gonzalez <omar@almerblank.com>
  7.  * - and Hasan Otuome <hasan@almerblank.com>
  8.  *
  9.  * Created on Jully 24, 2009
  10.  *
  11.  * @version 1.0
  12.  * @author Michel Chouinard <michel.chouinard@gmail.com>
  13.  * @copyright PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
  14.  * @license http://creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0 Unported License
  15.  * @package org.puremvc.php.multicore
  16.  *
  17.  */
  18. /**
  19.  *
  20.  */
  21.  
  22. require_once 'org/puremvc/php/multicore/interfaces/IProxy.php';
  23. require_once 'org/puremvc/php/multicore/interfaces/INotifier.php';
  24. require_once 'org/puremvc/php/multicore/patterns/observer/Notifier.php';
  25. require_once 'org/puremvc/php/multicore/patterns/facade/Facade.php';
  26.  
  27. /**
  28.  * A base <b>IProxy</b> implementation.
  29.  *
  30.  * In PureMVC, Proxy classes are used to manage parts of the
  31.  * application's data model.
  32.  *
  33.  * A <b>Proxy</b> might simply manage a reference to a local data object,
  34.  * in which case interacting with it might involve setting and
  35.  * getting of its data in synchronous fashion.
  36.  *
  37.  * <b>Proxy</b> classes are also used to encapsulate the application's
  38.  * interaction with remote services to save or retrieve data, in which case,
  39.  * we adopt an asyncronous idiom; setting data (or calling a method) on the
  40.  * <b>Proxy</b> and listening for a <b>Notification</b> to be sent
  41.  * when the <b>Proxy</b> has retrieved the data from the service.
  42.  *
  43.  * @see Notifier
  44.         org\puremvc\php\multicore\patterns\observer\Notifier.php
  45.  * @see Model
  46.         org\puremvc\php\multicore\core\Model.php
  47.  * @package org.puremvc.php.multicore
  48.  */
  49. class Proxy extends Notifier implements IProxyINotifier
  50. {
  51.  
  52.     /**
  53.      * Define the default name of the proxy
  54.      * @var string 
  55.      */
  56.     const NAME = 'Proxy';
  57.  
  58.     /**
  59.      * The name of the proxy
  60.      * @var string 
  61.      */
  62.     protected $proxyName;
  63.  
  64.     /**
  65.      * The data object managed by the proxy
  66.      * @var mixed 
  67.      */
  68.     protected $data;
  69.  
  70.     /**
  71.      * Constructor
  72.      *
  73.      * @param string $proxyName [OPTIONAL] Name for the proxy instance will default to <samp>Proxy::NAME</samp> if not set.
  74.      * @param mixed $data [OPTIONAL] Data object to be managed by the proxy may be set later with <samp>setData()</samp>.
  75.      */
  76.     public function __construct$proxyName=null$data=null )
  77.     {
  78.         $this->proxyName = !empty$proxyName $proxyName Proxy::NAME;
  79.         $this->setData($data);
  80.     }
  81.  
  82.     /**
  83.      * Get the Proxy name
  84.      *
  85.      * @return string The Proxy instance name
  86.      */
  87.     public function getProxyName()
  88.     {
  89.         return $this->proxyName;
  90.     }
  91.  
  92.     /**
  93.      * Data setter
  94.      *
  95.      * Set the data object
  96.      *
  97.      * @param mixed $data the data object
  98.      * @return void 
  99.      */
  100.     public function setData$data )
  101.     {
  102.         if !is_null$data ) )
  103.         {
  104.             $this->data = $data;
  105.         }
  106.     }
  107.  
  108.     /**
  109.      * Data getter
  110.      *
  111.      * Get the data object
  112.      *
  113.      * @return mixed The data Object. null if not set.
  114.      */
  115.     public function getData()
  116.     {
  117.         return isset($this->data$this->data : null );
  118.     }
  119.  
  120.     /**
  121.      * onRegister event
  122.      *
  123.      * Called by the Model when the Proxy is registered
  124.      *
  125.      * @return void 
  126.      */
  127.     public function onRegister)
  128.     {
  129.     }
  130.  
  131.     /**
  132.      * onRemove event
  133.      * Called by the Model when the Proxy is removed
  134.      *
  135.      * @return void 
  136.      */
  137.     public function onRemove)
  138.     {
  139.     }
  140.  
  141. }

Documentation generated on Mon, 03 Aug 2009 04:58:02 +0000 by phpDocumentor 1.4.2