diff --git a/composer.json b/composer.json index b65f8a8..344f97e 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "doctrine/dbal": "^2.6", "doctrine/doctrine-bundle": "^1.8", "doctrine/orm": "^2.6", + "ramsey/uuid": "^3.7", "symfony/console": "^4.0", "symfony/flex": "^1.0", "symfony/framework-bundle": "^4.0", diff --git a/composer.lock b/composer.lock index 4d5c7f4..2fa81a4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "6ddfd2d9adacc6e6d8b6e715d904c7ab", + "content-hash": "e5302db1e14db935b39e1b6d45d2f761", "packages": [ { "name": "doctrine/annotations", @@ -1092,6 +1092,54 @@ ], "time": "2017-05-04T11:12:50+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v2.0.11", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8", + "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "pseudorandom", + "random" + ], + "time": "2017-09-27T21:40:39+00:00" + }, { "name": "psr/cache", "version": "1.0.1", @@ -1282,6 +1330,86 @@ ], "time": "2017-01-02T13:31:39+00:00" }, + { + "name": "ramsey/uuid", + "version": "3.7.3", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "44abcdad877d9a46685a3a4d221e3b2c4b87cb76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/44abcdad877d9a46685a3a4d221e3b2c4b87cb76", + "reference": "44abcdad877d9a46685a3a4d221e3b2c4b87cb76", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "^1.0|^2.0", + "php": "^5.4 || ^7.0" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "codeception/aspect-mock": "^1.0 | ~2.0.0", + "doctrine/annotations": "~1.2.0", + "goaop/framework": "1.0.0-alpha.2 | ^1.0 | ^2.1", + "ircmaxell/random-lib": "^1.1", + "jakub-onderka/php-parallel-lint": "^0.9.0", + "mockery/mockery": "^0.9.9", + "moontoast/math": "^1.1", + "php-mock/php-mock-phpunit": "^0.3|^1.1", + "phpunit/phpunit": "^4.7|^5.0", + "squizlabs/php_codesniffer": "^2.3" + }, + "suggest": { + "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", + "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", + "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marijn Huizendveld", + "email": "marijn.huizendveld@gmail.com" + }, + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + }, + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", + "homepage": "https://github.com/ramsey/uuid", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "time": "2018-01-20T00:28:24+00:00" + }, { "name": "symfony/cache", "version": "v4.0.3", diff --git a/src/Entity/ItemType.php b/src/Entity/ItemType.php new file mode 100644 index 0000000..c816993 --- /dev/null +++ b/src/Entity/ItemType.php @@ -0,0 +1,154 @@ +commonName = $commonName; + $this->id = Uuid::uuid4(); + } + + public function getCommonName(): string + { + return $this->commonName; + } + + public function setCommonName(string $commonName): void + { + $this->commonName = $commonName; + } + + public function getOfficialName(): ?string + { + return $this->officialName; + } + + public function setOfficialName(?string $officialName): void + { + $this->officialName = $officialName; + } + + public function getBasicRentalPrice(): ?int + { + return $this->basicRentalPrice; + } + + public function setBasicRentalPrice(?int $basicRentalPrice): void + { + $this->basicRentalPrice = $basicRentalPrice; + } + + public function getProductPageUrl(): ?string + { + return $this->productPageUrl; + } + + public function setProductPageUrl(?string $productPageUrl): void + { + $this->productPageUrl = $productPageUrl; + } + + public function getAvatar(): ?string + { + return $this->avatar; + } + + public function setAvatar(?string $avatar): void + { + $this->avatar = $avatar; + } + + /** + * @return string[] + */ + public function getAttachments(): array + { + return $this->attachments; + } + + /** + * @param string[] $attachments + */ + public function setAttachments(array $attachments): void + { + $this->attachments = $attachments; + } + + public function getWeight(): ?int + { + return $this->weight; + } + + public function setWeight(?int $weight): void + { + $this->weight = $weight; + } +} diff --git a/src/Migrations/Version20180223161324.php b/src/Migrations/Version20180223161324.php new file mode 100644 index 0000000..6ba7b53 --- /dev/null +++ b/src/Migrations/Version20180223161324.php @@ -0,0 +1,30 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE TABLE item_type (id UUID NOT NULL, common_name VARCHAR(255) NOT NULL, official_name VARCHAR(1023) DEFAULT NULL, basic_rental_price INT DEFAULT NULL, product_page_url VARCHAR(255) DEFAULT NULL, avatar VARCHAR(255) DEFAULT NULL, attachments JSON DEFAULT NULL, weight INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('COMMENT ON COLUMN item_type.attachments IS \'(DC2Type:json_array)\''); + } + + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE SCHEMA public'); + $this->addSql('DROP TABLE item_type'); + } +} diff --git a/symfony.lock b/symfony.lock index 5dc50b3..eb6887d 100644 --- a/symfony.lock +++ b/symfony.lock @@ -65,6 +65,9 @@ "ocramius/proxy-manager": { "version": "2.1.1" }, + "paragonie/random_compat": { + "version": "v2.0.11" + }, "psr/cache": { "version": "1.0.1" }, @@ -77,6 +80,9 @@ "psr/simple-cache": { "version": "1.0.0" }, + "ramsey/uuid": { + "version": "3.7.3" + }, "symfony/cache": { "version": "v4.0.3" },