Skip to content
Snippets Groups Projects
Commit 4698017e authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #42624 implement ask git pull button

parent 530c7b07
Branches
Tags
3 merge requests!1659Master,!1639Dev#42624 skin update button,!1638Dev#42624 skin update button
......@@ -127,7 +127,11 @@ class Admin_IndexController extends ZendAfi_Controller_Action {
protected function _addGitPull($skins) {
$this->_helper->notify($this->_('La demande de mise à jour a été envoyée au serveur'));
$message = Class_Profil_SkinUpdateReader::askGitPull($skins)
? $this->_('La demande de mise à jour a été envoyée au serveur')
: $this->_('Erreur : La demande de mise à jour n\'a pas pu être envoyée au serveur');
$this->_helper->notify($message);
$this->_redirect('admin/index/update-skin');
}
......
......@@ -27,6 +27,22 @@ class Class_Profil_SkinUpdateReader {
protected $_folder;
public static function askGitPull($skins) {
$json = [];
foreach($skins as $skin)
$json[$skin->getLabel()] = ['UpdateTime' => 'git pull --rebase'];
$json = json_encode($json);
return static::getFileWriter()->putContents(static::getLogPath(), $json);
}
public static function getLogPath() {
return PATH_TEMP . static::$skins_update_log;
}
public function setFolder($folder) {
$this->_folder = $folder;
return $this;
......@@ -34,17 +50,15 @@ class Class_Profil_SkinUpdateReader {
public function getJson() {
return json_decode($this->getFileWriter()->getContents(PATH_TEMP . static::$skins_update_log), true);
return json_decode($this->getFileWriter()->getContents(static::getLogPath()), true);
}
public function getUpdateTime() {
if(!$this->_folder)
if(!$this->_folder || !($json = $this->getJson()))
return '';
return ($json = $this->getJson())
? $json[$this->_folder]['updateTime']
: '';
return $json[$this->_folder]['UpdateTime'];
}
}
?>
\ No newline at end of file
......@@ -34,7 +34,10 @@ abstract class IndexControllerUpdateSkinTestCase extends Admin_AbstractControlle
$file_writer
->whenCalled('getContents')
->answers(json_encode(['Valence' => ['updateTime' => '25/04/2016 15:01:37']]));
->answers(json_encode(['Valence' => ['UpdateTime' => '25/04/2016 15:01:37']]))
->whenCalled('putContents')
->answers(true);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment