You are here

class Geofield in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_geofield/src/Plugin/geolocation/DataProvider/Geofield.php \Drupal\geolocation_geofield\Plugin\geolocation\DataProvider\Geofield

Provides Google Maps.

Plugin annotation


@DataProvider(
  id = "geofield",
  name = @Translation("Geofield"),
  description = @Translation("Geofield."),
)

Hierarchy

Expanded class hierarchy of Geofield

1 string reference to 'Geofield'
geolocation_geofield.data_provider.schema.yml in modules/geolocation_geofield/config/schema/geolocation_geofield.data_provider.schema.yml
modules/geolocation_geofield/config/schema/geolocation_geofield.data_provider.schema.yml

File

modules/geolocation_geofield/src/Plugin/geolocation/DataProvider/Geofield.php, line 22

Namespace

Drupal\geolocation_geofield\Plugin\geolocation\DataProvider
View source
class Geofield extends DataProviderBase implements DataProviderInterface {

  /**
   * {@inheritdoc}
   */
  public function isViewsGeoOption(FieldPluginBase $views_field) {
    if ($views_field instanceof EntityField && $views_field
      ->getPluginId() == 'field') {
      $field_storage_definitions = $this->entityFieldManager
        ->getFieldStorageDefinitions($views_field
        ->getEntityType());
      if (!empty($field_storage_definitions[$views_field->field])) {
        $field_storage_definition = $field_storage_definitions[$views_field->field];
        if ($field_storage_definition
          ->getType() == 'geofield') {
          return TRUE;
        }
      }
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function isFieldGeoOption(FieldDefinitionInterface $fieldDefinition) {
    return $fieldDefinition
      ->getType() == 'geofield';
  }

  /**
   * {@inheritdoc}
   */
  public function getPositionsFromItem(FieldItemInterface $fieldItem) {
    if ($fieldItem instanceof GeofieldItem) {
      return [
        'lat' => $fieldItem
          ->get('lat')
          ->getValue(),
        'lng' => $fieldItem
          ->get('lon')
          ->getValue(),
      ];
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DataProviderBase::$entityFieldManager protected property Entity field manager.
DataProviderBase::$fieldDefinition protected property Field definition.
DataProviderBase::$viewsField protected property Views field.
DataProviderBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 1
DataProviderBase::fieldItemTokens public function Token replacement support function, callback to token replacement function.
DataProviderBase::getPositionsFromViewsRow public function Get positions from views row. Overrides DataProviderInterface::getPositionsFromViewsRow 1
DataProviderBase::getSettingsForm public function Provide data provider settings form array. Overrides DataProviderInterface::getSettingsForm 1
DataProviderBase::getTokenHelp public function Return field item tokens. Overrides DataProviderInterface::getTokenHelp 1
DataProviderBase::replaceFieldItemTokens public function Replace field item tokens. Overrides DataProviderInterface::replaceFieldItemTokens 1
DataProviderBase::setFieldDefinition public function Set field definition. Overrides DataProviderInterface::setFieldDefinition
DataProviderBase::setViewsField public function Set views field. Overrides DataProviderInterface::setViewsField
DataProviderBase::__construct public function Constructs a new GeocoderBase object. Overrides PluginBase::__construct 1
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
Geofield::getPositionsFromItem public function Get positions from field item list. Overrides DataProviderBase::getPositionsFromItem
Geofield::isFieldGeoOption public function Determine valid field geo option. Overrides DataProviderInterface::isFieldGeoOption
Geofield::isViewsGeoOption public function Determine valid views option. Overrides DataProviderBase::isViewsGeoOption
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
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.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.