You are here

abstract class AbstractSettingObject in Fasttoggle 8.2

Abstract class for an object on which Fasttoggle can modify settings.

Hierarchy

Expanded class hierarchy of AbstractSettingObject

1 file declares its use of AbstractSettingObject
AbstractSettingGroup.php in src/Plugin/SettingGroup/AbstractSettingGroup.php
Fasttoggle Object List of Values Setting

File

src/Plugin/SettingObject/AbstractSettingObject.php, line 17
Abstract Fasttoggle Object

Namespace

Drupal\fasttoggle\Plugin\SettingObject
View source
abstract class AbstractSettingObject extends PluginBase implements SettingObjectInterface {

  /**
   * @var object $object
   *   The object being managed.
   * */
  protected $object;

  /**
   * Retrieve the object type that can be modified by this setting.
   *
   * @return string
   *   The machine name for the object type being modified by this setting.
   */
  public function __get($name) {

    // Simple member
    if (isset($this->{$name})) {
      return $this->{$name};
    }

    // Annotation
    $definition = $this
      ->getPluginDefinition();
    if (isset($definition[$name])) {
      return $definition[$name];
    }

    // Specific getter function
    $functionName = "get_{$name}";
    if (is_callable([
      $this,
      $functionName,
    ])) {
      return $this
        ->{$functionName}();
    }

    // Unmatched
    $trace = debug_backtrace();
    trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
    return NULL;
  }

  /**
   * Set an instance of the object.
   */
  public function setObject($object) {
    $this->object = $object;
  }

  /**
   * Get the object instance.
   *
   * @return object
   *   The instance of the object, if any.
   */
  public function get_object() {
    return $this->object;
  }

  /**
   * Object ID.
   *
   * @return integer
   *   The unique ID of this instance of the object.
   */
  public abstract function get_id();

  /**
   * Object title.
   *
   * @return integer
   *   The title of the object for display.
   */
  public abstract function get_title();

  /**
   * Save function. Update the entity in the database.
   *
   * @return bool
   *   Whether the object was successfully saved.
   */
  public abstract function save();

  /**
   * Object subtype machine name.
   *
   * @return string
   *   A subtype (if any) of the object (eg node type).
   */
  public function get_type() {
    return '';
  }

  /**
   * Access.
   *
   * @return bool
   *   Whether the user is permitted to modify settings on this object instance.
   */
  public function mayEditEntity() {
    return FALSE;
  }

  /**
   * Get an array of sitewide setting form elements for this object type.
   *
   * @param $config
   *   The configuration storage.
   *
   * @return array
   *   Render array for the sitewide settings.
   */
  public static function getSitewideSettingFormElements($config) {
    return [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractSettingObject::$object protected property The object being managed.
AbstractSettingObject::getSitewideSettingFormElements public static function Get an array of sitewide setting form elements for this object type. Overrides SettingObjectInterface::getSitewideSettingFormElements 2
AbstractSettingObject::get_id abstract public function Object ID. Overrides SettingObjectInterface::get_id 3
AbstractSettingObject::get_object public function Get the object instance. Overrides SettingObjectInterface::get_object
AbstractSettingObject::get_title abstract public function Object title. Overrides SettingObjectInterface::get_title 3
AbstractSettingObject::get_type public function Object subtype machine name. Overrides SettingObjectInterface::get_type 1
AbstractSettingObject::mayEditEntity public function Access. Overrides SettingObjectInterface::mayEditEntity 3
AbstractSettingObject::save abstract public function Save function. Update the entity in the database. Overrides SettingObjectInterface::save 3
AbstractSettingObject::setObject public function Set an instance of the object. Overrides SettingObjectInterface::setObject 1
AbstractSettingObject::__get public function Retrieve the object type that can be modified by this setting. 1
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92
SettingObjectInterface::objectMatches public function Matches an object? 3
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.