@@ -30,14 +30,6 @@ class plgSystemGitDeploy extends CMSPlugin
3030 */
3131 protected $ autoloadLanguage = true ;
3232
33- /**
34- * Application object.
35- *
36- * @var CMSApplication
37- * @since 1.0
38- */
39- protected $ app ;
40-
4133 /**
4234 * Raw post data
4335 *
@@ -56,7 +48,7 @@ class plgSystemGitDeploy extends CMSPlugin
5648 */
5749 public function onAfterRoute ()
5850 {
59- if ($ this ->app ->input ->getCmd ('github ' , false ))
51+ if ($ this ->getApplication () ->input ->getCmd ('github ' , false ))
6052 {
6153 set_error_handler (
6254 function ($ severity , $ message , $ file , $ line )
@@ -70,7 +62,7 @@ function($e)
7062 {
7163 header ('HTTP/1.1 500 Internal Server Error ' );
7264 echo "Error on line {$ e ->getLine ()}: " . htmlspecialchars ($ e ->getMessage ());
73- $ this ->app ->close ();
65+ $ this ->getApplication () ->close ();
7466 }
7567 );
7668
@@ -85,7 +77,7 @@ function($e)
8577 $ this ->setPayload ();
8678 $ this ->handleGitHubEvent ();
8779
88- $ this ->app ->close ();
80+ $ this ->getApplication () ->close ();
8981 }
9082 }
9183
@@ -101,7 +93,7 @@ function($e)
10193 */
10294 protected function checkSecret ($ hookSecret )
10395 {
104- if (!$ this ->app ->input ->server ->get ('HTTP_X_HUB_SIGNATURE_256 ' , false ))
96+ if (!$ this ->getApplication () ->input ->server ->get ('HTTP_X_HUB_SIGNATURE_256 ' , false ))
10597 {
10698 throw new \Exception ("HTTP header 'X-Hub-Signature' is missing. " );
10799 }
@@ -111,7 +103,7 @@ protected function checkSecret($hookSecret)
111103 throw new \Exception ("Missing 'hash' extension to check the secret code validity. " );
112104 }
113105
114- list ($ algo , $ hash ) = explode ('= ' , $ this ->app ->input ->server ->getString ('HTTP_X_HUB_SIGNATURE_256 ' ), 2 ) + array ('' , '' );
106+ list ($ algo , $ hash ) = explode ('= ' , $ this ->getApplication () ->input ->server ->getString ('HTTP_X_HUB_SIGNATURE_256 ' ), 2 ) + array ('' , '' );
115107
116108 if (!in_array ($ algo , hash_algos (), TRUE ))
117109 {
@@ -136,11 +128,11 @@ protected function checkSecret($hookSecret)
136128 */
137129 protected function checkContentType ()
138130 {
139- if (!$ this ->app ->input ->server ->getString ('CONTENT_TYPE ' , false ))
131+ if (!$ this ->getApplication () ->input ->server ->getString ('CONTENT_TYPE ' , false ))
140132 {
141133 throw new \Exception ("Missing HTTP 'Content-Type' header. " );
142134 }
143- elseif (!$ this ->app ->input ->server ->getString ('HTTP_X_GITHUB_EVENT ' , false ))
135+ elseif (!$ this ->getApplication () ->input ->server ->getString ('HTTP_X_GITHUB_EVENT ' , false ))
144136 {
145137 throw new \Exception ("Missing HTTP 'X-Github-Event' header. " );
146138 }
@@ -156,18 +148,18 @@ protected function checkContentType()
156148 */
157149 protected function setPayload ()
158150 {
159- switch ($ this ->app ->input ->server ->getString ('CONTENT_TYPE ' ))
151+ switch ($ this ->getApplication () ->input ->server ->getString ('CONTENT_TYPE ' ))
160152 {
161153 case 'application/json ' :
162154 $ json = $ this ->rawPost ?: file_get_contents ('php://input ' );
163155 break ;
164156
165157 case 'application/x-www-form-urlencoded ' :
166- $ json = $ this ->app ->input ->post ->get ('payload ' );
158+ $ json = $ this ->getApplication () ->input ->post ->get ('payload ' );
167159 break ;
168160
169161 default :
170- throw new \Exception ('Unsupported content type: ' . $ this ->app ->input ->server ->getString ('HTTP_CONTENT_TYPE ' ));
162+ throw new \Exception ('Unsupported content type: ' . $ this ->getApplication () ->input ->server ->getString ('HTTP_CONTENT_TYPE ' ));
171163 }
172164
173165 $ this ->payload = json_decode ($ json );
@@ -183,7 +175,7 @@ protected function setPayload()
183175 */
184176 protected function handleGitHubEvent ()
185177 {
186- $ githubEvent = $ this ->app ->input ->server ->get ('HTTP_X_GITHUB_EVENT ' );
178+ $ githubEvent = $ this ->getApplication () ->input ->server ->get ('HTTP_X_GITHUB_EVENT ' );
187179
188180 switch (strtolower ($ githubEvent ))
189181 {
@@ -205,7 +197,7 @@ protected function handleGitHubEvent()
205197 default :
206198 header ('HTTP/1.0 404 Not Found ' );
207199 echo 'Event: ' . $ githubEvent . ' Payload: \n ' . $ this ->payload ;
208- $ this ->app ->close ();
200+ $ this ->getApplication () ->close ();
209201 }
210202 }
211203
@@ -270,7 +262,7 @@ protected function runGitPull($payload)
270262 $ commitsHtml .= '</ul> ' ;
271263
272264 // Do we have a targetSite parameter
273- $ targetSite = $ this ->app ->input ->getCmd ('targetSite ' , false );
265+ $ targetSite = $ this ->getApplication () ->input ->getCmd ('targetSite ' , false );
274266
275267 $ messageData ['pusherName ' ] = $ payload ->pusher ->name ;
276268 $ messageData ['repoUrl ' ] = $ payload ->repository ->url ;
0 commit comments