Skip to content
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
266 changes: 266 additions & 0 deletions .dev-tools/stubs/BackendAction.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
<?php
declare(strict_types=1);

namespace Magento\Backend\App;

use Magento\Framework\App\Action\AbstractAction;

/**
* All Backend Controllers (Adminhtml) inherit from this abstract class.
*/
abstract class Action extends AbstractAction
{
/**
* Authorization level of a basic admin session
*/
const ADMIN_RESOURCE = 'Magento_Backend::admin';

/**
* @var \Magento\Framework\AuthorizationInterface
*/
protected $_authorization;

/**
* @var \Magento\Backend\Model\Auth
*/
protected $_auth;

/**
* @var \Magento\Backend\Helper\Data
*/
protected $_helper;

/**
* @var \Magento\Backend\Model\UrlInterface
*/
protected $_backendUrl;

/**
* @var \Magento\Framework\Data\Form\FormKey\Validator
*/
protected $_formKeyValidator;

/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
protected $_localeResolver;

/**
* @var bool
*/
protected $_canUseBaseUrl;

/**
* @var \Magento\Backend\Model\Session
*/
protected $_session;

/**
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(\Magento\Backend\App\Action\Context $context)
{
parent::__construct($context);
$this->_authorization = $context->getAuthorization();
$this->_auth = $context->getAuth();
$this->_helper = $context->getHelper();
$this->_backendUrl = $context->getBackendUrl();
$this->_formKeyValidator = $context->getFormKeyValidator();
$this->_localeResolver = $context->getLocaleResolver();
$this->_canUseBaseUrl = $context->getCanUseBaseUrl();
$this->_session = $context->getSession();
}

/**
* Determine if current user is allowed to access this controller action.
*
* @return bool
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed(static::ADMIN_RESOURCE);
}

/**
* Populate the layout menu item as active
*
* @param string $menuId
* @return $this
*/
protected function _setActiveMenu($menuId)
{
return $this;
}

/**
* Generate crumbs for layout block
*
* @param string $label
* @param string $title
* @param string|null $link
* @return $this
*/
protected function _addBreadcrumb($label, $title, $link = null)
{
return $this;
}
}

namespace Magento\Backend\App\Action;

/**
* Shared context container passed into Backend Actions via Dependency Injection.
*/
class Context extends \Magento\Framework\App\Action\Context
{
/**
* @return \Magento\Framework\AuthorizationInterface
*/
public function getAuthorization() {}

/**
* @return \Magento\Backend\Model\Auth
*/
public function getAuth() {}

/**
* @return \Magento\Backend\Helper\Data
*/
public function getHelper() {}

/**
* @return \Magento\Backend\Model\UrlInterface
*/
public function getBackendUrl() {}

/**
* @return \Magento\Framework\Data\Form\FormKey\Validator
*/
public function getFormKeyValidator() {}

/**
* @return \Magento\Framework\Locale\ResolverInterface
*/
public function getLocaleResolver() {}

/**
* @return bool
*/
public function getCanUseBaseUrl() {}

/**
* @return \Magento\Backend\Model\Session
*/
public function getSession() {}
}

namespace Magento\Framework\App\Action;

use Magento\Framework\App\ActionInterface;

/**
* Underlying Framework action hierarchy
*/
abstract class AbstractAction implements ActionInterface
{
/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $_request;

/**
* @var \Magento\Framework\App\ResponseInterface
*/
protected $_response;

/**
* @var \Magento\Framework\Controller\ResultFactory
*/
protected $resultFactory;

/**
* @var \Magento\Framework\Controller\Result\RedirectFactory
*/
protected $resultRedirectFactory;

/**
* @var \Magento\Framework\Message\ManagerInterface
*/
protected $messageManager;

/**
* @param \Magento\Framework\App\Action\Context $context
*/
public function __construct(\Magento\Framework\App\Action\Context $context)
{
$this->_request = $context->getRequest();
$this->_response = $context->getResponse();
$this->resultFactory = $context->getResultFactory();
$this->resultRedirectFactory = $context->getResultRedirectFactory();
$this->messageManager = $context->getMessageManager();
}

/**
* @return \Magento\Framework\App\RequestInterface
*/
public function getRequest()
{
return $this->_request;
}

/**
* @return \Magento\Framework\App\ResponseInterface
*/
public function getResponse()
{
return $this->_response;
}
}

namespace Magento\Framework\App;

/**
* Core execution interface for Magento controllers.
*/
interface ActionInterface
{
/**
* Execute action based on request and return result
*
* @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\ResponseInterface
*/
public function execute();
}

namespace Magento\Framework\App\Action;

/**
* Core Action Context definition
*/
class Context
{
/**
* @return \Magento\Framework\App\RequestInterface
*/
public function getRequest() {}

/**
* @return \Magento\Framework\App\ResponseInterface
*/
public function getResponse() {}

/**
* @return \Magento\Framework\Controller\ResultFactory
*/
public function getResultFactory() {}

/**
* @return \Magento\Framework\Controller\Result\RedirectFactory
*/
public function getResultRedirectFactory() {}

/**
* @return \Magento\Framework\Message\ManagerInterface
*/
public function getMessageManager() {}
}
65 changes: 65 additions & 0 deletions .dev-tools/stubs/EmailTemplate.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);

namespace Magento\Config\Model\Config\Source\Email;

use Magento\Framework\Data\OptionSourceInterface;

/**
* Source model providing lists of transactional email templates for configuration dropdowns.
*/
class Template implements OptionSourceInterface
{
/**
* @var \Magento\Email\Model\ResourceModel\Template\CollectionFactory
*/
protected $_templatesFactory;

/**
* @var \Magento\Email\Model\Template\Config
*/
protected $_emailConfig;

/**
* @param \Magento\Email\Model\ResourceModel\Template\CollectionFactory $templatesFactory
* @param \Magento\Email\Model\Template\Config $emailConfig
*/
public function __construct(
\Magento\Email\Model\ResourceModel\Template\CollectionFactory $templatesFactory,
\Magento\Email\Model\Template\Config $emailConfig
) {
$this->_templatesFactory = $templatesFactory;
$this->_emailConfig = $emailConfig;
}

/** @return string */
public function getPath()
{}

/**
* Return array of options as key-value pairs for dropdown fields.
*
* @return array
*/
public function toOptionArray()
{
return [
['value' => 'string_template_id', 'label' => 'Template Label']
];
}
}

namespace Magento\Framework\Data;

/**
* Core interface required for any UI component or adminhtml system config source model.
*/
interface OptionSourceInterface
{
/**
* Return array of options as a multi-dimensional array containing value and label keys.
*
* @return array
*/
public function toOptionArray();
}
Loading
Loading