/**
  * Adds new rate or updates existing one
  *
  * @param string $currencyFrom
  * @param string $currencyTo
  * @param float  $rate
  */
 protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate)
 {
     if (!in_array($currencyTo, $this->managedCurrencies)) {
         return false;
     }
     $exchangeRate = $this->ratesRepository->findOneBy(['currencyFrom' => $currencyFrom, 'currencyTo' => $currencyTo]);
     if (null === $exchangeRate) {
         $exchangeRate = new CurrencyRate();
         $exchangeRate->setCurrencyFrom($currencyFrom);
         $exchangeRate->setCurrencyTo($currencyTo);
         $exchangeRate->setExchangeRate($rate);
         $this->helper->getEntityManager()->persist($exchangeRate);
     } else {
         $exchangeRate->setExchangeRate($rate);
     }
     return true;
 }
 /**
  * Creates new admin menu item
  *
  * @param \SimpleXMLElement $item
  */
 protected function addMenuItem(\SimpleXMLElement $item)
 {
     $em = $this->doctrineHelper->getEntityManager();
     $adminMenuItem = $this->adminMenuRepository->findOneBy(['identifier' => $item->identifier]);
     $parent = $this->adminMenuRepository->findOneBy(['identifier' => $item->parent]);
     if (null === $adminMenuItem) {
         $adminMenuItem = $this->adminMenuFactory->create();
         $adminMenuItem->setCssClass($item->css_class);
         $adminMenuItem->setIdentifier($item->identifier);
         $adminMenuItem->setName($item->name);
         $adminMenuItem->setRouteName($item->route_name);
         $adminMenuItem->setHierarchy($item->hierarchy);
         $adminMenuItem->setParent($parent);
         $em->persist($adminMenuItem);
         $em->flush();
     }
 }