original_string: protected function _setChildrenLevel($entity)
      {
          $config = $this->getConfig();
  
          if ($entity->get($config['left']) + 1 === $entity->get($config['right'])) {
              return;
          }
  
          $primaryKey = $this->_getPrimaryKey();
          $primaryKeyValue = $entity->get($primaryKey);
          $depths = [$primaryKeyValue => $entity->get($config['level'])];
  
          $children = $this->_table->find('children', [
              'for' => $primaryKeyValue,
              'fields' => [$this->_getPrimaryKey(), $config['parent'], $config['level']],
              'order' => $config['left'],
          ]);
  
          /* @var \Cake\Datasource\EntityInterface $node */
          foreach ($children as $node) {
              $parentIdValue = $node->get($config['parent']);
              $depth = $depths[$parentIdValue] + 1;
              $depths[$node->get($primaryKey)] = $depth;
  
              $this->_table->updateAll(
                  [$config['level'] => $depth],
                  [$primaryKey => $node->get($primaryKey)]
              );
          }
      }
code: protected function _setChildrenLevel($entity)
      {
          $config = $this->getConfig();
  
          if ($entity->get($config['left']) + 1 === $entity->get($config['right'])) {
              return;
          }
  
          $primaryKey = $this->_getPrimaryKey();
          $primaryKeyValue = $entity->get($primaryKey);
          $depths = [$primaryKeyValue => $entity->get($config['level'])];
  
          $children = $this->_table->find('children', [
              'for' => $primaryKeyValue,
              'fields' => [$this->_getPrimaryKey(), $config['parent'], $config['level']],
              'order' => $config['left'],
          ]);
  
          /* @var \Cake\Datasource\EntityInterface $node */
          foreach ($children as $node) {
              $parentIdValue = $node->get($config['parent']);
              $depth = $depths[$parentIdValue] + 1;
              $depths[$node->get($primaryKey)] = $depth;
  
              $this->_table->updateAll(
                  [$config['level'] => $depth],
                  [$primaryKey => $node->get($primaryKey)]
              );
          }
      }
code_tokens: protected function _setChildrenLevel ( $ entity ) { $ config = $ this -> getConfig ( ) ; if ( $ entity -> get ( $ config [ 'left' ] ) + 1 === $ entity -> get ( $ config [ 'right' ] ) ) { return ; } $ primaryKey = $ this -> _getPrimaryKey ( ) ; $ primaryKeyValue = $ entity -> get ( $ primaryKey ) ; $ depths = [ $ primaryKeyValue => $ entity -> get ( $ config [ 'level' ] ) ] ; $ children = $ this -> _table -> find ( 'children' , [ 'for' => $ primaryKeyValue , 'fields' => [ $ this -> _getPrimaryKey ( ) , $ config [ 'parent' ] , $ config [ 'level' ] ] , 'order' => $ config [ 'left' ] , ] ) ; /* @var \Cake\Datasource\EntityInterface $node */ foreach ( $ children as $ node ) { $ parentIdValue = $ node -> get ( $ config [ 'parent' ] ) ; $ depth = $ depths [ $ parentIdValue ] + 1 ; $ depths [ $ node -> get ( $ primaryKey ) ] = $ depth ; $ this -> _table -> updateAll ( [ $ config [ 'level' ] => $ depth ] , [ $ primaryKey => $ node -> get ( $ primaryKey ) ] ) ; } }
docstring: Set level for descendants.
  
  @param \Cake\Datasource\EntityInterface $entity The entity whose descendants need to be updated.
  @return void
docstring_tokens: Set level for descendants .