Handle a request going to our plugin's import URL,
e.g.: actions/architect/cp/import

@return mixed
960875
public function actionImport()
    {
        $filename = Architect::$configPath . DIRECTORY_SEPARATOR . Craft::$app->request->getQueryParam('file');
        $fileContents = '';
        if (is_file($filename)) {
            $fileContents = file_get_contents($filename);
        }
        return $this->renderTemplate('architect/import', [ 'importData' => $fileContents, 'invalidJSON' => false ]);
    }
456321
private function routing()
    {
        // import.
        $file = $this->app->getLoader()->findFirst($this->app->config('directory.config.routing') . DS . 'routes.yml');
        $this->router->import($file);

        // routing.
        $rule = $this->router->routing();
        $this->request->import($rule->getParams());

        // add action chain.
        $this->actionChain->addAction($rule->getController(), $rule->getAction());
    }
211331
public function routeRequest()
	{
		if($this->bound('router')){
			try {
				$pluginRequest = $this['request'];
				$this['router']->matched(function ($event) {
					global $wp_query;
					$wp_query->is_404 = false;
					$this->route_dispatched = true;
				});
				$response = $this['router']->dispatch($pluginRequest);
				if ($route = $pluginRequest->route()) {
					foreach ($route->computedMiddleware as $middleware) {
						$instance = $this->make($middleware);
						if (method_exists($instance, 'terminate')) {
							$instance->terminate($pluginRequest, $response);
						}
					}
				}
				if($this->bound('session')) {
					$this['session']->save();
				}
				$response->send();
				exit;
			}catch (\Exception $e) {
				$this->reportException($e);
				$this->renderException($pluginRequest, $e);
			} catch (\Throwable $e) {
				$this->reportException($e = new FatalThrowableError($e));
				$this->renderException($pluginRequest, $e);
			}
		}
	}
1147443
public function process()
	{
		$context = $this->getContext();

		try
		{
			$view = $this->getView();
			$id = $view->param( 'dl_id' );

			/** client/html/account/download/error/url/target
			 * Destination of the URL to redirect the customer if the file download isn't allowed
			 *
			 * The destination can be a page ID like in a content management system or the
			 * module of a software development framework. This "target" must contain or know
			 * the controller that should be called by the generated URL.
			 *
			 * @param string Destination of the URL
			 * @since 2019.04
			 * @category Developer
			 */
			$target = $context->getConfig()->get( 'client/html/account/download/error/url/target' );

			if( $this->checkAccess( $id ) === false ) {
				return $view->response()->withStatus( 401 )->withHeader( 'Location', $view->url( $target ) );
			}

			$manager = \Aimeos\MShop::create( $context, 'order/base/product/attribute' );
			$item = $manager->getItem( $id );

			if( $this->checkDownload( $id ) === false ) {
				return $view->response()->withStatus( 403 )->withHeader( 'Location', $view->url( $target ) );
			} else {
				$this->addDownload( $item );
			}

			parent::process();
		}
		catch( \Exception $e )
		{
			$this->logException( $e );
		}
	}
183971
protected function handleRequest()
    {
        try {
            $request = $this->getRequest();
            if ($request->isParseError() === true) {
                throw new ParseErrorException();
            }
            $this->events->trigger('sendRequest.pre', $this, array('methode' => $request->getMethod()));
            if (($ret = $this->getParentHandle()) instanceof RPCERROR && ($ret = $ret->getData()) instanceof \Exception) {
                throw $ret;
            }
        } catch (AbstractException $e) {
            if(isset($this->options['log'])) {
                $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage());
            }
            return $this->fault($e->getMessage(), $e->getCode());
        } catch (\Exception $e) {
            if(isset($this->options['log'])) {
                $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getTrace());
            }
            return ((isset($this->options['environment']) && $this->options['environment'] === "dev")) ? $this->fault('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getCode(), $e->getTrace()) : $this->fault('Internal error', RPCERROR::ERROR_INTERNAL);
        }
    }
1222191
public static function handleRequest() {
        $response = get_response();
        try {
            $routes = self::$routes->getRoutes();
            if (!empty($routes)) {
                $beforeRoutes = self::$beforeRoutes->getRoutes();
                if (!empty($beforeRoutes)) {
                    foreach ($beforeRoutes as $beforeRoute) {
                        self::executeAction($beforeRoute->getAction(), array_merge($_REQUEST, $beforeRoute->getParameters()));
                    }
                }

                try {
                    foreach ($routes as $route) {
                        $routeResult = self::executeAction($route->getAction(), array_merge($_REQUEST, $route->getParameters()));
                        if (isset($routeResult)) {
                            $response->content($routeResult);
                        }
                    }
                    $afterRoutes = self::$afterRoutes->getRoutes();
                    if (!empty($afterRoutes)) {
                        foreach ($afterRoutes as $afterRoute) {
                            $routeResult = self::executeAction($afterRoute->getAction(), array_merge($_REQUEST, $afterRoute->getParameters()));
                            if (isset($routeResult)) {
                                $response->content($routeResult);
                            }
                        }
                    }
                    $response->send();
                }
                catch (ActionNotFoundException $notFoundException) {
                    self::handleRequestNotFound();
                }
            }
            else {
                self::handleRequestNotFound();
            }
        }
        catch (Throwable $ex) {
            self::handleRequestException($ex);
        }
    }
1302358
public function importAction()
    {
        /* @var $form \Zork\Form\Form */
        $request        = $this->getRequest();
        $serviceLocator = $this->getServiceLocator();
        $returnUri      = $request->getQuery( 'returnUri' );
        $return         = $this->getValidReturnUri( $returnUri );
        $form           = $serviceLocator->get( 'Form' )
                                         ->get( 'Grid\Customize\Import' );

        if ( $request->isPost() )
        {
            $form->setData( $data = ArrayUtils::merge(
                $request->getPost()
                        ->toArray(),
                $request->getFiles()
                        ->toArray()
            ) );

            if ( ! empty( $data['returnUri'] ) )
            {
                $return = $this->getValidReturnUri(
                    $data['returnUri'],
                    $return
                );
            }

            if ( $form->isValid() )
            {
                $data       = $form->getData();
                $file       = $data['file']['tmp_name'];
                $name       = $data['file']['name'];
                $translator = $serviceLocator->get( 'translator' );
                $result     = $serviceLocator->get( 'Grid\Customize\Model\Importer' )
                                             ->import( $file, $name );

                if ( $result->isSuccess() )
                {
                    $this->messenger()
                         ->add(
                             sprintf(
                                 $translator->translate( 'customize.import.success.link.%s' ),
                                 $this->url()
                                      ->fromRoute( 'Grid\Paragraph\Render\Paragraph', array(
                                          'locale'        => (string) $this->locale(),
                                          'paragraphId'   => $result->getCreatedParagraphId(),
                                      ) )
                             ),
                             false,
                             Message::LEVEL_INFO
                         );
                }
                else
                {
                    $code = $result->getCode();

                    if ( ! isset( static::$importErrorMessages[$code] ) )
                    {
                        $code = ImportResult::UNKNOWN_ERROR;
                    }

                    $this->messenger()
                         ->add(
                             sprintf(
                                 $translator->translate( 'customize.import.failed.message.%s.%s' ),
                                 $translator->translate( static::$importErrorMessages[$code] ),
                                 $result->getErrorMessage()
                             ),
                             false,
                             Message::LEVEL_ERROR
                         );
                }

                if ( $return )
                {
                    return $this->redirect()
                                ->toUrl( $return );
                }
                else if ( $result->isSuccess() )
                {
                    return $this->redirect()
                                ->toRoute( 'Grid\Customize\CssAdmin\List', array(
                                    'locale' => (string) $this->locale(),
                                ) );
                }
            }
        }
        else if ( $return )
        {
            $form->get( 'returnUri' )
                 ->setValue( $return );
        }

        $form->setCancel(
            $return ? $return
                    : $this->url()
                           ->fromRoute( 'Grid\Customize\CssAdmin\List', array(
                               'locale' => (string) $this->locale(),
                           ) )
        );

        return array(
            'form' => $form,
        );
    }
393233
protected function handleRequest()
    {
        $this->call('received', array($this->input));
        
        if ($this->input->get('MsgType') && $this->input->get('MsgType') === 'event') {
            return $this->handleEvent($this->input);
        } elseif ($this->input->get('MsgId')) {
            return $this->handleMessage($this->input);
        }

        return false;
    }
880569
public function handleRename() {
		$id = $this->request->getQuery("id");
		$newName = $this->request->getQuery("newName");
		$token = $this->request->getQuery("token");
		
		$cache = $this->uploadControl->getCache();
		/** @noinspection PhpInternalEntityUsedInspection */
		$cacheFiles = $cache->load($this->uploadControl->getTokenizedCacheName($token));
		
		if(isset($cacheFiles[ $id ])) {
			/** @noinspection PhpInternalEntityUsedInspection */
			$cacheFiles[ $id ] = $this->uploadControl->getUploadModel()->rename($cacheFiles[ $id ], $newName);
			/** @noinspection PhpInternalEntityUsedInspection */
			$cache->save($this->uploadControl->getTokenizedCacheName($token), $cacheFiles);
		}
	}
80997
public function handle()
    {
        switch (strtolower($_SERVER['QUERY_STRING'])){
        case 'wsdl':
            $this->intoStruct();
            $this->handleWSDL();
            break;
        case 'disco':
            $this->intoStruct();
            $this->handleDISCO();
            break;
        default:
            $this->intoStruct();
            if (isset($_SERVER['HTTP_SOAPACTION'])) {
                $this->createServer();
            } elseif (isset($_REQUEST['svc'])) {
               	$this->handleHTTP(); // by JG
            } else {
                $this->handleINFO();
            }
            break;
        }
    }
951543
protected function handleGET()
    {
        $resources = $this->getResources();
        if (is_array($resources)) {
            $includeAccess = $this->request->getParameterAsBool(ApiOptions::INCLUDE_ACCESS);
            $asList = $this->request->getParameterAsBool(ApiOptions::AS_LIST);
            $idField = $this->request->getParameter(ApiOptions::ID_FIELD, static::getResourceIdentifier());
            $fields = $this->request->getParameter(ApiOptions::FIELDS);
            if (!$asList && $includeAccess) {
                foreach ($resources as &$resource) {
                    if (is_array($resource)) {
                        $name = array_get($resource, $idField);
                        $resource['access'] =
                            VerbsMask::maskToArray($this->getPermissions($name));
                    }
                }
            }

            return ResourcesWrapper::cleanResources($resources, $asList, $idField, $fields);
        }

        return $resources;
    }
465557
private function handleHTTP()
    {
    	try
    	{
			$method = new ReflectionMethod($this->classname, $_REQUEST["svc"]);
    	}
    	catch (Exception $ex)
    	{
    		echo '{ error: "Method does not exists" }';
    		exit;
    	}
		if (!$method->isPublic())
		{
    		echo '{ error: "Method is not public" }';
			exit;
		}

		$params = $method->getParameters();
		$paramValues = array();
		$missingParams = array();
		foreach ($params as $param)
		{
			$paramName = $param->getName();
			$paramValue = ( isset($_REQUEST[$paramName]) ? $_REQUEST[$paramName] : null);
			if (is_null($paramValue) && $param->isDefaultValueAvailable())
			{
				$paramValue = $param->getDefaultValue();
			}
			if (is_null($paramValue))
			{
				$missingParams[] = $paramName;
			}
			else
			{
				$paramValues[$paramName] = $paramValue;
			}
		}
		if (count($missingParams) > 0)
		{
			echo '{ error: "Missing params", parameters: [ "' . implode('","', $missingParams) . '"] }';
		}
		else
		{
			try
			{
				$result = $method->invokeArgs($this, $paramValues);
				if (is_array($result))
				{
					echo json_encode($result);
				}
				elseif (is_object($result))
				{
					echo '{ error: "Return type is not supported" } ';
				}
				else
				{
					echo $result;
				}
			}
			catch (Exception $ex)
			{
				echo '{ error: "' . $ex->getMessage() . '" }';
			}
		}
    }
460184
protected function sniffAction()
    {

        ///// insert /////
        if (Request::isMethod('post') && $this->url->value('insert' . $this->cid)) {
            $this->action = "insert";
            ///// update /////
        } elseif (Request::isMethod('patch') && $this->url->value('update' . $this->cid)) {
            $this->action = "update";
            $this->process_url = $this->url->append('update', $this->url->value('update' . $this->cid))->get();
            if (!$this->find($this->url->value('update' . $this->cid))) {
                $this->status = "unknow_record";
            }
            ///// delete /////
        } elseif (Request::isMethod('delete') && $this->url->value("do_delete" . $this->cid)) {
            $this->action = "delete";
            if (!$this->find($this->url->value("do_delete" . $this->cid))) {
                $this->status = "unknow_record";
            }
        }
    }
1002363
public function importAction($plugin, Request $request)
    {
        /* @var $chain ChainSearch */
        $chain = $this->get('anime_db.plugin.import');
        /* @var $import ImportInterface */
        if (!($import = $chain->getPlugin($plugin))) {
            throw $this->createNotFoundException('Plugin \''.$plugin.'\' is not found');
        }

        $form = $this->createForm($import->getForm())->handleRequest($request);

        $list = [];
        if ($form->isValid()) {
            // import items
            $list = (array) $import->import($form->getData());

            // persist entity
            $em = $this->getDoctrine()->getManager();
            foreach ($list as $key => $item) {
                if ($item instanceof Item) {
                    $em->persist($item);
                } else {
                    unset($list[$key]);
                }
            }
        }

        return $this->render('AnimeDbCatalogBundle:Item:import.html.twig', [
            'plugin' => $plugin,
            'items' => $list,
            'form' => $form->createView(),
        ]);
    }
1135439
protected function handlePOST()
    {
        $extract = $this->request->getParameterAsBool('extract', false);
        $clean = $this->request->getParameterAsBool('clean', false);
        $checkExist = $this->request->getParameterAsBool('check_exist', false);

        if (empty($this->filePath)) {
            $fileNameHeader = str_to_utf8($this->request->getHeader('X-File-Name'));
            $folderNameHeader = str_to_utf8($this->request->getHeader('X-Folder-Name'));
            $fileUrl = filter_var($this->request->getParameter('url', ''), FILTER_SANITIZE_URL);

            if (!empty($fileNameHeader)) {
                // html5 single posting for file create
                $result = $this->handleFileContent(
                    $this->folderPath,
                    $fileNameHeader,
                    $this->request->getContent(),
                    $this->request->getContentType(),
                    $extract,
                    $clean,
                    $checkExist
                );
            } elseif (!empty($folderNameHeader)) {
                // html5 single posting for folder create
                $fullPathName = $this->folderPath . $folderNameHeader;
                $content = $this->request->getPayloadData();
                $this->driver->createFolder($this->container, $fullPathName, $content);
                $result = ['name' => $folderNameHeader, 'path' => $fullPathName];
            } elseif (!empty($fileUrl)) {
                // upload a file from a url, could be expandable zip
                $tmpName = null;
                $newFileName = $this->request->input('filename', '');
                try {
                    $tmpName = FileUtilities::importUrlFileToTemp($fileUrl);
                    $result = $this->handleFile(
                        $this->folderPath,
                        $newFileName,
                        $tmpName,
                        '',
                        $extract,
                        $clean,
                        $checkExist
                    );
                    @unlink($tmpName);
                } catch (\Exception $ex) {
                    if (!empty($tmpName)) {
                        @unlink($tmpName);
                    }
                    throw $ex;
                }
            } elseif (null !== $uploadedFiles = $this->request->getFile('files')) {
                if (Arr::isAssoc($uploadedFiles)) { //Single file upload
                    $uploadedFiles = [$uploadedFiles];
                }
                $result = $this->handleFolderContentFromFiles($uploadedFiles, $extract, $clean, $checkExist);
                $result = ResourcesWrapper::cleanResources($result);
            } else {
                // possibly xml or json post either of files or folders to create, copy or move
                if (!empty($data = ResourcesWrapper::unwrapResources($this->getPayloadData()))) {
                    $result = $this->handleFolderContentFromData($data, $extract, $clean, $checkExist);
                    $result = ResourcesWrapper::cleanResources($result);
                } else {
                    // create folder from resource path
                    $this->driver->createFolder($this->container, $this->folderPath);
                    $result = ['name' => basename($this->folderPath), 'path' => $this->folderPath];
                }
            }
        } else {
            // create the file
            // possible file handling parameters
            $name = basename($this->filePath);
            $path = (false !== strpos($this->filePath, '/')) ? dirname($this->filePath) : '';
            $files = $this->request->getFile('files');

            if (empty($files)) {
                // direct load from posted data as content
                // or possibly xml or json post of file properties create, copy or move
                $result = $this->handleFileContent(
                    $path,
                    $name,
                    $this->request->getContent(),
                    $this->request->getContentType(),
                    $extract,
                    $clean,
                    $checkExist
                );
            } else {
                if (Arr::isAssoc($files)) { // Single file upload
                    $files = [$files];
                }
                if (1 < count($files)) {
                    throw new BadRequestException("Multiple files uploaded to a single REST resource '$name'.");
                }
                $file = array_get($files, 0);
                if (empty($file)) {
                    throw new BadRequestException("No file uploaded to REST resource '$name'.");
                }
                $error = $file['error'];
                if (UPLOAD_ERR_OK == $error) {
                    $result = $this->handleFile(
                        $path,
                        $name,
                        $file["tmp_name"],
                        $file['type'],
                        $extract,
                        $clean,
                        $checkExist
                    );
                } else {
                    throw new InternalServerErrorException("Failed to upload file $name.\n$error");
                }
            }
        }

        return ResponseFactory::create($result, null, ServiceResponseInterface::HTTP_CREATED);
    }
1036202
public function importAction($id)
    {
        /** @var \Thelia\Handler\Importhandler $importHandler */
        $importHandler = $this->container->get('thelia.import.handler');

        $import = $importHandler->getImport($id);
        if ($import === null) {
            return $this->pageNotFound();
        }

        $form = $this->createForm(AdminForm::IMPORT);

        try {
            $validatedForm = $this->validateForm($form);

            /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */
            $file = $validatedForm->get('file_upload')->getData();
            $file = $file->move(
                THELIA_CACHE_DIR . 'import' . DS . (new\DateTime)->format('Ymd'),
                uniqid() . '-' . $file->getClientOriginalName()
            );

            $lang = (new LangQuery)->findPk($validatedForm->get('language')->getData());

            $importEvent = $importHandler->import($import, $file, $lang);

            if (\count($importEvent->getErrors()) > 0) {
                $this->getSession()->getFlashBag()->add(
                    'thelia.import.error',
                    $this->getTranslator()->trans(
                        'Error(s) in import&nbsp;:<br />%errors',
                        [
                            '%errors' => implode('<br />', $importEvent->getErrors())
                        ]
                    )
                );
            }

            $this->getSession()->getFlashBag()->add(
                'thelia.import.success',
                $this->getTranslator()->trans(
                    'Import successfully done, %count row(s) have been changed',
                    [
                        '%count' => $importEvent->getImport()->getImportedRows()
                    ]
                )
            );

            return $this->generateRedirectFromRoute('import.view', [], ['id' => $id]);
        } catch (FormValidationException $e) {
            $form->setErrorMessage($this->createStandardFormValidationErrorMessage($e));
        } catch (\Exception $e) {
            $this->getParserContext()->setGeneralError($e->getMessage());
        }

        $this->getParserContext()
            ->addForm($form)
        ;

        return $this->configureAction($id);
    }
278558
protected function buildPluginRequest()
    {
        /** @var $parentRequest ActionRequest */
        $parentRequest = $this->runtime->getControllerContext()->getRequest();
        $pluginRequest = new ActionRequest($parentRequest);
        $pluginRequest->setArgumentNamespace('--' . $this->getPluginNamespace());
        $this->passArgumentsToPluginRequest($pluginRequest);

        if ($this->node instanceof NodeInterface) {
            $pluginRequest->setArgument('__node', $this->node);
            if ($pluginRequest->getControllerPackageKey() === null) {
                $pluginRequest->setControllerPackageKey($this->node->getProperty('package') ?: $this->getPackage());
            }
            if ($pluginRequest->getControllerSubpackageKey() === null) {
                $pluginRequest->setControllerSubpackageKey($this->node->getProperty('subpackage') ?: $this->getSubpackage());
            }
            if ($pluginRequest->getControllerName() === null) {
                $pluginRequest->setControllerName($this->node->getProperty('controller') ?: $this->getController());
            }
            if ($pluginRequest->getControllerActionName() === null) {
                $actionName = $this->node->getProperty('action');
                if ($actionName === null || $actionName === '') {
                    $actionName = $this->getAction() !== null ? $this->getAction() : 'index';
                }
                $pluginRequest->setControllerActionName($actionName);
            }

            $pluginRequest->setArgument('__node', $this->node);
            $pluginRequest->setArgument('__documentNode', $this->documentNode);
        } else {
            $pluginRequest->setControllerPackageKey($this->getPackage());
            $pluginRequest->setControllerSubpackageKey($this->getSubpackage());
            $pluginRequest->setControllerName($this->getController());
            $pluginRequest->setControllerActionName($this->getAction());
        }

        foreach ($this->properties as $key => $value) {
            $pluginRequest->setArgument('__' . $key, $this->fusionValue($key));
        }
        return $pluginRequest;
    }