Мне нужно добавить новые функции в пользовательский пакет Symfony, который мой коллега ранее разработал. Чтобы работать с этим пакетом, я установил его в Symfony Base_App через композитор. Во время установки была ошибка, и в одном из файлов использовалось неправильное пространство имен. Вот пример того, как сейчас установлен пакет: < /p>
return [
// Custom\NotificationBundle\NotificationBundle::class => ['all' => true],
Custom\NotificationBundle\DependencyInjection\CustomNotificationBundle::class => ['all' => true],
];
< /code>
Во время работы с этим пакетом я сталкиваюсь с ошибкой: < /p>
Определение для "custom.notifo.service" не имеет класса. Если вы собираетесь динамически ввести эту службу во время выполнения, отметьте ее как Synthetic = true. Если это абстрактное определение, используемое исключительно по определениям детей, добавьте Abstract = true, в противном случае укажите класс, чтобы избавиться от этой ошибки.
Ошибка отображается, когда я пытаюсь запустить bin/console config: summ notifo . />
services:
custom.notifo.service:
class: Custom\NotificationBundle\Service\NotifoService
arguments:
- '%custom.notifo.host%'
- '%custom.notifo.appid%'
- '%custom.notifo.apikey%'
- '@custom.notifo.requests_service'
- '%custom.notifo.sms.api_id%'
- '%custom.notifo.sms.sender_id%'
- '@logger'
public: true
autoconfigure: false
< /code>
bundle также имеет тесты и сервисы. Yaml выглядит так же: < /p>
services:
_defaults:
autowire: true
autoconfigure: true
custom.notifo.service:
class: Custom\NotificationBundle\Service\NotifoService
arguments: [ '%host%', '%appId%', '%apiKey%' , '@custom.notifo.requests_service', '%apiId%', '%senderId%', '@logger' ]
public: true
< /code>
Конфигурация выглядит так: < /p>
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('custom_notifo');
$treeBuilder->getRootNode()
->children()
->arrayNode('notifo')
->children()
->scalarNode('appid')
->defaultValue('custom')->end()
->scalarNode('apikey')
->defaultValue('custom')->end()
->scalarNode('host')
->defaultValue('custom')->end()
->arrayNode('sms')
->children()
->scalarNode('api_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('sender_id')->isRequired()->cannotBeEmpty()->end()
->end()
->end()
->end();
return $treeBuilder;
}
public function getName(){
return 'custom_notifo';
}
}
< /code>
Пакет выглядит следующим образом: < /p>
namespace Custom\NotificationBundle\DependencyInjection;
class CustomNotificationBundle extends Bundle
{
protected string $extensionAlias = 'custom_notifo';
public function build(ContainerBuilder $container): void
{
parent::build($container);
$extension = new CustomNotificationExtension();
$container->registerExtension($extension);
}
}
< /code>
У меня также есть этот класс < /p>
namespace Custom\NotificationBundle;
class NotificationBundle extends Bundle
{
}
< /code>
Я никогда раньше не работал с написанием пакета, поэтому я не знаю, что делать. Коллега сказал, что пакет работает, существует функция для отправки электронных писем через Notifo.
Подробнее здесь: https://stackoverflow.com/questions/797 ... ith-bundle