Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13 Tipos de documentos administrables #25

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Api/CidTypesRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Customer Identification Document
*
* @category Mugar
* @package Mugar_CustomerIdentificationDocument
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Mugar (https://www.mugar.io/)
*
*/

namespace Mugar\CustomerIdentificationDocument\Api;

use Magento\Framework\Api\SearchCriteriaInterface;
use Mugar\CustomerIdentificationDocument\Api\Data\CidTypeInterface;

/**
* @api
*/
interface CidTypesRepositoryInterface
{
/**
* @param CidTypeInterface $cidType
* @return CidTypeInterface
*/
public function save(CidTypeInterface $cidType);

/**
* @param $id
* @return CidTypeInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function get($id);

/**
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \Mugar\CustomerIdentificationDocument\Api\Data\CidTypeSearchResultInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getList(SearchCriteriaInterface $searchCriteria);

/**
* @param CidTypeInterface $cidType
* @return bool true on success
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function delete(CidTypeInterface $cidType);

/**
* @param int $cidTypeId
* @return bool true on success
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function deleteById($cidTypeId);

/**
* clear caches instances
* @return void
*/
public function clear();
}
55 changes: 55 additions & 0 deletions Api/Data/CidTypeInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Customer Identification Document
*
* @category Mugar
* @package Mugar_CustomerIdentificationDocument
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Mugar (https://www.mugar.io/)
*
*/

namespace Mugar\CustomerIdentificationDocument\Api\Data;

/**
* @api
*/
interface CidTypeInterface
{
const ID = 'cid_type_id';
const NAME = 'name';
const ACTIVE = 'active';

/**
* @param int $id
* @return CidTypeInterface
*/
public function setCidTypeId($id);

/**
* @return int
*/
public function getCidTypeId();

/**
* @param string $name
* @return CidTypeInterface
*/
public function setName($name);

/**
* @return string
*/
public function getName();

/**
* @param int $active
* @return CidTypeInterface
*/
public function setActive($active);

/**
* @return bool
*/
public function getActive();
}
47 changes: 47 additions & 0 deletions Api/Data/CidTypeSearchResultInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Customer Identification Document
*
* @category Mugar
* @package Mugar_CustomerIdentificationDocument
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Mugar (https://www.mugar.io/)
*
*/

namespace Mugar\CustomerIdentificationDocument\Api\Data;

use Magento\Framework\Api\SearchCriteriaInterface;

/**
* @api
*/
interface CidTypeSearchResultInterface
{
/**
* get items
*
* @return \Mugar\CustomerIdentificationDocument\Api\Data\CidTypeInterface[]
*/
public function getItems();

/**
* Set items
*
* @param \Mugar\CustomerIdentificationDocument\Api\Data\CidTypeInterface[] $items
* @return $this
*/
public function setItems(array $items);

/**
* @param SearchCriteriaInterface $searchCriteria
* @return $this
*/
public function setSearchCriteria(SearchCriteriaInterface $searchCriteria);

/**
* @param int $count
* @return $this
*/
public function setTotalCount($count);
}
24 changes: 24 additions & 0 deletions Api/ExecutorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Customer Identification Document
*
* @category Mugar
* @package Mugar_CustomerIdentificationDocument
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Mugar (https://www.mugar.io/)
*
*/

namespace Mugar\CustomerIdentificationDocument\Api;

/**
* @api
*/
interface ExecutorInterface
{
/**
* execute
* @param int $id
*/
public function execute($id);
}
48 changes: 48 additions & 0 deletions Block/Adminhtml/Button/Back.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Customer Identification Document
*
* @category Mugar
* @package Mugar_CustomerIdentificationDocument
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Mugar (https://www.mugar.io/)
*
*/

namespace Mugar\CustomerIdentificationDocument\Block\Adminhtml\Button;

use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class Back implements ButtonProviderInterface
{
/**
* @var UrlInterface
*/
private $url;

/**
* Back constructor.
* @param UrlInterface $url
*/
public function __construct(
UrlInterface $url
) {
$this->url = $url;
}

/**
* get button data
*
* @return array
*/
public function getButtonData()
{
return [
'label' => __('Back'),
'on_click' => sprintf("location.href = '%s';", $this->url->getUrl('*/*/')),
'class' => 'back',
'sort_order' => 10,
];
}
}
94 changes: 94 additions & 0 deletions Block/Adminhtml/Button/CidType/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* Customer Identification Document
*
* @category Mugar
* @package Mugar_CustomerIdentificationDocument
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Mugar (https://www.mugar.io/)
*
*/

namespace Mugar\CustomerIdentificationDocument\Block\Adminhtml\Button\CidType;

use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
use Mugar\CustomerIdentificationDocument\Api\Data\CidTypeInterface;
use Mugar\CustomerIdentificationDocument\Registry\CidType as CidTypeRegistry;

class Delete implements ButtonProviderInterface
{
/**
* @var CidTypeRegistry
*/
private $registry;

/**
* @var UrlInterface
*/
private $url;

/**
* Delete constructor.
* @param CidTypeRegistry $registry
* @param UrlInterface $url
*/
public function __construct(
CidTypeRegistry $registry,
UrlInterface $url
) {
$this->registry = $registry;
$this->url = $url;
}

/**
* get button data
*
* @return array
*/
public function getButtonData()
{
$data = [];
if ($this->getCidTypeId()) {
$data = [
'label' => __('Delete Document Type'),
'class' => 'delete',
'on_click' => 'deleteConfirm(\'' . __(
'Are you sure you want to do this?'
) . '\', \'' . $this->getDeleteUrl() . '\')',
'sort_order' => 20,
];
}
return $data;
}

/**
* @return CidTypeInterface | null
*/
private function getCidType()
{
return $this->registry->get();
}

/**
* @return int|null
*/
private function getCidTypeId()
{
$item = $this->getCidType();
return ($item) ? $item->getId() : null;
}

/**
* @return string
*/
public function getDeleteUrl()
{
return $this->url->getUrl(
'*/*/delete',
[
'cid_type_id' => $this->getCidTypeId(),
]
);
}
}
32 changes: 32 additions & 0 deletions Block/Adminhtml/Button/Reset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Customer Identification Document
*
* @category Mugar
* @package Mugar_CustomerIdentificationDocument
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @author Mugar (https://www.mugar.io/)
*
*/

namespace Mugar\CustomerIdentificationDocument\Block\Adminhtml\Button;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class Reset implements ButtonProviderInterface
{
/**
* get button data
*
* @return array
*/
public function getButtonData()
{
return [
'label' => __('Reset'),
'class' => 'reset',
'on_click' => 'location.reload();',
'sort_order' => 30
];
}
}
Loading