diff --git a/library/Class/DigitalResource.php b/library/Class/DigitalResource.php index af4bfad3897d0240e92e3af927f52dbd562b22b3..3694e4ef14ed87efa0253b56f0f2c99ae99ab32e 100644 --- a/library/Class/DigitalResource.php +++ b/library/Class/DigitalResource.php @@ -463,9 +463,15 @@ class Class_DigitalResource_Wrapper { class Class_DigitalResource_ConfigProvider { + protected static $_known_classes = []; + public function getConfig($digital_resource, $class_name, $plugin) { - if(!@class_exists($class_name)) + if (!isset(static::$_known_classes[$class_name])) + static::$_known_classes[$class_name] = @class_exists($class_name); + + if (!static::$_known_classes[$class_name]) return null; + return new $class_name(new Class_DigitalResource_Wrapper($digital_resource, $plugin)); } } diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 5481adec376ce255091e131ea304e0512092d526..2ef0e1d3c6b3c7a22aa1980a49f983555068a690 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -109,9 +109,10 @@ class NoticeLoader extends Storm_Model_Loader { } - public function getAllNoticesByClefChapeau($clef) { - return Class_Notice::findAllBy(['clef_chapeau' => $clef, - 'order' => 'tome_alpha desc']); + public function getAllNoticesByClefChapeau($clef, $conditions) { + return Class_Notice::findAllBy(array_merge($conditions, + ['clef_chapeau' => $clef, + 'order' => 'tome_alpha desc'])); } @@ -228,7 +229,8 @@ class Class_Notice extends Storm_Model_Abstract { $_first_exemplaire, $_data_map, $_collation, - $_main_author_cache; + $_main_author_cache, + $_same_serie_records; protected $_default_attribute_values = ['type_doc' => 0, 'annee' => null, @@ -815,10 +817,15 @@ class Class_Notice extends Storm_Model_Abstract { public function getNoticesMemeSeries() { + if (isset($this->_same_serie_records)) + return $this->_same_serie_records; + if (!$this->hasSerie()) - return []; + return $this->_same_serie_records = []; - return $this->getLoader()->getAllNoticesByClefChapeau($this->getClefChapeau()); + return $this->_same_serie_records = $this->getLoader() + ->getAllNoticesByClefChapeau($this->getClefChapeau(), + ['limit' => 20]); } diff --git a/library/Class/Notice/Facettes.php b/library/Class/Notice/Facettes.php index eb9ea2a6b30b49e76ddd431b7f9a63633f4fbcb6..e476cfee5f1c89e23796412ff2394199cb6046ae 100644 --- a/library/Class/Notice/Facettes.php +++ b/library/Class/Notice/Facettes.php @@ -89,7 +89,7 @@ class Class_Notice_Facettes { return $this->_record->getExemplaires(); $clef_chapeau = Class_Indexation::getInstance()->codeAlphaTitre($this->_record->getTitrePrincipal()); - $records = Class_Notice::getAllNoticesByClefChapeau($clef_chapeau); + $records = Class_Notice::getAllNoticesByClefChapeau($clef_chapeau, ['limit' => 20]); $record_ids = (new Storm_Model_Collection($records))->collect('id'); if ($record_ids->isEmpty()) diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 09f176d8cda985718b58f7eb49e12c3943970ea9..f045df6c1234ad43066c23b5568d8ce9fbb7f56b 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -1332,7 +1332,8 @@ class NoticeAjaxControllerDVDSeriesTest extends AbstractControllerTestCase { Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') ->whenCalled('findAllBy') ->with(['clef_chapeau' => 'OZ', - 'order' => 'tome_alpha desc']) + 'order' => 'tome_alpha desc', + 'limit' => 20]) ->answers([$oz_season2, $oz_season3]); @@ -1415,7 +1416,8 @@ class NoticeAjaxControllerPeriodiqueSerieTest extends NoticeAjaxControllerPeriod $this->onLoaderOfModel(Class_Notice::class) ->whenCalled('findAllBy') ->with(['clef_chapeau' => 'FAKIR', - 'order' => 'tome_alpha desc']) + 'order' => 'tome_alpha desc', + 'limit' => 20]) ->answers([$this->_fakir_56, $this->_fakir_57]); $this->dispatch('/noticeajax/series/id_notice/234');