You are here

public function BlogapiCommunicator::getValidTextFormat in Blog API 8

Try and load a default text format if the passed one doesn't exist.

Parameters

$data: The node data.

$user: The Drupal user object.

Return value

array|bool|mixed|null|string A valid text format ID.

2 calls to BlogapiCommunicator::getValidTextFormat()
BlogapiCommunicator::editPost in src/BlogapiCommunicator.php
Callback for editing a node.
BlogapiCommunicator::newPost in src/BlogapiCommunicator.php
Callback for creating a new node.

File

src/BlogapiCommunicator.php, line 376

Class

BlogapiCommunicator
Class BlogapiCommunicator.

Namespace

Drupal\blogapi

Code

public function getValidTextFormat($data, $user) {
  $format_load = FALSE;
  if (isset($data['format'])) {
    $format_load = $data['format'];
  }
  if (!$format_load || !array_key_exists($format_load, filter_formats())) {
    $format_load = $this
      ->getDefaultFormat($user);
  }
  return $format_load;
}