1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8class Tiki_Render_Lazy 9{ 10 private $callback; 11 private $data; 12 13 function __construct($callback) 14 { 15 $this->callback = $callback; 16 } 17 18 function __toString() 19 { 20 if ($this->callback) { 21 try { 22 $this->data = call_user_func($this->callback); 23 } catch (Exception $e) { 24 $this->data = $e->getMessage(); 25 } catch (Error $e) { 26 $this->data = $e->getMessage(); 27 } catch (Throwable $e) { 28 $this->data = $e->getMessage(); 29 } 30 $this->callback = null; 31 } 32 33 return (string) $this->data; 34 } 35} 36