msgraph: add metadata to users to connect with default calendar

This commit is contained in:
2022-05-06 10:13:32 +02:00
parent 5331f1becc
commit 9935af0497
9 changed files with 181 additions and 12 deletions

View File

@@ -350,15 +350,20 @@ class User implements AdvancedUserInterface
}
/**
* Set attributes.
* Merge the attributes with existing attributes.
*
* @param array $attributes
*
* @return Report
* Only the key provided will be created or updated.
*/
public function setAttributes($attributes)
public function setAttributes(array $attributes): self
{
$this->attributes = $attributes;
$this->attributes = array_merge($this->attributes, $attributes);
return $this;
}
public function unsetAttribute($key): self
{
unset($this->attributes[$key]);
return $this;
}

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
@@ -157,6 +158,29 @@ final class UserRepository implements ObjectRepository
return $qb->getQuery()->getResult();
}
/**
* Find users which does not have a key on attribute column
*
* @return array|User[]
*/
public function findByNotHavingAttribute(string $key, ?int $limit = null, ?int $offset = null): array
{
$rsm = new ResultSetMappingBuilder($this->entityManager);
$rsm->addRootEntityFromClassMetadata(User::class, 'u');
$sql = "SELECT ".$rsm->generateSelectClause()." FROM users u WHERE NOT attributes ? :key OR attributes IS NULL AND enabled IS TRUE";
if (null !== $limit) {
$sql .= " LIMIT $limit";
}
if (null !== $offset) {
$sql .= " OFFET $offset";
}
return $this->entityManager->createNativeQuery($sql, $rsm)->setParameter(':key', $key)->getResult();
}
public function getClassName()
{
return User::class;