csv - 预计在从资源导入服务时在文件中找到类...,但没有找到
问题描述
因此,我目前尝试使用 SyliusandFriendsImportExport-Plugin 添加 CustomerPorcessor,但是当我尝试通过 docker 启动项目时出现此错误:
Expected to find class "App\Processor\CustomerProcessor" in file "/srv/sylius/src/Processor/CustomerProcessor.php" while importing services from resource "../src/*", but it was not found! Check the namespace prefix used with the resource in /srv/sylius/config/services.yaml (which is loaded in resource "/srv/sylius/config/services.yaml").
我已经尝试过更改命名空间,但没有成功,但在 git 示例中,它们的操作与我相同:
services_ImportExportPlugin.yaml:
sylius.processor.customer:
class: FriendsOfSylius\SyliusImportExportPlugin\Processor\CustomerProcessor
arguments:
- "@sylius.factory.customer"
- "@sylius.repository.customer"
- "@sylius.importer.metadata_validator"
- "@doctrine.orm.entity_manager"
- '["id", "customer_group_id", "email", "first_name", "last_name", "birthday", "gender", "phone_number", "since", "title", "verificationCode", "hasApp", "street", "street_number", "postcode", "city", "opt_in_post", "opt_in_phone", "opt_in_email"]'
客户处理器.php:
<?php
namespace FriendsOfSylius\SyliusImportExportPlugin\Processor;
use Doctrine\ORM\EntityManagerInterface;
use FriendsOfSylius\SyliusImportExportPlugin\Exception\ImporterException;
use Payum\Core\Model\GatewayConfigInterface;
use Sylius\Component\Core\Factory\CustomerMethodFactoryInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
final class CustomerProcessor implements ResourceProcessorInterface
{
/** @var CustomerMethodFactoryInterface */
private $resourceFactory;
/** @var RepositoryInterface */
private $resourceRepository;
/** @var MetadataValidatorInterface */
private $metadataValidator;
/** @var EntityManagerInterface */
private $entityManager;
/** @var string[] */
private $headerKeys;
/**
* @param string[] $headerKeys
*/
public function __construct(
CustomerMethodFactoryInterface $factory,
RepositoryInterface $repository,
MetadataValidatorInterface $metadataValidator,
EntityManagerInterface $entityManager,
array $headerKeys
) {
$this->resourceFactory = $factory;
$this->resourceRepository = $repository;
$this->metadataValidator = $metadataValidator;
$this->headerKeys = $headerKeys;
$this->entityManager = $entityManager;
}
public function process(array $data): void
{
$this->metadataValidator->validateHeaders($this->headerKeys, $data);
$CustomerMethod = $this->getCustomerMethod($data['Code'], $data['Gateway']);
$gatewayConfig = $this->getGatewayConfig($data, $CustomerMethod);
$gatewayConfig->setGatewayName($data['Name']);
$CustomerMethod->setGatewayConfig($gatewayConfig);
$CustomerMethod->setName($data['Name']);
$CustomerMethod->setInstructions($data['Instructions']);
$this->entityManager->persist($CustomerMethod);
}
private function getCustomerMethod(string $code, string $gateway): CustomerInterface
{
/** @var CustomerInterface|null $CustomerMethod */
$CustomerMethod = $this->resourceRepository->findOneBy(['code' => $code]);
if ($CustomerMethod === null) {
/** @var CustomerInterface $CustomerMethod */
$CustomerMethod = $this->resourceFactory->createWithGateway($gateway);
$CustomerMethod->setCode($code);
}
return $CustomerMethod;
}
/**
* @param mixed[] $data
*/
private function getGatewayConfig(array $data, CustomerInterface $CustomerMethod): GatewayConfigInterface
{
$gatewayConfig = $CustomerMethod->getGatewayConfig();
if (null === $gatewayConfig) {
throw new ImporterException('Gateway does not exist:' . $data['Gateway']);
}
return $gatewayConfig;
}
}
所以我的预期结果将是一个无错误的运行,但我仍然收到上述错误。
解决方案
推荐阅读
- laravel - 如何删除ckeditor包(错误:找不到类'Ckeditor\CkeditorServiceProvider')?
- redis - kong api网关如何使用redis
- dependencies - ClassNotFoundException : org.apache.http.util.Args - 如何使用 MultipartEntityBuilder 上传文件?
- javascript - 获取数据之前的 Vue 渲染组件
- javascript - "Uncaught SyntaxError: Unexpected token <" when trying to use content of Rails array in Javascript
- eclipse - 隐藏/删除另一个插件提供的透视图 - eclipse
- python - Jupyter Lab/Notebook magic command %load with platform independent path
- c# - 数据注释只允许整数用于长数据类型属性
- android - 如何在 RealmObject 中查询 RealmList(在 Android 中)
- parsing - 使用 PDFBox 的 .NET 版本从 PDF 解析注释/注释:PDFBox.NET-1.8.9