Skip to content

Commit

Permalink
Refactor: Support new services layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrankruijter committed Apr 21, 2021
1 parent 42503ca commit c8fdb4a
Show file tree
Hide file tree
Showing 20 changed files with 203 additions and 218 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php
php:
- '7.3'
- '7.4'
- '8.0'

before_script:
- composer install
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.1.0 - 2021-04-21
### Refactor
- Support new services layer.

## 1.0.0 - 2020-11-10
### Added
- The initial implementation of the package.

# Versions
- [1.0.0 > Unreleased](https://github.com/ulrack/environment-extension/compare/1.0.0...HEAD)
- [1.1.0 > Unreleased](https://github.com/ulrack/environment-extension/compare/1.1.0...HEAD)
- [1.0.0 > 1.1.0](https://github.com/ulrack/environment-extension/compare/1.0.0...1.1.0)
17 changes: 8 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
"prefer-stable": true,
"minimum-stability": "stable",
"require": {
"php": "^7.3",
"grizz-it/configuration": "^1.2",
"grizz-it/storage": "^1.0",
"ulrack/command": "^2.0",
"ulrack/invocation-extension": "^1.1",
"ulrack/persistent-extension": "^1.1",
"ulrack/services": "^3.3"
"php": "^8.0",
"grizz-it/command": "^1.0",
"grizz-it/configuration": "^1.3",
"grizz-it/services": "^1.0",
"grizz-it/storage": "^1.1",
"ulrack/persistent-extension": "^1.2"
},
"authors": [
{
Expand Down Expand Up @@ -55,7 +54,7 @@
]
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"squizlabs/php_codesniffer": "^3.5"
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6"
}
}
5 changes: 0 additions & 5 deletions configuration/configuration/environment.configuration.json

This file was deleted.

13 changes: 0 additions & 13 deletions configuration/invocations/environment.invocations.json

This file was deleted.

3 changes: 0 additions & 3 deletions configuration/persistent/environment.persistent.json

This file was deleted.

9 changes: 9 additions & 0 deletions configuration/schema/environment.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$id": "environment.schema.json",
"type": "object",
"properties": {
"default": {
"default": null
}
}
}

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions configuration/services/environment.commands.json

This file was deleted.

59 changes: 59 additions & 0 deletions configuration/services/environment.core.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"parameters": {
"service.configuration.validation.environment": {
"key": "environment",
"schema": "environment.schema.json"
}
},
"services": {
"command.environment.get": {
"class": "\\Ulrack\\EnvironmentExtension\\Command\\EnvironmentGetCommand",
"parameters": {
"serviceFactory": "@{internal.core.service.factory}"
}
},
"command.environment.set": {
"class": "\\Ulrack\\EnvironmentExtension\\Command\\EnvironmentSetCommand",
"parameters": {
"environmentStorage": "@{persistent.environment}"
}
},
"command.environment.list": {
"class": "\\Ulrack\\EnvironmentExtension\\Command\\EnvironmentListCommand",
"parameters": {
"configRegistry": "@{invocations.get.config.registry}"
}
},
"service.factory.environment": {
"class": "\\Ulrack\\EnvironmentExtension\\Factory\\Extension\\EnvironmentFactory"
}
},
"invocations": {
"get.config.registry": {
"service": "internal.core.configuration.manager",
"method": "getConfigRegistry"
},
"add.environment.service.factory": {
"service": "internal.core.service.factory",
"method": "addExtension",
"parameters": {
"scope": "environment",
"extension": "@{services.service.factory.environment}"
},
"cache": true
}
},
"persistent": {
"environment": {}
},
"tags": {
"add.environment.factory": {
"trigger": "triggers.core.service.factories",
"service": "invocations.add.environment.service.factory"
},
"add.service.validation.environment": {
"service": "parameters.service.configuration.validation.environment",
"trigger": "triggers.service.configuration.validation"
}
}
}
8 changes: 5 additions & 3 deletions docs/usage/create-an-environment-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
This package add the ability to create and manage environment variables for
projects. This is being managed through the services layer, so multiple
declarations can be made per file. To create an environment variable create a
file in the `configuration/environment` directory with the following content.
file in the `configuration/services` directory with the following content.

```json
{
"foo": {
"default": null
"environment": {
"foo": {
"default": null
}
}
}
```
Expand Down
8 changes: 4 additions & 4 deletions src/Command/EnvironmentGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace Ulrack\EnvironmentExtension\Command;

use Ulrack\Command\Common\Command\InputInterface;
use Ulrack\Command\Common\Command\OutputInterface;
use Ulrack\Command\Common\Command\CommandInterface;
use Ulrack\Services\Common\ServiceFactoryInterface;
use GrizzIt\Command\Common\Command\InputInterface;
use GrizzIt\Command\Common\Command\OutputInterface;
use GrizzIt\Command\Common\Command\CommandInterface;
use GrizzIt\Services\Common\Factory\ServiceFactoryInterface;

class EnvironmentGetCommand implements CommandInterface
{
Expand Down
31 changes: 19 additions & 12 deletions src/Command/EnvironmentListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,28 @@
namespace Ulrack\EnvironmentExtension\Command;

use Exception;
use Ulrack\Command\Common\Command\InputInterface;
use Ulrack\Command\Common\Command\OutputInterface;
use Ulrack\Command\Common\Command\CommandInterface;
use Ulrack\Services\Common\ServiceFactoryInterface;
use Ulrack\EnvironmentExtension\Factory\Extension\EnvironmentFactory;
use GrizzIt\Command\Common\Command\InputInterface;
use GrizzIt\Command\Common\Command\OutputInterface;
use GrizzIt\Configuration\Common\RegistryInterface;
use GrizzIt\Command\Common\Command\CommandInterface;

class EnvironmentListCommand implements CommandInterface
{
/**
* Contains the environment factory.
* Contains the databases service factory.
*
* @var EnvironmentFactory
* @var RegistryInterface
*/
private $environmentFactory;
private $configRegistry;

/**
* Constructor.
*
* @param EnvironmentFactory $environmentFactory
* @param RegistryInterface $serviceRegsitry
*/
public function __construct(EnvironmentFactory $environmentFactory)
public function __construct(RegistryInterface $configRegistry)
{
$this->environmentFactory = $environmentFactory;
$this->configRegistry = $configRegistry;
}

/**
Expand All @@ -45,7 +44,15 @@ public function __invoke(
InputInterface $input,
OutputInterface $output
): void {
$keys = $this->environmentFactory->getKeys();
$keys = array_keys(
array_merge(
...array_column(
$this->configRegistry->toArray()['services'],
'environment'
)
)
);

if (count($keys) > 0) {
$output->outputList($keys);

Expand Down
8 changes: 4 additions & 4 deletions src/Command/EnvironmentSetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace Ulrack\EnvironmentExtension\Command;

use GrizzIt\Storage\Common\StorageInterface;
use Ulrack\Command\Common\Command\InputInterface;
use Ulrack\Command\Common\Command\OutputInterface;
use Ulrack\Command\Common\Command\CommandInterface;
use GrizzIt\Command\Common\Command\InputInterface;
use GrizzIt\Command\Common\Command\OutputInterface;
use GrizzIt\Command\Common\Command\CommandInterface;

class EnvironmentSetCommand implements CommandInterface
{
Expand Down Expand Up @@ -51,7 +51,7 @@ public function __invoke(
}

$this->environmentStorage->set(
$input->getParameter('key'),
'environment.' . $input->getParameter('key'),
$value
);
}
Expand Down
Loading

0 comments on commit c8fdb4a

Please sign in to comment.