Example #1
0
 /**
  * Expand the defintion by reference.
  *
  * @param Definition $definition
  * @param array $parameters
  */
 public function expand(Definition $definition, array $parameters = array())
 {
     $expRows = array();
     foreach ($definition['rows'] as $rowDefinition) {
         $rowItems = array(null);
         if (isset($rowDefinition['with_items'])) {
             $rowItems = $rowDefinition['with_items'];
         }
         $cellDefinitions = array();
         if (isset($rowDefinition['cells'])) {
             // Index the cell definitions..
             // This needs to be done because we cannot index them by default
             // in the definition because column names are dynamic and may validly be
             // duplicated (e.g. "name": "{{ cell.item }}").
             $cellDefinitions = $this->indexCellDefinitions($rowDefinition['cells']);
         }
         foreach ($rowItems as $rowItem) {
             $expRow = $this->expandRow($definition->getColumnNames(), $rowDefinition, $cellDefinitions, $rowItem, $parameters);
             // no longer need this
             unset($expRow['with_items']);
             $expRows[] = $expRow;
         }
     }
     $definition['rows'] = $expRows;
 }