1

Someone know how to exend this schema located in block module in core, to add a new data type in mapping from my custom module?

The point is that I need to add a Boolean field for all the blocks in the block configuration page and store this value (0 or 1) in all the block configuration files, but the problem I have is when I import the configuration for those blocks that does not import the boolean field.

I guess I'm missing declare a "data type" for this boolean field.

    block.block.*:
      type: config_entity
      label: 'Block'
      mapping:
        id:
          type: string
          label: 'ID'
        theme:
          type: string
          label: 'Theme'
        region:
          type: string
          label: 'Region'
        weight:
          type: integer
          label: 'Weight'
        provider:
          type: string
          label: 'Provider'
        plugin:
          type: string
          label: 'Plugin'
        settings:
          type: block.settings.[%parent.plugin]
        visibility:
          type: sequence
          label: 'Visibility Conditions'
          sequence:
            type: condition.plugin.[id]
            label: 'Visibility Condition'

I want to add this

   mapping:
    hide_for_campaign:
      type: boolean
      label: 'Blocks hidden in campaign page'
  • Can't you store the value in a field on your custom block type? – Ismail Cherri Sep 14 '18 at 16:24
  • The point is that I need to add a Boolean field for all the blocks in the block configuration page and store this value (0 or 1) in all the block configuration files, but the problem I have is when I import the configuration for those blocks that does not import the boolean field. I improved the description on top. – Diosbel Mezquía Sep 14 '18 at 20:26
  • I think in your case your could benefit from api.drupal.org/api/drupal/… – Ismail Cherri Sep 14 '18 at 21:27
  • mmm i dont know it says "Provides custom base field definitions for a content entity type." It can be useful for content entities, not Config entities, i need add it for block entity. – Diosbel Mezquía Sep 14 '18 at 21:37
1

The answer is to use the ThirdPartySettingsInterface Interface, using that interface you can add/save custom configuration for config entities, works perfect. Thank you !.

More info here https://www.heididev.com/how-alter-configuration-entity-data-drupal-8-or-add-additional-data-configuration-entities

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.