Skip to content
Snippets Groups Projects
Commit 74d44641 authored by Patrick Barroca's avatar Patrick Barroca
Browse files

rel #30704: factory extraction

parent dc4719c0
Branches
Tags
6 merge requests!1659Master,!1618Master,!1610Dev#35088 oai import in cosmogramme,!1595Master,!1588Hotline#30704 supprimer la vignette d un album ne supprime pas l information de vignette de la pseudonotice,!1569Hotline#30704 supprimer la vignette d un album ne supprime pas l information de vignette de la pseudonotice
......@@ -34,7 +34,7 @@ class Class_Indexation_PseudoNotice {
public static function index($model) {
$instance = self::newWith($model);
$instance = (new Class_Indexation_PseudoNoticeFactory())->buildFrom($model);
return ($instance->isValid()) ? $instance->save() : false;
}
......@@ -47,36 +47,18 @@ class Class_Indexation_PseudoNotice {
}
public static function newWith($model) {
$type_doc = $model->getTypeDocId();
// types simples
$mapping = [Class_TypeDoc::ARTICLE => 'Cms',
Class_TypeDoc::RSS => 'Rss',
Class_TypeDoc::SITE=> 'Sito'];
if (array_key_exists($type_doc, $mapping)) {
$class_name = 'Class_Indexation_PseudoNotice_' . $mapping[$type_doc];
return new $class_name($model);
}
// bibnum
if (99 < $type_doc)
return new Class_Indexation_PseudoNotice_Album($model);
return new Class_Indexation_PseudoNotice_Null();
}
public function __construct($model) {
$this->_model = $model;
$this->_type_doc = $model->getTypeDocId();
$this->_datas = array_change_key_case($model->toArray(), CASE_LOWER);
}
public function getId() {
return $this->_notice->getId();
}
public function getUnimarc() {
return $this->_notice->getUnimarc();
}
......
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Indexation_PseudoNoticeFactory {
public function buildFrom($model) {
$type_doc = $model->getTypeDocId();
// types simples
$mapping = [Class_TypeDoc::ARTICLE => 'Cms',
Class_TypeDoc::RSS => 'Rss',
Class_TypeDoc::SITE=> 'Sito'];
if (array_key_exists($type_doc, $mapping)) {
$class_name = 'Class_Indexation_PseudoNotice_' . $mapping[$type_doc];
return new $class_name($model);
}
// bibnum
return (99 < $type_doc)
? new Class_Indexation_PseudoNotice_Album($model)
: new Class_Indexation_PseudoNotice_Null();
}
}
\ No newline at end of file
......@@ -21,6 +21,8 @@
trait Trait_HasManyDomaines {
public function index()
public function setDomaineIds($domaines) {
if (is_array($domaines))
$domaines=implode(';', array_unique($domaines));
......
......@@ -114,9 +114,7 @@ class Class_Indexation_PseudoNoticeSitothequeFromRawSQLTest extends Class_Indexa
'description' => 'Top notch site',
'tags' => 'VOD']);
/** as done in Cosmogramme */
Class_Indexation_PseudoNotice::newWith($sito)->save();
$sito->index();
$this->_notice = Class_Notice::find(1);
}
......@@ -146,8 +144,9 @@ class Class_Indexation_PseudoNoticeCmsTest extends Class_Indexation_PseudoNotice
$article = $this->fixture('Class_Article',
['id' => 43,
'titre' => 'Festival Animation',
'contenu' => 'à Annecy']);
Class_Indexation_PseudoNotice::newWith($article)->save();
'contenu' => 'à Annecy',
'status']);
$article->beValidated()->index();
$this->_notice = Class_Notice::find(1);
}
......@@ -179,8 +178,7 @@ class Class_Indexation_PseudoNoticeSitothequeTest extends Class_Indexation_Pseud
'description' => 'Top notch site',
'tags' => 'VOD']);
Class_Indexation_PseudoNotice::newWith($this->_sito)->save();
$this->_sito->index();
$this->_notice = $this->_sito->getNotice();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment