Exemplo n.º 1
0
 public function tagOfName($name)
 {
     if (!$name instanceof Tag) {
         $name = new Name($name);
     }
     return $this->tagRepo->tagOfName($name);
 }
Exemplo n.º 2
0
 /**
  * @test
  * @group tagrepo
  */
 public function should_create_tag_when_name_not_found()
 {
     $n_tag = new TagName('foo');
     $tag = $this->tagRepo->tagOfNameOrCreate($n_tag);
     $this->em->clear();
     $tags = $this->tagRepo->all();
     $this->assertCount(3, $tags);
     $this->assertInstanceOf('Bakgat\\Notos\\Domain\\Model\\Descriptive\\Tag', $tag);
     $this->assertTrue($n_tag->equals($tag->name()));
 }
Exemplo n.º 3
0
 public function createWebsites()
 {
     $websites = [['n' => 'Rekenmeeseter', 'u' => 'www.rekenmeester.be', 'o' => ['WIS G1', 'WIS G1.a'], 't' => ['optellen', 'aftrekken']], ['n' => 'Google', 'u' => 'www.google.be', 'o' => ['WIS G7', 'WIS G9', 'WIS G9.e'], 't' => ['optellen', 'Sinterklaas']]];
     foreach ($websites as $awebsite) {
         $website = Website::register(new Name($awebsite['n']), new URL($awebsite['u']));
         foreach ($awebsite['t'] as $atag) {
             $tag = $this->tagRepo->tagOfName(new TagName($atag));
             $website->addTag($tag);
         }
         foreach ($awebsite['o'] as $aobjective) {
             $objective = $this->currRepo->objectiveOfCode($aobjective);
             $website->addObjective($objective);
         }
         $this->manager->persist($website);
         $this->websiteRepo->add($website);
     }
 }
Exemplo n.º 4
0
 /**
  * @param $data
  * @param $book
  */
 private function syncTags($data, Book $book)
 {
     $book->clearTags();
     if (isset($data['tags'])) {
         foreach ($data['tags'] as $tag) {
             $t = $this->tagRepository->tagOfNameOrCreate(new TagName($tag['name']));
             $book->addTag($t);
         }
         return $data;
     }
     return $data;
 }