class FieldValueFilter in Drupal 7 to 8/9 Module Upgrader 8
Filters for things that *look like* field accesses, e.g. $foo->bar[LANGUAGE_NONE][0]['value']. This filter doesn't guarantee that matched nodes actually ARE field accesses -- just that they have the proper formation (S-foils in attack formation!...what, you don't like Star Wars?)
Hierarchy
- class \Drupal\drupalmoduleupgrader\Utility\Filter\FieldValueFilter
Expanded class hierarchy of FieldValueFilter
2 files declare their use of FieldValueFilter
- FieldValueFilterTest.php in tests/
src/ Unit/ Utility/ Filter/ FieldValueFilterTest.php - Generic.php in src/
Plugin/ DMU/ Rewriter/ Generic.php
File
- src/
Utility/ Filter/ FieldValueFilter.php, line 16
Namespace
Drupal\drupalmoduleupgrader\Utility\FilterView source
class FieldValueFilter {
/**
* @var string
*/
protected $variable;
public function __construct($variable) {
$this->variable = $variable;
}
/**
* @return bool
*/
public function __invoke(Node $node) {
if ($node instanceof ArrayLookupNode) {
$root = $node
->getRootArray();
if ($root instanceof ObjectPropertyNode) {
$object = $root
->getObject();
if ($object instanceof VariableNode && $object
->getName() == $this->variable) {
return sizeof($node
->getKeys()) >= 3;
}
}
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldValueFilter:: |
protected | property | ||
FieldValueFilter:: |
public | function | ||
FieldValueFilter:: |
public | function |