Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mautic.corals.io/app/middlewares/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mautic.corals.io/app/middlewares/MiddlewareBuilder.php
<?php

namespace Mautic\Middleware;

use Mautic\CoreBundle\Cache\MiddlewareCacheWarmer;
use Stack\StackedHttpKernel;

class MiddlewareBuilder
{
    /**
     * @var \AppKernel
     */
    private $app;

    /**
     * @var string
     */
    private $cacheFile;

    public function __construct(\AppKernel $app)
    {
        $this->app       = $app;
        $this->cacheFile = sprintf('%s/middlewares.cache.php', $app->getCacheDir());
        $this->specs     = new \SplPriorityQueue();
    }

    public function resolve(): StackedHttpKernel
    {
        $this->loadMiddlewares();

        $app         = $this->app;
        $middlewares = [$app];

        foreach ($this->specs as $spec) {
            $app = $spec->newInstanceArgs([$app]);

            array_unshift($middlewares, $app);
        }

        return new StackedHttpKernel($app, $middlewares);
    }

    private function loadMiddlewares(): void
    {
        if (!$this->hasCacheFile()) {
            $this->warmUpCacheCommand();
        }

        $this->loadCacheFile();
    }

    private function warmUpCacheCommand(): void
    {
        $middlewareCacheWarmer = new MiddlewareCacheWarmer($this->app->getEnvironment());
        $middlewareCacheWarmer->warmUp($this->app->getCacheDir());
    }

    private function hasCacheFile(): bool
    {
        return file_exists($this->cacheFile);
    }

    private function loadCacheFile(): void
    {
        /** @var array $middlewares */
        $middlewares = include $this->cacheFile;

        foreach ($middlewares as $middleware) {
            $this->push($middleware);
        }
    }

    private function push(string $middlewareClass): void
    {
        try {
            $reflection = new \ReflectionClass($middlewareClass);
            $priority   = $reflection->getConstant('PRIORITY');

            $this->specs->insert($reflection, $priority);
        } catch (\ReflectionException $e) {
            /* If there's an error getting the kernel class, it's
             * an invalid middleware. If it's invalid, don't push
             * it to the stack
             */
        }
    }
}

Spamworldpro Mini