diff --git a/app/config/services.yml b/app/config/services.yml index c427f3610..7dee53644 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -322,7 +322,8 @@ services: AppBundle\Routing\LegacyRouter: autowire: true - AlgoliaSearch\Client: + Algolia\AlgoliaSearch\SearchClient: + factory: [ Algolia\AlgoliaSearch\SearchClient, create ] arguments: ["%algolia_app_id%", "%algolia_backend_api_key%"] AppBundle\Joindin\JoindinComments: diff --git a/composer.json b/composer.json index a8b30a001..fea7c4354 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "ext-json": "*", "ext-libxml": "*", "ext-openssl": "*", - "algolia/algoliasearch-client-php": "^1.12", + "algolia/algoliasearch-client-php": "^3.4", "beberlei/assert": "^2.9", "captioning/captioning": "^2.6", "ccmbenchmark/ting_bundle": "3.4.1", diff --git a/composer.lock b/composer.lock index 3ca321ac9..ce68a66b0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,31 +4,43 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e837825c26c89e1148ab591c5c3db9da", + "content-hash": "6f80c056e0d1c12771ebc7a6a3582164", "packages": [ { "name": "algolia/algoliasearch-client-php", - "version": "1.28.1", + "version": "3.4.2", "source": { "type": "git", "url": "https://github.com/algolia/algoliasearch-client-php.git", - "reference": "43b0b0dc64e2d0f206d903ad3a4fb8b0a3660f81" + "reference": "7505959737f7944507be7ef476752ad761873c4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/43b0b0dc64e2d0f206d903ad3a4fb8b0a3660f81", - "reference": "43b0b0dc64e2d0f206d903ad3a4fb8b0a3660f81", + "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/7505959737f7944507be7ef476752ad761873c4a", + "reference": "7505959737f7944507be7ef476752ad761873c4a", "shasum": "" }, "require": { "ext-curl": "*", + "ext-json": "*", "ext-mbstring": "*", - "php": "^5.3 || ^7.0" + "php": "^7.3 || ^8.0", + "psr/http-message": "^1.1 || ^2.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "satooshi/php-coveralls": "^1.0" + "friendsofphp/php-cs-fixer": "^2.0", + "fzaninotto/faker": "^1.8", + "phpunit/phpunit": "^8.0 || ^9.0", + "symfony/yaml": "^2.0 || ^4.0" + }, + "suggest": { + "guzzlehttp/guzzle": "If you prefer to use Guzzle HTTP client instead of the Http Client implementation provided by the package" }, + "bin": [ + "bin/algolia-doctor" + ], "type": "library", "extra": { "branch-alias": { @@ -36,8 +48,12 @@ } }, "autoload": { - "psr-0": { - "AlgoliaSearch": "src/" + "files": [ + "src/Http/Psr7/functions.php", + "src/functions.php" + ], + "psr-4": { + "Algolia\\AlgoliaSearch\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -48,23 +64,21 @@ { "name": "Algolia Team", "email": "contact@algolia.com" - }, - { - "name": "Jonathan H. Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Ryan T. Catlin", - "email": "ryan.catlin@gmail.com" } ], "description": "Algolia Search API Client for PHP", - "homepage": "https://github.com/algolia/algoliasearch-client-php", + "keywords": [ + "algolia", + "api", + "client", + "php", + "search" + ], "support": { "issues": "https://github.com/algolia/algoliasearch-client-php/issues", - "source": "https://github.com/algolia/algoliasearch-client-php/tree/1.28.1" + "source": "https://github.com/algolia/algoliasearch-client-php/tree/3.4.2" }, - "time": "2020-06-03T15:36:28+00:00" + "time": "2025-01-22T11:13:54+00:00" }, { "name": "aura/sqlquery", @@ -492,6 +506,77 @@ }, "time": "2017-03-23T21:52:55+00:00" }, + { + "name": "composer/pcre", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/1.0.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-21T20:24:37+00:00" + }, { "name": "cuyz/valinor", "version": "0.17.1", @@ -3631,16 +3716,16 @@ }, { "name": "nesbot/carbon", - "version": "2.72.6", + "version": "2.73.0", "source": { "type": "git", "url": "https://github.com/CarbonPHP/carbon.git", - "reference": "1e9d50601e7035a4c61441a208cb5bed73e108c5" + "reference": "9228ce90e1035ff2f0db84b40ec2e023ed802075" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/1e9d50601e7035a4c61441a208cb5bed73e108c5", - "reference": "1e9d50601e7035a4c61441a208cb5bed73e108c5", + "url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/9228ce90e1035ff2f0db84b40ec2e023ed802075", + "reference": "9228ce90e1035ff2f0db84b40ec2e023ed802075", "shasum": "" }, "require": { @@ -3734,7 +3819,7 @@ "type": "tidelift" } ], - "time": "2024-12-27T09:28:11+00:00" + "time": "2025-01-08T20:10:23+00:00" }, { "name": "nojimage/twitter-text-php", @@ -3932,19 +4017,20 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "1.29.8", + "version": "1.29.10", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "089ffdfc04b5fcf25a3503d81a4e589f247e20e3" + "reference": "c80041b1628c4f18030407134fe88303661d4e4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/089ffdfc04b5fcf25a3503d81a4e589f247e20e3", - "reference": "089ffdfc04b5fcf25a3503d81a4e589f247e20e3", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c80041b1628c4f18030407134fe88303661d4e4e", + "reference": "c80041b1628c4f18030407134fe88303661d4e4e", "shasum": "" }, "require": { + "composer/pcre": "^1||^2||^3", "ext-ctype": "*", "ext-dom": "*", "ext-fileinfo": "*", @@ -4031,9 +4117,9 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.8" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.10" }, - "time": "2025-01-12T03:16:27+00:00" + "time": "2025-02-08T02:56:14+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -7091,77 +7177,6 @@ }, "time": "2022-03-30T09:27:43+00:00" }, - { - "name": "composer/pcre", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/composer/pcre.git", - "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560", - "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.3", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Pcre\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "PCRE wrapping library that offers type-safe preg_* replacements.", - "keywords": [ - "PCRE", - "preg", - "regex", - "regular expression" - ], - "support": { - "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/1.0.1" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-01-21T20:24:37+00:00" - }, { "name": "composer/semver", "version": "3.4.3", @@ -7536,16 +7551,16 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.1", + "version": "2.1.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7" + "reference": "451b17f9665481ee502adc39be987cb71067ece2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", - "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/451b17f9665481ee502adc39be987cb71067ece2", + "reference": "451b17f9665481ee502adc39be987cb71067ece2", "shasum": "" }, "require": { @@ -7590,25 +7605,25 @@ "type": "github" } ], - "time": "2025-01-05T16:43:48+00:00" + "time": "2025-02-13T12:49:56+00:00" }, { "name": "rector/rector", - "version": "2.0.7", + "version": "2.0.9", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "e70d681f6a0c361a63e6825897cd97746436f015" + "reference": "4393230e478c0006795770fe74c223b5c64ed68c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/e70d681f6a0c361a63e6825897cd97746436f015", - "reference": "e70d681f6a0c361a63e6825897cd97746436f015", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/4393230e478c0006795770fe74c223b5c64ed68c", + "reference": "4393230e478c0006795770fe74c223b5c64ed68c", "shasum": "" }, "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.1" + "phpstan/phpstan": "^2.1.3" }, "conflict": { "rector/rector-doctrine": "*", @@ -7641,7 +7656,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/2.0.7" + "source": "https://github.com/rectorphp/rector/tree/2.0.9" }, "funding": [ { @@ -7649,7 +7664,7 @@ "type": "github" } ], - "time": "2025-01-19T09:41:28+00:00" + "time": "2025-02-10T08:14:01+00:00" }, { "name": "smalot/pdfparser", diff --git a/sources/AppBundle/Command/IndexMeetupsCommand.php b/sources/AppBundle/Command/IndexMeetupsCommand.php index ddbb340aa..ff9b3bfb9 100644 --- a/sources/AppBundle/Command/IndexMeetupsCommand.php +++ b/sources/AppBundle/Command/IndexMeetupsCommand.php @@ -4,8 +4,8 @@ namespace AppBundle\Command; -use AlgoliaSearch\AlgoliaException; -use AlgoliaSearch\Client; +use Algolia\AlgoliaSearch\Exceptions\AlgoliaException; +use Algolia\AlgoliaSearch\SearchClient; use AppBundle\Event\Model\Repository\MeetupRepository; use AppBundle\Indexation\Meetups\Runner; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; @@ -35,8 +35,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $container = $this->getContainer(); $ting = $this->getContainer()->get('ting'); - /** @var Client $algoliaClient */ - $algoliaClient = $container->get(Client::class); + /** @var SearchClient $algoliaClient */ + $algoliaClient = $container->get(SearchClient::class); $meetupRepository = $ting->get(MeetupRepository::class); if ($input->getOption('run-scraping')) { diff --git a/sources/AppBundle/Controller/Website/HomeController.php b/sources/AppBundle/Controller/Website/HomeController.php index a41b73f0d..12a6f766c 100644 --- a/sources/AppBundle/Controller/Website/HomeController.php +++ b/sources/AppBundle/Controller/Website/HomeController.php @@ -7,8 +7,9 @@ use Afup\Site\Corporate\Articles; use Afup\Site\Corporate\Branche; use Afup\Site\Corporate\Feuille; -use AlgoliaSearch\AlgoliaException; -use AlgoliaSearch\Client; +use Algolia\AlgoliaSearch\Exceptions\AlgoliaException; +use Algolia\AlgoliaSearch\SearchClient; +use AppBundle\Event\Model\Meetup; use AppBundle\Event\Model\Repository\TalkRepository; use AppBundle\Event\Model\Talk; use AppBundle\Twig\ViewRenderer; @@ -26,14 +27,14 @@ class HomeController extends AbstractController private LoggerInterface $logger; private RepositoryFactory $repositoryFactory; private AdapterInterface $traceableAdapter; - private Client $client; + private SearchClient $client; private bool $homeAlgoliaEnabled; public function __construct(ViewRenderer $view, LoggerInterface $logger, RepositoryFactory $repositoryFactory, AdapterInterface $traceableAdapter, - Client $client, + SearchClient $client, bool $homeAlgoliaEnabled) { $this->view = $view; @@ -65,18 +66,15 @@ public function display(): Response ]); } - /** - * @return Talk - */ - protected function getTalkOfTheDay() + protected function getTalkOfTheDay(): Talk { return $this->repositoryFactory->get(TalkRepository::class)->getTalkOfTheDay(new \DateTime()); } /** - * @return array + * @return array */ - protected function getLatestMeetups() + protected function getLatestMeetups(): array { if (!$this->homeAlgoliaEnabled) { return []; diff --git a/sources/AppBundle/Indexation/Meetups/Runner.php b/sources/AppBundle/Indexation/Meetups/Runner.php index be342933e..cea14d4af 100644 --- a/sources/AppBundle/Indexation/Meetups/Runner.php +++ b/sources/AppBundle/Indexation/Meetups/Runner.php @@ -4,9 +4,8 @@ namespace AppBundle\Indexation\Meetups; -use AlgoliaSearch\AlgoliaException; -use AlgoliaSearch\Client; -use AlgoliaSearch\Index; +use Algolia\AlgoliaSearch\SearchClient; +use Algolia\AlgoliaSearch\SearchIndex; use AppBundle\Antennes\AntennesCollection; use AppBundle\Event\Model\Meetup; use AppBundle\Event\Model\Repository\MeetupRepository; @@ -14,23 +13,19 @@ class Runner { - protected Client $algoliaClient; + protected SearchClient $algoliaClient; protected MeetupRepository $meetupRepository; protected Transformer $transformer; - public function __construct(Client $algoliaClient, MeetupRepository $meetupRepository) + public function __construct(SearchClient $algoliaClient, MeetupRepository $meetupRepository) { $this->algoliaClient = $algoliaClient; $this->meetupRepository = $meetupRepository; $this->transformer = new Transformer(new AntennesCollection()); } - /** - * - * @throws AlgoliaException - */ public function run(): void { $index = $this->initIndex(); @@ -39,17 +34,15 @@ public function run(): void $meetups = $this->getTransformedMeetupsFromDatabase(); - $index->clearIndex(); - $index->addObjects($meetups, 'meetup_id'); + $index->clearObjects(); + $index->saveObjects($meetups, [ + 'objectIDKey' => 'meetup_id' + ]); echo "Indexation des meetups terminée avec succès !\n"; } - /** - * @return Index - * @throws AlgoliaException - */ - protected function initIndex() + protected function initIndex(): SearchIndex { $index = $this->algoliaClient->initIndex('afup_meetups'); @@ -80,10 +73,9 @@ private function getTransformedMeetupsFromDatabase(): array } /** - * @param CollectionInterface $meetupsCollection * @return array */ - public function transformMeetupsForIndexation($meetupsCollection): array + public function transformMeetupsForIndexation(CollectionInterface $meetupsCollection): array { $meetupsArray = []; /** @var Meetup $meetup */ diff --git a/sources/AppBundle/Indexation/Talks/Runner.php b/sources/AppBundle/Indexation/Talks/Runner.php index afff5d417..69262ce79 100644 --- a/sources/AppBundle/Indexation/Talks/Runner.php +++ b/sources/AppBundle/Indexation/Talks/Runner.php @@ -4,8 +4,8 @@ namespace AppBundle\Indexation\Talks; -use AlgoliaSearch\Client; -use AlgoliaSearch\Index; +use Algolia\AlgoliaSearch\SearchClient; +use Algolia\AlgoliaSearch\SearchIndex; use AppBundle\Event\Model\Planning; use AppBundle\Event\Model\Repository\EventRepository; use AppBundle\Event\Model\Repository\PlanningRepository; @@ -15,22 +15,19 @@ class Runner { - protected Client $algoliaClient; + protected SearchClient $algoliaClient; protected RepositoryFactory $ting; protected Transformer $transformer; - public function __construct(Client $algoliaClient, RepositoryFactory $ting) + public function __construct(SearchClient $algoliaClient, RepositoryFactory $ting) { $this->algoliaClient = $algoliaClient; $this->ting = $ting; $this->transformer = new Transformer(); } - /** - * - */ public function run(): void { $index = $this->initIndex(); @@ -45,14 +42,13 @@ public function run(): void $objects[] = $object; } - $index->clearIndex(); - $index->addObjects($objects, 'planning_id'); + $index->clearObjects(); + $index->saveObjects($objects, [ + 'objectIDKey' => 'planning_id' + ]); } - /** - * @return Index - */ - protected function initIndex() + protected function initIndex(): SearchIndex { $index = $this->algoliaClient->initIndex('afup_talks');