mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 07:43:12 +08:00
Added Create and Delete tag actions
This commit is contained in:
29
module/Core/src/Repository/TagRepository.php
Normal file
29
module/Core/src/Repository/TagRepository.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||
|
||||
class TagRepository extends EntityRepository implements TagRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Delete the tags identified by provided names
|
||||
*
|
||||
* @param array $names
|
||||
* @return int The number of affected entries
|
||||
*/
|
||||
public function deleteByName(array $names)
|
||||
{
|
||||
if (empty($names)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
$qb->delete(Tag::class, 't')
|
||||
->where($qb->expr()->in('t.name', $names));
|
||||
|
||||
return $qb->getQuery()->execute();
|
||||
}
|
||||
}
|
||||
17
module/Core/src/Repository/TagRepositoryInterface.php
Normal file
17
module/Core/src/Repository/TagRepositoryInterface.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Repository;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
|
||||
interface TagRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
/**
|
||||
* Delete the tags identified by provided names
|
||||
*
|
||||
* @param array $names
|
||||
* @return int The number of affected entries
|
||||
*/
|
||||
public function deleteByName(array $names);
|
||||
}
|
||||
Reference in New Issue
Block a user