mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 09:17:35 +00:00
- replaced release version with package version in @since and @depreacated tags - removed @since tag from private properties/methods and non @api classes
82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
namespace Magento\Bundle\Setup;
|
|
|
|
use Magento\Framework\Setup\ExternalFKSetup;
|
|
use Magento\Framework\Setup\InstallSchemaInterface;
|
|
use Magento\Framework\Setup\ModuleContextInterface;
|
|
use Magento\Framework\Setup\SchemaSetupInterface;
|
|
use Magento\Framework\EntityManager\MetadataPool;
|
|
use Magento\Catalog\Api\Data\ProductInterface;
|
|
|
|
/**
|
|
* @codeCoverageIgnore
|
|
*/
|
|
class Recurring implements InstallSchemaInterface
|
|
{
|
|
/**
|
|
* @var MetadataPool
|
|
*/
|
|
protected $metadataPool;
|
|
|
|
/**
|
|
* @var ExternalFKSetup
|
|
*/
|
|
protected $externalFKSetup;
|
|
|
|
/**
|
|
* @param MetadataPool $metadataPool
|
|
* @param ExternalFKSetup $externalFKSetup
|
|
*/
|
|
public function __construct(
|
|
MetadataPool $metadataPool,
|
|
ExternalFKSetup $externalFKSetup
|
|
) {
|
|
$this->metadataPool = $metadataPool;
|
|
$this->externalFKSetup = $externalFKSetup;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
|
{
|
|
$installer = $setup;
|
|
$installer->startSetup();
|
|
|
|
$listTables = [
|
|
'catalog_product_bundle_price_index' => 'entity_id',
|
|
'catalog_product_bundle_selection' => 'product_id',
|
|
];
|
|
foreach ($listTables as $tableName => $columnName) {
|
|
$this->addExternalForeignKeys($installer, $tableName, $columnName);
|
|
}
|
|
|
|
$installer->endSetup();
|
|
}
|
|
|
|
/**
|
|
* Add external foreign keys
|
|
*
|
|
* @param SchemaSetupInterface $installer
|
|
* @param string $tableName
|
|
* @param string $columnName
|
|
* @return void
|
|
* @throws \Exception
|
|
*/
|
|
protected function addExternalForeignKeys(SchemaSetupInterface $installer, $tableName, $columnName)
|
|
{
|
|
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
|
|
$this->externalFKSetup->install(
|
|
$installer,
|
|
$metadata->getEntityTable(),
|
|
$metadata->getIdentifierField(),
|
|
$tableName,
|
|
$columnName
|
|
);
|
|
}
|
|
}
|