Skip to content
Snippets Groups Projects

Master

Merged Patrick Barroca requested to merge master into WIP
Compare and
4 files
+ 38
11
Preferences
Compare changes
Files
4
@@ -21,6 +21,33 @@
class Class_Migration_ArteVODAuthorsOrder {
use Trait_MemoryCleaner;
public function updateAuthorsForAllAlbums($closure=null) {
try {
$page = 0;
while($albums = Class_Album::findAllBy(['type_doc_id' => Class_TypeDoc::ARTEVOD,
'order' => 'id',
'limitPage' => [$page, 500]])) {
$this->_runPage($albums, $closure);
$this->_cleanMemory();
$page++;
}
} catch(Exception $e) {
return;
}
}
protected function _runPage($albums, $closure) {
foreach($albums as $album) {
$this->updateAuthors($album);
if ($closure)
$closure($album);
}
}
public function updateAuthors($album) {
$old_authors = new Storm_Collection($album->getAuthors());
$album->getMarc()->clearZone('701');
@@ -36,15 +63,6 @@ class Class_Migration_ArteVODAuthorsOrder {
}
public function updateAuthorsForAllAlbums($closure=null) {
foreach(Class_Album::findAllBy(['type_doc_id' => Class_TypeDoc::ARTEVOD]) as $album) {
$this->updateAuthors($album);
if ($closure)
$closure($album);
}
}
protected function addAuthorsTo($authors, $closure, $album) {
$authors->select($closure)
->eachDo(function ($author) use ($album)