eZ Community » Forums » eZ Publish 5 Platform » Netgen Tags bundle as Service in eZ...
expandshrink

Netgen Tags bundle as Service in eZ Publish

Netgen Tags bundle as Service in eZ Publish

Monday 20 April 2015 9:46:18 am - 9 replies

Hi there,

I am trying to use the NetGen tags bundle (found here https://github.com/netgen/TagsBundle) as a Service.

The aim is to be able to create Tags, not from admin but from a command line. I have a file that contains all the tags to create.

My problem is that i'm unable to use the \TagsBundle\API\Repository\TagsService which is an interface. 

I tried to inject dependency in the services.yml file but i guess i'm doing something wrong sad.gif Emoticon

I would like to be able to do something like :

$repository = $this->getContainer()->get('ezpublish.api.repository')
$contentTypeService = $repository->getContentTypeService();
$TagsService = $repository->getTagsService();

as used to create ContentType. The service is listed directly in the eZ api repository.

Thanks for your help.

Modified on Monday 20 April 2015 9:49:57 am by Task Mikaël

Monday 20 April 2015 11:40:15 am

Found solution !

The bundle was not installed correctly via composer. That's why the dependencies were not working ... such a shame ...

Thanks anyway.

Monday 20 April 2015 12:12:28 pm

Why don't you just inject the tags service itself ? I'd even recommend that you do the same for the eZ Repository services (Content Service, etc). They're all available as individual services: @ezpublish.api.service.content.

The one from the TagsBundle is named @ezpublish.api.service.tags.

Or am I missing something ?

Monday 20 April 2015 1:03:19 pm

Hello Task,

I'm pleased you were able to find the solution yourself!

Your really coming along nicely!

Best wishes

Cheers,
Heath

Modified on Monday 20 April 2015 1:03:32 pm by // Heath

Monday 20 April 2015 1:24:22 pm

Hi,

thanks for answers. Yeah, when i'm spending more than half a day trying to make something work, i ask around. Sometimes it's relevant some other times not.

I am now able to use the service :

$tagService = $this->getContainer()->get('ezpublish.api.service.tags');
$tagsCreateStruct = $tagService->newTagCreateStruct($parentTagId, $keyword);
$tagService->createTag($tagsCreateStruct);

I don't know why, i'm not able to create a tag directly under the "Top Level Tags". Each time i'm trying to execute the command with $parentTagId = 0, null, -1 or false the script is crashing.

I went to see the eztags extension that is in charge of adding the tag \extension\eztags\modules\tags\add.php and tried to debug the $parentTagId. When i add a tag from admin the $parentTagId == 0. But when i run the script using the service with $parentTagId == 0, the script is trying to load the tag with id 0 and crashes instead of creating my tag under it.

An easy way to debug this would be creating a first tag called Root with id == 1 and put all my tags under it.

This is not top priority at all, but i was just asking myself why it is working through Admin and not with the Script.

Cheers.

Tuesday 21 April 2015 9:21:44 am

Thank you for the detailed feedback. I'll ping one of the maintainers, maybe he'll have a clue.

In any case, I'm sure they'd be thrilled if you reported an issue, or suggested a fix :p

Cheers.

Tuesday 21 April 2015 9:27:45 am

Hi everyone!

The issue Mikaël mentions was already fixed couple of months ago, but it was not in any stable release. I released the new 1.2 version of Tags Bundle just yesterday which has the issue fixed so you can try and use that version to see if that fixes your problem.

Cheers!

Tuesday 21 April 2015 10:14:45 am

Hi,

Thanks for you answer, i'll try upgrading the bundle.

Cheers.

Thursday 23 April 2015 3:37:59 pm

Worked with upgrade ! thanks !

Thursday 23 April 2015 4:46:45 pm

Good to hear that! happy.gif Emoticon

Cheers!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from