NifProcessed.php in Field NIF 8
File
src/NifProcessed.php
View source
<?php
namespace Drupal\field_nif;
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\TypedData;
use Drupal\Core\TypedData\TypedDataInterface;
class NifProcessed extends TypedData {
protected $processed = NULL;
public function __construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL) {
parent::__construct($definition, $name, $parent);
if ($definition
->getSetting('document source') === NULL) {
throw new \InvalidArgumentException("The definition's 'document source' key has to specify the name of the properties to be processed.");
}
}
public function getValue() {
if ($this->processed !== NULL) {
return $this->processed;
}
$this->processed = '';
$item = $this
->getParent();
$source = $this->definition
->getSetting('document source');
foreach ($source as $property) {
$this->processed .= $item->{$property};
}
return $this->processed;
}
public function setValue($value, $notify = TRUE) {
$this->processed = $value;
if ($notify && isset($this->parent)) {
$this->parent
->onChange($this->name);
}
}
}
Classes
Name |
Description |
NifProcessed |
A computed property for processing NIF/CIF/NIE documents. |