/**
  * Perform a single access check operation on a given attribute, object and (optionally) user
  * It is safe to assume that $attribute and $object's class pass supportsAttribute/supportsClass
  * $user can be one of the following:
  *   a UserInterface object (fully authenticated user)
  *   a string               (anonymously authenticated user).
  *
  * @param string               $attribute
  * @param Registration         $object
  * @param UserInterface|string $user
  *
  * @return bool
  */
 protected function isGranted($attribute, $object, $user = null)
 {
     if (!$user instanceof UserInterface) {
         return false;
     }
     return $user == $object->getUser();
 }
 /**
  * Genera una factura para la inscripción indicada.
  *
  * @param Registration $registration
  * @param $filename
  *
  * @return string
  */
 public function generateInvoiceDraft(Registration $registration, &$filename)
 {
     $filename = sprintf('factura-%s-%d-%s.pdf', $registration->getConvention()->getSlug(), $registration->getId(), $registration->getUser()->getUniversity()->getSlug());
     $html = $this->twig->render('themes/invoice/invoice_draft.html.twig', array('registration' => $registration, 'fecha' => new \DateTime('today')));
     return $this->loggableGenerator->getOutputFromHtml($html);
 }