Neos\Flow\Session\Session::addTag PHP Метод

addTag() публичный Метод

Note that third-party libraries might also tag your session. Therefore it is recommended to use namespaced tags such as "Acme-Demo-MySpecialTag".
public addTag ( string $tag ) : void
$tag string The tag – must match be a valid cache frontend tag
Результат void
    public function addTag($tag)
    {
        if ($this->started !== true) {
            throw new Exception\SessionNotStartedException('Tried to tag a session which has not been started yet.', 1355143533);
        }
        if (!$this->metaDataCache->isValidTag($tag)) {
            throw new \InvalidArgumentException(sprintf('The tag used for tagging session %s contained invalid characters. Make sure it matches this regular expression: "%s"', $this->sessionIdentifier, FrontendInterface::PATTERN_TAG));
        }
        if (!in_array($tag, $this->tags)) {
            $this->tags[] = $tag;
        }
    }

Usage Example

 /**
  * @test
  * @expectedException \Neos\Flow\Session\Exception\SessionNotStartedException
  */
 public function addTagThrowsExceptionIfCalledOnNonStartedSession()
 {
     $session = new Session();
     $session->addTag('MyTag');
 }