BookStack\Entity::matchesOrContains PHP Method

matchesOrContains() public method

Checks if an entity matches or contains another given entity.
public matchesOrContains ( Entity $entity ) : boolean
$entity Entity
return boolean
    public function matchesOrContains(Entity $entity)
    {
        $matches = [get_class($this), $this->id] === [get_class($entity), $entity->id];
        if ($matches) {
            return true;
        }
        if (($entity->isA('chapter') || $entity->isA('page')) && $this->isA('book')) {
            return $entity->book_id === $this->id;
        }
        if ($entity->isA('page') && $this->isA('chapter')) {
            return $entity->chapter_id === $this->id;
        }
        return false;
    }