getConfiguredInstance() публичный статический Метод

public static getConfiguredInstance ( ) : DIContainer
Результат DIContainer
Пример #1
0
 /**
  * Finishes clone operation
  *
  * @subcommand finish-restore-site
  *
  * @when before_wp_load
  *
  */
 public function finishRestore($args, $assoc_args)
 {
     define('SHORTINIT', true);
     $wpConfigPath = \WP_CLI\Utils\locate_wp_config();
     require_once $wpConfigPath;
     require ABSPATH . WPINC . '/formatting.php';
     require ABSPATH . WPINC . '/link-template.php';
     require ABSPATH . WPINC . '/shortcodes.php';
     require ABSPATH . WPINC . '/taxonomy.php';
     wp_plugin_directory_constants();
     require_once WP_PLUGIN_DIR . '/versionpress/bootstrap.php';
     $versionPressContainer = DIContainer::getConfiguredInstance();
     /** @var ActionsDefinitionRepository $actionsDefinitionRepository */
     $actionsDefinitionRepository = $versionPressContainer->resolve(VersionPressServices::ACTIONS_DEFINITION_REPOSITORY);
     $actionsDefinitionRepository->restoreAllDefinitionFilesFromHistory();
     // Truncate tables
     /** @var Database $database */
     $database = $versionPressContainer->resolve(VersionPressServices::DATABASE);
     /** @var DbSchemaInfo $dbSchema */
     $dbSchema = $versionPressContainer->resolve(VersionPressServices::DB_SCHEMA);
     $tables = array_map(function ($entityName) use($dbSchema) {
         return $dbSchema->getPrefixedTableName($entityName);
     }, array_merge($dbSchema->getAllEntityNames(), array_map(function ($referenceDetails) {
         return $referenceDetails['junction-table'];
     }, $dbSchema->getAllMnReferences())));
     $tables = array_filter($tables, function ($table) use($database) {
         return $table !== $database->options;
     });
     foreach ($tables as $table) {
         $truncateCmd = "TRUNCATE TABLE `{$table}`";
         @$database->query($truncateCmd);
         // Intentional @ - not existing table is ok for us but TRUNCATE ends with error
     }
     // Create VersionPress tables
     /** @var \VersionPress\Initialization\Initializer $initializer */
     $initializer = $versionPressContainer->resolve(VersionPressServices::INITIALIZER);
     $initializer->createVersionPressTables();
     WP_CLI::success("VersionPress tables created");
     // Install Custom merge driver
     MergeDriverInstaller::installMergeDriver(VP_PROJECT_ROOT, VERSIONPRESS_PLUGIN_DIR, VP_VPDB_DIR);
     WP_CLI::success("Git merge driver added");
     // Run synchronization
     /** @var SynchronizationProcess $syncProcess */
     $syncProcess = $versionPressContainer->resolve(VersionPressServices::SYNCHRONIZATION_PROCESS);
     $syncProcess->synchronizeAll();
     WP_CLI::success("Database synchronized");
     VPCommandUtils::runWpCliCommand('vp-internal', 'flush-regenerable-values', ['require' => __FILE__]);
 }
Пример #2
0
<?php

use Nette\Caching\Storages\FileStorage;
use Nette\Loaders\RobotLoader;
use Tracy\Debugger;
use VersionPress\DI\DIContainer;
use VersionPress\DI\VersionPressServices;
define('VERSIONPRESS_PLUGIN_DIR', __DIR__);
define('VERSIONPRESS_MIRRORING_DIR', WP_CONTENT_DIR . '/vpdb');
define('VERSIONPRESS_TEMP_DIR', VERSIONPRESS_PLUGIN_DIR . '/temp');
define('VERSIONPRESS_ACTIVATION_FILE', VERSIONPRESS_MIRRORING_DIR . '/.active');
require_once VERSIONPRESS_PLUGIN_DIR . '/versionpress-functions.php';
if (defined('DOING_AJAX')) {
    header("Content-Type: application/json");
}
Debugger::enable(Debugger::DEVELOPMENT, VERSIONPRESS_PLUGIN_DIR . '/log');
$robotLoader = new RobotLoader();
$robotLoader->addDirectory(VERSIONPRESS_PLUGIN_DIR . '/src');
$robotLoader->setCacheStorage(new FileStorage(VERSIONPRESS_PLUGIN_DIR . '/temp'));
$robotLoader->register();
global $versionPressContainer;
$versionPressContainer = DIContainer::getConfiguredInstance();
Пример #3
0
 /**
  * Defines global constants, container and wpdb dynamic mapping of value references.
  * It's not pretty, but makes the mapping functions very flexible (they can have various dependecies).
  */
 private static function defineGlobalVariables()
 {
     global $versionPressContainer, $wpdb, $wp_taxonomies;
     defined('VERSIONPRESS_PLUGIN_DIR') || define('VERSIONPRESS_PLUGIN_DIR', self::$testConfig->testSite->path . '/wp-content/plugins/versionpress');
     defined('VP_VPDB_DIR') || define('VP_VPDB_DIR', self::$testConfig->testSite->path . '/wp-content/vpdb');
     $versionPressContainer = DIContainer::getConfiguredInstance();
     $wpdb = self::$wpdb;
     $rawTaxonomies = self::$wpAutomation->runWpCliCommand('taxonomy', 'list', ['format' => 'json', 'fields' => 'name']);
     $taxonomies = array_column(json_decode($rawTaxonomies, true), 'name');
     $wp_taxonomies = array_combine($taxonomies, $taxonomies);
 }