How to set group permissions on single page in package installer?

Permalink
I've been trying to find how to set group permissions for pages created in a package installer and only found examples for 5.6 to work with so far.

What is the correct way to remove all permissions for a single page (e.g. guest is a default) and added a specific group permission? I have been successful in creating new groups but thus far assigning group permissions is eluding me.

I am doing:
use \Concrete\Core\User\Group\Group as Group;
...
$sp = SinglePage::add("/ffw", $pkg); $sp_ffw = $sp; // remember for later
$sp->update(array('cName'=>t('some title'), 'cDescription'=>t('some title')));
$group_sysadmins = Group::add( 'System Admin', 'Users who can do all but full CMS admin tasks', false, $pkg, null );
$group_guest = Group::getByName('Guest');
$sp_ffw->assignPermissions( $group_sysadmins [ 'view' ]);
$sp_ffw->removePermissions( $group_guest );


Any wisdom gratefully received. If I sort it in the meantime I'll post the findings here for other lost souls.

surefyre
 
surefyre replied on at Permalink Reply 1 Attachment
surefyre
I finally sorted it:

// create page
$sp = SinglePage::add("/ffw", $pkg); $sp_ffw = $sp; // remember for later
$sp->update(array('cName'=>t('titletext'), 'cDescription'=>t('titletext')));
// create group
$group_sysadmins = Group::add( 'System Admin', 'Users who can do all but full CMS admin tasks', false, $pkg, null );
// get 'guest' group
$group_guest = Group::getByName('Guest');
// set permissions
$sp_ffw->setPermissionsToManualOverride( );
$sp_ffw->assignPermissions( $group_sysadmins, [ 'view_page' ]);
$sp_ffw->removePermissions( $group_guest, [ 'view_page' ] );

So I was close, initially.

You can verify this works by checking your single page permissions in the sitemap.