Email.php in Social Media Links Block and Field 8.2
File
src/Plugin/SocialMediaLinks/Platform/Email.php
View source
<?php
namespace Drupal\social_media_links\Plugin\SocialMediaLinks\Platform;
use Drupal\social_media_links\PlatformBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class Email extends PlatformBase {
public function getUrl() {
return Url::fromUri('mailto:' . $this
->getValue());
}
public static function validateValue(array &$element, FormStateInterface $form_state, array $form) {
if (!empty($element['#value'])) {
$validator = \Drupal::service('email.validator');
if (!$validator
->isValid($element['#value'])) {
$form_state
->setError($element, t('The entered email address is not valid.'));
}
}
}
}
Classes
Name |
Description |
Email |
Provides 'email' platform. |