fix tests

This commit is contained in:
Dennis Eichhorn 2023-09-22 23:25:21 +00:00
parent 57d83ba9d9
commit 0b2aab5278
5 changed files with 26 additions and 8 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -28,7 +28,7 @@ class Image
public string $src = '';
public $resource = null;
public ?\GdImage $resource = null;
public int $color = 0;
}

View File

@ -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);