Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
0c21b61
NGSTACK-977 add 'isHidden' and 'isInvisible' properties to Tag object…
AntePrkacin May 23, 2025
71034c0
NGSTACK-977 update database schema to include 'is_hidden' and 'is_inv…
AntePrkacin May 23, 2025
981a985
NGSTACK-977 add support for 'isHidden' and 'isInvisible' properties i…
AntePrkacin May 23, 2025
d3dc59e
NGSTACK-977 add support for 'isHidden' and 'isInvisible' fields in tr…
AntePrkacin May 23, 2025
62ba8ad
NGSTACK-977 add 'Hide tag' button and its functionality in admin inte…
AntePrkacin Jun 4, 2025
0ee8a42
NGSTACK-977 add 'Unhide tag' button and its functionality in admin in…
AntePrkacin Jun 5, 2025
033de91
NGSTACK-977 fix bug when creating queries and update translations to …
AntePrkacin Jun 5, 2025
b47e3a5
NGSTACK-977 add functionality for hiding and unhiding selected childr…
AntePrkacin Jun 5, 2025
302837d
NGSTACK-977 throw 404 on frontend if tag is hidden
AntePrkacin Jun 5, 2025
fcabf76
NGSTACK-977 add 'disabled' property to hidden tags and disable adding…
AntePrkacin Jun 5, 2025
402ca4c
NGSTACK-977 add 'hidden' text after hidden tags in eztags content field
AntePrkacin Jun 6, 2025
f12c262
NGSTACK-977 fix php-cs-fixer and phpstan reports
AntePrkacin Jun 6, 2025
9813914
NGSTACK-977 add 'is_hidden' and 'is_invisible' fields to test databas…
AntePrkacin Jun 6, 2025
9987286
NGSTACK-977 fix TagsIntegrationTest by adding 'isHidden' and 'isInvis…
AntePrkacin Jun 6, 2025
c698f26
NGSTACK-977 update phpdocs and remove tag visibility information bein…
AntePrkacin Jun 6, 2025
f8bcf8d
NGSTACK-977 modify gateway to make the hidden tag also invisible
AntePrkacin Jun 6, 2025
e5b2f5f
NGSTACK-977 remove unnecessary cast to int for 'is_hidden' and 'is_in…
AntePrkacin Jun 6, 2025
7e88bdd
NGSTACK-977 add 'hidesynonym' and 'unhidesynonym' policies
AntePrkacin Jun 6, 2025
dece52c
NGSTACK-977 add translation domain and make tag visibility info trans…
AntePrkacin Jun 6, 2025
543afc4
NGSTACK-977 change all 'unhide' text to 'reveal' regarding the tags v…
AntePrkacin Jun 6, 2025
8b20a72
NGSTACK-977 make descendant tags who have one hidden parent stay invi…
AntePrkacin Jun 9, 2025
54ec1e9
NGSTACK-977 fix logic for revealing a hidden tag
AntePrkacin Jun 9, 2025
a61028b
NGSTACK-977 set 'is_hidden' and 'is_invisible' fields correctly when …
AntePrkacin Jun 9, 2025
45b2f03
NGSTACK-977 update logic for revealing a tag to handle both ancestor …
AntePrkacin Jun 9, 2025
e50dfdb
NGSTACK-977 fix a test for creating a tag by adding 'is_invisible' pr…
AntePrkacin Jun 9, 2025
69672a5
NGSTACK-977 add events for hiding and revealing a tag and add tests f…
AntePrkacin Jun 9, 2025
086e954
NGSTACK-977 add 'show_hidden' parameter in the configTreeBuilder and …
AntePrkacin Jun 10, 2025
4af3ecd
NGSTACK-977 inject configResolver into SiteAccessAware/TagsService, a…
AntePrkacin Jun 10, 2025
0f8c7dd
NGSTACK-977 add 'show_hidden' argument to necessary functions in the …
AntePrkacin Jun 10, 2025
75858b8
NGSTACK-977 add 'show_hidden' argument to necessary functions in the …
AntePrkacin Jun 10, 2025
d99a9d4
NGSTACK-977 update PHPDoc for hide and reveal methods and add ' (hidd…
AntePrkacin Jun 10, 2025
d09d660
NGSTACK-977 add ' (hidden)' next to tag keyword in the TagTreeData if…
AntePrkacin Jun 10, 2025
a6d7415
NGSTACK-977 update DoctrineDatabaseTest and TagsHandlerTest with test…
AntePrkacin Jun 10, 2025
eed05e2
NGSTACK-977 add 'hide_tag' and 'reveal_tag' data to the TagTree in Tr…
AntePrkacin Jun 11, 2025
37da894
NGSTACK-977 add visibility information for children when listing them…
AntePrkacin Jun 11, 2025
e69b243
NGSTACK-977 not show hidden tags when trying to search for them in ez…
AntePrkacin Jun 11, 2025
514e3d0
NGSTACK-977 update postgresql schema and legacy.yaml file with 'is_hi…
AntePrkacin Jun 11, 2025
81d4007
NGSTACK-977 update PHPDoc for isHidden and isInvisible Tag properties
AntePrkacin Jun 12, 2025
a720391
NGSTACK-977 modify 'tags_reveal' to 'tags_revealed' translation message
AntePrkacin Jun 12, 2025
a69c38c
NGSTACK-977 extract TagTreeText formatting into a separate function a…
AntePrkacin Jun 12, 2025
08ef43d
NGSTACK-977 add upgrade instructions for tag visibility to UPGRADE.md…
AntePrkacin Jun 17, 2025
550f0e3
NGSTACK-977 update hideAction() and revealAction() methods for hiding…
AntePrkacin Jun 23, 2025
4a174cc
NGSTACK-977 separate escape logic from the formatting logic for tag k…
AntePrkacin Jun 23, 2025
6692248
NGSTACK-977 rename 'showHidden' to 'showHiddenTags' parameter in conf…
AntePrkacin Jun 23, 2025
203dcd6
NGSTACK-977 add MySQL and PostgreSQL upgrade scripts for 'is_hidden' …
AntePrkacin Jun 23, 2025
ec62925
NGSTACK-977 fix a call to searchTags() method in FieldController
AntePrkacin Jun 23, 2025
c05ab16
NGSTACK-977 rename MoveTagsType form to MultiselectTagsType form and …
AntePrkacin Jun 24, 2025
07866bc
NGSTACK-977 update hideTagsAction and revealTagsAction methods in Tag…
AntePrkacin Jun 24, 2025
535890e
NGSTACK-977 add 'autocomplete_provide_hidden_tags' parameter to the c…
AntePrkacin Jun 24, 2025
96279be
NGSTACK-977 modify autoCompleteAction() method in FieldController to …
AntePrkacin Jun 24, 2025
9a00e4e
NGSTACK-977 make autocomplete suggestions not show invisible tags whe…
AntePrkacin Jun 26, 2025
cf15dfc
NGSTACK-977 add data about tag visibility when searching for tags in …
AntePrkacin Jun 26, 2025
fd4e11f
NGSTACK-977 fix tag converting to synonym process and merging process…
AntePrkacin Jun 26, 2025
c81ccef
NGSTACK-977 remove dump statements from 'hide' and 'reveal' twig temp…
AntePrkacin Jun 26, 2025
45cf8e6
NGSTACK-977 update 'is_hidden' check to 'is_invisible' check in metho…
AntePrkacin Jun 26, 2025
50a4c29
NGSTACK-977 fix revealing a hidden synonym by checking the 'main_tag_…
AntePrkacin Jun 26, 2025
40605b9
NGSTACK-977 update testConvertToSynonym to check 'is_invisible' property
AntePrkacin Jun 26, 2025
88fc80e
NGSTACK-977 add some missing translations for french langauge
AntePrkacin Jun 26, 2025
71a9102
NGSTACK-977 change policies to only have one for hiding and revealing
AntePrkacin Jun 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bundle/API/Repository/TagsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,22 @@ public function newSynonymCreateStruct(int $mainTagId, string $mainLanguageCode)
*/
public function newTagUpdateStruct(): TagUpdateStruct;

/**
* Hides $tag.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException If the current user is not allowed to delete this tag
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong exception text If the current user is not allowed to delete this tag. Shoud be hide instead of delete.

Same goes for unhide.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed PHPDocs: c698f26

Will probably rename 'unhide' to 'reveal', as Petar suggested below

* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException If the specified tag is not found
*/
public function hideTag(Tag $tag): void;

/**
* Unhides $tag.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException If the current user is not allowed to delete this tag
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException If the specified tag is not found
*/
public function unhideTag(Tag $tag): void;
Comment thread
pspanja marked this conversation as resolved.
Outdated

/**
* Allows tags API execution to be performed with full access sand-boxed.
*
Expand Down
10 changes: 10 additions & 0 deletions bundle/API/Repository/Values/Tags/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ final class Tag extends ValueObject
*/
protected ?string $prioritizedLanguageCode;

/**
* Indicates if the Tag object is visible or not
*/
protected bool $isHidden;

/**
* Indicates if the Tag object is located under another hidden Tag object
*/
protected bool $isInvisible;

/**
* Construct object optionally with a set of properties.
*
Expand Down
94 changes: 94 additions & 0 deletions bundle/Controller/Admin/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,49 @@ public function childrenAction(Request $request, ?Tag $tag = null): Response
);
}

if ($request->request->has('HideTagsAction')) {
return $this->redirectToRoute(
'netgen_tags_admin_tag_hide_tags',
[
'parentId' => $tag?->id ?? 0,
],
);
}

if ($request->request->has('UnhideTagsAction')) {
return $this->redirectToRoute(
'netgen_tags_admin_tag_unhide_tags',
[
'parentId' => $tag?->id ?? 0,
],
);
}

return $this->redirect($request->getPathInfo());
}

public function hideAction(Request $request, Tag $tag): Response
{
$this->denyAccessUnlessGranted('ibexa:tags:hide' . ($tag->isSynonym() ? 'synonym' : ''));

$this->tagsService->hideTag($tag);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check the submitted button and CSRF token here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do. There is an example in deleteTagAction method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added CSRF token check to hideAction() method in TagController (550f0e3)


$this->addFlashMessage('success', 'tag_hidden', ['%tagKeyword%' => $tag->keyword]);

return $this->redirectToTag($tag);
}

public function unhideAction(Request $request, Tag $tag): Response
{
$this->denyAccessUnlessGranted('ibexa:tags:unhide' . ($tag->isSynonym() ? 'synonym' : ''));

$this->tagsService->unhideTag($tag);

$this->addFlashMessage('success', 'tag_unhidden', ['%tagKeyword%' => $tag->keyword]);

return $this->redirectToTag($tag);
}

/**
* This method is called from a form containing all children tags of a tag.
* It shows a confirmation view.
Expand Down Expand Up @@ -666,6 +706,60 @@ public function deleteTagsAction(Request $request, ?Tag $parentTag = null): Resp
);
}

public function hideTagsAction(Request $request, ?Tag $parentTag = null): Response
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with CSRF. What we need to do here is create a Symfony multiselect form for selecting the tags in lieu of moveTagsAction method. Same goes for revealTagsAction.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emodric OK. Just to confirm that I understood correctly - I will remove the 'Hide selected tags' and 'Reveal selected tags' buttons below the children list - childrenAction() method. Instead, I will put two new buttons (somewhere else) that tell 'Hide kids' or 'Reveal kids'. When either of them is pressed, a multiselect form will show up where the user will be able to select the desired tags they want to hide or reveal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, do it in the same way as it is now, but with Symfony form in lieu of "move tags". Try and see if you can reuse the existing form type. It's now called MoveTagsType, try to reuse it by renaming it to e.g. MultiselectTagsType or similar.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed MoveTagsType form to MultiselectTagsType form and used it when hiding and revealing multiple tags:
c05ab16 07866bc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntePrkacin Sounds good 👍

{
$this->denyAccessUnlessGranted('ibexa:tags:hide');

$tagIds = (array) $request->request->get(
'Tags',
$request->hasSession() ? $request->getSession()->get('ngtags_tag_ids') : [],
);

if (count($tagIds) === 0) {
return $this->redirectToTag($parentTag);
}

$tags = [];
foreach ($tagIds as $tagId) {
$tags[] = $this->tagsService->loadTag((int) $tagId);
}

foreach ($tags as $tagObject) {
$this->tagsService->hideTag($tagObject);
}

$this->addFlashMessage('success', 'tags_hidden');

return $this->redirectToTag($parentTag);
}

public function unhideTagsAction(Request $request, ?Tag $parentTag = null): Response
{
$this->denyAccessUnlessGranted('ibexa:tags:unhide');

$tagIds = (array) $request->request->get(
'Tags',
$request->hasSession() ? $request->getSession()->get('ngtags_tag_ids') : [],
);

if (count($tagIds) === 0) {
return $this->redirectToTag($parentTag);
}

$tags = [];
foreach ($tagIds as $tagId) {
$tags[] = $this->tagsService->loadTag((int) $tagId);
}

foreach ($tags as $tagObject) {
$this->tagsService->unhideTag($tagObject);
}

$this->addFlashMessage('success', 'tags_unhidden');

return $this->redirectToTag($parentTag);
}

public function searchTagsAction(Request $request): Response
{
$this->denyAccessUnlessGranted('ibexa:tags:read');
Expand Down
2 changes: 2 additions & 0 deletions bundle/Controller/Admin/TreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
'parent' => $isRoot ? '#' : $tag->parentTagId,
'text' => $synonymCount > 0 ? $this->escape($tag->keyword) . ' (+' . $synonymCount . ')' : $this->escape($tag->keyword),
'children' => $this->tagsService->getTagChildrenCount($tag) > 0,
'hidden' => $tag->isHidden,

Check failure on line 129 in bundle/Controller/Admin/TreeController.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to protected property Netgen\TagsBundle\API\Repository\Values\Tags\Tag::$isHidden.
'invisible' => $tag->isInvisible,

Check failure on line 130 in bundle/Controller/Admin/TreeController.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to protected property Netgen\TagsBundle\API\Repository\Values\Tags\Tag::$isInvisible.
'a_attr' => [
'href' => str_replace(':tagId', (string) $tag->id, $this->treeLinks['show_tag']),
'rel' => $tag->id,
Expand Down
8 changes: 8 additions & 0 deletions bundle/Controller/TagViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
*/
public function viewAction(TagView $view): TagView
{
if ($view->getTag()->isHidden) {

Check failure on line 17 in bundle/Controller/TagViewController.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to protected property Netgen\TagsBundle\API\Repository\Values\Tags\Tag::$isHidden.
throw $this->createNotFoundException('Tag is hidden.');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the message here. As this is the frontend, we do not want to communicate any revealing info.

As far as the user is concerned, the tag does not exist and that's it.

Also, here, you can only check for visible/invisible since when the tag is hidden, it should automatically be invisible too. That is, it is not possible for the tag to be hidden but not invisible too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the message: c698f26

}

if ($view->getTag()->isInvisible) {

Check failure on line 21 in bundle/Controller/TagViewController.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to protected property Netgen\TagsBundle\API\Repository\Values\Tags\Tag::$isInvisible.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emodric should this include the check for the show_hidden_tags configuration option?

throw $this->createNotFoundException('Tag is hidden by parent.');
}

return $view;
}
}
10 changes: 10 additions & 0 deletions bundle/Core/Event/TagsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ public function newTagUpdateStruct(): TagUpdateStruct
return $this->service->newTagUpdateStruct();
}

public function hideTag(Tag $tag): void
{
$this->service->hideTag($tag);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No event dispatching here and in unhide tag method?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about them... added them now: 69672a5

}

public function unhideTag(Tag $tag): void
{
$this->service->unhideTag($tag);
}

public function sudo(callable $callback, ?TagsServiceInterface $outerTagsService = null): mixed
{
return $this->service->sudo($callback, $outerTagsService ?? $this);
Expand Down
16 changes: 16 additions & 0 deletions bundle/Core/Persistence/Cache/TagsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,22 @@ public function deleteTag(int $tagId): void
$this->cache->invalidateTags(['tag-path-' . $tagId]);
}

public function hideTag(int $tagId): void
{
$this->logger->logCall(__METHOD__, ['tag' => $tagId]);
$this->tagsHandler->hideTag($tagId);

$this->cache->invalidateTags(['tag-path-' . $tagId]);
}

public function unhideTag(int $tagId): void
{
$this->logger->logCall(__METHOD__, ['tag' => $tagId]);
$this->tagsHandler->unhideTag($tagId);

$this->cache->invalidateTags(['tag-path-' . $tagId]);
}

/**
* Return relevant cache tags so cache can be purged reliably.
*
Expand Down
10 changes: 10 additions & 0 deletions bundle/Core/Persistence/Legacy/Tags/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,14 @@ abstract public function moveSubtree(array $sourceTagData, ?array $destinationPa
* If $tagId is a synonym, only the synonym is deleted.
*/
abstract public function deleteTag(int $tagId): void;

/**
* Hides tag identified by $tagId.
*/
abstract public function hideTag(int $tagId): void;

/**
* Unhides tag identified by $tagId.
*/
abstract public function unhideTag(int $tagId): void;
}
58 changes: 58 additions & 0 deletions bundle/Core/Persistence/Legacy/Tags/Gateway/DoctrineDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,62 @@
$query->execute();
}

public function hideTag(int $tagId): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('eztags')
->set('is_hidden', 1)

Check failure on line 852 in bundle/Core/Persistence/Legacy/Tags/Gateway/DoctrineDatabase.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #2 $value of method Doctrine\DBAL\Query\QueryBuilder::set() expects string, int given.
->where(
$query->expr()->eq('id', ':tag_id'),
)->setParameter('tag_id', $tagId, Types::INTEGER);

$query->execute();

$query = $this->connection->createQueryBuilder();
$query
->update('eztags')
->set('is_invisible', 1)

Check failure on line 862 in bundle/Core/Persistence/Legacy/Tags/Gateway/DoctrineDatabase.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #2 $value of method Doctrine\DBAL\Query\QueryBuilder::set() expects string, int given.
->where(
$query->expr()->like('path_string', ':path_string'),
)
->andWhere(
$query->expr()->neq('id', ':tag_id'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When hiding a tag, the hidden root tag should also be invisible, so we don't need this neq condition.

This is the way Ibexa works when hiding content, so there is no need to do this differently here. It will only cause confusion in the long run.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, didn't know that this was how Ibexa works.
Removed the neq: f8bcf8d

)
->setParameter('path_string', '%/' . $tagId . '/%', Types::STRING)
->setParameter('tag_id', $tagId, Types::INTEGER);

$query->execute();
}

public function unhideTag(int $tagId): void
{
$query = $this->connection->createQueryBuilder();
$query
->update('eztags')
->set('is_hidden', 0)

Check failure on line 880 in bundle/Core/Persistence/Legacy/Tags/Gateway/DoctrineDatabase.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #2 $value of method Doctrine\DBAL\Query\QueryBuilder::set() expects string, int given.
->where(
$query->expr()->eq('id', ':tag_id'),
)->setParameter('tag_id', $tagId, Types::INTEGER);

$query->execute();

$query = $this->connection->createQueryBuilder();
$query
->update('eztags')
->set('is_invisible', 0)

Check failure on line 890 in bundle/Core/Persistence/Legacy/Tags/Gateway/DoctrineDatabase.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #2 $value of method Doctrine\DBAL\Query\QueryBuilder::set() expects string, int given.
->where(
$query->expr()->like('path_string', ':path_string'),
)
->andWhere(
$query->expr()->neq('id', ':tag_id'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark about root tag invisibility goes here.

Also, I think we need to consider here what happens when some tag is already hidden explicitly below the tag being unhidden here. In that case, we can't really make tags below the already hidden tag invisible to maintain data consistency. We should see how Ibexa does this and just copy the implementation from there.

Copy link
Copy Markdown
Author

@AntePrkacin AntePrkacin Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the tag invisibility in the above comment.

Regarding the problem you mentioned about looking at the descendant tags and leaving them invisible if they have at least one parent that is explicitly hidden, I fixed it here:
8b20a72 54ec1e9 45b2f03

)
->setParameter('path_string', '%/' . $tagId . '/%', Types::STRING)
->setParameter('tag_id', $tagId, Types::INTEGER);

$query->execute();
}

private function createTagIdsQuery(?array $translations = null, bool $useAlwaysAvailable = true): QueryBuilder
{
$query = $this->connection->createQueryBuilder();
Expand Down Expand Up @@ -930,6 +986,8 @@
'eztags.remote_id',
'eztags.main_language_id',
'eztags.language_mask',
'eztags.is_hidden',
'eztags.is_invisible',
// Tag keywords
'eztags_keyword.keyword',
'eztags_keyword.locale',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,26 @@ public function deleteTag(int $tagId): void
throw new RuntimeException('Database error', 0, $e);
}
}

public function hideTag(int $tagId): void
{
try {
$this->innerGateway->hideTag($tagId);
} catch (DBALException $e) {
throw new RuntimeException('Database error', 0, $e);
} catch (PDOException $e) {
throw new RuntimeException('Database error', 0, $e);
}
}

public function unhideTag(int $tagId): void
{
try {
$this->innerGateway->unhideTag($tagId);
} catch (DBALException $e) {
throw new RuntimeException('Database error', 0, $e);
} catch (PDOException $e) {
throw new RuntimeException('Database error', 0, $e);
}
}
}
12 changes: 12 additions & 0 deletions bundle/Core/Persistence/Legacy/Tags/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ public function deleteTag(int $tagId): void
$this->gateway->deleteTag($tagInfo->id);
}

public function hideTag(int $tagId): void
{
$tagInfo = $this->loadTagInfo($tagId);
$this->gateway->hideTag($tagInfo->id);
}

public function unhideTag(int $tagId): void
{
$tagInfo = $this->loadTagInfo($tagId);
$this->gateway->unhideTag($tagInfo->id);
}

/**
* Copies tag object identified by $sourceData into destination identified by $destinationParentData.
*
Expand Down
4 changes: 4 additions & 0 deletions bundle/Core/Persistence/Legacy/Tags/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function createTagInfoFromRow(array $row): TagInfo
$tagInfo->alwaysAvailable = (bool) ((int) $row['language_mask'] & 1);
$tagInfo->mainLanguageCode = $this->languageHandler->load($row['main_language_id'])->languageCode;
$tagInfo->languageIds = $this->languageMaskGenerator->extractLanguageIdsFromMask((int) $row['language_mask']);
$tagInfo->isHidden = (bool) ((int) $row['is_hidden']);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need double cast here. You probably copied the thing from (bool) ((int) $row['language_mask'] & 1), but that has double cast due to bitwise and operator.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the double cast, kept only the bool one: e5b2f5f

$tagInfo->isInvisible = (bool) ((int) $row['is_invisible']);

return $tagInfo;
}
Expand All @@ -60,6 +62,8 @@ public function extractTagListFromRows(array $rows): array
$tag->alwaysAvailable = (bool) ((int) $row['language_mask'] & 1);
$tag->mainLanguageCode = $this->languageHandler->load($row['main_language_id'])->languageCode;
$tag->languageIds = $this->languageMaskGenerator->extractLanguageIdsFromMask((int) $row['language_mask']);
$tag->isHidden = (bool) ((int) $row['is_hidden']);
Comment thread
pspanja marked this conversation as resolved.
Outdated
$tag->isInvisible = (bool) ((int) $row['is_invisible']);
$tagList[$tagId] = $tag;
}

Expand Down
2 changes: 2 additions & 0 deletions bundle/Core/Repository/TagsMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public function buildTagDomainList(array $spiTags, array $prioritizedLanguages =
'mainLanguageCode' => $spiTag->mainLanguageCode,
'languageCodes' => $languageCodes,
'prioritizedLanguageCode' => $prioritizedLanguageCode,
'isHidden' => $spiTag->isHidden,
'isInvisible' => $spiTag->isInvisible,
],
);
}
Expand Down
Loading
Loading