Import the content of an archive in a workspace.

@param Configuration $configuration
@param Workspace $workspace
@return Workspace
771233
public function importInExistingWorkspace(Configuration $configuration, Workspace $workspace)
    {
        $root = $this->resourceManager->getResourceFromNode($this->resourceManager->getWorkspaceRoot($workspace));
        $wsRoles = $this->roleManager->getRolesByWorkspace($workspace);
        $entityRoles = [];

        foreach ($wsRoles as $wsRole) {
            $entityRoles[$this->roleManager->getWorkspaceRoleBaseName($wsRole)] = $wsRole;
        }

        $workspace = $this->container->get('claroline.manager.transfert_manager')->importResources(
            $configuration,
            $workspace->getCreator(),
            $root->getResourceNode()
        );

        $this->importRichText();

        return $workspace;
    }
175978
private function getUsageParser(Configuration $configuration)
    {
        return new UsageParser(
            $this->getStaticAnalysisVisitors($configuration),
            $this->getViolationVisitors(),
            $this->getBaseTraverser(),
            new NodeTraverser(),
            new NodeTraverser()
        );
    }
540343
public function loadConfiguration(ConfigurationInterface $configuration)
    {
        $extAssocList = $configuration->getExternalAssociations();
        foreach ($extAssocList as $extAssoc) {
            $this->mapExternalAssociation($extAssoc);
        }
        return $this;
    }
1184280
public function configure(\OtherCode\Rest\Core\Configuration $configuration = null)
    {
        if (isset($configuration)) {
            $this->configuration = $configuration;
        } else {
            $this->configuration = new \OtherCode\Rest\Core\Configuration();
        }
        $this->request->setHeaders($this->configuration->httpheader);
        return $this;
    }
667693
public function updateWorkspace($workspaceId = null, $data = ["name" => ""])
    {
        $workspaceId = $workspaceId ?: $this->defaultWorkspaceId;

        return $this->curl->put("workspaces/{$workspaceId}", ['data' => $data]);
    }
71383
public function registerToConfiguration(Configuration $configuration): ObjectInterface
    {
        $configuration->addConfigurationObject($this->className, $this);

        return $this;
    }
57693
public function createWorkspace(Workspace $workspace)
    {
        if (0 === count($workspace->getOrganizations())) {
            if (
                $this->container->get('security.token_storage')->getToken() &&
                $this->container->get('security.token_storage')->getToken()->getUser() instanceof User &&
                $this->container->get('security.token_storage')->getToken()->getUser()->getMainOrganization()
            ) {
                //we want a min organization
                $workspace->addOrganization($this->container->get('security.token_storage')->getToken()->getUser()->getMainOrganization());
                $this->om->persist($workspace);
                $this->om->flush();
            } else {
                $organizationManager = $this->container->get('claroline.manager.organization.organization_manager');
                $default = $organizationManager->getDefault();
                $workspace->addOrganization($default);
            }
        }

        $ch = $this->container->get('claroline.config.platform_config_handler');
        $workspace->setMaxUploadResources($ch->getParameter('max_upload_resources'));
        $workspace->setMaxStorageSize($ch->getParameter('max_storage_size'));
        $workspace->setMaxUsers($ch->getParameter('max_workspace_users'));
        $this->editWorkspace($workspace);

        return $workspace;
    }
105612
protected function fileFactory(array $configuration): File
	{
		return (new File($this->container->get(FileSystem::class), $configuration['path'], $this->classWhitelist))->setPrefix($configuration['prefix'] ?? '');
	}
1240634
public static function import($fileName, $config=[])
	{
		$config = ArrayHelper::merge(['mode' => 'import', 'fileName' => $fileName, 'asArray' => true], $config);
		return self::widget($config);
	}
1327961
protected function prepareBaseWorkspaceOptions(Workspace $excludedWorkspace = null)
    {
        $baseWorkspaceOptions = [];
        foreach ($this->workspaceRepository->findAll() as $workspace) {
            /** @var Workspace $workspace */
            if (!$workspace->isPersonalWorkspace() && $workspace !== $excludedWorkspace && ($workspace->isPublicWorkspace() || $workspace->isInternalWorkspace() || $this->userService->currentUserCanManageWorkspace($workspace))) {
                $baseWorkspaceOptions[$workspace->getName()] = $workspace->getTitle();
            }
        }

        return $baseWorkspaceOptions;
    }
472495
public function create(array $data, Workspace $workspace)
    {
        $options = [Options::LIGHT_COPY, Options::REFRESH_UUID];
        // gets entity from raw data.
        $workspace = $this->deserialize($data, $workspace, $options);

        // creates the entity if allowed
        $this->checkPermission('CREATE', $workspace, [], true);

        if ($this->dispatch('create', 'pre', [$workspace, $options])) {
            $this->om->save($workspace);
            $this->dispatch('create', 'post', [$workspace, $options]);
        }

        return $workspace;
    }
159747
public function create(Configuration $configuration, OutputInterface $output)
    {
        $this->symbolTable = new SymbolTable();

        $deprecationProgressOutput = new VerboseProgressOutput(
            new ProgressBar($output),
            $configuration->isVerbose(),
            'Deprecation detection'
        );
        $deprecationUsageParser = $this->getUsageParser($configuration);
        $deprecationUsageFinder = new ParsedPhpFileFinder(
            $deprecationUsageParser,
            $deprecationProgressOutput,
            new UsageFinderFactory()
        );

        $this->ancestorResolver = new AncestorResolver($deprecationUsageParser);

        $ruleSetProgressOutput = new VerboseProgressOutput(
            new ProgressBar($output),
            $configuration->isVerbose(),
            'RuleSet generation'
        );
        $ruleSetDeprecationParser = $this->getDeprecationParser();
        $ruleSetDeprecationFinder = new ParsedPhpFileFinder(
            $ruleSetDeprecationParser,
            $ruleSetProgressOutput,
            new DeprecationFinderFactory()
        );
        $deprecationDirectoryTraverser = new DirectoryTraverser($ruleSetDeprecationFinder);

        $violationDetector = $this->getViolationDetector($configuration);

        $renderer = $this->getRenderer($configuration, $output);

        $ruleSetLoader = $this->getRuleSetLoader($deprecationDirectoryTraverser, $configuration);

        $progressOutput = new DefaultProgressOutput($output, new Stopwatch());

        return new DeprecationDetector(
            $this->getPredefinedRuleSet(),
            $ruleSetLoader,
            $this->ancestorResolver,
            $deprecationUsageFinder,
            $violationDetector,
            $renderer,
            $progressOutput
        );
    }
1181132
public function build(Configuration $configuration, array $data): Definition
    {
        $name = $data['name'];
        unset($data['name']);
        $data['type'] = 'contao';

        return new DictionaryDefinition($name, $data);
    }
1220869
protected function mergeFileContent(string $pathAndFilename, array $configuration): array
    {
        if (!is_file($pathAndFilename)) {
            return $configuration;
        }

        try {
            $yaml = file_get_contents($pathAndFilename);
            if ($this->usePhpYamlExtension) {
                $loadedConfiguration = @yaml_parse($yaml);
                if ($loadedConfiguration === false) {
                    throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '".', 1391894094);
                }
            } else {
                $loadedConfiguration = Yaml::parse($yaml);
            }
            unset($yaml);

            if (is_array($loadedConfiguration)) {
                $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $loadedConfiguration);
            }
        } catch (Exception $exception) {
            throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '". Error message: ' . $exception->getMessage(), 1232014321);
        }

        return $configuration;
    }
1243196
private function getViolationDetector(Configuration $configuration)
    {
        $violationChecker = $this->getViolationChecker($configuration);
        $violationFilter = $this->getViolationFilter($configuration);

        return new ViolationDetector(
            $violationChecker,
            $violationFilter
        );
    }
620517
public function build(ImportConfiguration $importConfiguration, StorageInterface $sourceStorage = null, $createdBy = null, $requestContext = null)
    {
        $importer = $this->importerRepository->get($importConfiguration->getImporterId());
        if ($importer->getSourceStorage()) {
            $sourceStorage = $importer->getSourceStorage();
        } elseif (!$sourceStorage) {
            throw new InvalidConfigurationException("Either the importRequest or the importer '".$importConfiguration->getImporterId()."' must have a source storage set.");
        }

        $importRun = $importConfiguration->toRun($createdBy);

        //apply static context from importer & request
        $context = $requestContext;
        if (!is_null($importer->getContext()) && !empty($importer->getContext())) {
            $importerContext = $importer->getContext();
            if ($importerContext && $requestContext) {
                $context = array_merge($importerContext, $requestContext);
            } else {
                $context = $importerContext;
            }
        }
        $importRun->setContext($context);

        $import = $this->factorImport($importer, $sourceStorage, $importRun);

        //after everthing was build, apply softdata from sourcestorage to importrun
        //dont do this any earlier, as there might be AFTER_BUILD hooks, that may change
        //the sourcestorage configuration
        $importRun->setInfo((array) $sourceStorage->info());

        return $import;
    }
490528
protected function buildCacheTags(array $configuration, $fusionPath, $fusionObject)
    {
        $cacheTags = [];
        if (isset($configuration['entryTags'])) {
            foreach ($configuration['entryTags'] as $tagKey => $tagValue) {
                $tagValue = $this->runtime->evaluate($fusionPath . '/__meta/cache/entryTags/' . $tagKey, $fusionObject);
                if (is_array($tagValue)) {
                    $cacheTags = array_merge($cacheTags, $tagValue);
                } elseif ((string)$tagValue !== '') {
                    $cacheTags[] = $tagValue;
                }
            }
            foreach ($this->flushTags() as $tagKey => $tagValue) {
                $cacheTags[] = $tagValue;
            }
        } else {
            $cacheTags = [ContentCache::TAG_EVERYTHING];
        }
        return array_unique($cacheTags);
    }