Beispiel #1
0
 /** inheritdoc */
 public static function options($filters = array(), $orderBy = array(), $limit = null, $offset = null, $params = null, $allow_html = true, $group_by = null)
 {
     $called_class = get_called_class();
     $cache_id = md5($called_class . serialize($filters) . serialize($orderBy) . $limit . $offset);
     if (isset($called_class::$_options[$cache_id])) {
         return $called_class::$_options[$cache_id];
     }
     $metadata = $called_class::metadata();
     $is_root = $metadata->name == $metadata->rootEntityName;
     if (!is_null($group_by)) {
         return parent::options($filters, $orderBy, $limit, $offset, $params, $allow_html, $group_by);
     }
     $results = $called_class::select('item')->leftJoin('item.children', 'children')->addSelect('children')->orderBy('item.root, item.lft', 'ASC');
     if ($is_root) {
         $results->where('item.lvl = 1');
     }
     $results = $results->getQuery()->getResult();
     return $called_class::$_options[$cache_id] = static::buildTreeOptions($results, $is_root);
 }