prefix = $prefix; $this->name = $name; } /** * Use this inside your custom tags to add Symfony's helpers to your compiled template */ public function use_helper() { $args = func_get_args(); self::$helpers = array_unique(array_merge(self::$helpers, $args)); } public static function get_used_helpers() { $r = array(); foreach (self::$helpers as $h) { $r[] = "'$h'"; } return ""; } /** * require_attributes * * @return exception * */ public function require_attributes() { foreach(func_get_args() as $attrib) { if (!array_key_exists($attrib, $this->attributes)) { throw new Exception("El atributo [".$attrib."] es requerido por la funcion [".$this->name."]"); } } } /** * require_one * * @return mixed * */ public function require_one() { $ret = FALSE; $attribs = func_get_args(); foreach($attribs as $attrib) { if (array_key_exists($attrib, $this->attributes)) { $ret = $attrib; break; } } if ($ret === FALSE) { throw new Exception("Al menos falta uno de los siguientes atributos [".implode(',', $attribs)."] requeridos por la funcion [".$this->name."]"); } return $ret; } /** * buffer * * @param mixed $buffer * @return mixed * */ public function buffer($buffer = FALSE) { if ($buffer !== FALSE) { $this->buffer .= $buffer; } else { return $this->buffer; } } /** * add_attributes * * @param array $array * @return void * */ public function add_attributes(array $array = array()) { $this->attributes = array_merge($this->attributes, $array); } /** * get_name * * @return string * */ public function get_name() { return $this->name; } /** * offsetGet * * @param int $key * @return mixed * */ public function offsetGet($key) { return $this->offsetExists($key) ? $this->attributes[$key] : NULL; } /** * offsetSet * * @param int $key * @param mixed $val * @return void * */ public function offsetSet($key, $val) { $this->attributes[$key] = $val; } /** * offsetExists * * @param int $key * @return bool * */ public function offsetExists($key) { return isset($this->attributes[$key]); } /** * offsetUnset * * @param int $key * @return void * */ public function offsetUnset($key) { unset($this->attributes[$key]); } /** * parse_buffer * */ abstract public function parse_buffer(); } //End Temper Tag Library