Привет всем, у меня есть пакет отчетов и служба AdminUsersStatsListBlockService, которой нужен UserRepository.php в пакете отчетов для доступа к функции, я попытался добавить BookingBundle.php в пакете отчетов к функции конструкции, но я продолжаю конструировать безвот мой код и мои ошибки:
ЗДЕСЬ AdminUsersStatsListBlockService.php (поэтому я попытался добавить сюда репозиторий Booking):
<?php
/*
* This file is part of the Cocorico package.
*
* (c) Cocolabs SAS <contact@cocolabs.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cocorico\ReportBundle\Block\Service;
use Cocorico\BookingBundle\Entity\Booking;
use Cocorico\ReportBundle\Repository\UserRepository;
use Cocorico\ReportBundle\Repository\BookingRepository; /*(added)*/
use Sonata\AdminBundle\Admin\Pool;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\CoreBundle\Validator\ErrorElement;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
class AdminUsersStatsListBlockService extends AbstractBlockService
{
protected $userRepository;
protected $bookingRepository;/*(added)*/
protected $adminPool;
/**
* @param string $name
* @param EngineInterface $templating
* @param UserRepository $userRepository
* @param Pool $adminPool
* @param BookingRepository $bookingRepository/*(added)*/
*/
public function __construct(
$name,
EngineInterface $templating,
UserRepository $userRepository,
Pool $adminPool = null,
BookingRepository $bookingRepository/*(added)*/
) {
parent::__construct($name, $templating);
$this->userRepository = $userRepository;
$this->bookingRepository = $bookingRepository;/*(added)*/
$this->adminPool = $adminPool;
}
/**
* {@inheritdoc}
*/
public function execute(BlockContextInterface $blockContext, Response $response = null)
{
$stat = $blockContext->getSetting('stat');
switch ($stat) {
case 'offerers-expiring':
$results = $this->userRepository->getTopOfferersWithBookingsStatusCount(
Booking::STATUS_EXPIRED,
null,
null,
$blockContext->getSetting('limit')
);
break;
case 'offerers-refusing':
$results = $this->userRepository->getTopOfferersWithBookingsStatusCount(
Booking::STATUS_REFUSED,
null,
null,
$blockContext->getSetting('limit')
);
break;
case 'offerers-accepting':
$results = $this->userRepository->getTopOfferersWithBookingsStatusCount(
Booking::STATUS_PAYED,
null,
null,
$blockContext->getSetting('limit')
);
break;
case 'bookings-expired-list':
$results = $this->bookingRepository->getBookingsExpired(); /*there i want to use it*/
break;
default:
$results = array();
}
return $this->renderResponse(
$blockContext->getTemplate(),
array(
'block' => $blockContext->getBlock(),
'settings' => $blockContext->getSettings(),
'results' => $results,
'admin_pool' => $this->adminPool,
),
$response
);
}
}
Вот ошибка, которую я получаю:
request.CRITICAL: необработанное исключение PHP Symfony \ Component \ Debug \ Exception \ FatalThrowableError: "Ошибка типа: слишком мало аргументов для функции Cocorico \ ReportBundle \ Block \ Service \ AdminUsersStatsListBlockService :: __ construct (), 4 передано в / var /www / Symfony / var / cache / prod / Container7aqlalh / getCocoricoReport_Admin_Block_Users_StatsListService.php в строке 13 и ожидается ровно 5 "по адресу /var/www/Symfony/vendor/cocorico/report-bundle/Block/Service/Lister/ListUpserUисключение ":" [объект] (Symfony \ Component \ Debug \ Exception \ FatalThrowableError (код: 0): ошибка типа: слишком мало аргументов для функции Cocorico \ ReportBundle \ Block \ Service \ AdminUsersStatsListBlockService :: __ construct (), 4 передано в / var / www / Symfony / var / cache /prod / Container7aqlalh / getCocoricoReport_Admin_Block_Users_StatsListService.php в строке 13 и ровно 5 ожидаемых в /var/www/Symfony/vendor/cocorico/report-bundle/Block/Service/AdminUsersStatsListBlockService * [101]] * [101] php
и контейнер все еще не создается с помощью репозитория бронирования:
<?php
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'cocorico_report.admin.block.users.stats_list' shared service.
include_once $this->targetDirs[3].'/vendor/sonata-project/block-bundle/src/Block/BlockServiceInterface.php';
include_once $this->targetDirs[3].'/vendor/sonata-project/block-bundle/src/Block/Service/BlockServiceInterface.php';
include_once $this->targetDirs[3].'/vendor/sonata-project/block-bundle/src/Block/Service/AbstractBlockService.php';
include_once $this->targetDirs[3].'/vendor/cocorico/report-bundle/Block/Service/AdminUsersStatsListBlockService.php';
return $this->services['cocorico_report.admin.block.users.stats_list'] = new \Cocorico\ReportBundle\Block\Service\AdminUsersStatsListBlockService('cocorico_report.admin.block.users.stats_list', ${($_ = isset($this->services['templating']) ? $this->services['templating'] : $this->load('getTemplatingService.php')) && false ?: '_'}, ${($_ = isset($this->services['cocorico_report.user.repository']) ? $this->services['cocorico_report.user.repository'] : $this->load('getCocoricoReport_User_RepositoryService.php')) && false ?: '_'}, ${($_ = isset($this->services['sonata.admin.pool']) ? $this->services['sonata.admin.pool'] : $this->getSonata_Admin_PoolService()) && false ?: '_'});
Редактировать: нашел это, это загрузчик? :
services:
cocorico_report.admin.block.stats:
class: Cocorico\ReportBundle\Block\Service\AdminStatsBlockService
arguments:
- "cocorico_report.admin.block.stats"
- "@templating"
- "@cocorico_report.report.manager"
tags:
- { name: sonata.block }
cocorico_report.admin.block.users.stats_list:
class: Cocorico\ReportBundle\Block\Service\AdminUsersStatsListBlockService
arguments:
- "cocorico_report.admin.block.users.stats_list"
- "@templating"
- "@cocorico_report.user.repository"
- "@sonata.admin.pool"
tags:
- { name: sonata.block }
Заранее спасибо за помощь! :)