You are here

public function UiPatternsSourceManager::getFieldsByTag in UI Patterns 8

Get field source definitions by specified tags.

Parameters

string $tag: Field source tag.

array $context: Plugin context.

Return value

\Drupal\ui_patterns\Definition\PatternSourceField[] List of source fields.

File

src/UiPatternsSourceManager.php, line 49

Class

UiPatternsSourceManager
Provides the UI Patterns Source plugin manager.

Namespace

Drupal\ui_patterns

Code

public function getFieldsByTag($tag, array $context) {

  /** @var \Drupal\ui_patterns\Plugin\PatternSourceInterface $plugin */
  $fields = [];
  foreach ($this
    ->getDefinitionsByTag($tag) as $id => $definition) {
    $plugin = $this
      ->createInstance($id, [
      'context' => $context,
    ]);
    foreach ($plugin
      ->getSourceFields() as $field) {
      $fields[$field
        ->getFieldKey()] = $field;
    }
  }
  return $fields;
}