NerdsAndCompany\Schematic\Services\UserGroups::export PHP Method

export() public method

Export user groups.
public export ( array $groups = [] ) : array
$groups array
return array
    public function export(array $groups = [])
    {
        Craft::log(Craft::t('Exporting User Groups'));
        $groupDefinitions = [];
        $this->sectionsById = $this->getSectionsService()->getAllSections('id');
        $this->assetSourceById = $this->getAssetSourcesService()->getAllSources('id');
        $this->globalSetsById = $this->getGlobalsService()->getAllSets('id');
        $this->mappedPermissions = $this->getAllMappedPermissions();
        foreach ($groups as $group) {
            $groupDefinitions[$group->handle] = $this->getGroupDefinition($group);
        }
        return $groupDefinitions;
    }

Usage Example

Example #1
0
 /**
  * @covers ::export
  * @dataProvider provideValidUserGroups
  *
  * @param UserGroupModel[] $groups
  * @param string[]         $groupPermissions
  * @param array            $expectedResult
  */
 public function testSuccessfulExport(array $groups, array $groupPermissions, array $expectedResult = [])
 {
     $this->setMockUserGroupsService();
     $this->setMockUserPermissionsService($groupPermissions);
     $this->setMockSectionsService('id');
     $this->setMockAssetSourcesService('id');
     $this->setMockGlobalsService('id');
     $schematicUserGroupsService = new UserGroups();
     $actualResult = $schematicUserGroupsService->export($groups);
     $this->assertSame($expectedResult, $actualResult);
 }