eZ\Publish\Core\REST\Common\Output\Generator::checkStart PHP Method

checkStart() protected method

Check close / end operation.
protected checkStart ( string $type, mixed $data, array $validParents )
$type string
$data mixed
$validParents array
    protected function checkStart($type, $data, array $validParents)
    {
        $lastTag = end($this->stack);
        if (!is_array($lastTag)) {
            throw new Exceptions\OutputGeneratorException(sprintf('Invalid start: Trying to open outside of a document.'));
        }
        if (!in_array($lastTag[0], $validParents)) {
            throw new Exceptions\OutputGeneratorException(sprintf('Invalid start: Trying to open %s inside %s, valid parent nodes are: %s.', $type, $lastTag[0], implode(', ', $validParents)));
        }
        $this->stack[] = array($type, $data, array());
    }