diff --git a/Dockerfile b/Dockerfile
index 9d557f1..cd78aa7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -26,4 +26,4 @@ RUN composer install $COMPOSER_FLAGS --no-scripts --no-autoloader
COPY . .
RUN composer install $COMPOSER_FLAGS
-CMD composer ci
+CMD php ./example/run.php
diff --git a/README.md b/README.md
index 1127416..976ec29 100644
--- a/README.md
+++ b/README.md
@@ -21,8 +21,8 @@ class Component extends \Keboola\Component\BaseComponent
// get parameters
$parameters = $this->getConfig()->getParameters();
- // get value of customKey.customSubkey parameter and fail if missing
- $customParameter = $this->getConfig()->getValue(['parameters', 'customKey', 'customSubkey']);
+ // get value of customKey.customSubKey parameter and fail if missing
+ $customParameter = $this->getConfig()->getValue(['parameters', 'customKey', 'customSubKey']);
// get value with default value if not present
$customParameterOrNull = $this->getConfig()->getValue(['parameters', 'customKey'], 'someDefaultValue');
@@ -109,17 +109,17 @@ To implement a sync action
### Custom getters in config
-You might want to add getter methods for custom parameters in the config. That way you don't need to remember exact keys (`parameters.errorCount.maximumAllowed`), but instead use a method to retrieve the value (`$config->getMaximumAllowedErrorCount()`).
+You might want to add getter methods for custom parameters in the config. That way you don't need to remember exact keys (`parameters.customKey.customSubKey`), but instead use a method to retrieve the value (`$config->getCustomSubKey()`).
Simply create your own `Config` class, that extends `BaseConfig` and override `\Keboola\Component\BaseComponent::getConfigClass()` method to return your new class name.
```php
class MyConfig extends \Keboola\Component\Config\BaseConfig
{
- public function getMaximumAllowedErrorCount()
+ public function getCustomSubKey()
{
$defaultValue = 0;
- return $this->getValue(['parameters', 'errorCount', 'maximumAllowed'], $defaultValue);
+ return $this->getValue(['parameters', 'customKey', 'customSubKey'], $defaultValue);
}
}
```
@@ -149,10 +149,10 @@ class MyConfigDefinition extends \Keboola\Component\Config\BaseConfigDefinition
$parametersNode
->isRequired()
->children()
- ->arrayNode('errorCount')
+ ->arrayNode('customKey')
->isRequired()
->children()
- ->integerNode('maximumAllowed')
+ ->integerNode('customSubKey')
->isRequired();
return $parametersNode;
}
diff --git a/example/Component.php b/example/Component.php
index 8eb9642..f164ebe 100644
--- a/example/Component.php
+++ b/example/Component.php
@@ -15,11 +15,11 @@ protected function run(): void
// get parameters
$parameters = $this->getConfig()->getParameters();
- // get value of customKey.customSubkey parameter and fail if missing
- $customParameter = $this->getConfig()->getValue(['parameters', 'customKey', 'customSubkey']);
+ // get value of customKey.customSubKey parameter and fail if missing
+ $customParameter = $this->getConfig()->getValue(['parameters', 'customKey', 'customSubKey']);
// get value with default value if not present
- $customParameterOrNull = $this->getConfig()->getValue(['parameters', 'customKey'], 'someDefaultValue');
+ $customParameterOrNull = $this->getConfig()->getValue(['parameters', 'anotherCustomKey'], 'someDefaultValue');
// get manifest for input file
$fileManifest = $this->getManifestManager()->getFileManifest('input-file.csv');
@@ -53,4 +53,14 @@ protected function getSyncActions(): array
{
return ['custom' => 'customSyncAction'];
}
+
+ protected function getConfigDefinitionClass(): string
+ {
+ return MyConfigDefinition::class;
+ }
+
+ protected function getConfigClass(): string
+ {
+ return MyConfig::class;
+ }
}
diff --git a/example/MyConfig.php b/example/MyConfig.php
index 3876066..efed322 100644
--- a/example/MyConfig.php
+++ b/example/MyConfig.php
@@ -8,9 +8,9 @@
class MyConfig extends BaseConfig
{
- public function getMaximumAllowedErrorCount(): int
+ public function getCustomSubKey(): int
{
$defaultValue = 0;
- return $this->getIntValue(['parameters', 'errorCount', 'maximumAllowed'], $defaultValue);
+ return $this->getIntValue(['parameters', 'customKey', 'customSubKey'], $defaultValue);
}
}
diff --git a/example/MyConfigDefinition.php b/example/MyConfigDefinition.php
index cb96605..68037e5 100644
--- a/example/MyConfigDefinition.php
+++ b/example/MyConfigDefinition.php
@@ -15,10 +15,10 @@ protected function getParametersDefinition(): ArrayNodeDefinition
$parametersNode
->isRequired()
->children()
- ->arrayNode('errorCount')
+ ->arrayNode('customKey')
->isRequired()
->children()
- ->integerNode('maximumAllowed')
+ ->integerNode('customSubKey')
->isRequired();
return $parametersNode;
}
diff --git a/phpcs.xml b/phpcs.xml
index 569e0d7..bd581db 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -4,7 +4,6 @@
-
*/src/Kernel.php
diff --git a/src/Config/BaseConfig.php b/src/Config/BaseConfig.php
index c30ca55..152afb0 100644
--- a/src/Config/BaseConfig.php
+++ b/src/Config/BaseConfig.php
@@ -31,7 +31,7 @@ class BaseConfig implements ConfigInterface
*/
public function __construct(
array $config,
- ?ConfigurationInterface $configDefinition = null
+ ?ConfigurationInterface $configDefinition = null,
) {
$this->setConfigDefinition($configDefinition);
$this->setConfig($config);
diff --git a/src/Manifest/ManifestManager.php b/src/Manifest/ManifestManager.php
index 5148646..f686a4f 100644
--- a/src/Manifest/ManifestManager.php
+++ b/src/Manifest/ManifestManager.php
@@ -20,7 +20,7 @@ class ManifestManager
private string $dataDir;
public function __construct(
- string $dataDir
+ string $dataDir,
) {
$this->dataDir = $dataDir;
}
@@ -36,7 +36,7 @@ final public function getManifestFilename(string $fileName): string
public function writeFileManifest(
string $fileName,
- OutFileManifestOptions $options
+ OutFileManifestOptions $options,
): void {
$tableManifestName = $this->getManifestFilename($fileName);
$this->internalWriteFileManifest($tableManifestName, $options->toArray());
diff --git a/src/Manifest/ManifestManager/Options/OutTable/ManifestOptionsSchema.php b/src/Manifest/ManifestManager/Options/OutTable/ManifestOptionsSchema.php
index 45d6b52..06666ad 100644
--- a/src/Manifest/ManifestManager/Options/OutTable/ManifestOptionsSchema.php
+++ b/src/Manifest/ManifestManager/Options/OutTable/ManifestOptionsSchema.php
@@ -31,7 +31,7 @@ public function __construct(
bool $nullable = true,
bool $primaryKey = false,
?string $description = null,
- ?array $metadata = null
+ ?array $metadata = null,
) {
$this->setName($name);
if ($dataTypes !== null) {
diff --git a/src/Manifest/ManifestManager/Options/OutTable/Serializer/LegacyManifestNormalizer.php b/src/Manifest/ManifestManager/Options/OutTable/Serializer/LegacyManifestNormalizer.php
index d04cd53..e8db71c 100644
--- a/src/Manifest/ManifestManager/Options/OutTable/Serializer/LegacyManifestNormalizer.php
+++ b/src/Manifest/ManifestManager/Options/OutTable/Serializer/LegacyManifestNormalizer.php
@@ -172,7 +172,7 @@ private function setTableMetadata(ManifestOptions $manifestOptions, array $data)
private function setSchema(
ManifestOptions $manifestOptions,
array $data,
- ?string $metadataBackend
+ ?string $metadataBackend,
): void {
$schema = [];
@@ -226,7 +226,7 @@ private function setMetadata(
array &$metadata,
?string &$description,
bool &$primaryKey,
- bool &$isNullable
+ bool &$isNullable,
): void {
if ($meta['key'] === 'KBC.description') {
$description = $meta['value'];