| @@ 39-75 (lines=37) @@ | ||
| 36 | return $this->container->getParameter(trim($stringIdentifier, '%')); |
|
| 37 | } |
|
| 38 | ||
| 39 | private function getExpressionLanguage() |
|
| 40 | { |
|
| 41 | { |
|
| 42 | $language = new ExpressionLanguage(); |
|
| 43 | $language->addFunction( |
|
| 44 | new ExpressionFunction( |
|
| 45 | 'relatedContentIds', |
|
| 46 | function() { |
|
| 47 | throw new \Exception('ref function does not support compilation'); |
|
| 48 | }, |
|
| 49 | function($foo, Content $content, $fieldDefinitionIdentifier) { |
|
| 50 | $fieldValue = $content->getFieldValue($fieldDefinitionIdentifier); |
|
| 51 | if ($fieldValue instanceof FieldType\Relation\Value) { |
|
| 52 | return [$fieldValue->destinationContentId]; |
|
| 53 | } elseif ($fieldValue instanceof FieldType\RelationList\Value) { |
|
| 54 | return $fieldValue->destinationContentIds; |
|
| 55 | } else { |
|
| 56 | throw new \Exception("Expected a Relation or RelationList field value"); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ) |
|
| 60 | ); |
|
| 61 | $language->addFunction( |
|
| 62 | new ExpressionFunction( |
|
| 63 | 'collection_item', |
|
| 64 | function() { |
|
| 65 | throw new \Exception('ref function does not support compilation'); |
|
| 66 | }, |
|
| 67 | function($foo, $identifier) { |
|
| 68 | return $this->referenceResolver->getReferenceValue('reference:collection_item_' . $identifier); |
|
| 69 | } |
|
| 70 | ) |
|
| 71 | ); |
|
| 72 | ||
| 73 | return $language; |
|
| 74 | } |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| @@ 45-81 (lines=37) @@ | ||
| 42 | ); |
|
| 43 | } |
|
| 44 | ||
| 45 | private function getExpressionLanguage() |
|
| 46 | { |
|
| 47 | { |
|
| 48 | $language = new ExpressionLanguage(); |
|
| 49 | $language->addFunction( |
|
| 50 | new ExpressionFunction( |
|
| 51 | 'relatedContentIds', |
|
| 52 | function() { |
|
| 53 | throw new \Exception('ref function does not support compilation'); |
|
| 54 | }, |
|
| 55 | function($foo, Content $content, $fieldDefinitionIdentifier) { |
|
| 56 | $fieldValue = $content->getFieldValue($fieldDefinitionIdentifier); |
|
| 57 | if ($fieldValue instanceof FieldType\Relation\Value) { |
|
| 58 | return [$fieldValue->destinationContentId]; |
|
| 59 | } elseif ($fieldValue instanceof FieldType\RelationList\Value) { |
|
| 60 | return $fieldValue->destinationContentIds; |
|
| 61 | } else { |
|
| 62 | throw new \Exception("Expected a Relation or RelationList field value"); |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ) |
|
| 66 | ); |
|
| 67 | $language->addFunction( |
|
| 68 | new ExpressionFunction( |
|
| 69 | 'collection_item', |
|
| 70 | function() { |
|
| 71 | throw new \Exception('ref function does not support compilation'); |
|
| 72 | }, |
|
| 73 | function($foo, $identifier) { |
|
| 74 | return $this->referenceResolver->getReferenceValue('reference:collection_item_' . $identifier); |
|
| 75 | } |
|
| 76 | ) |
|
| 77 | ); |
|
| 78 | ||
| 79 | return $language; |
|
| 80 | } |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||