| Línea 1... |
Línea 1... |
| 1 |
<?php
|
1 |
<?php
|
| 2 |
|
- |
|
| 3 |
declare(strict_types=1);
|
2 |
declare(strict_types = 1);
|
| 4 |
|
- |
|
| 5 |
namespace LeadersLinked\Command;
|
3 |
namespace LeadersLinked\Command;
|
| Línea 6... |
Línea 4... |
| 6 |
|
4 |
|
| 7 |
use Symfony\Component\Console\Command\Command;
|
5 |
use Symfony\Component\Console\Command\Command;
|
| 8 |
use Symfony\Component\Console\Input\InputInterface;
|
6 |
use Symfony\Component\Console\Input\InputInterface;
|
| 9 |
use Symfony\Component\Console\Output\OutputInterface;
|
7 |
use Symfony\Component\Console\Output\OutputInterface;
|
| 10 |
use Laminas\Db\Adapter\AdapterInterface;
|
- |
|
| 11 |
|
8 |
use Laminas\Db\Adapter\AdapterInterface;
|
| 12 |
use Laminas\Log\LoggerInterface;
|
9 |
use Laminas\Log\LoggerInterface;
|
| 13 |
use LeadersLinked\Mapper\UserMapper;
|
10 |
use LeadersLinked\Mapper\UserMapper;
|
| 14 |
use LeadersLinked\Mapper\CompanyMapper;
|
11 |
use LeadersLinked\Mapper\CompanyMapper;
|
| 15 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
12 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
| 16 |
use LeadersLinked\Model\User;
|
13 |
use LeadersLinked\Model\User;
|
| 17 |
use LeadersLinked\Model\UserType;
|
14 |
use LeadersLinked\Model\UserType;
|
| 18 |
use LeadersLinked\Model\CompanyUser;
|
15 |
use LeadersLinked\Model\CompanyUser;
|
| 19 |
use Laminas\Mvc\I18n\Translator;
|
16 |
use Laminas\Mvc\I18n\Translator;
|
| 20 |
use LeadersLinked\Cache\CacheInterface;
|
- |
|
| 21 |
|
17 |
use LeadersLinked\Cache\CacheInterface;
|
| 22 |
use LeadersLinked\Mapper\FeedMapper;
|
18 |
use LeadersLinked\Mapper\FeedMapper;
|
| Línea 23... |
Línea 19... |
| 23 |
use LeadersLinked\Library\Storage;
|
19 |
use LeadersLinked\Library\Storage;
|
| 24 |
|
20 |
|
| - |
|
21 |
class SendDataToS3Command extends Command
|
| 25 |
class SendDataToS3Command extends Command
|
22 |
{
|
| 26 |
{
|
23 |
|
| 27 |
/**
|
24 |
/**
|
| 28 |
*
|
25 |
*
|
| 29 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
26 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
| 30 |
*/
|
27 |
*/
|
| 31 |
private $adapter;
|
28 |
private $adapter;
|
| 32 |
|
29 |
|
| 33 |
/**
|
30 |
/**
|
| 34 |
*
|
31 |
*
|
| 35 |
* @var \LeadersLinked\Cache\CacheInterface
|
32 |
* @var \LeadersLinked\Cache\CacheInterface
|
| Línea 36... |
Línea -... |
| 36 |
*/
|
- |
|
| 37 |
private $cache;
|
33 |
*/
|
| 38 |
|
34 |
private $cache;
|
| 39 |
|
35 |
|
| 40 |
/**
|
36 |
/**
|
| 41 |
*
|
37 |
*
|
| Línea 46... |
Línea 42... |
| 46 |
/**
|
42 |
/**
|
| 47 |
*
|
43 |
*
|
| 48 |
* @var array
|
44 |
* @var array
|
| 49 |
*/
|
45 |
*/
|
| 50 |
private $config;
|
46 |
private $config;
|
| 51 |
|
- |
|
| 52 |
|
47 |
|
| 53 |
/**
|
48 |
/**
|
| 54 |
*
|
49 |
*
|
| 55 |
* @var \Laminas\Mvc\I18n\Translator
|
50 |
* @var \Laminas\Mvc\I18n\Translator
|
| 56 |
*/
|
51 |
*/
|
| 57 |
private $translator;
|
52 |
private $translator;
|
| 58 |
|
- |
|
| 59 |
|
53 |
|
| 60 |
/**
|
54 |
/**
|
| 61 |
*
|
55 |
*
|
| 62 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
56 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
| 63 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
57 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
| - |
|
58 |
* @param
|
| 64 |
* @param \Laminas\Log\LoggerInterface
|
59 |
* \Laminas\Log\LoggerInterface
|
| 65 |
* @param array $config
|
60 |
* @param array $config
|
| 66 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
61 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
| 67 |
*/
|
62 |
*/
|
| 68 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
63 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
| 69 |
{
|
64 |
{
|
| 70 |
$this->adapter = $adapter;
|
65 |
$this->adapter = $adapter;
|
| 71 |
$this->cache = $cache;
|
66 |
$this->cache = $cache;
|
| 72 |
$this->logger = $logger;
|
67 |
$this->logger = $logger;
|
| 73 |
$this->config = $config;
|
68 |
$this->config = $config;
|
| 74 |
$this->translator = $translator;
|
69 |
$this->translator = $translator;
|
| 75 |
|
70 |
|
| 76 |
parent::__construct();
|
71 |
parent::__construct();
|
| 77 |
}
|
72 |
}
|
| Línea 78... |
Línea 73... |
| 78 |
|
73 |
|
| - |
|
74 |
private function getDirContents($dir, &$results = array())
|
| 79 |
private function getDirContents($dir, &$results = array()) {
|
75 |
{
|
| 80 |
$files = scandir($dir);
|
76 |
$files = scandir($dir);
|
| 81 |
|
77 |
|
| 82 |
foreach ($files as $key => $value) {
|
78 |
foreach ($files as $key => $value) {
|
| 83 |
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
79 |
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
| 84 |
if (!is_dir($path)) {
|
80 |
if (! is_dir($path)) {
|
| 85 |
$results[] = $path;
|
81 |
$results[] = $path;
|
| 86 |
} else if ($value != "." && $value != "..") {
|
82 |
} else if ($value != "." && $value != "..") {
|
| 87 |
$this->getDirContents($path, $results);
|
83 |
$this->getDirContents($path, $results);
|
| 88 |
$results[] = $path;
|
84 |
$results[] = $path;
|
| 89 |
}
|
85 |
}
|
| 90 |
}
|
86 |
}
|
| 91 |
|
87 |
|
| 92 |
return $results;
|
88 |
return $results;
|
| 93 |
}
|
89 |
}
|
| 94 |
|
90 |
|
| 95 |
protected function execute(InputInterface $input, OutputInterface $output) : int
|
91 |
protected function execute(InputInterface $input, OutputInterface $output): int
|
| 96 |
{
|
92 |
{
|
| 97 |
$output->writeln('Inicializando el S3');
|
93 |
$output->writeln('Inicializando el S3');
|
| 98 |
|
94 |
|
| 99 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
95 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
| 100 |
|
96 |
|
| 101 |
$paths = [
|
97 |
$paths = [
|
| 102 |
$this->config['leaderslinked.fullpath.chat'] => $this->config['leaderslinked.storage.fullpath_chat'],
|
98 |
$this->config['leaderslinked.fullpath.chat'] => $this->config['leaderslinked.storage.fullpath_chat'],
|
| 103 |
$this->config['leaderslinked.fullpath.group'] => $this->config['leaderslinked.storage.fullpath_group'],
|
99 |
$this->config['leaderslinked.fullpath.group'] => $this->config['leaderslinked.storage.fullpath_group'],
|
| 104 |
$this->config['leaderslinked.fullpath.user'] => $this->config['leaderslinked.storage.fullpath_user'],
|
100 |
$this->config['leaderslinked.fullpath.user'] => $this->config['leaderslinked.storage.fullpath_user'],
|
| 105 |
$this->config['leaderslinked.fullpath.image'] => $this->config['leaderslinked.storage.fullpath_image'],
|
101 |
$this->config['leaderslinked.fullpath.image'] => $this->config['leaderslinked.storage.fullpath_image'],
|
| 106 |
$this->config['leaderslinked.fullpath.job'] => $this->config['leaderslinked.storage.fullpath_job'],
|
102 |
$this->config['leaderslinked.fullpath.job'] => $this->config['leaderslinked.storage.fullpath_job'],
|
| 107 |
$this->config['leaderslinked.fullpath.company'] => $this->config['leaderslinked.storage.fullpath_company'],
|
103 |
$this->config['leaderslinked.fullpath.company'] => $this->config['leaderslinked.storage.fullpath_company'],
|
| 108 |
$this->config['leaderslinked.fullpath.feed'] => $this->config['leaderslinked.storage.fullpath_feed'],
|
104 |
$this->config['leaderslinked.fullpath.feed'] => $this->config['leaderslinked.storage.fullpath_feed'],
|
| 109 |
$this->config['leaderslinked.fullpath.post'] => $this->config['leaderslinked.storage.fullpath_post'],
|
105 |
$this->config['leaderslinked.fullpath.post'] => $this->config['leaderslinked.storage.fullpath_post'],
|
| 110 |
$this->config['leaderslinked.fullpath.microlearning_topic'] => $this->config['leaderslinked.storage.fullpath_microlearning_topic'],
|
106 |
$this->config['leaderslinked.fullpath.microlearning_topic'] => $this->config['leaderslinked.storage.fullpath_microlearning_topic'],
|
| 111 |
$this->config['leaderslinked.fullpath.microlearning_capsule'] => $this->config['leaderslinked.storage.fullpath_microlearning_capsule'],
|
107 |
$this->config['leaderslinked.fullpath.microlearning_capsule'] => $this->config['leaderslinked.storage.fullpath_microlearning_capsule'],
|
| 112 |
$this->config['leaderslinked.fullpath.microlearning_slide'] => $this->config['leaderslinked.storage.fullpath_microlearning_slide'],
|
108 |
$this->config['leaderslinked.fullpath.microlearning_slide'] => $this->config['leaderslinked.storage.fullpath_microlearning_slide'],
|
| 113 |
$this->config['leaderslinked.fullpath.job_description'] => $this->config['leaderslinked.storage.fullpath_job_description'],
|
109 |
$this->config['leaderslinked.fullpath.job_description'] => $this->config['leaderslinked.storage.fullpath_job_description'],
|
| 114 |
$this->config['leaderslinked.fullpath.self_evaluation'] => $this->config['leaderslinked.storage.fullpath_self_evaluation'],
|
110 |
$this->config['leaderslinked.fullpath.self_evaluation'] => $this->config['leaderslinked.storage.fullpath_self_evaluation'],
|
| 115 |
$this->config['leaderslinked.fullpath.performance_evaluation'] => $this->config['leaderslinked.storage.fullpath_performance_evaluation'],
|
111 |
$this->config['leaderslinked.fullpath.performance_evaluation'] => $this->config['leaderslinked.storage.fullpath_performance_evaluation'],
|
| 116 |
$this->config['leaderslinked.fullpath.recruitment_selection'] => $this->config['leaderslinked.storage.fullpath_recruitment_selection'],
|
112 |
$this->config['leaderslinked.fullpath.recruitment_selection'] => $this->config['leaderslinked.storage.fullpath_recruitment_selection'],
|
| 117 |
$this->config['leaderslinked.fullpath.planning_objectives_and_goals'] => $this->config['leaderslinked.storage.fullpath_planning_objectives_and_goals'],
|
113 |
$this->config['leaderslinked.fullpath.planning_objectives_and_goals'] => $this->config['leaderslinked.storage.fullpath_planning_objectives_and_goals'],
|
| 118 |
$this->config['leaderslinked.fullpath.message'] => $this->config['leaderslinked.storage.fullpath_message'],
|
114 |
$this->config['leaderslinked.fullpath.message'] => $this->config['leaderslinked.storage.fullpath_message'],
|
| 119 |
$this->config['leaderslinked.fullpath.survey'] => $this->config['leaderslinked.storage.fullpath_survey'],
|
115 |
$this->config['leaderslinked.fullpath.survey'] => $this->config['leaderslinked.storage.fullpath_survey'],
|
| 120 |
$this->config['leaderslinked.fullpath.network'] => $this->config['leaderslinked.storage.fullpath_network'],
|
116 |
$this->config['leaderslinked.fullpath.network'] => $this->config['leaderslinked.storage.fullpath_network'],
|
| 121 |
$this->config['leaderslinked.fullpath.daily_pulse'] => $this->config['leaderslinked.storage.fullpath_daily_pulse'],
|
117 |
$this->config['leaderslinked.fullpath.daily_pulse'] => $this->config['leaderslinked.storage.fullpath_daily_pulse'],
|
| 122 |
$this->config['leaderslinked.fullpath.engagement_reward'] => $this->config['leaderslinked.storage.fullpath_engagement_reward'],
|
118 |
$this->config['leaderslinked.fullpath.engagement_reward'] => $this->config['leaderslinked.storage.fullpath_engagement_reward'],
|
| 123 |
$this->config['leaderslinked.fullpath.knowledge_area'] => $this->config['leaderslinked.storage.fullpath_knowledge_area'],
|
119 |
$this->config['leaderslinked.fullpath.knowledge_area'] => $this->config['leaderslinked.storage.fullpath_knowledge_area'],
|
| 124 |
$this->config['leaderslinked.fullpath.my_coach'] => $this->config['leaderslinked.storage.fullpath_my_coach'],
|
120 |
$this->config['leaderslinked.fullpath.my_coach'] => $this->config['leaderslinked.storage.fullpath_my_coach']
|
| 125 |
];
|
- |
|
| 126 |
|
- |
|
| Línea 127... |
Línea -... |
| 127 |
|
- |
|
| 128 |
|
- |
|
| 129 |
|
- |
|
| 130 |
|
121 |
];
|
| Línea 131... |
Línea -... |
| 131 |
|
- |
|
| 132 |
$output->writeln('Leyendo el directorio de storage ');
|
- |
|
| 133 |
|
122 |
|
| 134 |
|
123 |
$output->writeln('Leyendo el directorio de storage ');
|
| 135 |
|
124 |
|
| 136 |
$directory = 'data/storage';
|
- |
|
| 137 |
$records = $this->getDirContents($directory);
|
- |
|
| 138 |
foreach($records as $filepath)
|
- |
|
| 139 |
{
|
125 |
$directory = 'data/storage';
|
| 140 |
|
126 |
$records = $this->getDirContents($directory);
|
| 141 |
|
127 |
foreach ($records as $filepath) {
|
| 142 |
|
128 |
|
| 143 |
if(!file_exists($filepath)) {
|
129 |
if (! file_exists($filepath)) {
|
| 144 |
continue;
|
130 |
continue;
|
| 145 |
}
|
131 |
}
|
| 146 |
|
132 |
|
| 147 |
if(is_dir($filepath) || !is_readable($filepath)) {
|
- |
|
| 148 |
continue;
|
133 |
if (is_dir($filepath) || ! is_readable($filepath)) {
|
| 149 |
}
|
134 |
continue;
|
| 150 |
|
135 |
}
|
| 151 |
|
136 |
|
| 152 |
$s = explode('data/storage', $filepath);
|
137 |
$s = explode('data/storage', $filepath);
|
| 153 |
|
138 |
|
| 154 |
$s3Filename = basename($filepath);
|
139 |
$s3Filename = basename($filepath);
|
| 155 |
$s3Filepath = $s[1];
|
140 |
$s3Filepath = $s[1];
|
| 156 |
$s3Filepath = trim(str_replace('/' . $s3Filename, '', $s3Filepath));
|
- |
|
| 157 |
|
141 |
$s3Filepath = trim(str_replace('/' . $s3Filename, '', $s3Filepath));
|
| 158 |
foreach($paths as $key => $value)
|
142 |
|
| 159 |
{
|
143 |
foreach ($paths as $key => $value) {
|
| 160 |
$key = str_replace('data/storage', '', $key);
|
- |
|
| 161 |
$s3Filepath = str_replace($key, $value . '/', $s3Filepath );
|
144 |
$key = str_replace('data/storage', '', $key);
|
| 162 |
}
|
145 |
$s3Filepath = str_replace($key, $value . '/', $s3Filepath);
|
| 163 |
|
146 |
}
|
| 164 |
|
147 |
|
| 165 |
if(empty($s3Filepath)) {
|
148 |
if (empty($s3Filepath)) {
|
| 166 |
$filename = $s3Filename;
|
149 |
$filename = $s3Filename;
|
| 167 |
} else {
|
- |
|
| 168 |
$filename = $s3Filepath . '/' . $s3Filename;
|
150 |
} else {
|
| 169 |
}
|
151 |
$filename = $s3Filepath . '/' . $s3Filename;
|
| 170 |
|
152 |
}
|
| 171 |
|
153 |
|
| 172 |
echo 'filename = ' . $filename . "\r\n";
|
- |
|
| 173 |
echo 'filepath = ' . $filepath . "\r\n";
|
154 |
echo 'filename = ' . $filename . "\r\n";
|
| 174 |
exit;
|
155 |
echo 'filepath = ' . $filepath . "\r\n";
|
| 175 |
|
156 |
exit();
|
| 176 |
|
157 |
|
| 177 |
$output->writeln('Comprobando el archivo : ' . $filename);
|
158 |
$output->writeln('Comprobando el archivo : ' . $filename);
|
| 178 |
|
159 |
|
| 179 |
if($storage->objectExist($filename)) {
|
160 |
if ($storage->objectExist($filename)) {
|
| 180 |
$output->writeln('Existe el archivo en el S3 : ' . $filename);
|
161 |
$output->writeln('Existe el archivo en el S3 : ' . $filename);
|
| 181 |
} else {
|
162 |
} else {
|
| 182 |
|
163 |
|
| 183 |
$output->writeln('Grabando el archivo : ' . $filename);
|
- |
|
| 184 |
$storage->putObject($filename, $filepath);
|
- |
|
| 185 |
}
|
164 |
$output->writeln('Grabando el archivo : ' . $filename);
|
| 186 |
|
- |
|
| Línea 187... |
Línea 165... |
| 187 |
|
165 |
$storage->putObject($filename, $filepath);
|
| 188 |
}
|
166 |
}
|
| 189 |
|
167 |
}
|
| 190 |
|
168 |
|
| 191 |
$output->writeln('Fin del proceso');
|
- |
|
| 192 |
|
- |
|
| 193 |
return 0;
|
- |
|
| 194 |
}
|
169 |
$output->writeln('Fin del proceso');
|
| 195 |
|
170 |
|