netgen / TagsBundle

Netgen Tags Bundle is an eZ Platform bundle for taxonomy management and easier classification of content, providing more functionality for tagging content than ezkeyword field type included in eZ Platform kernel.
https://netgen.io
GNU General Public License v2.0
48 stars 44 forks source link

Update eztag field value #104

Closed ahmed-bhs closed 5 years ago

ahmed-bhs commented 5 years ago

I'm trying to update a content wish have an eztag field value. I'm flowing the content updatethe documentation section https://doc.ezplatform.com/en/1.7/api/public_php_api_managing_content/#updating-content, unfortunately I'm getting this exception: Content fields did not validate

This is my code:

    $content = $this->repository->getContentService()->loadContentByRemoteId('bee932d48db96b7e10fd82ea3d3cfe0c');
    $tag1 = $this->tagsService->loadTag(67);
    $tag2 = $this->tagsService->loadTag(169);

    $contentUpdateStruct = $this->repository->getContentService()->newContentUpdateStruct();
    $contentUpdateStruct->initialLanguageCode = 'fre-FR';
    $contentUpdateStruct->setField('eztag_identifier', [$atg1, $tag2]);
    $contentInfo = $this->repository->getContentService()->loadContentInfo($content->id);
    $contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo);
    $contentDraft = $this->repository->getContentService()->updateContent($contentDraft->versionInfo, $contentUpdateStruct);
    $content = $this->repository->getContentService()->publishVersion($contentDraft->versionInfo);

Any idea would be appreciated.