Skip to content
Snippets Groups Projects
Commit ece324c2 authored by Laurent's avatar Laurent
Browse files

rel #32494 album web site: automatic creation of website category

parent 9cc5025f
6 merge requests!1553Master,!1502Master,!1501Stable,!1289Master,!1286Dev#32494 sitotheque utiliser l interface album pour creer une sitotheque,!1269Dev#32494 sitotheque utiliser l interface album pour creer une sitotheque
......@@ -71,7 +71,10 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
$html = (new Class_WebService_SimpleWebClient())->open_url($url);
$dom = new Zend_Dom_Query($html);
$album = Class_Album::newInstance(['type_doc_id' => Class_TypeDoc::WEBSITE]);
$category = Class_AlbumCategorie::getOrCreateRootCategory('Sites web');
$album = Class_Album::newInstance(['type_doc_id' => Class_TypeDoc::WEBSITE,
'categorie' => $category]);
$album->setTitre($dom->queryXpath('//head/title')->current()->textContent);
$description_node = $dom->queryXpath('//head/meta[@name="description"]')->current();
......
......@@ -20,6 +20,18 @@
*/
class AlbumCategorieLoader extends Storm_Model_Loader {
public function getOrCreateRootCategory($label) {
if ($category = Class_AlbumCategorie::findFirstBy(['libelle' => $label,
'parent_id' => 0]))
return $category;
$category = Class_AlbumCategorie::newInstance(['libelle' => $label]);
$category->save();
return $category;
}
/**
* @return array
*/
......
......@@ -634,6 +634,12 @@ class SitothequeControllerImportFromUrlTest extends AbstractControllerTestCase {
}
/** @test */
public function albumCategorieShouldBeWebsite() {
$this->assertEquals('Sites web', $this->_cned->getCategorie()->getLibelle());
}
/** @test */
public function albumShouldHaveOneResourceWithUrlCnedDotFr() {
$this->assertNotNull($resource = $this->_cned->getRessources()[0]);
......
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