mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 00:38:46 +03:00
Added tag property to json serialization of ShortUrl
This commit is contained in:
parent
1cf6c93007
commit
322180bde4
2 changed files with 14 additions and 2 deletions
|
@ -178,7 +178,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||||
'originalUrl' => $this->originalUrl,
|
'originalUrl' => $this->originalUrl,
|
||||||
'dateCreated' => isset($this->dateCreated) ? $this->dateCreated->format(\DateTime::ISO8601) : null,
|
'dateCreated' => isset($this->dateCreated) ? $this->dateCreated->format(\DateTime::ISO8601) : null,
|
||||||
'visitsCount' => count($this->visits),
|
'visitsCount' => count($this->visits),
|
||||||
'tags' => $this->tags,
|
'tags' => $this->tags->toArray(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use Shlinkio\Shlink\Common\Entity\AbstractEntity;
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="tags")
|
* @ORM\Table(name="tags")
|
||||||
*/
|
*/
|
||||||
class Tag extends AbstractEntity
|
class Tag extends AbstractEntity implements \JsonSerializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -37,4 +37,16 @@ class Tag extends AbstractEntity
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify data which should be serialized to JSON
|
||||||
|
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||||
|
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||||
|
* which is a value of any type other than a resource.
|
||||||
|
* @since 5.4.0
|
||||||
|
*/
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue