Skip to content
Snippets Groups Projects
Commit aa371edb authored by Tobias Gross-Vogt's avatar Tobias Gross-Vogt
Browse files

local data updates

parent 95513ca4
No related branches found
No related tags found
No related merge requests found
Pipeline #191143 passed
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "92bc4a145720f84a7607d0270308ac9f",
"content-hash": "1262fab1c713ea8767e23bf5b9729efc",
"packages": [
{
"name": "adldap2/adldap2",
......@@ -396,11 +396,11 @@
},
{
"name": "dbp/relay-core-bundle",
"version": "0.1.37",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://gitlab.tugraz.at/dbp/relay/dbp-relay-core-bundle",
"reference": "b58c833026de0aa0572a38684d0b0f2107e46aee"
"reference": "7f2301d63ff98fa9cdd9faaac5e610f57f8c64db"
},
"require": {
"api-platform/core": "^2.6.6",
......@@ -409,6 +409,8 @@
"ext-fileinfo": "*",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.0",
"kevinrob/guzzle-cache-middleware": "^4.0",
"league/uri": "^6.5",
"nelmio/cors-bundle": "^2.1.0",
"php": "^7.3 || ^8.0",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0",
......@@ -442,6 +444,7 @@
"symfony/phpunit-bridge": "^5.3",
"vimeo/psalm": "^4.4"
},
"default-branch": true,
"type": "symfony-bundle",
"extra": {
"hooks": {
......@@ -460,7 +463,7 @@
"AGPL-3.0-or-later"
],
"description": "The core bundle of the Relay API gateway",
"time": "2022-06-22T09:04:47+00:00"
"time": "2022-08-10T12:21:15+00:00"
},
{
"name": "doctrine/annotations",
......@@ -11183,9 +11186,18 @@
"time": "2015-12-17T08:42:14+00:00"
}
],
"aliases": [],
"aliases": [
{
"package": "dbp/relay-core-bundle",
"version": "dev-main",
"alias": "0.1.37",
"alias_normalized": "0.1.37.0"
}
],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"dbp/relay-core-bundle": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
......@@ -11197,5 +11209,5 @@
"platform-overrides": {
"php": "7.3"
},
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.2.0"
}
......@@ -5,9 +5,9 @@ declare(strict_types=1);
namespace Dbp\Relay\BasePersonConnectorLdapBundle\Event;
use Dbp\Relay\BasePersonBundle\Entity\Person;
use Dbp\Relay\CoreBundle\LocalData\LocalDataAwareEvent;
use Dbp\Relay\CoreBundle\LocalData\LocalDataAwarePostEvent;
class PersonFromUserItemPostEvent extends LocalDataAwareEvent
class PersonFromUserItemPostEvent extends LocalDataAwarePostEvent
{
public const NAME = 'dbp.relay.base_person_connector_ldap_bundle.person_from_user_item.post';
......
......@@ -20,7 +20,6 @@ use Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonUserItemPreEvent;
use Dbp\Relay\CoreBundle\API\UserSessionInterface;
use Dbp\Relay\CoreBundle\Exception\ApiError;
use Dbp\Relay\CoreBundle\Helpers\Tools as CoreTools;
use Dbp\Relay\CoreBundle\LocalData\LocalData;
use Dbp\Relay\CoreBundle\LocalData\LocalDataAwareEventDispatcher;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Container\ContainerInterface;
......@@ -68,11 +67,8 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
private $birthdayAttributeName;
/** @var EventDispatcherInterface */
private $dispatcher;
/** @var LocalDataAwareEventDispatcher */
private $localDataAwareEventDispatcher;
private $eventDispatcher;
public function __construct(ContainerInterface $locator, EventDispatcherInterface $dispatcher)
{
......@@ -81,8 +77,7 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
$this->currentPerson = null;
$this->locator = $locator;
$this->deploymentEnv = 'production';
$this->dispatcher = $dispatcher;
$this->localDataAwareEventDispatcher = new LocalDataAwareEventDispatcher(Person::class, $dispatcher);
$this->eventDispatcher = new LocalDataAwareEventDispatcher(Person::class, $dispatcher);
}
public function setConfig(array $config)
......@@ -226,7 +221,7 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
public function getPersons(array $filters): array
{
$this->localDataAwareEventDispatcher->initRequestedLocalDataAttributes(LocalData::getIncludeParameter($filters));
$this->eventDispatcher->onNewOperation($filters);
$persons = [];
$items = $this->getPeopleUserItems($filters);
......@@ -241,7 +236,7 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
private function getPersonUserItem(string $identifier): User
{
$preEvent = new PersonUserItemPreEvent($identifier);
$this->dispatcher->dispatch($preEvent, PersonUserItemPreEvent::NAME);
$this->eventDispatcher->dispatch($preEvent, PersonUserItemPreEvent::NAME);
$identifier = $preEvent->getIdentifier();
try {
......@@ -271,7 +266,7 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
public function personFromUserItem(User $user, bool $full): Person
{
// $preEvent = new PersonFromUserItemPreEvent($user, $full);
// $this->dispatcher->dispatch($preEvent, PersonFromUserItemPreEvent::NAME);
// $this->eventDispatcher->dispatch($preEvent, PersonFromUserItemPreEvent::NAME);
// $user = $preEvent->getUser();
$identifier = $user->getFirstAttribute($this->identifierAttributeName) ?? '';
......@@ -305,14 +300,14 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
}
$postEvent = new PersonFromUserItemPostEvent($attributes, $person, $full);
$this->localDataAwareEventDispatcher->dispatch($postEvent, PersonFromUserItemPostEvent::NAME);
$this->eventDispatcher->dispatch($postEvent, PersonFromUserItemPostEvent::NAME);
return $postEvent->getPerson();
}
public function getPerson(string $id, array $options = []): Person
{
$this->localDataAwareEventDispatcher->initRequestedLocalDataAttributes(LocalData::getIncludeParameter($options));
$this->eventDispatcher->onNewOperation($options);
// extract username in case $id is an iri, e.g. /base/people/{user}
$parts = explode('/', $id);
......@@ -353,7 +348,7 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
if ($this->currentPerson) {
if ($this->currentPerson->getIdentifier() === $currentIdentifier) {
if (!$checkLocalDataAttributes || $this->localDataAwareEventDispatcher->checkRequestedAttributesIdentitcal($this->currentPerson)) {
if (!$checkLocalDataAttributes || $this->eventDispatcher->checkRequestedAttributesIdentical($this->currentPerson)) {
return $this->currentPerson;
} else {
// cache a new instance of Person because the cached instance's local data attributes do not match the requested attributes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment