You are here

abstract class DevelImageProviderPluginBase in Devel images provider 8

Hierarchy

Expanded class hierarchy of DevelImageProviderPluginBase

1 file declares its use of DevelImageProviderPluginBase
DummyImageProvider.php in lib/Drupal/devel_image_provider/Plugin/devel_image_provider/provider/DummyImageProvider.php
Contains \Drupal\devel_image_provider\Plugin\devel_image_provider\provider\DummyImageProvider.

File

lib/Drupal/devel_image_provider/Plugin/Type/DevelImageProviderPluginBase.php, line 14
Contains \Drupal\devel_image_provider\DevelImageProviderPluginBase.

Namespace

Drupal\devel_image_provider\Plugin\Type
View source
abstract class DevelImageProviderPluginBase extends PluginBase implements DevelImageProviderPluginInterface {

  /**
   * The provider url.
   *
   * @var string
   */
  protected $base_url;

  /**
   * Defined settings for the method.
   *
   * @var string
   */
  protected $settings;
  public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->settings = variable_get('devel_image_provider_settings_' . $plugin_id, array());
  }
  public function availableMethods() {
    return drupal_map_assoc(array(
      'curl',
      'gd',
      'file_get_contents',
    ));
  }
  public function settingsForm() {
    $info = $this
      ->getDefinition();
    $form['devel_image_provider_' . $info['id']] = array(
      '#type' => 'details',
      '#collapsed' => FALSE,
      '#title' => t('Provider settings'),
      '#states' => array(
        'visible' => array(
          ':input[name="devel_generate_image_function"]' => array(
            'value' => 'devel_image_provider_generate',
          ),
          ':input[name="available_providers[devel_image_provider_method_selected]"]' => array(
            'value' => $info['id'],
          ),
        ),
      ),
    );
    $methods = $this
      ->availableMethods();
    if (!empty($methods)) {
      $form['devel_image_provider_' . $info['id']]['devel_image_provider_get_method'] = array(
        '#type' => 'radios',
        '#title' => t('Method to get files'),
        '#default_value' => isset($this->settings['devel_image_provider_get_method']) ? $this->settings['devel_image_provider_get_method'] : 'file_get_contents',
        '#options' => $this
          ->availableMethods(),
      );
    }
    $form['devel_image_provider_' . $info['id']]['devel_image_provider_gray'] = array(
      '#type' => 'checkbox',
      '#title' => t('Gray version'),
      '#default_value' => isset($this->settings['devel_image_provider_gray']) ? $this->settings['devel_image_provider_gray'] : NULL,
    );
    return $form;
  }
  public function settingsFormValidate(&$form, &$form_state) {
  }
  public function settingsFormSubmit(&$form, &$form_state) {
    $info = $this
      ->getDefinition();
    $values = $form_state['values']['config_providers']['devel_image_provider_' . $info['id']];
    variable_set('devel_image_provider_settings_' . $info['id'], $values);
  }
  public function generateImage($object, $field, $instance, $bundle) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DevelImageProviderPluginBase::$base_url protected property The provider url.
DevelImageProviderPluginBase::$settings protected property Defined settings for the method.
DevelImageProviderPluginBase::availableMethods public function Sets the available methods to get the images from this provider. Overrides DevelImageProviderPluginInterface::availableMethods
DevelImageProviderPluginBase::generateImage public function Image generation handler. Overrides DevelImageProviderPluginInterface::generateImage 1
DevelImageProviderPluginBase::settingsForm public function Generates a settings form for this handler. Overrides DevelImageProviderPluginInterface::settingsForm 1
DevelImageProviderPluginBase::settingsFormSubmit public function Generates a settings form submit function for this handler. Overrides DevelImageProviderPluginInterface::settingsFormSubmit
DevelImageProviderPluginBase::settingsFormValidate public function Generates a settings form validate function for this handler. Overrides DevelImageProviderPluginInterface::settingsFormValidate
DevelImageProviderPluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.