Tax.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Controller\Adminhtml;
  7. use Magento\Framework\Exception\InputException;
  8. /**
  9. * Adminhtml common tax class controller
  10. *
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. */
  13. abstract class Tax extends \Magento\Backend\App\Action
  14. {
  15. /**
  16. * Authorization level of a basic admin session
  17. *
  18. * @see _isAllowed()
  19. */
  20. const ADMIN_RESOURCE = 'Magento_Tax::manage_tax';
  21. /**
  22. * @var \Magento\Tax\Api\TaxClassRepositoryInterface
  23. */
  24. protected $taxClassRepository;
  25. /**
  26. * @var \Magento\Tax\Api\Data\TaxClassInterfaceFactory
  27. */
  28. protected $taxClassDataObjectFactory;
  29. /**
  30. * @param \Magento\Backend\App\Action\Context $context
  31. * @param \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService
  32. * @param \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory
  33. */
  34. public function __construct(
  35. \Magento\Backend\App\Action\Context $context,
  36. \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService,
  37. \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory
  38. ) {
  39. $this->taxClassRepository = $taxClassService;
  40. $this->taxClassDataObjectFactory = $taxClassDataObjectFactory;
  41. parent::__construct($context);
  42. }
  43. /**
  44. * Validate/Filter Tax Class Name
  45. *
  46. * @param string $className
  47. * @return string processed class name
  48. * @throws \Magento\Framework\Exception\InputException
  49. */
  50. protected function _processClassName($className)
  51. {
  52. $className = trim($className);
  53. if ($className == '') {
  54. throw new InputException(__('Invalid name of tax class specified.'));
  55. }
  56. return $className;
  57. }
  58. }