Ejemplo n.º 1
0
 /**
  * Factory package
  */
 public function testFactoryPackage()
 {
     if ($this->skipPackageTest) {
         $this->markTestSkipped('P12 and/or WWDR certificate(s) not found');
     }
     // Create an event ticket
     $pass = new EventTicket(time(), "The Beat Goes On");
     $pass->setBackgroundColor('rgb(60, 65, 76)');
     $pass->setLogoText('Apple Inc.');
     // Create pass structure
     $structure = new Structure();
     // Add primary field
     $primary = new Field('event', 'The Beat Goes On');
     $primary->setLabel('Event');
     $structure->addPrimaryField($primary);
     // Add secondary field
     $secondary = new Field('location', 'Moscone West');
     $secondary->setLabel('Location');
     $structure->addSecondaryField($secondary);
     // Add auxiliary field
     $auxiliary = new Field('datetime', '2013-04-15 @10:25');
     $auxiliary->setLabel('Date & Time');
     $structure->addAuxiliaryField($auxiliary);
     // Add icon image
     $icon = new Image(__DIR__ . '/../../img/icon.png', 'icon');
     $pass->addImage($icon);
     // Set pass structure
     $pass->setStructure($structure);
     // Add barcode
     $barcode = new Barcode(Barcode::TYPE_QR, 'barcodeMessage');
     $pass->setBarcode($barcode);
     $this->factory->setOutputPath(__DIR__ . '/../../../www/passes');
     $file = $this->factory->package($pass);
     $this->assertInstanceOf('SplFileObject', $file);
 }
 public function indexAction()
 {
     // Get pass factory
     $factory = $this->get('pass_factory');
     // Create an event ticket
     $ticket = new EventTicket("1234567890", "The Beat Goes On");
     $ticket->setBackgroundColor('rgb(60, 65, 76)');
     $ticket->setLogoText('Apple Inc.');
     // Create pass structure
     $structure = new Structure();
     // Add primary field
     $primary = new Field('event', 'The Beat Goes On');
     $primary->setLabel('Event');
     $structure->addPrimaryField($primary);
     // Add secondary field
     $secondary = new Field('location', 'Moscone West');
     $secondary->setLabel('Location');
     $structure->addSecondaryField($secondary);
     // Add auxiliary field
     $auxiliary = new Field('datetime', '2013-04-15 @10:25');
     $auxiliary->setLabel('Date & Time');
     $structure->addAuxiliaryField($auxiliary);
     // Set pass structure
     $ticket->setStructure($structure);
     // Add barcode
     $barcode = new Barcode('PKBarcodeFormatQR', 'barcodeMessage');
     $ticket->setBarcode($barcode);
     return $this->render('EoPassbookBundle:Demo:index.html.twig', array('pass' => $factory->package($ticket)));
 }
Ejemplo n.º 3
0
 /**
  * Event Ticket
  */
 public function testEventTicket()
 {
     $this->eventTicket->setBackgroundColor('rgb(60, 65, 76)');
     $this->assertSame('rgb(60, 65, 76)', $this->eventTicket->getBackgroundColor());
     $this->eventTicket->setLogoText('Apple Inc.');
     $this->assertSame('Apple Inc.', $this->eventTicket->getLogoText());
     // Add location
     $location = new Location(59.33792, 18.06873);
     $this->eventTicket->addLocation($location);
     // Create pass structure
     $structure = new Structure();
     // Add primary field
     $primary = new Field('event', 'The Beat Goes On');
     $primary->setLabel('Event');
     $structure->addPrimaryField($primary);
     // Add secondary field
     $secondary = new Field('location', 'Moscone West');
     $secondary->setLabel('Location');
     $structure->addSecondaryField($secondary);
     // Add auxiliary field
     $auxiliary = new Field('datetime', '2013-04-15 @10:25');
     $auxiliary->setLabel('Date & Time');
     $structure->addAuxiliaryField($auxiliary);
     // Relevant date
     $this->eventTicket->setRelevantDate(new \DateTime());
     // Set pass structure
     $this->eventTicket->setStructure($structure);
     // Add barcode
     $barcode = new Barcode('PKBarcodeFormatQR', 'barcodeMessage');
     $this->eventTicket->setBarcode($barcode);
     $json = PassFactory::serialize($this->eventTicket);
     $array = json_decode($json, true);
     $this->assertArrayHasKey('eventTicket', $array);
     $this->assertArrayHasKey('locations', $array);
     $this->assertArrayHasKey('barcode', $array);
     $this->assertArrayHasKey('logoText', $array);
     $this->assertArrayHasKey('backgroundColor', $array);
     $this->assertArrayHasKey('eventTicket', $array);
     $this->assertArrayHasKey('relevantDate', $array);
 }
Ejemplo n.º 4
0
use Passbook\Type\EventTicket;
// Create an event ticket
$pass = new EventTicket("1234567890", "The Beat Goes On");
$pass->setBackgroundColor('rgb(60, 65, 76)');
$pass->setLogoText('Apple Inc.');
// Create pass structure
$structure = new Structure();
// Add primary field
$primary = new Field('event', 'The Beat Goes On');
$primary->setLabel('Event');
$structure->addPrimaryField($primary);
// Add secondary field
$secondary = new Field('location', 'Moscone West');
$secondary->setLabel('Location');
$structure->addSecondaryField($secondary);
// Add auxiliary field
$auxiliary = new Field('datetime', '2015-08-15 @10:25');
$auxiliary->setLabel('Date & Time');
$structure->addAuxiliaryField($auxiliary);
// Add icon image
$icon = new Image('img/icon.png', 'icon');
$pass->addImage($icon);
// Set pass structure
$pass->setStructure($structure);
// Add barcode
$barcode = new Barcode(Barcode::TYPE_QR, 'barcodeMessage');
$pass->setBarcode($barcode);
// Create pass factory instance
$factory = new PassFactory('PASS-TYPE-IDENTIFIER', 'TEAM-IDENTIFIER', 'ORGANIZATION-NAME', 'cert/pass.p12', '123456', 'cert/AppleWWDRCA.pem');
$factory->setOutputPath('/tmp/testpass');
$factory->package($pass);