/** * * @param string $attribute * @param Club $club * @param UserInterface $user * @return boolean */ protected function isGranted($attribute, $club, $user = null) { switch ($attribute) { case self::VIEW: if (!$club->isPrivate()) { return true; } // make sure there is a user object (i.e. that the user is logged in) if (!$user instanceof UserInterface) { return false; } if (in_array('ROLE_ADMIN', $user->getRoles())) { return true; } break; case self::EDIT: // make sure there is a user object (i.e. that the user is logged in) if (!$user instanceof UserInterface) { return false; } foreach ($club->getAdministrators() as $administrator) { if ($administrator->getId() == $user->getId()) { return true; } } if (in_array('ROLE_ADMIN', $user->getRoles())) { return true; } return false; case self::CREATE: break; } return false; }
/** * Lists all Athlete entities. * * @Route("/", name="club_athlete") * @Method("GET") * @Template() */ public function indexAction(Club $club) { $athletes = $club->getAthletes(); return array('club' => $club, 'athletes' => $athletes); }
/** * * @Security("is_granted('VIEW', club)") * * @Route("/{slug}/logo", name="club_logo") * @Method("GET") */ public function getImageAction(Club $club) { $fileContent = base64_decode($club->getLogo()->getContent()); $f = finfo_open(); $mime_type = finfo_buffer($f, $fileContent, FILEINFO_MIME_TYPE); $response = new Response(); $response->headers->set('Content-Type', $mime_type); $response->headers->set('Expires', 0); $response->headers->set('Cache-Control', 'must-revalidate'); $response->headers->set('Pragma', 'public'); $response->headers->set('Content-length', strlen($fileContent)); $response->setContent($fileContent); return $response; }
/** * Creates a form to delete a Post entity by id. * * @param Club $club * @param Post $post * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Club $club, Post $post) { return $this->createFormBuilder()->setAction($this->generateUrl('club_post_delete', array('slug' => $club->getSlug(), 'post_slug' => $post->getSlug())))->setMethod('DELETE')->add('submit', 'submit', array('label' => 'Eliminar', 'attr' => array('class' => 'confirm', 'data-type' => 'submit_delete', 'data-text' => "¿Está usted seguro de que quiere eliminar este post?")))->getForm(); }
private function setClub() { $clubName = "PBM Bikers"; $club = $this->manager->getRepository("OesteveGrupetaBundle:Club")->findOneBy(array('name' => $clubName)); if (!$club) { $club = new Club(); $club->setName($clubName); $this->manager->persist($club); $this->manager->flush(); } return $club; }
/** * Creates a form to delete a Activity entity by club and activity * * @param Club $club * @param Activity $activity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Club $club, Activity $activity) { return $this->createFormBuilder()->setAction($this->generateUrl('club_activity_delete', array('slug' => $club->getSlug(), 'activity_slug' => $activity->getSlug())))->setMethod('DELETE')->add('submit', 'submit', array('label' => 'Eliminar', 'attr' => array('data-type' => 'submit_delete')))->getForm(); }