You are here

public function ViewsSlideshowWidgetTypeBase::checkCompatiblity in Views Slideshow 8.4

Check if the widget type is compatible with the selected slideshow.

Return value

bool TRUE if the widget type is compatible with the slideshow.

Overrides ViewsSlideshowWidgetTypeInterface::checkCompatiblity

File

src/ViewsSlideshowWidgetTypeBase.php, line 102

Class

ViewsSlideshowWidgetTypeBase
Base class for a Views slideshow widget type.

Namespace

Drupal\views_slideshow

Code

public function checkCompatiblity($slideshow) {
  $is_compatible = 1;

  // Check if every required accept value in the widget has a
  // corresponding calls value in the slideshow.
  foreach ($this->pluginDefinition['accepts'] as $accept_key => $accept_value) {
    if (is_array($accept_value) && !empty($accept_value['required']) && !in_array($accept_key, $slideshow['calls'])) {
      $is_compatible = 0;
      break;
    }
  }

  // No need to go through this if it's not compatible.
  if ($is_compatible) {

    // Check if every required calls value in the widget has a
    // corresponding accepts call.
    foreach ($this->pluginDefinition['calls'] as $calls_key => $calls_value) {
      if (is_array($calls_value) && !empty($calls_value['required']) && !in_array($calls_key, $slideshow['accepts'])) {
        $is_compatible = 0;
        break;
      }
    }
  }
  return $is_compatible;
}