public function normalize()
 {
     $this->_loadLogger();
     $this->_loadAttributeDefinitions();
     $newAttributes = array();
     /**
      * @var string $attributeName
      * @var array  $attributeValues
      */
     foreach ($this->_attributes as $attributeName => $attributeValues) {
         // Not defined in SURFconext attributes... can't find any aliases.
         if (!isset($this->_definitions[$attributeName])) {
             $newAttributes[$attributeName] = $attributeValues;
             continue;
         }
         // Traverse aliases to actual definition
         $originalAttributeName = $attributeName;
         $attributesSeen = array($attributeName);
         while (isset($this->_definitions[$attributeName]) && !is_array($this->_definitions[$attributeName])) {
             // Circular dependency check (Topological sorting)
             if (in_array($this->_definitions[$attributeName], $attributesSeen)) {
                 $this->_logger->error("Circular dependency detected in tree: " . implode(' => ', $attributesSeen) . ' => ' . $this->_definitions[$attributeName] . " reverting back to original '{$originalAttributeName}'");
                 $attributeName = $originalAttributeName;
                 break;
             }
             $attributeName = $this->_definitions[$attributeName];
             $attributesSeen[] = $attributeName;
         }
         if ($attributeName !== $originalAttributeName) {
             $this->_logger->debug("Attribute Normalization: '{$originalAttributeName}' resolves to '{$attributeName}'");
         }
         // Whoa, a resolved alias that doesn't have a definition?
         if (!isset($this->_definitions[$attributeName])) {
             $this->_logger->error("Attribute Normalization: Attribute '{$originalAttributeName}' resolved to '{$attributeName}'" . " but this does not have a definition? Skipping this attribute and it's values");
         }
         if (!isset($newAttributes[$attributeName])) {
             $newAttributes[$attributeName] = $attributeValues;
             continue;
         }
         // Note that array_diff does not work recursively
         $valuesDiff = array_diff($newAttributes[$attributeName], $attributeValues);
         if (empty($valuesDiff)) {
             $this->_logger->debug("Attribute Normalization: '{$attributeName}' (originally '{$attributeName}') " . "already exists with the same value... doing nothing.");
             continue;
         } else {
             $this->_logger->notice("Attribute Normalization: '{$attributeName}' (originally '{$attributeName}') " . "already exists with a different value... overwriting.");
             $newAttributes[$attributeName] = $attributeValues;
         }
     }
     return $newAttributes;
 }
 public function injectOverrides()
 {
     $fixture = new \OpenConext\Component\EngineBlockFixtures\SuperGlobalsFixture(new \OpenConext\Component\EngineBlockFixtures\DataStore\JsonDataStore(self::FILE));
     $overrides = $fixture->getAll();
     foreach ($overrides as $superGlobalName => $values) {
         $superGlobalName = '_' . $superGlobalName;
         global ${$superGlobalName};
         $global =& ${$superGlobalName};
         foreach ($values as $name => $value) {
             $this->_logger->notice(sprintf('Overwriting $%s[%s]', $superGlobalName, $name), array('super_global' => array('from' => $global[$name], 'to' => $value)));
             $global[$name] = $value;
         }
     }
     return true;
 }
 /**
  * @param string $id
  * @param string $type
  * @param string $ietfLanguageTag
  * @return string
  */
 private function getTypeForLang($id, $type, $ietfLanguageTag = 'en')
 {
     if (isset($this->definitions[$id][$type][$ietfLanguageTag])) {
         return $this->definitions[$id][$type][$ietfLanguageTag];
     }
     $this->logger->notice("Attribute lookup failure '{$id}' has no '{$type}' for language '{$ietfLanguageTag}'");
     return '';
 }
 /**
  * Association d'un Intent et d'un paiement, avec envoie des evenements
  * @since  1.0.0
  * @param mixed                                  $intentId integer si intentId est false alors nous avons un payment orphelin.
  * @param Ecedi\Donate\CoreBundle\Entity\Payment $payment  une instance de payment
  * @todo  flush is not right here, it should be in the controller
  *
  */
 public function attachPayment($intentId, Payment $payment)
 {
     $intentRepository = $this->getDoctrine()->getRepository('DonateCoreBundle:Intent');
     $em = $this->getDoctrine()->getManager();
     if ($intentId && ($intent = $intentRepository->find($intentId))) {
         $intent->addPayment($payment);
         $this->logger->debug('addPayment to intent');
         if ($intent->getType() == Intent::TYPE_SPOT && $intent->getStatus() == Intent::STATUS_PENDING) {
             //Propagation de l'état du paiement vers l'intent
             $intent->setStatus(Intent::STATUS_DONE);
             $this->logger->debug('set intent status to DONE');
         } else {
             //on reçoit plusieurs post-sale pour le même spot order...
             $this->logger->notice('another post sale for this intent');
         }
         $em->persist($intent);
     }
     $this->dispatchPaymentStatusEvent($payment);
     $em->persist($payment);
     $em->flush();
 }