1: <?php
2:
3: namespace Himedia\Padocc\Task\Extended;
4:
5: use Himedia\Padocc\AttributeProperties;
6: use Himedia\Padocc\Task;
7:
8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
29: class CVSExport extends Task
30: {
31: 32: 33: 34:
35: private $oSyncTask;
36:
37: 38: 39:
40: protected function init()
41: {
42: parent::init();
43:
44: $this->aAttrProperties = array(
45: 'repository' => AttributeProperties::FILE | AttributeProperties::REQUIRED,
46: 'module' => AttributeProperties::DIR | AttributeProperties::REQUIRED,
47: 'srcdir' => AttributeProperties::DIR,
48: 'destdir' => AttributeProperties::DIR | AttributeProperties::REQUIRED
49: | AttributeProperties::ALLOW_PARAMETER
50: );
51:
52: if (empty($this->aAttValues['srcdir'])) {
53: $this->aAttValues['srcdir'] =
54: $this->aConfig['dir']['repositories'] . '/cvs/'
55: . $this->oProperties->getProperty('project_name') . '_'
56: . $this->oProperties->getProperty('environment_name') . '_'
57: . $this->sCounter;
58: } else {
59: $this->aAttValues['srcdir'] =
60: preg_replace('#/$#', '', $this->aAttValues['srcdir']);
61: }
62:
63:
64: $this->oNumbering->addCounterDivision();
65: $this->oSyncTask = Task\Base\Sync::getNewInstance(
66: array(
67: 'src' => $this->aAttValues['srcdir'] . '/' . $this->aAttValues['module'] . '/',
68: 'destdir' => $this->aAttValues['destdir']
69: ),
70: $this->oProject,
71: $this->oDIContainer
72: );
73: $this->oNumbering->removeCounterDivision();
74: }
75:
76: 77: 78: 79:
80: public static function getTagName ()
81: {
82: return 'cvsexport';
83: }
84:
85: 86: 87:
88: public function setUp ()
89: {
90: parent::setUp();
91: $this->getLogger()->info('+++');
92: try {
93: $this->oSyncTask->setUp();
94: } catch (\UnexpectedValueException $oException) {
95: if ($oException->getMessage() !== "File or directory '" . $this->aAttValues['srcdir']
96: . '/' . $this->aAttValues['module'] . '/' . "' not found!") {
97: throw $oException;
98: }
99: }
100:
101: $this->getLogger()->info('---');
102: }
103:
104: 105: 106: 107: 108: 109:
110: protected function centralExecute ()
111: {
112: parent::centralExecute();
113: $this->getLogger()->info('+++');
114:
115: $this->getLogger()->info("Export from '" . $this->aAttValues['repository'] . "' CVS repository+++");
116: $aResult = $this->oShell->exec(
117: $this->aConfig['bash_path'] . ' ' . $this->aConfig['dir']['inc'] . '/cvsexport.sh'
118: . ' "' . $this->aAttValues['repository'] . '"'
119: . ' "' . $this->aAttValues['module'] . '"'
120: . ' "' . $this->aAttValues['srcdir'] . '"'
121: );
122: $this->getLogger()->info(implode("\n", $aResult) . '---');
123:
124: $this->oSyncTask->execute();
125: $this->getLogger()->info('---');
126: }
127: }
128: