@@ -30,6 +30,7 @@ class CategoriesApiController extends AbstractApiController {
3030 /** @var Schema */
3131 private $ idParamSchema ;
3232
33+
3334 /**
3435 * CategoriesApiController constructor.
3536 *
@@ -153,9 +154,9 @@ protected function fullSchema() {
153154 * @return array
154155 */
155156 public function get ($ id ) {
156- $ this ->permission ('Garden.Settings.Manage ' );
157157
158- $ in = $ this ->idParamSchema ()->setDescription ('Get a category. ' );
158+ $ this ->permission ('Garden.Settings.Manage ' );
159+ $ in = $ this ->idParamSchema ()->setDescription ('Get a category by ID. ' );
159160 $ out = $ this ->schema ($ this ->schemaWithParent (), 'out ' );
160161
161162 $ row = $ this ->category ($ id );
@@ -165,6 +166,27 @@ public function get($id) {
165166 return $ result ;
166167 }
167168
169+ /**
170+ * Get a single category by urlcode.
171+ *
172+ * @param string $urlcode The urlcode of the category.
173+ * @throws NotFoundException if unable to find the category.
174+ * @return array
175+ */
176+ public function get_urlcode ($ urlcode ) {
177+ $ this ->permission ('Garden.Settings.Manage ' );
178+ $ in = $ this ->schema ([
179+ 'urlcode:s ' => 'Category urlcode. ' ,
180+ ])->setDescription ('Get a category by urlcode. ' );
181+
182+ $ out = $ this ->schema ($ this ->schemaWithParent (), 'out ' );
183+ $ row = $ this ->category ($ urlcode );
184+ $ row = $ this ->normalizeOutput ($ row );
185+ $ result = $ out ->validate ($ row );
186+ return $ result ;
187+
188+ }
189+
168190 /**
169191 * Get a category for editing.
170192 *
0 commit comments