public function Generic::rewriteAsSetter in Drupal 7 to 8/9 Module Upgrader 8
Rewrites an assignment expression as a property setter. 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.
\Pharborist\Operators\AssignNode $assignment: The entire assignment expression being rewritten.
Return value
\Pharborist\ExpressionNode|null
2 calls to Generic::rewriteAsSetter()
- FormState::rewriteAsSetter in src/
Plugin/ DMU/ Rewriter/ FormState.php - Rewrites an assignment expression as a property setter. 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::rewriteAsSetter()
- FormState::rewriteAsSetter in src/
Plugin/ DMU/ Rewriter/ FormState.php - Rewrites an assignment expression as a property setter. Returns NULL if the expression cannot be rewritten.
File
- src/
Plugin/ DMU/ Rewriter/ Generic.php, line 208
Class
- Generic
- Plugin annotation @Rewriter( id = "_rewriter", deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Rewriter\GenericDeriver" )
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\RewriterCode
public function rewriteAsSetter(ExpressionNode $expr, $property, AssignNode $assignment) {
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]['set'])) {
return ObjectMethodCallNode::create($object, $this->pluginDefinition['properties'][$property]['set'])
->appendArgument(clone $assignment
->getRightOperand());
}
}