original_string: public function beforeDelete(Event $event, EntityInterface $entity)
      {
          $config = $this->getConfig();
          $this->_ensureFields($entity);
          $left = $entity->get($config['left']);
          $right = $entity->get($config['right']);
          $diff = $right - $left + 1;
  
          if ($diff > 2) {
              $query = $this->_scope($this->_table->query())
                  ->delete()
                  ->where(function ($exp) use ($config, $left, $right) {
                      /* @var \Cake\Database\Expression\QueryExpression $exp */
                      return $exp
                          ->gte($config['leftField'], $left + 1)
                          ->lte($config['leftField'], $right - 1);
                  });
              $statement = $query->execute();
              $statement->closeCursor();
          }
  
          $this->_sync($diff, '-', "> {$right}");
      }
code: public function beforeDelete(Event $event, EntityInterface $entity)
      {
          $config = $this->getConfig();
          $this->_ensureFields($entity);
          $left = $entity->get($config['left']);
          $right = $entity->get($config['right']);
          $diff = $right - $left + 1;
  
          if ($diff > 2) {
              $query = $this->_scope($this->_table->query())
                  ->delete()
                  ->where(function ($exp) use ($config, $left, $right) {
                      /* @var \Cake\Database\Expression\QueryExpression $exp */
                      return $exp
                          ->gte($config['leftField'], $left + 1)
                          ->lte($config['leftField'], $right - 1);
                  });
              $statement = $query->execute();
              $statement->closeCursor();
          }
  
          $this->_sync($diff, '-', "> {$right}");
      }
code_tokens: public function beforeDelete ( Event $ event , EntityInterface $ entity ) { $ config = $ this -> getConfig ( ) ; $ this -> _ensureFields ( $ entity ) ; $ left = $ entity -> get ( $ config [ 'left' ] ) ; $ right = $ entity -> get ( $ config [ 'right' ] ) ; $ diff = $ right - $ left + 1 ; if ( $ diff > 2 ) { $ query = $ this -> _scope ( $ this -> _table -> query ( ) ) -> delete ( ) -> where ( function ( $ exp ) use ( $ config , $ left , $ right ) { /* @var \Cake\Database\Expression\QueryExpression $exp */ return $ exp -> gte ( $ config [ 'leftField' ] , $ left + 1 ) -> lte ( $ config [ 'leftField' ] , $ right - 1 ) ; } ) ; $ statement = $ query -> execute ( ) ; $ statement -> closeCursor ( ) ; } $ this -> _sync ( $ diff , '-' , "> {$right}" ) ; }
docstring: Also deletes the nodes in the subtree of the entity to be delete
  
  @param \Cake\Event\Event $event The beforeDelete event that was fired
  @param \Cake\Datasource\EntityInterface $entity The entity that is going to be saved
  @return void
docstring_tokens: Also deletes the nodes in the subtree of the entity to be delete