Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbannert committed Sep 27, 2018
1 parent 2242fba commit 94b50f5
Show file tree
Hide file tree
Showing 26 changed files with 2,008 additions and 829 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"narrowspark/coding-standard": "^1.2.0",
"narrowspark/testing-helper": "^7.0.0",
"nyholm/nsa": "^1.1.0",
"phpunit/phpunit": "^7.2.0"
"phpunit/phpunit": "^7.2.0",
"symfony/process": "^4.1"
},
"config": {
"optimize-autoloader": true,
Expand Down Expand Up @@ -66,7 +67,8 @@
"psr-4": {
"Narrowspark\\Automatic\\Test\\": "tests/Automatic/",
"Narrowspark\\Automatic\\Common\\Test\\": "tests/Common/",
"Narrowspark\\Automatic\\Security\\Test\\": "tests/Security/"
"Narrowspark\\Automatic\\Security\\Test\\": "tests/Security/",
"Narrowspark\\Automatic\\Functional\\Test\\": "tests/Functional/"
},
"files": [
"tests/Automatic/TmpDirMock.php"
Expand Down
11 changes: 6 additions & 5 deletions doc/CONFIGURATORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ Only the composer `command`, `installer` and `package` events are supported, you
}
```

You can create your own script executor, create a new class inside your Package Repository in a `Automatic` folder and extend `Narrowspark\Automatic\Common\ScriptExtender\AbstractScriptExtender` the example below shows you how it should look:
You can create your own script executor, create a new executor class in your `Automatic` folder, inside your Package. The class needs to extend `Narrowspark\Automatic\Common\ScriptExtender\AbstractScriptExtender`.
You have a example below:

```php
<?php
Expand Down Expand Up @@ -220,7 +221,7 @@ The following example shows you, how your `composer.json` can look:

### Creating Package Configurators

Narrowspark Automatic Configurators must be stored inside your Composer package repository in a `Automatic` folder.
Narrowspark Automatic Configurators must be created inside your Composer Package in a `Automatic` folder.

Add a new key `custom-configurators` to the `automatic.json` file or to `extra automatic ` section in your composer.json file to register new Package Configurator(s).

Expand All @@ -232,9 +233,9 @@ This example shows you, how to add a new Package Configurator in your `composer.
"narrowspark/automatic-common": "^0.4.0"
},
"automatic": {
"custom-configurators" : {
"name of the configurator": "Your\\Package\\Configurator"
}
"custom-configurators" : [
"Your\\Package\\Configurator"
]
}
}
```
Expand Down
37 changes: 10 additions & 27 deletions src/Automatic/AbstractConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Narrowspark\Automatic\Common\Contract\Configurator as ConfiguratorContract;
use Narrowspark\Automatic\Common\Contract\Exception\InvalidArgumentException;
use Narrowspark\Automatic\Common\Contract\Package as PackageContract;
use Narrowspark\Automatic\Contract\Configurator as MainConfiguratorContract;

abstract class AbstractConfigurator
abstract class AbstractConfigurator implements MainConfiguratorContract
{
/**
* All registered automatic configurators.
Expand Down Expand Up @@ -53,24 +54,15 @@ public function __construct(Composer $composer, IOInterface $io, array $options)
}

/**
* Get all registered configurators.
*
* @return array
* {@inheritdoc}
*/
public function getConfigurators(): array
{
return $this->configurators;
}

/**
* Add a new automatic configurator.
*
* @param string $name
* @param string $configurator
*
* @throws \Narrowspark\Automatic\Common\Contract\Exception\InvalidArgumentException
*
* @return void
* {@inheritdoc}
*/
public function add(string $name, string $configurator): void
{
Expand All @@ -86,23 +78,15 @@ public function add(string $name, string $configurator): void
}

/**
* Check if configurator is registered.
*
* @param string $name
*
* @return bool
* {@inheritdoc}
*/
public function has(string $name): bool
{
return isset($this->configurators[$name]);
}

/**
* Configure the application after the package settings.
*
* @param \Narrowspark\Automatic\Common\Contract\Package $package
*
* @return void
* {@inheritdoc}
*/
public function configure(PackageContract $package): void
{
Expand All @@ -114,11 +98,7 @@ public function configure(PackageContract $package): void
}

/**
* Unconfigure the application after the package settings.
*
* @param \Narrowspark\Automatic\Common\Contract\Package $package
*
* @return void
* {@inheritdoc}
*/
public function unconfigure(PackageContract $package): void
{
Expand All @@ -129,6 +109,9 @@ public function unconfigure(PackageContract $package): void
}
}

/**
* {@inheritdoc}
*/
public function reset(): void
{
$this->configurators = [];
Expand Down
Loading

0 comments on commit 94b50f5

Please sign in to comment.