class SocialProfileFieldsFlushForm in Open Social 8.9
Same name and namespace in other branches
- 8.2 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 8.3 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 8.4 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 8.5 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 8.6 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 8.7 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 8.8 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 10.3.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 10.0.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 10.1.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- 10.2.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsFlushForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
Class SocialProfileFieldsFlushForm.
Provides confirmation form for resetting a vocabulary to alphabetical order.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfirmFormBase implements ConfirmFormInterface
- class \Drupal\social_profile_fields\Form\SocialProfileFieldsFlushForm
- class \Drupal\Core\Form\ConfirmFormBase implements ConfirmFormInterface
Expanded class hierarchy of SocialProfileFieldsFlushForm
1 string reference to 'SocialProfileFieldsFlushForm'
- social_profile_fields.routing.yml in modules/
social_features/ social_profile/ modules/ social_profile_fields/ social_profile_fields.routing.yml - modules/social_features/social_profile/modules/social_profile_fields/social_profile_fields.routing.yml
File
- modules/
social_features/ social_profile/ modules/ social_profile_fields/ src/ Form/ SocialProfileFieldsFlushForm.php, line 18
Namespace
Drupal\social_profile_fields\FormView source
class SocialProfileFieldsFlushForm extends ConfirmFormBase {
/**
* Profilestorage.
*
* @var \Drupal\profile\ProfileStorage
*/
protected $profileStorage;
/**
* Configstorage.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
protected $configFactory;
/**
* Fiekdconfigstorage.
*
* @var \Drupal\field\FieldConfigStorage
*/
protected $fieldStorage;
/**
* Constructs a new ExportUserConfirm.
*
* @param \Drupal\profile\ProfileStorage $profiel_storage
* The profile storage.
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config.
* @param \Drupal\field\FieldConfigStorage $field_storage
* The field storage.
*/
public function __construct(ProfileStorage $profiel_storage, ConfigFactory $config_factory, FieldConfigStorage $field_storage) {
$this->profileStorage = $profiel_storage;
$this->configFactory = $config_factory;
$this->fieldStorage = $field_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity.manager')
->getStorage('profile'), $container
->get('config.factory'), $container
->get('entity.manager')
->getStorage('field_config'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'social_profile_fields_flush_form';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this
->t('Flush profile.');
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('social_profile_fields.settings');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this
->t('Yes, continue');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$pids = \Drupal::entityQuery('profile')
->condition('type', 'profile')
->execute();
$fields = $this
->getUnselectedFields();
$batch = [
'title' => t('Flushing profiles.'),
'operations' => [
[
'\\Drupal\\social_profile_fields\\SocialProfileFieldsBatch::performFlush',
[
$pids,
$fields,
],
],
],
'finished' => '\\Drupal\\social_profile_fields\\SocialProfileFieldsBatch::performFlushFinishedCallback',
];
batch_set($batch);
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
/**
* {@inheritdoc}
*/
public function getDescription() {
$fields = $this
->getUnselectedFields();
$field_string = implode(', ', $fields);
return $this
->t('<strong>WARNING</strong>: Flushing profile data will permanently <strong>remove all data</strong> from the following fields from the database: %fields. The search indexes may also be cleared and will need re-indexing. This <strong>cannot be undone</strong>. Are you sure you want to continue?', [
'%fields' => $field_string,
]);
}
/**
* Function that return an array of field names.
*
* @return array
* An array of field names.
*/
protected function getUnselectedFields() {
$profile_fields = $this->fieldStorage
->loadByProperties([
'entity_type' => 'profile',
'bundle' => 'profile',
]);
$settings = $this->configFactory
->get('social_profile_fields.settings');
$empty = [];
/** @var \Drupal\field\Entity\FieldConfig $value */
foreach ($profile_fields as $key => $value) {
$setting_id = str_replace('.', '_', $key);
$sval = $settings
->get($setting_id);
if (isset($sval) && $sval == FALSE) {
$empty[] = $value
->getName();
}
if ($setting_id === 'profile_profile_field_profile_address') {
if (isset($sval) && $sval == FALSE) {
$empty[] = 'country';
}
$city_val = $settings
->get('profile_address_field_city');
if (isset($city_val) && $city_val == FALSE) {
$empty[] = 'locality';
}
$address_val = $settings
->get('profile_address_field_address');
if (isset($address_val) && $address_val == FALSE) {
$empty[] = 'addressLine1';
}
$postalcode_val = $settings
->get('profile_address_field_postalcode');
if (isset($postalcode_val) && $postalcode_val == FALSE) {
$empty[] = 'postalCode';
}
}
}
return $empty;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfirmFormBase:: |
public | function |
Form constructor. Overrides FormInterface:: |
21 |
ConfirmFormBase:: |
public | function |
Returns a caption for the link which cancels the action. Overrides ConfirmFormInterface:: |
1 |
ConfirmFormBase:: |
public | function |
Returns the internal name used to refer to the confirmation item. Overrides ConfirmFormInterface:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
SocialProfileFieldsFlushForm:: |
protected | property |
Configstorage. Overrides FormBase:: |
|
SocialProfileFieldsFlushForm:: |
protected | property | Fiekdconfigstorage. | |
SocialProfileFieldsFlushForm:: |
protected | property | Profilestorage. | |
SocialProfileFieldsFlushForm:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
|
SocialProfileFieldsFlushForm:: |
public | function |
Returns the route to go to if the user cancels the action. Overrides ConfirmFormInterface:: |
|
SocialProfileFieldsFlushForm:: |
public | function |
Returns a caption for the button that confirms the action. Overrides ConfirmFormBase:: |
|
SocialProfileFieldsFlushForm:: |
public | function |
Returns additional text to display as a description. Overrides ConfirmFormBase:: |
|
SocialProfileFieldsFlushForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
SocialProfileFieldsFlushForm:: |
public | function |
Returns the question to ask the user. Overrides ConfirmFormInterface:: |
|
SocialProfileFieldsFlushForm:: |
protected | function | Function that return an array of field names. | |
SocialProfileFieldsFlushForm:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
SocialProfileFieldsFlushForm:: |
public | function | Constructs a new ExportUserConfirm. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |