Exemplo n.º 1
0
 /**
  * Adds a new task.
  *
  * @param string $taskString The new task.
  */
 public function add($taskString)
 {
     $task = new Task();
     $task->setTask($taskString);
     $this->_em->persist($task);
     $this->_em->flush($task);
 }
Exemplo n.º 2
0
 public function load(ObjectManager $manager)
 {
     $obj = new Task();
     $obj->setName('example task')->setNotes("nota di esempio")->setCreatedAt(new \DateTime())->setFinished(true)->addTag($this->getReference('tag:home'))->addTag($this->getReference('tag:company'));
     $manager->persist($obj);
     $manager->flush();
 }
Exemplo n.º 3
0
 public function showAction(Request $request)
 {
     // create a task and give it some dummy data for this example
     $task = new Task();
     $task->setTask('Write a blog post');
     $task->setDueDate(new \DateTime('tomorrow'));
     //$task->setLevel(new \Integer(0));
     //$task->setLevel('0');
     /* Instead of building the form in the controller we using class TaskType (AppBundle\Form\Type\TaskType)
        $form = $this->createFormBuilder($task)
            ->add('task', TextType::class)            
            ->add('dueDate', DateType::class)            
            ->add('save', SubmitType::class, array('label' => 'Create Task'))
            ->add('saveAndAdd', SubmitType::class, array('label' => 'Save and Add'))
            ->getForm();
        $form->handleRequest($request);
        */
     // This way I may use the form task any where whitout need to repeat-it
     $form = $this->createForm(TaskType::class, $task);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // ... perform some action, such as saving the task to the database
         // ....
         //$form->get('sbmDate')->setData(new \DateTime());
         echo '<pre>';
         print_r($task);
         die;
         #return $this->redirectToRoute('task_success');
         $nextAction = $form->get('saveAndAdd')->isClicked() ? 'task_new' : 'task_success';
         return $this->redirectToRoute($nextAction);
     }
     return $this->render('default/tasking.html.twig', array('form' => $form->createView()));
 }
Exemplo n.º 4
0
 public function load(ObjectManager $manager)
 {
     $yaml = new Parser();
     $symbonfy_base_dir = $this->container->getParameter('kernel.root_dir');
     $data_dir = $symbonfy_base_dir . '/Resources/data/';
     try {
         $value = Yaml::parse(file_get_contents($data_dir . 'tasks.yml'));
     } catch (ParseException $e) {
         printf("Unable to parse the YAML string: %s", $e->getMessage());
     }
     /*
     tasks:
         0: { id: 1, name: ''}
         1: { id: 1, name: ''}
     taskauthor:
         0: { id: 1, name: "Brad Taylor", isActive: true }
         1: { id: 2, name: "William O'Neil", isActive: false }
     */
     $tasks = array(0 => array('name' => 'Task 0', 'description' => 'Description Task 0', 'products' => [1, 2, 3]), 1 => array('name' => 'Task 1', 'description' => 'Description Task 1', 'products' => [1, 4]), 2 => array('name' => 'Task 2', 'description' => 'Description Task 2', 'products' => [2, 3]));
     foreach ($tasks as $task_id => $data) {
         $task = new Task();
         $task->setName($data['name']);
         $task->setDescription($data['description']);
         foreach ($data['products'] as $product) {
             $task->addProduct($this->getReference($product));
         }
         $manager->persist($task);
     }
     $manager->flush();
 }
Exemplo n.º 5
0
 /**
  * Event automatically fired when user is registered
  *
  * @param FilterUserResponseEvent $event
  */
 public function onUserRegistered(FilterUserResponseEvent $event)
 {
     /** @var User $user */
     $user = $event->getUser();
     $name = 'Unasigned actions';
     $task = new Task($name, $user);
     $task->setDefault(true);
     $this->taskRepository->save($task);
 }
Exemplo n.º 6
0
 /**
  * @Route("/form", name="form")
  */
 public function newAction(Request $request)
 {
     // create a task and give it some dummy data for this example
     $task = new Task();
     $task->setTask('Write a blog post');
     $task->setDueDate(new \DateTime('tomorrow'));
     $form = $this->createFormBuilder($task)->add('task', 'text')->add('dueDate', 'date')->add('save', 'submit', array('label' => 'Create Task'))->getForm();
     return $this->render('home.html.twig');
 }
Exemplo n.º 7
0
 /**
  * Sets task as users default task
  *
  * @param Task $task
  * @param User $user
  */
 public function setTaskAsDefault(Task $task, User $user)
 {
     $this->em->beginTransaction();
     $defaultTask = $this->taskRepository->findUserDefaultTask($user->getId());
     $defaultTask->setDefault(false);
     $task->setDefault(true);
     $this->taskRepository->update($task);
     $this->em->flush();
     $this->em->commit();
 }
 /**
  * @Route("", name="task_insert")
  * @Method({"POST"})
  */
 public function insertAction(Request $request)
 {
     $task = new Task();
     $task->setName('A Foo Bar');
     $task->setDescription('Lorem ipsum dolor');
     $em = $this->getDoctrine()->getManager();
     $em->persist($task);
     $em->flush();
     $response = new Response();
     $response->setContent(json_encode(array("message" => 'Created product id ' . $task->getId())));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Exemplo n.º 9
0
 public function load(ObjectManager $manager)
 {
     $task = new Task();
     $task->setDescription('task one');
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $tag1 = new Tag();
     $tag1->setName('tag1');
     $tag1->addTask($task);
     $task->getTags()->add($tag1);
     $manager->persist($task);
     $manager->flush();
 }
Exemplo n.º 10
0
 public function load(ObjectManager $manager)
 {
     $obj = new Task();
     $obj->setName("Exemple de tâche pour l'été");
     $obj->setNotes("Cette tâche est créée pour la data fixture. C'est seulement pour la démonstration. Désolé!");
     $obj->setCreatedAt(new \DateTime());
     $obj->setFinished(false);
     $obj->setDueDate(new \DateTime());
     $obj->addTag($this->getReference('tag:home'));
     $obj->addTag($this->getReference('tag:important'));
     $obj->setUser($this->getReference('user:toto'));
     $manager->persist($obj);
     $manager->flush();
 }
Exemplo n.º 11
0
 /**
  * 添加新任务
  * [
  * 'urls':
  * [
  * title:"",
  * host:"",
  * url:"",
  * level:""
  * ]
  * ]
  * @Route("/addtask", name="addtask")
  * @Method("POST")
  */
 public function addTask(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $data = $this->getData($request);
     $this->get('logger')->addError('ERROR', $data);
     // return $this->response(Response::HTTP_OK,implode($data));
     //        return $this->response(Response::HTTP_OK, $data);
     //记录Url
     if (!empty($data['urls'])) {
         foreach ($data['urls'] as $url) {
             $urlInfo = parse_url($url['url']);
             if (!isset($urlInfo['host'])) {
                 continue;
             }
             if ($em->getRepository('AppBundle:Task')->findBy(['url' => $url['url']])) {
                 $this->get('logger')->addError('ERROR', $url['url']);
                 continue;
             }
             $task = new Task();
             $task->setStatus(Task::STATUS_NO_DO);
             $task->setTitle($url['title']);
             $task->setDomain($urlInfo['host']);
             $task->setUrl($url['url']);
             $task->setLevel($url['level']);
             $task->setAddtime(time());
             $em->persist($task);
             $em->flush();
         }
     }
     //记录已经完成
     $task = $em->getRepository('AppBundle:Task')->find($data['id']);
     $task->setStatus(Task::STATUS_DO_SUCCESS);
     $em->flush();
     return $this->response(Response::HTTP_OK, []);
 }
Exemplo n.º 12
0
 /**
  * @Route("/form1", name="form1")
  */
 public function indexAction1(Request $request)
 {
     // create a task and give it some dummy data for this example
     $task = new Task();
     $task->setTask('Write a blog post');
     $task->setDueDate(new \DateTime('tomorrow'));
     $form = $this->createFormBuilder($task)->add('task', TextType::class)->add('codeReference', TextType::class, ['required' => false])->add('gender', ChoiceType::class, ['choices' => ['Male' => 'M', 'Female' => 'F', '' => null]])->add('dueDate', DateType::class)->add('save', SubmitType::class, array('label' => 'Create Task'))->add('saveAndAdd', SubmitType::class, array('label' => 'Save and Add'))->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // ... perform some action, such as saving the task to the database
         $nextAction = $form->get('saveAndAdd')->isClicked() ? 'task_new' : 'form';
         return $this->redirectToRoute($nextAction);
     }
     return $this->render('AppBundle:default:form.html.twig', array('form' => $form->createView()));
 }
Exemplo n.º 13
0
 /**
  * @Route("/testblog", name="testblog")
  */
 public function testblogAction(Request $request)
 {
     $data = array();
     // crea una task y le asigna algunos datos ficticios para este ejemplo
     $task = new Task();
     $task->setTask('Write a blog post');
     $task->setDueDate(new \DateTime('tomorrow'));
     $form = $this->createFormBuilder($task)->add('task', TextType::class)->add('dueDate', DateType::class)->add('save', SubmitType::class, array('label' => 'Create Task'))->add('saveAndAdd', SubmitType::class, array('label' => 'Save and Add'))->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // ... perform some action, such as saving the task to the database
         $nextAction = $form->get('saveAndAdd')->isClicked() ? 'task_new' : 'task_success';
         return $this->redirectToRoute($nextAction);
     }
     return $this->render('AppBundle:blog:testblog.html.twig', array('data' => $data, 'form' => $form->createView()));
 }
Exemplo n.º 14
0
 /**
  * @Route("/", name="homepage")
  * @Method({"GET", "POST"})
  */
 public function indexAction(Request $request)
 {
     /** @var EntityManager $em */
     $em = $this->getDoctrine()->getManager();
     $task = new Task();
     $task->setCreatedAt(new \DateTime());
     $form = $this->createFormBuilder($task)->setAction($this->generateUrl('homepage'))->setMethod('POST')->add('task', 'text')->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em->persist($task);
         $em->flush();
         $this->addFlash('notice', 'Task added.');
         return $this->redirectToRoute('homepage');
     }
     $tasks = $em->getRepository('AppBundle:Task')->findAll();
     return $this->render('default/index.html.twig', ['form' => $form->createView(), 'tasks' => $tasks]);
 }
Exemplo n.º 15
0
 public function newAction(Request $request)
 {
     // create a task and give it some dummy data for this example
     $task = new Task();
     $task->setTask('Write a blog post');
     $task->setDueDate(new \DateTime('tomorrow'));
     $form = $this->createFormBuilder($task)->add('task', 'text')->add('dueDate', 'date')->add('save', 'submit', array('label' => 'Create Task'))->getForm();
     $form->handleRequest($request);
     $errors = array();
     if ($form->isValid()) {
         // perform some action, such as saving the task to the database
         $data = $form->getData();
         var_dump($data);
         die;
     } else {
         $errors = $form->getErrors();
     }
     return $this->render('task/new.html.twig', array('form' => $form->createView(), 'errors' => $errors));
 }
 /**
  * @Route("/task", name="task")
  */
 public function newAction(Request $request)
 {
     $task = new Task();
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $tag1 = new Tag();
     $tag1->name = 'tag1';
     $task->getTags()->add($tag1);
     $tag2 = new Tag();
     $tag2->name = 'tag2';
     $task->getTags()->add($tag2);
     // end dummy code
     $form = $this->createForm(TaskType::class, $task, array('action' => $this->get('router')->generate('task')));
     $form->handleRequest($request);
     if ($form->isSubmitted()) {
         $this->addFlash('notice', 'Your changes were saved!');
     }
     return $this->render('AppBundle:Task:new.html.twig', array('form' => $form->createView()));
 }
Exemplo n.º 17
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     foreach (range(1, 2) as $s) {
         foreach (range(1, 5) as $i) {
             $task = new Task();
             $task->setProject($this->getReference('project' . $s));
             $task->setName('Project-' . $s . '-Task-' . $i);
             $task->setStatus('Pending');
             $task->setDescription('Some brief project description to go here.');
             $task->setUserId($s);
             $task->setCreatedAt(new \DateTime('now'));
             $task->setUpdatedAt(new \DateTime('now'));
             $date = new \DateTime('now');
             $duedate = $date->add(new \DateInterval('P30D'));
             $task->setDueDate($duedate);
             $manager->persist($task);
         }
     }
     $manager->flush();
 }
Exemplo n.º 18
0
 public function load(ObjectManager $manager)
 {
     $task1 = new Task();
     $task1->setUser($manager->merge($this->getReference('user_one')));
     $task1->setName('Setup Computer');
     $task1->setStatus(4);
     $task1->setTag('task A');
     $task1->setStartAt(new \DateTime('-3 days'));
     $task1->setFinishAt(new \DateTime('-2 days'));
     $task1->setContent('Setup the new computer!');
     $task2 = new Task();
     $task2->setUser($manager->merge($this->getReference('user_two')));
     $task2->setName('Install all software as required');
     $task2->setStatus(5);
     $task1->setTag('task B');
     $task2->setStartAt(new \DateTime('-2 days'));
     $task2->setFinishAt(new \DateTime('-1 days'));
     $task2->setContent('Install all software for the new computere');
     $task3 = new Task();
     $task3->setName('Setup Table');
     $task3->setUser($manager->merge($this->getReference('user_three')));
     $task3->setStatus(3);
     $task1->setTag('task A');
     $task3->setStartAt(new \DateTime('-1 days'));
     $task3->setFinishAt(new \DateTime());
     $task3->setContent('Install tables for the computer!');
     $task4 = new Task();
     $task4->setName('Prepare the stationary for staffs');
     $task4->setUser($manager->merge($this->getReference('user_one')));
     $task4->setStatus(2);
     $task1->setTag('task A');
     $task4->setStartAt(new \DateTime('+2 days'));
     $task4->setFinishAt(new \DateTime('+3 days'));
     $task4->setContent('Collect all stationary for staffs!');
     $task5 = new Task();
     $task5->setUser($manager->merge($this->getReference('user_three')));
     $task5->setName('Grab chair for staff');
     $task5->setStatus(1);
     $task1->setTag('task C');
     $task5->setStartAt(new \DateTime('+4 days'));
     $task5->setFinishAt(new \DateTime('+5 days'));
     $task5->setContent('Get chair for staff!');
     $manager->persist($task1);
     $manager->persist($task2);
     $manager->persist($task3);
     $manager->persist($task4);
     $manager->persist($task5);
     $manager->flush();
 }
Exemplo n.º 19
0
 /**
  * @Route("/new")
  */
 public function newAction(Request $request)
 {
     // create a task and give it some dummy data for this example
     $task = new Task();
     $task->setTask('Write a blog post');
     $task->setDueDate(new \DateTime('tomorrow'));
     $form = $this->createFormBuilder($task)->add('task', 'text')->add('dueDate', 'date')->add('save', 'submit', array('label' => 'Create Task'))->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // ... perform some action, such as saving the task to the database
         return $this->redirectToRoute('task_success');
     }
     $validator = $this->get('validator');
     $errors = $validator->validate($task);
     // if (count($errors) > 0) {
     //      * Uses a __toString method on the $errors variable which is a
     //      * ConstraintViolationList object. This gives us a nice string
     //      * for debugging.
     //     $errorsString = (string) $errors;
     //     return new Response($errorsString);
     // }
     return $this->render('default/new.html.twig', array('form' => $form->createView(), 'errors' => $errors));
 }
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  * @Route("/new-task")
  */
 public function newAction(Request $request)
 {
     $task = new Task();
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $tag1 = new Tag();
     $tag1->setName('tag1');
     $task->getTags()->add($tag1);
     $tag2 = new Tag();
     $tag2->setName('tag2');
     $task->getTags()->add($tag2);
     // end dummy code
     $form = $this->createForm(new TaskType(), $task);
     $form->handleRequest($request);
     if ($form->isValid()) {
         // ... maybe do some form processing, like saving the Task and Tag objects
         $em = $this->getDoctrine()->getManager();
         $task = $form->getData();
         $em->persist($task);
         $em->flush();
     }
     return $this->render('new.html.twig', array('form' => $form->createView()));
 }
Exemplo n.º 21
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('title')->add('content')->add('priorityId', EntityType::class, ['class' => Priority::class, 'query_builder' => function ($repository) use($options) {
         return $repository->getPriorities($options, true);
     }])->add('deadline', DateTimeType::class)->add('parentTaskId', EntityType::class, ['class' => Task::class, 'query_builder' => function ($repository) use($options) {
         return $repository->getTasks($options, true);
     }, 'required' => false])->add('status', ChoiceType::class, ['choices' => Task::getStatuses()])->add('assigned', EntityType::class, ['class' => User::class, 'multiple' => true, 'mapped' => false, 'query_builder' => function ($repository) use($options) {
         return $repository->getUsers($options, true);
     }, 'data' => $options['data']->assigned])->add('followers', EntityType::class, ['class' => User::class, 'multiple' => true, 'mapped' => false, 'query_builder' => function ($repository) use($options) {
         return $repository->getUsers($options, true);
     }, 'data' => $options['data']->followers])->add('labels', EntityType::class, ['class' => Labels::class, 'multiple' => true, 'mapped' => false, 'query_builder' => function ($repository) use($options) {
         return $repository->getLabels($options, true);
     }, 'data' => $options['data']->labels, 'required' => false]);
 }
Exemplo n.º 22
0
 public function newAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $task = new Task();
     $task->setName('Task name');
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $product1 = new Product();
     $product1->setName('prodct1');
     $product1->setPrice('11.11');
     $task->getProducts()->add($product1);
     $product2 = new Product();
     $product2->setName('product2');
     $product2->setPrice('22.22');
     $task->getProducts()->add($product2);
     $form = $this->createForm(TaskType::class, $task);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em->persist($task);
         $em->flush();
         return $form->get('saveAndAdd')->isClicked() ? $this->redirectToRoute('task_new', [], 301) : $this->redirectToRoute('task_list', [], 301);
     }
     return $this->render('AppBundle:Task:new.html.twig', array('form' => $form->createView()));
 }
Exemplo n.º 23
0
 /**
  * @Route("json/admin/tasks/add", name="json_tasks_add")
  * @Method("POST")
  * @param Request $request
  * @return Response
  */
 public function jsonAddTaskAction(Request $request)
 {
     $task = new Task();
     $task->setTitle($request->request->get('title'));
     $task->setCreatedAt(new DateTime($request->request->get('dateFrom')));
     $task->setFinishDate(new DateTime($request->request->get('dateTo')));
     $task->setDescription($request->request->get('description'));
     $this->get('task_manager')->saveTask($task);
     foreach ($request->request->get('employees') as $employee) {
         $user = $this->get('user_repository')->findByPk($employee);
         $user->addTask($task);
     }
     $this->getDoctrine()->getManager()->flush();
     return new JsonResponse(array('Success'));
 }
 /**
  * @Route("/test-form", name="test")
  */
 public function newAction(Request $request)
 {
     $task = new Task();
     $task->setTask('Write a blog post');
     $task->setDueDate(new \DateTime('tomorrow'));
     $form = $this->createFormBuilder($task)->add('task', 'text')->add('dueDate', 'date')->add('save', 'submit', array('label' => 'Create Task'))->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         return $this->redirectToRoute('task_success');
     }
     return $this->render('AppBundle::testForm.html.twig', array('form' => $form->createView()));
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $state = new State();
     $state->setName('Ingresado');
     $manager->persist($state);
     $project = new Project();
     $project->setName('Project 1');
     $manager->persist($project);
     $parentTask = new Task();
     $parentTask->setTitle('Parent task 1');
     $parentTask->setDescription('Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.');
     $parentTask->setPublishedAt(new \DateTime());
     $parentTask->setProject($project);
     $parentTask->setState($state);
     $manager->persist($parentTask);
     $timeEntry = new TimeEntry();
     $timeEntry->setTask($parentTask);
     $timeEntry->setDate(new \DateTime());
     $timeEntry->setHours(8);
     $timeEntry->setComment('Lorem ipsum ad his scripta blandit partiendo');
     $manager->persist($timeEntry);
     $manager->flush();
     for ($i = 1; $i <= 5; $i++) {
         $task = new Task();
         $task->setTitle('Task ' . $i);
         $task->setDescription('Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.');
         $task->setPublishedAt(new \DateTime());
         $task->setProject($project);
         $task->setState($state);
         $task->setParent($parentTask);
         $manager->persist($task);
     }
     $manager->flush();
     $state = new State();
     $state->setName('En curso');
     $manager->persist($state);
     $project = new Project();
     $project->setName('Project 2');
     $manager->persist($project);
     $parentTask = new Task();
     $parentTask->setTitle('Parent task 2');
     $parentTask->setDescription('Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.');
     $parentTask->setPublishedAt(new \DateTime());
     $parentTask->setProject($project);
     $parentTask->setState($state);
     $manager->persist($parentTask);
     $timeEntry = new TimeEntry();
     $timeEntry->setTask($parentTask);
     $timeEntry->setDate(new \DateTime());
     $timeEntry->setHours(8);
     $timeEntry->setComment('Lorem ipsum ad his scripta blandit partiendo');
     $manager->persist($timeEntry);
     $manager->flush();
     for ($i = $i; $i <= 10; $i++) {
         $task = new Task();
         $task->setTitle('Task ' . $i);
         $task->setDescription('Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.');
         $task->setPublishedAt(new \DateTime());
         $task->setProject($project);
         $task->setState($state);
         $task->setParent($parentTask);
         $manager->persist($task);
     }
     $manager->flush();
     $state = new State();
     $state->setName('Finalizado');
     $manager->persist($state);
     $project = new Project();
     $project->setName('Project 3');
     $manager->persist($project);
     $parentTask = new Task();
     $parentTask->setTitle('Parent task 3');
     $parentTask->setDescription('Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.');
     $parentTask->setPublishedAt(new \DateTime());
     $parentTask->setProject($project);
     $parentTask->setState($state);
     $timeEntry = new TimeEntry();
     $timeEntry->setTask($parentTask);
     $timeEntry->setDate(new \DateTime());
     $timeEntry->setHours(8);
     $timeEntry->setComment('Lorem ipsum ad his scripta blandit partiendo');
     $manager->persist($timeEntry);
     $manager->persist($parentTask);
     $manager->flush();
     for ($i = $i; $i <= 15; $i++) {
         $task = new Task();
         $task->setTitle('Task ' . $i);
         $task->setDescription('Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.');
         $task->setPublishedAt(new \DateTime());
         $task->setProject($project);
         $task->setState($state);
         $task->setParent($parentTask);
         $manager->persist($task);
     }
     $manager->flush();
 }
Exemplo n.º 26
0
 /**
  * @param int $listId
  * @param string $text
  * @return Task
  */
 public function addTask($listId, $text)
 {
     $task = new Task();
     $task->setText($text);
     $todoList = $this->todoListRepository->getList($listId);
     $todoList->addTask($task);
     $task->setTodoList($todoList);
     $this->objectManager->persist($task);
     $this->objectManager->persist($todoList);
     $this->objectManager->flush();
     return $task;
 }
Exemplo n.º 27
0
 /**
  * @param Task $tasks
  * @return $this
  */
 public function addTask(Task $tasks)
 {
     $tasks->addUser($this);
     $this->tasks[] = $tasks;
     return $this;
 }
Exemplo n.º 28
0
 private function canDelete(Task $task, User $user)
 {
     return $user === $task->getOwner();
 }
Exemplo n.º 29
0
 /**
  * Creates a form to delete a Task entity.
  *
  * @param Task $task The Task entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Task $task)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('task_delete', array('id' => $task->getId())))->setMethod('DELETE')->getForm();
 }
Exemplo n.º 30
0
 public function load(ObjectManager $manager)
 {
     $newTask1 = new Task();
     $newTask1->setName("Написать клиенту");
     $newTask1->setText("Написать клиенту");
     $newTask1->setStatus("Новая");
     $newTask1->setResponsible($this->getReference('Administrator1'));
     $manager->persist($newTask1);
     $newTask2 = new Task();
     $newTask2->setName("Выставить счет");
     $newTask2->setText("Выставить счет");
     $newTask2->setStatus("В работе");
     $newTask2->setResponsible($this->getReference('Administrator2'));
     $manager->persist($newTask2);
     $newTask3 = new Task();
     $newTask3->setName("Составить список задач на неделю");
     $newTask3->setText("Составить список задач на неделю");
     $newTask3->setStatus("Закрыта");
     $newTask3->setResponsible($this->getReference('Administrator1'));
     $manager->persist($newTask3);
     $newTask4 = new Task();
     $newTask4->setName("Задача 4");
     $newTask4->setText("Задача 4");
     $newTask4->setStatus("Новая");
     $newTask4->setResponsible($this->getReference('Administrator3'));
     $manager->persist($newTask4);
     $newTask5 = new Task();
     $newTask5->setName("Задача 5");
     $newTask5->setText("Задача 5");
     $newTask5->setStatus("Закрыта");
     $newTask5->setResponsible($this->getReference('Administrator1'));
     $manager->persist($newTask5);
     $newTask6 = new Task();
     $newTask6->setName("Задача 6");
     $newTask6->setText("Задача 6");
     $newTask6->setStatus("Новая");
     $newTask6->setResponsible($this->getReference('Administrator1'));
     $manager->persist($newTask6);
     $newTask7 = new Task();
     $newTask7->setName("Задача 7");
     $newTask7->setText("Задача 7");
     $newTask7->setStatus("Новая");
     $newTask7->setResponsible($this->getReference('Administrator3'));
     $manager->persist($newTask7);
     $newTask8 = new Task();
     $newTask8->setName("Задача 8");
     $newTask8->setText("Задача 8");
     $newTask8->setStatus("В работе");
     $newTask8->setResponsible($this->getReference('Administrator2'));
     $manager->persist($newTask8);
     $newTask9 = new Task();
     $newTask9->setName("Задача 9");
     $newTask9->setText("Задача 9");
     $newTask9->setStatus("Закрыта");
     $newTask9->setResponsible($this->getReference('Administrator2'));
     $manager->persist($newTask9);
     $newTask10 = new Task();
     $newTask10->setName("Задача 10");
     $newTask10->setText("Задача 10");
     $newTask10->setStatus("Новая");
     $newTask10->setResponsible($this->getReference('Administrator1'));
     $manager->persist($newTask10);
     $manager->flush();
     $this->addReference('Task1', $newTask1);
     $this->addReference('Task2', $newTask2);
     $this->addReference('Task3', $newTask3);
     $this->addReference('Task4', $newTask4);
     $this->addReference('Task5', $newTask5);
     $this->addReference('Task6', $newTask6);
     $this->addReference('Task7', $newTask7);
     $this->addReference('Task8', $newTask8);
     $this->addReference('Task9', $newTask9);
     $this->addReference('Task10', $newTask10);
 }