diff --git a/composer.json b/composer.json index 446683ee..52e3969c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ "beberlei/doctrineextensions": "^1.2", "doctrine/annotations": "^1.6", "doctrine/doctrine-bundle": "^2.0", - "dunglas/doctrine-json-odm": "^1.0", "florianv/swap": "^4.0", "friendsofsymfony/ckeditor-bundle": "^2.0", "gregwar/captcha-bundle": "^2.1.0", diff --git a/composer.lock b/composer.lock index 7bb38835..69eb1e26 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ec3095adecf24f5680e7c904c5f0731f", + "content-hash": "6ebc8e9705e901be6f00f9f6418cf900", "packages": [ { "name": "beberlei/assert", @@ -1265,72 +1265,6 @@ ], "time": "2020-01-08T19:53:19+00:00" }, - { - "name": "dunglas/doctrine-json-odm", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/dunglas/doctrine-json-odm.git", - "reference": "70afdc23e68a31c7cbf8417f2dbb285ec929e14e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dunglas/doctrine-json-odm/zipball/70afdc23e68a31c7cbf8417f2dbb285ec929e14e", - "reference": "70afdc23e68a31c7cbf8417f2dbb285ec929e14e", - "shasum": "" - }, - "require": { - "doctrine/orm": "^2.6.3", - "php": "^7.1", - "symfony/property-access": "^3.4 || ^4.1 || ^5.0", - "symfony/property-info": "^3.4 || ^4.1 || ^5.0", - "symfony/serializer": "^3.4 || ^4.1 || ^5.0" - }, - "require-dev": { - "doctrine/doctrine-bundle": "^1.8", - "symfony/finder": "^3.4 || ^4.1 || ^5.0", - "symfony/framework-bundle": "^3.4 || ^4.1 || ^5.0", - "symfony/phpunit-bridge": "^5.0" - }, - "suggest": { - "scienta/doctrine-json-functions": "To add support for JSON functions in DQL.", - "symfony/framework-bundle": "To use the provided bundle." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Dunglas\\DoctrineJsonOdm\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kévin Dunglas", - "email": "dunglas@gmail.com", - "homepage": "https://dunglas.fr" - } - ], - "description": "An object document mapper for Doctrine ORM using JSON types of modern RDBMS.", - "homepage": "https://dunglas.fr", - "keywords": [ - "database", - "json", - "mysql", - "odm", - "orm", - "postgresql", - "rdbms" - ], - "time": "2019-12-23T09:48:22+00:00" - }, { "name": "egulias/email-validator", "version": "2.1.17", @@ -3723,16 +3657,16 @@ }, { "name": "s9e/text-formatter", - "version": "2.3.6", + "version": "2.3.7", "source": { "type": "git", "url": "https://github.com/s9e/TextFormatter.git", - "reference": "b96dc121d2dfaabe7e3df42e76d93ffb857cf377" + "reference": "39088b779b71e120098a7a8a8f7dc4900cb8b671" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/b96dc121d2dfaabe7e3df42e76d93ffb857cf377", - "reference": "b96dc121d2dfaabe7e3df42e76d93ffb857cf377", + "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/39088b779b71e120098a7a8a8f7dc4900cb8b671", + "reference": "39088b779b71e120098a7a8a8f7dc4900cb8b671", "shasum": "" }, "require": { @@ -3758,7 +3692,7 @@ }, "type": "library", "extra": { - "version": "2.3.6" + "version": "2.3.7" }, "autoload": { "psr-4": { @@ -3788,7 +3722,7 @@ "parser", "shortcodes" ], - "time": "2020-02-24T18:19:59+00:00" + "time": "2020-03-10T23:47:09+00:00" }, { "name": "scheb/two-factor-bundle", @@ -9310,20 +9244,20 @@ }, { "name": "felixfbecker/advanced-json-rpc", - "version": "v3.1.0", + "version": "v3.1.1", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "a407a6cb0325cd489c6dff57afcba6baeccc0483" + "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/a407a6cb0325cd489c6dff57afcba6baeccc0483", - "reference": "a407a6cb0325cd489c6dff57afcba6baeccc0483", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/0ed363f8de17d284d479ec813c9ad3f6834b5c40", + "reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40", "shasum": "" }, "require": { - "netresearch/jsonmapper": "^1.0", + "netresearch/jsonmapper": "^1.0 || ^2.0", "php": ">=7.0", "phpdocumentor/reflection-docblock": "^4.0.0 || ^5.0.0" }, @@ -9347,7 +9281,7 @@ } ], "description": "A more advanced JSONRPC implementation", - "time": "2020-02-11T20:48:40+00:00" + "time": "2020-03-11T15:21:41+00:00" }, { "name": "felixfbecker/language-server-protocol", @@ -11642,16 +11576,16 @@ }, { "name": "vimeo/psalm", - "version": "3.9.4", + "version": "3.9.5", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "352bd3f5c5789db04e4010856c2f4e01ed354f4e" + "reference": "0cfe565d0afbcd31eadcc281b9017b5692911661" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/352bd3f5c5789db04e4010856c2f4e01ed354f4e", - "reference": "352bd3f5c5789db04e4010856c2f4e01ed354f4e", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/0cfe565d0afbcd31eadcc281b9017b5692911661", + "reference": "0cfe565d0afbcd31eadcc281b9017b5692911661", "shasum": "" }, "require": { @@ -11734,7 +11668,7 @@ "inspection", "php" ], - "time": "2020-03-06T20:23:11+00:00" + "time": "2020-03-09T22:59:56+00:00" }, { "name": "webmozart/glob", diff --git a/config/bundles.php b/config/bundles.php index 18ed373d..6b24f5c2 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -23,5 +23,4 @@ return [ Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true], R\U2FTwoFactorBundle\RU2FTwoFactorBundle::class => ['all' => true], Translation\Bundle\TranslationBundle::class => ['all' => true], - \Dunglas\DoctrineJsonOdm\Bundle\DunglasDoctrineJsonOdmBundle::class => ['all' => true], ]; diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 865651a1..78f8ae5e 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -23,10 +23,13 @@ declare(strict_types=1); namespace App\Entity\Attachments; use App\Entity\Base\AbstractStructuralDBElement; +use App\Entity\Parameters\AttachmentTypeParameter; +use App\Entity\Parameters\DeviceParameter; use App\Validator\Constraints\ValidFileFilter; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Class AttachmentType. @@ -56,9 +59,16 @@ class AttachmentType extends AbstractStructuralDBElement /** * @var Collection|AttachmentTypeAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\AttachmentTypeAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; + /** @var AttachmentTypeParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\AttachmentTypeParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * @var Collection|Attachment[] * @ORM\OneToMany(targetEntity="Attachment", mappedBy="attachment_type") diff --git a/src/Entity/Base/AbstractStructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php index 4611f193..2c261172 100644 --- a/src/Entity/Base/AbstractStructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Entity\Base; use App\Entity\Attachments\AttachmentContainingDBElement; +use App\Entity\Parameters\ParametersTrait; use App\Validator\Constraints\NoneOfItsChildren; use function count; use Doctrine\Common\Collections\ArrayCollection; @@ -50,7 +51,7 @@ use Symfony\Component\Serializer\Annotation\Groups; */ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement { - use SpecificationsTrait; + use ParametersTrait; public const ID_ROOT_ELEMENT = 0; @@ -103,6 +104,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement { parent::__construct(); $this->children = new ArrayCollection(); + $this->parameters = new ArrayCollection(); } /****************************************************************************** diff --git a/src/Entity/Devices/Device.php b/src/Entity/Devices/Device.php index 5dfdc199..be1dd031 100644 --- a/src/Entity/Devices/Device.php +++ b/src/Entity/Devices/Device.php @@ -52,6 +52,7 @@ namespace App\Entity\Devices; use App\Entity\Attachments\DeviceAttachment; use App\Entity\Base\AbstractPartsContainingDBElement; +use App\Entity\Parameters\DeviceParameter; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use InvalidArgumentException; @@ -97,6 +98,11 @@ class Device extends AbstractPartsContainingDBElement */ protected $attachments; + /** @var DeviceParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\DeviceParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + */ + protected $parameters; + /******************************************************************************** * * Getters diff --git a/src/Entity/LogSystem/AbstractLogEntry.php b/src/Entity/LogSystem/AbstractLogEntry.php index 79d9b3aa..346ca7e7 100644 --- a/src/Entity/LogSystem/AbstractLogEntry.php +++ b/src/Entity/LogSystem/AbstractLogEntry.php @@ -47,6 +47,7 @@ use App\Entity\Attachments\AttachmentType; use App\Entity\Base\AbstractDBElement; use App\Entity\Devices\Device; use App\Entity\Devices\DevicePart; +use App\Entity\Parameters\AbstractParameter; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; use App\Entity\Parts\Manufacturer; @@ -114,6 +115,7 @@ abstract class AbstractLogEntry extends AbstractDBElement protected const TARGET_TYPE_ORDERDETAIL = 15; protected const TARGET_TYPE_PRICEDETAIL = 16; protected const TARGET_TYPE_MEASUREMENTUNIT = 17; + protected const TARGET_TYPE_PARAMETER = 18; /** @var array This const is used to convert the numeric level to a PSR-3 compatible log level */ protected const LEVEL_ID_TO_STRING = [ @@ -145,6 +147,7 @@ abstract class AbstractLogEntry extends AbstractDBElement self::TARGET_TYPE_ORDERDETAIL => Orderdetail::class, self::TARGET_TYPE_PRICEDETAIL => Pricedetail::class, self::TARGET_TYPE_MEASUREMENTUNIT => MeasurementUnit::class, + self::TARGET_TYPE_PARAMETER => AbstractParameter::class ]; /** @var User The user which has caused this log entry diff --git a/src/Entity/Specifications/Specification.php b/src/Entity/Parameters/AbstractParameter.php similarity index 60% rename from src/Entity/Specifications/Specification.php rename to src/Entity/Parameters/AbstractParameter.php index 954a837e..9c12521d 100644 --- a/src/Entity/Specifications/Specification.php +++ b/src/Entity/Parameters/AbstractParameter.php @@ -18,13 +18,42 @@ * along with this program. If not, see . */ -namespace App\Entity\Specifications; - +namespace App\Entity\Parameters; +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractNamedDBElement; +use App\Repository\DBElementRepository; +use Doctrine\ORM\Mapping as ORM; +use InvalidArgumentException; +use LogicException; use Symfony\Component\Validator\Constraints as Assert; -class Specification +/** + * @ORM\Entity() + * @ORM\Table("parameters") + * @ORM\InheritanceType("SINGLE_TABLE") + * @ORM\DiscriminatorColumn(name="type", type="smallint") + * @ORM\DiscriminatorMap({ + * 0 = "CategoryParameter", + * 1 = "CurrencyParameter", + * 2 = "DeviceParameter", + * 3 = "FootprintParameter", + * 4 = "GroupParameter", + * 5 = "ManufacturerParameter", + * 6 = "MeasurementUnitParameter", + * 7 = "PartParameter", + * 8 = "StorelocationParameter", + * 9 = "SupplierParameter", + * 10 = "AttachmentTypeParameter" + * }) + */ +abstract class AbstractParameter extends AbstractNamedDBElement { + /** + * @var string The class of the element that can be passed to this attachment. Must be overridden in subclasses. + */ + public const ALLOWED_ELEMENT_CLASS = ''; + /** * @var string The name of the specification (e.g. "Collector-Base Voltage"). Required! * @Assert\NotBlank() @@ -34,6 +63,7 @@ class Specification /** * @var string The mathematical symbol for this specification. Can be rendered pretty later. Should be short * @Assert\Length(max=10) + * @ORM\Column(type="string", nullable=false) */ protected $symbol = ""; @@ -42,12 +72,14 @@ class Specification * @Assert\Type({"float","null"}) * @Assert\LessThanOrEqual(propertyPath="value_typical") * @Assert\LessThan(propertyPath="value_max") + * @ORM\Column(type="float", nullable=true) */ protected $value_min; /** * @var float|null The typical value of this property. * @Assert\Type({"null", "float"}) + * @ORM\Column(type="float", nullable=true) */ protected $value_typical; @@ -55,21 +87,42 @@ class Specification * @var float|null The maximum value of this property. * @Assert\Type({"float", "null"}) * @Assert\GreaterThanOrEqual(propertyPath="value_typical") + * @ORM\Column(type="float", nullable=true) */ protected $value_max; /** * @var string The unit in which the value values are given (e.g. V) * @Assert\Length(max=5) + * @ORM\Column(type="string", nullable=false) */ protected $unit = ""; /** * @var string A text value for the given property. - * + * @ORM\Column(type="string", nullable=false) */ protected $value_text = ""; + /** + * @var string The group this parameter belongs to. + * @ORM\Column(type="string", nullable=false, name="param_group") + */ + protected $group = ""; + + /** + * Mapping is done in sub classes + * @var AbstractDBElement|null The element to which this parameter belongs to. + */ + protected $element; + + public function __construct() + { + if ('' === static::ALLOWED_ELEMENT_CLASS) { + throw new LogicException('An *Attachment class must override the ALLOWED_ELEMENT_CLASS const!'); + } + } + /** * Returns the name of the specification (e.g. "Collector-Base Voltage"). * @return string @@ -79,12 +132,36 @@ class Specification return $this->name; } + /** + * Returns the element this parameter belongs to. + * @return AbstractDBElement|null + */ + public function getElement(): ?AbstractDBElement + { + return $this->element; + } + + /** + * Sets the element to which this parameter belongs to. + * @param AbstractDBElement $element + * @return $this + */ + public function setElement(AbstractDBElement $element): self + { + if (! is_a($element, static::ALLOWED_ELEMENT_CLASS)) { + throw new InvalidArgumentException(sprintf('The element associated with a %s must be a %s!', static::class, static::ALLOWED_ELEMENT_CLASS)); + } + + $this->element = $element; + return $this; + } + /** * Sets the name of the specification. This value is required. * @param string $name * @return $this */ - public function setName(string $name): Specification + public function setName(string $name): AbstractNamedDBElement { $this->name = $name; return $this; @@ -104,7 +181,7 @@ class Specification * @param string $symbol * @return $this */ - public function setSymbol(string $symbol): Specification + public function setSymbol(string $symbol): self { $this->symbol = $symbol; return $this; @@ -124,7 +201,7 @@ class Specification * @param float|null $value_min * @return $this */ - public function setValueMin(?float $value_min): Specification + public function setValueMin(?float $value_min): self { $this->value_min = $value_min; return $this; @@ -144,7 +221,7 @@ class Specification * @param float $value_typical * @return $this */ - public function setValueTypical(?float $value_typical): Specification + public function setValueTypical(?float $value_typical): self { $this->value_typical = $value_typical; return $this; @@ -164,7 +241,7 @@ class Specification * @param float|null $value_max * @return $this */ - public function setValueMax(?float $value_max): Specification + public function setValueMax(?float $value_max): self { $this->value_max = $value_max; return $this; @@ -184,7 +261,7 @@ class Specification * @param string $unit * @return $this */ - public function setUnit(string $unit): Specification + public function setUnit(string $unit): self { $this->unit = $unit; return $this; @@ -204,11 +281,14 @@ class Specification * @param string $value_text * @return $this */ - public function setValueText(string $value_text): Specification + public function setValueText(string $value_text): self { $this->value_text = $value_text; return $this; } - + public function getIDString(): string + { + return 'PM'.sprintf('%09d', $this->getID()); + } } \ No newline at end of file diff --git a/src/Entity/Parameters/AttachmentTypeParameter.php b/src/Entity/Parameters/AttachmentTypeParameter.php new file mode 100644 index 00000000..ab0e1811 --- /dev/null +++ b/src/Entity/Parameters/AttachmentTypeParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + + +use App\Entity\Attachments\AttachmentType; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class AttachmentTypeParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = AttachmentType::class; + /** + * @var AttachmentType the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/CategoryParameter.php b/src/Entity/Parameters/CategoryParameter.php new file mode 100644 index 00000000..698912fb --- /dev/null +++ b/src/Entity/Parameters/CategoryParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + + +use App\Entity\Parts\Category; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class CategoryParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Category::class; + /** + * @var Category the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/CurrencyParameter.php b/src/Entity/Parameters/CurrencyParameter.php new file mode 100644 index 00000000..9c20a60a --- /dev/null +++ b/src/Entity/Parameters/CurrencyParameter.php @@ -0,0 +1,41 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\PriceInformations\Currency; +use Doctrine\ORM\Mapping as ORM; + +/** + * A attachment attached to a category element. + * + * @ORM\Entity() + */ +class CurrencyParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Currency::class; + + /** + * @var Currency the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/DeviceParameter.php b/src/Entity/Parameters/DeviceParameter.php new file mode 100644 index 00000000..7438d41a --- /dev/null +++ b/src/Entity/Parameters/DeviceParameter.php @@ -0,0 +1,41 @@ +. + */ + +namespace App\Entity\Parameters; + + +use App\Entity\Devices\Device; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class DeviceParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Device::class; + + /** + * @var Device the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Devices\Device", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/FootprintParameter.php b/src/Entity/Parameters/FootprintParameter.php new file mode 100644 index 00000000..baca6e0a --- /dev/null +++ b/src/Entity/Parameters/FootprintParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\Parts\Footprint; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class FootprintParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Footprint::class; + + /** + * @var Footprint the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/GroupParameter.php b/src/Entity/Parameters/GroupParameter.php new file mode 100644 index 00000000..facaf367 --- /dev/null +++ b/src/Entity/Parameters/GroupParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\UserSystem\Group; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class GroupParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Group::class; + + /** + * @var Group the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/ManufacturerParameter.php b/src/Entity/Parameters/ManufacturerParameter.php new file mode 100644 index 00000000..91375fe0 --- /dev/null +++ b/src/Entity/Parameters/ManufacturerParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\Parts\Manufacturer; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class ManufacturerParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Manufacturer::class; + + /** + * @var Manufacturer the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/MeasurementUnitParameter.php b/src/Entity/Parameters/MeasurementUnitParameter.php new file mode 100644 index 00000000..5d64d4d0 --- /dev/null +++ b/src/Entity/Parameters/MeasurementUnitParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\Parts\MeasurementUnit; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class MeasurementUnitParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class; + + /** + * @var MeasurementUnit the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Base/SpecificationsTrait.php b/src/Entity/Parameters/ParametersTrait.php similarity index 58% rename from src/Entity/Base/SpecificationsTrait.php rename to src/Entity/Parameters/ParametersTrait.php index 278061b5..f69e9ab9 100644 --- a/src/Entity/Base/SpecificationsTrait.php +++ b/src/Entity/Parameters/ParametersTrait.php @@ -18,37 +18,46 @@ * along with this program. If not, see . */ -namespace App\Entity\Base; +namespace App\Entity\Parameters; -use App\Entity\Specifications\Specification; +use App\Entity\Parameters\AbstractParameter; +use Doctrine\Common\Collections\Collection; use Symfony\Component\Validator\Constraints as Assert; -trait SpecificationsTrait +trait ParametersTrait { /** - * @var Specification[] - * @ORM\Column(type="json_document") + * Mapping done in subclasses + * @var AbstractParameter[]|Collection * @Assert\Valid() */ - protected $specifications = []; + protected $parameters; /** * Return all associated specifications - * @return Specification[] + * @return AbstractParameter[]|Collection */ - public function getSpecifications(): array + public function getParameters(): Collection { - return $this->specifications ?? []; + return $this->parameters; } /** - * @param array $specifications + * Add a new parameter information. + * @param AbstractParameter $parameter * @return $this */ - public function setSpecifications(array $specifications): self + public function addParameter(AbstractParameter $parameter): self { - $this->specifications = $specifications; + $parameter->setElement($this); + $this->parameters->add($parameter); + return $this; + } + + public function removeParameter(AbstractParameter $parameter): self + { + $this->parameters->removeElement($parameter); return $this; } } \ No newline at end of file diff --git a/src/Entity/Parameters/PartParameter.php b/src/Entity/Parameters/PartParameter.php new file mode 100644 index 00000000..025fdae3 --- /dev/null +++ b/src/Entity/Parameters/PartParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\Parts\Part; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class PartParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Part::class; + + /** + * @var Part the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/StorelocationParameter.php b/src/Entity/Parameters/StorelocationParameter.php new file mode 100644 index 00000000..7442f1e9 --- /dev/null +++ b/src/Entity/Parameters/StorelocationParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\Parts\Storelocation; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class StorelocationParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Storelocation::class; + + /** + * @var Storelocation the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parameters/SupplierParameter.php b/src/Entity/Parameters/SupplierParameter.php new file mode 100644 index 00000000..7bd28cd0 --- /dev/null +++ b/src/Entity/Parameters/SupplierParameter.php @@ -0,0 +1,40 @@ +. + */ + +namespace App\Entity\Parameters; + +use App\Entity\Parts\Supplier; +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Entity() + * @package App\Entity\Parameters + */ +class SupplierParameter extends AbstractParameter +{ + public const ALLOWED_ELEMENT_CLASS = Supplier::class; + + /** + * @var Supplier the element this para is associated with + * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="parameters") + * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). + */ + protected $element; +} \ No newline at end of file diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index a5c98475..a4f9d327 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -24,8 +24,11 @@ namespace App\Entity\Parts; use App\Entity\Attachments\CategoryAttachment; use App\Entity\Base\AbstractPartsContainingDBElement; +use App\Entity\Parameters\CategoryParameter; +use App\Entity\Parameters\DeviceParameter; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Class AttachmentType. @@ -101,9 +104,16 @@ class Category extends AbstractPartsContainingDBElement /** * @var Collection|CategoryAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; + /** @var CategoryParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * Returns the ID as an string, defined by the element class. * This should have a form like P000014, for a part with ID 14. diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 8fb7b9bb..a9f382b3 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -52,8 +52,11 @@ namespace App\Entity\Parts; use App\Entity\Attachments\FootprintAttachment; use App\Entity\Base\AbstractPartsContainingDBElement; +use App\Entity\Parameters\DeviceParameter; +use App\Entity\Parameters\FootprintParameter; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Class Footprint. @@ -81,6 +84,7 @@ class Footprint extends AbstractPartsContainingDBElement /** * @var Collection|FootprintAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; @@ -91,6 +95,12 @@ class Footprint extends AbstractPartsContainingDBElement */ protected $footprint_3d; + /** @var FootprintParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\FootprintParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * Returns the ID as an string, defined by the element class. * This should have a form like P000014, for a part with ID 14. diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index 113e0a03..297a0cf9 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -52,8 +52,11 @@ namespace App\Entity\Parts; use App\Entity\Attachments\ManufacturerAttachment; use App\Entity\Base\AbstractCompany; +use App\Entity\Parameters\DeviceParameter; +use App\Entity\Parameters\ManufacturerParameter; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Class Manufacturer. @@ -81,9 +84,16 @@ class Manufacturer extends AbstractCompany /** * @var Collection|ManufacturerAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; + /** @var ManufacturerParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\ManufacturerParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * Returns the ID as an string, defined by the element class. * This should have a form like P000014, for a part with ID 14. diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 0a5213aa..c06e8542 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -44,6 +44,8 @@ namespace App\Entity\Parts; use App\Entity\Attachments\MeasurementUnitAttachment; use App\Entity\Base\AbstractPartsContainingDBElement; +use App\Entity\Parameters\DeviceParameter; +use App\Entity\Parameters\MeasurementUnitParameter; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; @@ -99,9 +101,16 @@ class MeasurementUnit extends AbstractPartsContainingDBElement /** * @var Collection|MeasurementUnitAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; + /** @var MeasurementUnitParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\MeasurementUnitParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * Returns the ID as an string, defined by the element class. * This should have a form like P000014, for a part with ID 14. diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 12e295c7..35a53950 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -52,8 +52,10 @@ namespace App\Entity\Parts; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentContainingDBElement; -use App\Entity\Base\SpecificationsTrait; +use App\Entity\Parameters\ParametersTrait; use App\Entity\Devices\Device; +use App\Entity\Parameters\DeviceParameter; +use App\Entity\Parameters\PartParameter; use App\Entity\Parts\PartTraits\AdvancedPropertyTrait; use App\Entity\Parts\PartTraits\BasicPropertyTrait; use App\Entity\Parts\PartTraits\InstockTrait; @@ -82,13 +84,19 @@ class Part extends AttachmentContainingDBElement use InstockTrait; use ManufacturerTrait; use OrderTrait; - use SpecificationsTrait; + use ParametersTrait; /** * TODO. */ protected $devices = []; + /** @var PartParameter[] + * @Assert\Valid() + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\PartParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + */ + protected $parameters; + /** * @ColumnSecurity(type="datetime") * @ORM\Column(type="datetime", name="datetime_added", options={"default"="CURRENT_TIMESTAMP"}) @@ -134,6 +142,7 @@ class Part extends AttachmentContainingDBElement parent::__construct(); $this->partLots = new ArrayCollection(); $this->orderdetails = new ArrayCollection(); + $this->parameters = new ArrayCollection(); } /** diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php index 6efe730f..0a7f37e1 100644 --- a/src/Entity/Parts/Storelocation.php +++ b/src/Entity/Parts/Storelocation.php @@ -52,8 +52,11 @@ namespace App\Entity\Parts; use App\Entity\Attachments\StorelocationAttachment; use App\Entity\Base\AbstractPartsContainingDBElement; +use App\Entity\Parameters\DeviceParameter; +use App\Entity\Parameters\StorelocationParameter; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Class Store location. @@ -85,11 +88,17 @@ class Storelocation extends AbstractPartsContainingDBElement * @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY") * @ORM\JoinTable(name="part_lots", * joinColumns={@ORM\JoinColumn(name="id_store_location", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")} + * inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")} * ) */ protected $parts; + /** @var StorelocationParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\StorelocationParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * @var bool * @ORM\Column(type="boolean") @@ -110,6 +119,7 @@ class Storelocation extends AbstractPartsContainingDBElement /** * @var Collection|StorelocationAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 263b55f2..e2b34d78 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -52,6 +52,8 @@ namespace App\Entity\Parts; use App\Entity\Attachments\SupplierAttachment; use App\Entity\Base\AbstractCompany; +use App\Entity\Parameters\DeviceParameter; +use App\Entity\Parameters\SupplierParameter; use App\Entity\PriceInformations\Currency; use App\Validator\Constraints\Selectable; use Doctrine\Common\Collections\Collection; @@ -109,9 +111,16 @@ class Supplier extends AbstractCompany /** * @var Collection|SupplierAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; + /** @var SupplierParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\SupplierParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * Gets the currency that should be used by default, when creating a orderdetail with this supplier. * diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index a3dc0d62..817082ea 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -44,6 +44,8 @@ namespace App\Entity\PriceInformations; use App\Entity\Attachments\CurrencyAttachment; use App\Entity\Base\AbstractStructuralDBElement; +use App\Entity\Parameters\CurrencyParameter; +use App\Entity\Parameters\SupplierParameter; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; @@ -89,9 +91,16 @@ class Currency extends AbstractStructuralDBElement /** * @var Collection|CurrencyAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; + /** @var CurrencyParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\CurrencyParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + /** * Returns the 3 letter ISO code of this currency. * diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index 3da256ec..88767aa7 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -44,10 +44,13 @@ namespace App\Entity\UserSystem; use App\Entity\Attachments\GroupAttachment; use App\Entity\Base\AbstractStructuralDBElement; +use App\Entity\Parameters\GroupParameter; +use App\Entity\Parameters\SupplierParameter; use App\Security\Interfaces\HasPermissionsInterface; use App\Validator\Constraints\ValidPermission; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * This entity represents an user group. @@ -81,6 +84,7 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa /** * @var Collection|GroupAttachment[] * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() */ protected $attachments; @@ -90,6 +94,12 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa */ protected $permissions; + /** @var GroupParameter[] + * @ORM\OneToMany(targetEntity="App\Entity\Parameters\GroupParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) + * @Assert\Valid() + */ + protected $parameters; + public function __construct() { parent::__construct(); diff --git a/src/Form/SpecificationType.php b/src/Form/ParameterType.php similarity index 91% rename from src/Form/SpecificationType.php rename to src/Form/ParameterType.php index 92393f09..f3eabe56 100644 --- a/src/Form/SpecificationType.php +++ b/src/Form/ParameterType.php @@ -20,14 +20,15 @@ namespace App\Form; -use App\Entity\Specifications\Specification; +use App\Entity\Parameters\AbstractParameter; +use App\Entity\Parameters\Parameter; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -class SpecificationType extends AbstractType +class ParameterType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { @@ -61,7 +62,7 @@ class SpecificationType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => Specification::class + 'data_class' => AbstractParameter::class ]); } } \ No newline at end of file diff --git a/src/Form/Part/PartBaseType.php b/src/Form/Part/PartBaseType.php index 6d173d20..c8cd502d 100644 --- a/src/Form/Part/PartBaseType.php +++ b/src/Form/Part/PartBaseType.php @@ -44,15 +44,16 @@ namespace App\Form\Part; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\PartAttachment; +use App\Entity\Parameters\PartParameter; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; use App\Entity\Parts\Manufacturer; use App\Entity\Parts\MeasurementUnit; use App\Entity\Parts\Part; use App\Entity\PriceInformations\Orderdetail; -use App\Entity\Specifications\Specification; +use App\Entity\Parameters\Parameter; use App\Form\AttachmentFormType; -use App\Form\SpecificationType; +use App\Form\ParameterType; use App\Form\Type\MasterPictureAttachmentType; use App\Form\Type\SIUnitType; use App\Form\Type\StructuralEntityType; @@ -266,13 +267,16 @@ class PartBaseType extends AbstractType ], ]); - $builder->add('specifications', CollectionType::class, [ - 'entry_type' => SpecificationType::class, + $builder->add('parameters', CollectionType::class, [ + 'entry_type' => ParameterType::class, 'allow_add' => true, 'allow_delete' => true, 'label' => false, 'by_reference' => false, - 'prototype_data' => new Specification(), + 'prototype_data' => new PartParameter(), + 'entry_options' => [ + 'data_class' => PartParameter::class + ] ]); $builder->add('log_comment', TextType::class, [ diff --git a/src/Migrations/Version20200308204758.php b/src/Migrations/Version20200308204758.php deleted file mode 100644 index 27e2a657..00000000 --- a/src/Migrations/Version20200308204758.php +++ /dev/null @@ -1,57 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('ALTER TABLE attachment_types ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE categories ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE currencies ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE devices ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE footprints ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE manufacturers ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE measurement_units ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE storelocations ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE suppliers ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE groups ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE parts ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\''); - $this->addSql('ALTER TABLE log CHANGE level level TINYINT'); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('ALTER TABLE `attachment_types` DROP specifications'); - $this->addSql('ALTER TABLE `categories` DROP specifications'); - $this->addSql('ALTER TABLE currencies DROP specifications'); - $this->addSql('ALTER TABLE `devices` DROP specifications'); - $this->addSql('ALTER TABLE `footprints` DROP specifications'); - $this->addSql('ALTER TABLE `groups` DROP specifications'); - $this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL'); - $this->addSql('ALTER TABLE `manufacturers` DROP specifications'); - $this->addSql('ALTER TABLE `measurement_units` DROP specifications'); - $this->addSql('ALTER TABLE `parts` DROP specifications'); - $this->addSql('ALTER TABLE `storelocations` DROP specifications'); - $this->addSql('ALTER TABLE `suppliers` DROP specifications'); - } -} diff --git a/src/Migrations/Version20200311204104.php b/src/Migrations/Version20200311204104.php new file mode 100644 index 00000000..16195f23 --- /dev/null +++ b/src/Migrations/Version20200311204104.php @@ -0,0 +1,37 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE parameters (id INT AUTO_INCREMENT NOT NULL, symbol VARCHAR(255) NOT NULL, value_min DOUBLE PRECISION DEFAULT NULL, value_typical DOUBLE PRECISION DEFAULT NULL, value_max DOUBLE PRECISION DEFAULT NULL, unit VARCHAR(255) NOT NULL, value_text VARCHAR(255) NOT NULL, param_group VARCHAR(255) NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, type SMALLINT NOT NULL, element_id INT NOT NULL, INDEX IDX_69348FE1F1F2A24 (element_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE log CHANGE level level TINYINT'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE parameters'); + $this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL'); + } +} diff --git a/templates/Parts/edit/_specifications.html.twig b/templates/Parts/edit/_specifications.html.twig index 479c60a0..331f5c23 100644 --- a/templates/Parts/edit/_specifications.html.twig +++ b/templates/Parts/edit/_specifications.html.twig @@ -1,6 +1,6 @@ {% form_theme form with ['Parts/edit/edit_form_styles.html.twig', "bootstrap_4_layout.html.twig"] %} - +
@@ -14,8 +14,8 @@ - {% for spec in form.specifications %} - {{ form_widget(spec) }} + {% for param in form.parameters %} + {{ form_widget(param) }} {% endfor %}
{% trans %}specifications.property{% endtrans %}
diff --git a/templates/Parts/edit/edit_form_styles.html.twig b/templates/Parts/edit/edit_form_styles.html.twig index 714e6d57..6c897987 100644 --- a/templates/Parts/edit/edit_form_styles.html.twig +++ b/templates/Parts/edit/edit_form_styles.html.twig @@ -64,7 +64,7 @@ {% endblock %} -{% block specification_widget %} +{% block parameter_widget %} {{ form_widget(form.name) }}{{ form_errors(form.name) }} {{ form_widget(form.symbol) }}{{ form_errors(form.symbol) }}