Skip to content
Permalink
Browse files

Merge pull request #162 from tarlepp/ramsey-uuid-doctrine

Feat/Ordered V1 UUID
  • Loading branch information...
tarlepp committed Oct 6, 2019
2 parents 8223d79 + cbefb49 commit 013ff5dd3428b4f74597e48046308a2a7cc6c5fd
Showing with 738 additions and 587 deletions.
  1. +4 −0 .idea/.gitignore
  2. +19 −0 .idea/dataSources.xml
  3. +8 −1 .idea/inspectionProfiles/Project_Default.xml
  4. +1 −0 .idea/php.xml
  5. +6 −0 .idea/sqldialects.xml
  6. +1 −0 .idea/symfony-flex-backend.iml
  7. +3 −2 composer.json
  8. +63 −5 composer.lock
  9. +9 −0 config/packages/ramsey_uuid_doctrine.yaml
  10. +1 −1 config/services.yaml
  11. +1 −1 phpunit.xml.dist
  12. +1 −1 src/Command/ApiKey/ApiKeyHelper.php
  13. +9 −6 src/Entity/ApiKey.php
  14. +10 −5 src/Entity/DateDimension.php
  15. +11 −6 src/Entity/Healthz.php
  16. +8 −5 src/Entity/LogLogin.php
  17. +11 −6 src/Entity/LogLoginFailure.php
  18. +8 −5 src/Entity/LogRequest.php
  19. +5 −1 src/Entity/Role.php
  20. +2 −2 src/Entity/Traits/LogEntityTrait.php
  21. +32 −0 src/Entity/Traits/Uuid.php
  22. +9 −6 src/Entity/User.php
  23. +9 −6 src/Entity/UserGroup.php
  24. +2 −2 src/Entity/UserInterface.php
  25. +0 −323 src/Migrations/Version20190530181507.php
  26. +0 −70 src/Migrations/Version20190607143136.php
  27. +0 −72 src/Migrations/Version20190905151530.php
  28. +309 −0 src/Migrations/Version20191006091354.php
  29. +2 −1 src/Repository/Traits/RepositoryMethodsTrait.php
  30. +4 −2 src/Repository/UserRepository.php
  31. +13 −3 src/Rest/RepositoryHelper.php
  32. +78 −0 src/Rest/UuidHelper.php
  33. +8 −7 src/Security/ApiKeyUser.php
  34. +4 −4 src/Utils/Tests/RestTraitTestCase.php
  35. +12 −0 symfony.lock
  36. +8 −7 tests/Integration/Entity/EntityTestCase.php
  37. +1 −1 tests/Integration/Entity/RoleTest.php
  38. +13 −5 tests/Integration/EventSubscriber/LockedUserSubscriberTest.php
  39. +13 −2 tests/Integration/Form/DataTransformer/RoleTransformerTest.php
  40. +1 −0 tests/Integration/Form/Type/Console/ApiKeyTypeTest.php
  41. +4 −1 tests/Unit/Security/ApiKeyUserTest.php
  42. +5 −4 tools/infection/composer.lock
  43. +5 −4 tools/php-coveralls/composer.lock
  44. +5 −4 tools/phpinsights/composer.lock
  45. +5 −4 tools/phpmetrics/composer.lock
  46. +5 −4 tools/phpstan/composer.lock
  47. +5 −4 tools/phpunit/composer.lock
  48. +5 −4 tools/psalm/composer.lock
@@ -0,0 +1,4 @@

# Datasource local storage ignored files
/dataSources.local.xml
/dataSources/
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="MySQL for 5.1 - symfony-flex-backend@localhost" uuid="0de2d918-34df-4d6c-8cd5-359391c7b753">
<driver-ref>mysql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3310/symfony-flex-backend</jdbc-url>
<driver-properties>
<property name="autoReconnect" value="true" />
<property name="zeroDateTimeBehavior" value="convertToNull" />
<property name="tinyInt1isBit" value="false" />
<property name="characterEncoding" value="utf8" />
<property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" />
</driver-properties>
</data-source>
</component>
</project>
@@ -88,24 +88,28 @@
<inspection_tool class="SecurityAdvisoriesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="optionConfiguration">
<list>
<option value="barryvdh/laravel-debugbar" />
<option value="behat/behat" />
<option value="brianium/paratest" />
<option value="codeception/codeception" />
<option value="codedungeon/phpunit-result-printer" />
<option value="composer/composer" />
<option value="doctrine/coding-standard" />
<option value="filp/whoops" />
<option value="friendsofphp/php-cs-fixer" />
<option value="humbug/humbug" />
<option value="infection/infection" />
<option value="jakub-onderka/php-parallel-lint" />
<option value="johnkary/phpunit-speedtrap" />
<option value="kalessil/production-dependencies-guard" />
<option value="mikey179/vfsStream" />
<option value="mockery/mockery" />
<option value="mybuilder/phpunit-accelerator" />
<option value="orchestra/testbench" />
<option value="pdepend/pdepend" />
<option value="phan/phan" />
<option value="phing/phing" />
<option value="phpcompatibility/php-compatibility" />
<option value="phpmd/phpmd" />
<option value="phpro/grumphp" />
<option value="phpspec/phpspec" />
@@ -129,8 +133,11 @@
<option value="symfony/var-dumper" />
<option value="vimeo/psalm" />
<option value="wimg/php-compatibility" />
<option value="wp-coding-standards/wpcs" />
<option value="yiisoft/yii2-coding-standards" />
<option value="yiisoft/yii2-debug" />
<option value="yiisoft/yii2-gii" />
<option value="zendframework/zend-coding-standard" />
<option value="zendframework/zend-debug" />
<option value="zendframework/zend-test" />
</list>
@@ -154,4 +161,4 @@
<inspection_tool class="UselessUnsetInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="UsingInclusionReturnValueInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
</profile>
</component>
</component>
@@ -129,6 +129,7 @@
<path value="$PROJECT_DIR$/vendor/symfony/serializer" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/symfony/var-exporter" />
<path value="$PROJECT_DIR$/vendor/ramsey/uuid-doctrine" />
</include_path>
</component>
<component name="PhpInterpreters">
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/src/Migrations/Version20191006091354.php" dialect="MySQL" />
</component>
</project>
@@ -118,6 +118,7 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/uuid" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/uuid-doctrine" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sensio/framework-extra-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sensiolabs/security-checker" />
<excludeFolder url="file://$MODULE_DIR$/vendor/stof/doctrine-extensions-bundle" />
@@ -35,7 +35,7 @@
"nelmio/api-doc-bundle": "3.4.0",
"nelmio/cors-bundle": "1.5.6",
"piwik/device-detector": "3.12.0",
"ramsey/uuid": "3.8.0",
"ramsey/uuid-doctrine": "1.5.0",
"sensio/framework-extra-bundle": "5.4.1",
"stof/doctrine-extensions-bundle": "1.3.0",
"symfony/asset": "4.3.4",
@@ -128,7 +128,8 @@
},
"symfony": {
"id": "01BFA135DXTPRA5CR250NTJJJP",
"require": "4.3.4"
"require": "4.3.4",
"allow-contrib": true
}
}
}

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,9 @@
doctrine:
dbal:
types:
uuid: 'Ramsey\Uuid\Doctrine\UuidType'
uuid_binary: 'Ramsey\Uuid\Doctrine\UuidBinaryType'
uuid_binary_ordered_time: 'Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType'
mapping_types:
uuid_binary: 'binary'
uuid_binary_ordered_time: 'binary'
@@ -9,7 +9,7 @@ parameters:
env(JWT_PUBLIC_KEY_PATH): '%env(string:key:JWT_PUBLIC_KEY:json:file:APPLICATION_CONFIG)%'
env(CORS_ALLOW_ORIGIN): '%env(string:key:CORS_ALLOW_ORIGIN:json:file:APPLICATION_CONFIG)%'
locale: 'en'
app.uuid_regex: '^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
app.uuid_regex: '^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-1[0-9a-fA-F]{3}\-[89ab][0-9a-f]{3}\-[0-9a-fA-F]{12}$'

services:
# default configuration for services in *this* file
@@ -2,7 +2,7 @@

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.4/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
@@ -124,7 +124,7 @@ private function getApiKeyEntity(SymfonyStyle $io, string $question): ?ApiKeyEnt
$choices = [];
$iterator = $this->getApiKeyIterator($choices);
array_map($iterator, $this->apiKeyResource->find([], ['token' => 'ASC']));
array_map($iterator, $this->apiKeyResource->find(null, ['token' => 'ASC']));
$choices['Exit'] = 'Exit command';
@@ -10,11 +10,12 @@
use App\Entity\Traits\Blameable;
use App\Entity\Traits\Timestampable;
use App\Entity\Traits\Uuid;
use App\Security\RolesService;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints as AssertCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
@@ -47,9 +48,10 @@ class ApiKey implements EntityInterface, UserGroupAwareInterface
// Traits
use Blameable;
use Timestampable;
use Uuid;
/**
* @var string
* @var UuidInterface
*
* @Groups({
* "ApiKey",
@@ -58,7 +60,8 @@ class ApiKey implements EntityInterface, UserGroupAwareInterface
*
* @ORM\Column(
* name="id",
* type="guid",
* type="uuid_binary_ordered_time",
* unique=true,
* nullable=false,
* )
* @ORM\Id()
@@ -135,11 +138,11 @@ class ApiKey implements EntityInterface, UserGroupAwareInterface
/**
* ApiKey constructor.
*
* * @throws Throwable
* @throws Throwable
*/
public function __construct()
{
$this->id = Uuid::uuid4()->toString();
$this->id = $this->getUuid();
$this->userGroups = new ArrayCollection();
$this->logsRequest = new ArrayCollection();
@@ -151,7 +154,7 @@ public function __construct()
*/
public function getId(): string
{
return $this->id;
return $this->id->toString();
}
/**
@@ -8,11 +8,12 @@
namespace App\Entity;
use App\Entity\Traits\Uuid;
use DateTime;
use DateTimeImmutable;
use DateTimeZone;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Throwable;
use function floor;
@@ -35,8 +36,11 @@
*/
class DateDimension implements EntityInterface
{
// Traits
use Uuid;
/**
* @var string
* @var UuidInterface
*
* @Groups({
* "DateDimension",
@@ -45,7 +49,8 @@ class DateDimension implements EntityInterface
*
* @ORM\Column(
* name="id",
* type="guid",
* type="uuid_binary_ordered_time",
* unique=true,
* nullable=false,
* )
* @ORM\Id()
@@ -268,7 +273,7 @@ class DateDimension implements EntityInterface
*/
public function __construct(?DateTime $dateTime = null)
{
$this->id = Uuid::uuid4()->toString();
$this->id = $this->getUuid();
if ($dateTime !== null) {
$this->date = $dateTime;
@@ -290,7 +295,7 @@ public function __construct(?DateTime $dateTime = null)
*/
public function getId(): string
{
return $this->id;
return $this->id->toString();
}
/**

0 comments on commit 013ff5d

Please sign in to comment.
You can’t perform that action at this time.