* @author Lorenzo Alberton * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * @version CVS: $Id: Wrapper.php 300729 2010-06-24 12:05:53Z quipo $ * @link http://pear.php.net/package/Calendar */ /** * Allows Calendar include path to be redefined * @ignore */ if (!defined('CALENDAR_ROOT')) { define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); } /** * Load Calendar decorator base class */ require_once CALENDAR_ROOT.'Decorator.php'; /** * Decorator to help with wrapping built children in another decorator * * @category Date and Time * @package Calendar * @author Harry Fuecks * @author Lorenzo Alberton * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * @link http://pear.php.net/package/Calendar * @access public */ class Calendar_Decorator_Wrapper extends Calendar_Decorator { /** * Constructs Calendar_Decorator_Wrapper * * @param object &$Calendar subclass of Calendar * * @access public */ function Calendar_Decorator_Wrapper(&$Calendar) { parent::Calendar_Decorator($Calendar); } /** * Wraps objects returned from fetch in the named Decorator class * * @param string $decorator name of Decorator class to wrap with * * @return object instance of named decorator * @access public */ function & fetch($decorator) { $Calendar = parent::fetch(); if ($Calendar) { $ret = new $decorator($Calendar); } else { $ret = false; } return $ret; } /** * Wraps the returned calendar objects from fetchAll in the named decorator * * @param string $decorator name of Decorator class to wrap with * * @return array * @access public */ function fetchAll($decorator) { $children = parent::fetchAll(); foreach ($children as $key => $Calendar) { $children[$key] = new $decorator($Calendar); } return $children; } } ?>