Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use SymfonyComponentConsoleCommandCommand;
- use SymfonyComponentConsoleInputInputArgument;
- use SymfonyComponentConsoleInputInputInterface;
- use SymfonyComponentConsoleOutputOutputInterface;
- use VendorModuleModelAmountFactory;
- class AddItem extends Command
- {
- const INPUT_KEY_ACTION = 'Credit';
- const INPUT_KEY_REFERENCE = 'Amount has been credited';
- //const INPUT_KEY_AMOUNT = 50;
- private $amountFactory;
- public function __construct(AmountFactory $amountFactory)
- {
- $this->amountFactory = $amountFactory;
- parent::__construct();
- }
- protected function configure()
- {
- $this->setName('example:credit:refund')
- ->addArgument(
- self::INPUT_KEY_ACTION,
- InputArgument::REQUIRED,
- 'Action name'
- )->addArgument(
- self::INPUT_KEY_REFERENCE,
- InputArgument::REQUIRED,
- 'Action Reference'
- );
- //$this->setDescription('Demo console command');
- parent::configure();
- }
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $amount = $this->amountFactory->create();
- $amount->setAction($input->getArgument(self::INPUT_KEY_ACTION));
- $amount->setReference($input->getArgument(self::INPUT_KEY_REFERENCE));
- //$amount->setAmount($input->getArgument(self::INPUT_KEY_AMOUNT));
- $amount->setIsObjectNew(true);
- $amount->save();
- return Cli::RETURN_SUCCESS;
- }
- }
- <type name="MagentoFrameworkConsoleCommandList">
- <arguments>
- <argument name="commands" xsi:type="array">
- <item name="rhinosCredit" xsi:type="object">VendorModuleConsoleCommandAddItem</item>
- </argument>
- </arguments>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement