-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f9d2721
Showing
50 changed files
with
2,610 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* Copyright © Marcin Materzok - MTRZK Sp. z o .o. All rights reserved. | ||
* See LICENSE_MTRZK for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mtrzk\FaqPage\Api\Data; | ||
|
||
/** | ||
* Interface QuestionInterface | ||
* | ||
* @api | ||
* @since 1.0.0 | ||
*/ | ||
interface QuestionInterface | ||
{ | ||
public const ID = 'id'; | ||
public const QUESTION = 'question'; | ||
public const ANSWER = 'answer'; | ||
public const POSITION = 'position'; | ||
public const ACTIVE = 'active'; | ||
public const STORE_IDS = 'store_ids'; | ||
public const CREATED_AT = 'created_at'; | ||
public const UPDATED_AT = 'updated_at'; | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getId(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getQuestion(): string; | ||
|
||
/** | ||
* @param string $question | ||
* | ||
* @return QuestionInterface | ||
*/ | ||
public function setQuestion(string $question): QuestionInterface; | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getAnswer(): ?string; | ||
|
||
/** | ||
* @param string|null $answer | ||
* | ||
* @return QuestionInterface | ||
*/ | ||
public function setAnswer(?string $answer): QuestionInterface; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getPosition(): int; | ||
|
||
/** | ||
* @param int|null $position | ||
* | ||
* @return QuestionInterface | ||
*/ | ||
public function setPosition(?int $position): QuestionInterface; | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isActive(): bool; | ||
|
||
/** | ||
* @param bool $active | ||
* | ||
* @return QuestionInterface | ||
*/ | ||
public function setActive(bool $active): QuestionInterface; | ||
|
||
/** | ||
* @param string $createdAt | ||
* | ||
* @return QuestionInterface | ||
*/ | ||
public function setCreatedAt(string $createdAt): QuestionInterface; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCreatedAt(): string; | ||
|
||
/** | ||
* @param string $updatedAt | ||
* | ||
* @return QuestionInterface | ||
*/ | ||
public function setUpdatedAt(string $updatedAt): QuestionInterface; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUpdatedAt(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Copyright © Marcin Materzok - MTRZK Sp. z o .o. All rights reserved. | ||
* See LICENSE_MTRZK for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mtrzk\FaqPage\Api\Data; | ||
|
||
use Magento\Framework\Api\SearchResultsInterface; | ||
|
||
/** | ||
* Interface QuestionSearchResultInterface | ||
*/ | ||
interface QuestionSearchResultInterface extends SearchResultsInterface | ||
{ | ||
/** | ||
* Get customers list. | ||
* | ||
* @return QuestionInterface[] | ||
*/ | ||
public function getItems(): array; | ||
|
||
/** | ||
* Set customers list. | ||
* | ||
* @param QuestionInterface[] $items | ||
* | ||
* @return QuestionSearchResultInterface | ||
*/ | ||
public function setItems(array $items): self; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* Copyright © Marcin Materzok - MTRZK Sp. z o .o. All rights reserved. | ||
* See LICENSE_MTRZK for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mtrzk\FaqPage\Api; | ||
|
||
use Mtrzk\FaqPage\Api\Data\QuestionInterface; | ||
use Magento\Framework\Api\SearchCriteriaInterface; | ||
use Magento\Framework\Api\SearchResultsInterface; | ||
use Magento\Framework\Exception\CouldNotDeleteException; | ||
use Magento\Framework\Exception\CouldNotSaveException; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
|
||
/** | ||
* Interface QuestionRepositoryInterface | ||
* | ||
* @api | ||
* @since 1.0.0 | ||
*/ | ||
interface QuestionRepositoryInterface | ||
{ | ||
/** | ||
* @param QuestionInterface $question | ||
* | ||
* @return QuestionInterface | ||
* | ||
* @throws CouldNotSaveException | ||
*/ | ||
public function save(QuestionInterface $question): QuestionInterface; | ||
|
||
/** | ||
* @param int $id | ||
* | ||
* @return QuestionInterface | ||
* | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function getById(int $id): QuestionInterface; | ||
|
||
/** | ||
* @param SearchCriteriaInterface $searchCriteria | ||
* | ||
* @return SearchResultsInterface | ||
*/ | ||
public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface; | ||
|
||
/** | ||
* @param mixed $id | ||
* | ||
* @return bool | ||
* | ||
* @throws CouldNotDeleteException | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function delete($id): bool; | ||
|
||
/** | ||
* @param int $id | ||
* | ||
* @return bool | ||
* | ||
* @throws CouldNotDeleteException | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function deleteById(int $id): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Copyright © Marcin Materzok - MTRZK Sp. z o .o. All rights reserved. | ||
* See LICENSE_MTRZK for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mtrzk\FaqPage\Block\Adminhtml\Form\Question; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Back to grid button. | ||
*/ | ||
class Back extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Retrieve Back To Grid button settings. | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData(): array | ||
{ | ||
return $this->wrapButtonSettings( | ||
'Back To Grid', | ||
'back', | ||
sprintf("location.href = '%s';", $this->getUrl('*/*/')), | ||
[], | ||
10 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* Copyright © Marcin Materzok - MTRZK Sp. z o .o. All rights reserved. | ||
* See LICENSE_MTRZK for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mtrzk\FaqPage\Block\Adminhtml\Form\Question; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Delete entity button. | ||
*/ | ||
class Delete extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Retrieve Delete button settings. | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData(): array | ||
{ | ||
return $this->wrapButtonSettings( | ||
'Delete', | ||
'delete', | ||
'deleteConfirm(\'' | ||
. __('Are you sure you want to delete this line configuration?')->render() | ||
. '\', \'' . $this->getUrl('*/*/remove', ['id' => $this->getId()]) . '\')', | ||
[], | ||
20 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* Copyright © Marcin Materzok - MTRZK Sp. z o .o. All rights reserved. | ||
* See LICENSE_MTRZK for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mtrzk\FaqPage\Block\Adminhtml\Form\Question; | ||
|
||
use Magento\Backend\Block\Widget\Context; | ||
use Magento\Framework\UrlInterface; | ||
|
||
/** | ||
* Generic (form) button for FaqPage Question entity. | ||
*/ | ||
class GenericButton | ||
{ | ||
/** @var Context */ | ||
private Context $context; | ||
|
||
/** @var UrlInterface */ | ||
private UrlInterface $urlBuilder; | ||
|
||
/** | ||
* @param Context $context | ||
*/ | ||
public function __construct(Context $context) | ||
{ | ||
$this->context = $context; | ||
$this->urlBuilder = $context->getUrlBuilder(); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId(): int | ||
{ | ||
return (int) $this->context->getRequest()->getParam('id'); | ||
} | ||
|
||
/** | ||
* @param string $label | ||
* @param string $class | ||
* @param string $onclick | ||
* @param array $dataAttribute | ||
* @param int $sortOrder | ||
* | ||
* @return array | ||
*/ | ||
protected function wrapButtonSettings( | ||
string $label, | ||
string $class, | ||
string $onclick = '', | ||
array $dataAttribute = [], | ||
int $sortOrder = 0 | ||
): array { | ||
return [ | ||
'label' => $label, | ||
'on_click' => $onclick, | ||
'data_attribute' => $dataAttribute, | ||
'class' => $class, | ||
'sort_order' => $sortOrder, | ||
]; | ||
} | ||
|
||
/** | ||
* Get url. | ||
* | ||
* @param string $route | ||
* @param array $params | ||
* | ||
* @return string | ||
*/ | ||
protected function getUrl(string $route, array $params = []): string | ||
{ | ||
return $this->urlBuilder->getUrl($route, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Copyright © Marcin Materzok - MTRZK Sp. z o .o. All rights reserved. | ||
* See LICENSE_MTRZK for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mtrzk\FaqPage\Block\Adminhtml\Form\Question; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Save entity button. | ||
*/ | ||
class Save extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Retrieve Save button settings. | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData(): array | ||
{ | ||
return $this->wrapButtonSettings( | ||
'Save', | ||
'save primary', | ||
'', | ||
[ | ||
'mage-init' => ['button' => ['event' => 'save']], | ||
'form-role' => 'save', | ||
], | ||
10 | ||
); | ||
} | ||
} |
Oops, something went wrong.