public function childCount(EntityInterface $node, $direct = false)
    {
        $config = $this->getConfig();
        $parent = $this->_table->aliasField($config['parent']);

        if ($direct) {
            return $this->_scope($this->_table->find())
                ->where([$parent => $node->get($this->_getPrimaryKey())])
                ->count();
        }

        $this->_ensureFields($node);

        return ($node->get($config['right']) - $node->get($config['left']) - 1) / 2;
    }
public function childCount(EntityInterface $node, $direct = false)
    {
        $config = $this->getConfig();
        $parent = $this->_table->aliasField($config['parent']);

        if ($direct) {
            return $this->_scope($this->_table->find())
                ->where([$parent => $node->get($this->_getPrimaryKey())])
                ->count();
        }

        $this->_ensureFields($node);

        return ($node->get($config['right']) - $node->get($config['left']) - 1) / 2;
    }
public function childCount ( EntityInterface $ node , $ direct = false ) { $ config = $ this -> getConfig ( ) ; $ parent = $ this -> _table -> aliasField ( $ config [ 'parent' ] ) ; if ( $ direct ) { return $ this -> _scope ( $ this -> _table -> find ( ) ) -> where ( [ $ parent => $ node -> get ( $ this -> _getPrimaryKey ( ) ) ] ) -> count ( ) ; } $ this -> _ensureFields ( $ node ) ; return ( $ node -> get ( $ config [ 'right' ] ) - $ node -> get ( $ config [ 'left' ] ) - 1 ) / 2 ; }
Get the number of children nodes.

@param \Cake\Datasource\EntityInterface $node The entity to count children for
@param bool $direct whether to count all nodes in the subtree or just
direct children
@return int Number of children nodes.
Get the number of children nodes .