Skip to content

Instantly share code, notes, and snippets.

@ger86
Last active March 7, 2019 10:52
Show Gist options
  • Save ger86/0f712457d0fefe16614511e044842ca3 to your computer and use it in GitHub Desktop.
Save ger86/0f712457d0fefe16614511e044842ca3 to your computer and use it in GitHub Desktop.
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\StripePlan;
use App\Service\StripeCreateYearlyPlan;
class StripeCreateYearlyPlanCommand extends Command {
protected static $defaultName = 'app:stripe:create-yearly-plan';
/**
* @param StripeCreateYearlyPlan $createAdmin
*/
public function __construct(
EntityManagerInterface $em,
StripeCreateYearlyPlan $stripeCreateYearlyPlan
) {
$this->stripeCreateYearlyPlan = $stripeCreateYearlyPlan;
$this->em = $em;
parent::__construct();
}
protected function configure() {
$this
->setDescription('Creates the yearly plan')
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
$amount = 20.00;
$name = 'Suscripción anual';
$planInfo = ($this->stripeCreateYearlyPlan)($name, $amount);
$stripePlan = new StripePlan();
$stripePlan->setAmount($amount);
$stripePlan->setName($name);
$stripePlan->setPlanId($planInfo->id);
$stripePlan->setProductId($planInfo->product);
$this->em->persist($stripePlan);
$this->em->flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment