| @@ 17-59 (lines=43) @@ | ||
| 14 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
| 15 | * @link http://swisscom.ch |
|
| 16 | */ |
|
| 17 | class ReadOnlyFieldsCompilerPass implements CompilerPassInterface |
|
| 18 | { |
|
| 19 | /** |
|
| 20 | * @var DocumentMap |
|
| 21 | */ |
|
| 22 | private $documentMap; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Make readOnly fields map and set it to parameter |
|
| 26 | * |
|
| 27 | * @param ContainerBuilder $container container builder |
|
| 28 | * |
|
| 29 | * @return void |
|
| 30 | */ |
|
| 31 | public function process(ContainerBuilder $container) |
|
| 32 | { |
|
| 33 | $this->documentMap = $container->get('graviton.document.map'); |
|
| 34 | ||
| 35 | $map = []; |
|
| 36 | foreach ($this->documentMap->getDocuments() as $document) { |
|
| 37 | $readOnlyFields = $this->documentMap->getFieldNamesFlat( |
|
| 38 | $document, |
|
| 39 | '', |
|
| 40 | '', |
|
| 41 | function ($field) { |
|
| 42 | return $field->isReadOnly(); |
|
| 43 | } |
|
| 44 | ); |
|
| 45 | ||
| 46 | if (!empty($readOnlyFields)) { |
|
| 47 | foreach ($readOnlyFields as $key => $readOnlyField) { |
|
| 48 | if (substr($readOnlyField, -2) == '.0') { |
|
| 49 | unset($readOnlyFields[$key]); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | $map[$document->getClass()] = array_values($readOnlyFields); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| 57 | $container->setParameter('graviton.document.readonly.fields', $map); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||
| @@ 17-59 (lines=43) @@ | ||
| 14 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
| 15 | * @link http://swisscom.ch |
|
| 16 | */ |
|
| 17 | class RecordOriginExceptionFieldsCompilerPass implements CompilerPassInterface |
|
| 18 | { |
|
| 19 | /** |
|
| 20 | * @var DocumentMap |
|
| 21 | */ |
|
| 22 | private $documentMap; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Make recordOriginException fields map and set it to parameter |
|
| 26 | * |
|
| 27 | * @param ContainerBuilder $container container builder |
|
| 28 | * |
|
| 29 | * @return void |
|
| 30 | */ |
|
| 31 | public function process(ContainerBuilder $container) |
|
| 32 | { |
|
| 33 | $this->documentMap = $container->get('graviton.document.map'); |
|
| 34 | ||
| 35 | $map = []; |
|
| 36 | foreach ($this->documentMap->getDocuments() as $document) { |
|
| 37 | $recordOriginExceptionFields = $this->documentMap->getFieldNamesFlat( |
|
| 38 | $document, |
|
| 39 | '', |
|
| 40 | '', |
|
| 41 | function ($field) { |
|
| 42 | return $field->isRecordOriginException(); |
|
| 43 | } |
|
| 44 | ); |
|
| 45 | ||
| 46 | if (!empty($recordOriginExceptionFields)) { |
|
| 47 | foreach ($recordOriginExceptionFields as $key => $recordOriginExceptionField) { |
|
| 48 | if (substr($recordOriginExceptionField, -2) == '.0') { |
|
| 49 | unset($recordOriginExceptionFields[$key]); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | $map[$document->getClass()] = array_values($recordOriginExceptionFields); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| 57 | $container->setParameter('graviton.document.recordoriginexception.fields', $map); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||