You are here

public function Main__1_1::getFilesId in RESTful 7.2

Return the files ID from the multiple files array.

Since by default Entity API does not allow to get the file ID, we extract it ourself in this preprocess callback.

Parameters

array $value: Array of files array as retrieved by the wrapper.

Return value

int Array with file IDs.

File

tests/modules/restful_test/src/Plugin/resource/entity_test/main/v1/Main__1_1.php, line 157
Contains \Drupal\restful_test\Plugin\resource\entity_test\main\v1\Main__1_1.

Class

Main__1_1
Class Main__1_1 @package Drupal\restful_test\Plugin\resource

Namespace

Drupal\restful_test\Plugin\resource\entity_test\main\v1

Code

public function getFilesId(array $value) {
  if (ResourceFieldBase::isArrayNumeric($value)) {
    $return = array();
    foreach ($value as $file_array) {
      $return[] = $this
        ->getFilesId($file_array);
    }
    return $return;
  }
  return empty($value['fid']) ? NULL : $value['fid'];
}