Overview

Namespaces

  • GAubry
    • ErrorHandler
    • Helpers
    • Logger
    • Shell
  • Himedia
    • Padocc
      • DB
      • Minifier
      • Numbering
      • Properties
      • Task
        • Base
        • Extended
  • None
  • Psr
    • Log

Classes

  • B2CSwitchSymlink
  • BuildLanguage
  • CVSExport
  • GitExport
  • Minifier
  • SwitchSymlink
  • TwengaServers
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: namespace Himedia\Padocc\Task\Extended;
 4: 
 5: use Himedia\Padocc\AttributeProperties;
 6: use Himedia\Padocc\Task;
 7: 
 8: /**
 9:  * Génère les fichiers de langue au format [geozoneId].php pour un projet donné.
10:  * À inclure dans une tâche env ou target.
11:  *
12:  * Complètement recodé par rapport à la version précédente : environ 20 fois plus rapide !
13:  *
14:  * Exemples : <buildlanguage project="rts" destdir="${SERVERS}:${BASEDIR}/languages" />
15:  *
16:  * @author Geoffroy AUBRY <gaubry@hi-media.com>
17:  */
18: class BuildLanguage extends Task
19: {
20:     /**
21:      * {@inheritdoc}
22:      */
23:     protected function init()
24:     {
25:         parent::init();
26: 
27:         $this->aAttrProperties = array(
28:             'project' => AttributeProperties::REQUIRED,
29:             'destdir' => AttributeProperties::DIR | AttributeProperties::REQUIRED
30:                 | AttributeProperties::ALLOW_PARAMETER
31:         );
32:     }
33: 
34:     /**
35:      * Retourne le nom du tag XML correspondant à cette tâche dans les config projet.
36:      *
37:      * @return string nom du tag XML correspondant à cette tâche dans les config projet.
38:      * @codeCoverageIgnore
39:      */
40:     public static function getTagName ()
41:     {
42:         return 'buildlanguage';
43:     }
44: 
45:     /**
46:      * Phase de traitements centraux de l'exécution de la tâche.
47:      * Elle devrait systématiquement commencer par "parent::centralExecute();".
48:      * Appelé par execute().
49:      * @see execute()
50:      */
51:     protected function centralExecute ()
52:     {
53:         parent::centralExecute();
54:         $this->getLogger()->info('+++');
55: 
56:         $sLanguagesPath = tempnam(
57:             $this->aConfig['dir']['tmp'],
58:             $this->oProperties->getProperty('execution_id') . '_languages_'
59:         );
60:         $sURL = 'https://xyz/translation_tool/build_language_files.php?project='
61:               . $this->aAttValues['project'];
62:         $this->getLogger()->info('Generate language archive from web service: ' . $sURL);
63:         if (! copy($sURL, $sLanguagesPath)) {
64:             throw new \RuntimeException("Copy of '$sURL' to '$sLanguagesPath' failed!");
65:         }
66: 
67:         // Diffusion de l'archive :
68:         $this->getLogger()->info('Send language archive to all servers+++');
69:         $aDestDirs = $this->processPath($this->aAttValues['destdir']);
70:         foreach ($aDestDirs as $sDestDir) {
71:             $aResult = $this->oShell->copy($sLanguagesPath, $sDestDir);
72:             $sResult = implode("\n", $aResult);
73:             if (trim($sResult) != '') {
74:                 $this->getLogger()->info($sResult);
75:             }
76:         }
77:         $this->getLogger()->info('---');
78: 
79:         // Décompression des archives :
80:         $this->getLogger()->info('Extract language files from archive on each server+++');
81:         $sPatternCmd = 'cd %1$s && tar -xf %1$s/"' . basename($sLanguagesPath)
82:                      . '" && rm -f %1$s/"' . basename($sLanguagesPath) . '"';
83:         foreach ($aDestDirs as $sDestDir) {
84:             $aResult = $this->oShell->execSSH($sPatternCmd, $sDestDir);
85:             $sResult = implode("\n", $aResult);
86:             if (trim($sResult) != '') {
87:                 $this->getLogger()->info($sResult);
88:             }
89:         }
90:         $this->getLogger()->info('---');
91: 
92:         @unlink($sLanguagesPath);
93:         $this->getLogger()->info('---');
94:     }
95: }
96: 
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0