public function gitDeployProject($git_branch, $extends = null)
 {
     $config = Config::get('github');
     $config['branch'] = $git_branch;
     $config['post_data'] = Input::get('payload');
     if ($config['active'] === FALSE) {
         App::abort(403, 'Модуль отключен');
     }
     if ($config['test_mode_key'] == $extends) {
         $config['test_mode'] = TRUE;
     } else {
         $config['test_mode'] = FALSE;
     }
     $github = new GitHub();
     $github->init($config);
     if ($extends == 'test') {
         echo $github->testConnect('/usr/bin/ssh -T git@github.com');
     } else {
         echo $github->execute('git reset --hard HEAD');
         echo "\n";
         echo $github->pull();
         echo "\n";
         echo $github->setAccessMode();
         echo "\n";
         foreach ($config['directories'] as $directory) {
             echo $github->setAccessMode($directory, '0777');
         }
     }
 }
 public function postSave($mod_name)
 {
     #Helper::dd(Input::all());
     $json_request = array('status' => FALSE, 'responseText' => '');
     $file = Input::get('file');
     $tpl = Input::get('tpl');
     if ($tpl === '') {
         return Response::json($json_request, 200);
     }
     if ($mod_name == 'layout') {
         $full_file = app_path('views/templates/' . Config::get('app.template') . '/' . $file . '.blade.php');
     } else {
         $full_file = app_path('modules/' . $mod_name . '/views/' . $file . '.blade.php');
     }
     $result = @file_put_contents($full_file, $tpl);
     /**
      * Send changes to GitHub
      */
     $config = Config::get('github');
     if ($config['active'] != FALSE && Input::get('git') && class_exists('GitHub')) {
         #if($config['test_mode_key'] == $extends):
         $config['test_mode'] = TRUE;
         #else:
         #    $config['test_mode'] = FALSE;
         #endif;
         $config['set_log'] = FALSE;
         $github = new GitHub();
         $github->init($config);
         $result = $github->execute('git add ' . $full_file);
         #echo $result . "\n";
         if ($result == 0) {
             $result = $github->execute('git commit -m "server commit - template editor; module: ' . $mod_name . ', file: ' . $file . '"');
             #echo $result . "\n";
             if ($result == 0) {
                 $result = $github->pull();
                 #echo $result . "\n";
                 $result = $github->push();
                 #echo $result . "\n";
             }
         }
     }
     $json_request['status'] = true;
     return Response::json($json_request, 200);
 }