1: <?php
2:
3: namespace Himedia\Padocc\Task\Base;
4:
5: use GAubry\Shell\PathStatus;
6: use Himedia\Padocc\AttributeProperties;
7: use Himedia\Padocc\Task;
8:
9: 10: 11: 12: 13: 14: 15: 16:
17: class Copy extends Task
18: {
19: 20: 21:
22: protected function init()
23: {
24: parent::init();
25:
26: $this->aAttrProperties = array(
27: 'src' => AttributeProperties::SRC_PATH | AttributeProperties::FILEJOKER | AttributeProperties::REQUIRED,
28: 'destdir' => AttributeProperties::DIR | AttributeProperties::REQUIRED
29: );
30: }
31:
32: 33: 34: 35:
36: public static function getTagName ()
37: {
38: return 'copy';
39: }
40:
41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51:
52: public function check ()
53: {
54:
55:
56: parent::check();
57:
58:
59: $this->aAttValues['src'] = preg_replace('#/$#', '', $this->aAttValues['src']);
60:
61: if (preg_match('/\*|\?/', $this->aAttValues['src']) === 0
62: && $this->oShell->getPathStatus($this->aAttValues['src']) === PathStatus::STATUS_DIR
63: ) {
64: $this->aAttValues['destdir'] .= '/' . substr(strrchr($this->aAttValues['src'], '/'), 1);
65: $this->aAttValues['src'] .= '/*';
66: }
67: }
68:
69: 70: 71: 72: 73: 74:
75: protected function centralExecute ()
76: {
77: parent::centralExecute();
78: $this->getLogger()->info('+++');
79:
80: $aSrcPath = $this->processSimplePath($this->aAttValues['src']);
81: $aDestDirs = $this->processPath($this->aAttValues['destdir']);
82: foreach ($aDestDirs as $sDestDir) {
83: $this->oShell->copy($aSrcPath, $sDestDir);
84: }
85:
86: $this->getLogger()->info('---');
87: }
88: }
89: