コード例 #1
0
 /**
  * @param \APY\DataGridBundle\Grid\Column\Column $column
  * @return string
  */
 protected function getFieldName($column, $withAlias = false)
 {
     $name = $column->getField();
     if ($column instanceof DQLColumn) {
         if (!$withAlias) {
             return $name;
         }
         return $column->getDql() . ' as ' . $name;
     } else {
         if (strpos($name, '.') !== false) {
             $previousParent = '';
             $elements = explode('.', $name);
             while ($element = array_shift($elements)) {
                 if (count($elements) > 0) {
                     $parent = $previousParent == '' ? self::TABLE_ALIAS : $previousParent;
                     $previousParent .= '_' . $element;
                     $this->joins[$previousParent] = array('field' => $parent . '.' . $element, 'type' => $column->getJoinType());
                 } else {
                     $name = $previousParent . '.' . $element;
                 }
             }
             $alias = str_replace('.', '::', $column->getId());
         } elseif (strpos($name, ':') !== false) {
             $previousParent = self::TABLE_ALIAS;
             $alias = $name;
         } else {
             return self::TABLE_ALIAS . '.' . $name;
         }
     }
     // Aggregate dql functions
     $matches = array();
     if ($column->hasDQLFunction($matches)) {
         if (strtolower($matches['parameters']) == 'distinct') {
             $functionWithParameters = $matches['function'] . '(DISTINCT ' . $previousParent . '.' . $matches['field'] . ')';
         } else {
             $parameters = '';
             if ($matches['parameters'] !== '') {
                 $parameters = ', ' . (is_numeric($matches['parameters']) ? $matches['parameters'] : "'" . $matches['parameters'] . "'");
             }
             $functionWithParameters = $matches['function'] . '(' . $previousParent . '.' . $matches['field'] . $parameters . ')';
         }
         if ($withAlias) {
             // Group by the primary field of the previous entity
             $this->query->addGroupBy($previousParent);
             $this->querySelectfromSource->addGroupBy($previousParent);
             return "{$functionWithParameters} as {$alias}";
         }
         return $alias;
     }
     if ($withAlias) {
         return "{$name} as {$alias}";
     }
     return $name;
 }
コード例 #2
0
ファイル: Entity.php プロジェクト: TMSolution/DataGridBundle
 /**
  * @param \APY\DataGridBundle\Grid\Column\Column $column
  * @return string
  */
 protected function getFieldName($column, $withAlias = false)
 {
     $name = $column->getField();
     /* $isAssocciation = $column->getParam('isAssocciation');
        if($name=='product'){
        var_dump($isAssocciation);die();
        } */
     if (strpos($name, '.') !== false) {
         $previousParent = '';
         $elements = explode('.', $name);
         while ($element = array_shift($elements)) {
             if (count($elements) > 0) {
                 $parent = $previousParent == '' ? $this->getTableAlias() : $previousParent;
                 $previousParent .= '_' . $element;
                 $joinType = $column->getJoinType();
                 $this->joins[$previousParent] = array('field' => $parent . '.' . $element, 'type' => $joinType);
             } else {
                 $name = $previousParent . '.' . $element;
             }
         }
         $alias = str_replace('.', '::', $column->getId());
     } elseif (strpos($name, ':') !== false) {
         $previousParent = $this->getTableAlias();
         $alias = $name;
     } else {
         return $this->getTableAlias() . '.' . $name;
     }
     // Aggregate dql functions
     $matches = array();
     if ($column->hasDQLFunction($matches)) {
         if (strtolower($matches['parameters']) == 'distinct') {
             $functionWithParameters = $matches['function'] . '(DISTINCT ' . $previousParent . '.' . $matches['field'] . ')';
         } else {
             $parameters = '';
             if ($matches['parameters'] !== '') {
                 $parameters = ', ' . (is_numeric($matches['parameters']) ? $matches['parameters'] : "'" . $matches['parameters'] . "'");
             }
             $functionWithParameters = $matches['function'] . '(' . $previousParent . '.' . $matches['field'] . $parameters . ')';
         }
         if ($withAlias) {
             // Group by the primary field of the previous entity
             $this->query->addGroupBy($previousParent);
             $this->querySelectfromSource->addGroupBy($previousParent);
             return "{$functionWithParameters} as {$alias}";
         }
         return $alias;
     }
     if ($withAlias) {
         return "{$name} as {$alias}";
     }
     return $name;
 }
コード例 #3
0
 /**
  * Cell Drawing override
  *
  * @param \APY\DataGridBundle\Grid\Column\Column $column
  * @param \APY\DataGridBundle\Grid\Row $row
  * @param \APY\DataGridBundle\Grid\Grid $grid
  *
  * @return string
  */
 public function getGridCell($column, $row, $grid)
 {
     $value = $column->renderCell($row->getField($column->getField()), $row, $this->router);
     $id = $this->names[$grid->getHash()];
     if ($id != '' && ($this->hasBlock($block = 'grid_' . $id . '_column_' . $column->getRenderBlockId() . '_cell') || $this->hasBlock($block = 'grid_' . $id . '_column_' . $column->getType() . '_cell') || $this->hasBlock($block = 'grid_' . $id . '_column_' . $column->getParentType() . '_cell') || $this->hasBlock($block = 'grid_' . $id . '_column_id_' . $column->getRenderBlockId() . '_cell') || $this->hasBlock($block = 'grid_' . $id . '_column_type_' . $column->getType() . '_cell') || $this->hasBlock($block = 'grid_' . $id . '_column_type_' . $column->getParentType() . '_cell')) || $this->hasBlock($block = 'grid_column_' . $column->getRenderBlockId() . '_cell') || $this->hasBlock($block = 'grid_column_' . $column->getType() . '_cell') || $this->hasBlock($block = 'grid_column_' . $column->getParentType() . '_cell') || $this->hasBlock($block = 'grid_column_id_' . $column->getRenderBlockId() . '_cell') || $this->hasBlock($block = 'grid_column_type_' . $column->getType() . '_cell') || $this->hasBlock($block = 'grid_column_type_' . $column->getParentType() . '_cell')) {
         return $this->renderBlock($block, array('grid' => $grid, 'column' => $column, 'row' => $row, 'value' => $value));
     }
     return $this->renderBlock('grid_column_cell', array('grid' => $grid, 'column' => $column, 'row' => $row, 'value' => $value));
 }