Skip to content

Commit

Permalink
Merge pull request #243 from jhedstrom/expose-isbasefield
Browse files Browse the repository at this point in the history
Expose ::isBaseField()
  • Loading branch information
jhedstrom authored Feb 28, 2023
2 parents 44427ae + 9174152 commit 5e23dcd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Drupal/Driver/BaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ public function isField($entity_type, $field_name) {
return FALSE;
}

/**
* {@inheritdoc}
*/
public function isBaseField($entity_type, $field_name) {
return FALSE;
}

/**
* {@inheritdoc}
*/
Expand Down
13 changes: 13 additions & 0 deletions src/Drupal/Driver/Cores/CoreInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ public function getFieldHandler($entity, $entity_type, $field_name);
*/
public function isField($entity_type, $field_name);

/**
* Checks if the specified field is a Drupal base field.
*
* @param string $entity_type
* The entity type to check.
* @param string $field_name
* The field name to check.
*
* @return bool
* TRUE if the given field is a base field, FALSE otherwise.
*/
public function isBaseField($entity_type, $field_name);

/**
* Returns array of field types for the specified entity.
*
Expand Down
8 changes: 8 additions & 0 deletions src/Drupal/Driver/Cores/Drupal6.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,14 @@ public function isField($entity_type, $field_name) {
return isset($map[$field_name]);
}

/**
* {@inheritdoc}
*/
public function isBaseField($entity_type, $field_name) {
// Base fields are only supported in Drupal 8 and higher.
return FALSE;
}

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Drupal/Driver/Cores/Drupal7.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ public function isField($entity_type, $field_name) {
return !empty($map[$field_name]) && array_key_exists($entity_type, $map[$field_name]['bundles']);
}

/**
* {@inheritdoc}
*/
public function isBaseField($entity_type, $field_name) {
// Base fields are only supported in Drupal 8 and higher.
return FALSE;
}

/**
* {@inheritdoc}
*/
Expand Down
13 changes: 13 additions & 0 deletions src/Drupal/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ public function roleDelete($rid);
*/
public function isField($entity_type, $field_name);

/**
* Checks if the specified field is a Drupal base field.
*
* @param string $entity_type
* The entity type to check.
* @param string $field_name
* The field name to check.
*
* @return bool
* TRUE if the given field is a base field, FALSE otherwise.
*/
public function isBaseField($entity_type, $field_name);

/**
* Returns a configuration item.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Drupal/Driver/DrupalDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ public function isField($entity_type, $field_name) {
return $this->getCore()->isField($entity_type, $field_name);
}

/**
* {@inheritdoc}
*/
public function isBaseField($entity_type, $field_name) {
return $this->getCore()->isBaseField($entity_type, $field_name);
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 5e23dcd

Please sign in to comment.