Skip to content
Permalink
Browse files

ipTraceable ipValue is required

  • Loading branch information
mabar authored and f3l1x committed Nov 26, 2019
1 parent bc5a6d8 commit edefd1faa9c6f678931b97867abb1eebc951e264
Showing with 19 additions and 4 deletions.
  1. +11 −0 .docs/README.md
  2. +2 −1 README.md
  3. +6 −3 src/DI/Atlantic18BehaviorExtension.php
@@ -8,6 +8,7 @@ Doctrine ([Atlantic18/DoctrineExtensions](https://github.com/Atlantic18/Doctrine
- [Configuration](#configuration)
- [Loggable, Translatable, Treeable](#loggable-translatable-treeable)
- [Translatable](#translatable)
- [IpTraceable](#iptraceable)

## Setup

@@ -85,3 +86,13 @@ nettrine.extensions.atlantic18:
persistDefaultTranslation: off
skipOnLoad: off
```

### [IpTraceable](https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/ip_traceable.md)

IpTraceable requires client IP address:

```
nettrine.extensions.atlantic18:
ipTraceable:
ipValue: @Nette\Http\IRequest::getRemoteAddress()
```
@@ -20,7 +20,8 @@ Doctrine ([Atlantic18/DoctrineExtensions](https://github.com/Atlantic18/Doctrine
- [Configuration](.docs/README.md#configuration)
- [Loggable, Translatable, Treeable](.docs/README.md#loggable-translatable-treeable)
- [Translatable](.docs/README.md#translatable)

- [IpTraceable](.docs/README.md##iptraceable)

## Versions

| State | Version | Branch | Nette | PHP |
@@ -13,6 +13,7 @@
use Gedmo\Translatable\TranslatableListener;
use Gedmo\Tree\TreeListener;
use Nette\DI\CompilerExtension;
use Nette\DI\Definitions\Statement;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use stdClass;
@@ -43,7 +44,9 @@ public function getConfigSchema(): Schema
]))->default(false),
'uploadable' => Expect::bool(false),
'sortable' => Expect::bool(false),
'ipTraceable' => Expect::bool(false),
'ipTraceable' => Expect::anyOf(false, Expect::structure([
'ipValue' => Expect::anyOf(Expect::string(), Expect::array(), Expect::type(Statement::class))->required(),
]))->default(false),
]);
}

@@ -132,11 +135,11 @@ public function loadConfiguration(): void

// IpTraceable ===============================================

if ($config->ipTraceable) {
if ($config->ipTraceable !== false) {
$builder->addDefinition($this->prefix('ipTraceable'))
->setFactory(IpTraceableListener::class)
->addSetup('setAnnotationReader', ['@' . Reader::class])
->addSetup('setIpValue', !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null)
->addSetup('setIpValue', $config->ipTraceable->ipValue)
->addTag(self::TAG_NETTRINE_SUBSCRIBER);
}
}

0 comments on commit edefd1f

Please sign in to comment.
You can’t perform that action at this time.