Skip to content

Commit 98cd3c7

Browse files
committed
Internal: Refactor entities to use PHP 8 attributes for ORM annotations.
Replaced all Symfony Doctrine ORM annotations with PHP 8 attributes to modernize the codebase and improve readability. Additionally, updated type hints and property declarations to enforce strict typing and better align with PHP 8 standards.
1 parent 3c175e7 commit 98cd3c7

File tree

5 files changed

+215
-512
lines changed

5 files changed

+215
-512
lines changed

public/plugin/H5pImport/Entity/H5pImport.php

+34-85
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
// For licensing terms, see /license.txt
3+
/* For licensing terms, see /license.txt */
4+
5+
declare(strict_types=1);
46

57
namespace Chamilo\PluginBundle\H5pImport\Entity;
68

@@ -12,105 +14,52 @@
1214
use Doctrine\ORM\Mapping as ORM;
1315
use Gedmo\Mapping\Annotation as Gedmo;
1416

15-
/**
16-
* Class H5pImport.
17-
*
18-
* @ORM\Entity()
19-
*
20-
* @ORM\Table(name="plugin_h5p_import")
21-
*/
17+
#[ORM\Entity]
18+
#[ORM\Table(name: 'plugin_h5p_import')]
2219
class H5pImport
2320
{
24-
/**
25-
* @var string
26-
*
27-
* @ORM\Column(name="path", type="text", nullable=false)
28-
*/
29-
protected $path;
21+
#[ORM\Column(name: 'path', type: 'text', nullable: false)]
22+
protected string $path;
3023

31-
/**
32-
* @var string
33-
*
34-
* @ORM\Column(name="relative_path", type="text", nullable=false)
35-
*/
36-
protected $relativePath;
24+
#[ORM\Column(name: 'relative_path', type: 'text', nullable: false)]
25+
protected string $relativePath;
3726

38-
/**
39-
* @var DateTime
40-
*
41-
* @Gedmo\Timestampable(on="create")
42-
*
43-
* @ORM\Column(name="created_at", type="datetime", nullable=false)
44-
*/
45-
protected $createdAt;
27+
#[Gedmo\Timestampable(on: 'create')]
28+
#[ORM\Column(name: 'created_at', type: 'datetime', nullable: false)]
29+
protected DateTime $createdAt;
4630

47-
/**
48-
* @var DateTime
49-
*
50-
* @Gedmo\Timestampable(on="update")
51-
*
52-
* @ORM\Column(name="modified_at", type="datetime", nullable=false)
53-
*/
54-
protected $modifiedAt;
31+
#[Gedmo\Timestampable(on: 'update')]
32+
#[ORM\Column(name: 'modified_at', type: 'datetime', nullable: false)]
33+
protected DateTime $modifiedAt;
5534

56-
/**
57-
* @var int
58-
*
59-
* @ORM\Column(name="iid", type="integer")
60-
*
61-
* @ORM\Id
62-
*
63-
* @ORM\GeneratedValue
64-
*/
65-
private $iid;
35+
#[ORM\Column(name: 'iid', type: 'integer')]
36+
#[ORM\Id]
37+
#[ORM\GeneratedValue]
38+
private ?int $iid;
6639

67-
/**
68-
* @var Course
69-
*
70-
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
71-
*
72-
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false)
73-
*/
74-
private $course;
40+
#[ORM\ManyToOne(targetEntity: Course::class)]
41+
#[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', nullable: false)]
42+
private Course $course;
7543

76-
/**
77-
* @var null|Session
78-
*
79-
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
80-
*
81-
* @ORM\JoinColumn(name="session_id", referencedColumnName="id")
82-
*/
83-
private $session;
44+
#[ORM\ManyToOne(targetEntity: Session::class)]
45+
#[ORM\JoinColumn(name: 'session_id', referencedColumnName: 'id')]
46+
private ?Session $session;
8447

85-
/**
86-
* @var null|string
87-
*
88-
* @ORM\Column(name="name", type="text", nullable=true)
89-
*/
90-
private $name;
48+
#[ORM\Column(name: 'name', type: 'text', nullable: true)]
49+
private ?string $name;
9150

92-
/**
93-
* @var null|string
94-
*
95-
* @ORM\Column(name="description", type="text", nullable=true)
96-
*/
97-
private $description;
51+
#[ORM\Column(name: 'description', type: 'text', nullable: true)]
52+
private ?string $description;
9853

9954
/**
10055
* @var Collection<int, H5pImportLibrary>
101-
*
102-
* @ORM\ManyToMany(targetEntity="H5pImportLibrary", mappedBy="h5pImports", cascade={"persist"})
10356
*/
104-
private $libraries;
57+
#[ORM\ManyToMany(targetEntity: H5pImportLibrary::class, mappedBy: 'h5pImports', cascade: ['persist'])]
58+
private Collection $libraries;
10559

106-
/**
107-
* @var H5pImportLibrary
108-
*
109-
* @ORM\ManyToOne(targetEntity="H5pImportLibrary")
110-
*
111-
* @ORM\JoinColumn(name="main_library_id", referencedColumnName="iid", onDelete="SET NULL")
112-
*/
113-
private $mainLibrary;
60+
#[ORM\ManyToOne(targetEntity: H5pImportLibrary::class)]
61+
#[ORM\JoinColumn(name: 'main_library_id', referencedColumnName: 'iid', onDelete: 'SET NULL')]
62+
private H5pImportLibrary $mainLibrary;
11463

11564
public function __construct()
11665
{

public/plugin/H5pImport/Entity/H5pImportLibrary.php

+45-93
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
// For licensing terms, see /license.txt
3+
/* For licensing terms, see /license.txt */
4+
5+
declare(strict_types=1);
46

57
namespace Chamilo\PluginBundle\H5pImport\Entity;
68

@@ -12,115 +14,65 @@
1214
use Doctrine\ORM\Mapping as ORM;
1315
use Gedmo\Mapping\Annotation as Gedmo;
1416

15-
/**
16-
* Class H5pImportLibrary.
17-
*
18-
* @ORM\Entity()
19-
*
20-
* @ORM\Table(name="plugin_h5p_import_library")
21-
*/
22-
class H5pImportLibrary extends EntityRepository
17+
#[ORM\Entity]
18+
#[ORM\Table(name: 'plugin_h5p_import_library')]
19+
class H5pImportLibrary
2320
{
24-
/**
25-
* @var \DateTime
26-
*
27-
* @Gedmo\Timestampable(on="create")
28-
*
29-
* @ORM\Column(name="created_at", type="datetime", nullable=false)
30-
*/
31-
protected $createdAt;
21+
#[Gedmo\Timestampable(on: 'create')]
22+
#[ORM\Column(name: 'created_at', type: 'datetime', nullable: false)]
23+
protected DateTime $createdAt;
3224

33-
/**
34-
* @var \DateTime
35-
*
36-
* @Gedmo\Timestampable(on="update")
37-
*
38-
* @ORM\Column(name="modified_at", type="datetime", nullable=false)
39-
*/
40-
protected $modifiedAt;
25+
#[Gedmo\Timestampable(on: 'update')]
26+
#[ORM\Column(name: 'modified_at', type: 'datetime', nullable: false)]
27+
protected DateTime $modifiedAt;
4128

42-
/**
43-
* @var int
44-
*
45-
* @ORM\Column(name="iid", type="integer")
46-
*
47-
* @ORM\Id
48-
*
49-
* @ORM\GeneratedValue
50-
*/
51-
private $iid;
29+
#[ORM\Column(name: 'iid', type: 'integer')]
30+
#[ORM\Id]
31+
#[ORM\GeneratedValue]
32+
private ?int $iid;
5233

53-
/**
54-
* @ORM\Column(name="title", type="string", nullable=true)
55-
*/
56-
private $title;
34+
#[ORM\Column(name: 'title', type: 'string', nullable: true)]
35+
private ?string $title;
5736

58-
/**
59-
* @ORM\Column(name="machine_name", type="string")
60-
*/
61-
private $machineName;
37+
#[ORM\Column(name: 'machine_name', type: 'string')]
38+
private string $machineName;
6239

63-
/**
64-
* @ORM\Column(name="major_version", type="integer")
65-
*/
66-
private $majorVersion;
40+
#[ORM\Column(name: 'major_version', type: 'integer')]
41+
private int $majorVersion;
6742

68-
/**
69-
* @ORM\Column(name="minor_version", type="integer")
70-
*/
71-
private $minorVersion;
43+
#[ORM\Column(name: 'minor_version', type: 'integer')]
44+
private int $minorVersion;
7245

73-
/**
74-
* @ORM\Column(name="patch_version", type="integer")
75-
*/
76-
private $patchVersion;
46+
#[ORM\Column(name: 'patch_version', type: 'integer')]
47+
private int $patchVersion;
7748

78-
/**
79-
* @ORM\Column(name="runnable", type="integer", nullable=true)
80-
*/
81-
private $runnable;
49+
#[ORM\Column(name: 'runnable', type: 'integer', nullable: true)]
50+
private ?int $runnable;
8251

83-
/**
84-
* @ORM\Column(name="embed_types", type="array", nullable=true)
85-
*/
86-
private $embedTypes;
52+
#[ORM\Column(name: 'embed_types', type: 'array', nullable: true)]
53+
private ?array $embedTypes;
8754

88-
/**
89-
* @ORM\Column(name="preloaded_js" , type="array", nullable=true)
90-
*/
91-
private $preloadedJs;
55+
#[ORM\Column(name: 'preloaded_js', type: 'array', nullable: true)]
56+
private array $preloadedJs;
9257

93-
/**
94-
* @ORM\Column(name="preloaded_css", type="array", nullable=true)
95-
*/
96-
private $preloadedCss;
58+
#[ORM\Column(name: 'preloaded_css', type: 'array', nullable: true)]
59+
private array $preloadedCss;
9760

98-
/**
99-
* @ORM\Column(name="library_path", type="string", length=255)
100-
*/
101-
private $libraryPath;
61+
#[ORM\Column(name: 'library_path', type: 'string', length: 255)]
62+
private string $libraryPath;
10263

10364
/**
10465
* @var Collection<int, H5pImport>
105-
*
106-
* @ORM\ManyToMany(targetEntity="H5pImport", inversedBy="libraries")
107-
*
108-
* @ORM\JoinTable(
109-
* name="plugin_h5p_import_rel_libraries",
110-
* joinColumns={@ORM\JoinColumn(name="h5p_import_library_id", referencedColumnName="iid", onDelete="CASCADE")},
111-
* inverseJoinColumns={@ORM\JoinColumn(name="h5p_import_id", referencedColumnName="iid", onDelete="CASCADE")}
112-
* )
113-
*/
114-
private $h5pImports;
115-
116-
/**
117-
* @var Course
118-
*
119-
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
120-
*
121-
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false)
12266
*/
123-
private $course;
67+
#[ORM\ManyToMany(targetEntity: H5pImport::class, inversedBy: 'libraries')]
68+
#[ORM\JoinTable(name: 'plugin_h5p_import_rel_libraries')]
69+
#[ORM\JoinColumn(name: 'h5p_import_library_id', referencedColumnName: 'iid', onDelete: 'CASCADE')]
70+
#[ORM\InverseJoinColumn(name: 'h5p_import_id', referencedColumnName: 'iid', onDelete: 'CASCADE')]
71+
private Collection $h5pImports;
72+
73+
#[ORM\ManyToOne(targetEntity: Course::class)]
74+
#[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', nullable: false)]
75+
private Course $course;
12476

12577
public function __construct()
12678
{

0 commit comments

Comments
 (0)