Пример #1
0
	public function submit() {
		/*$this->load->library('unit_test');
		echo $this->unit->run($this->input->post('number_of_contacts'), 4);
		return;*/
		
		if ($this->_submit_validate() === FALSE) {
			$this->add();
			return;
		}
		
		$tags = explode(',', $this->input->post('tags'));
		$tagsArray = array();
		foreach ($tags as $tag) {
			$tag1 = $this->em->getRepository('models\\EventTag')->findOneBy(array('name' => trim($tag)));
			if (!($tag1)){
				$tag1 = new models\EventTag;
				$tag1->setName(trim($tag));
				$this->em->persist($tag1);
				$this->em->flush();
			}
			$tagsArray[] = $tag1;
		}
		
		// dummy!! should get the currently logged in user
		$user1 = $this->em->find('models\User','1');
		
		$event= new models\Event;
		$event->setUser($user1);
		$event->setName($this->input->post('name'));
		$event->setDescription($this->input->post('description'));
		$event->setPlace($this->input->post('place'));
		$event->setDeadline(new DateTime(str_replace('/', '-', $this->input->post('deadline'))));
		$event->setTimestart($this->processDateTimeInput($this->input->post('time-start')));
		$event->setTimeend($this->processDateTimeInput($this->input->post('time-end')));
		$event->setCost($this->input->post('cost'));
		$event->setLimitation($this->input->post('limitation'));
		$event->setTags($tagsArray);
		$this->em->persist($event);
		$this->em->flush();

		$this->index();

	}
Пример #2
0
	public function addEventTags(){
		$event = $this->em->find('models\Event','1');
		
		$tag1 = new models\EventTag;
		$tag1->setName('hanami');
		$tag2 = new models\EventTag;
		$tag2->setName('summer');
		$tag3 = new models\EventTag;
		$tag3->setName('sakura');
		$this->em->persist($tag1);
		$this->em->persist($tag2);
		$this->em->persist($tag3);
		
		$event->setTags(array($tag1, $tag2, $tag3));
		
		$this->em->persist($event);
		$this->em->flush();
		
		$data['message'] = 'done';
		$this->load->view('home', $data);
	}