mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Created TagService
This commit is contained in:
34
module/Core/src/Service/Tag/TagService.php
Normal file
34
module/Core/src/Service/Tag/TagService.php
Normal 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']);
|
||||
}
|
||||
}
|
||||
12
module/Core/src/Service/Tag/TagServiceInterface.php
Normal file
12
module/Core/src/Service/Tag/TagServiceInterface.php
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user