Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (35 sloc) 1.05 KB
<?php
declare(strict_types=1);
namespace Netgen\Layouts\Ez\Item\ValueLoader;
use eZ\Publish\API\Repository\LocationService;
use Netgen\Layouts\Item\ValueLoaderInterface;
use Throwable;
final class LocationValueLoader implements ValueLoaderInterface
{
/**
* @var \eZ\Publish\API\Repository\LocationService
*/
private $locationService;
public function __construct(LocationService $locationService)
{
$this->locationService = $locationService;
}
public function load($id): ?object
{
try {
$location = $this->locationService->loadLocation((int) $id);
} catch (Throwable $t) {
return null;
}
return $location->contentInfo->published ? $location : null;
}
public function loadByRemoteId($remoteId): ?object
{
try {
$location = $this->locationService->loadLocationByRemoteId((string) $remoteId);
} catch (Throwable $t) {
return null;
}
return $location->contentInfo->published ? $location : null;
}
}
You can’t perform that action at this time.