Skip to content

Commit

Permalink
remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Dec 16, 2021
1 parent 07daad1 commit 217aab6
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 269 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# License
Copyright (C) 2017 DACHCOM.DIGITAL
Copyright (C) 2021 DACHCOM.DIGITAL

This software is available under the GNU General Public License version 3 (GPLv3).

Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ The Dynamic Search Bundle allows you to redefine your search strategy. It's base

## Further Information
- [Example Setup](docs/0_ExampleSetup.md)
- [Configuration](#)
- [Context Guard](#)
- [Document Definition](#)
- [Logging](#)
- [Data Creation](#)
- [Enable automatic Update / Insert / Delete Service](#)
- [Data Fetching](#)
- Configuration
- Context Guard
- Document Definition
- Logging
- Data Creation
- [Resource Validation](docs/40_ResourceValidator.md)
- Enable automatic Update / Insert / Delete Service
- Data Fetching
- [Output Channels](docs/30_OutputChannels.md)
- [Create Output Channel](docs/300_CreateOutputChannel.md)
- [Multi Search Channels](#)
- [Channel Filter / Actions](docs/302_ChannelFilterActions.md)
- [Filter (Faceted Search / Aggregation)](#)
- [Create Filter Definition](#)
- [API](#)
- Multi Search Channels
- Filter (Faceted Search / Aggregation)
- Create Filter Definition
- API

## Copyright and License
Copyright: [DACHCOM.DIGITAL](http://dachcom-digital.com)
Expand Down
6 changes: 5 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## Migrating from Version 1.x to Version 2.0.0

### Global Changes

- PHP8 return type declarations added: you may have to adjust your extensions accordingly
- All Folders in `views` are lowercase/dashed now (`views/common`, `views/output-channel`, ...)
- `FieldTransformerInterface::configureOptions` return type changed to `void`
Expand All @@ -18,6 +17,11 @@
the `knp_pager.items` event
- `views/common/list/paginated/_wrapper.html.twig`, `views/common/pagination/_default.html.twig` mark-up changed, check your views
accordingly
- Resource (Untrusted/Proxy) validation has been removed, you need to use the [resource validator](docs/40_ResourceValidator.md)
now:
- Methods `checkUntrustedResourceProxy` and `validateUntrustedResource` from `DataProviderInterface` has been removed. Use `DataProviderValidationAwareInterface::validateResource` instead.
- Methods `checkUntrustedResourceProxy` and `validateUntrustedResource` from `ResourceValidatorInterface` has been removed.
- Class `ProxyResource` has been removed.

### Fixes
--
Expand Down
50 changes: 50 additions & 0 deletions docs/40_ResourceValidator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Resource Validation
In some cases, you need to validate your resource, before it should get dispatched in a specific operation like `insert`, `update` or `delete`.
Just use the `DynamicSearchEvents::RESOURCE_CANDIDATE_VALIDATION` event to manipulate the resource candidate:

```yaml
App\DynamicSearch\EventListener\ResourceCandidateListener:
tags:
- { name: kernel.event_subscriber }
```
```php
<?php

namespace App\DynamicSearch\EventListener;

use DynamicSearchBundle\DynamicSearchEvents;
use DynamicSearchBundle\Event\ResourceCandidateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ResourceCandidateListener implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
DynamicSearchEvents::RESOURCE_CANDIDATE_VALIDATION => ['validateResourceCandidate', 0]
];
}

public function validateResourceCandidate(ResourceCandidateEvent $e): void
{
$resourceCandidate = $e->getResourceCandidate();
$resource = $resourceCandidate->getResource();

// always allow dispatching delete operation as they are
if ($resourceCandidate->getDispatchType() === 'delete') {
return;
}

// example I: change dispatch type to force delete
if ($yourConditionMet && $resourceCandidate->getDispatchType() === 'update' && $resourceCandidate->isAllowedToModifyDispatchType() === true) {
$resourceCandidate->setDispatchType('delete');
}

// example II: set resource to null if it should not get indexed at all
if ($yourConditionMet && $resourceCandidate->isAllowedToModifyResource() === true) {
$resourceCandidate->setResource(null);
}
}
}
```
10 changes: 0 additions & 10 deletions src/DynamicSearchBundle/Provider/DataProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ interface DataProviderInterface extends ProviderInterface

public static function configureOptions(OptionsResolver $resolver): void;

/**
* @deprecated since 1.0.0 and will be removed in 2.0.0. Use {@link DataProviderValidationAwareInterface::validateResource} instead
*/
public function checkUntrustedResourceProxy(ContextDefinitionInterface $contextDefinition, $resource);

/**
* @deprecated since 1.0.0 and will be removed in 2.0.0. Use {@link DataProviderValidationAwareInterface::validateResource} instead
*/
public function validateUntrustedResource(ContextDefinitionInterface $contextDefinition, $resource);

/**
* @throws ProviderException
* @throws ProcessCancelledException
Expand Down
22 changes: 0 additions & 22 deletions src/DynamicSearchBundle/Queue/DataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DynamicSearchBundle\Builder\ContextDefinitionBuilderInterface;
use DynamicSearchBundle\Context\ContextDefinitionInterface;
use DynamicSearchBundle\Resource\Proxy\ProxyResourceInterface;
use DynamicSearchBundle\Validator\ResourceValidatorInterface;
use DynamicSearchBundle\Logger\LoggerInterface;
use DynamicSearchBundle\Manager\QueueManagerInterface;
Expand Down Expand Up @@ -114,27 +113,6 @@ protected function generateJob(string $contextName, string $dispatchType, mixed
$resourceType = gettype($resource);
}

// check for proxy resource (deprecated)
$proxyResource = $this->resourceValidator->checkUntrustedResourceProxy($contextName, $dispatchType, $resource);

if ($proxyResource instanceof ProxyResourceInterface) {
$resource = $proxyResource->hasProxyResource() ? $proxyResource->getProxyResource() : $resource;
$dispatchType = $proxyResource->hasProxyContextDispatchType() ? $proxyResource->getProxyContextDispatchType() : $dispatchType;
}

// check for proxy validity (deprecated)
$resourcedIsValid = $this->resourceValidator->validateUntrustedResource($contextName, $dispatchType, $resource);

if ($resourcedIsValid === false) {
$this->logger->debug(
sprintf('[DEPRECATED] Resource has been marked as untrusted. Skipping...'),
'queue',
$contextName
);

return;
}

$normalizedResourceStack = $this->generateResourceMeta($contextName, $dispatchType, $resource);

if (count($normalizedResourceStack) === 0) {
Expand Down
110 changes: 0 additions & 110 deletions src/DynamicSearchBundle/Resource/Proxy/ProxyResource.php

This file was deleted.

49 changes: 0 additions & 49 deletions src/DynamicSearchBundle/Resource/Proxy/ProxyResourceInterface.php

This file was deleted.

12 changes: 0 additions & 12 deletions src/DynamicSearchBundle/Runner/SimpleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,6 @@ protected function runModification(string $contextName, string $contextDispatchT
$resourceType = gettype($resource);
}

$resourcedIsValid = $this->resourceValidator->validateUntrustedResource($contextDefinition->getName(), $contextDefinition->getContextDispatchType(), $resource);

if ($resourcedIsValid === false) {
$this->logger->debug(
sprintf('Resource has been marked as untrusted. Skipping...'),
$contextDefinition->getDataProviderName(),
$contextDefinition->getName()
);

return;
}

$normalizedResourceStack = $this->resourceHarmonizer->harmonizeUntilNormalizedResourceStack($contextDefinition, $resource);

if ($normalizedResourceStack === null) {
Expand Down
30 changes: 0 additions & 30 deletions src/DynamicSearchBundle/Validator/ResourceValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,6 @@ public function __construct(
$this->eventDispatcher = $eventDispatcher;
}

/**
* @deprecated
*/
public function checkUntrustedResourceProxy(string $contextName, string $dispatchType, $resource)
{
$contextDefinition = $this->contextDefinitionBuilder->buildContextDefinition($contextName, $dispatchType);
$dataProvider = $this->getDataProvider($contextName, $dispatchType);

if (!$dataProvider instanceof DataProviderInterface) {
return null;
}

return $dataProvider->checkUntrustedResourceProxy($contextDefinition, $resource);
}

/**
* @deprecated
*/
public function validateUntrustedResource(string $contextName, string $dispatchType, $resource)
{
$contextDefinition = $this->contextDefinitionBuilder->buildContextDefinition($contextName, $dispatchType);
$dataProvider = $this->getDataProvider($contextName, $dispatchType);

if (!$dataProvider instanceof DataProviderInterface) {
return false;
}

return $dataProvider->validateUntrustedResource($contextDefinition, $resource);
}

public function validateResource(
string $contextName,
string $dispatchType,
Expand Down
Loading

0 comments on commit 217aab6

Please sign in to comment.