mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
msgraph: add metadata to users to connect with default calendar
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user