sfWebResponse::addMeta PHP Method

addMeta() public method

Adds a meta header.
public addMeta ( string $key, string $value, boolean $replace = true, boolean $escape = true )
$key string Name of the header
$value string Meta header value (if null, remove the meta)
$replace boolean true if it's replaceable
$escape boolean true for escaping the header
    public function addMeta($key, $value, $replace = true, $escape = true)
    {
        $key = strtolower($key);
        if (null === $value) {
            unset($this->metas[$key]);
            return;
        }
        // FIXME: If you use the i18n layer and escape the data here, it won't work
        // see include_metas() in AssetHelper
        if ($escape) {
            $value = htmlspecialchars($value, ENT_QUOTES, $this->options['charset']);
        }
        $current = isset($this->metas[$key]) ? $this->metas[$key] : null;
        if ($replace || !$current) {
            $this->metas[$key] = $value;
        }
    }

Usage Example

コード例 #1
0
 /**
  * Update the response meta values with the data contained within an array.
  *
  * @param array $data
  * @param sfWebResponse $sf_response
  * @return void
  */
 public static function setCommonMetas(array $data, sfWebResponse $sf_response)
 {
     foreach ($data as $key => $value) {
         $sf_response->addMeta($key, $value);
     }
 }