Skip to content

Instantly share code, notes, and snippets.

@kolomiec-valeriy
Created September 30, 2019 13:55
Show Gist options
  • Save kolomiec-valeriy/55ca2e7e26981f3890bf8ee55334930a to your computer and use it in GitHub Desktop.
Save kolomiec-valeriy/55ca2e7e26981f3890bf8ee55334930a to your computer and use it in GitHub Desktop.
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use App\Subscription\IosSubscriptionManager;
use App\Entity\Subscription\IAPIosReceipt;
use Psr\Log\LoggerInterface;
class FixReceiptsWithoutUsersController extends Controller
{
/**
* @Route("/fix-receipts")
* @param IosSubscriptionManager $manager
* @param LoggerInterface $logger
*
* @return JsonResponse
*/
public function fixReceiptsWithoutUsers(IosSubscriptionManager $manager)
{
$receipts = $this->getDoctrine()->getRepository(IAPIosReceipt::class)->findBy([
'account' => null,
]);
/** @var IAPIosReceipt $receipt */
foreach ($receipts as $receipt) {
if (!$receipt->getAccount()) {
$manager->queue($receipt);
}
}
return $this->json('Found receipts without users - '.count($receipts));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment