Is it possible to set the default value for enableMaxDepthChecks to true?
Currently I have to add the following annotation to every route:
#View(serializerEnableMaxDepthChecks=true)
Is there a way to set this in the config or elsewhere to be the default?
Place this into your config.yml
jms_serializer:
default_context:
serialization:
enable_max_depth_checks: true
BUT! After making these changes, the parameter serializerEnableMaxDepthChecks becomes non-working, so you can't set it to false , and I don't know why...
Related
I am using symfony5 and what I want to achive is to use a parameter in another parameter. Is it possible? Of course I've searchd for it, but did not find a solution. For example:
media:
extendions:
- pdf
path: '%kernel.project_dir%/media/'
incomingPdf:
#path: '%kernel.project_dir%/media/incoming/pdf'
path: '#=parameter("media")["path"]incoming/pdf'
It says, expressions is not allowed in parameters.
In incomingPdf I want to use defined media['path']s value.
trying to get the sf4 serializer component to use snake_case as the default:
Symfony\Component\Serializer\Normalizer\ObjectNormalizer:
public: true
arguments: ['#serializer.mapping.class_metadata_factory', '#serializer.name_converter.camel_case_to_snake_case']
tags: [serializer.normalizer]
works.
but now DateTime is being normalized to empty arrays.
I don't get why, without the config changes, its normalized to a date string, as you would expect.
What am i doing wrong here?
turns out, you simply need to enable a name_converter the proper way like this instead:
# config/packages/framework.yaml
framework:
# ...
serializer:
name_converter: 'serializer.name_converter.camel_case_to_snake_case'
see
https://symfony.com/doc/current/serializer.html#enabling-a-name-converter
https://github.com/symfony/symfony/issues/40818
By default, ApiDoc lists out all operations for each API endpoint, like this:
In the Swagger demo, however, operations are hidden by default until the user chooses to show them.
Is there a configuration option for ApiDoc that will hide operations by default? I haven't found anything like this in the documentation.
Documentation section can be hidden by default with parameter default_sections_opened:
nelmio_api_doc.default_sections_opened: false
Default value for this parameter is true. See configuration reference.
You must change your config.yml file like this (default_sections_opened to false):
nelmio_api_doc:
name: 'API documentation'
exclude_sections: []
**default_sections_opened: false**
motd:
template: 'NelmioApiDocBundle::Components/motd.html.twig'
request_listener:
enabled: true
parameter: _doc
sandbox:
enabled: false
I have a bundle with its custom *Extension class where I need to read configuration from another bundle (SecurityBundle in particular) where I have for example.
security:
...
firewalls:
main:
pattern: '^%url_prefix%'
I'm wondering how can I get value for security.firewalls.main.pattern with interpolated url_prefix parameter?
Retrieving configuration values (of any bundle different than the one into what your extension is located, because you are in an extension) is not supported, and it seems that'll not be in the future.
The only ways are:
Define a parameter representing the whole option's value (as pointed by this answer on a similar question):
# app/config/security.yml
parameters:
firewalls.main.pattern: '^%url_prefix%'
# ...
security:
# ...
firewalls:
main:
pattern: '^%url_prefix%'
Parse your config.yml using the Yaml component:
$yamlPath = $this->getParameter('kernel.root_dir').'/config/security.yml';
$config = Symfony\Component\Yaml\Yaml::parse(file_get_contents($yamlPath));
// The option value
$value = $config['security']['firewalls']['main']['pattern'];
I think that's really a pity to don't be able to retrieve a config option from any container-aware context without doing such hacks.
I need to switch 'translation fallback' and 'persistDefaultLocaleTranslation' on.
I know how to change it: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md#default-locale
but don't know where should I access that listener.. Maybe in config.yml? how??
I am looking for something like this:
(config.yml)
...
translatable-extension:
translationFallback:true
persistDefaultLocaleTranslation: true
If you have the StofDoctrineExtensionsBundle installed (https://github.com/stof/StofDoctrineExtensionsBundle), you can configure the default values for this in config.yml
stof_doctrine_extensions:
default_locale: "%locale%"
translation_fallback: true
persist_default_translation: true
Haven't found this is in any docs, but it is in the configuration for the bundle https://github.com/stof/StofDoctrineExtensionsBundle/blob/master/DependencyInjection/Configuration.php#L30
I'm not sure I fully understand what you are asking but in a typical setup you would have the translation fallback referenced in your config.yml like this.
framework:
translator: { fallback: %locale% }
In this example the locale placeholder references the locale setting in your parameters.ini/parameters.yml file.
I believe this is commented out by default in your config.yml but uncommenting this line will effectively enable translations.
You can see the full list of configuration options with along with their defaults here:
http://symfony.com/doc/current/reference/configuration/framework.html#full-default-configuration