Exemplo n.º 1
0
 /**
  * To string
  *
  * @return string
  */
 public function __toString()
 {
     $result = 'New EventGroup';
     if (null !== $this->event && null !== $this->group) {
         $result = $this->event->getName() . ' - ' . $this->group->getName();
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * To string
  *
  * @return string
  */
 public function __toString()
 {
     $result = 'New GroupGenre';
     if (null !== $this->group && null !== $this->genre) {
         $result = $this->group->getName() . ' - ' . $this->genre->getName();
     }
     return $result;
 }
Exemplo n.º 3
0
 public function postGroupsAction(Request $request)
 {
     $entity = new Group();
     $entity->setName($request->query->get('name'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($entity);
     $em->flush();
 }
Exemplo n.º 4
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $group1 = new Group();
     $group1->setOffshoot(true);
     $group1->setName('Première Antenne');
     $group1->setDescription('Voici la description de l\'antenne 1');
     $group2 = new Group();
     $group2->setOffshoot(true);
     $group2->setName('Deuxième Antenne');
     $group2->setDescription('Voici la description de l\'antenne 2');
     $this->addReference('offshoot', $group2);
     $group3 = new Group();
     $group3->setName('Premier Groupe');
     $group3->setDescription('Voici la description du groupe 1');
     $manager->persist($group1);
     $manager->persist($group2);
     $manager->persist($group3);
     $manager->flush();
 }
Exemplo n.º 5
0
 public function createAction($format)
 {
     try {
         $em = $this->getDoctrine()->getManager();
         $group = new Group();
         $params = array();
         $content = $this->get("request")->getContent();
         if (!empty($content)) {
             $params = json_decode($content, true);
             $group->setName($params['name']);
             $group->setRoles($params['roles']);
         }
         $em->persist($group);
         $em->flush();
         return $this->formatResponse("ok", $format);
     } catch (Exception $ex) {
         return $this->formatResponse("error", $format);
     }
 }
 /**
  * Find Album group
  *
  * @param Group  $group Group
  * @param string $album Album
  *
  * @throws BadRequestHttpException
  *
  * @return []
  */
 public function findAlbumGroup($group, $album)
 {
     $response = $this->client->get($this->lastFmApiUrl, ['query' => ['method' => 'album.getinfo', 'artist' => $group->getName(), 'album' => $album, 'api_key' => $this->lastFmKey, 'format' => 'json']]);
     $data = json_decode((string) $response->getBody()->getContents(), true);
     if (array_key_exists('error', $data)) {
         throw new BadRequestHttpException('Не правильний запит');
     }
     $durationMinutes = 0;
     $album = $data['album'];
     if (!array_key_exists('wiki', $album)) {
         $album['wiki']['published'] = 'Не відомо';
     }
     foreach ($album['tracks']['track'] as $track) {
         $durationMinutes += $track['duration'];
     }
     $album['duration'] = ['hour' => round($durationMinutes / 60), 'minute' => $durationMinutes % 60];
     $album['groupSlug'] = $group->getSlug();
     return $album;
 }
Exemplo n.º 7
0
 public function addGroupAction(Request $request)
 {
     try {
         $em = $this->getDoctrine()->getManager();
         $data = json_decode($request->getContent());
         $educationForm = $em->getRepository('AppBundle:EducationForm')->find($data->educationForm);
         $group = new Group();
         $group->setCode($data->code);
         $group->setName($data->code);
         $group->setMail($data->mail);
         $group->setEducationForm($educationForm);
         $group->setStartYear($data->startYear);
         $em->persist($group);
         $em->flush();
         $response = ['success' => "Grupa a fost adaugata cu success"];
         return new JsonResponse($response);
     } catch (Exception $e) {
         $response = ['error' => "Au aparut careva probleme la adaugarea grupei. Va rugam incercati mai triziu!"];
         return new JsonResponse($response);
     }
 }
Exemplo n.º 8
0
 /**
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function createGroupAction(Request $request)
 {
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     //todo: Add some validation
     $name = $request->get('name');
     if ($name === null) {
         return new JsonResponse(['success' => 0, 'message' => 'group name is missing'], Response::HTTP_BAD_REQUEST);
     }
     $group = new Group();
     $group->setName($name);
     $entityManager->persist($group);
     $entityManager->flush();
     return new JsonResponse(['success' => 1, 'message' => 'group has been created']);
 }
Exemplo n.º 9
0
 /**
  * @return bool
  */
 public function isSuperAdministrator()
 {
     return $this->group->isSuperAdministrator();
 }
Exemplo n.º 10
0
 /**
  * Convert object AppBundle\Entity\Group to AppBundle\Form\Entity\Group
  *
  * @param Group $group Group
  *
  * @return GroupForm[]
  */
 public function convertToGroupForm(Group $group)
 {
     return (new GroupForm())->setName($group->getName())->setDescription($group->getDescription())->setCountry($group->getCountry())->setCity($group->getCity())->setFoundedAt($group->getFoundedAt()->format('Y'));
 }
Exemplo n.º 11
0
 /**
  * @param Group              $group
  * @param AuthorizationGroup $authorizationGroup
  */
 public function saveAuthorizationGroup(Group $group, AuthorizationGroup $authorizationGroup)
 {
     $authorizations = $group->getAuthorizations();
     foreach ($authorizationGroup->getAuthorizations() as $authorizationGranted) {
         $authorization = $authorizationGranted->getAuthorization();
         if ($authorizationGranted->isGranted() && !$authorizations->contains($authorization)) {
             $authorizations->add($authorization);
             continue;
         }
         if (!$authorizationGranted->isGranted() && $authorizations->contains($authorization)) {
             $authorizations->removeElement($authorization);
         }
     }
     $this->manager->flush();
 }
Exemplo n.º 12
0
 /**
  * Creates a form to delete a Group entity.
  *
  * @param Group $group The Group entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Group $group)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('group_delete', array('id' => $group->getId())))->setMethod('DELETE')->getForm();
 }
Exemplo n.º 13
0
 /**
  * Test __toString method
  */
 public function testToString()
 {
     $group = new Group();
     $this->assertEquals('New Group', $group->__toString());
 }
 /**
  * @param Group $group
  *
  * @return bool
  */
 private function isGroupEditable(Group $group)
 {
     return $this->isGranted('ROLE_AUTH_GRPS_AUTHZ_EDIT') && !$group->isSuperAdministrator();
 }
Exemplo n.º 15
0
 /**
  * @param Group $group
  *
  * @return bool
  */
 private function isGroupActivate(Group $group)
 {
     return $this->isGranted('ROLE_AUTH_GRPS_ACTIV') && !$group->isSuperAdministrator();
 }