Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Jan 22, 2020
2 parents f8e586e + 7885fcb commit 4117ce9
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ CONTAINER_REPRO=https://hub.docker.com/repository/docker/conduction/orc-php
##################################################

NOTIFICATION_ENABLED=falsedxfddxf
NOTIFICATION_PROVIDER=sasdasd
NOTIFICATION_PROVIDER=sasdasdasd
NOTIFICATION_ENABLED_AUTHORIZATION=sasd

##################################################
Expand Down
1 change: 1 addition & 0 deletions api/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ doctrine:
url: '%env(resolve:DATABASE_URL)%'
types:
uuid: Ramsey\Uuid\Doctrine\UuidType
datetime: App\Types\UTCDateTimeType #We override the default doctrine datetime with a UTC based version
incompleteDate: App\Types\IncompleteDateType
underInvestigation: App\Types\UnderInvestigationType
money: Tbbc\MoneyBundle\Type\MoneyType
Expand Down
2 changes: 1 addition & 1 deletion api/src/Swagger/SwaggerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private function getAdditionalEntityDocs($entity)
$groups = $propertyAnnotation->getGroups();
break;

// Constrainds (Validation)
// Constrainds (Validation)
case "Assert\Date":
$atributes['type'] = 'string';
$atributes['format'] = 'date';
Expand Down
46 changes: 46 additions & 0 deletions api/src/Types/UTCDateTimeType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace App\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeType;

class UTCDateTimeType extends DateTimeType
{
private static $utc = null;

public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}

if (is_null(self::$utc)) {
self::$utc = new \DateTimeZone('UTC');
}

$value->setTimeZone(self::$utc);

return $value->format($platform->getDateTimeFormatString());
}

public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}

if (is_null(self::$utc)) {
self::$utc = new \DateTimeZone('UTC');
}

$val = \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value, self::$utc);

if (!$val) {
throw ConversionException::conversionFailed($value, $this->getName());
}

return $val;
}
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ services:
# - db-data:/var/lib/postgresql/data:rw

db:
image: mysql:5.6
image: mysql:5.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD=example
Expand Down
1 change: 1 addition & 0 deletions openapi.yaml
1 change: 1 addition & 0 deletions publiccode.yaml

0 comments on commit 4117ce9

Please sign in to comment.