diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 9220ffc..39f950c 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -71,13 +71,13 @@ final class ApiController extends Controller { if (!empty($val = $this->validateQAQuestionCreate($request))) { $response->set('qa_question_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $question = $this->createQAQuestionFromRequest($request, $response, $data); - $this->createModel($request->getHeader()->getAccount(), $question, QAQuestionMapper::class, 'question', $request->getOrigin()); + $this->createModel($request->header->account, $question, QAQuestionMapper::class, 'question', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Question', 'Question successfully created.', $question); } @@ -97,12 +97,12 @@ final class ApiController extends Controller $mardkownParser = new Markdown(); $question = new QAQuestion(); - $question->setName((string) $request->getData('title')); - $question->setQuestion((string) $request->getData('plain')); + $question->name = (string) $request->getData('title'); + $question->question = (string) $request->getData('plain'); $question->setLanguage((string) $request->getData('language')); $question->setCategory(new NullQACategory((int) $request->getData('category'))); $question->setStatus((int) $request->getData('status')); - $question->setCreatedBy(new NullAccount($request->getHeader()->getAccount())); + $question->createdBy = new NullAccount($request->header->account); if (!empty($tags = $request->getDataJson('tags'))) { foreach ($tags as $tag) { @@ -113,7 +113,7 @@ final class ApiController extends Controller $internalResponse = new HttpResponse(); $this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, $data); - $question->addTag($internalResponse->get($request->getUri()->__toString())['response']); + $question->addTag($internalResponse->get($request->uri->__toString())['response']); } else { $question->addTag(new NullTag((int) $tag['id'])); } @@ -167,13 +167,13 @@ final class ApiController extends Controller { if (!empty($val = $this->validateQAAnswerCreate($request))) { $response->set('qa_answer_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $answer = $this->createQAAnswerFromRequest($request); - $this->createModel($request->getHeader()->getAccount(), $answer, QAAnswerMapper::class, 'answer', $request->getOrigin()); + $this->createModel($request->header->account, $answer, QAAnswerMapper::class, 'answer', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Answer', 'Answer successfully created.', $answer); } @@ -191,10 +191,10 @@ final class ApiController extends Controller $mardkownParser = new Markdown(); $answer = new QAAnswer(); - $answer->setAnswer((string) $request->getData('plain')); - $answer->setQuestion(new NullQAQuestion((int) $request->getData('question'))); + $answer->answer = (string) $request->getData('plain'); + $answer->question = new NullQAQuestion((int) $request->getData('question')); $answer->setStatus((int) $request->getData('status')); - $answer->setCreatedBy(new NullAccount($request->getHeader()->getAccount())); + $answer->createdBy = new NullAccount($request->header->account); return $answer; } @@ -241,21 +241,21 @@ final class ApiController extends Controller { if (!empty($val = $this->validateQACategoryCreate($request))) { $response->set('qa_category_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $category = $this->createQACategoryFromRequest($request); - $this->createModel($request->getHeader()->getAccount(), $category, QACategoryMapper::class, 'category', $request->getOrigin()); + $this->createModel($request->header->account, $category, QACategoryMapper::class, 'category', $request->getOrigin()); - $l11nRequest = new HttpRequest($request->getUri()); + $l11nRequest = new HttpRequest($request->uri); $l11nRequest->setData('category', $category->getId()); $l11nRequest->setData('name', $request->getData('name')); $l11nRequest->setData('language', $request->getData('language')); $l11nQACategory = $this->createQACategoryL11nFromRequest($l11nRequest); - $this->createModel($request->getHeader()->getAccount(), $l11nQACategory, QACategoryL11nMapper::class, 'tag_l11n', $request->getOrigin()); + $this->createModel($request->header->account, $l11nQACategory, QACategoryL11nMapper::class, 'tag_l11n', $request->getOrigin()); $category->setName($l11nQACategory); @@ -277,7 +277,7 @@ final class ApiController extends Controller //$category->setApp(new NullQAApp((int) ($request->getData('app') ?? 1))); if ($request->getData('parent') !== null) { - $category->setParent(new NullQACategory((int) $request->getData('parent'))); + $category->parent = new NullQACategory((int) $request->getData('parent')); } return $category; @@ -340,13 +340,13 @@ final class ApiController extends Controller { if (!empty($val = $this->validateQACategoryL11nCreate($request))) { $response->set('qa_category_l11n_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $l11nQACategory = $this->createQACategoryL11nFromRequest($request); - $this->createModel($request->getHeader()->getAccount(), $l11nQACategory, QACategoryL11nMapper::class, 'qa_category_l11n', $request->getOrigin()); + $this->createModel($request->header->account, $l11nQACategory, QACategoryL11nMapper::class, 'qa_category_l11n', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Category localization successfully created', $l11nQACategory); } @@ -367,7 +367,7 @@ final class ApiController extends Controller $l11nQACategory->setLanguage((string) ( $request->getData('language') ?? $request->getLanguage() )); - $l11nQACategory->setName((string) ($request->getData('name') ?? '')); + $l11nQACategory->name = (string) ($request->getData('name') ?? ''); return $l11nQACategory; } diff --git a/Models/QAAnswer.php b/Models/QAAnswer.php index ccdbe3a..44dc0a8 100755 --- a/Models/QAAnswer.php +++ b/Models/QAAnswer.php @@ -43,7 +43,7 @@ class QAAnswer implements \JsonSerializable * @var string * @since 1.0.0 */ - private $answer = ''; + public $answer = ''; /** * Answer raw. @@ -51,7 +51,7 @@ class QAAnswer implements \JsonSerializable * @var string * @since 1.0.0 */ - private $answerRaw = ''; + public $answerRaw = ''; /** * Question @@ -59,7 +59,7 @@ class QAAnswer implements \JsonSerializable * @var QAQuestion * @since 1.0.0 */ - private QAQuestion $question; + public QAQuestion $question; /** * Is accepted answer. @@ -75,7 +75,7 @@ class QAAnswer implements \JsonSerializable * @var Account * @since 1.0.0 */ - private Account $createdBy; + public Account $createdBy; /** * Created at. @@ -83,7 +83,7 @@ class QAAnswer implements \JsonSerializable * @var \DateTimeImmutable * @since 1.0.0 */ - private \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; /** * Constructor. @@ -213,44 +213,6 @@ class QAAnswer implements \JsonSerializable return $this->isAccepted; } - /** - * Get created by - * - * @return Account - * - * @since 1.0.0 - */ - public function getCreatedBy() : Account - { - return $this->createdBy; - } - - /** - * Set created by - * - * @param Account $account Creator - * - * @return void - * - * @since 1.0.0 - */ - public function setCreatedBy(Account $account) : void - { - $this->createdBy = $account; - } - - /** - * Get created at - * - * @return \DateTimeImmutable - * - * @since 1.0.0 - */ - public function getCreatedAt() : \DateTimeImmutable - { - return $this->createdAt; - } - /** * {@inheritdoc} */ diff --git a/Models/QACategory.php b/Models/QACategory.php index d8440a8..7a66b6e 100755 --- a/Models/QACategory.php +++ b/Models/QACategory.php @@ -45,10 +45,20 @@ class QACategory implements \JsonSerializable /** * Parent category. * - * @var null|QACategory + * @var QACategory * @since 1.0.0 */ - private ?self $parent = null; + public self $parent; + + /** + * Constructor. + * + * @sicne 1.0.0 + */ + public function __construct() + { + $this->parent = new NullQACategory(); + } /** * Get id. @@ -88,40 +98,14 @@ class QACategory implements \JsonSerializable if ($name instanceof QACategoryL11n) { $this->name = $name; } elseif ($this->name instanceof QACategoryL11n && \is_string($name)) { - $this->name->setName($name); + $this->name->name = $name; } elseif (\is_string($name)) { $this->name = new QACategoryL11n(); - $this->name->setName($name); + $this->name->name = $name; $this->name->setLanguage($lang); } } - /** - * Get the parent category - * - * @return null|self - * - * @since 1.0.0 - */ - public function getParent() : ?self - { - return $this->parent; - } - - /** - * Set the parent category - * - * @param null|self $parent Parent category - * - * @return void - * - * @since 1.0.0 - */ - public function setParent(?self $parent) : void - { - $this->parent = $parent; - } - /** * {@inheritdoc} */ diff --git a/Models/QACategoryL11n.php b/Models/QACategoryL11n.php index 58dcd01..1a09750 100644 --- a/Models/QACategoryL11n.php +++ b/Models/QACategoryL11n.php @@ -57,7 +57,7 @@ class QACategoryL11n implements \JsonSerializable, ArrayableInterface * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Constructor. @@ -148,20 +148,6 @@ class QACategoryL11n implements \JsonSerializable, ArrayableInterface return $this->name; } - /** - * Set name - * - * @param string $name Name - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - /** * {@inheritdoc} */ diff --git a/Models/QAQuestion.php b/Models/QAQuestion.php index e2a62f5..991e09f 100755 --- a/Models/QAQuestion.php +++ b/Models/QAQuestion.php @@ -42,7 +42,7 @@ class QAQuestion implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Question status. @@ -58,7 +58,7 @@ class QAQuestion implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $question = ''; + public string $question = ''; /** * Category. @@ -82,7 +82,7 @@ class QAQuestion implements \JsonSerializable * @var Account * @since 1.0.0 */ - private Account $createdBy; + public Account $createdBy; /** * Created at. @@ -90,7 +90,7 @@ class QAQuestion implements \JsonSerializable * @var \DateTimeImmutable * @since 1.0.0 */ - private \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; /** * Tags. @@ -193,58 +193,6 @@ class QAQuestion implements \JsonSerializable return false; } - /** - * Get title. - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Set name. - * - * @param string $name Name - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - - /** - * Get the question. - * - * @return string - * - * @since 1.0.0 - */ - public function getQuestion() : string - { - return $this->question; - } - - /** - * Set the question - * - * @param string $question Question - * - * @return void - * - * @since 1.0.0 - */ - public function setQuestion(string $question) : void - { - $this->question = $question; - } - /** * Get the status * @@ -297,44 +245,6 @@ class QAQuestion implements \JsonSerializable $this->category = $category; } - /** - * Get created by - * - * @return Account - * - * @since 1.0.0 - */ - public function getCreatedBy() : Account - { - return $this->createdBy; - } - - /** - * Set created by - * - * @param Account $account Created by - * - * @return void - * - * @since 1.0.0 - */ - public function setCreatedBy(Account $account) : void - { - $this->createdBy = $account; - } - - /** - * Get created at date time - * - * @return \DateTimeImmutable - * - * @since 1.0.0 - */ - public function getCreatedAt() : \DateTimeImmutable - { - return $this->createdAt; - } - /** * Get tags * diff --git a/Theme/Backend/qa-dashboard.tpl.php b/Theme/Backend/qa-dashboard.tpl.php index 11a863d..dcce917 100755 --- a/Theme/Backend/qa-dashboard.tpl.php +++ b/Theme/Backend/qa-dashboard.tpl.php @@ -25,7 +25,7 @@ echo $this->getData('nav')->render(); ?> = $this->printHtml(\count($question->getAnswers())); ?>