writePropertyValue example

    // this behavior is configurable, see language_field_info_alter().     $this->setValue(['value' => \Drupal::languageManager()->getDefaultLanguage()->getId()]$notify);
    return $this;
  }

  /** * {@inheritdoc} */
  public function onChange($property_name$notify = TRUE) {
    // Make sure that the value and the language property stay in sync.     if ($property_name == 'value') {
      $this->writePropertyValue('language', $this->value);
    }
    elseif ($property_name == 'language') {
      $this->writePropertyValue('value', $this->get('language')->getTargetIdentifier());
    }
    parent::onChange($property_name$notify);
  }

  /** * {@inheritdoc} */
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    
      $this->properties[$property_name] = $this->getTypedDataManager()->getPropertyInstance($this$property_name$value);
    }
    return $this->properties[$property_name];
  }

  /** * {@inheritdoc} */
  public function set($property_name$value$notify = TRUE) {
    // Separate the writing in a protected method, such that onChange     // implementations can make use of it.     $this->writePropertyValue($property_name$value);
    $this->onChange($property_name$notify);
    return $this;
  }

  /** * Writes the value of a property without handling changes. * * Implementations of onChange() should use this method instead of set() in * order to avoid onChange() being triggered again. * * @param string $property_name * The name of the property to be written. * @param $value * The value to set. */
return $value === NULL || $value === '';
  }

  /** * {@inheritdoc} */
  public function onChange($property_name$notify = TRUE) {
    // Unset processed properties that are affected by the change.     foreach ($this->definition->getPropertyDefinitions() as $property => $definition) {
      if ($definition->getClass() == '\Drupal\text\TextProcessed') {
        if ($property_name == 'format' || ($definition->getSetting('text source') == $property_name)) {
          $this->writePropertyValue($property, NULL);
        }
      }
    }
    parent::onChange($property_name$notify);
  }

  /** * {@inheritdoc} */
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $random = new Random();
    
return $values;
  }

  /** * {@inheritdoc} */
  public function onChange($property_name$notify = TRUE) {
    // Make sure that the target ID and the target property stay in sync.     if ($property_name == 'entity') {
      $property = $this->get('entity');
      $target_id = $property->isTargetNew() ? NULL : $property->getTargetIdentifier();
      $this->writePropertyValue('target_id', $target_id);
    }
    elseif ($property_name == 'target_id') {
      $this->writePropertyValue('entity', $this->target_id);
    }
    parent::onChange($property_name$notify);
  }

  /** * {@inheritdoc} */
  public function isEmpty() {
    
Home | Imprint | This part of the site doesn't use cookies.