Skip to content

Commit

Permalink
feat: Use ramsey/uuid for Webhook ID generation, doctrine/dbal remo…
Browse files Browse the repository at this point in the history
…ved AutoGenerated uuids
  • Loading branch information
ambroisemaupate committed Jul 25, 2023
1 parent b3ff245 commit 55f80fc
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"pimple/pimple": "^3.3.1",
"psr/cache": ">=1.0.1",
"psr/log": ">=1.1",
"ramsey/uuid": "^4.7",
"rezozero/crypto": "^1.0.0",
"rezozero/intervention-request-bundle": "~3.0.0",
"rezozero/liform-bundle": "^0.18.1",
Expand Down
1 change: 1 addition & 0 deletions lib/RoadizCoreBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"lexik/jwt-authentication-bundle": "^2.13",
"phpdocumentor/reflection-docblock": "^5.2",
"phpoffice/phpspreadsheet": "^1.15",
"ramsey/uuid": "^4.7",
"rezozero/crypto": "^1.0.0",
"rezozero/intervention-request-bundle": "~3.0.0",
"rezozero/liform-bundle": "^0.18.1",
Expand Down
9 changes: 8 additions & 1 deletion lib/RoadizCoreBundle/src/Api/Filter/ArchiveFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ final class ArchiveFilter extends AbstractContextAwareFilter
*/
protected function isDateField(string $property, string $resourceClass): bool
{
return isset(DateFilter::DOCTRINE_DATE_TYPES[(string) $this->getDoctrineFieldType($property, $resourceClass)]);
$type = $this->getDoctrineFieldType($property, $resourceClass);
if (null === $type) {
return false;
}
if (\is_string($type)) {
return \in_array($type, \array_keys(DateFilter::DOCTRINE_DATE_TYPES), true);
}
return $type->getName() === 'datetime' || $type->getName() === 'date';
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/RoadizCoreBundle/src/Bag/NodeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace RZ\Roadiz\CoreBundle\Bag;

use Doctrine\DBAL\DBALException;
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\Bag\LazyParameterBag;
use RZ\Roadiz\Contracts\NodeType\NodeTypeResolverInterface;
Expand Down Expand Up @@ -46,7 +45,7 @@ protected function populateParameters(): void
$this->parameters[$nodeType->getName()] = $nodeType;
$this->parameters[$nodeType->getSourceEntityFullQualifiedClassName()] = $nodeType;
}
} catch (DBALException $e) {
} catch (\Exception $e) {
$this->parameters = [];
}
$this->ready = true;
Expand Down
5 changes: 1 addition & 4 deletions lib/RoadizCoreBundle/src/Bag/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace RZ\Roadiz\CoreBundle\Bag;

use Doctrine\DBAL\DBALException;
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\Bag\LazyParameterBag;
use RZ\Roadiz\CoreBundle\Entity\Role;
Expand Down Expand Up @@ -44,7 +43,7 @@ protected function populateParameters(): void
foreach ($roles as $role) {
$this->parameters[$role->getRole()] = $role;
}
} catch (DBALException $e) {
} catch (\Exception $e) {
$this->parameters = [];
}
$this->ready = true;
Expand All @@ -57,8 +56,6 @@ protected function populateParameters(): void
* @param null $default
*
* @return Role
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
public function get($key, $default = null): Role
{
Expand Down
3 changes: 1 addition & 2 deletions lib/RoadizCoreBundle/src/Bag/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace RZ\Roadiz\CoreBundle\Bag;

use Doctrine\DBAL\DBALException;
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\Bag\LazyParameterBag;
use RZ\Roadiz\CoreBundle\Entity\Document;
Expand Down Expand Up @@ -45,7 +44,7 @@ protected function populateParameters(): void
foreach ($settings as $setting) {
$this->parameters[$setting->getName()] = $setting->getValue();
}
} catch (DBALException $e) {
} catch (\Exception $e) {
$this->parameters = [];
}
$this->ready = true;
Expand Down
6 changes: 5 additions & 1 deletion lib/RoadizCoreBundle/src/Entity/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Webhook extends AbstractDateTimed implements WebhookInterface
#[
ORM\Id,
ORM\Column(type:"string", length:36),
ORM\GeneratedValue(strategy: "UUID"),
Serializer\Groups(["id"]),
SymfonySerializer\Groups(["id"]),
Serializer\Type("string")
Expand Down Expand Up @@ -99,6 +98,11 @@ class Webhook extends AbstractDateTimed implements WebhookInterface
#[SymfonySerializer\Ignore]
protected ?Node $rootNode = null;

public function __construct(?string $uuid = null)
{
$this->id = $uuid ?? \Ramsey\Uuid\Uuid::uuid4()->toString();
}

/**
* @return string|null
*/
Expand Down
1 change: 1 addition & 0 deletions lib/Rozier/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"prettier": "^2.7.1",
"ramsey/uuid": "^4.7",
"resolve-url-loader": "^2.2.0",
"rimraf": "^2.6.0",
"sass-loader": "^6.0.6",
Expand Down

0 comments on commit 55f80fc

Please sign in to comment.