Bir bitiş noktası yürütmek için bir symfony konsol komutu oluşturmaya çalışıyorum.Symfony 2 - Bir denetleyici yöntemini konsol komutundan çağırılıyor
BillingBundle/Komut/RejectCommand.php
<?php
namespace BillingBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class RejectCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('cron:rejectLines')
->setDescription('Executes the RejectLines cron');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln("Starting the cron");
// Call the method here
$output->writeln("Cron completed");
}
}
?>
Ben
BillingBundle/Hizmetler/SalesOrderService.php
/**
* @InjectParams({
* "repository" = @Inject("billing.repository.sales_order"),
* "sapInterface" = @Inject("external.sap_sales_order_interface"),
* "articleService" = @Inject("stream_one.product.interface.solution_store_product_service"),
* "logger" = @Inject("logger")
* })
*/
public function __construct(SalesOrderRepositoryInterface $repository, SapSalesOrderInterface $sapInterface, ArticleService $articleService, Logger $logger) {
$this->repository = $repository;
$this->sapInterface = $sapInterface;
$this->articleService = $articleService;
$this->logger = $logger;
}
/**
* CRON: Reject lines
*
* @Post("/rejectLines", name="reject_lines_post")
*/
public function rejectSalesOrderLines() {
// do some stuff and quit silently
}
arayıp uç nokta
tanımlanan çalışıyorum
POSTman kullanarak son nokta/reddetme satırları aradığımda bu iyi çalışır. Ancak, ben bu yüzden
php app/konsol cron çağırdığınızda o konsol komutundan diyorsunuz nasıl emin değilim: rejectLines
çalışıyor.
Bu benim elde etmek istediğim şeydir. SalesOrderService sınıf __construct geçirilen bazı argümanları çünkü
$cron = new SalesOrderService();
$cron->rejectSalesOrderLines();
Ancak, ben komut üzerinden arama yaparken bunu geçebilir nasıl emin değilim. Herhangi bir fikir ?
Eğer CLI çalıştırmak için denediniz bu yardım? Çıktı nedir? –