Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Jan 20, 2024
1 parent b14362e commit 60dd494
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
24 changes: 9 additions & 15 deletions docs/guide/en/attribute-resolver-factory.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# Attribute resolver factory

The hydrator uses `AttributeResolverFactoryInterface` implementation to create attribute resolvers. The package provides two
implementations out of the box.
The hydrator uses `AttributeResolverFactoryInterface` implementation to create attribute resolvers.
The package provides two implementations out of the box:

## Attribute resolver factories out of the box
- `ReflectionAttributeResolverFactory`. Uses reflection to create attribute resolver, and can create attribute resolvers
without dependencies only.
- `ContainerAttributeResolverFactory`. Uses [PSR-11](https://www.php-fig.org/psr/psr-11/) compatible DI container
to create attribute resolver.

### `ReflectionAttributeResolverFactory`

It uses reflection to create attribute resolver, and can create attribute resolvers without dependencies only.

### `ContainerAttributeResolverFactory`

It uses PSR-11 compatible DI container to create attribute resolver.

## Default attribute resolver factory

It depends on environment. When using hydrator package within the Yii ecosystem (an application uses
[Yii Config](https://github.com/yiisoft/config)), by default uses `ContainerAttributeResolverFactory`. Otherwise, it uses `ReflectionAttributeResolverFactory`.
Default factory used depends on the environment. When using hydrator package within the Yii ecosystem (an application
uses [Yii Config](https://github.com/yiisoft/config)), default is `ContainerAttributeResolverFactory`. Otherwise,
it is `ReflectionAttributeResolverFactory`.

## Using attribute resolver factory

Expand Down
22 changes: 9 additions & 13 deletions docs/guide/en/object-factory.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Object Factory

The hydrator uses `ObjectFactoryInterface` implementation to create object when you uses `Hydrator::create()` method: hydrator passes to factory resolved constructor arguments and gets created object for next hydration. The package provides two implementations out of the box.

## Object factories out of the box

### `ReflectionObjectFactory`

It uses reflection to create object, and cannot create objects when not all constructor arguments are resolved.
This object factory is used by default.

### `ContainerObjectFactory`

It uses [Yii Injector](https://github.com/yiisoft/injector) to create object that allow to use PSR-11 compatible
DI container for resolve constructor arguments, which were not resolved by the hydrator.
The hydrator uses `ObjectFactoryInterface` implementation to create object when you use `Hydrator::create()` method:
hydrator passes resolved constructor arguments to factory and obtains created object for next hydration.
The package provides two implementations out of the box:

- `ReflectionObjectFactory`. Uses reflection to create object. It cannot create objects when some constructor arguments
aren't resolved. This object factory is used by default.
- `ContainerObjectFactory`. Uses [Yii Injector](https://github.com/yiisoft/injector) to create object that allow to use
[PSR-11](https://www.php-fig.org/psr/psr-11/) compatible DI container to resolve constructor argument not resolved
by the hydrator.

## Using object factory

Expand Down

0 comments on commit 60dd494

Please sign in to comment.