class NodeBooleanField in Fasttoggle 8.2
Abstract interface for settings. Plugin strings are used for quick filtering without the need to instantiate the class.
Plugin annotation
@Plugin(
entityType = "node",
name = "node_boolean_field",
description = "Boolean field",
id = "node_field_boolean",
group = "node_core",
weight = 40,
default = false,
base_formatter = "Drupal\fasttoggle\Plugin\Field\FieldFormatter\BooleanFormatter",
labels = {
FASTTOGGLE_LABEL_ACTION = {
0 = @Translation("apply attribute"),
1 = @Translation("remove attribute"),
},
FASTTOGGLE_LABEL_STATUS = {
0 = @Translation("not attribute"),
1 = @Translation("attribute"),
},
},
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\fasttoggle\Plugin\SettingObject\AbstractSettingObject implements SettingObjectInterface
- class \Drupal\fasttoggle\Plugin\SettingObject\node implements SettingObjectInterface
- class \Drupal\fasttoggle\Plugin\SettingGroup\NodeCore implements SettingGroupInterface
- class \Drupal\fasttoggle\Plugin\Setting\NodeBooleanField implements SettingInterface uses SettingTrait
- class \Drupal\fasttoggle\Plugin\SettingGroup\NodeCore implements SettingGroupInterface
- class \Drupal\fasttoggle\Plugin\SettingObject\node implements SettingObjectInterface
- class \Drupal\fasttoggle\Plugin\SettingObject\AbstractSettingObject implements SettingObjectInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of NodeBooleanField
File
- src/
Plugin/ Setting/ NodeBooleanField.php, line 43 - Fasttoggle Node Sticky
Namespace
Drupal\fasttoggle\Plugin\SettingView source
class NodeBooleanField extends NodeCore implements SettingInterface {
use SettingTrait;
/**
* Access control function.
*
* @param $node
* The node against which to check (un)publish permission.
*
* @return boolean
* Whether the user is allowed to (un)publish the node.
*/
public function mayEditSetting() {
$user = \Drupal::currentUser();
//@TODO Needs more tests?
return AccessResult::allowedIfHasPermission($user, 'edit any article content');
}
/**
* Return whether this setting matches the provided field definition.
*
* @param $definition
* The field definition for which a match is being sought.
*
* @return boolean
* Whether this plugin handles the definition.
*/
public static function matches($definition) {
$has_get = is_callable(array(
$definition,
'get',
));
$entity = $has_get ? $definition
->get('entity_type') : $definition
->getProvider();
return $entity == 'node' && $definition
->getName() == 'field_boolean';
}
public function get_attributes() {
return [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractSettingObject:: |
protected | property | The object being managed. | |
AbstractSettingObject:: |
public | function |
Get the object instance. Overrides SettingObjectInterface:: |
|
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 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
node:: |
public | function |
Object ID. Overrides AbstractSettingObject:: |
|
node:: |
public | function |
Object title. Overrides AbstractSettingObject:: |
|
node:: |
public | function |
Object subtype machine name. Overrides AbstractSettingObject:: |
|
node:: |
public | function |
Access. Overrides AbstractSettingObject:: |
|
node:: |
public | function |
Matches an object? Overrides SettingObjectInterface:: |
|
node:: |
public | function |
Save function. Overrides AbstractSettingObject:: |
|
node:: |
public | function |
Set the node object. Overrides AbstractSettingObject:: |
|
NodeBooleanField:: |
public | function | ||
NodeBooleanField:: |
public static | function |
Return whether this setting matches the provided field definition. Overrides SettingInterface:: |
|
NodeBooleanField:: |
public | function |
Access control function. Overrides SettingTrait:: |
|
NodeCore:: |
public static | function |
Return whether this setting matches the provided field definition. Overrides SettingGroupInterface:: |
|
NodeCore:: |
public | function |
Access. Overrides SettingGroupInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
SettingTrait:: |
public | function | Keys for config settings. | |
SettingTrait:: |
public | function | Get the markup we modify. | |
SettingTrait:: |
public | function | Get a plain text list of human readable labels for the setting, in the order used. | |
SettingTrait:: |
public static | function | Get an array of sitewide setting form elements for this object type. | |
SettingTrait:: |
public | function | Get a list of actual values for the setting, in the order used. | 1 |
SettingTrait:: |
function | Retrieve the FieldItem for a setting. | ||
SettingTrait:: |
public | function | Get labels (fallback function if a template is used (eg roles) | |
SettingTrait:: |
function | Retrieve the current value of the setting. | 1 | |
SettingTrait:: |
public | function | Write access check. | |
SettingTrait:: |
public | function | Move to the next setting value. | |
SettingTrait:: |
public | function | Move to the previous setting value and save it. | |
SettingTrait:: |
public | function | Return a render array for an instance of this setting. | |
SettingTrait:: |
function | Set a custom field name (eg fields on nodes). | ||
SettingTrait:: |
public | function | Return the sitewide form element for this setting. | 1 |
SettingTrait:: |
function | Modify the setting. | 1 | |
SettingTrait:: |
public | function | Allow access to the trait constructor if the setting also implements one. | |
SettingTrait:: |
public | function | 1 | |
SettingTrait:: |
public | function | Retrieve the object type that can be modified by this setting. | |
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. |