From 8654699c62700311065572e300bcd87753f7ba2a Mon Sep 17 00:00:00 2001 From: Elisha Witte Date: Thu, 20 Feb 2025 11:21:38 +0100 Subject: [PATCH] Fix localizations --- .env.example | 2 ++ src/Apple/PassFactory.php | 10 +++++----- tests/Apple/PassFactoryTest.php | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index d20e9e5..689bf97 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ PASSES_APPLE_CERT="tests/certs/certificate.p12" PASSES_APPLE_WWDR="tests/certs/wwdr.pem" PASSES_APPLE_PASSWORD= +PASSES_APPLE_TEAM_ID= +PASSES_APPLE_IDENTIFIER= diff --git a/src/Apple/PassFactory.php b/src/Apple/PassFactory.php index 15f5049..0aeb585 100644 --- a/src/Apple/PassFactory.php +++ b/src/Apple/PassFactory.php @@ -356,7 +356,7 @@ protected function createLocalizations(Pass $pass, string $dir): void file_put_contents($localizationDir.'/'.self::STRINGS_FILENAME, $strings); foreach ($localization->images as $image) { - $filename = $localizationDir.'/'.($image->getName() ?? $image->getFilename()); + $filename = $localizationDir.'/'.$this->getImageName($image).'.'.$image->getExtension(); copy($image->getPathname(), $filename); } } @@ -368,7 +368,7 @@ protected function createLocalizations(Pass $pass, string $dir): void protected function createManifest(string $dir): void { $manifest = []; - $files = new FilesystemIterator($dir); + $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)); /** @var SplFileInfo $file */ foreach ($files as $file) { @@ -451,13 +451,13 @@ protected function openssl_pkcs12_read_wrapper(string $pkcs12, string $passphras // Try an alternative route using shell_exec to allow legacy support // Try the shell_exec method with and without the -legacy flag $commands = [ - 'openssl pkcs12 -in '.escapeshellarg($this->certificate) - .' -passin '.escapeshellarg('pass:'.$passphrase) - .' -passout '.escapeshellarg('pass:'.$passphrase), 'openssl pkcs12 -in '.escapeshellarg($this->certificate) .' -passin '.escapeshellarg('pass:'.$passphrase) .' -passout '.escapeshellarg('pass:'.$passphrase) .' -legacy', + 'openssl pkcs12 -in '.escapeshellarg($this->certificate) + .' -passin '.escapeshellarg('pass:'.$passphrase) + .' -passout '.escapeshellarg('pass:'.$passphrase), ]; foreach ($commands as $command) { diff --git a/tests/Apple/PassFactoryTest.php b/tests/Apple/PassFactoryTest.php index 99d706b..028186f 100644 --- a/tests/Apple/PassFactoryTest.php +++ b/tests/Apple/PassFactoryTest.php @@ -23,9 +23,9 @@ public function test_create_pass(): void $pass = new Coupon( description: 'Example description', organizationName: 'ACME', - passTypeIdentifier: 'pass.com.acme.test', + passTypeIdentifier: getenv('PASSES_APPLE_IDENTIFIER'), serialNumber: '1890038600058', - teamIdentifier: '12345ABCD', + teamIdentifier: getenv('PASSES_APPLE_TEAM_ID'), primaryFields: [new Field(key: 'primary', value: '::value::', label: 'Coupon')], ); $pass