/**
  * @test
  */
 public function assigns_a_direct_skill_to_its_default_category()
 {
     $defaultCategory = (new Category())->setTitle('default');
     $activity = new Activity($defaultCategory);
     $skill = (new Skill())->setTitle('throwing')->setCategory($activity->getCategories()->get('default'));
     $activity->addSkill($skill);
     $this->assertSame($activity->getCategories()->get('default'), $skill->getCategory());
 }
Ejemplo n.º 2
0
 /**
  * Add activity
  *
  * @param Activity $activity
  * @return Student
  */
 public function addActivity(Activity $activity)
 {
     $key = $activity->getMachineName();
     if ($this->activities->containsKey($key)) {
         throw new \InvalidArgumentException('This Student already belongs to this Activity');
     }
     $this->activities->set($key, $activity);
     return $this;
 }
 private function setActivity($issue, $user, $type, $entityManager, $pre = false)
 {
     $entity = new Activity();
     $entity->setIssue($issue)->setProject($issue->getProject())->setUser($user)->setType($type);
     $entityManager->persist($entity);
     if (!$pre) {
         $entityManager->flush();
     }
 }
 public function load(ObjectManager $manager)
 {
     $activity = new Activity();
     $activity->setUser($this->getReference('user_admin'))->setIssue($this->getReference('issue_one'))->setProject($this->getReference('project_one'))->setType(Activity::CREATE_ISSUE);
     $manager->persist($activity);
     $activityTwo = new Activity();
     $activityTwo->setUser($this->getReference('user_manager'))->setIssue($this->getReference('issue_two'))->setProject($this->getReference('project_two'))->setType(Activity::CREATE_ISSUE);
     $manager->persist($activityTwo);
     $activityThree = new Activity();
     $activityThree->setUser($this->getReference('user_operator'))->setIssue($this->getReference('issue_three'))->setProject($this->getReference('project_three'))->setType(Activity::CREATE_ISSUE);
     $manager->persist($activityThree);
     $manager->flush();
 }
 /**
  * @param Entity\Activity $activity
  */
 private function attachCompetencies(Entity\Activity $activity)
 {
     switch ($activity->getTitle()) {
         case 'Basketball':
         case 'Football':
             $competencyList = array('Dribbling', 'Passing', 'Rebounding', 'Shooting', 'Defending', 'Gameplay', 'Tactics/Challenges');
             break;
         default:
             $competencyList = array();
     }
     $em = $this->kernel->getContainer()->get('doctrine')->getManager();
     if (!empty($competencyList)) {
         foreach ($competencyList as $competencyTitle) {
             $competency = new Entity\Competency();
             $competency->setTitle($competencyTitle);
             $em->persist($competency);
             $activity->addCompetency($competency);
             $em->persist($activity);
         }
     }
     $em->flush();
 }
 /**
  * @param ObjectManager $manager
  * @return Activity
  */
 private function loadAthletics(ObjectManager $manager)
 {
     $defaultCategory = (new Category())->setTitle('default');
     $manager->persist($defaultCategory);
     $athletics = new Activity($defaultCategory);
     $athletics->setTitle('Athletics');
     // Athletics::Distances
     $distances = (new Category())->setTitle('Distances')->setActivity($athletics);
     $manager->persist($distances);
     $athletics->addCategory($distances);
     // Athletics::Distances::Throws
     $throws = (new Category())->setTitle('Throws')->setParent($distances);
     $manager->persist($throws);
     $distances->addChild($throws);
     // Athletics::Distances::Throws::Discus
     $discus = (new Skill())->setTitle('Discus')->setCategory($throws);
     $manager->persist($discus);
     $throws->addSkill($discus);
     // Athletics::Distances::Throws::Shot
     $shot = (new Skill())->setTitle('Shot')->setCategory($throws);
     $manager->persist($shot);
     $throws->addSkill($shot);
     // Athletics::Distances::Throws::Javelin
     $javelin = (new Skill())->setTitle('Javelin')->setCategory($throws);
     $manager->persist($javelin);
     $throws->addSkill($javelin);
     // Athletics::Distances::Jumps
     $jumps = (new Category())->setTitle('Jumps')->setParent($distances);
     $manager->persist($jumps);
     $distances->addChild($jumps);
     // Athletics::Distances::Jumps::Long
     $long = (new Skill())->setTitle('Long')->setCategory($jumps);
     $manager->persist($long);
     $jumps->addSkill($long);
     // Athletics::Distances::Jumps::High
     $high = (new Skill())->setTitle('High')->setCategory($jumps);
     $manager->persist($high);
     $jumps->addSkill($high);
     // Athletics::Distances::Jumps::Triple
     $triple = (new Skill())->setTitle('Triple')->setCategory($jumps);
     $manager->persist($athletics);
     $manager->persist($triple);
     $jumps->addSkill($triple);
     // Athletics::Technique
     $technique = (new Skill())->setTitle('Technique')->setCategory($athletics->getCategories()->get('default'));
     $manager->persist($technique);
     $athletics->addSkill($technique);
     $manager->persist($athletics);
     return $athletics;
 }
Ejemplo n.º 7
0
 /**
  * Creates a form to delete a Activity entity.
  *
  * @param Activity $activity The Activity entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Activity $activity)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('activity_delete', array('id' => $activity->getId())))->setMethod('DELETE')->getForm();
 }