How to get vocabularies for an entity reference to a taxonomy? So I'm having a bit of a difficult time finding out how to get the information I want.

I have an entity reference field - call it field_event_type. This is an entity reference to a taxonomy. I am trying to programmatically get the possible vocabularies associated with this entity reference and get the fields/properties associated with them. Basically walking each of the bundles to get their relevant information.

So far I can get the field definition on the parent node, which looks like this:

Array
(
    [uuid] =&gt; 32eeda5f-270f-477d-b24c-75ed15e69b2a
    [langcode] =&gt; en
    [status] =&gt; 1
    [dependencies] =&gt; Array
        (
            [module] =&gt; Array
                (
                    [0] =&gt; node
                    [1] =&gt; taxonomy
                )

        )

    [id] =&gt; node.field_event_type
    [field_name] =&gt; field_event_type
    [entity_type] =&gt; node
    [type] =&gt; entity_reference
    [settings] =&gt; Array
        (
            [target_type] =&gt; taxonomy_term
        )

    [module] =&gt; core
    [locked] =&gt; 
    [cardinality] =&gt; 1
    [translatable] =&gt; 1
    [indexes] =&gt; Array
        (
        )

    [persist_with_no_fields] =&gt; 
    [custom_storage] =&gt; 
)


By doing this:

\Drupal::config('field.storage.node.field_event_type')-&gt;get();


Based on this link:

field_info_field() deprecated, what&#39;s the equivalent?

But I'm not sure how to get the vocabularies or even if that's the right thing to do to get the information I want.

How would I go about getting the vocabularies? I should be able to just load by VID and get the correct fields at that point, correct?
So here is my process (it won't work when you're loading in the relevant entity types via a view, only by the "default" method):

$type is the content type, $field is the field of the ER.

$field_data = \Drupal::config('field.field.node.' . $type . "." . $field)->get();

$bundles = $field_data['settings']['handler_settings']['target_bundles'];

At which point you can iterate over the given bundles for an ER.

You'll probably want to do some flow control somewhere to ensure the ER has the correct handler you want - located here:

$handler = $field_data['settings']['handler'];


But this should work to get the data I asked for above.