Sets the applicable format to the HttpFoundation Request.

@throws AccessDeniedException
175466
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        if (!$attributes = RequestAttributesExtractor::extractAttributes($request)) {
            return;
        }

        $resourceMetadata = $this->resourceMetadataFactory->create($attributes['resource_class']);

        $isGranted = $resourceMetadata->getOperationAttribute($attributes, 'access_control', null, true);

        if (null === $isGranted) {
            return;
        }

        $extraVariables = $request->attributes->all();
        $extraVariables['object'] = $request->attributes->get('data');
        $extraVariables['request'] = $request;

        if (!$this->resourceAccessChecker->isGranted($attributes['resource_class'], $isGranted, $extraVariables)) {
            throw new AccessDeniedException($resourceMetadata->getOperationAttribute($attributes, 'access_control_message', 'Access Denied.', true));
        }
    }
1250328
public function adminWorkspaceTagCreateFormAction()
    {
        if (!$this->authorization->isGranted('ROLE_ADMIN')) {
            throw new AccessDeniedException();
        }
        $workspaceTag = new WorkspaceTag();
        $form = $this->formFactory->create(
            FormFactory::TYPE_ADMIN_WORKSPACE_TAG,
            array(),
            $workspaceTag
        );

        return array('form' => $form->createView());
    }
1348454
public void setDisplayFormat(DisplayFormat format) {
        getStorageHandler().getStorageEngine().setConfigEntry("longmode", format.toString());
        displayFormat = format;
    }
254942
public void setAccess(String access) {
        if ("public".equals(access)) publicScope = true;
        else if ("protected".equals(access)) protectedScope = true;
        else if ("package".equals(access)) packageScope = true;
        else if ("private".equals(access)) privateScope = true;
    }
856153
public function refreshListAction(Request $request)
    {
        if (false === $this->admin->checkAccess('list')) {
            throw new AccessDeniedException();
        }
        $galleryListMode = $request->get('pcode') ? true : false;
        $datagrid = $this->admin->getDatagrid();
        $datagrid->getForm()->createView();
        $persistentParameters = $this->admin->getPersistentParameters();

        $tags = $this->getDoctrine()
            ->getRepository(Tag::class)
            ->createQueryBuilder('t')
            ->select('t', 'c')
            ->leftJoin('t.children', 'c') // preload
            ->orderBy('t.path', 'ASC')
            ->getQuery()->getResult();

        $tagAdmin = $this->get('networking_init_cms.admin.tag');

        return $this->render(
            '@NetworkingInitCms/MediaAdmin/list_items.html.twig',
            [
                'providers' => $this->get('sonata.media.pool')->getProvidersByContext(
                    $request->get('context', $persistentParameters['context'])
                ),
                'tags' => $tags,
                'tagAdmin' => $tagAdmin,
                'lastItem' => 0,
                'action' => 'list',
                'datagrid' => $datagrid,
                'galleryListMode' => $galleryListMode,
                'show_actions' => true,
            ]
        );
    }
445357
public void updateStreamPresets(UpdateStreamPresetsRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");

        checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty.");
        checkStringNotEmpty(request.getApp(), "App should NOT be empty");
        checkStringNotEmpty(request.getStream(), "Stream should NOT be empty.");
        // presets can be null for letting stream to use domain's presets,
        // so no need to check if presets is null

        InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, LIVE_DOMAIN,
                request.getDomain(), LIVE_APP, request.getApp(), LIVE_STREAM, request.getStream());
        internalRequest.addParameter("presets", null);
        invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }
955740
public function blockIllegalRequests(ActionRequest $request)
    {
        $filterMatched = array_reduce($this->filters, function (bool $filterMatched, RequestFilter $filter) use ($request) {
            return ($filter->filterRequest($request) ? true : $filterMatched);
        }, false);

        if ($this->rejectAll && !$filterMatched) {
            throw new AccessDeniedException('The request was blocked, because no request filter explicitly allowed it.', 1216923741);
        }
    }
1353983
@Override
    public T setApplicationXML(File resource) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource must be specified");
        return setApplicationXML(new FileAsset(resource));
    }
951694
public void setFormat(AnalyticsS3ExportFileFormat format) {
        if (format == null) {
            setFormat((String) null);
        } else {
            setFormat(format.toString());
        }
    }
1028760
public void setFileHeader(/* @Nullable */ JvmDeclaredType jvmDeclaredType, /* @Nullable */ String headerText) {
		if (jvmDeclaredType == null || headerText == null) {
			return;
		}
		FileHeaderAdapter fileHeaderAdapter = (FileHeaderAdapter) EcoreUtil.getAdapter(jvmDeclaredType.eAdapters(),
				FileHeaderAdapter.class);
		if (fileHeaderAdapter == null) {
			fileHeaderAdapter = new FileHeaderAdapter();
			jvmDeclaredType.eAdapters().add(fileHeaderAdapter);
		}
		fileHeaderAdapter.setHeaderText(headerText);
	}
1059469
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();

        if ($request->attributes->get(SetIsAdminRequestListener::ADMIN_FLAG_NAME) !== true) {
            return;
        }

        if ($this->csrfTokenValidator->validateCsrfToken($request, $this->csrfTokenId)) {
            return;
        }

        throw new AccessDeniedHttpException('Missing or invalid CSRF token');
    }
580326
private void appendRequestParam(FastStringWriter actualUriBuf, Object name,
            Object value, String encoding) {

        if (value == null) {
            value = "";
        }

        actualUriBuf.append(urlEncode(name, encoding))
                    .append('=')
                    .append(urlEncode(value, encoding));
    }
1270163
public function uploadAction(Request $request, $type = 'image')
    {
        $this->checkIfMediaBundleIsLoaded();

        if (false === $this->admin->checkAccess('CREATE')) {
            throw new AccessDeniedException();
        }

	    /** @var $mediaAdmin \Sonata\MediaBundle\Admin\ORM\MediaAdmin */
	    $mediaAdmin = $this->container->get('sonata.media.admin.media');

	    $mediaAdmin->setRequest($request);

        $provider = $request->get('provider');
        $file = $request->files->get('upload');

	    $message = $this->admin->trans(
		    'The file is not readable.',[], 'validators'
	    );
	    $response = ['uploaded' => 0, 'error'  => ['message' =>  $message]];


        if (!$provider || null === $file) {
	        return new JsonResponse($response);
        }

        if ($file instanceof UploadedFile && $file->isValid()) {

            try {
                $context = $request->get('context', $this->get('sonata.media.pool')->getDefaultContext());

	            /** @var Media $media */
	            $media = $mediaAdmin->getNewInstance();
	            $media->setEnabled(true);
	            $media->setName($file->getClientOriginalName());
                $media->setBinaryContent($file);
                $media->setContext($context);
                $media->setProviderName($provider);


	            $provider = $mediaAdmin->getPool()->getProvider($provider);

	            $provider->transform($media);

	            $validator = $this->container->get('validator');

	            $errors = $validator->validate($media);

	            if ($errors->count() > 0) {
		            $duplicate = false;
		            foreach ($errors as $error) {
			            $errorMessages[] = $error->getMessage();

			            if ($error->getMessage() == 'File is duplicate') {
				            $duplicate = true;
			            }
		            }

		            if ($duplicate) {
			            $originalMedia = $mediaAdmin->checkForDuplicate($media);
			            $path = $provider->generatePublicUrl($originalMedia, 'reference');
			            $response = [
			            	'uploaded' => 1,
				            'fileName' => $originalMedia->getMetadataValue('filename'),
				            'url' => $path,
				            'error'  => ['message' => 'duplicate media']];
		            }else{
			            $response = ['uploaded' => 0, 'error'  => ['message' =>  implode(', ', $errorMessages)]];
		            }

		            return new JsonResponse($response);
	            }

	            try {
		            $mediaAdmin->create($media);
		            $path = $provider->generatePublicUrl($media, 'reference');
                    $response = ['uploaded' => 1, 'fileName' => $media->getMetadataValue('filename'), 'url' => $path ];
	            } catch (\Exception $e) {
		            $response = ['uploaded' => 0, 'error'  => ['message' => $e->getMessage()]];
	            }

            } catch (\Exception $e) {

	            $response = ['uploaded' => 0, 'error'  => ['message' => $e->getMessage()]];
            } catch (\Throwable $e) {
	            $response = ['uploaded' => 0, 'error'  => ['message' => $e->getMessage()]];
            }
        } elseif ($file instanceof UploadedFile && !$file->isValid()) {

	        $response = ['uploaded' => 0, 'error'  => ['message' =>  $file->getError()]];
        } else {
            $message = $this->admin->trans(
                'error.file_upload_size',
                ['%max_server_size%' => ini_get('upload_max_filesize')], 'media'
            );

	        $response = ['uploaded' => 0, 'error'  => ['message' =>  $message]];
        }

        return new JsonResponse($response);
    }
1142702
public void setReadAccess(String userId, boolean allowed) {
    if (StringUtil.isEmpty(userId)) {
      throw new IllegalArgumentException("cannot setRead/WriteAccess for null userId");
    }
    boolean writePermission = getWriteAccess(userId);
    setPermissionsIfNonEmpty(userId, allowed, writePermission);
  }
281145
public function setFieldValue(User $user, FieldFacet $field, $value, $force = false)
    {
        if (!$this->authorization->isGranted('edit', new FieldFacetCollection([$field], $user)) && !$force) {
            throw new AccessDeniedException();
        }

        $fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue')
            ->findOneBy(['user' => $user, 'fieldFacet' => $field]);

        if (null === $fieldFacetValue) {
            $fieldFacetValue = new FieldFacetValue();
            $fieldFacetValue->setUser($user);
            $fieldFacetValue->setFieldFacet($field);
        }

        switch ($field->getType()) {
            case FieldFacet::DATE_TYPE:
                $date = is_string($value) ?
                    new \DateTime($value) :
                    $value;
                $fieldFacetValue->setDateValue($date);
                break;
            case FieldFacet::NUMBER_TYPE:
                $fieldFacetValue->setFloatValue($value);
                break;
            case FieldFacet::CHOICE_TYPE:
                $options = $field->getOptions();

                if (isset($options['multiple']) && $options['multiple']) {
                    $fieldFacetValue->setArrayValue($value);
                } else {
                    $fieldFacetValue->setStringValue($value);
                }
                break;
            case FieldFacet::CASCADE_TYPE:
                $fieldFacetValue->setArrayValue($value);
                break;
            default:
                $fieldFacetValue->setStringValue($value);
        }

        $this->om->persist($fieldFacetValue);
        $this->om->flush();
    }
1311451
public function setFieldValue(User $user, FieldFacet $field, $value, $force = false)
    {
        if (!$this->authorization->isGranted('edit', $field) && !$force) {
            throw new AccessDeniedException();
        }

        $fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue')
            ->findOneBy(array('user' => $user, 'fieldFacet' => $field));

        if ($fieldFacetValue === null) {
            $fieldFacetValue = new FieldFacetValue();
            $fieldFacetValue->setUser($user);
            $fieldFacetValue->setFieldFacet($field);
        }

        switch ($field->getType()) {
            case FieldFacet::DATE_TYPE:
                $date = is_string($value) ?
                    \DateTime::createFromFormat(
                        $this->translator->trans('date_form_datepicker_php', array(), 'platform'),
                        $value
                    ):
                    $value;
                $fieldFacetValue->setDateValue($date);
                break;
            case FieldFacet::FLOAT_TYPE:
                $fieldFacetValue->setFloatValue($value);
                break;
            case FieldFacet::STRING_TYPE:
                $fieldFacetValue->setStringValue($value);
                break;
            default:
                throw new \Exception('The facet type ' . $field->getType() . ' is unknown.');
        }

        $this->om->persist($fieldFacetValue);
        $this->om->flush();
    }
1136281
function setAccessEntry() {
      if (name && accessEntry.names) accessEntry.names.push(name);
      else accessEntry.names = null;
    }