/** * Returns a new collection of mappings of this collection that are not member of the $complementCollection. * * @param MappingCollection $complementCollection * @return \Flowpack\ElasticSearch\Mapping\MappingCollection */ public function diffAgainstCollection(MappingCollection $complementCollection) { $returnMappings = new \Flowpack\ElasticSearch\Mapping\MappingCollection(); foreach ($this as $entityMapping) { /** @var $entityMapping \Flowpack\ElasticSearch\Domain\Model\Mapping */ $mapping = new \Flowpack\ElasticSearch\Domain\Model\Mapping(clone $entityMapping->getType()); $saveMapping = FALSE; foreach ($entityMapping->getProperties() as $propertyName => $propertySettings) { foreach ($propertySettings as $entitySettingKey => $entitySettingValue) { $backendSettingValue = $complementCollection->getMappingSetting($entityMapping, $propertyName, $entitySettingKey); if ($entitySettingValue !== $backendSettingValue) { $mapping->setPropertyByPath(array($propertyName, $entitySettingKey), $entitySettingValue); $saveMapping = TRUE; } } } if ($saveMapping) { $returnMappings->add($mapping); } } return $returnMappings; }