Assing a template variable

@param string $key name of the variable within the template
@param string $value replacement value
@param bool $encode if true, special XML characters are encoded
@throws OdfException
@return odf
517135
public function setVars($key, $value, $encode = true, $charset = 'ISO-8859')
    {
        $tag= $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT'];
        if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml, $tag) === false) {
                throw new OdfException("var $key not found in the document");
        }
        $value = $encode ? $this->recursiveHtmlspecialchars($value) : $value;
        $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value;
        $this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
        return $this;
    }
317605
private function encodeValue(XMLWriter $xml, $value) {

        if ( $value === null ) $xml->writeRaw($this->use_ex_nil === true ? '<ex:nil />' : '<nil />');

        else if ( is_array($value) ) {

            if ( !self::catchStruct($value) ) $this->encodeArray($xml, $value);

            else $this->encodeStruct($xml, $value);

        } else if ( @array_key_exists($value, $this->special_types) ) {

            switch ( $this->special_types[$value] ) {

                case 'base64':
                    
                    $xml->writeElement("base64", $value);

                    break;
                
                case 'datetime':
                    
                    $xml->writeElement("dateTime.iso8601", self::timestampToIso8601Time($value));

                    break;
                
                case 'cdata':
                    
                    $xml->writeCData($value);

                    break;
                
            }

        } else if ( is_bool($value) ) {

            $xml->writeElement("boolean", $value ? 1 : 0);

        } else if ( is_double($value) ) {

            $xml->writeElement("double", $value);

        } else if ( is_integer($value) ) {
            
            $xml->writeElement("int", $value);

        } else if ( is_object($value) ) {

            $this->encodeObject($xml, $value);

        } else if ( is_string($value) ) {

            $value = htmlentities($value, ENT_QUOTES, $this->encoding, false);

            $string = preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/S', 'self::numericEntities', $value);

            $xml->writeRaw("<string>".$string."</string>");

        } else throw new XmlrpcException("Unknown type for encoding");

    }
409086
public function set($key, $value = null, $override = false)
    {
        // if key is array,
        // loop the set, while expecting value parameter to be override
        if(is_array($key))
        {
            $override = $value;

            foreach($key as $k => $val)
            {
                if($override === true)
                    $this->setOverride($k, $val);
                else
                    $this->data[$k] = $val;
            }

            return $this;
        }
        else
        {
            if($override === true)
                $this->setOverride($key, $value);
            else
                $this->data[$key] = $value;

            return $this;
        }
    }
8369
protected function encode($value)
    {
        try {
            return $this->encoders->getEncoderForValue($value)
                ->encode($value, new EncodingContext());
        } catch (EncodingException | InvalidArgumentException | OutOfBoundsException $ex) {
            throw new SerializationException('Failed to serialize value', 0, $ex);
        }
    }
740681
public function setValueByKey($key, $value)
    {
        $model = Configuration::whereConfigurationKey($key)->first();

        if (null === $model) {
            return null;
        }
        $model->update(['configuration_value' => $value]);

        return $model;
    }
894648
protected function attributeElement($key, $value)
    {
        $html = self::getInstance()->html;
        $args = func_get_args();
        return call_user_func_array(array($html, __FUNCTION__), $args);
    }
326107
public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
    {
        $value = $data['value'];

        if ($encode === true) {
            $value = General::sanitize($value);
        } else {
            if (!General::validateXML($data['value'], $errors, false, new XsltProcess)) {
                $value = html_entity_decode($data['value'], ENT_QUOTES, 'UTF-8');
                $value = $this->__replaceAmpersands($value);

                if (!General::validateXML($value, $errors, false, new XsltProcess)) {
                    $value = General::sanitize($data['value']);
                }
            }
        }

        $wrapper->appendChild(
            new XMLElement($this->get('element_name'), $value, array('handle' => $data['handle']))
        );
    }
1354148
protected function mutateMetableAttribute(string $key, $value): ?string
    {
        if (\is_null($value)) {
            return $value;
        }

        if ($value instanceof Arrayable) {
            $value = $value->toArray();
        } elseif (! \is_array($value)) {
            $value = (array) $value;
        }

        return $this->castAttributeAsJson($key, $value);
    }
523454
protected static function build_attribute_element( $key, $value ) {
		// For numeric keys we will assume that the value is a boolean attribute
		// where the presence of the attribute represents a true value and the
		// absence represents a false value.
		if ( is_numeric( $key ) ) {
			return $value;
		}

		// Treat boolean attributes as HTML properties.
		if ( is_bool( $value ) && 'value' !== $key ) {
			return $value ? $key : '';
		}

		if ( is_array( $value ) && 'class' === $key ) {
			return 'class="' . static::esc_html_class( $value ) . '"';
		}

		if ( ! is_null( $value ) ) {
			return $key . '="' . esc_attr( $value ) . '"';
		}

		return null;
	}
50895
protected function encode($value)
    {
        $key = (string) $value;
        if (!isset(static::$cacheEncode[$key])) {
            $isAngularVar = false;
            if (\mb_substr($value, 0, 2) == '{{' && \mb_substr($value, -2) == '}}') {
                $isAngularVar = true;
                $value = \trim(\mb_substr($value, 2, -2));
            }
            static::$cacheEncode[$key] = \rawurlencode($value);
            static::$cacheEncode[$key] = \strtr(static::$cacheEncode[$key], static::$urlencodeCorrectionMap);
            if ($isAngularVar === true) {
                static::$cacheEncode[$key] = '{{ ' . static::$cacheEncode[$key] . ' }}';
            }
        }

        return static::$cacheEncode[$key];
    }
885176
public function addBindingValue(string $key, $value): string
    {
        $key = $this->removeTableFromKey($key);
        $placeholder = ':' . $key;
        if (!isset($this->bindingValues[$key])) {
            $this->bindingValues[$key] = $value;
            $this->bindingValueCounts[$key] = 1;
            return $placeholder;
        }

        $placeholder .= $this->bindingValueCounts[$key];
        $this->bindingValueCounts[$key]++;
        $this->bindingValues[$placeholder] = $value;
        return $placeholder;
    }
953163
protected function attributeElement($key, $value)
    {
        is_numeric($key) && $key = $value;

        if (is_array($value)) {
            $value = current($value);
        }

        if (!is_null($value)) {
            return $key . '="' . e($value) . '"';
        }
    }
1110799
public function setAttribute(string $key, string $value)
    {
        if ($this->valid($key, $value)) {
            $value = encrypt($value);
        }

        return parent::setAttribute($key, $value);
    }
230551
public function setValue($key, $value) {
		if( !isset($key) ) {
			// Invalid key
			throw new Exception("nullKey");
			
		} else if( !in_array($key, static::$fields) ) {
			// Unknown key
			throw new FieldNotFoundException($key, static::getClass());
			
		} else if( $key === static::$IDFIELD ) {
			// ID is not editable
			throw new Exception("idNotEditable");
			
		} else if( $value !== $this->data[$key] ) {
			// The value is different
			$this->addModFields($key);
			$this->data[$key] = $value;
		}
		return $this;
	}
917730
final public function offsetSet($key, $value)
	{
		$key = (string) $key;

		if ( array_key_exists($key, $this->_stack) ) {
			throw new \DomainException('Key already exists.');
		}

		$this->_stack[$key] = $value;
	}
1123592
public function addVariable($key, $value)
    {
        if (is_null($key) || ! is_string($key)) {
            throw new RuntimeException(sprintf('The key where to save your variable in the expression context is invalid. Got "%s".', $key));
        }

        $this->variables[$key] = $value;
    }
352312
public function encrypt($value, string $key, bool $base64 = false): string
    {
        $ret = $this->encryptBinary(serialize($value), $key);
        return ($base64) ? base64_encode($ret) : $ret;
    }