Skip to content
Snippets Groups Projects
UWServiceInterface.php 5.99 KiB
<?php

namespace Drupal\uw_cfg_common\Service;

use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;

/**
 * Interface UWServiceInterface.
 *
 * Interface that is collection of common functions used in custom blocks.
 *
 * @package Drupal\uw_cfg_common\Service
 */
interface UWServiceInterface {

  /**
   * Get the image styles used in UW crops.
   *
   * @param string $type
   *   The type of styles to get.
   * @param bool $get_all
   *   Flag to get all the image styles.
   *
   * @return string[]
   *   Array of image styles that are used.
   */
  public function getCropImageStyles(string $type, bool $get_all = FALSE): array;

  /**
   * Prepares responsive image.
   *
   * @param \Drupal\Core\Entity\EntityInterface|null $entity
   *   Image entity or null.
   * @param string $image_style
   *   Image style to be used for responsive image.
   *
   * @return array
   *   Array with details for responsive image.
   */
  public function prepareResponsiveImage(?EntityInterface $entity, string $image_style): array;

  /**
   * Get the UW images styles used in UW responsive image.
   *
   * @return array
   *   Array of image styles.
   */
  public function uwGetResponsiveImageStyles(): array;

  /**
   * Gets content types that have feature images.
   *
   * @param string $type
   *   The type of preprocess (node, teaser, featured_image, etc).
   *
   * @return array
   *   Array of content types that has featured images.
   */
  public function uwGetNodePreprocessing(string $type): array;

  /**
   * Gets dates from node.
   *
   * @param \Drupal\node\Node $node
   *   Node entity.
   *
   * @return string
   *   Yes or no.
   */