3737use Ibexa \Core \Repository \Values \Content \VersionInfo ;
3838use Ibexa \FieldTypeRichText \FieldType \RichText \Value as RichTextValue ;
3939use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
40+ use Psr \Log \LoggerInterface ;
41+ use Psr \Log \NullLogger ;
4042
4143class MetaNameSchema extends NameSchemaService
4244{
@@ -83,6 +85,7 @@ public function __construct(
8385 RepositoryInterface $ repository ,
8486 TranslationHelper $ translationHelper ,
8587 ConfigResolverInterface $ configurationResolver ,
88+ ?LoggerInterface $ logger = null ,
8689 array $ settings = []
8790 ) {
8891 $ this ->fieldTypeRegistry = $ fieldTypeRegistry ;
@@ -99,6 +102,7 @@ public function __construct(
99102 $ this ->translationHelper = $ translationHelper ;
100103 $ this ->relationListField = $ this ->fieldTypeRegistry ->getFieldType ('ezobjectrelationlist ' );
101104 $ this ->configurationResolver = $ configurationResolver ;
105+ $ this ->logger = $ logger ?? new NullLogger ();
102106 }
103107
104108 public function setRichTextConverter (RichTextConverterInterface $ richTextConverter ): void
@@ -266,8 +270,16 @@ protected function handleRelationValue(RelationValue $value, string $languageCod
266270 if (!$ value ->destinationContentId ) {
267271 return '' ;
268272 }
269- $ relatedContent = $ this ->repository ->getContentService ()->loadContent ($ value ->destinationContentId );
270- // @todo: we can probably be better here and handle more than just "image"
273+ //if the content is not translated
274+ try {
275+ $ relatedContent = $ this ->repository ->getContentService ()->loadContent ($ value ->destinationContentId );
276+ } catch (\Exception $ e ) {
277+ $ this ->logger ->error ($ e ->getMessage (), [
278+ 'exception ' => $ e ,
279+ ]);
280+ return '' ;
281+ }
282+ // @todo: we can probably be better here and handle more than just "image"
271283 $ fieldImageValue = $ relatedContent ->getFieldValue ('image ' );
272284 if ($ fieldImageValue instanceof ImageValue) {
273285 if ($ fieldImageValue ->uri ) {
0 commit comments