Acl\AclExtras::_checkNode PHP Method

_checkNode() protected method

Check a node for existance, create it if it doesn't exist.
protected _checkNode ( string $path, string $alias, integer $parentId = null ) : array
$path string The path to check
$alias string The alias to create
$parentId integer The parent id to use when creating.
return array Aco Node array
    protected function _checkNode($path, $alias, $parentId = null)
    {
        $node = $this->Aco->node($path);
        if (!$node) {
            $data = ['parent_id' => $parentId, 'model' => null, 'alias' => $alias];
            $entity = $this->Aco->newEntity($data);
            $node = $this->Aco->save($entity);
            $this->out(__d('cake_acl', 'Created Aco node: <success>{0}</success>', $path));
        } else {
            $node = $node->first();
        }
        return $node;
    }