protected function getValue(DatasourceInterface $datasource, FieldDefinition $fieldDescription, $rendererPrefix = null) { $fieldTypeName = $fieldDescription->getFieldType(); $fieldTypeInstance = $this->configuration->getFieldTypeInstance($fieldTypeName, $rendererPrefix); $unformattedFieldValue = $datasource->getFieldValue($fieldDescription); $formattedFieldValue = $fieldTypeInstance->render($unformattedFieldValue); if (null !== $fieldDescription->getCallback()) { $formattedFieldValue = $fieldDescription->executeCallBack($formattedFieldValue, $datasource); } return $formattedFieldValue; }
public function executeCallback($value, DatasourceInterface $datasource) { $callback = $this->callback; if (!$callback instanceof Closure) { throw new InvalidArgumentException('The callback must be a callable'); } return $callback($value, $datasource->current()); }