mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
buildsubdef with worker
This commit is contained in:
@@ -133,9 +133,9 @@ $cli->command(new QueryParseCommand());
|
|||||||
$cli->command(new QuerySampleCommand());
|
$cli->command(new QuerySampleCommand());
|
||||||
$cli->command(new FindConceptsCommand());
|
$cli->command(new FindConceptsCommand());
|
||||||
|
|
||||||
$cli->command($cli['alchemy_worker.commands.run_dispatcher_command']);
|
//$cli->command($cli['alchemy_worker.commands.run_dispatcher_command']);
|
||||||
$cli->command($cli['alchemy_worker.commands.run_worker_command']);
|
//$cli->command($cli['alchemy_worker.commands.run_worker_command']);
|
||||||
$cli->command($cli['alchemy_worker.commands.show_configuration']);
|
//$cli->command($cli['alchemy_worker.commands.show_configuration']);
|
||||||
|
|
||||||
$cli->loadPlugins();
|
$cli->loadPlugins();
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@ namespace Alchemy\Phrasea\Border;
|
|||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Border\Checker\CheckerInterface;
|
use Alchemy\Phrasea\Border\Checker\CheckerInterface;
|
||||||
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
|
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionBuildEvent;
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\TfArchivedate;
|
use Alchemy\Phrasea\Metadata\Tag\TfArchivedate;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\TfQuarantine;
|
use Alchemy\Phrasea\Metadata\Tag\TfQuarantine;
|
||||||
@@ -333,7 +335,7 @@ class Manager
|
|||||||
$this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element);
|
$this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element);
|
||||||
|
|
||||||
if(!$nosubdef) {
|
if(!$nosubdef) {
|
||||||
$element->rebuild_subdefs();
|
$this->app['dispatcher']->dispatch(RecordEvents::SUBDEFINITION_BUILD, new SubdefinitionBuildEvent($element, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $element;
|
return $element;
|
||||||
|
@@ -14,6 +14,8 @@ use Alchemy\Phrasea\Application\Helper\EntityManagerAware;
|
|||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||||
use Alchemy\Phrasea\Controller\Exception as ControllerException;
|
use Alchemy\Phrasea\Controller\Exception as ControllerException;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionBuildEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEdit;
|
use Alchemy\Phrasea\Core\Event\RecordEdit;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Model\Entities\StoryWZ;
|
use Alchemy\Phrasea\Model\Entities\StoryWZ;
|
||||||
@@ -68,7 +70,9 @@ class StoryController extends Controller
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$story->set_metadatas($metadatas)->rebuild_subdefs();
|
$recordAdapter = $story->set_metadatas($metadatas);
|
||||||
|
// tell phraseanet to rebuild subdef
|
||||||
|
$this->dispatch(RecordEvents::SUBDEFINITION_BUILD, new SubdefinitionBuildEvent($recordAdapter));
|
||||||
|
|
||||||
$storyWZ = new StoryWZ();
|
$storyWZ = new StoryWZ();
|
||||||
$storyWZ->setUser($this->getAuthenticatedUser());
|
$storyWZ->setUser($this->getAuthenticatedUser());
|
||||||
|
@@ -16,6 +16,7 @@ use Alchemy\Phrasea\Application\Helper\SubDefinitionSubstituerAware;
|
|||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionBuildEvent;
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
use Alchemy\Phrasea\Metadata\PhraseanetMetadataReader;
|
use Alchemy\Phrasea\Metadata\PhraseanetMetadataReader;
|
||||||
use Alchemy\Phrasea\Metadata\PhraseanetMetadataSetter;
|
use Alchemy\Phrasea\Metadata\PhraseanetMetadataSetter;
|
||||||
@@ -156,7 +157,7 @@ class ToolsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$substituted || $force) {
|
if (!$substituted || $force) {
|
||||||
$record->rebuild_subdefs();
|
$this->dispatch(RecordEvents::SUBDEFINITION_BUILD, new SubdefinitionBuildEvent($record));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,6 +29,8 @@ final class RecordEvents
|
|||||||
const SUB_DEFINITIONS_CREATED = 'record.sub_definitions_created';
|
const SUB_DEFINITIONS_CREATED = 'record.sub_definitions_created';
|
||||||
const SUB_DEFINITION_CREATION_FAILED = 'record.sub_definition_creation_failed';
|
const SUB_DEFINITION_CREATION_FAILED = 'record.sub_definition_creation_failed';
|
||||||
|
|
||||||
|
const SUBDEFINITION_BUILD = 'record.subdefinition_build';
|
||||||
|
|
||||||
const MEDIA_SUBSTITUTED = 'record.media_substituted';
|
const MEDIA_SUBSTITUTED = 'record.media_substituted';
|
||||||
|
|
||||||
const STORY_COVER_CHANGED = 'record.story_cover_changed';
|
const STORY_COVER_CHANGED = 'record.story_cover_changed';
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Core\Event\Record;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Model\RecordInterface;
|
||||||
|
|
||||||
|
class SubdefinitionBuildEvent extends RecordEvent
|
||||||
|
{
|
||||||
|
private $isNewRecord;
|
||||||
|
|
||||||
|
public function __construct(RecordInterface $record, $isNewRecord = false)
|
||||||
|
{
|
||||||
|
parent::__construct($record);
|
||||||
|
|
||||||
|
$this->isNewRecord = $isNewRecord;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isNewRecord()
|
||||||
|
{
|
||||||
|
return $this->isNewRecord;
|
||||||
|
}
|
||||||
|
}
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Core\Event\Subscriber;
|
|||||||
use Alchemy\Phrasea\Core\Event\Record\CollectionChangedEvent;
|
use Alchemy\Phrasea\Core\Event\Record\CollectionChangedEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionBuildEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\RecordEdit;
|
use Alchemy\Phrasea\Core\Event\RecordEdit;
|
||||||
use Alchemy\Phrasea\Core\PhraseaEvents;
|
use Alchemy\Phrasea\Core\PhraseaEvents;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\TfEditdate;
|
use Alchemy\Phrasea\Metadata\Tag\TfEditdate;
|
||||||
@@ -30,6 +31,7 @@ class RecordEditSubscriber implements EventSubscriberInterface
|
|||||||
PhraseaEvents::RECORD_UPLOAD => 'onEdit',
|
PhraseaEvents::RECORD_UPLOAD => 'onEdit',
|
||||||
RecordEvents::ROTATE => 'onRecordChange',
|
RecordEvents::ROTATE => 'onRecordChange',
|
||||||
RecordEvents::COLLECTION_CHANGED => 'onCollectionChanged',
|
RecordEvents::COLLECTION_CHANGED => 'onCollectionChanged',
|
||||||
|
RecordEvents::SUBDEFINITION_BUILD => 'onBuildSubdefs',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +51,12 @@ class RecordEditSubscriber implements EventSubscriberInterface
|
|||||||
$recordAdapter->clearStampCache();
|
$recordAdapter->clearStampCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onBuildSubdefs(SubdefinitionBuildEvent $event)
|
||||||
|
{
|
||||||
|
$recordAdapter = $this->convertToRecordAdapter($event->getRecord());
|
||||||
|
$recordAdapter->rebuild_subdefs();
|
||||||
|
}
|
||||||
|
|
||||||
public function onEdit(RecordEdit $event)
|
public function onEdit(RecordEdit $event)
|
||||||
{
|
{
|
||||||
static $into = false;
|
static $into = false;
|
||||||
|
@@ -167,6 +167,24 @@ class SubdefGenerator
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set a logger to use
|
||||||
|
* @param LoggerInterface $logger
|
||||||
|
*/
|
||||||
|
public function setLogger(LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to get the logger
|
||||||
|
* @return LoggerInterface
|
||||||
|
*/
|
||||||
|
public function getLogger()
|
||||||
|
{
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
|
|
||||||
private function generateSubdef(\record_adapter $record, \databox_subdef $subdef_class, $pathdest)
|
private function generateSubdef(\record_adapter $record, \databox_subdef $subdef_class, $pathdest)
|
||||||
{
|
{
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Media;
|
|||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\MediaSubstitutedEvent;
|
use Alchemy\Phrasea\Core\Event\Record\MediaSubstitutedEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionBuildEvent;
|
||||||
use Alchemy\Phrasea\Filesystem\FilesystemService;
|
use Alchemy\Phrasea\Filesystem\FilesystemService;
|
||||||
use MediaAlchemyst\Alchemyst;
|
use MediaAlchemyst\Alchemyst;
|
||||||
use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException;
|
use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException;
|
||||||
@@ -79,7 +80,7 @@ class SubdefSubstituer
|
|||||||
$record->write_metas();
|
$record->write_metas();
|
||||||
|
|
||||||
if ($shouldSubdefsBeRebuilt) {
|
if ($shouldSubdefsBeRebuilt) {
|
||||||
$record->rebuild_subdefs();
|
$this->dispatcher->dispatch(RecordEvents::SUBDEFINITION_BUILD, new SubdefinitionBuildEvent($record));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dispatcher->dispatch(RecordEvents::MEDIA_SUBSTITUTED, new MediaSubstitutedEvent($record));
|
$this->dispatcher->dispatch(RecordEvents::MEDIA_SUBSTITUTED, new MediaSubstitutedEvent($record));
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
namespace Alchemy\Phrasea\TaskManager\Job;
|
namespace Alchemy\Phrasea\TaskManager\Job;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionBuildEvent;
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
use Alchemy\Phrasea\Border\File;
|
use Alchemy\Phrasea\Border\File;
|
||||||
use Alchemy\Phrasea\Border\Manager as borderManager;
|
use Alchemy\Phrasea\Border\Manager as borderManager;
|
||||||
@@ -1001,7 +1003,7 @@ class ArchiveJob extends AbstractJob
|
|||||||
{
|
{
|
||||||
// quick fix to reconnect if mysql is lost
|
// quick fix to reconnect if mysql is lost
|
||||||
$app->getApplicationBox()->get_connection();
|
$app->getApplicationBox()->get_connection();
|
||||||
$databox->get_connection();
|
$collection->get_connection();
|
||||||
|
|
||||||
$status = \databox_status::operation_or($stat0, $stat1);
|
$status = \databox_status::operation_or($stat0, $stat1);
|
||||||
|
|
||||||
@@ -1032,7 +1034,8 @@ class ArchiveJob extends AbstractJob
|
|||||||
}
|
}
|
||||||
|
|
||||||
$story->setStatus(\databox_status::operation_or($stat0, $stat1));
|
$story->setStatus(\databox_status::operation_or($stat0, $stat1));
|
||||||
$story->rebuild_subdefs();
|
|
||||||
|
$app['dispatcher']->dispatch(RecordEvents::SUBDEFINITION_BUILD, new SubdefinitionBuildEvent($story));
|
||||||
|
|
||||||
unset($media);
|
unset($media);
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ use Alchemy\Phrasea\Core\Event\Record\OriginalNameChangedEvent;
|
|||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvent;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||||
use Alchemy\Phrasea\Core\Event\Record\StatusChangedEvent;
|
use Alchemy\Phrasea\Core\Event\Record\StatusChangedEvent;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionBuildEvent;
|
||||||
use Alchemy\Phrasea\Core\PhraseaTokens;
|
use Alchemy\Phrasea\Core\PhraseaTokens;
|
||||||
use Alchemy\Phrasea\Databox\Subdef\MediaSubdefRepository;
|
use Alchemy\Phrasea\Databox\Subdef\MediaSubdefRepository;
|
||||||
use Alchemy\Phrasea\Filesystem\FilesystemService;
|
use Alchemy\Phrasea\Filesystem\FilesystemService;
|
||||||
@@ -284,7 +285,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
$this->getDataboxConnection()->executeUpdate($sql, ['type' => $type, 'record_id' => $this->getRecordId()]);
|
$this->getDataboxConnection()->executeUpdate($sql, ['type' => $type, 'record_id' => $this->getRecordId()]);
|
||||||
|
|
||||||
if ($old_type !== $type) {
|
if ($old_type !== $type) {
|
||||||
$this->rebuild_subdefs();
|
$this->dispatch(RecordEvents::SUBDEFINITION_BUILD, new SubdefinitionBuildEvent($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
@@ -341,7 +342,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
array(':mime' => $mime, ':record_id' => $this->getRecordId())
|
array(':mime' => $mime, ':record_id' => $this->getRecordId())
|
||||||
)) {
|
)) {
|
||||||
|
|
||||||
$this->rebuild_subdefs();
|
$this->dispatch(RecordEvents::SUBDEFINITION_BUILD, new SubdefinitionBuildEvent($this));
|
||||||
|
|
||||||
$this->delete_data_from_cache();
|
$this->delete_data_from_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user