MapItem.php in Drupal 9
File
core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php
View source
<?php
namespace Drupal\Core\Field\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\FieldItemBase;
class MapItem extends FieldItemBase {
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
return [];
}
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return [
'columns' => [
'value' => [
'type' => 'blob',
'size' => 'big',
'serialize' => TRUE,
],
],
];
}
public function toArray() {
return $this
->getValue();
}
public function setValue($values, $notify = TRUE) {
$this->values = [];
if (!isset($values)) {
return;
}
if (!is_array($values)) {
if ($values instanceof MapItem) {
$values = $values
->getValue();
}
else {
$values = unserialize($values, [
'allowed_classes' => FALSE,
]);
}
}
$this->values = $values;
if ($notify && isset($this->parent)) {
$this->parent
->onChange($this->name);
}
}
public function __get($name) {
if (!isset($this->values[$name])) {
$this->values[$name] = [];
}
return $this->values[$name];
}
public function __set($name, $value) {
if (isset($value)) {
$this->values[$name] = $value;
}
else {
unset($this->values[$name]);
}
}
public static function mainPropertyName() {
return NULL;
}
public function isEmpty() {
return empty($this->values);
}
}
Classes
Name |
Description |
MapItem |
Defines the 'map' entity field type. |