Skip to content

Commit 9f5d19f

Browse files
authored
Improvements (trexima#14)
* Added clone methods Updated getters and setters * Improvements * Updated MonthYearRange * Added sort for languages and digital skills * Updated driving licenses * Added social accounts
1 parent 937bed1 commit 9f5d19f

39 files changed

+1423
-792
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"minimum-stability": "stable",
1414
"require": {
15-
"php": "^8.0",
15+
"php": "^8.1",
1616
"symfony/framework-bundle": "^6.2",
1717
"symfony/twig-bundle": "^6.2",
1818
"claviska/simpleimage": "^3.3",

composer.lock

+231-244
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/services.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
arguments: ['%trexima_european_cv_upload_url%']
2626

2727
Trexima\EuropeanCvBundle\Export\EuropeanCvExporter:
28-
arguments:
28+
arguments:
2929
$projectDir: '%kernel.project_dir%'
3030
$uploadUrl: '%trexima_european_cv_upload_url%'
3131

@@ -42,27 +42,23 @@ services:
4242
$url: '%trexima_european_cv_harvey_url%'
4343
$username: '%trexima_european_cv_harvey_username%'
4444
$password: '%trexima_european_cv_harvey_password%'
45-
45+
4646
Trexima\EuropeanCvBundle\Facade\GooglePlaces:
4747
arguments:
4848
$apiKey: '%trexima_european_cv_google_apikey%'
4949

50-
Trexima\EuropeanCvBundle\Form\Type\EuropeanCVPracticeType:
51-
arguments:
52-
$translator: '@translator'
53-
5450
Trexima\EuropeanCvBundle\Form\Type\EuropeanCVWorkBreakType:
5551
arguments:
5652
$translator: '@translator'
5753

5854
Trexima\EuropeanCvBundle\Form\Parts\EuropeanCVPartBasicInfoType:
5955
arguments:
56+
$propertyAccessor: '@property_accessor'
6057
$translator: '@translator'
6158
$uploadUrl: '%trexima_european_cv_upload_url%'
6259

6360
Trexima\EuropeanCvBundle\Form\Type\EuropeanCVEducationType:
6461
arguments:
65-
$urlGenerator: '@router.default'
6662
$translator: '@translator'
6763

6864
Trexima\EuropeanCvBundle\Form\Type\EuropeanCVCertificateType:

src/Entity/AbstractGoogleAddress.php

+23-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Trexima\EuropeanCvBundle\Entity;
44

55
use Doctrine\ORM\Mapping as ORM;
6-
use Gedmo\Mapping\Annotation as Gedmo;
6+
use Doctrine\Persistence\Proxy;
77

88
#[ORM\Index(fields: ['administrativeAreaLevel1'])]
99
#[ORM\Index(fields: ['locality'])]
@@ -77,9 +77,13 @@ class AbstractGoogleAddress
7777
#[ORM\Column(type: 'float', nullable: true)]
7878
protected ?float $longitude = null;
7979

80-
#[Gedmo\Timestampable(on: 'create')]
8180
#[ORM\Column(type: 'datetime_immutable')]
82-
protected ?\DateTimeImmutable $createdAt = null;
81+
protected \DateTimeImmutable $createdAt;
82+
83+
public function __construct()
84+
{
85+
$this->createdAt = new \DateTimeImmutable();
86+
}
8387

8488
public function getId(): ?int
8589
{
@@ -326,7 +330,7 @@ public function setLongitude(?float $longitude): self
326330
return $this;
327331
}
328332

329-
public function getCreatedAt(): ?\DateTimeImmutable
333+
public function getCreatedAt(): \DateTimeImmutable
330334
{
331335
return $this->createdAt;
332336
}
@@ -375,6 +379,21 @@ public function copyTo(AbstractGoogleAddress $to): void
375379
$to->setLongitude($this->getLongitude());
376380
}
377381

382+
public function __clone()
383+
{
384+
/*
385+
* If the entity has an identity, proceed as normal.
386+
* https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/implementing-wakeup-or-clone.html
387+
*/
388+
if ($this->id) {
389+
if ($this instanceof Proxy && !$this->__isInitialized()) {
390+
$this->__load();
391+
}
392+
393+
$this->id = null;
394+
}
395+
}
396+
378397
public function __toString(): string
379398
{
380399
return $this->getFormattedAddress();

src/Entity/Embeddable/DateRange.php

+19-7
Original file line numberDiff line numberDiff line change
@@ -30,58 +30,70 @@ public function getBeginDay(): ?int
3030
return $this->beginDay;
3131
}
3232

33-
public function setBeginDay(?int $beginDay): void
33+
public function setBeginDay(?int $beginDay): self
3434
{
3535
$this->beginDay = $beginDay;
36+
37+
return $this;
3638
}
3739

3840
public function getBeginMonth(): ?int
3941
{
4042
return $this->beginMonth;
4143
}
4244

43-
public function setBeginMonth(?int $beginMonth): void
45+
public function setBeginMonth(?int $beginMonth): self
4446
{
4547
$this->beginMonth = $beginMonth;
48+
49+
return $this;
4650
}
4751

4852
public function getBeginYear(): ?int
4953
{
5054
return $this->beginYear;
5155
}
5256

53-
public function setBeginYear(?int $beginYear): void
57+
public function setBeginYear(?int $beginYear): self
5458
{
5559
$this->beginYear = $beginYear;
60+
61+
return $this;
5662
}
5763

5864
public function getEndDay(): ?int
5965
{
6066
return $this->endDay;
6167
}
6268

63-
public function setEndDay(?int $endDay): void
69+
public function setEndDay(?int $endDay): self
6470
{
6571
$this->endDay = $endDay;
72+
73+
return $this;
6674
}
6775

6876
public function getEndMonth(): ?int
6977
{
7078
return $this->endMonth;
7179
}
7280

73-
public function setEndMonth(?int $endMonth): void
81+
public function setEndMonth(?int $endMonth): self
7482
{
7583
$this->endMonth = $endMonth;
84+
85+
return $this;
7686
}
7787

7888
public function getEndYear(): ?int
7989
{
8090
return $this->endYear;
8191
}
8292

83-
public function setEndYear(?int $endYear): void
93+
public function setEndYear(?int $endYear): self
8494
{
8595
$this->endYear = $endYear;
96+
97+
return $this;
8698
}
87-
}
99+
}

src/Entity/Embeddable/MonthYearRange.php

+36-19
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,18 @@
1010
class MonthYearRange
1111
{
1212
#[Assert\NotBlank]
13-
#[Assert\Range(
14-
min: 1,
15-
max: 12,
16-
)]
13+
#[Assert\Range(min: 1, max: 12)]
1714
#[ORM\Column(type: 'smallint', nullable: true)]
1815
private ?int $beginMonth = null;
1916

2017
#[Assert\NotBlank]
2118
#[ORM\Column(type: 'smallint', nullable: true)]
2219
private ?int $beginYear = null;
2320

24-
#[Assert\NotBlank]
25-
#[Assert\Range(
26-
min: 1,
27-
max: 12,
28-
)]
21+
#[Assert\Range(min: 1, max: 12)]
2922
#[ORM\Column(type: 'smallint', nullable: true)]
3023
private ?int $endMonth = null;
3124

32-
#[Assert\NotBlank]
3325
#[ORM\Column(type: 'smallint', nullable: true)]
3426
private ?int $endYear = null;
3527

@@ -38,46 +30,71 @@ public function getBeginMonth(): ?int
3830
return $this->beginMonth;
3931
}
4032

41-
public function setBeginMonth(?int $beginMonth): void
33+
public function setBeginMonth(?int $beginMonth): self
4234
{
4335
$this->beginMonth = $beginMonth;
36+
37+
return $this;
4438
}
4539

4640
public function getBeginYear(): ?int
4741
{
4842
return $this->beginYear;
4943
}
5044

51-
public function setBeginYear(?int $beginYear): void
45+
public function setBeginYear(?int $beginYear): self
5246
{
5347
$this->beginYear = $beginYear;
48+
49+
return $this;
5450
}
5551

5652
public function getEndMonth(): ?int
5753
{
5854
return $this->endMonth;
5955
}
6056

61-
public function setEndMonth(?int $endMonth): void
57+
public function setEndMonth(?int $endMonth): self
6258
{
6359
$this->endMonth = $endMonth;
60+
61+
return $this;
6462
}
6563

6664
public function getEndYear(): ?int
6765
{
6866
return $this->endYear;
6967
}
7068

71-
public function setEndYear(?int $endYear): void
69+
public function setEndYear(?int $endYear): self
7270
{
7371
$this->endYear = $endYear;
72+
73+
return $this;
7474
}
7575

7676
#[Assert\Callback]
77-
public function validate(ExecutionContextInterface $context, $payload)
77+
public function validate(ExecutionContextInterface $context, $payload): void
7878
{
79+
$endYear = $this->getEndYear();
80+
$endMonth = $this->getEndMonth();
81+
82+
if ($endYear === null && $endMonth === null) {
83+
return;
84+
}
85+
86+
if ($endYear === null || $endMonth === null) {
87+
$context->buildViolation('trexima_european_cv.range_not_valid')
88+
->atPath('endMonth')
89+
->addViolation();
90+
$context->buildViolation('trexima_european_cv.range_not_valid')
91+
->atPath('endYear')
92+
->addViolation();
93+
return;
94+
}
95+
7996
$from = $this->getBeginYear() . sprintf('%02d', $this->getBeginMonth());
80-
$to = $this->getEndYear() . sprintf('%02d', $this->getEndMonth());
97+
$to = $endYear . sprintf('%02d', $endMonth);
8198

8299
if ($from > $to) {
83100
$context->buildViolation('trexima_european_cv.range_not_valid')
@@ -87,11 +104,11 @@ public function validate(ExecutionContextInterface $context, $payload)
87104
->atPath('beginYear')
88105
->addViolation();
89106
$context->buildViolation('trexima_european_cv.range_not_valid')
90-
->atPath('endYear')
107+
->atPath('endMonth')
91108
->addViolation();
92109
$context->buildViolation('trexima_european_cv.range_not_valid')
93-
->atPath('endMonth')
110+
->atPath('endYear')
94111
->addViolation();
95112
}
96113
}
97-
}
114+
}

src/Entity/Embeddable/YearRange.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@ public function getBeginYear(): ?int
3737
return $this->beginYear;
3838
}
3939

40-
public function setBeginYear(?int $beginYear): void
40+
public function setBeginYear(?int $beginYear): self
4141
{
4242
$this->beginYear = $beginYear;
43+
44+
return $this;
4345
}
4446

4547
public function getEndYear(): ?int
4648
{
4749
return $this->endYear;
4850
}
4951

50-
public function setEndYear(?int $endYear): void
52+
public function setEndYear(?int $endYear): self
5153
{
5254
$this->endYear = $endYear;
55+
56+
return $this;
5357
}
54-
}
58+
}

src/Entity/Enum/CompetenceEnum.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ enum CompetenceEnum: string
4545
case COMPETENCE_39 = 'Trpezlivosť';
4646
case COMPETENCE_40 = 'Umelecký talent (napr. hudobný, pohybový, literárny)';
4747
case COMPETENCE_41 = 'Vnútorná stabilita';
48-
}
48+
}

src/Entity/Enum/DigitalSkillLevelEnum.php

-13
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,3 @@ enum DigitalSkillLevelEnum: int
88
case DIGITAL_SKILL_LEVEL_INTERMEDIATE = 2;
99
case DIGITAL_SKILL_LEVEL_EXPERT = 3;
1010
}
11-
12-
13-
14-
15-
16-
17-
18-
19-
20-
21-
22-
23-

src/Entity/Enum/DrivingLicenseEnum.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public function getIconClass(): ?string
2828
default => null,
2929
};
3030
}
31-
}
31+
}

src/Entity/Enum/EducationEnum.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ enum EducationEnum: string
1313
case EDUCATION_6 = 'Vysokoškolské vzdelanie prvého stupňa';
1414
case EDUCATION_7 = 'Vysokoškolské vzdelanie druhého stupňa';
1515
case EDUCATION_8 = 'Vysokoškolské vzdelanie tretieho stupňa';
16-
}
16+
}

src/Entity/Enum/EducationTypeEnum.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ enum EducationTypeEnum: int
1111

1212
public function title(): string
1313
{
14-
return match($this) {
14+
return match ($this) {
1515
static::EDUCATION_ELEMENTARY_SCHOOL => 'trexima_european_cv.education_type_enum.education_elementary_school',
1616
static::EDUCATION_HIGH_SCHOOL => 'trexima_european_cv.education_type_enum.education_high_school',
1717
static::EDUCATION_UNIVERSITY => 'trexima_european_cv.education_type_enum.education_university',
1818
static::EDUCATION_CERTIFICATE => 'trexima_european_cv.education_type_enum.education_certificate',
1919
};
2020
}
21-
}
21+
}

0 commit comments

Comments
 (0)