1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Media\Subjects\MediaSubject |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import-product-media |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Media\Subjects; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\RegistryKeys; |
24
|
|
|
use TechDivision\Import\Subjects\FileUploadTrait; |
25
|
|
|
use TechDivision\Import\Subjects\FileUploadSubjectInterface; |
26
|
|
|
use TechDivision\Import\Product\Subjects\AbstractProductSubject; |
27
|
|
|
use TechDivision\Import\Product\Media\Utils\ConfigurationKeys; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The subject implementation for the product media handling. |
31
|
|
|
* |
32
|
|
|
* @author Tim Wagner <[email protected]> |
33
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
34
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
35
|
|
|
* @link https://github.com/techdivision/import-product-media |
36
|
|
|
* @link http://www.techdivision.com |
37
|
|
|
*/ |
38
|
|
|
class MediaSubject extends AbstractProductSubject implements FileUploadSubjectInterface |
39
|
|
|
{ |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* The trait that provides file upload functionality. |
43
|
|
|
* |
44
|
|
|
* @var \TechDivision\Import\Subjects\FileUploadTrait |
45
|
|
|
*/ |
46
|
|
|
use FileUploadTrait; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The trait that provides media import functionality. |
50
|
|
|
* |
51
|
|
|
* @var \TechDivision\Import\Media\Subjects\MediaSubjectTrait |
52
|
|
|
*/ |
53
|
|
|
use MediaSubjectTrait; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Intializes the previously loaded global data for exactly one variants. |
57
|
|
|
* |
58
|
|
|
* @param string $serial The serial of the actual import |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function setUp($serial) |
63
|
|
|
{ |
64
|
|
|
|
65
|
|
|
// invoke parent method |
66
|
|
|
parent::setUp($serial); |
67
|
|
|
|
68
|
|
|
// load the entity manager and the registry processor |
69
|
|
|
$registryProcessor = $this->getRegistryProcessor(); |
70
|
|
|
|
71
|
|
|
// load the status of the actual import process |
72
|
|
|
$status = $registryProcessor->getAttribute(RegistryKeys::STATUS); |
73
|
|
|
|
74
|
|
|
// load the SKU => entity ID mapping |
75
|
|
|
$this->skuEntityIdMapping = $status[RegistryKeys::SKU_ENTITY_ID_MAPPING]; |
76
|
|
|
|
77
|
|
|
// initialize media directory => can be absolute or relative |
78
|
|
|
if ($this->getConfiguration()->hasParam(ConfigurationKeys::MEDIA_DIRECTORY)) { |
79
|
|
|
$this->setMediaDir( |
80
|
|
|
$this->resolvePath( |
81
|
|
|
$this->getConfiguration()->getParam(ConfigurationKeys::MEDIA_DIRECTORY) |
82
|
|
|
) |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
// initialize images directory => can be absolute or relative |
87
|
|
|
if ($this->getConfiguration()->hasParam(ConfigurationKeys::IMAGES_FILE_DIRECTORY)) { |
88
|
|
|
$this->setImagesFileDir( |
89
|
|
|
$this->resolvePath( |
90
|
|
|
$this->getConfiguration()->getParam(ConfigurationKeys::IMAGES_FILE_DIRECTORY) |
91
|
|
|
) |
92
|
|
|
); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|