Skip to content
Open

Dev #159

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,26 @@
"role": "Maintainer"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/TatevikGr/rss-bundle.git"
}
],
"support": {
"issues": "https://github.com/phpList/rest-api/issues",
"forum": "https://discuss.phplist.org/",
"source": "https://github.com/phpList/rest-api"
},
"require": {
"php": "^8.1",
"phplist/core": "dev-main",
"phplist/core": "dev-dev",
"friendsofsymfony/rest-bundle": "*",
"symfony/test-pack": "^1.0",
"symfony/process": "^6.4",
"zircote/swagger-php": "^4.11",
"ext-dom": "*"
"ext-dom": "*",
"tatevikgr/rss-feed": "dev-main as 0.1.0"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
Expand Down Expand Up @@ -123,5 +130,10 @@
}
}
}
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
10 changes: 7 additions & 3 deletions config/services/managers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ services:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\MessageManager:
PhpList\Core\Domain\Messaging\Service\Manager\MessageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\TemplateManager:
PhpList\Core\Domain\Messaging\Service\Manager\TemplateManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\TemplateImageManager:
PhpList\Core\Domain\Messaging\Service\Manager\TemplateImageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\Manager\BounceRegexManager:
autowire: true
autoconfigure: true

Expand Down
5 changes: 5 additions & 0 deletions config/services/messenger_handlers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
PhpList\Core\Domain\Messaging\MessageHandler\CampaignProcessorMessageHandler:
autowire: true
autoconfigure: true
public: false
12 changes: 12 additions & 0 deletions config/services/normalizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,15 @@ services:
PhpList\RestBundle\Statistics\Serializer\TopLocalPartsNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true

PhpList\RestBundle\Subscription\Serializer\UserBlacklistNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true

PhpList\RestBundle\Subscription\Serializer\SubscribePageNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true

PhpList\RestBundle\Messaging\Serializer\BounceRegexNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\AdminAttributeDefinition;
use PhpList\Core\Domain\Identity\Service\AdminAttributeDefinitionManager;
Expand Down Expand Up @@ -32,7 +33,8 @@ public function __construct(
RequestValidator $validator,
AdminAttributeDefinitionManager $definitionManager,
AdminAttributeDefinitionNormalizer $normalizer,
PaginatedDataProvider $paginatedDataProvider
PaginatedDataProvider $paginatedDataProvider,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);
$this->definitionManager = $definitionManager;
Expand Down Expand Up @@ -89,6 +91,8 @@ public function create(Request $request): JsonResponse
$definitionRequest = $this->validator->validate($request, CreateAttributeDefinitionRequest::class);

$attributeDefinition = $this->definitionManager->create($definitionRequest->getDto());
$this->entityManager->flush();

$json = $this->normalizer->normalize($attributeDefinition, 'json');

return $this->json($json, Response::HTTP_CREATED);
Expand Down Expand Up @@ -156,6 +160,7 @@ public function update(
attributeDefinition: $attributeDefinition,
attributeDefinitionDto: $definitionRequest->getDto(),
);
$this->entityManager->flush();
$json = $this->normalizer->normalize($attributeDefinition, 'json');

return $this->json($json, Response::HTTP_OK);
Expand Down Expand Up @@ -211,6 +216,7 @@ public function delete(
}

$this->definitionManager->delete($attributeDefinition);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down
9 changes: 8 additions & 1 deletion src/Identity/Controller/AdminAttributeValueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\Filter\AdminAttributeValueFilter;
use PhpList\Core\Domain\Identity\Model\Administrator;
Expand All @@ -27,18 +28,21 @@ class AdminAttributeValueController extends BaseController
private AdminAttributeManager $attributeManager;
private AdminAttributeValueNormalizer $normalizer;
private PaginatedDataProvider $paginatedDataProvider;
private EntityManagerInterface $entityManager;

public function __construct(
Authentication $authentication,
RequestValidator $validator,
AdminAttributeManager $attributeManager,
AdminAttributeValueNormalizer $normalizer,
PaginatedDataProvider $paginatedDataProvider
PaginatedDataProvider $paginatedDataProvider,
EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);
$this->attributeManager = $attributeManager;
$this->normalizer = $normalizer;
$this->paginatedDataProvider = $paginatedDataProvider;
$this->entityManager = $entityManager;
}

#[Route(
Expand Down Expand Up @@ -122,6 +126,7 @@ public function createOrUpdate(
definition: $definition,
value: $request->toArray()['value'] ?? null
);
$this->entityManager->flush();
$json = $this->normalizer->normalize($attributeDefinition, 'json');

return $this->json($json, Response::HTTP_CREATED);
Expand Down Expand Up @@ -193,6 +198,7 @@ public function delete(
throw $this->createNotFoundException('Administrator attribute not found.');
}
$this->attributeManager->delete($attribute);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down Expand Up @@ -350,6 +356,7 @@ public function getAttributeDefinition(
attributeDefinitionId: $definition->getId()
);
$this->attributeManager->delete($attribute);
$this->entityManager->flush();

return $this->json(
$this->normalizer->normalize($attribute),
Expand Down
7 changes: 6 additions & 1 deletion src/Identity/Controller/AdministratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\Administrator;
use PhpList\Core\Domain\Identity\Service\AdministratorManager;
Expand Down Expand Up @@ -35,7 +36,8 @@ public function __construct(
RequestValidator $validator,
AdministratorManager $administratorManager,
AdministratorNormalizer $normalizer,
PaginatedDataProvider $paginatedProvider
PaginatedDataProvider $paginatedProvider,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);
$this->administratorManager = $administratorManager;
Expand Down Expand Up @@ -149,6 +151,7 @@ public function createAdministrator(
$createRequest = $validator->validate($request, CreateAdministratorRequest::class);

$administrator = $this->administratorManager->createAdministrator($createRequest->getDto());
$this->entityManager->flush();
$json = $normalizer->normalize($administrator, 'json');

return $this->json($json, Response::HTTP_CREATED);
Expand Down Expand Up @@ -255,6 +258,7 @@ public function updateAdministrator(
/** @var UpdateAdministratorRequest $updateRequest */
$updateRequest = $this->validator->validate($request, UpdateAdministratorRequest::class);
$this->administratorManager->updateAdministrator($administrator, $updateRequest->getDto());
$this->entityManager->flush();

return $this->json($this->normalizer->normalize($administrator), Response::HTTP_OK);
}
Expand Down Expand Up @@ -303,6 +307,7 @@ public function deleteAdministrator(
throw $this->createNotFoundException('Administrator not found.');
}
$this->administratorManager->deleteAdministrator($administrator);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Identity/Controller/PasswordResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Service\PasswordManager;
use PhpList\Core\Security\Authentication;
Expand All @@ -29,6 +30,7 @@ public function __construct(
Authentication $authentication,
RequestValidator $validator,
PasswordManager $passwordManager,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);

Expand Down Expand Up @@ -74,6 +76,7 @@ public function requestPasswordReset(Request $request): JsonResponse
$resetRequest = $this->validator->validate($request, RequestPasswordResetRequest::class);

$this->passwordManager->generatePasswordResetToken($resetRequest->email);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down Expand Up @@ -117,6 +120,7 @@ public function validateToken(Request $request): JsonResponse
$validateRequest = $this->validator->validate($request, ValidateTokenRequest::class);

$administrator = $this->passwordManager->validatePasswordResetToken($validateRequest->token);
$this->entityManager->flush();

return $this->json([ 'valid' => $administrator !== null]);
}
Expand Down Expand Up @@ -169,6 +173,7 @@ public function resetPassword(Request $request): JsonResponse
$resetRequest->token,
$resetRequest->newPassword
);
$this->entityManager->flush();

if ($success) {
return $this->json([ 'message' => 'Password updated successfully']);
Expand Down
4 changes: 4 additions & 0 deletions src/Identity/Controller/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\AdministratorToken;
use PhpList\Core\Domain\Identity\Service\SessionManager;
Expand Down Expand Up @@ -34,6 +35,7 @@ public function __construct(
Authentication $authentication,
RequestValidator $validator,
SessionManager $sessionManager,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);

Expand Down Expand Up @@ -96,6 +98,7 @@ public function createSession(
loginName:$createSessionRequest->loginName,
password: $createSessionRequest->password
);
$this->entityManager->flush();

$json = $normalizer->normalize($token, 'json');

Expand Down Expand Up @@ -163,6 +166,7 @@ public function deleteSession(
}

$this->sessionManager->deleteSession($token);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down
Loading
Loading