/**
  * {@inheritdoc}
  */
 public function fetch($sourceName = null, \DateTime $date = null)
 {
     $rates = array();
     $sourceNames = $sourceName === null ? array_map(function (SourceInterface $source) {
         return $source->getName();
     }, $this->sources->all()) : (array) $sourceName;
     foreach ($sourceNames as $sourceName) {
         $source = $this->sources->get($sourceName);
         $configurations = $this->configurations->all(array('sourceName' => $sourceName));
         /**
          * @var Configuration $configuration
          */
         foreach ($configurations as $configuration) {
             $rates[] = $source->fetch($configuration->getCurrencyCode(), $configuration->getRateType(), $date);
         }
     }
     /**
      * @var ProcessorInterface $processor
      */
     foreach ($this->processors->all() as $processor) {
         $rates = $processor->process($this->baseCurrency, $this->configurations, $rates);
     }
     $this->repository->save($rates);
     return $rates;
 }
 /**
  * Edit rate.
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function editAction(Request $request)
 {
     $this->denyAccessUnlessGranted(array('ROLE_EXCHANGE_RATE_MANAGER', 'ROLE_EXCHANGE_RATE_EDIT'));
     $form = $this->createForm($this->getEditFormType(), $this->getRateFromRequest($request));
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $this->repository->save(array($form->getData()));
         $this->get('session')->getFlashBag()->add('success', 'exchange_rate.flash.edit.success');
         return $this->redirectToRoute('roc_exchange_rate_list');
     }
     return $this->render($this->settings['edit'], array('base_template' => $this->settings['base_template'], 'form' => $form->createView(), 'secure' => $this->settings['secure']));
 }