Added Create and Delete tag actions

This commit is contained in:
Alejandro Celaya
2017-07-15 09:00:53 +02:00
parent 6717102dd2
commit b2d9f2fc01
10 changed files with 286 additions and 11 deletions

View 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();
}
}

View 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);
}