mirror of
https://github.com/Karaka-Management/oms-Labeling.git
synced 2026-01-11 09:08:42 +00:00
fix tests
This commit is contained in:
parent
57d83ba9d9
commit
0b2aab5278
|
|
@ -11,6 +11,8 @@ $margin = 50;
|
|||
|
||||
$l = new Label();
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\Item $item */
|
||||
|
||||
// top
|
||||
$text = new Text();
|
||||
$text->text = $item->getL11n('name1')->content;
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ final class Installer extends InstallerAbstract
|
|||
{
|
||||
parent::install($app, $info, $cfgHandler);
|
||||
|
||||
/* Bill types */
|
||||
/* Label layouts */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/layouts.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var array $types */
|
||||
/** @var array $layouts */
|
||||
$layouts = \json_decode($fileContent, true);
|
||||
if ($layouts === false) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/Labeling/Theme/Backend/layout-list');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005701001, $request, $response);
|
||||
|
||||
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
|
||||
/** @var \Modules\Labeling\Models\LabelLayout[] $layouts */
|
||||
$layouts = LabelLayoutMapper::getAll()
|
||||
->with('l11n')
|
||||
->with('template')
|
||||
|
|
@ -125,15 +125,16 @@ final class BackendController extends Controller
|
|||
|
||||
$view->data['item'] = $item;
|
||||
|
||||
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
|
||||
$layouts = LabelLayoutMapper::getAll()
|
||||
/** @var \Modules\Labeling\Models\LabelLayout[] $layout */
|
||||
$layout = LabelLayoutMapper::get()
|
||||
->with('l11n')
|
||||
->with('template')
|
||||
->with('template/sources')
|
||||
->where('l11n/language', $response->header->l11n->language)
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$view->data['layouts'] = $layouts;
|
||||
$view->data['layout'] = $layout;
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Image
|
|||
|
||||
public string $src = '';
|
||||
|
||||
public $resource = null;
|
||||
public ?\GdImage $resource = null;
|
||||
|
||||
public int $color = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,18 @@ class Label
|
|||
|
||||
public array $elements = [];
|
||||
|
||||
public function render()
|
||||
public function render() : ?\GdImage
|
||||
{
|
||||
$im = \imagecreatetruecolor((int) (37.8 * $this->width), (int) (37.8 * $this->height));
|
||||
if ($im === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$bg = \imagecolorallocatealpha($im, 255, 255, 255, 0);
|
||||
if ($bg === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
\imagefill($im, 0, 0, $bg);
|
||||
|
||||
/*
|
||||
|
|
@ -79,6 +87,9 @@ class Label
|
|||
\imagettftext($im, $element->size, 0, $element->x, $element->y, $color, $element->font, $element->text);
|
||||
} elseif ($element instanceof Image) {
|
||||
$in = $element->resource === null ? \imagecreatefrompng(__DIR__ . '/../../..' . $element->src) : $element->resource;
|
||||
if ($in === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$srcW = \imagesx($in);
|
||||
$srcH = \imagesy($in);
|
||||
|
|
@ -95,6 +106,10 @@ class Label
|
|||
$newH = (int) ($srcH * $ratio);
|
||||
|
||||
$newIn = \imagecreatetruecolor($newW, $newH);
|
||||
if ($newIn === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
\imagecolortransparent($newIn, \imagecolorallocatealpha($newIn, 0, 0, 0, 127));
|
||||
\imagealphablending($newIn, false);
|
||||
\imagesavealpha($newIn, true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user