Last active
March 7, 2019 10:52
-
-
Save ger86/0f712457d0fefe16614511e044842ca3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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