Skip to content

Commit 990d84d

Browse files
committed
Extend configuration for renaming files functionality
1 parent d7eb09b commit 990d84d

File tree

2 files changed

+113
-10
lines changed

2 files changed

+113
-10
lines changed

src/ConfigurationInterface.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,42 @@ public function getSubjects(array $filters = array());
428428
*/
429429
public function getMoveFilesPrefix();
430430

431+
/**
432+
* Set's the first subject of the actual import with a prefix defined.
433+
*
434+
* @param \TechDivision\Import\Configuration\SubjectConfigurationInterface $firstPrefixedSubject The subject configuration
435+
*
436+
* @return void
437+
*/
438+
public function setFirstPrefixedSubject(SubjectConfigurationInterface $firstPrefixedSubject);
439+
440+
/**
441+
* Return's the first subject of the actual import with a prefix defined.
442+
*
443+
* @return \TechDivision\Import\Configuration\SubjectConfigurationInterface|null The subject configuration
444+
*/
445+
public function getFirstPrefixedSubject();
446+
431447
/**
432448
* Get the definition from an empty value
433449
*
434450
* @return string A string with constant for empty attribute value
435451
*/
436452
public function getEmptyAttributeValueConstant();
453+
454+
/**
455+
* Sets the explict name of a file that has to be imported.
456+
*
457+
* @param string $filename The explicit filename
458+
*
459+
* @return void
460+
*/
461+
public function setFilename($filename);
462+
463+
/**
464+
* Load the explicit name of the file that has to be imported.
465+
*
466+
* @return string The explicit filename
467+
*/
468+
public function getFilename();
437469
}

src/Subject/FileResolverConfigurationInterface.php

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* PHP version 7
77
*
88
* @author Tim Wagner <[email protected]>
9-
* @copyright 2020 TechDivision GmbH <[email protected]>
9+
* @copyright 2021 TechDivision GmbH <[email protected]>
1010
* @license https://opensource.org/licenses/MIT
1111
* @link https://github.com/techdivision/import-configuration
1212
* @link http://www.techdivision.com
@@ -18,27 +18,69 @@
1818
* The interface for a file resolver's configuration.
1919
*
2020
* @author Tim Wagner <[email protected]>
21-
* @copyright 2020 TechDivision GmbH <[email protected]>
21+
* @copyright 2021 TechDivision GmbH <[email protected]>
2222
* @license https://opensource.org/licenses/MIT
2323
* @link https://github.com/techdivision/import-configuration
2424
* @link http://www.techdivision.com
2525
*/
2626
interface FileResolverConfigurationInterface
2727
{
2828

29+
/**
30+
* The default prefix sequence of the import files.
31+
*
32+
* @var string
33+
*/
34+
const DEFAULT_PREFIX = '.*';
35+
36+
/**
37+
* The default filename sequence of the import files.
38+
*
39+
* @var string
40+
*/
41+
const DEFAULT_FILENAME = '.*';
42+
43+
/**
44+
* The counter sequence of the import files.
45+
*
46+
* @var string
47+
*/
48+
const DEFAULT_COUNTER = '\d+';
49+
50+
/**
51+
* The file suffix for import files.
52+
*
53+
* @var string
54+
*/
55+
const DEFAULT_SUFFIX = 'csv';
56+
57+
/**
58+
* The file suffix for OK file.
59+
*
60+
* @var string
61+
*/
62+
const DEFAULT_OK_FILE_SUFFIX = 'ok';
63+
64+
/**
65+
* The separator char for the elements of the file.
66+
*
67+
* @var string
68+
*/
69+
const DEFAULT_ELEMENT_SEPARATOR = '_';
70+
2971
/**
3072
* Returns the file resolver's unique DI identifier.
3173
*
3274
* @return string The file resolver's unique DI identifier
3375
*/
34-
public function getId();
76+
public function getId() : string;
3577

3678
/**
3779
* Returns the prefix/meta sequence for the import files.
3880
*
3981
* @return string The prefix
4082
*/
41-
public function getPrefix();
83+
public function getPrefix() : string;
4284

4385
/**
4486
* Query's whether or not a custom prefix has been configured for the
@@ -48,14 +90,24 @@ public function getPrefix();
4890
*
4991
* @return boolean TRUE if the file resolver has a custom prefix, else FALSE
5092
*/
51-
public function hasPrefix($defaultPrefix = '.*');
93+
public function hasPrefix($defaultPrefix = FileResolverConfigurationInterface::DEFAULT_PREFIX) : bool;
5294

5395
/**
5496
* Returns the filename/meta sequence of the import files.
5597
*
5698
* @return string The suffix
5799
*/
58-
public function getFilename();
100+
public function getFilename() : string;
101+
102+
/**
103+
* Query's whether or not a custom filename has been configured for the
104+
* file resolver.
105+
*
106+
* @param string $defaultFilename The default filename to match against
107+
*
108+
* @return boolean TRUE if the file resolver has a custom filename, else FALSE
109+
*/
110+
public function hasFilename($defaultFilename = FileResolverConfigurationInterface::DEFAULT_FILENAME);
59111

60112
/**
61113
* Returns the counter/meta sequence of the import files.
@@ -64,31 +116,50 @@ public function getFilename();
64116
*/
65117
public function getCounter();
66118

119+
/**
120+
* Query's whether or not a custom counter has been configured for the
121+
* file resolver.
122+
*
123+
* @param string $defaultCounter The default counter to match against
124+
*
125+
* @return boolean TRUE if the file resolver has a custom counter, else FALSE
126+
*/
127+
public function hasCounter($defaultCounter = FileResolverConfigurationInterface::DEFAULT_COUNTER);
128+
67129
/**
68130
* Returns the suffix for the import files.
69131
*
70132
* @return string The suffix
71133
*/
72-
public function getSuffix();
134+
public function getSuffix() : string;
73135

74136
/**
75137
* Return's the suffix for the OK file.
76138
*
77139
* @return string The OK file suffix
78140
*/
79-
public function getOkFileSuffix();
141+
public function getOkFileSuffix() : string;
80142

81143
/**
82144
* Returns the delement separator char.
83145
*
84146
* @return string The element separator char
85147
*/
86-
public function getElementSeparator();
148+
public function getElementSeparator() : string;
87149

88150
/**
89151
* Returns the elements the filenames consists of.
90152
*
91153
* @return array The array with the filename elements
92154
*/
93-
public function getPatternElements();
155+
public function getPatternElements() : array;
156+
157+
/**
158+
* Set's the the elements the filenames consists of.
159+
*
160+
* @param array $patternElements The array with the filename elements
161+
*
162+
* @return void
163+
*/
164+
public function setPatternElements(array $patternElements) : void;
94165
}

0 commit comments

Comments
 (0)