Beispiel #1
0
 /**
  * Fill the response with the default class IDs (if they don't exist already)
  * so that app versions with hardcoded defaults don't crash
  *
  * @param array $response The response
  */
 private function fillDefault(array &$response)
 {
     $classes = $this->getDoctrine()->getRepository('AppBundle:SchoolClass')->createQueryBuilder('c')->select('c.id')->where('c.id in (:ids)')->setParameter('ids', static::$defaultClasses)->getQuery()->getResult();
     $missing = array_diff(static::$defaultClasses, array_map('current', $classes));
     if (empty($missing)) {
         return;
     }
     $orientation = new Orientation();
     $separation = new Separation();
     $orientation->setName('')->setFullName('')->setColour('');
     $separation->setName('')->setFullName('')->setColour('');
     $separation->addOrientation($orientation);
     $orientation->setSeparation($separation);
     $this->setId($separation);
     $this->setId($orientation);
     foreach ($missing as $id) {
         $class = new SchoolClass();
         $this->setId($class, $id);
         $class->setName('');
         $class->setOrientation($orientation);
         $class->setDefault(false);
         $orientation->addClass($class);
     }
     $response['grades'][] = ['id' => 2, 'name' => '', 'separations' => [$separation]];
 }
 public function isSelected(SchoolClass $class, Separation $separation = null)
 {
     if (!array_key_exists($separation->getId(), $this->classes)) {
         return false;
     } elseif ($separation) {
         return $this->classes[$separation->getId()] == $class->getId();
     } else {
         return in_array($class->getId(), $this->classes);
     }
 }