You are here

class RealisticDummyContentValueField in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/includes/RealisticDummyContentValueField.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentValueField
  2. 7.2 api/src/includes/RealisticDummyContentValueField.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentValueField

Generic Drupal field.

Represents a generic field which appears in an entity object as array('value' => 'xyz').

Hierarchy

Expanded class hierarchy of RealisticDummyContentValueField

1 file declares its use of RealisticDummyContentValueField
RealisticDummyContentValueFieldTest.php in api/tests/src/Unit/includes/RealisticDummyContentValueFieldTest.php

File

api/src/includes/RealisticDummyContentValueField.php, line 13

Namespace

Drupal\realistic_dummy_content_api\includes
View source
class RealisticDummyContentValueField extends RealisticDummyContentField {

  /**
   * {@inheritdoc}
   */
  public function implementValueFromFile($file) : array {
    $value = $file
      ->value();
    if ($value === NULL) {
      return [];
    }
    return $this
      ->format($value);
  }

  /**
   * Mockable wrapper around the formatter.
   *
   * @param mixed $value
   *   A file, or string.
   *
   * @return array
   *   A formatted item.
   */
  public function format($value) : array {
    return Framework::instance()
      ->formatProperty('value', $value);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RealisticDummyContentAttribute::$entity private property Entity managed by this class.
RealisticDummyContentAttribute::$name private property The name of this attribuet, for example title, picture, field_image...
RealisticDummyContentAttribute::change public function Changes this attribute by looking for data in files.
RealisticDummyContentAttribute::changeFromFiles public function Given candidate files, change value of this attribute based on one of them.
RealisticDummyContentAttribute::env public function Returns the appropriate environment, real or testing.
RealisticDummyContentAttribute::fileSave public function Return a file object.
RealisticDummyContentAttribute::getBundle public function Gets the bundle of the associated entity.
RealisticDummyContentAttribute::getCandidateFiles public function Get all candidate files for a given field for this entity.
RealisticDummyContentAttribute::getEntity public function Getter for $this->entity.
RealisticDummyContentAttribute::getEntityType public function Get the entity type of the associated entity.
RealisticDummyContentAttribute::getExtensions public function Get acceptable file extensions which contain data for this attribute. 1
RealisticDummyContentAttribute::getImageExtensions public function Return acceptable image file extensions.
RealisticDummyContentAttribute::getName public function Getter for $this->name.
RealisticDummyContentAttribute::getTextExtensions public function Return acceptable text file extensions.
RealisticDummyContentAttribute::getUid public function Gets the UID of the associated entity.
RealisticDummyContentAttribute::imageSave public function Return an image file object if possible.
RealisticDummyContentAttribute::rand public function Returns a pseudo-random number.
RealisticDummyContentAttribute::valueFromFile public function Given a RealisticDummyContentFileGroup object, get structured property.
RealisticDummyContentAttribute::valueFromFiles public function Given a list of files, return a value from one of them.
RealisticDummyContentAttribute::__construct public function Constructor.
RealisticDummyContentDrupalTrait::fieldInfoField public function Mockable wrapper around Framework::fieldInfoField().
RealisticDummyContentDrupalTrait::getAllVocabularies public function Mockable wrapper around Framework::getAllVocabularies().
RealisticDummyContentDrupalTrait::newVocabularyTerm public function Mockable wrapper around Framework::newVocabularyTerm().
RealisticDummyContentDrupalTrait::taxonomyLoadTree public function Mockable wrapper around Framework::taxonomyLoadTree().
RealisticDummyContentDrupalTrait::termId public function Mockable wrapper around Framework::termId().
RealisticDummyContentDrupalTrait::termName public function Mockable wrapper around Framework::termName().
RealisticDummyContentDrupalTrait::vocabularyMachineName public function Mockable wrapper around Framework::vocabularyMachineName().
RealisticDummyContentDrupalTrait::watchdogThrowable public function Log a \Throwable to the watchdog.
RealisticDummyContentField::getType public function Returns the type of this attribute. Overrides RealisticDummyContentAttribute::getType
RealisticDummyContentValueField::format public function Mockable wrapper around the formatter.
RealisticDummyContentValueField::implementValueFromFile public function Given a RealisticDummyContentFileGroup object, get a structured property. Overrides RealisticDummyContentAttribute::implementValueFromFile