From 56bcde63301fbf146c497357e7351a54fb606eaa Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Fri, 8 Oct 2021 10:53:39 +0200 Subject: [PATCH] dev #142642 Page indexation : add work key --- VERSIONS_WIP/142642 | 1 + .../Class/Indexation/PseudoNotice/WorkKey.php | 18 ++++++++++++++++-- .../IndexablePagesPseudoRecordTest.php | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 VERSIONS_WIP/142642 diff --git a/VERSIONS_WIP/142642 b/VERSIONS_WIP/142642 new file mode 100644 index 00000000000..5cf5f85e3e1 --- /dev/null +++ b/VERSIONS_WIP/142642 @@ -0,0 +1 @@ + - ticket #142642 : Indexation des pages : création d'une clé œuvre pour la notice générée \ No newline at end of file diff --git a/library/Class/Indexation/PseudoNotice/WorkKey.php b/library/Class/Indexation/PseudoNotice/WorkKey.php index c2d169eef09..ae59d3dda45 100644 --- a/library/Class/Indexation/PseudoNotice/WorkKey.php +++ b/library/Class/Indexation/PseudoNotice/WorkKey.php @@ -37,7 +37,8 @@ class Class_Indexation_PseudoNotice_WorkKey { $map = [Class_Album::class => Class_Indexation_PseudoNotice_WorkKeyAlbum::class, Class_Sitotheque::class => Class_Indexation_PseudoNotice_WorkKeyTitre::class, Class_Article::class => Class_Indexation_PseudoNotice_WorkKeyCms::class, - Class_Rss::class => Class_Indexation_PseudoNotice_WorkKeyTitre::class]; + Class_Rss::class => Class_Indexation_PseudoNotice_WorkKeyTitre::class, + Class_Profil::class => Class_Indexation_PseudoNotice_WorkKeyPage::class]; foreach($map as $model_class => $key_class) if (is_a($model, $model_class)) @@ -99,6 +100,19 @@ class Class_Indexation_PseudoNotice_WorkKeyTitre extends Class_Indexation_Pseudo +class Class_Indexation_PseudoNotice_WorkKeyPage extends Class_Indexation_PseudoNotice_WorkKey { + public function _record() { + return new Class_Entity(['TitrePrincipal' => $this->_model->getTitre(), + 'ComplementTitre' => '', + 'AuteurClefAlpha' => $this->_model->isInPortail() + ? 'Portal' + : $this->_model->getBibLibelle(), + 'TomeAlpha' => $this->_model->getId()]); + } +} + + + class Class_Indexation_PseudoNotice_WorkKeyCms extends Class_Indexation_PseudoNotice_WorkKey { public function _record() { @@ -107,4 +121,4 @@ class Class_Indexation_PseudoNotice_WorkKeyCms extends Class_Indexation_PseudoNo 'AuteurClefAlpha' => $this->_model->getAuthorName(), 'TomeAlpha' => '']); } -} \ No newline at end of file +} diff --git a/tests/scenarios/IndexablePages/IndexablePagesPseudoRecordTest.php b/tests/scenarios/IndexablePages/IndexablePagesPseudoRecordTest.php index 8b3d47de548..d0773f15b07 100644 --- a/tests/scenarios/IndexablePages/IndexablePagesPseudoRecordTest.php +++ b/tests/scenarios/IndexablePages/IndexablePagesPseudoRecordTest.php @@ -118,6 +118,24 @@ class IndexablePagesPseudoRecordEnabledIndexableTest extends ModelTestCase { } + /** @test */ + public function recordWorkKeyShouldBeMysuperpage_Portal_233() { + $this->assertEquals('MYSUPERPAGE--PORTAL-233', + $this->_record->getClefOeuvre()); + } + + + /** @test */ + public function withPageInLibraryAnnecyShouldBeMysuperpage_Annecy_233() { + $this->_page->setBib($this->fixture(Class_Bib::class, + ['id' => 3, + 'libelle' => 'Annecy'])) + ->index(); + $this->assertEquals('MYSUPERPAGE--ANNECY-233', + $this->_page->getNotice()->getClefOeuvre()); + } + + /** @test */ public function recordTitleShouldBeMySuperPage() { $this->assertEquals('My super page', $this->_record->getTitrePrincipal()); -- GitLab