123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\CatalogUrlRewrite\Setup;
- use Magento\Catalog\Api\Data\CategoryInterface;
- use Magento\Catalog\Api\Data\ProductInterface;
- use Magento\CatalogUrlRewrite\Model\ResourceModel\Category\Product as ResourceProduct;
- use Magento\Framework\EntityManager\MetadataPool;
- use Magento\Framework\Setup\ExternalFKSetup;
- use Magento\Framework\Setup\InstallSchemaInterface;
- use Magento\Framework\Setup\ModuleContextInterface;
- use Magento\Framework\Setup\SchemaSetupInterface;
- /**
- * CatalogUrlRewrite recurring setup
- */
- 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();
- $metadata = $this->metadataPool->getMetadata(CategoryInterface::class);
- $this->externalFKSetup->install(
- $installer,
- $metadata->getEntityTable(),
- $metadata->getIdentifierField(),
- ResourceProduct::TABLE_NAME,
- 'category_id'
- );
- $metadata = $this->metadataPool->getMetadata(ProductInterface::class);
- $this->externalFKSetup->install(
- $installer,
- $metadata->getEntityTable(),
- $metadata->getIdentifierField(),
- 'catalog_url_rewrite_product_category',
- 'product_id'
- );
- $installer->endSetup();
- }
- }
|