3
0

Compare commits

...

6 Commits

Author SHA1 Message Date
brabli efc9b17136 Fix outdated code 2026-05-05 11:00:43 +01:00
brabli d3de91ea0b Update deps 2026-05-05 11:00:29 +01:00
brabli f9700e1959 Add general composer command 2026-05-05 10:41:53 +01:00
brabli 92bd22ad99 Update container php ver 2026-05-05 10:41:46 +01:00
brabli 5548df12bd Replace makefile with justfile 2026-05-05 10:38:28 +01:00
mf 6e2c241349 Adding formatting 2023-01-09 16:19:16 +00:00
8 changed files with 42 additions and 53 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM php:8.1-alpine
FROM php:8.4-alpine
WORKDIR /code
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
-16
View File
@@ -1,16 +0,0 @@
PHP = docker compose run php
.PHONY: composer_install composer_update static_analysis tests
composer_install:
@$(PHP) composer install
composer_update:
@$(PHP) composer update
static_analysis:
@$(PHP) vendor/bin/psalm
tests:
@$(PHP) rm -rf var/cache
@$(PHP) vendor/bin/phpunit
+9 -8
View File
@@ -3,16 +3,17 @@
"description": "Provides a search system for Symfony projects",
"type": "symfony-bundle",
"require": {
"php": ">=8.0",
"beberlei/doctrineextensions": "^1.3",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/orm": "^2.12",
"symfony/framework-bundle": "*"
"php": ">=8.2",
"beberlei/doctrineextensions": "^1.5",
"doctrine/doctrine-bundle": "^2.13",
"doctrine/orm": "^2.20 || ^3.3",
"doctrine/persistence": "^3.3 || ^4.0",
"symfony/framework-bundle": "^6.4 || ^7.0"
},
"require-dev": {
"vimeo/psalm": "^4.24",
"psalm/plugin-symfony": "^3.1",
"phpunit/phpunit": "^9.5"
"vimeo/psalm": "^6.0",
"psalm/plugin-symfony": "^5.2",
"phpunit/phpunit": "^11.0 || ^12.0"
},
"autoload": {
"psr-4": {
+1 -5
View File
@@ -8,11 +8,7 @@ services:
tags:
- { name: 'console.command', command: 'pcm:search:reindex' }
pcm_search.searchable_subscriber:
class: Pcm\SearchBundle\EventSubscriber\SearchableSubscriber
public: true
tags:
- { name: doctrine.event_subscriber }
Pcm\SearchBundle\EventSubscriber\SearchableSubscriber: ~
pcm_search.search_service:
alias: Pcm\SearchBundle\Service\SearchService
+17
View File
@@ -0,0 +1,17 @@
php := "docker compose run php"
composer-install:
@{{php}} composer install
composer-update:
@{{php}} composer update
composer *args:
@{{php}} composer {{args}}
static-analysis:
@{{php}} vendor/bin/psalm
tests:
@{{php}} rm -rf var/cache
@{{php}} vendor/bin/phpunit
+1
View File
@@ -84,6 +84,7 @@ class SearchIndexCommand extends Command
}
$progress_bar->finish();
$io->writeln('');
$table = new Table($output);
$table
+11 -15
View File
@@ -6,24 +6,20 @@ namespace Pcm\SearchBundle\EventSubscriber;
use Pcm\SearchBundle\Entity\Interface\SearchableInterface;
use Pcm\SearchBundle\Service\SearchService;
use Doctrine\Common\EventSubscriber;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Doctrine\ORM\Event\PreRemoveEventArgs;
use Doctrine\ORM\Events;
class SearchableSubscriber implements EventSubscriber
#[AsDoctrineListener(event: Events::postPersist)]
#[AsDoctrineListener(event: Events::postUpdate)]
#[AsDoctrineListener(event: Events::preRemove)]
class SearchableSubscriber
{
public function __construct(private SearchService $searchService) {}
public function getSubscribedEvents(): array
{
return [
Events::postPersist,
Events::postUpdate,
Events::preRemove
];
}
public function postUpdate(LifecycleEventArgs $args)
public function postUpdate(PostUpdateEventArgs $args): void
{
$entity = $args->getObject();
@@ -32,7 +28,7 @@ class SearchableSubscriber implements EventSubscriber
}
}
public function postPersist(LifecycleEventArgs $args)
public function postPersist(PostPersistEventArgs $args): void
{
$entity = $args->getObject();
@@ -41,7 +37,7 @@ class SearchableSubscriber implements EventSubscriber
}
}
public function preRemove(LifecycleEventArgs $args)
public function preRemove(PreRemoveEventArgs $args): void
{
$entity = $args->getObject();
+2 -8
View File
@@ -6,9 +6,7 @@ namespace Pcm\SearchBundle\Service;
use Pcm\SearchBundle\Entity\SearchIndex;
use Pcm\SearchBundle\Entity\Interface\SearchableInterface;
use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Proxy\Proxy;
class SearchService
{
@@ -38,7 +36,7 @@ class SearchService
*/
public function unIndex(SearchableInterface $entity)
{
$class = get_class($entity);
$class = $this->em->getClassMetadata($entity::class)->getName();
$search_result = $this
->em
@@ -69,11 +67,7 @@ class SearchService
$data = implode(' ', $values);
$class = get_class($entity);
if ($entity instanceof Proxy) {
$class = ClassUtils::getRealClass($class);
}
$class = $this->em->getClassMetadata($entity::class)->getName();
$searchResult = $this
->em