DataDefinition::create('string')->setLabel(t('Country')), 'locality' => DataDefinition::create('string')->setLabel(t('Locality')), 'thoroughfare' => DataDefinition::create('string')->setLabel(t('Thoroughfare')), 'postal_code' => DataDefinition::create('string')->setLabel(t('Postal code')), ]; } /** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { return [ 'columns' => [ 'country' => [ 'description' => 'The ISO country code.', 'type' => 'varchar', 'length' => 2, ], 'locality' => [ 'description' => 'The locality.', 'type' => 'varchar', 'length' => 255, ], 'thoroughfare' => [ 'description' => 'The thoroughfare.', 'type' => 'varchar', 'length' => 255, ], 'postal_code' => [ 'description' => 'The postal code.', 'type' => 'varchar', 'length' => 255, ], ], ]; } /** * {@inheritdoc} */ public function isEmpty() { $empty = TRUE; foreach (['country', 'locality', 'thoroughfare', 'postal_code'] as $column) { $empty &= $this->get($column)->getValue() === NULL; } return (bool) $empty; } }