|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\DocumentGenerator\PdfLetters\Forms\Fields; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Trait AdminPdfLetterFieldsControllerTrait |
|
7
|
|
|
* @package ByTIC\DocumentGenerator\PdfLetters\Forms\Fields |
|
8
|
|
|
*/ |
|
9
|
|
|
trait AdminPdfLetterFieldsFormTrait |
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
protected function initGenericElements() |
|
13
|
|
|
{ |
|
14
|
|
|
$this->initPositionElements(); |
|
15
|
|
|
$this->initSizeElement(); |
|
16
|
|
|
$this->initColorElement(); |
|
17
|
|
|
$this->initAlignElement(); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
protected function initPositionElements() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->addInput('x', 'X', true); |
|
|
|
|
|
|
23
|
|
|
$this->addInput('y', 'Y', true); |
|
|
|
|
|
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
protected function initColorElement() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->addInput('color', translator()->trans('color'), false); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
protected function initSizeElement() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->addSelect('size', translator()->trans('size'), true); |
|
|
|
|
|
|
34
|
|
|
foreach (range(9, 500) as $size) { |
|
35
|
|
|
$this->size->addOption($size, $size); |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
protected function initAlignElement() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->addSelect('align', translator()->trans('align'), true); |
|
|
|
|
|
|
42
|
|
|
foreach (['left', 'center', 'right'] as $option) { |
|
43
|
|
|
$this->getElement('align')->addOption($option, translator()->trans($option)); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.