Задать вопрос
Ответы пользователя по тегу Symfony
  • Использование ElasticsearchLogstashHandler внутри Docker?

    Lebnik
    @Lebnik
    Объяви сервис:
    services:
        Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler:
            class: Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler
            arguments:
                - 'http://elasticsearch:9200'


    а чтобы ошибок не было:
    services:
        Psr\Log\NullLogger:
            class: Psr\Log\NullLogger
    
        'http_client_without_logs':
            class: Symfony\Component\HttpClient\CurlHttpClient
            calls:
                - [setLogger, ['@Psr\Log\NullLogger']]
    
        Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler:
            class: Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler
            arguments:
                - 'http://elasticsearch:9200'
                - 'monolog'
                - '@http_client_without_logs'
    Ответ написан
    Комментировать
  • Почему JMSSerializerBundle игнорирует аннотации?

    Lebnik
    @Lebnik
    $serializer = SerializerBuilder::create()
                ->setSerializationContextFactory(function () {
                    return \JMS\Serializer\SerializationContext::create()
                        ->setSerializeNull(true)
                        ;
                })
                ->setDeserializationContextFactory(function () {
                    return \JMS\Serializer\DeserializationContext::create()
                        ->setSerializeNull(true)
                        ;
                })
                ->setAnnotationReader($annotationReader)
                ->setPropertyNamingStrategy(new SerializedNameImportantThanPropertyNameStrategy())
                ->build();

    Ignoring some parent classes: CComponent, CModel, CActiveRecord
    $class = new \ReflectionClass($serializer);
            $property = $class->getProperty('navigator');
            $property->setAccessible(true);
            $navigator = $property->getValue($serializer);
    
            $class = new \ReflectionClass($navigator);
            $property = $class->getProperty('metadataFactory');
            $property->setAccessible(true);
            $metadataFactory = $property->getValue($navigator);
    
            $class = new \ReflectionClass($metadataFactory);
            $property = $class->getProperty('loadedClassMetadata');
            $property->setAccessible(true);
            $property->setValue($metadataFactory, [
                'CComponent' => new NullMetadata(new \stdClass()),
                'CModel' => new NullMetadata(new \stdClass()),
                'CActiveRecord' => new NullMetadata(new \stdClass()),
            ]);
    Ответ написан
    Комментировать