Skip to content

Commit 3b9267f

Browse files
committed
Use repo methods
1 parent d94f825 commit 3b9267f

File tree

8 files changed

+201
-86
lines changed

8 files changed

+201
-86
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
"tatevikgr/rss-feed": "dev-main",
8181
"ext-pdo": "*",
8282
"ezyang/htmlpurifier": "^4.19",
83-
"ext-libxml": "*"
83+
"ext-libxml": "*",
84+
"ext-gd": "*"
8485
},
8586
"require-dev": {
8687
"phpunit/phpunit": "^9.5",

config/parameters.yml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ parameters:
9393
env(DEFAULT_MESSAGEAGE): '691200'
9494
messaging.use_manual_text_part : '%%env(USE_MANUAL_TEXT_PART)%%'
9595
env(USE_MANUAL_TEXT_PART): 0
96+
97+
phplist.upload_images_dir: '%%env(PHPLIST_UPLOADIMAGES_DIR)%%'
98+
env(PHPLIST_UPLOADIMAGES_DIR): 'images'

src/Domain/Configuration/Model/ConfigOption.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ enum ConfigOption: string
2525
case NotifyEndDefault = 'notifyend_default';
2626
case WordWrap = 'wordwrap';
2727
case RemoteUrlAppend = 'remoteurl_append';
28+
case OrganisationLogo = 'organisation_logo';
2829
}

src/Domain/Identity/Model/AdminAttributeDefinition.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace PhpList\Core\Domain\Identity\Model;
66

7+
use Doctrine\Common\Collections\ArrayCollection;
8+
use Doctrine\Common\Collections\Collection;
79
use Doctrine\ORM\Mapping as ORM;
810
use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel;
911
use PhpList\Core\Domain\Common\Model\Interfaces\Identity;
@@ -37,6 +39,13 @@ class AdminAttributeDefinition implements DomainModel, Identity
3739
#[ORM\Column(name:'tablename', type: 'string', length: 255, nullable: true)]
3840
private ?string $tableName;
3941

42+
#[ORM\OneToMany(
43+
targetEntity: AdminAttributeValue::class,
44+
mappedBy: 'attributeDefinition',
45+
orphanRemoval: true
46+
)]
47+
private Collection $attributeValues;
48+
4049
public function __construct(
4150
string $name,
4251
?string $type = null,
@@ -51,6 +60,7 @@ public function __construct(
5160
$this->defaultValue = $defaultValue;
5261
$this->required = $required;
5362
$this->tableName = $tableName;
63+
$this->attributeValues = new ArrayCollection();
5464
}
5565

5666
public function getId(): ?int
@@ -122,4 +132,10 @@ public function setRequired(?bool $required): self
122132

123133
return $this;
124134
}
135+
136+
/** @return Collection<int, AdminAttributeValue> */
137+
public function getAttributeValues(): Collection
138+
{
139+
return $this->attributeValues;
140+
}
125141
}

src/Domain/Identity/Model/Administrator.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace PhpList\Core\Domain\Identity\Model;
66

77
use DateTime;
8+
use Doctrine\Common\Collections\ArrayCollection;
9+
use Doctrine\Common\Collections\Collection;
810
use Doctrine\ORM\Mapping as ORM;
911
use InvalidArgumentException;
1012
use PhpList\Core\Domain\Common\Model\Interfaces\CreationDate;
@@ -13,6 +15,7 @@
1315
use PhpList\Core\Domain\Common\Model\Interfaces\ModificationDate;
1416
use PhpList\Core\Domain\Common\Model\Interfaces\OwnableInterface;
1517
use PhpList\Core\Domain\Identity\Repository\AdministratorRepository;
18+
use PhpList\Core\Domain\Subscription\Model\SubscriberList;
1619

1720
/**
1821
* This class represents an administrator who can log to the system, is allowed to administer
@@ -65,11 +68,15 @@ class Administrator implements DomainModel, Identity, CreationDate, Modification
6568
#[ORM\Column(name: 'privileges', type: 'text', nullable: true)]
6669
private ?string $privileges = null;
6770

71+
#[ORM\OneToMany(targetEntity: SubscriberList::class, mappedBy: 'owner')]
72+
private Collection $ownedLists;
73+
6874
public function __construct()
6975
{
7076
$this->createdAt = new DateTime();
7177
$this->updatedAt = new DateTime();
7278
$this->email = '';
79+
$this->ownedLists = new ArrayCollection();
7380
}
7481

7582
public function getId(): ?int
@@ -211,4 +218,12 @@ public function setUpdatedAt(): void
211218
{
212219
$this->updatedAt = new DateTime();
213220
}
221+
222+
/**
223+
* @return Collection<int, SubscriberList>
224+
*/
225+
public function getOwnedLists(): Collection
226+
{
227+
return $this->ownedLists;
228+
}
214229
}

src/Domain/Identity/Repository/AdminAttributeDefinitionRepository.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpList\Core\Domain\Common\Repository\CursorPaginationTrait;
99
use PhpList\Core\Domain\Common\Repository\Interfaces\PaginatableRepositoryInterface;
1010
use PhpList\Core\Domain\Identity\Model\AdminAttributeDefinition;
11+
use PhpList\Core\Domain\Identity\Model\Administrator;
1112

1213
class AdminAttributeDefinitionRepository extends AbstractRepository implements PaginatableRepositoryInterface
1314
{
@@ -17,4 +18,28 @@ public function findOneByName(string $name): ?AdminAttributeDefinition
1718
{
1819
return $this->findOneBy(['name' => $name]);
1920
}
21+
22+
/** @return array<int, array{value: mixed, name: string}> */
23+
public function getForAdmin(Administrator $admin): array
24+
{
25+
return $this->createQueryBuilder('ad')
26+
->select("COALESCE(aav.value, '') AS value", 'ad.name')
27+
->leftJoin(
28+
'ad.attributeValues',
29+
'aav',
30+
'WITH',
31+
'aav.administrator = :admin'
32+
)
33+
->setParameter('admin', $admin)
34+
->getQuery()
35+
->getResult();
36+
}
37+
38+
public function getAllWIthEmptyValues(): array
39+
{
40+
return $this->createQueryBuilder('ad')
41+
->select("ad.name AS name", "'' AS value")
42+
->getQuery()
43+
->getResult();
44+
}
2045
}

src/Domain/Messaging/Repository/TemplateImageRepository.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,29 @@
77
use PhpList\Core\Domain\Common\Repository\AbstractRepository;
88
use PhpList\Core\Domain\Common\Repository\CursorPaginationTrait;
99
use PhpList\Core\Domain\Common\Repository\Interfaces\PaginatableRepositoryInterface;
10+
use PhpList\Core\Domain\Messaging\Model\TemplateImage;
1011

1112
class TemplateImageRepository extends AbstractRepository implements PaginatableRepositoryInterface
1213
{
1314
use CursorPaginationTrait;
15+
16+
public function findByFilename(string $filename): ?TemplateImage
17+
{
18+
return $this->createQueryBuilder('ti')
19+
->where('ti.filename = :filename')
20+
->setParameter('filename', $filename)
21+
->andWhere('ti.template = 0')
22+
->getQuery()
23+
->getOneOrNullResult();
24+
}
25+
26+
public function findById(int $id): ?TemplateImage
27+
{
28+
return $this->createQueryBuilder('ti')
29+
->where('ti.id = :id')
30+
->setParameter('id', $id)
31+
->andWhere('ti.template = 0')
32+
->getQuery()
33+
->getOneOrNullResult();
34+
}
1435
}

0 commit comments

Comments
 (0)