Skip to content

Commit

Permalink
Merging develop to master in preparation for 2.3.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Apr 27, 2020
2 parents 9d9445a + a5021ac commit 5ab185d
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.2.4 - TBD
## 2.3.0 - 2020-04-27

### Added

- Nothing.
- [#37](https://github.com/laminas/laminas-diactoros/pull/37) adds a ConfigProvider and Module, allowing the package to be autoregistered within Mezzio and MVC applications. Each provides configuration mapping PSR-17 HTTP message factory interfaces to the Diactoros implementations of them.

### Changed

Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev",
"dev-develop": "2.2.x-dev",
"dev-release-1.8": "1.8.x-dev"
"dev-master": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
},
"laminas": {
"config-provider": "Laminas\\Diactoros\\ConfigProvider",
"module": "Laminas\\Diactoros"
}
},
"require": {
Expand Down
11 changes: 11 additions & 0 deletions docs/book/v2/factories.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ The `ServerRequestFactory` continues to define the static method

These classes may be used as described in the specification document for the
purpose of creating Diactoros instances that fulfill PSR-7 typehints.

## Autoregistration of factories

- Since 2.3.0

When installing Diactoros in a Laminas or Mezzio application, or any application
using the [laminas-component-installer plugin](https://docs.laminas.dev/laminas-component-installer),
you will now be prompted to install its `ConfigProvider` and/or `Module`. When
you do, it registers the Diactoros factory implementations under the PSR-17
interface names, allowing you to compose instances of the interface in your
application classes..
51 changes: 51 additions & 0 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* @see https://github.com/laminas/laminas-diactoros for the canonical source repository
* @copyright https://github.com/laminas/laminas-diactoros/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-diactoros/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Laminas\Diactoros;

use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;

class ConfigProvider
{
/**
* Retrieve configuration for laminas-diactoros.
*
* @return array
*/
public function __invoke() : array
{
return [
'dependencies' => $this->getDependencies(),
];
}

/**
* Returns the container dependencies.
* Maps factory interfaces to factories.
*/
public function getDependencies() : array
{
return [
'invokables' => [
RequestFactoryInterface::class => RequestFactory::class,
ResponseFactoryInterface::class => ResponseFactory::class,
StreamFactoryInterface::class => StreamFactory::class,
ServerRequestFactoryInterface::class => ServerRequestFactory::class,
UploadedFileFactoryInterface::class => UploadedFileFactory::class,
UriFactoryInterface::class => UriFactory::class
],
];
}
}
21 changes: 21 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* @see https://github.com/laminas/laminas-diactoros for the canonical source repository
* @copyright https://github.com/laminas/laminas-diactoros/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-diactoros/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Laminas\Diactoros;

class Module
{
public function getConfig(): array
{
return [
'service_manager' => (new ConfigProvider())->getDependencies(),
];
}
}

0 comments on commit 5ab185d

Please sign in to comment.