[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.147.81.172: ~ $
<?php

namespace MailPoet\Doctrine;

if (!defined('ABSPATH')) exit;


use MailPoet\Config\Env;
use MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadata;
use MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadataFactory;
use MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadataInfo;

// Taken from Doctrine docs (see link bellow) but implemented in metadata factory instead of an event
// because we need to add prefix at runtime, not at metadata dump (which is included in builds).
// @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.5/cookbook/sql-table-prefixes.html
class TablePrefixMetadataFactory extends ClassMetadataFactory {
  /** @var string */
  private $prefix;

  /** @var array */
  private $prefixedMap = [];

  public function __construct() {
    if (Env::$dbPrefix === null) {
      throw new \RuntimeException('DB table prefix not initialized');
    }
    $this->prefix = Env::$dbPrefix;
    $this->setProxyClassNameResolver(new ProxyClassNameResolver());
  }

  /**
   * @return ClassMetadata<object>
   */
  public function getMetadataFor($className) {
    $classMetadata = parent::getMetadataFor($className);
    if (isset($this->prefixedMap[$classMetadata->getName()])) {
      return $classMetadata;
    }

    // prefix tables only after they are saved to cache so the prefix does not get included in cache
    // (getMetadataFor can call itself recursively but it saves to cache only after the recursive calls)
    $cacheKey = $this->getCacheKey($classMetadata->getName());
    $isCached = ($cache = $this->getCache()) ? $cache->hasItem($cacheKey) : false;
    if ($classMetadata instanceof ClassMetadata && $isCached) {
      $this->addPrefix($classMetadata);
      $this->prefixedMap[$classMetadata->getName()] = true;
    }
    return $classMetadata;
  }

  /**
   * @param ClassMetadata<object> $classMetadata
   */
  public function addPrefix(ClassMetadata $classMetadata) {
    if (!$classMetadata->isInheritanceTypeSingleTable() || $classMetadata->getName() === $classMetadata->rootEntityName) {
      $classMetadata->setPrimaryTable([
        'name' => $this->prefix . $classMetadata->getTableName(),
      ]);
    }

    foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
      if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide']) {
        $mappedTableName = $mapping['joinTable']['name'];
        $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
      }
    }
  }
}

Filemanager

Name Type Size Permission Actions
Annotations Folder 0755
EntityTraits Folder 0755
EventListeners Folder 0755
Types Folder 0755
Validator Folder 0755
ConfigurationFactory.php File 2.84 KB 0644
ConnectionFactory.php File 3.19 KB 0644
EntityManagerFactory.php File 2.5 KB 0644
MetadataCache.php File 2.8 KB 0644
PSRCacheInvalidArgumentException.php File 225 B 0644
PSRCacheItem.php File 1010 B 0644
PSRMetadataCache.php File 2.23 KB 0644
ProxyClassNameResolver.php File 1.02 KB 0644
Repository.php File 2.62 KB 0644
SerializableConnection.php File 937 B 0644
TablePrefixMetadataFactory.php File 2.46 KB 0644
index.php File 0 B 0644