Not all entity reference-style fields use "target_id" as the reference key, some of them, like og_membership, use other names for the array element. The current reference object doesn't provide a way of changing the array key used for storing the return value on a given field, so it'd be useful if there was a way of doing this.

CommentFileSizeAuthor
#2 yaml_content-n3107138-2.patch1.14 KBdamienmckenna

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new1.14 KB

This supports a third argument to the 'reference' processor so that you can e.g. generate og_membership records like this:

- entity: "og_membership"
  state: "active"
  language: "en"
  type: "default"
  uid:
    - "#process":
        callback: "reference"
        args:
          - "user"
          - name: "regularuser"
  entity_type: "node"
  entity_bundle: "organization"
  entity_id:
    - "#process":
        callback: "reference"
        args:
          - "node"
          - type: "organization"
            title: "Lorem ipsum"
          - "value"
damienmckenna’s picture

Status: Needs review » Fixed
Parent issue: » #3055576: Plan for YAML Content 8.x-1.x-alpha6

Committed.

  • DamienMcKenna committed c85cdd0 on 8.x-1.x
    Issue #3107138 by DamienMcKenna: Allow reference item to designate the...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

drupalninja99’s picture

@damien when I try to update to the latest version I am getting this error:

TypeError: Argument 2 passed to Drupal\yaml_content\Service\LoadHelper::__construct() must be an instance of                               [error]
Drupal\yaml_content\Service\LoggerInterface, instance of Drupal\Core\Logger\LoggerChannel given, called in
/var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 277 in
Drupal\yaml_content\Service\LoadHelper->__construct() (line 43 of
/var/www/html/web/modules/contrib/yaml_content/src/Service/LoadHelper.php) #0
/var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(277):
Drupal\yaml_content\Service\LoadHelper->__construct(Object(Drupal\yaml_content\ContentLoader\ContentLoader),
Object(Drupal\Core\Logger\LoggerChannel), Object(Drupal\Core\StringTranslation\TranslationManager))
#1 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(173):
Drupal\Component\DependencyInjection\Container->createService(Array, 'yaml_content.lo...')
#2 /var/www/html/web/core/lib/Drupal.php(158): Drupal\Component\DependencyInjection\Container->get('yaml_content.lo...')
#3 /var/www/html/web/modules/contrib/yaml_content/yaml_content.drush.inc(110): Drupal::service('yaml_content.lo...')
#4 /var/www/html/vendor/drush/drush/includes/command.inc(422): drush_yaml_content_import_profile('hf_covid')
#5 /var/www/html/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#6 /var/www/html/vendor/drush/drush/includes/command.inc(199): drush_command('hf_covid')
#7 /var/www/html/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#8 /var/www/html/vendor/drush/drush/includes/preflight.inc(67): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#9 phar:///usr/local/bin/drush/bin/drush.php(153): drush_main()

damienmckenna’s picture

Please open a new bug report for that.