hasFlag example


  public function hasSessionBagFlag(Request $request) {
    /** @var \Drupal\session_test\Session\TestSessionBag */
    $bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
    return new Response(empty($bag->hasFlag())
      ? $this->t('Flag is absent from session bag')
      : $this->t('Flag is present in session bag')
    );
  }

}
public function __construct(int $flags = 0)
    {
        $this->flags = $flags;
    }

    /** * @return $this */
    public function setFlag(int $flag, bool $on)static
    {
        if ($on && !$this->hasFlag($flag)) {
            $this->flags += $flag;
        }

        if (!$on && $this->hasFlag($flag)) {
            $this->flags -= $flag;
        }

        return $this;
    }

    public function hasFlag(int $flag): bool
    {
Home | Imprint | This part of the site doesn't use cookies.