Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. use SymfonyComponentConsoleCommandCommand;
  2. use SymfonyComponentConsoleInputInputArgument;
  3. use SymfonyComponentConsoleInputInputInterface;
  4. use SymfonyComponentConsoleOutputOutputInterface;
  5. use VendorModuleModelAmountFactory;
  6.  
  7. class AddItem extends Command
  8. {
  9. const INPUT_KEY_ACTION = 'Credit';
  10. const INPUT_KEY_REFERENCE = 'Amount has been credited';
  11. //const INPUT_KEY_AMOUNT = 50;
  12.  
  13. private $amountFactory;
  14.  
  15. public function __construct(AmountFactory $amountFactory)
  16. {
  17.  
  18. $this->amountFactory = $amountFactory;
  19. parent::__construct();
  20.  
  21. }
  22.  
  23. protected function configure()
  24. {
  25.  
  26. $this->setName('example:credit:refund')
  27. ->addArgument(
  28. self::INPUT_KEY_ACTION,
  29. InputArgument::REQUIRED,
  30. 'Action name'
  31. )->addArgument(
  32. self::INPUT_KEY_REFERENCE,
  33. InputArgument::REQUIRED,
  34. 'Action Reference'
  35. );
  36. //$this->setDescription('Demo console command');
  37.  
  38. parent::configure();
  39. }
  40. protected function execute(InputInterface $input, OutputInterface $output)
  41. {
  42. $amount = $this->amountFactory->create();
  43. $amount->setAction($input->getArgument(self::INPUT_KEY_ACTION));
  44. $amount->setReference($input->getArgument(self::INPUT_KEY_REFERENCE));
  45. //$amount->setAmount($input->getArgument(self::INPUT_KEY_AMOUNT));
  46. $amount->setIsObjectNew(true);
  47. $amount->save();
  48. return Cli::RETURN_SUCCESS;
  49. }
  50. }
  51.  
  52. <type name="MagentoFrameworkConsoleCommandList">
  53. <arguments>
  54. <argument name="commands" xsi:type="array">
  55. <item name="rhinosCredit" xsi:type="object">VendorModuleConsoleCommandAddItem</item>
  56. </argument>
  57. </arguments>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement