ForwardFW
[ class tree: ForwardFW ] [ index: ForwardFW ] [ all elements ]

Source for file Callback.php

Documentation is available at Callback.php

  1. <?php
  2. declare(encoding "utf-8");
  3. /**
  4.  * This file is part of ForwardFW a web application framework.
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2.1 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public
  17.  * License along with this library; if not, write to the Free Software
  18.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  *
  20.  * PHP version 5
  21.  *
  22.  * @category   Cache
  23.  * @package    ForwardFW
  24.  * @subpackage Main
  25.  * @author     Alexander Opitz <opitz.alexander@primacom.net>
  26.  * @copyright  2009,2010 The Authors
  27.  * @license    http://www.gnu.org/copyleft/gpl.html GNU General Public License
  28.  * @version    SVN: $Id: $
  29.  * @link       http://forwardfw.sourceforge.net
  30.  * @since      File available since Release 0.0.8
  31.  */
  32.  
  33. require_once 'ForwardFW/Exception/Callback.php';
  34.  
  35. /**
  36.  * Config for a Cache.
  37.  *
  38.  * @category   Config
  39.  * @package    ForwardFW
  40.  * @subpackage Main
  41.  * @author     Alexander Opitz <opitz.alexander@primacom.net>
  42.  * @license    http://www.gnu.org/copyleft/gpl.html GNU General Public License
  43.  * @link       http://forwardfw.sourceforge.net
  44.  */
  45. {
  46.     /**
  47.      * @var Callback The callback function configuration
  48.      */
  49.     public $callback = null;
  50.  
  51.     /**
  52.      * @var array Array with the parameters for function call.
  53.      */
  54.     public $arParameters = null;
  55.  
  56.     /**
  57.      * Constructor with validation of $callback
  58.      *
  59.      * @param Callback $callback     The callback function.
  60.      * @param array    $arParameters Parameters for function call.
  61.      *
  62.      * @return void 
  63.      * @throws ForwardFW_Exception_Callback
  64.      */
  65.     public function __construct($callbackarray $arParameters null)
  66.     {
  67.         if (is_callable($callbacktrue)) {
  68.             $this->callback = $callback;
  69.             $this->setParameters($arParameters);
  70.         else {
  71.             throw new ForwardFW_Exception_Callback('This is no callback function');
  72.         }
  73.     }
  74.  
  75.     /**
  76.      * Sets the parameters array for callback.
  77.      *
  78.      * @param array $arParameters Parameters for function call.
  79.      *
  80.      * @return ForwrdFW_Callback 
  81.      */
  82.     public function setParameters(array $arParameters null)
  83.     {
  84.         $this->arParameters $arParameters;
  85.  
  86.         return $this;
  87.     }
  88.  
  89.  
  90.     /**
  91. /**
  92.      * Gets the parameters array for callback.
  93.      *
  94.      * @return array|nullThe parameters.
  95.      */
  96.     public function getParameters()
  97.     {
  98.         return $this->arParameters;
  99.     }
  100.  
  101.     /**
  102.      * Do the callback
  103.      *
  104.      * @return mixed Depends on function call.
  105.      */
  106.     public function doCallback()
  107.     {
  108.         if (is_null($this->arParameters)) {
  109.             return call_user_func($this->callback);
  110.         else {
  111.             return call_user_func_array($this->callback$this->arParameters);
  112.         }
  113.     }
  114. }
  115. ?>

Documentation generated on Sun, 30 Jan 2011 20:46:38 +0100 by phpDocumentor 1.4.3