1

Тема: sfDoctrineTreePlugin

День добрый.
Установил плагин sfDoctrineTreePlugin и при использовании его на свой таблице категорий (порядка ~150 записей) получил тормоза при показе дерева. Кол-во запросов к базе переваливало за три сотни. После ковыряния в коде плагина и небольших правок получил всего 4 запроса. Если кому будет интересно, правил код шаблона sfDoctrineTreePlugin/modules/sfDoctrineTree/templates/_nested_set_list.php :

<?php use_helper('Javascript', 'DoctrineTree'); ?>
<?php if( isset($records) && is_object($records) && $records->count() > 0 ): ?>
  <ul  id="dhtmlgoodies_tree2" class="dhtmlgoodies_tree">
    <?php
      $prevLevel = 0;
      $noRootAttr =  " noDrag='true' noSiblings='true' noDelete='true'";
      if ($no_root_rename) {
        $noRootAttr .= " noRename='true'";
      }
      if (isset($options['noAdd']) && $options['noAdd']) {
        $noRootAttr .= " noAdd='true'";
      }
      $nodeNoAttr = $options->count() > 0 ? _tag_options($options) : null;
      foreach($records AS $record):
        $currentLevel = $record->getLevel();
        $noAttr = $currentLevel == 0 ?  $noRootAttr : $nodeNoAttr;
        $recordIdentifier = $record->identifier();
        foreach ($recordIdentifier as $obj) {
          $identifier[] = $obj;
        }
        if($prevLevel > 0 && $currentLevel == $prevLevel) {
          echo '</li>';
        }
        if($currentLevel > $prevLevel) {
          echo '<ul>';
        }
        elseif ($currentLevel < $prevLevel) {
          echo str_repeat('</ul></li>', $prevLevel - $currentLevel);
        }
    ?>
      <li id ="node<?php echo $identifier[0] ?>" <?php echo $noAttr ?>>
    <?php
        $partial = $link_partial ? $link_partial : 'sfDoctrineTree/link';
        include_partial($partial, array('record' => $record, 'model' => $model, 'field' => $field, 'root' => $root, 'identifier' => $identifier[0]));
        if ($currentLevel == 0) {
          echo image_tag('/sfDoctrineTreePlugin/images/indicator.gif', array('style' => 'padding:0pt 5px;display:none;vertical-align:middle;', 'id' => 'doctrine_tree_indicator'));
        }
        $prevLevel = $currentLevel;
      endforeach;
    ?>
    </li>
  </ul>
<?php endif; ?>

Проблема была в вызовах в цикле вида $record->getNode()->getLevel() , которые я заменил на $record->getLevel()