for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace AppBundle\Controller\Api;
use AppBundle\Entity\DTO\DtoEvent;
use AppBundle\Entity\Event;
use AppBundle\Exception\JsonHttpException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class CalendarController extends Controller
{
/**
* @Route("/events")
* @Method({"GET"})
*/
public function userEventsAction()
$user = $this->getUser();
$events = $user->getEvents();
$calendar = $this->get('app.google_calendar');
$googleEvents = [];
foreach ($events as $event) {
$googleEvents[] = $calendar
->getEventById($event->getGoogleId());
}
$events = [];
foreach ($googleEvents as $event) {
if ($event) {
$events[] = new DtoEvent($event);
return new JsonResponse(['events' => $events]);
* @Route("/events/{id}")
* @Method("GET")
public function singleEventAction($id)
/** @var Event $event */
$event = $this->getDoctrine()->getRepository('AppBundle:Event')
->findByGoogleId($id);
$user = $event->getUsers()->first();
first
$event->getUsers()
array
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.
if (!$user) {
throw new JsonHttpException(404, 'User not found.');
$googleEvent = $this->get('app.google_calendar')
->getEventById($id);
$event = new DtoEvent($googleEvent);
return new JsonResponse(['event' => $event]);
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.