2929
3030namespace VuFind \Db \Row ;
3131
32+ use DateTime ;
33+ use VuFind \Db \Entity \ShortlinksEntityInterface ;
34+
3235/**
3336 * Row Definition for shortlinks
3437 *
3740 * @author Demian Katz <[email protected] > 3841 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
3942 * @link https://vufind.org Main Site
43+ *
44+ * @property int $id
45+ * @property string $path
46+ * @property string $hash
47+ * @property string $created
4048 */
4149class Shortlinks extends RowGateway implements \VuFind \Db \Entity \ShortlinksEntityInterface
4250{
@@ -49,4 +57,84 @@ public function __construct($adapter)
4957 {
5058 parent ::__construct ('id ' , 'shortlinks ' , $ adapter );
5159 }
60+
61+ /**
62+ * Get identifier (returns null for an uninitialized or non-persisted object).
63+ *
64+ * @return ?int
65+ */
66+ public function getId (): ?int
67+ {
68+ return $ this ->id ?? null ;
69+ }
70+
71+ /**
72+ * Get the path of the URL.
73+ *
74+ * @return string
75+ */
76+ public function getPath (): string
77+ {
78+ return $ this ->path ?? '' ;
79+ }
80+
81+ /**
82+ * Set the path (e.g. /Search/Results?lookfor=foo) of the URL being shortened;
83+ * shortened URLs are always assumed to be within the hostname where VuFind is running.
84+ *
85+ * @param string $path Path
86+ *
87+ * @return ShortlinksEntityInterface
88+ */
89+ public function setPath (string $ path ): ShortlinksEntityInterface
90+ {
91+ $ this ->path = $ path ;
92+ return $ this ;
93+ }
94+
95+ /**
96+ * Get shortlinks hash.
97+ *
98+ * @return ?string
99+ */
100+ public function getHash (): ?string
101+ {
102+ return $ this ->hash ?? null ;
103+ }
104+
105+ /**
106+ * Set shortlinks hash.
107+ *
108+ * @param ?string $hash Shortlinks hash
109+ *
110+ * @return ShortlinksEntityInterface
111+ */
112+ public function setHash (?string $ hash ): ShortlinksEntityInterface
113+ {
114+ $ this ->hash = $ hash ;
115+ return $ this ;
116+ }
117+
118+ /**
119+ * Get creation timestamp.
120+ *
121+ * @return DateTime
122+ */
123+ public function getCreated (): DateTime
124+ {
125+ return DateTime::createFromFormat ('Y-m-d H:i:s ' , $ this ->created );
126+ }
127+
128+ /**
129+ * Set creation timestamp.
130+ *
131+ * @param DateTime $dateTime Creation timestamp
132+ *
133+ * @return ShortlinksEntityInterface
134+ */
135+ public function setCreated (DateTime $ dateTime ): ShortlinksEntityInterface
136+ {
137+ $ this ->created = $ dateTime ->format ('Y-m-d H:i:s ' );
138+ return $ this ;
139+ }
52140}
0 commit comments