GridCellProvider::getTemplateVarsFromRowColumn PHP Method

getTemplateVarsFromRowColumn() public method

Subclasses have to implement this method to extract variables for a given column from a data element so that they may be assigned to template before rendering.
public getTemplateVarsFromRowColumn ( $row, $column ) : array
$row GridRow
$column GridColumn
return array
    function getTemplateVarsFromRowColumn($row, $column)
    {
        return array();
    }

Usage Example

 /**
  * Extracts variables for a given column from a data element
  * so that they may be assigned to template before rendering.
  * @param $row GridRow
  * @param $column GridColumn
  * @return array
  */
 function getTemplateVarsFromRowColumn($row, $column)
 {
     $userGroup = $row->getData();
     /* @var $userGroup UserGroup */
     $columnId = $column->getId();
     $workflowStages = Application::getApplicationStages();
     $roleDao = DAORegistry::getDAO('RoleDAO');
     /* @var $roleDao RoleDAO */
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     /* @var $userGroupDao UserGroupDAO */
     $assignedStages = $userGroupDao->getAssignedStagesByUserGroupId($userGroup->getContextId(), $userGroup->getId());
     switch ($columnId) {
         case 'name':
             return array('label' => $userGroup->getLocalizedName());
         case 'abbrev':
             return array('label' => $userGroup->getLocalizedAbbrev());
         case in_array($columnId, $workflowStages):
             // Set the state of the select element that will
             // be used to assign the stage to the user group.
             $selectDisabled = false;
             if (in_array($columnId, $roleDao->getForbiddenStages($userGroup->getRoleId()))) {
                 // This stage should not be assigned to the user group.
                 $selectDisabled = true;
             }
             return array('selected' => in_array($columnId, array_keys($assignedStages)), 'disabled' => $selectDisabled);
         default:
             break;
     }
     return parent::getTemplateVarsFromRowColumn($row, $column);
 }
All Usage Examples Of GridCellProvider::getTemplateVarsFromRowColumn