Skip to content

Commit

Permalink
Merge branch 'hotfix_25127_send_multimedia_object_update_event_on_add…
Browse files Browse the repository at this point in the history
…_or_override_material_file' into '1.2.x'

TTK-25127 send multimedia object update event on add or orverride material file

See merge request pumukit/PumukitExternalAPIBundle!11
  • Loading branch information
Yurujai committed May 18, 2021
2 parents 171d6f0 + 7d65187 commit f663e7a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<service id="pumukit_external_api.api_common_service" class="Pumukit\ExternalAPIBundle\Services\APICommonService">
<argument type="service" id="doctrine_mongodb.odm.document_manager"/>
<argument type="service" id="pumukitschema.factory"/>
<argument type="service" id="pumukitschema.multimediaobject_dispatcher"/>
<argument>%pumukit.locales%</argument>
</service>

Expand Down
16 changes: 14 additions & 2 deletions Services/APICommonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\SchemaBundle\Document\Series;
use Pumukit\SchemaBundle\Services\FactoryService;
use Pumukit\SchemaBundle\Services\MultimediaObjectEventDispatcherService;
use Symfony\Component\HttpFoundation\Response;

class APICommonService
Expand All @@ -14,12 +15,18 @@ class APICommonService
protected $documentManager;
/** @var FactoryService */
protected $factoryService;
private $multimediaObjectEventDispatcherService;
protected $pumukitLocales;

public function __construct(DocumentManager $documentManager, FactoryService $factoryService, array $pumukitLocales)
{
public function __construct(
DocumentManager $documentManager,
FactoryService $factoryService,
MultimediaObjectEventDispatcherService $multimediaObjectEventDispatcherService,
array $pumukitLocales
) {
$this->documentManager = $documentManager;
$this->factoryService = $factoryService;
$this->multimediaObjectEventDispatcherService = $multimediaObjectEventDispatcherService;
$this->pumukitLocales = $pumukitLocales;
}

Expand Down Expand Up @@ -86,4 +93,9 @@ protected function processSeriesTitle(string $requestTitle): array

return $seriesTitle;
}

protected function multimediaObjectDispatchUpdate(MultimediaObject $multimediaObject): void
{
$this->multimediaObjectEventDispatcherService->dispatchUpdate($multimediaObject);
}
}
2 changes: 2 additions & 0 deletions Services/APIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function addAttachment(array $requestParameters)

$multimediaObject = $this->processMaterialFile($multimediaObject, $body, $materialMetadata, $overriding);

$this->multimediaObjectDispatchUpdate($multimediaObject);

$mediaPackage = $this->generateXML($multimediaObject);

return $mediaPackage->asXML();
Expand Down

0 comments on commit f663e7a

Please sign in to comment.