You are here

public function EntityChangedFieldsTrait::getGetterName in Brightcove Video Connect 8

Same name and namespace in other branches
  1. 8.2 src/EntityChangedFieldsTrait.php \Drupal\brightcove\EntityChangedFieldsTrait::getGetterName()
  2. 3.x src/EntityChangedFieldsTrait.php \Drupal\brightcove\EntityChangedFieldsTrait::getGetterName()

Get getter method from the name of the field.

Parameters

string $name: The name of the field.

array $methods: The available methods.

Return value

string The name of the getter function.

1 call to EntityChangedFieldsTrait::getGetterName()
EntityChangedFieldsTrait::checkUpdatedFields in src/EntityChangedFieldsTrait.php
Check for updated fields.

File

src/EntityChangedFieldsTrait.php, line 113

Class

EntityChangedFieldsTrait
Provides a trait to identify changed entity fields.

Namespace

Drupal\brightcove

Code

public function getGetterName($name, array $methods) {
  $function_part_name = $name;

  // Get entity key's status field alias.
  $status = self::getEntityType()
    ->getKey('status');

  // Use the correct function for the status field.
  if ($name == $status) {
    $function_part_name = 'published';
  }

  // Acquire getter method name.
  $getter_name = 'get' . str_replace('_', '', $function_part_name);
  $is_getter_name = 'is' . str_replace('_', '', $function_part_name);
  $getter = NULL;
  if (isset($methods[$getter_name])) {
    $getter = $methods[$getter_name];
  }
  elseif (isset($methods[$is_getter_name])) {
    $getter = $methods[$is_getter_name];
  }
  return $getter;
}