@@ -71,30 +71,13 @@ private function getMeta(\ReflectionMethod $method)
7171 foreach ($ annotations as $ annotation ) {
7272 if ($ annotation instanceof AbstractWebContextParam) {
7373 $ pos = $ this ->getPos ($ annotation , $ method );
74- $ meta [$ pos ] = [$ annotation ::GLOBAL_KEY , $ annotation ->key ];
74+ $ meta [$ pos ] = [$ annotation ::GLOBAL_KEY , $ annotation ->key , $ annotation -> default ];
7575 }
7676 }
7777
7878 return $ meta ;
7979 }
8080
81- /**
82- * @param array $meta
83- * @param int $i
84- *
85- * @return array
86- */
87- private function getParam (array $ meta , $ i )
88- {
89- list ($ globalKey , $ key ) = $ meta [$ i ];
90- $ webContext = $ this ->webContext ->get ($ globalKey );
91- if (isset ($ webContext [$ key ])) {
92- return [true , $ webContext [$ key ]];
93- }
94-
95- return [false , null ];
96- }
97-
9881 /**
9982 * @param AbstractWebContextParam $annotation
10083 * @param \ReflectionMethod $method
@@ -124,10 +107,30 @@ private function getPos(AbstractWebContextParam $annotation, \ReflectionMethod $
124107 private function setArg (Arguments $ args , array $ meta , $ i )
125108 {
126109 if (isset ($ meta [$ i ]) && (! isset ($ args [$ i ]))) {
127- list ($ hasParam , $ param ) = $ this ->getParam ($ meta , $ i );
110+ list ($ hasParam , $ param, $ default ) = $ this ->getParam ($ meta , $ i );
128111 if ($ hasParam ) {
129112 $ args [$ i ] = $ param ;
130113 }
114+ if ($ default ) {
115+ $ args [$ i ] = $ default ;
116+ }
131117 }
132118 }
119+
120+ /**
121+ * @param array $meta
122+ * @param int $i
123+ *
124+ * @return array
125+ */
126+ private function getParam (array $ meta , $ i )
127+ {
128+ list ($ globalKey , $ key , $ default ) = $ meta [$ i ];
129+ $ webContext = $ this ->webContext ->get ($ globalKey );
130+ if (isset ($ webContext [$ key ])) {
131+ return [true , $ webContext [$ key ], $ default ];
132+ }
133+
134+ return [false , null , $ default ];
135+ }
133136}
0 commit comments