mirror of
https://github.com/Karaka-Management/oms-Knowledgebase.git
synced 2026-02-08 14:28:41 +00:00
cleanup and tests added for ci/cd
This commit is contained in:
parent
ddd0148e21
commit
f3666290cf
|
|
@ -35,6 +35,19 @@ use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||||
final class ApiController extends Controller
|
final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api method to create a wiki entry
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function apiWikiDocCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
public function apiWikiDocCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
{
|
{
|
||||||
if (!empty($val = $this->validateWikiDocCreate($request))) {
|
if (!empty($val = $this->validateWikiDocCreate($request))) {
|
||||||
|
|
@ -48,6 +61,15 @@ final class ApiController extends Controller
|
||||||
$response->set('doc', $doc->jsonSerialize());
|
$response->set('doc', $doc->jsonSerialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create a wiki entry from request.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return WikiDoc
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function createWikiDocFromRquest(RequestAbstract $request) : WikiDoc
|
public function createWikiDocFromRquest(RequestAbstract $request) : WikiDoc
|
||||||
{
|
{
|
||||||
$mardkownParser = new Markdown();
|
$mardkownParser = new Markdown();
|
||||||
|
|
@ -61,6 +83,15 @@ final class ApiController extends Controller
|
||||||
return $doc;
|
return $doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to validate wiki entry creation from request
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<string, bool>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function validateWikiDocCreate(RequestAbstract $request) : array
|
private function validateWikiDocCreate(RequestAbstract $request) : array
|
||||||
{
|
{
|
||||||
$val = [];
|
$val = [];
|
||||||
|
|
@ -78,6 +109,19 @@ final class ApiController extends Controller
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api method to create a wiki category
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function apiWikiCategoryCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
public function apiWikiCategoryCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
{
|
{
|
||||||
if (!empty($val = $this->validateWikiCategoryCreate($request))) {
|
if (!empty($val = $this->validateWikiCategoryCreate($request))) {
|
||||||
|
|
@ -91,6 +135,15 @@ final class ApiController extends Controller
|
||||||
$response->set('category', $category->jsonSerialize());
|
$response->set('category', $category->jsonSerialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create a wiki category from request.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return WikiCategory
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function createWikiCategoryFromRquest(RequestAbstract $request) : WikiCategory
|
public function createWikiCategoryFromRquest(RequestAbstract $request) : WikiCategory
|
||||||
{
|
{
|
||||||
$mardkownParser = new Markdown();
|
$mardkownParser = new Markdown();
|
||||||
|
|
@ -102,6 +155,15 @@ final class ApiController extends Controller
|
||||||
return $category;
|
return $category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to validate wiki category creation from request
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<string, bool>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function validateWikiCategoryCreate(RequestAbstract $request) : array
|
private function validateWikiCategoryCreate(RequestAbstract $request) : array
|
||||||
{
|
{
|
||||||
$val = [];
|
$val = [];
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,27 @@ class WikiCategory implements \JsonSerializable
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get parent category
|
||||||
|
*
|
||||||
|
* @return null|int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getParent() : ?int
|
public function getParent() : ?int
|
||||||
{
|
{
|
||||||
return $this->parent;
|
return $this->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set parent category
|
||||||
|
*
|
||||||
|
* @param int $parent Parent category
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setParent(int $parent) : void
|
public function setParent(int $parent) : void
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,27 @@ class WikiDoc implements \JsonSerializable
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get language
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getLanguage() : string
|
public function getLanguage() : string
|
||||||
{
|
{
|
||||||
return $this->language;
|
return $this->language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set language
|
||||||
|
*
|
||||||
|
* @param string $language Language
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setLanguage(string $language) : void
|
public function setLanguage(string $language) : void
|
||||||
{
|
{
|
||||||
$this->language = $language;
|
$this->language = $language;
|
||||||
|
|
@ -112,31 +128,79 @@ class WikiDoc implements \JsonSerializable
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get content
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getDoc() : string
|
public function getDoc() : string
|
||||||
{
|
{
|
||||||
return $this->doc;
|
return $this->doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set content
|
||||||
|
*
|
||||||
|
* @param string $doc Document content
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setDoc(string $doc) : void
|
public function setDoc(string $doc) : void
|
||||||
{
|
{
|
||||||
$this->doc = $doc;
|
$this->doc = $doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get status
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getStatus() : int
|
public function getStatus() : int
|
||||||
{
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set status
|
||||||
|
*
|
||||||
|
* @param int $status Status
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setStatus(int $status) : void
|
public function setStatus(int $status) : void
|
||||||
{
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get category
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getCategory()
|
public function getCategory()
|
||||||
{
|
{
|
||||||
return $this->category;
|
return $this->category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set cateogry
|
||||||
|
*
|
||||||
|
* @param int $category Category
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function setCategory(int $category) : void
|
public function setCategory(int $category) : void
|
||||||
{
|
{
|
||||||
$this->category = $category;
|
$this->category = $category;
|
||||||
|
|
@ -180,11 +244,27 @@ class WikiDoc implements \JsonSerializable
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get badges
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function getBadges() : array
|
public function getBadges() : array
|
||||||
{
|
{
|
||||||
return $this->badges;
|
return $this->badges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add badge
|
||||||
|
*
|
||||||
|
* @param mixed $badge Badge
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function addBadge($badge) : void
|
public function addBadge($badge) : void
|
||||||
{
|
{
|
||||||
$this->badges[] = $badge;
|
$this->badges[] = $badge;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user