public function Generic::rewriteAsGetter in Drupal 7 to 8/9 Module Upgrader 8
Rewrites the given expression as a property getter. Returns NULL if the expression cannot be rewritten.
Parameters
\Pharborist\ExpressionNode $expr: The expression to rewrite.
string $property: The property being used in the expression.
Return value
\Pharborist\ExpressionNode|null
2 calls to Generic::rewriteAsGetter()
- FormState::rewriteAsGetter in src/
Plugin/ DMU/ Rewriter/ FormState.php - Rewrites the given expression as a property getter. Returns NULL if the expression cannot be rewritten.
- Generic::rewrite in src/
Plugin/ DMU/ Rewriter/ Generic.php - Parametrically rewrites the function containing the given parameter.
1 method overrides Generic::rewriteAsGetter()
- FormState::rewriteAsGetter in src/
Plugin/ DMU/ Rewriter/ FormState.php - Rewrites the given expression as a property getter. Returns NULL if the expression cannot be rewritten.
File
- src/
Plugin/ DMU/ Rewriter/ Generic.php, line 180
Class
- Generic
- Plugin annotation @Rewriter( id = "_rewriter", deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Rewriter\GenericDeriver" )
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\RewriterCode
public function rewriteAsGetter(ExpressionNode $expr, $property) {
if ($expr instanceof ObjectPropertyNode) {
// Should be getRootObject() or getLookupRoot().
// @see Pharborist issue #191
$object = clone $expr
->getObject();
}
elseif ($expr instanceof ArrayLookupNode) {
$object = clone $expr
->getRootArray();
}
if (isset($object) && isset($this->pluginDefinition['properties'][$property]['get'])) {
return ObjectMethodCallNode::create($object, $this->pluginDefinition['properties'][$property]['get']);
}
}