@@ -33,6 +33,11 @@ trait ActionHelperTrait
3333
3434 public function getOptionsRoute ():string
3535 {
36+ $ r = $ this ->getRoute ();
37+ $ r = explode ('/ ' , $ r );
38+ array_pop ($ r );
39+ return implode ('/ ' , $ r ) . '/options ' ;
40+
3641 if (!empty ($ this ->prefixSettings )) {
3742 if (isset ($ this ->prefixSettings ['module ' ])) {
3843 $ prefix = $ this ->prefixSettings ['module ' ];
@@ -81,4 +86,38 @@ public static function finalOptionsRoute(string $prefix, string $controllerId):
8186 {
8287 return trim ($ prefix , '/ ' ) . '/ ' . $ controllerId . '/options ' ;
8388 }
89+
90+ public function getRoute (): string
91+ {
92+ if ($ this ->xRoute ) {
93+ return $ this ->xRoute ;
94+ }
95+
96+ if (!empty ($ this ->prefixSettings )) {
97+ if (isset ($ this ->prefixSettings ['module ' ])) {
98+ $ prefix = $ this ->prefixSettings ['module ' ];
99+ // return static::finalOptionsRoute($prefix, $this->controllerId);
100+ return trim ($ prefix , '/ ' ) . '/ ' . $ this ->controllerId . '/ ' . $ this ->id ;
101+ } elseif (isset ($ this ->prefixSettings ['namespace ' ]) && str_contains ($ this ->prefixSettings ['namespace ' ], '\modules \\' )) { # if `module` not present then check in namespace and then in path
102+ $ prefix = static ::computeModule ('\\' , $ this ->prefixSettings ['namespace ' ]);
103+ if ($ prefix ) {
104+ // return static::finalOptionsRoute($prefix, $this->controllerId);
105+ return trim ($ prefix , '/ ' ) . '/ ' . $ this ->controllerId . '/ ' . $ this ->id ;
106+ }
107+ } elseif (isset ($ this ->prefixSettings ['path ' ]) && str_contains ($ this ->prefixSettings ['path ' ], '/modules/ ' )) {
108+ $ prefix = static ::computeModule ('/ ' , $ this ->prefixSettings ['path ' ]);
109+ if ($ prefix ) {
110+ // return static::finalOptionsRoute($prefix, $this->controllerId);
111+ return trim ($ prefix , '/ ' ) . '/ ' . $ this ->controllerId . '/ ' . $ this ->id ;
112+ }
113+ }
114+ }
115+
116+ // if (!empty($this->prefixSettings)) {
117+ // $prefix = $this->prefixSettings['module'] ?? $this->prefix;
118+ // return trim($prefix, '/') . '/' . $this->controllerId . '/' . $this->id;
119+ // }
120+
121+ return $ this ->controllerId . '/ ' . $ this ->id ;
122+ }
84123}
0 commit comments