Skip to content

Commit 083eccc

Browse files
Merge pull request #30 from SebastianKrupinski/feat/properties-from-request
feat: add properties from request
2 parents e40e975 + ec92ca4 commit 083eccc

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

lib/Requests/Interfaces/RequestGetInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,13 @@ public function targetFromRequest(Request $request, string $selector): static;
4040
* @return self
4141
*/
4242
public function property(string ...$name): static;
43+
44+
/**
45+
* Set which properties to fetch from another request result
46+
*
47+
* @param Request $request The request to reference
48+
* @param string $selector The path to extract property names from
49+
* @return self
50+
*/
51+
public function propertyFromRequest(Request $request, string $selector): static;
4352
}

lib/Requests/RequestGet.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,14 @@ public function property(string ...$name): static
4141

4242
return $this;
4343
}
44+
45+
public function propertyFromRequest(Request $request, string $selector): static
46+
{
47+
$this->_command['#properties'] = new \stdClass();
48+
$this->_command['#properties']->resultOf = $request->getIdentifier();
49+
$this->_command['#properties']->name = $request->getClass() . '/' . $request->getMethod();
50+
$this->_command['#properties']->path = $selector;
51+
52+
return $this;
53+
}
4454
}

0 commit comments

Comments
 (0)