b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / app / code / MageWorx / GiftCards / Controller / Adminhtml / GiftCards /
Filename/home/dev2.destoffenstraat.com/app/code/MageWorx/GiftCards/Controller/Adminhtml/GiftCards/Edit.php
Size2.99 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified13-May-2022 10:39
Last accessed22-Aug-2025 19:38
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © MageWorx. All rights reserved.
* See LICENSE.txt for license details.
*/

namespace MageWorx\GiftCards\Controller\Adminhtml\GiftCards;

use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\Registry;

class Edit extends \Magento\Backend\App\Action
{
/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* @var \MageWorx\GiftCards\Model\GiftCardsRepository
*/
protected $giftCardsRepository;

/**
* @var \MageWorx\GiftCards\Model\GiftCardsFactory
*/
protected $giftCardsFactory;

/**
* @var \Magento\Framework\Registry
*/
protected $registry;

/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
Registry $registry,
\MageWorx\GiftCards\Model\GiftCardsFactory $giftCardsFactory,
\MageWorx\GiftCards\Model\GiftCardsRepository $giftCardsRepository
) {
$this->resultPageFactory = $resultPageFactory;
$this->registry = $registry;
$this->giftCardsRepository = $giftCardsRepository;
$this->giftCardsFactory = $giftCardsFactory;
parent::__construct($context);
}

protected function _initAction()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('MageWorx_GiftCards::giftcards_giftcards')
->addBreadcrumb(__('Giftcards'), __('Giftcards'))
->addBreadcrumb(__('Manage Giftc Cards'), __('Manage Gift Cards'));

return $resultPage;
}

public function execute()
{
$giftCardId = (int)$this->getRequest()->getParam('card_id');

if ($giftCardId) {
$giftCard = $this->giftCardsRepository->get($giftCardId);
} else {
$giftCard = $this->giftCardsFactory->create();
$giftCard->setData([]);
}

$data = $this->_objectManager->get('\Magento\Backend\Model\Session')->getFormData(true);
if (!empty($data)) {
$giftCard->setData($data);
}

$this->registry->register('mageworx_current_giftcard', $giftCard);

$resultPage = $this->_initAction();

$resultPage->addBreadcrumb(
$giftCardId ? __('Edit Gift Card' . ' ' . $giftCard->getCardCode()) : __('New Gift Card'),
$giftCardId ? __('Edit Gift Card' . ' ' . $giftCard->getCardCode()) : __('New Gift Card')
);

$resultPage->getConfig()->getTitle()->prepend(__('Gift Cards'));
$resultPage->getConfig()->getTitle()
->prepend(
$giftCard->getId() ? __('Gift Card' . ' ' . $giftCard->getCardCode()) : __('New Gift Card')
);

return $resultPage;
}

protected function _isAllowed()
{
return $this->_authorization->isAllowed('MageWorx_GiftCards::mageworx_giftcards_giftcards');
}
}