@@ 31-44 (lines=14) @@ | ||
28 | /** |
|
29 | * {@inheritdoc} |
|
30 | */ |
|
31 | public function extract(Context $context, Value $value, PlainExtractorDefinitionInterface $definition, ExtractorInterface $extractor) |
|
32 | { |
|
33 | if ($definition->getNext()) { |
|
34 | // we have a type constraint on raw value here, so regards that we return raw value, |
|
35 | // we will try to extract it just to ensure constrain validity |
|
36 | try { |
|
37 | $extractor->extract($context, $value, $definition->getNext()); |
|
38 | } catch (ExtractorException $e) { |
|
39 | throw new ExtractorException('Raw value constraint failed: ' . $e->getMessage()); |
|
40 | } |
|
41 | } |
|
42 | ||
43 | return $value; |
|
44 | } |
|
45 | } |
|
46 |
@@ 41-52 (lines=12) @@ | ||
38 | /** |
|
39 | * {@inheritdoc} |
|
40 | */ |
|
41 | public function extract(Context $context, Value $value, PlainExtractorDefinitionInterface $definition, ExtractorInterface $extractor) |
|
42 | { |
|
43 | foreach ($this->scalar_extractors as $scalar_extractor) { |
|
44 | try { |
|
45 | return $scalar_extractor->extract($context, $value, $definition, $extractor); |
|
46 | } catch (ExtractorException $e) { |
|
47 | // |
|
48 | } |
|
49 | } |
|
50 | ||
51 | throw new ExtractorException('Value must be of the type scalar or be able to be casted to scalar, ' . $value->typeOf()->value() . ' given'); |
|
52 | } |
|
53 | } |
|
54 |