public function setState($state)
    {
        $state = (int) $state;
        if ($this->isRoot() && !($state & Page::STATE_ONLINE)) {
            throw new \LogicException("Root page state must be online.");
        }

        if (!$this->isOnline() && (self::STATE_ONLINE & $state) && !$this->isRoot() && !$this->getPublishing()) {
            $this->setPublishing(new \DateTime());
        }

        $this->_state = $state;

        return $this;
    }