Created TagService

This commit is contained in:
Alejandro Celaya
2017-07-07 12:49:41 +02:00
parent 486ea10c3c
commit c37660f763
4 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace Shlinkio\Shlink\Core\Service\Tag;
use Acelaya\ZsmAnnotatedServices\Annotation as DI;
use Doctrine\ORM\EntityManagerInterface;
use Shlinkio\Shlink\Core\Entity\Tag;
class TagService implements TagServiceInterface
{
/**
* @var EntityManagerInterface
*/
private $em;
/**
* VisitService constructor.
* @param EntityManagerInterface $em
*
* @DI\Inject({"em"})
*/
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
/**
* @return Tag[]
* @throws \UnexpectedValueException
*/
public function listTags()
{
return $this->em->getRepository(Tag::class)->findBy([], ['name' => 'DESC']);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Shlinkio\Shlink\Core\Service\Tag;
use Shlinkio\Shlink\Core\Entity\Tag;
interface TagServiceInterface
{
/**
* @return Tag[]
*/
public function listTags();
}