Recurring.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Catalog\Setup;
  7. use Magento\Catalog\Api\Data\CategoryInterface;
  8. use Magento\Framework\EntityManager\MetadataPool;
  9. use Magento\Framework\Setup\ExternalFKSetup;
  10. use Magento\Framework\Setup\InstallSchemaInterface;
  11. use Magento\Framework\Setup\ModuleContextInterface;
  12. use Magento\Framework\Setup\SchemaSetupInterface;
  13. /**
  14. * Catalog recurring setup
  15. */
  16. class Recurring implements InstallSchemaInterface
  17. {
  18. /**
  19. * @var MetadataPool
  20. */
  21. protected $metadataPool;
  22. /**
  23. * @var ExternalFKSetup
  24. */
  25. protected $externalFKSetup;
  26. /**
  27. * @param MetadataPool $metadataPool
  28. * @param ExternalFKSetup $externalFKSetup
  29. */
  30. public function __construct(
  31. MetadataPool $metadataPool,
  32. ExternalFKSetup $externalFKSetup
  33. ) {
  34. $this->metadataPool = $metadataPool;
  35. $this->externalFKSetup = $externalFKSetup;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
  41. {
  42. $installer = $setup;
  43. $installer->startSetup();
  44. $metadata = $this->metadataPool->getMetadata(CategoryInterface::class);
  45. $this->externalFKSetup->install(
  46. $installer,
  47. $metadata->getEntityTable(),
  48. $metadata->getIdentifierField(),
  49. 'catalog_category_product',
  50. 'category_id'
  51. );
  52. $installer->endSetup();
  53. }
  54. }