-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Tag resolver --------- Co-authored-by: alexz707 <alexz707@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StaticResolverBundle\Models\Tag; | ||
|
||
use Pimcore\Model\Element\Tag; | ||
|
||
class TagResolver implements TagResolverInterface | ||
{ | ||
public function getById(int $id): ?Tag | ||
{ | ||
return Tag::getById($id); | ||
} | ||
|
||
/** | ||
* @return array<int, Tag> | ||
*/ | ||
public function getTagsForElement(string $cType, int $cId): array | ||
{ | ||
return Tag::getTagsForElement($cType, $cId); | ||
} | ||
|
||
public function assignTagToElement(string $cType, int $cId, Tag $tag): void | ||
{ | ||
Tag::addTagToElement($cType, $cId, $tag); | ||
} | ||
|
||
public function unassignTagFromElement(string $cType, int $cId, Tag $tag): void | ||
{ | ||
Tag::removeTagFromElement($cType, $cId, $tag); | ||
} | ||
|
||
/** | ||
* @param array<int, int> $cIds | ||
* @param array<int, int> $tagIds | ||
*/ | ||
public function batchAssignTagsToElements(string $cType, array $cIds, array $tagIds): void | ||
{ | ||
Tag::batchAssignTagsToElement($cType, $cIds, $tagIds); | ||
} | ||
|
||
/** | ||
* @param array<int, int> $cIds | ||
* @param array<int, int> $tagIds | ||
*/ | ||
public function batchReplaceTagsForElements(string $cType, array $cIds, array $tagIds): void | ||
{ | ||
Tag::batchAssignTagsToElement($cType, $cIds, $tagIds, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StaticResolverBundle\Models\Tag; | ||
|
||
use Pimcore\Model\Element\Tag; | ||
|
||
interface TagResolverInterface | ||
{ | ||
public function getById(int $id): ?Tag; | ||
|
||
/** | ||
* @return array<int, Tag> | ||
*/ | ||
public function getTagsForElement(string $cType, int $cId): array; | ||
|
||
public function assignTagToElement(string $cType, int $cId, Tag $tag): void; | ||
|
||
public function unassignTagFromElement(string $cType, int $cId, Tag $tag): void; | ||
|
||
/** | ||
* @param array<int, int> $cIds | ||
* @param array<int, int> $tagIds | ||
*/ | ||
public function batchAssignTagsToElements(string $cType, array $cIds, array $tagIds): void; | ||
|
||
/** | ||
* @param array<int, int> $cIds | ||
* @param array<int, int> $tagIds | ||
*/ | ||
public function batchReplaceTagsForElements(string $cType, array $cIds, array $tagIds): void; | ||
} |