Fixing tests

This commit is contained in:
Jeremy Benoist
2016-10-30 11:27:09 +01:00
parent 7f55941856
commit 48656e0eaa
7 changed files with 63 additions and 23 deletions

View File

@ -49,22 +49,23 @@ class DownloadImagesSubscriber implements EventSubscriber
return;
}
$em = $args->getEntityManager();
$config = new $this->configClass();
$config->setEntityManager($args->getEntityManager());
// field content has been updated
if ($args->hasChangedField('content')) {
$html = $this->downloadImages($em, $entity);
$html = $this->downloadImages($config, $entity);
if (null !== $html) {
if (false !== $html) {
$args->setNewValue('content', $html);
}
}
// field preview picture has been updated
if ($args->hasChangedField('previewPicture')) {
$previewPicture = $this->downloadPreviewImage($em, $entity);
$previewPicture = $this->downloadPreviewImage($config, $entity);
if (null !== $previewPicture) {
if (false !== $previewPicture) {
$entity->setPreviewPicture($previewPicture);
}
}
@ -88,17 +89,25 @@ class DownloadImagesSubscriber implements EventSubscriber
// update all images inside the html
$html = $this->downloadImages($config, $entity);
if (null !== $html) {
if (false !== $html) {
$entity->setContent($html);
}
// update preview picture
$previewPicture = $this->downloadPreviewImage($config, $entity);
if (null !== $previewPicture) {
if (false !== $previewPicture) {
$entity->setPreviewPicture($previewPicture);
}
}
/**
* Download all images from the html.
*
* @param Config $config
* @param Entry $entry
*
* @return string|false False in case of async
*/
public function downloadImages(Config $config, Entry $entry)
{
// if ($config->get('download_images_with_rabbitmq')) {
@ -113,6 +122,14 @@ class DownloadImagesSubscriber implements EventSubscriber
);
}
/**
* Download the preview picture.
*
* @param Config $config
* @param Entry $entry
*
* @return string|false False in case of async
*/
public function downloadPreviewImage(Config $config, Entry $entry)
{
// if ($config->get('download_images_with_rabbitmq')) {