Overview

Namespaces

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

Classes

  • Backup
  • Call
  • Composer
  • Copy
  • Environment
  • ExternalProperty
  • FillTemplate
  • HTTP
  • Link
  • MkDir
  • Project
  • Property
  • Rename
  • Sync
  • Target
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: namespace Himedia\Padocc\Task\Base;
 4: 
 5: use Himedia\Padocc\AttributeProperties;
 6: use Himedia\Padocc\Task;
 7: 
 8: /**
 9:  * Définit une propriété externe qu'il sera obligatoire de fournir lors de tout déploiement.
10:  * Cette propriété est par la suite réutilisable dans les attributs possédant le flag ALLOW_PARAMETER.
11:  * À inclure dans une tâche env ou target.
12:  *
13:  * Exemple : <externalproperty name="ref" description="Branch or tag to deploy" />
14:  *
15:  * @author Geoffroy AUBRY <gaubry@hi-media.com>
16:  */
17: class ExternalProperty extends Task
18: {
19:     /**
20:      * Préfixe de propriété externe, c.-à-d. fournie par l'utilisateur.
21:      * @var string
22:      * @see centralExecute()
23:      */
24:     const EXTERNAL_PROPERTY_PREFIX = 'external_property_';
25: 
26:     /**
27:      * {@inheritdoc}
28:      */
29:     protected function init()
30:     {
31:         parent::init();
32: 
33:         $this->aAttrProperties = array(
34:             'name' => AttributeProperties::REQUIRED,
35:             'description' => AttributeProperties::REQUIRED
36:         );
37:     }
38: 
39:     /**
40:      * {@inheritdoc}
41:      * @codeCoverageIgnore
42:      */
43:     public static function getTagName ()
44:     {
45:         return 'externalproperty';
46:     }
47: 
48:     /**
49:      * Phase de traitements centraux de l'exécution de la tâche.
50:      * Elle devrait systématiquement commencer par "parent::centralExecute();".
51:      * Appelé par execute().
52:      * @see execute()
53:      */
54:     protected function centralExecute ()
55:     {
56:         parent::centralExecute();
57:         $this->getLogger()->info('+++');
58:         try {
59:             $sValue = $this->oProperties->getProperty(self::EXTERNAL_PROPERTY_PREFIX . $this->aAttValues['name']);
60:         } catch (\UnexpectedValueException $oException) {
61:             $sMsg = "Property '" . $this->aAttValues['name'] . "' undefined!";
62:             throw new \UnexpectedValueException($sMsg, 1, $oException);
63:         }
64:         $sMsg = "Set external property '" . $this->aAttValues['name'] . "' (description: '"
65:               . $this->aAttValues['description'] . "') to '$sValue'.";
66:         $this->getLogger()->info($sMsg);
67:         $this->oProperties->setProperty($this->aAttValues['name'], $sValue);
68:         $this->getLogger()->info('---');
69:     }
70: }
71: 
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0