Endroid\QrCode\QrCode::get PHP Method

get() public method

Create QR Code and return its content.
public get ( string | null $format = null ) : string
$format string | null Image type (gif, png, wbmp, jpeg)
return string
    public function get($format = null)
    {
        $this->create();
        if ($format == 'jpg') {
            $format = 'jpeg';
        }
        if (!in_array($format, $this->image_types_available)) {
            $format = $this->image_type;
        }
        if (!function_exists('image' . $format)) {
            throw new ImageFunctionUnknownException('QRCode: function image' . $format . ' does not exists.');
        }
        ob_start();
        $success = call_user_func('image' . $format, $this->image);
        if ($success === false) {
            throw new ImageFunctionFailedException('QRCode: function image' . $format . ' failed.');
        }
        $content = ob_get_clean();
        return $content;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Create HTML template for ticket invitation
  *
  * @param Ticket $ticket
  *
  * @return string
  */
 public function generateHTML(Ticket $ticket)
 {
     $twig = $this->templating;
     $url = $this->router->generate('event_ticket_check', array('ticket' => $ticket->getId(), 'hash' => $ticket->getHash()), true);
     $this->qrCode->setText($url);
     $this->qrCode->setSize(105);
     $this->qrCode->setPadding(0);
     $qrCodeBase64 = base64_encode($this->qrCode->get());
     $templateContent = $twig->loadTemplate('StfalconEventBundle:Ticket:show_pdf.html.twig');
     $body = $templateContent->render(array('ticket' => $ticket, 'qrCodeBase64' => $qrCodeBase64, 'path' => realpath($this->kernel->getRootDir() . '/../web') . '/'));
     return $body;
 }
All Usage Examples Of Endroid\QrCode\QrCode::get