Skip to content

Commit f992821

Browse files
authored
Fixes action not found issue when calling an action defined in a layout (#10)
* Fixes action not found issue when calling an action defined in a layout * only publish on command
1 parent 1a56551 commit f992821

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Publish Packages
22

33
on:
4-
push:
5-
branches: [main]
6-
tags: ["v*"]
74
workflow_dispatch:
85

96
jobs:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v0.3.1
4+
- Fixes action not found error when calling an action provided via a layout (#10)
5+
36
## v0.3.0
47

58
- Added a `bind` option to queries and mutations (#9)

packages/viper-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ozmos/viper-react",
33
"description": "React plugin for Viper",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"private": false,
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",

packages/viper-vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ozmos/viper-vue",
33
"description": "Vue plugin for Viper",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"private": false,
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",

packages/vite-plugin-viper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@ozmos/vite-plugin-viper",
33
"description": "Vite plugin for Viper",
44
"private": false,
5-
"version": "0.3.0",
5+
"version": "0.3.1",
66
"main": "./src/index.js",
77
"type": "module",
88
"scripts": {

src/PageComponent.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -332,34 +332,34 @@ public function action(string $name)
332332
return null;
333333
}
334334

335-
$reflection = new \ReflectionClass($this->pageInstance());
335+
$reflection = new \ReflectionClass($actions[$name]);
336336

337-
$params = $this->getParams();
338-
$headerColumns = str(request()->header('x-viper-bind-keys'))->explode(',');
339-
$headerValues = str(request()->header('x-viper-bind-values'))->explode(',');
337+
$params = $this->getParams();
338+
$headerColumns = str(request()->header('x-viper-bind-keys'))->explode(',');
339+
$headerValues = str(request()->header('x-viper-bind-values'))->explode(',');
340340

341-
$method = $reflection->getMethod($name);
341+
$method = $reflection->getMethod($name);
342342

343-
foreach ($method->getParameters() as $param) {
344-
$attrs = $param->getAttributes(Bind::class);
343+
foreach ($method->getParameters() as $param) {
344+
$attrs = $param->getAttributes(Bind::class);
345345

346-
if (empty($attrs)) {
347-
continue;
348-
}
346+
if (empty($attrs)) {
347+
continue;
348+
}
349349

350-
$attr = $attrs[0]->newInstance();
351-
$index = $headerColumns->search($param->getName());
350+
$attr = $attrs[0]->newInstance();
351+
$index = $headerColumns->search($param->getName());
352352

353-
if ($index === false) {
354-
continue;
355-
}
353+
if ($index === false) {
354+
continue;
355+
}
356356

357-
$model = $this->resolveModel($param->getType()->getName(), $headerValues[$index], $attr->column);
357+
$model = $this->resolveModel($param->getType()->getName(), $headerValues[$index], $attr->column);
358358

359-
if ($model) {
360-
$params[$param->getName()] = $model;
359+
if ($model) {
360+
$params[$param->getName()] = $model;
361+
}
361362
}
362-
}
363363

364364
return app()->call($actions[$name]->$name(...), $params);
365365
}

src/Transformers/PageTransformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function transform(ReflectionClass $class, string $name): null|Transforme
4848
$bindings[] = $param->getName();
4949
}
5050
$bindingType = json_encode($bindings);
51-
$propLines[] = "{$method->getName()}: { result: ".$returnType."; bindings: $bindingType }";
51+
$propLines[] = "{$method->getName()}: { result: " . $returnType . "; bindings: $bindingType }";
5252
}
5353

5454
$actions = $method->getAttributes(Action::class);
@@ -83,7 +83,7 @@ public function transformAction(\ReflectionMethod $method, MissingSymbolsCollect
8383
$returnType = $this->reflectionToTypeScript($method, $missingSymbols);
8484

8585
$argType = 'any';
86-
$bindings = [];
86+
$bindings = [];
8787

8888
foreach ($method->getparameters() as $parameter) {
8989
if ($parameter->getType()->isBuiltin()) {
@@ -93,7 +93,7 @@ public function transformAction(\ReflectionMethod $method, MissingSymbolsCollect
9393
$attrs = $parameter->getAttributes(Bind::class);
9494

9595
if (!empty($attrs)) {
96-
$bindings[] = $parameter->getName();
96+
$bindings[] = $parameter->getName();
9797
}
9898

9999
$classReflect = new \ReflectionClass($parameter->getType()->getName());
@@ -104,7 +104,7 @@ public function transformAction(\ReflectionMethod $method, MissingSymbolsCollect
104104
}
105105
}
106106

107-
$bindingType = json_encode($bindings);
107+
$bindingType = json_encode($bindings);
108108

109109
return "{$method->getName()}: { args: {$argType}; result: {$returnType}; bindings: $bindingType; }";
110110
}

0 commit comments

Comments
 (0)