signUpGroups( 'org\wplake\advanced_views\Groups', __DIR__ . '/src/Groups' ); } protected function primary(CurrentScreen $currentScreen): void { $this->groupCreator = new Creator(); $this->viewData = $this->groupCreator->create(ViewData::class); $this->cardData = $this->groupCreator->create(CardData::class); $this->options = new Options(); $this->html = new Html(); $cardsFileSystem = new FileSystem('cards'); $this->cardsDataStorage = new CardsDataStorage( $cardsFileSystem, new CardFsFields(), new DbManagement($cardsFileSystem, CardsCpt::NAME, 'card_'), $this->cardData ); $viewsFileSystem = new FileSystem('views'); $this->viewsDataStorage = new ViewsDataStorage( $viewsFileSystem, new FsFields(), new DbManagement($viewsFileSystem, ViewsCpt::NAME, 'view_'), $this->viewData ); $this->settings = new Settings($this->options); $this->plugin = new Plugin($this->options, $this->settings); $this->twig = new Twig($this->settings, $this->plugin); $this->item = $this->groupCreator->create(ItemData::class); $this->dataVendors = new DataVendors(); $this->frontAssets = new FrontAssets($this->plugin, $this->dataVendors); $this->upgrades = new Upgrades( $this->plugin, $this->settings, $this->twig ); // it's a hack, but there is no other way to pass data (constructor is always called automatically) FieldData::setDataVendors($this->dataVendors); // load right here, as used everywhere $this->settings->load(); $this->plugin->setHooks($currentScreen); $this->twig->setHooks($currentScreen, __FILE__); $this->frontAssets->setHooks($currentScreen); $this->dataVendors->setHooks($currentScreen); $cardsFileSystem->setHooks($currentScreen); $viewsFileSystem->setHooks($currentScreen); } protected function views(CurrentScreen $currentScreen): void { $fieldMarkup = new FieldMarkup($this->dataVendors, $this->frontAssets); $this->viewMarkup = new ViewMarkup($this->html, $fieldMarkup, $this->dataVendors); $this->viewFactory = new ViewFactory( $this->frontAssets, $this->viewsDataStorage, $this->viewMarkup, $this->twig, $fieldMarkup, $this->dataVendors ); $viewMetaBoxes = new ViewsCptMetaBoxes($this->html, $this->viewsDataStorage, $this->dataVendors); $this->viewsSaveActions = new ViewsCptSaveActions( $this->viewsDataStorage, $this->plugin, $this->viewData, $this->frontAssets, $this->viewMarkup, $viewMetaBoxes, $this->html, $this->viewFactory ); $viewsCpt = new ViewsCpt($this->viewsDataStorage); $viewsCptTable = new ViewsCptTable( $this->viewsDataStorage, ViewsCpt::NAME, $this->html, $viewMetaBoxes, $this->viewFactory ); $viewsFsOnlyCptTableTab = new FsOnlyCptTableTab($viewsCptTable, $this->viewsDataStorage); $viewsBulkValidationCptTableTab = new ViewsBulkValidationCptTableTab( $viewsCptTable, $this->viewsDataStorage, $viewsFsOnlyCptTableTab, $this->viewFactory ); $viewsCptAssetsReducer = new CptAssetsReducer(ViewsCpt::NAME); $viewsCptGutenbergEditorSettings = new CptGutenbergEditorSettings(ViewsCpt::NAME); $this->viewShortcode = new ViewShortcode($this->settings, $this->viewsDataStorage, $this->viewFactory); $viewMetaBoxes->setHooks($currentScreen); $viewsCpt->setHooks($currentScreen); $viewsCptTable->setHooks($currentScreen); $viewsFsOnlyCptTableTab->setHooks($currentScreen); $viewsBulkValidationCptTableTab->setHooks($currentScreen); $viewsCptGutenbergEditorSettings->setHooks($currentScreen); $viewsCptAssetsReducer->setHooks($currentScreen); $this->viewsSaveActions->setHooks($currentScreen); $this->viewShortcode->setHooks($currentScreen); } protected function cards(CurrentScreen $currentScreen): void { $this->queryBuilder = new QueryBuilder($this->dataVendors); $this->cardMarkup = new CardMarkup($this->queryBuilder, $this->frontAssets); $this->cardFactory = new CardFactory( $this->frontAssets, $this->queryBuilder, $this->cardMarkup, $this->twig, $this->cardsDataStorage ); $acfCardsMetaBoxes = new CardsCptMetaBoxes($this->html, $this->cardsDataStorage, $this->viewsDataStorage); $this->cardsSaveActions = new CardsCptSaveActions( $this->cardsDataStorage, $this->plugin, $this->cardData, $this->frontAssets, $this->cardMarkup, $this->queryBuilder, $this->html, $acfCardsMetaBoxes, $this->cardFactory ); $cardsCpt = new CardsCpt( $this->cardsDataStorage, $this->html, $acfCardsMetaBoxes ); $cardsCptTable = new CardsCptTable( $this->cardsDataStorage, CardsCpt::NAME, $this->html, $acfCardsMetaBoxes, $this->cardFactory ); $cardsFsOnlyCptTableTab = new FsOnlyCptTableTab($cardsCptTable, $this->cardsDataStorage); $cardsBulkValidationCptTableTab = new CardsBulkValidationCptTableTab( $cardsCptTable, $this->cardsDataStorage, $cardsFsOnlyCptTableTab, $this->cardFactory ); $cardsCptAssetsReducer = new CptAssetsReducer(CardsCpt::NAME); $cardsCptGutenbergEditorSettings = new CptGutenbergEditorSettings(CardsCpt::NAME); $acfCardsViewIntegration = new CardsViewIntegration( $this->cardsDataStorage, $this->viewsDataStorage, $this->cardsSaveActions ); $this->cardShortcode = new CardShortcode($this->settings, $this->cardsDataStorage, $this->cardFactory); $cardsCpt->setHooks($currentScreen); $cardsCptTable->setHooks($currentScreen); $cardsFsOnlyCptTableTab->setHooks($currentScreen); $cardsBulkValidationCptTableTab->setHooks($currentScreen); $cardsCptAssetsReducer->setHooks($currentScreen); $cardsCptGutenbergEditorSettings->setHooks($currentScreen); $acfCardsMetaBoxes->setHooks($currentScreen); $this->cardsSaveActions->setHooks($currentScreen); $acfCardsViewIntegration->setHooks($currentScreen); $this->cardShortcode->setHooks($currentScreen); } protected function integration(CurrentScreen $currentScreen): void { $this->acfDependency = new AcfDependency($this->plugin); $this->fieldIntegration = new FieldDataIntegration( ViewsCpt::NAME, $this->dataVendors, $this->viewsDataStorage ); $cardDataIntegration = new CardDataIntegration(CardsCpt::NAME, $this->dataVendors, $this->viewsDataStorage); $itemIntegration = new ItemDataIntegration(ViewsCpt::NAME, $this->dataVendors); // metaField is a part of the Meta Filter, so we use 'cardsCpt' here $metaFieldIntegration = new MetaFieldDataIntegration(CardsCpt::NAME, $this->dataVendors); $mountPointIntegrationForViews = new MountPointDataIntegration(ViewsCpt::NAME); $mountPointIntegrationForCards = new MountPointDataIntegration(CardsCpt::NAME); $taxFieldIntegration = new TaxFieldDataIntegration(CardsCpt::NAME); $toolsDataIntegration = new ToolsDataIntegration($this->viewsDataStorage, $this->cardsDataStorage); $this->acfDependency->setHooks($currentScreen); $this->fieldIntegration->setHooks($currentScreen); $cardDataIntegration->setHooks($currentScreen); $itemIntegration->setHooks($currentScreen); $metaFieldIntegration->setHooks($currentScreen); $mountPointIntegrationForViews->setHooks($currentScreen); $mountPointIntegrationForCards->setHooks($currentScreen); $taxFieldIntegration->setHooks($currentScreen); $toolsDataIntegration->setHooks($currentScreen); // only now, when views() are called $this->dataVendors->makeIntegrationInstances( $currentScreen, $this->item, $this->viewsDataStorage, $this->viewsSaveActions, $this->viewFactory, $this->groupCreator->create(RepeaterFieldData::class), $this->viewShortcode ); } protected function others(CurrentScreen $currentScreen): void { $demoImport = new DemoImport( $this->cardsSaveActions, $this->viewsSaveActions, $this->cardsDataStorage, $this->viewsDataStorage, $this->settings, $this->item ); $acfIntegration = new AcfIntegration(''); $dashboard = new Dashboard($this->plugin, $this->html, $demoImport, $acfIntegration); $acfPro = new AcfPro($this->plugin); // late dependencies $this->upgrades->setDependencies( $this->viewsDataStorage, $this->cardsDataStorage, $this->viewsSaveActions, $this->cardsSaveActions, ); $activeInstallations = new ActiveInstallations( $this->plugin, $this->settings, $this->options, $this->viewsDataStorage ); $tools = new Tools( new ToolsData($this->groupCreator), $this->cardsDataStorage, $this->viewsDataStorage, $this->plugin, $this->viewData, $this->cardData ); $settings = new SettingsPage( new SettingsData($this->groupCreator), $this->settings, $this->viewsDataStorage, $this->cardsDataStorage, $this->groupCreator->create(GitRepository::class) ); $adminAssets = new AdminAssets( $this->plugin, $this->cardsDataStorage, $this->viewsDataStorage, $this->viewFactory, $this->cardFactory, $this->settings ); $dashboard->setHooks($currentScreen); $demoImport->setHooks($currentScreen); $acfPro->setHooks($currentScreen); // only after late dependencies were set $this->upgrades->setHooks($currentScreen); $activeInstallations->setHooks($currentScreen); $tools->setHooks($currentScreen); $adminAssets->setHooks($currentScreen); $settings->setHooks($currentScreen); } protected function bridge(): void { AdvancedViews::$innerViewShortcode = $this->viewShortcode; AdvancedViews::$innerCardShortcode = $this->cardShortcode; } public function init(): void { // skip initialization if PRO already active if (class_exists(Plugin::class)) { return; } require_once __DIR__ . '/prefixed_vendors/vendor/scoper-autoload.php'; $currentScreen = new CurrentScreen(); $this->acfGroups(); $this->primary($currentScreen); $this->views($currentScreen); $this->cards($currentScreen); $this->integration($currentScreen); $this->others($currentScreen); $this->bridge(); } }; $acfViews->init();