Skip to content

Commit

Permalink
Allowing the remote_id in content update to be on a location or a object
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Clements committed Apr 27, 2016
1 parent af244c3 commit 32ad279
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Core/API/ComplexFields/EzImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ public function createValue()
$migrationDir = $this->container->getParameter('kaliop_bundle_migration.version_directory');
$bundlePath = $this->bundle->getPath();
$filePath = $bundlePath . '/' . $migrationDir . '/images/' . $imageData['path'];
$altText = array_key_exists('alt_text', $imageData) ? $imageData['alt_text'] : '';

$value = new ImageValue(
array(
'path' => $filePath,
'fileSize' => filesize($filePath),
'fileName' => basename($filePath),
'alternativeText' => $imageData['alt_text']
'alternativeText' => $altText
)
);

Expand Down
8 changes: 7 additions & 1 deletion Core/API/Managers/ContentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ public function update()
if ($this->isReference($remoteId)) {
$remoteId = $this->getReference($remoteId);
}
$contentInfo = $contentService->loadContentInfoByRemoteId($remoteId);

try {
$contentInfo = $contentService->loadContentInfoByRemoteId($remoteId);
} catch (\eZ\Publish\API\Repository\Exceptions\NotFoundException $e) {
$location = $this->repository->getLocationService()->loadLocationByRemoteId($remoteId);
$contentInfo = $location->contentInfo;
}
}

$contentType = $contentTypeService->loadContentType($contentInfo->contentTypeId);
Expand Down

0 comments on commit 32ad279

Please sign in to comment.