Returns the processor for $fieldTypeIdentifier.
public getProcessor ( string $fieldTypeIdentifier ) : |
||
$fieldTypeIdentifier | string | |
return |
public function testRegisterProcessorsOverwrite() { $registry = new FieldTypeProcessorRegistry(); $processorA = $this->getAProcessorMock(); $processorB = $this->getAProcessorMock(); $registry->registerProcessor('my-type', $processorA); $registry->registerProcessor('my-type', $processorB); $this->assertSame($processorB, $registry->getProcessor('my-type')); }
/** * Parses the given $configurationHash using the FieldType identified by * $fieldTypeIdentifier. * * @param string $fieldTypeIdentifier * @param mixed $configurationHash * * @return mixed */ public function parseValidatorConfiguration($fieldTypeIdentifier, $configurationHash) { if ($this->fieldTypeProcessorRegistry->hasProcessor($fieldTypeIdentifier)) { $fieldTypeProcessor = $this->fieldTypeProcessorRegistry->getProcessor($fieldTypeIdentifier); $configurationHash = $fieldTypeProcessor->preProcessValidatorConfigurationHash($configurationHash); } $fieldType = $this->fieldTypeService->getFieldType($fieldTypeIdentifier); return $fieldType->validatorConfigurationFromHash($configurationHash); }
/** * Serializes the given $value for $fieldType with $generator into * $elementName. * * @param string $elementName * @param \eZ\Publish\Core\REST\Common\Output\Generator $generator * @param \eZ\Publish\API\Repository\FieldType $fieldType * @param mixed $value */ protected function serializeValue($elementName, Generator $generator, FieldType $fieldType, $value) { $hash = $fieldType->toHash($value); $fieldTypeIdentifier = $fieldType->getFieldTypeIdentifier(); if ($this->fieldTypeProcessorRegistry->hasProcessor($fieldTypeIdentifier)) { $processor = $this->fieldTypeProcessorRegistry->getProcessor($fieldTypeIdentifier); $hash = $processor->postProcessValueHash($hash); } $this->serializeHash($elementName, $generator, $hash); }