msgraph-sdk-php
msgraph-sdk-php copied to clipboard
Error in using sdk in Symfony with caching
When I get a model from the graph, I get the correct model. But I'm using caching in Symfony to save requests.
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($type, $email) {
$item->expiresAfter(self::CACHE_EXPIRES_IN_SECONDS_SHORT);
try {
$requestConfig
= new GroupsRequestBuilderGetRequestConfiguration(queryParameters: GroupsRequestBuilderGetRequestConfiguration::createQueryParameters(filter: 'startsWith(mail,\''
. $email . '\')'));
$groups = $this->graphClient->groups()->get($requestConfig)->wait()->getValue();
if ($groups) {
foreach ($groups as $group) {
if ($group instanceof \Microsoft\Graph\Generated\Models\Group && $group->getMail() == $email) {
return $group;
}
}
}
return null;
} catch (ApiException $exception) {
$this->handleException($exception);
}
});
In my local machine, this gives no trouble, when testing this. On my remote machine, I get an error
In DefaultMarshaller.php line 50:
Serialization of 'Closure' is not allowed
It seems the serialization does not work well on this model?
Any suggestions? Tim