Skip to content

Commit

Permalink
Make XMP Meta Data filename configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Jan 27, 2024
1 parent 3ad4e75 commit c5b44c8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/OrderDocumentPdfBuilderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use horstoeko\orderx\codelists\OrderDocumentTypes;
use horstoeko\orderx\OrderPackageVersion;
use horstoeko\orderx\OrderPdfWriter;
use horstoeko\stringmanagement\PathUtils;
use setasign\Fpdi\PdfParser\StreamReader as PdfStreamReader;

/**
Expand Down Expand Up @@ -178,7 +177,7 @@ private function updatePdfMetadata(): void
$pdfMetadataInfos = $this->preparePdfMetadata();
$this->pdfWriter->setPdfMetadataInfos($pdfMetadataInfos);

$xmp = simplexml_load_file(PathUtils::combinePathWithFile(OrderSettings::getAssetDirectory(), 'orderx_extension_schema.xmp'));
$xmp = simplexml_load_file(OrderSettings::getFullXmpMetaDataFilename());

$descNodes = $xmp->xpath('rdf:Description');
$descNode = $descNodes[0];
Expand Down
72 changes: 55 additions & 17 deletions src/OrderSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,21 @@ class OrderSettings
*/
protected static $iccProfileFilename = "sRGB_v4_ICC.icc";

/**
* The filename of the XMP meta data
*
* @var string
*/
protected static $xmpMetaDataFilename = "orderx_extension_schema.xmp";

/**
* Get the number of decimals to use for amount values
*
* @return integer
*/
public static function getAmountDecimals(): int
{
return self::$amountDecimals;
return static::$amountDecimals;
}

/**
Expand All @@ -82,7 +89,7 @@ public static function getAmountDecimals(): int
*/
public static function setAmountDecimals(int $amountDecimals): void
{
self::$amountDecimals = $amountDecimals;
static::$amountDecimals = $amountDecimals;
}

/**
Expand All @@ -92,7 +99,7 @@ public static function setAmountDecimals(int $amountDecimals): void
*/
public static function getQuantityDecimals(): int
{
return self::$quantityDecimals;
return static::$quantityDecimals;
}

/**
Expand All @@ -103,7 +110,7 @@ public static function getQuantityDecimals(): int
*/
public static function setQuantityDecimals(int $quantityDecimals): void
{
self::$quantityDecimals = $quantityDecimals;
static::$quantityDecimals = $quantityDecimals;
}

/**
Expand All @@ -113,7 +120,7 @@ public static function setQuantityDecimals(int $quantityDecimals): void
*/
public static function getPercentDecimals(): int
{
return self::$percentDecimals;
return static::$percentDecimals;
}

/**
Expand All @@ -124,7 +131,7 @@ public static function getPercentDecimals(): int
*/
public static function setPercentDecimals(int $percentDecimals): void
{
self::$percentDecimals = $percentDecimals;
static::$percentDecimals = $percentDecimals;
}

/**
Expand All @@ -134,7 +141,7 @@ public static function setPercentDecimals(int $percentDecimals): void
*/
public static function getDecimalSeparator(): string
{
return self::$decimalSeparator;
return static::$decimalSeparator;
}

/**
Expand All @@ -145,7 +152,7 @@ public static function getDecimalSeparator(): string
*/
public static function setDecimalSeparator(string $decimalSeparator): void
{
self::$decimalSeparator = $decimalSeparator;
static::$decimalSeparator = $decimalSeparator;
}

/**
Expand All @@ -155,7 +162,7 @@ public static function setDecimalSeparator(string $decimalSeparator): void
*/
public static function getThousandsSeparator(): string
{
return self::$thousandsSeparator;
return static::$thousandsSeparator;
}

/**
Expand All @@ -166,7 +173,7 @@ public static function getThousandsSeparator(): string
*/
public static function setThousandsSeparator(string $thousandsSeparator): void
{
self::$thousandsSeparator = $thousandsSeparator;
static::$thousandsSeparator = $thousandsSeparator;
}

/**
Expand All @@ -176,7 +183,7 @@ public static function setThousandsSeparator(string $thousandsSeparator): void
*/
public static function getIccProfileFilename(): string
{
return self::$iccProfileFilename;
return static::$iccProfileFilename;
}

/**
Expand All @@ -187,7 +194,28 @@ public static function getIccProfileFilename(): string
*/
public static function setIccProfileFilename(string $iccProfileFilename): void
{
self::$iccProfileFilename = $iccProfileFilename;
static::$iccProfileFilename = $iccProfileFilename;
}

/**
* Get the filename for the XMP meta data
*
* @return string
*/
public static function getXmpMetaDataFilename(): string
{
return static::$xmpMetaDataFilename;
}

/**
* Set the filename for the XMP meta data
*
* @param string $xmpMetaDataFilename
* @return void
*/
public static function setXmpMetaDataFilename(string $xmpMetaDataFilename): void
{
static::$xmpMetaDataFilename = $xmpMetaDataFilename;
}

/**
Expand All @@ -207,7 +235,7 @@ public static function getRootDirectory(): string
*/
public static function getSourceDirectory(): string
{
return PathUtils::combineAllPaths(self::getRootDirectory(), "src");
return PathUtils::combineAllPaths(static::getRootDirectory(), "src");
}

/**
Expand All @@ -217,7 +245,7 @@ public static function getSourceDirectory(): string
*/
public static function getAssetDirectory(): string
{
return PathUtils::combineAllPaths(self::getSourceDirectory(), "assets");
return PathUtils::combineAllPaths(static::getSourceDirectory(), "assets");
}

/**
Expand All @@ -227,7 +255,7 @@ public static function getAssetDirectory(): string
*/
public static function getYamlDirectory(): string
{
return PathUtils::combineAllPaths(self::getSourceDirectory(), "yaml");
return PathUtils::combineAllPaths(static::getSourceDirectory(), "yaml");
}

/**
Expand All @@ -237,7 +265,7 @@ public static function getYamlDirectory(): string
*/
public static function getValidationDirectory(): string
{
return PathUtils::combineAllPaths(self::getSourceDirectory(), "validation");
return PathUtils::combineAllPaths(static::getSourceDirectory(), "validation");
}

/**
Expand All @@ -247,6 +275,16 @@ public static function getValidationDirectory(): string
*/
public static function getFullIccProfileFilename(): string
{
return PathUtils::combinePathWithFile(self::getAssetDirectory(), self::$iccProfileFilename);
return PathUtils::combinePathWithFile(static::getAssetDirectory(), static::$iccProfileFilename);
}

/**
* Get the full filename containg the XNP information to user
*
* @return string
*/
public static function getFullXmpMetaDataFilename(): string
{
return PathUtils::combinePathWithFile(static::getAssetDirectory(), static::$xmpMetaDataFilename);
}
}

0 comments on commit c5b44c8

Please sign in to comment.