【问题标题】:Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "!service_locator"未启用标签支持。您必须使用标志 \"Yaml::PARSE_CUSTOM_TAGS\" 才能使用 \"!service_locator\"
【发布时间】:2022-08-19 21:33:23
【问题描述】:

我正在尝试将 webpack-encore-bundle 添加到我的 Drupal 站点,我在 services.yml 文件中有这个:

services:
  webpack_encore.twig_entry_files_extension:
    class: Symfony\\WebpackEncoreBundle\\Twig\\EntryFilesTwigExtension
    arguments:
      [\'@service_container\']
    tags:
      - { name: twig.extension }

  webpack_encore.tag_renderer:
    class: Symfony\\WebpackEncoreBundle\\Asset\\TagRenderer
    tags:
      - { name: kernel.reset}
    arguments:
      [\'@webpack_encore.entrypoint_lookup_collection\', \'@assets.packages\']

  assets.packages:
    class: Symfony\\Component\\Asset\\Packages

  webpack_encore.default_entrypoint:
    class: Symfony\\WebpackEncoreBundle\\Asset\\EntrypointLookup
    arguments:
      - \'web/themes/custom/mytheme_base/public/build/entrypoints.json\'

  webpack_encore.entrypoint_lookup_collection:
    class: Symfony\\WebpackEncoreBundle\\Asset\\EntrypointLookupCollection
    arguments:
      - !service_locator
        _default: \'@webpack_encore.default_entrypoint\'

但我收到此错误:

In YamlSymfony.php line 40:
                                                                                                                                                
  Tags support is not enabled. You must use the flag \"Yaml::PARSE_CUSTOM_TAGS\" to use \"!service_locator\" at line 27 (near \"!service_locator\").  
                                                                                                                                                

In Parser.php line 1157:
                                                                                                                                                
  Tags support is not enabled. You must use the flag \"Yaml::PARSE_CUSTOM_TAGS\" to use \"!service_locator\" at line 27 (near \"!service_locator\").  

你知道如何解决吗?

    标签: symfony


    【解决方案1】:

    如果在代码中使用自定义标签:请参阅 Symfony 文档:https://symfony.com/doc/5.4/components/yaml.html#parsing-and-dumping-custom-tags

    如果您在运行bin/console.php lint:yaml my/repository 时遇到此错误,请尝试使用“--parse-tags”选项运行它:bin/console.php lint:yaml --parse-tags my/repository

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-19
      • 1970-01-01
      • 2018-10-30
      • 2011-04-11
      • 2020-11-05
      • 2018-12-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多