@param FacadeInterface $facade
@param GroupInterface  $group

@return FacadeInterface
549560
protected function addSite(FacadeInterface $facade, GroupInterface $group)
    {
        if ($this->hasGroup(CMSGroupContext::SITE) && $site = $group->getSite()) {
            $facade->site = $this->getContext()->transform('site', $site);
        }

        return $facade;
    }
1049414
private function createGroups(OutputInterface $output)
    {
        $em = $this->container->get('ekyna_user.group.manager');
        $repository = $this->container->get('ekyna_user.group.repository');

        foreach ($this->defaultGroups as $name => $options) {
            $output->write(sprintf(
                '- <comment>%s</comment> %s ',
                $name,
                str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT)
            ));
            if (null !== $group = $repository->findOneBy(['name' => $name])) {
                $output->writeln('already exists.');
                continue;
            }
            /** @var \Ekyna\Bundle\UserBundle\Model\GroupInterface $group */
            $group = $repository->createNew();
            $group
                ->setDefault($options[2])
                ->setName($name)
                ->setRoles($options[0])
            ;
            $em->persist($group);
            $output->writeln('created.');
        }
        $em->flush();
    }
430020
public static function pathsToPublish($provider = null, $group = null)
	{
		if ($group && array_key_exists($group, static::$publishGroups))
		{
			return static::$publishGroups[$group];
		}

		if ($provider && array_key_exists($provider, static::$publishes))
		{
			return static::$publishes[$provider];
		}

		if ($group || $provider)
		{
			return [];
		}

		$paths = [];

		foreach (static::$publishes as $class => $publish)
		{
			$paths = array_merge($paths, $publish);
		}

		return $paths;
	}
769671
public function leaveGroup(ModelInterface $group): PodiumResponse
    {
        return $this->getPodium()->member->leave($this->ensureMembership(), $group);
    }
876533
public function inGroup(GroupInterface $group)
	{
		foreach ($this->getGroups() as $_group)
		{
			if ($_group->getId() == $group->getId())
			{
				return true;
			}
		}

		return false;
	}
377262
public function canDelete(GroupInterface $group, array $parameters)
    {
        $nbrGroupsUsers = $parameters;
        if (!array_key_exists($group->getId(), $nbrGroupsUsers)) {
            $nbrGroupsUsers = $this->userRepository->getCountsUsersByGroups(array($group->getId()));
        }

        return 0 === $nbrGroupsUsers[$group->getId()];
    }
713135
protected function addMainAttributes(FacadeInterface $facade, NodeInterface $node)
    {
        if ($site = $this->siteRepository->findOneBySiteId($node->getSiteId())) {
            $facade->templateSet = $site->getTemplateSet();
        }

        $facade->id = $node->getId();
        $facade->nodeId = $node->getNodeId();
        $facade->name = $node->getName();
        $facade->siteId = $node->getSiteId();
        $facade->deleted = $node->isDeleted();
        $facade->template = $node->getTemplate();
        $facade->nodeType = $node->getNodeType();
        $facade->parentId = $node->getParentId();
        $facade->path = $node->getPath();
        $facade->routePattern = $node->getRoutePattern();
        $facade->language = $node->getLanguage();
        $facade->metaDescription = $node->getMetaDescription();
        $facade->metaIndex = $node->getMetaIndex();
        $facade->metaFollow = $node->getMetaFollow();
        $facade->version = $node->getVersion();
        $facade->versionName = $node->getVersionName();
        $facade->createdBy = $node->getCreatedBy();
        $facade->updatedBy = $node->getUpdatedBy();
        $facade->createdAt = $node->getCreatedAt();
        $facade->updatedAt = $node->getUpdatedAt();

        if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS_DELETE_VERSION)) {
            $facade->addRight('can_delete', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $node) && $this->businessRulesManager->isGranted(NodeStrategy::DELETE_VERSION, $node));
        }
        if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS)) {
            $facade->addRight('can_read', $this->authorizationChecker->isGranted(ContributionActionInterface::READ, $node));
            $facade->addRight('can_edit_data', $this->businessRulesManager->isGranted(BusinessActionInterface::EDIT, $node) && $this->authorizationChecker->isGranted(ContributionActionInterface::EDIT, $node));
            $facade->addRight('can_edit', $this->authorizationChecker->isGranted(ContributionActionInterface::EDIT, $node));
        }
        if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS_CHANGE_STATUS)) {
            $facade->addRight('can_publish_node', $this->businessRulesManager->isGranted(NodeStrategy::CHANGE_TO_PUBLISH_STATUS, $node));
        }

        return $facade;
    }
467424
public static function getOrCreate($groups)
    {
        $app = Facade::getFacadeApplication();
        /** @var $database \Concrete\Core\Database\Connection\Connection */
        $database = $app->make('database')->connection();
        $petID = $database->fetchColumn(
            'select petID from PermissionAccessEntityTypes
                      where petHandle = \'group_combination\''
        );
        $query = $database->createQueryBuilder();
        $query->select('pae.peID')->from('PermissionAccessEntities', 'pae');
        $i = 1;
        $query->where('petid = :entityTypeID')->setParameter('entityTypeID', $petID);
        foreach ($groups as $group) {
            $query
                ->leftJoin(
                    'pae',
                    'PermissionAccessEntityGroups',
                    'paeg' . $i,
                    'pae.peID = paeg' . $i . '.peID'
                )
                ->andWhere('paeg' . $i . '.gID = :group' . $i)
                ->setParameter('group' . $i, $group->getGroupID());
            $i++;
        }

        $peIDs = $query->execute()->fetchAll();
        $peID = 0;

        // Check for all the groups belonging to this AccessEntity.
        if (!empty($peIDs)) {
            foreach ($peIDs as $result) {
                $allGroups = $database->fetchColumn(
                    'select count(gID) from PermissionAccessEntityGroups
                              where peID = ' . $result['peID']
                );
                if ($allGroups == count($groups)) {
                    $peID = $result['peID'];
                    break;
                }
            }
        }
        // If the accessEntity doesnt exist, then create a new one.
        if (empty($peID)) {
            $database->insert('PermissionAccessEntities', ['petID' => $petID]);
            $peID = $database->lastInsertId();
            $app->make('config')->save(
                'concrete.misc.access_entity_updated',
                time()
            );
            foreach ($groups as $group) {
                $database->insert(
                    'PermissionAccessEntityGroups',
                    ['peID' => $peID, 'gID' => $group->getGroupID()]
                );
            }
        }

        return self::getByID($peID);
    }
457444
public function pushMiddlewareToGroup($group, $middleware)
    {
        if (! array_key_exists($group, $this->middlewareGroups)) {
            $this->middlewareGroups[$group] = array();
        }

        if (! in_array($middleware, $this->middlewareGroups[$group])) {
            $this->middlewareGroups[$group][] = $middleware;
        }

        return $this;
    }
713743
public function method(string $method, string $uriPath, callable $handler, array $parameters = []): GroupInterface
    {
        list($middleware, $configurators, $requestFactory, $useGroupFactory, $name) =
            $this->normalizeRouteParameters($parameters);

        $uriPath = $this->normalizeUri($uriPath, $this->hasTrailSlash());

        $route = $this->createRoute($this, $method, $uriPath, $handler)
            ->setUseGroupRequestFactory($useGroupFactory)
            ->setRequestFactory($requestFactory)
            ->setConfigurators($configurators)
            ->setMiddleware($middleware)
            ->setName($name);

        return $this->addRoute($route);
    }
327768
public function addTargetGroup(TargetGroupInterface $targetGroup)
    {
        $fileVersion = $this->getFileVersion();
        $fileVersion->addTargetGroup($targetGroup);

        return $this;
    }
1319823
protected function addAreas(FacadeInterface $facade, NodeInterface $node)
    {
        if ($this->hasGroup(CMSGroupContext::AREAS)) {
            foreach ($node->getAreas() as $key => $area) {
                $facade->setAreas($this->getContext()->transform('area', $area), $key);
            }
        }

        return $facade;
    }
1330167
public function removeGroup(GroupInterface $group)
	{
		if ($this->inGroup($group))
		{
			$this->remove('groups', $group);
		}

		return true;
	}
990655
public function deleteGroup($groupId)
    {
        try {
            return $this->innerGateway->deleteGroup($groupId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
475828
public function reverseTransform(FacadeInterface $facade, array $params = array())
    {
        $trashItems = array();
        $trashItemsFacade = $facade->getTrashItems();
        foreach ($trashItemsFacade as $trashItemFacade) {
            $trashItem = $this->getContext()->reverseTransform('trash_item', $trashItemFacade);
            if (null !== $trashItem) {
                $trashItems[] = $trashItem;
            }
        }

        return $trashItems;
    }
706480
public function showGroup( $groupId )
    {
        $collection = $this->repository->getPatientsByParam( ['groupId' => $groupId ] );
        return $this->buildBundle( $collection );
    }
1311212
public function showGroup( $groupId )
    {
        $collection = $this->repository->getAppointmentsByParam( ['groupId' => $groupId ] );
        return $this->buildBundle( $collection );
    }