コード例 #1
0
ファイル: SchubertImporter.php プロジェクト: iuf/junia
 /**
  * @param string $name
  * @return Startgroup
  */
 private function getStartgroup($name)
 {
     $name = $this->translate($name);
     // some special cases
     $competition = null;
     if ($name == 'Junior Expert (male)' || $name == 'Expert (male)') {
         $competition = $this->competitions->get('Individual Freestyle (male)');
         $startgroupName = str_replace(' (male)', '', $name);
     } else {
         if ($name == 'Junior Expert (female)' || $name == 'Expert (female)') {
             $competition = $this->competitions->get('Individual Freestyle (female)');
             $startgroupName = str_replace(' (female)', '', $name);
         }
     }
     if ($competition === null) {
         $words = new Set();
         foreach (array_values($this->translations) as $names) {
             $words->addAll(Text::create($names)->split(' '));
         }
         $startgroupName = trim(str_replace($words->toArray(), '', $name));
         $words = Text::create($startgroupName)->split(' ');
         $competitionName = preg_replace('/\\s\\s+/', ' ', trim(str_replace($words->toArray(), '', $name)));
         if (!$this->competitions->has($competitionName)) {
             throw new \Exception('Cannot find competition for ' . $competitionName);
         }
         $competition = $this->competitions->get($competitionName);
     }
     $startgroup = new Startgroup();
     $startgroup->setName($startgroupName);
     $startgroup->setSlug(NameUtils::dasherize(strtolower($startgroupName)));
     $startgroup->setCompetition($competition);
     return $startgroup;
 }