Reading the documentation, I don't find any information about how replace hook_rules_data_info. It might be obvious, but please point me in the right direction and consider adding this info to the docs. I'm not skilled enough myself to update the docs.

Comments

hansfn created an issue. See original summary.

hansfn’s picture

In Drupal 7 I just had:

  [...]
  'property info' => array(
    'uid' => array(
      'type' => 'integer',
      'label' => t('User ID'),
    ),
    'timestamp' => array(
      'type' => 'integer',
      'label' => t('Timestamp'),
    ),
    'name' => array(
      'type' => 'text',
      'label' => t('Name'),
    )
  );

How do you properly define the samething? As a subclass of \Drupal\Core\TypedData\Plugin\DataType\Map? How?

fago’s picture

Yes, that's now covered by the Typed Data API. Thus, you'd define a new data type using typed data. You can then use it in Rules. For structures like that, you'd need to define a complex data type, i.e. you can extend from the Map base class in the ComplexDataDefinition base class. The definition class needs to be used for defining the structure, for the actual instance class you can use whatever fits your use case. Could be that Map is already perfectly fine for your use case.

I hope that helps!

fago’s picture

Status: Active » Fixed
hansfn’s picture

Hi, fago.

I'm happy that I wasn't complete off the track, but I still think the Rules documentation would benefit from a code sample. I did try to look at Typed Data API documentation, but I didn't really find the help I needed. I'll look at that Map class again ...

I didn't reopen the issue since I realize that you are busy, but if you have some free time please consider adding that code sample to the docs ;-)

Status: Fixed » Closed (fixed)

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