From ef515b53449a1e7d93aa6795967401d0c1ff3ca9 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Mon, 23 May 2016 18:21:27 +0200 Subject: [PATCH] Add refresh method --- src/ResourceGenerator.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ResourceGenerator.php b/src/ResourceGenerator.php index add5c94..29dbfb4 100644 --- a/src/ResourceGenerator.php +++ b/src/ResourceGenerator.php @@ -181,6 +181,27 @@ protected function createExtendingClass(string $type, array $yaml) $class = $factory->class($yaml['class']) ->extend('Base' . $yaml['class']); + $class->addStmt($factory->method('refresh') + ->makePublic() + ->setReturnType($yaml['class']) + ->addStmt( + new Node\Stmt\Return_( + new Node\Expr\MethodCall( + new Node\Expr\Variable('this'), + 'wait', + [ + new Node\Expr\MethodCall( + new Node\Expr\Variable('this'), + 'callAsync', + [ + new Node\Scalar\String_('refresh'), + ] + ), + ] + ) + ) + )); + $node = $factory->namespace($yaml['namespace'] . '\\' . $type ) ->addStmt($factory->use($yaml['namespace'] . '\\' . $yaml['class'])->as('Base' . $yaml['class'])) ->addStmt($class)