Airship\Engine\Lens::prepend PHP 메소드

prepend() 공개 메소드

Maintain an array of values for later rendering, prepending the supplied value.
public prepend ( string $key, mixed $val ) : self
$key string Index
$val mixed Value
리턴 self
    public function prepend(string $key, $val) : self
    {
        if (!isset($this->stored[$key])) {
            $this->stored[$key] = [];
        } elseif (!is_array($this->stored[$key])) {
            // Let's store the existing value as the first index
            $this->stored[$key] = [$this->stored[$key]];
        }
        \array_unshift($this->stored[$key], $val);
        return $this;
    }