getInt example

try {
  Settings::initialize(dirname(__DIR__), DrupalKernel::findSitePath($request)$autoloader);
}
catch (HttpExceptionInterface $e) {
  $response = new Response('', $e->getStatusCode());
  $response->prepare($request)->send();
  exit;
}

if (Settings::get('rebuild_access', FALSE) ||
  ($request->query->get('token') && $request->query->get('timestamp') &&
    (($request->server->getInt('REQUEST_TIME') - $request->query->get('timestamp')) < 300) &&
    hash_equals(Crypt::hmacBase64($request->query->get('timestamp'), Settings::get('hash_salt'))$request->query->get('token'))
  )) {
  // Clear user cache for all major platforms.   $user_caches = [
    'apcu_clear_cache',
    'wincache_ucache_clear',
  ];
  array_map('call_user_func', array_filter($user_caches, 'is_callable'));

  drupal_rebuild($autoloader$request);
  \Drupal::messenger()->addStatus('Cache rebuild complete.');
}

    }

    private function getFrwState(): FrwState
    {
        $completedAt = $this->configService->getString('core.frw.completedAt');
        if ($completedAt !== '') {
            return FrwState::completedState(new \DateTimeImmutable($completedAt));
        }
        $failedAt = $this->configService->getString('core.frw.failedAt');
        if ($failedAt !== '') {
            $failureCount = $this->configService->getInt('core.frw.failureCount');

            return FrwState::failedState(new \DateTimeImmutable($failedAt)$failureCount);
        }

        return FrwState::openState();
    }

    private function updateFrwUserToken(Context $context, AccessTokenStruct $accessToken): void
    {
        /** @var AdminApiSource $contextSource */
        $contextSource = $context->getSource();
        
default => throw new \RuntimeException(sprintf('Invalid mail agent given "%s"', $emailAgent)),
        };
    }

    private function createSmtpTransport(SystemConfigService $configService): TransportInterface
    {
        $dsn = new Dsn(
            $this->getEncryption($configService) === 'ssl' ? 'smtps' : 'smtp',
            $configService->getString('core.mailerSettings.host'),
            $configService->getString('core.mailerSettings.username'),
            $configService->getString('core.mailerSettings.password'),
            $configService->getInt('core.mailerSettings.port'),
            $this->getEncryption($configService) !== null ? [] : ['verify_peer' => 0]
        );

        return $this->envBasedTransport->fromDsnObject($dsn);
    }

    private function getEncryption(SystemConfigService $configService): ?string
    {
        $encryption = $configService->getString('core.mailerSettings.encryption');

        return match ($encryption) {
            
return implode(' ', $parts);
    }

    /** * @return callable(int,int):int */
    private static function hashEngine(string $context): callable
    {
        if (class_exists(Randomizer::class)) {
            $randomizer = new Randomizer(new Xoshiro256StarStar(hash('sha256', $context, true)));

            return static fn ($start$end) => $randomizer->getInt($start$end);
        }

        $counter = 0;

        return static function D$start$end) use ($context, &$counter) {
            $possibleValues = range($start$end);
            ++$counter;

            return $possibleValues[(int) fmod(hexdec(substr(md5($context.'-'.$counter), 0, 10)), \count($possibleValues))];
        };
    }
}

    public function __construct(
        private readonly SystemConfigService $systemConfigService,
        private readonly Connection $connection,
        private readonly ClockInterface $clock = new NativeClock(),
    ) {
    }

    public function removeOldLogs(): void
    {
        $entryLifetimeSeconds = $this->systemConfigService->getInt('core.webhook.entryLifetimeSeconds');

        if ($entryLifetimeSeconds === -1) {
            return;
        }

        $deleteBefore = $this->clock
            ->now()
            ->modify("- $entryLifetimeSeconds seconds")
            ->format(Defaults::STORAGE_DATE_TIME_FORMAT);

        $this->connection->executeStatement(
            

    public function __construct(
        private readonly AbstractSalesChannelContextFactory $salesChannelContextFactory,
        private readonly SitemapExporterInterface $sitemapExporter,
        private readonly LoggerInterface $logger,
        private readonly SystemConfigService $systemConfigService,
    ) {
    }

    public function __invoke(SitemapMessage $message): void
    {
        $sitemapRefreshStrategy = $this->systemConfigService->getInt('core.sitemap.sitemapRefreshStrategy');
        if ($sitemapRefreshStrategy !== SitemapExporterInterface::STRATEGY_SCHEDULED_TASK) {
            return;
        }

        $this->generate($message);
    }

    private function generate(SitemapMessage $message): void
    {
        if ($message->getLastSalesChannelId() === null || $message->getLastLanguageId() === null) {
            return;
        }

        return new JsonResponse($this->codeService->getFixedCode());
    }

    #[Route(path: '/api/_action/promotion/codes/generate-individual', name: 'api.action.promotion.codes.generate-individual', methods: ['GET'], defaults: ['_acl' => ['promotion.editor']])]     public function generateIndividualCodes(Request $request): Response
    {
        $codePattern = (string) $request->query->get('codePattern');
        if ($codePattern === '') {
            throw RoutingException::missingRequestParameter('codePattern');
        }
        $amount = $request->query->getInt('amount');

        return new JsonResponse($this->codeService->generateIndividualCodes($codePattern$amount));
    }

    #[Route(path: '/api/_action/promotion/codes/replace-individual', name: 'api.action.promotion.codes.replace-individual', methods: ['PATCH'], defaults: ['_acl' => ['promotion.editor']])]     public function replaceIndividualCodes(Request $request, Context $context): Response
    {
        $promotionId = (string) $request->request->get('promotionId');
        $codePattern = (string) $request->request->get('codePattern');
        $amount = $request->request->getInt('amount');

        
        return $clientIps ? array_reverse($clientIps) : [$firstTrustedIp];
    }

    /** * Is this IIS with UrlRewriteModule? * * This method consumes, caches and removed the IIS_WasUrlRewritten env var, * so we don't inherit it to sub-requests. */
    private function isIisRewrite(): bool
    {
        if (1 === $this->server->getInt('IIS_WasUrlRewritten')) {
            $this->isIisRewrite = true;
            $this->server->remove('IIS_WasUrlRewritten');
        }

        return $this->isIisRewrite;
    }
}
throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/navigation/{activeId}/{rootId}', name: 'store-api.navigation', methods: ['GET', 'POST'], defaults: ['_entity' => 'category'])]     public function load(
        string $activeId,
        string $rootId,
        Request $request,
        SalesChannelContext $context,
        Criteria $criteria
    ): NavigationRouteResponse {
        $depth = $request->query->getInt('depth', $request->request->getInt('depth', 2));

        $metaInfo = $this->getCategoryMetaInfo($activeId$rootId);

        $active = $this->getMetaInfoById($activeId$metaInfo);

        $root = $this->getMetaInfoById($rootId$metaInfo);

        // Validate the provided category is part of the sales channel         $this->validate($activeId$active['path']$context);

        $isChild = $this->isChildCategory($activeId$active['path']$rootId);

        
/** * Returns the number of additional media items that can be selected. * * When the value is not available in the URL the default is 0. When a * negative integer is passed, an unlimited amount of media items can be * selected. * * @return int * The number of additional media items that can be selected. */
  public function getAvailableSlots() {
    return $this->getInt('media_library_remaining');
  }

  /** * Returns all opener-specific parameter values. * * @return array * An associative array of all opener-specific parameter values. */
  public function getOpenerParameters() {
    return $this->all('media_library_opener_parameters');
  }

  

        return $this->decorated;
    }

    #[Route(path: '/store-api/sitemap', name: 'store-api.sitemap', methods: ['GET', 'POST'])]     public function load(Request $request, SalesChannelContext $context): SitemapRouteResponse
    {
        if ($context->hasState(...$this->states)) {
            return $this->getDecorated()->load($request$context);
        }

        $strategy = $this->config->getInt('core.sitemap.sitemapRefreshStrategy');
        if ($strategy === SitemapExporterInterface::STRATEGY_LIVE) {
            return $this->getDecorated()->load($request$context);
        }

        $key = $this->generateKey($request$context);

        if ($key === null) {
            return $this->getDecorated()->load($request$context);
        }

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($request$context) {
            
$this->expectException(UnexpectedValueException::class);
        $this->expectExceptionMessage('Parameter value "word" cannot be converted to "string".');

        $bag->getDigits('word');
    }

    public function testGetInt()
    {
        $bag = new ParameterBag(['digits' => '123', 'bool' => true]);

        $this->assertSame(123, $bag->getInt('digits', 0), '->getInt() gets a value of parameter as integer');
        $this->assertSame(0, $bag->getInt('unknown', 0), '->getInt() returns zero if a parameter is not defined');
        $this->assertSame(10, $bag->getInt('unknown', 10), '->getInt() returns the default if a parameter is not defined');
        $this->assertSame(1, $bag->getInt('bool', 0), '->getInt() returns 1 if a parameter is true');
    }

    /** * @group legacy */
    public function testGetIntExceptionWithArray()
    {
        $this->expectDeprecation(sprintf('Since symfony/http-foundation 6.3: Ignoring invalid values when using "%s::getInt(\'digits\')" is deprecated and will throw an "%s" in 7.0; use method "filter()" with flag "FILTER_NULL_ON_FAILURE" to keep ignoring them.', ParameterBag::class, UnexpectedValueException::class));

        
#[Route(path: '/api/_action/order/{orderId}/recalculate', name: 'api.action.order.recalculate', methods: ['POST'])]     public function recalculateOrder(string $orderId, Context $context): Response
    {
        $this->recalculationService->recalculateOrder($orderId$context);

        return new Response(null, Response::HTTP_NO_CONTENT);
    }

    #[Route(path: '/api/_action/order/{orderId}/product/{productId}', name: 'api.action.order.add-product', methods: ['POST'])]     public function addProductToOrder(string $orderId, string $productId, Request $request, Context $context): Response
    {
        $quantity = $request->request->getInt('quantity', 1);
        $this->recalculationService->addProductToOrder($orderId$productId$quantity$context);

        return new Response(null, Response::HTTP_NO_CONTENT);
    }

    #[Route(path: '/api/_action/order/{orderId}/creditItem', name: 'api.action.order.add-credit-item', methods: ['POST'])]     public function addCreditItemToOrder(string $orderId, Request $request, Context $context): Response
    {
        $identifier = (string) $request->request->get('identifier');
        $type = LineItem::CREDIT_LINE_ITEM_TYPE;
        $quantity = $request->request->getInt('quantity', 1);

        

        $response = $this->removeCookies($request$response);

        $response->headers->remove(CookieRemoveHandler::COOKIE_CONFIG_KEY);
        $response->headers->remove(CookieRemoveHandler::COOKIE_GROUP_COLLECTION_KEY);

        return $response;
    }

    private function removeCookies(Request $request, Response $response): Response
    {
        $allowCookie = $request->cookies->getInt('allowCookie');

        if ($allowCookie === 1) {
            return $response;
        }

        $responseHeaders = $response->headers;
        $cookieResponseHeader = $responseHeaders->get(CookieRemoveHandler::COOKIE_CONFIG_KEY);
        if (!\is_string($cookieResponseHeader)) {
            return $response;
        }

        

    public function __construct(
        EntityRepository $scheduledTaskRepository,
        private readonly SystemConfigService $systemConfigService,
        private readonly Connection $connection
    ) {
        parent::__construct($scheduledTaskRepository);
    }

    public function run(): void
    {
        $entryLifetimeSeconds = $this->systemConfigService->getInt('core.logging.entryLifetimeSeconds');
        $maxEntries = $this->systemConfigService->getInt('core.logging.entryLimit');

        if ($entryLifetimeSeconds !== -1) {
            $deleteBefore = (new \DateTime(sprintf('- %d seconds', $entryLifetimeSeconds)))
                ->format(Defaults::STORAGE_DATE_TIME_FORMAT);
            $this->connection->executeStatement(
                'DELETE FROM `log_entry` WHERE `created_at` < :before',
                ['before' => $deleteBefore]
            );
        }

        
Home | Imprint | This part of the site doesn't use cookies.