lithium\storage\session\strategy\Hmac::write()

public method

Write strategy method.

Adds an HMAC signature to the data. Note that this will transform the passed $data to an array, and add a __signature key with the HMAC-calculated value.

Parameters

  • mixed $data

    The data to be signed.

  • array $options

    Options for this method.

Returns

array

Data & signature.

Source

	public function write($data, array $options = []) {
		$class = $options['class'];

		$futureData = $class::read(null, ['strategies' => false]);
		$futureData = [$options['key'] => $data] + $futureData;
		unset($futureData['__signature']);

		$signature = static::_signature($futureData);
		$class::write('__signature', $signature, ['strategies' => false] + $options);
		return $data;
	}