InitialValuesEvent.php 1.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
<?php

namespace Drupal\address\Event;

use Drupal\Core\Field\FieldDefinitionInterface;
use Symfony\Component\EventDispatcher\Event;

/**
 * Defines the initial values event.
 *
11 12
 * @deprecated No longer fired since 1.5. Use hook_field_widget_form_alter()
 *             to change the address #default_value instead.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
 */
class InitialValuesEvent extends Event {

  /**
   * The initial values.
   *
   * @var array
   */
  protected $initialValues;

  /**
   * The field definition.
   *
   * @var \Drupal\Core\Field\FieldDefinitionInterface
   */
  protected $fieldDefinition;

  /**
   * Constructs a new InitialValuesEvent object.
   *
33
   * @param array $initial_values
34
   *   The initial values.
35
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
36 37
   *   The field definition.
   */
38 39 40
  public function __construct(array $initial_values, FieldDefinitionInterface $field_definition) {
    $this->initialValues = $initial_values;
    $this->fieldDefinition = $field_definition;
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  }

  /**
   * Gets the initial values.
   *
   * @return array
   *   The initial values.
   */
  public function getInitialValues() {
    return $this->initialValues;
  }

  /**
   * Sets the initial values.
   *
56
   * @param array $initial_values
57
   *   The initial values to set.
58
   *
59 60
   * @return $this
   */
61 62
  public function setInitialValues(array $initial_values) {
    $this->initialValues = $initial_values;
63 64 65 66 67 68 69 70 71 72 73 74 75 76
    return $this;
  }

  /**
   * Gets the field definition.
   *
   * @return \Drupal\Core\Field\FieldDefinitionInterface
   *   The field definition.
   */
  public function getFieldDefinition() {
    return $this->fieldDefinition;
  }

}