Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function getDefault($locale = null)
 {
     if (is_string($this->default) && $this->isAllowed($this->default)) {
         return Currency::create($this->default);
     }
     if (!$this->default) {
         $currency = new Currency(null, $locale);
         if ($this->isAllowed($currency->getIsoCode())) {
             return $currency;
         }
     } elseif (is_array($this->default)) {
         $default = $locale ?: Locale::getDefault();
         foreach ($this->default as $locale => $code) {
             if ($default === $locale && $this->isAllowed($code)) {
                 return Currency::create($code);
             }
         }
     }
     return Currency::create($this->getCodes()[0]);
 }