8
8
namespace Magento \CatalogGraphQl \Model \Resolver \Category ;
9
9
10
10
use Magento \Catalog \Model \Category ;
11
+ use Magento \Framework \Exception \LocalizedException ;
11
12
use Magento \Framework \GraphQl \Config \Element \Field ;
12
- use Magento \Framework \GraphQl \Query \Resolver \Value ;
13
- use Magento \Framework \GraphQl \Query \Resolver \ValueFactory ;
14
13
use Magento \Framework \GraphQl \Query \ResolverInterface ;
15
14
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
16
15
use Magento \Catalog \Helper \Output as OutputHelper ;
20
19
*/
21
20
class CategoryHtmlAttribute implements ResolverInterface
22
21
{
23
- /**
24
- * @var ValueFactory
25
- */
26
- private $ valueFactory ;
27
-
28
22
/**
29
23
* @var OutputHelper
30
24
*/
31
25
private $ outputHelper ;
32
26
33
27
/**
34
- * @param ValueFactory $valueFactory
35
28
* @param OutputHelper $outputHelper
36
29
*/
37
30
public function __construct (
38
- ValueFactory $ valueFactory ,
39
31
OutputHelper $ outputHelper
40
32
) {
41
- $ this ->valueFactory = $ valueFactory ;
42
33
$ this ->outputHelper = $ outputHelper ;
43
34
}
44
35
@@ -51,23 +42,16 @@ public function resolve(
51
42
ResolveInfo $ info ,
52
43
array $ value = null ,
53
44
array $ args = null
54
- ): Value {
45
+ ) {
55
46
if (!isset ($ value ['model ' ])) {
56
- $ result = function () {
57
- return null ;
58
- };
59
- return $ this ->valueFactory ->create ($ result );
47
+ throw new LocalizedException (__ ('"model" value should be specified ' ));
60
48
}
61
49
62
50
/* @var $category Category */
63
51
$ category = $ value ['model ' ];
64
52
$ fieldName = $ field ->getName ();
65
53
$ renderedValue = $ this ->outputHelper ->categoryAttribute ($ category , $ category ->getData ($ fieldName ), $ fieldName );
66
54
67
- $ result = function () use ($ renderedValue ) {
68
- return $ renderedValue ;
69
- };
70
-
71
- return $ this ->valueFactory ->create ($ result );
55
+ return $ renderedValue ;
72
56
}
73
57
}
0 commit comments