You are here

class ElevateZoomPlus in ElevateZoom Plus 7

Same name and namespace in other branches
  1. 8 src/Entity/ElevateZoomPlus.php \Drupal\elevatezoomplus\Entity\ElevateZoomPlus

Defines the ElevateZoomPlus configuration entity.

Hierarchy

Expanded class hierarchy of ElevateZoomPlus

4 files declare their use of ElevateZoomPlus
elevatezoomplus.elevatezoomplus_optionset.inc in ./elevatezoomplus.elevatezoomplus_optionset.inc
ElevateZoomPlus default optionset API include file.
elevatezoomplus.install in ./elevatezoomplus.install
Installation actions for ElevateZoomPlus.
ElevateZoomPlusForm.php in modules/ui/src/Form/ElevateZoomPlusForm.php
ElevateZoomPlusManager.php in src/ElevateZoomPlusManager.php

File

src/Entity/ElevateZoomPlus.php, line 10

Namespace

Drupal\elevatezoomplus\Entity
View source
class ElevateZoomPlus extends SlickBase implements ElevateZoomPlusInterface {

  /**
   * Defines elevatezoomplus table name.
   */
  const TABLE = 'elevatezoomplus_optionset';

  /**
   * {@inheritdoc}
   */
  public static function create(array $values = []) {
    ctools_include('export');
    $optionset = ctools_export_crud_new(static::TABLE);
    $optionset->options = $optionset->options['settings'] = [];
    foreach (self::defaultProperties() as $key => $ignore) {
      if (isset($values[$key])) {
        $optionset->{$key} = $values[$key];
      }
    }
    if (empty($values['label']) && isset($values['name'])) {
      $optionset->label = $values['name'];
    }
    $defaults['settings'] = self::defaultSettings();
    $optionset->options = $optionset->options + $defaults;
    return $optionset;
  }

  /**
   * Returns the typecast values.
   *
   * @param array $settings
   *   An array of Optionset settings.
   */
  public static function typecast(array &$settings = []) {
    if (empty($settings)) {
      return;
    }
    $defaults = self::defaultSettings();
    foreach ($defaults as $name => $value) {
      if (isset($settings[$name])) {

        // Seems double is ignored, and causes a missing schema, unlike float.
        $type = gettype($defaults[$name]);
        $type = $type == 'double' ? 'float' : $type;

        // Change float to integer if value is no longer float.
        if ($name == 'lensOpacity' || $name == 'tintOpacity') {
          $type = $settings[$name] == '0' || $settings[$name] == '1' ? 'integer' : 'float';
        }
        settype($settings[$name], $type);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    if (!isset(static::$defaultSettings)) {
      static::$defaultSettings = [
        'responsive' => FALSE,
        'zoomType' => 'window',
        'zoomWindowWidth' => 400,
        'zoomWindowHeight' => 400,
        'zoomWindowOffsetX' => 0,
        'zoomWindowOffsetY' => 0,
        'zoomWindowPosition' => '1',
        'zoomWindowFadeIn' => FALSE,
        'zoomWindowFadeOut' => FALSE,
        'zoomTintFadeIn' => FALSE,
        'zoomTintFadeOut' => FALSE,
        'scrollZoom' => FALSE,
        'easing' => FALSE,
        'easingType' => 'zoomdefault',
        'easingDuration' => 2000,
        'borderSize' => 4,
        'borderColour' => '#888',
        'showLens' => TRUE,
        'containLensZoom' => FALSE,
        'lensBorder' => 1,
        'lensShape' => 'square',
        'lensSize' => 200,
        'lensFadeIn' => FALSE,
        'lensFadeOut' => FALSE,
        'lensColour' => 'white',
        'lensOpacity' => 0.4,
        'lenszoom' => FALSE,
        'tint' => FALSE,
        'tintColour' => '#333',
        'tintOpacity' => 0.4,
        'constrainType' => '',
        'constrainSize' => '',
        'imageCrossfade' => FALSE,
        'cursor' => 'default',
        'loadingIcon' => '',
      ];
    }
    return static::$defaultSettings;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ElevateZoomPlus::create public static function Returns a new optionset object without saving it to the database. Overrides SlickBase::create
ElevateZoomPlus::defaultSettings public static function Returns available slick default options under group 'settings'. Overrides SlickBase::defaultSettings
ElevateZoomPlus::TABLE constant Defines elevatezoomplus table name. Overrides SlickBase::TABLE
ElevateZoomPlus::typecast public static function Returns the typecast values. Overrides SlickBase::typecast
SlickBase::$defaultSettings protected static property The plugin default settings. 1
SlickBase::$label public property The human-readable name for the optionset.
SlickBase::$name public property The legacy CTools ID for the configurable optionset.
SlickBase::$options public property The plugin instance options.
SlickBase::defaultProperties public static function Returns default database field property values. 1
SlickBase::delete public function Deletes the optionset from database.
SlickBase::exists public static function Checks whether an optionset with the given name already exists. Overrides SlickBaseInterface::exists
SlickBase::getOptions public function Returns the Slick options by group, or property. Overrides SlickBaseInterface::getOptions
SlickBase::getSetting public function Returns the value of a slick setting. Overrides SlickBaseInterface::getSetting
SlickBase::getSettings public function Returns the array of slick settings. Overrides SlickBaseInterface::getSettings
SlickBase::id public function Overrides Drupal\Core\Entity\Entity::id().
SlickBase::label public function The slick label.
SlickBase::load public static function Returns the given optionset object identified by $id. Overrides SlickBaseInterface::load
SlickBase::loadMultiple public static function Fetches all optionsets from the storage. Overrides SlickBaseInterface::loadMultiple
SlickBase::loadWithFallback public static function Load the optionset with a fallback.
SlickBase::save public function Saves the optionset to database.
SlickBase::setSetting public function Sets the value of a slick setting. Overrides SlickBaseInterface::setSetting
SlickBase::setSettings public function Sets the array of slick settings. Overrides SlickBaseInterface::setSettings
SlickBase::toArray public function Returns an array of all property values.