/** * Helper function which returns a single image mapping * for the passed variant image and variant model. * * @param Image $image * @param Detail $variant * @return null|Image\Mapping */ protected function getVariantMappingOfImage(Image $image, Detail $variant) { $parent = $image->getParent(); /**@var $mapping Image\Mapping*/ foreach ($parent->getMappings() as $mapping) { $match = true; /**@var $rule Image\Rule*/ foreach ($mapping->getRules() as $rule) { $option = $this->getCollectionElementByProperty($variant->getConfiguratorOptions(), 'id', $rule->getOption()->getId()); if (!$option) { $match = false; break; } } if ($match) { return $mapping; } } return null; }