/**
  * This action is called when a form has been submitted to create a new
  * site.
  *
  * It will get all the information needed to duplicate the model site, and
  * further: management of uploaded files, constants management, etc.
  */
 public function processCopyAction()
 {
     $cacheToken = $this->request->getArgument('duplicationToken');
     $cache = CacheManager::getCacheInstance(CacheManager::CACHE_PROCESSED);
     $cacheData = $cache->get($cacheToken);
     // @todo: manage wrong token or wrong cacheData
     $cacheData = json_decode($cacheData, true);
     // Check if the process is a modification of an already duplicated site.
     $modifySite = null;
     if ($this->request->hasArgument('modifySite') && Core::checkUidIsSavedSite($this->request->getArgument('modifySite'))) {
         $modifySite = $this->request->getArgument('modifySite');
         $cacheData['duplicationData']['modelPageUid'] = $cacheData['fieldsValues']['modelSite'];
         $cacheData['duplicationData']['modifySite'] = $modifySite;
         $cacheData['duplicationData']['duplicatedPageUid'] = $modifySite;
         /** @var Save $savedSite */
         $savedSite = $this->saveRepository->findLastByRootPageUid($modifySite);
         $cacheData['savedSite'] = $savedSite->getConfiguration();
     } else {
         $cacheData['duplicationData']['modelPageUid'] = $cacheData['fieldsValues']['modelSite'];
         $cacheData['duplicationData']['copyDestination'] = Core::getExtensionConfiguration('copyDestination');
     }
     // Saving modified data in cache.
     $cache->set($cacheToken, json_encode($cacheData));
     $this->view->assign('duplicationToken', $cacheToken);
     $siteModificationToken = $modifySite ? true : false;
     $duplicationConfiguration = AbstractDuplicationProcess::getCleanedDuplicationConfiguration($cacheData['duplicationData']['modelPageUid'], $siteModificationToken);
     $this->view->assign('duplicationConfiguration', $duplicationConfiguration);
     $this->view->assign('duplicationConfigurationJSON', addslashes(json_encode(array_keys($duplicationConfiguration))));
 }