Contact.php in FZ152 8
File
modules/contact/src/Plugin/Fz152/Contact.php
View source
<?php
namespace Drupal\fz152_contact\Plugin\Fz152;
use Drupal\fz152\Fz152PluginBase;
use Drupal\fz152_contact\Form\Fz152ContactSettings;
class Contact extends Fz152PluginBase {
protected $configFactory;
public function getSettingsPage() {
return [
'path' => 'contact',
'title' => 'Contact',
'form' => Fz152ContactSettings::class,
'weight' => 5,
];
}
public function getForms() {
$forms = [];
$contact_forms = $this
->getContactForms();
foreach (array_keys($contact_forms) as $form) {
$config = $this
->config("fz152_contact.settings.{$form}");
if ($config
->get('enabled')) {
$forms[] = [
'form_id' => 'contact_message_' . $form . '_form',
'weight' => $config
->get('weight') ?: NULL,
];
}
}
return $forms;
}
protected function getContactForms() {
$bundleInfo = \Drupal::service('entity_type.bundle.info');
return $bundleInfo
->getBundleInfo('contact_message');
}
protected function config($name) {
if (!isset($this->configFactory)) {
$this->configFactory = \Drupal::service('config.factory');
}
return $this->configFactory
->get($name);
}
}
Classes
Name |
Description |
Contact |
Provides an annotated Fz152 plugin to configure contact form. |