コード例 #1
0
 function it_shoulds_return_all_items_from_database_as_targets($simpleMappingManager, SimpleMapping $simpleMapping)
 {
     $simpleMappingManager->getMapping($this->getIdentifier('generic'))->willReturn(array($simpleMapping));
     $simpleMapping->getSource()->willReturn('generic_source');
     $simpleMapping->getTarget()->willReturn('generic_target');
     $this->getAllTargets()->shouldReturn(array(array('id' => 'generic_target', 'text' => 'generic_target')));
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function process($item)
 {
     $simpleMapping = new SimpleMapping();
     $simpleMapping->setIdentifier(sha1($item['identifier']));
     $simpleMapping->setSource($item['source']);
     $simpleMapping->setTarget($item['target']);
     return $simpleMapping;
 }
コード例 #3
0
 /**
  * Set mapping to database for given identifier.
  *
  * @param array  $mapping
  * @param string $identifier
  */
 public function setMapping(array $mapping, $identifier)
 {
     $this->pruneOldMapping($identifier);
     foreach ($mapping as $mappingItem) {
         if ($mappingItem['source'] != '') {
             $simpleMappingItem = $this->getEntityRepository()->findOneBy(array('identifier' => $identifier, 'source' => $mappingItem['source']));
             if (!$simpleMappingItem) {
                 $simpleMappingItem = new SimpleMapping();
                 $simpleMappingItem->setIdentifier($identifier);
                 $simpleMappingItem->setSource($mappingItem['source']);
             }
             $simpleMappingItem->setTarget($mappingItem['target']);
             $this->objectManager->persist($simpleMappingItem);
         }
     }
     $this->objectManager->flush();
 }