Exemplo n.º 1
0
 /**
  *
  * @param type $format
  * @return \IntlDateFormatter
  * @throws Exception
  */
 protected function getIntlDateFormater($format)
 {
     if (\is_string($format)) {
         $format = \constant('\\IntlDateFormatter::' . \strtoupper($format));
     } else {
         if (!\is_numeric($format)) {
             throw new Exception('Format must be an string or IntlDateFormater Int Value');
         }
     }
     $locale = \Symfony\Component\Locale\Locale::getDefault();
     $tz = $this->userManager->getTimezone();
     $fmt = new \IntlDateFormatter($locale, $format, $format, $tz->getName(), \IntlDateFormatter::GREGORIAN);
     return $fmt;
 }
Exemplo n.º 2
0
 /**
  * @Given /^I created country "([^""]*)"$/
  * @Given /^there is country "([^""]*)"$/
  */
 public function thereIsCountry($name, $provinces = null, $flush = true)
 {
     /* @var $country CountryInterface */
     if (null === ($country = $this->getRepository('country')->findOneBy(array('name' => $name)))) {
         $country = $this->getRepository('country')->createNew();
         $country->setName(trim($name));
         $country->setIsoName(array_search($name, Locale::getDisplayCountries(Locale::getDefault())));
         if (null !== $provinces) {
             $provinces = $provinces instanceof TableNode ? $provinces->getHash() : $provinces;
             foreach ($provinces as $provinceName) {
                 $country->addProvince($this->thereisProvince($provinceName));
             }
         }
         $manager = $this->getEntityManager();
         $manager->persist($country);
         if ($flush) {
             $manager->flush();
         }
     }
     return $country;
 }
 private function localizeName($name, $locale = null)
 {
     return ($locale or $locale = Locale::getDefault()) ? $name . '.' . $locale : $name;
 }