concrete/src/Permission/Access/Entity/GroupCombinationEntity.php
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);
    }
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);
    }
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 ) ; }
Function used to get or create a GroupCombination Permission Access Entity.

@param Group[] $groups Groups for this combination.

@return self
Function used to get or create a GroupCombination Permission Access Entity .