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/bundles/IntegrationsBundle/Migration/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mautic.corals.io/app/bundles/IntegrationsBundle/Migration/Engine.php
<?php

declare(strict_types=1);

namespace Mautic\IntegrationsBundle\Migration;

use Doctrine\ORM\EntityManager;
use Mautic\IntegrationsBundle\Exception\PathNotFoundException;

class Engine
{
    private string $migrationsPath;

    public function __construct(
        private EntityManager $entityManager,
        private string $tablePrefix,
        string $pluginPath,
        private string $bundleName
    ) {
        $this->migrationsPath = $pluginPath.'/Migrations/';
    }

    /**
     * Run available migrations.
     */
    public function up(): void
    {
        try {
            $migrationClasses = $this->getMigrationClasses();
        } catch (PathNotFoundException $e) {
            return;
        }

        if (!$migrationClasses) {
            return;
        }

        $this->entityManager->beginTransaction();

        try {
            foreach ($migrationClasses as $migrationClass) {
                /** @var AbstractMigration $migration */
                $migration = new $migrationClass($this->entityManager, $this->tablePrefix);

                if ($migration->shouldExecute()) {
                    $migration->execute();
                }
            }

            $this->entityManager->commit();
        } catch (\Doctrine\DBAL\Exception $e) {
            $this->entityManager->rollback();

            throw $e;
        }
    }

    /**
     * Get migration classes to proceed.
     *
     * @return string[]
     */
    private function getMigrationClasses(): array
    {
        $migrationFileNames = $this->getMigrationFileNames();
        $migrationClasses   = [];

        foreach ($migrationFileNames as $fileName) {
            require_once $this->migrationsPath.$fileName;
            $className          = preg_replace('/\\.[^.\\s]{3,4}$/', '', $fileName);
            $className          = 'MauticPlugin\\'.$this->bundleName."\Migrations\\{$className}";
            $migrationClasses[] = $className;
        }

        return $migrationClasses;
    }

    /**
     * Get migration file names.
     *
     * @return string[]
     */
    private function getMigrationFileNames(): array
    {
        $fileNames = @scandir($this->migrationsPath);

        if (false === $fileNames) {
            throw new PathNotFoundException(sprintf("'%s' directory not found", $this->migrationsPath));
        }

        return array_diff($fileNames, ['.', '..']);
    }
}

Spamworldpro Mini