private static function configureAbspath(IOInterface $io, $composer, $web_dir)
 {
     $wp_dir = PackageLocator::getPackagePath($composer, static::$wpPackage);
     $wp_load = "{$wp_dir}/wp-load.php";
     $abspath = $web_dir . '/';
     if (!is_file($wp_load)) {
         $io->write(sprintf('<error>Wordpress installation is broken, %s is missing.</error>', str_replace(getcwd() . '/', '', $wp_load)));
     }
     $io->write(sprintf('Setting <info>ABSPATH</info> to <info>%s</info>.', $abspath));
     $define = "define( 'ABSPATH', '{$abspath}' );";
     file_put_contents($wp_load, preg_replace("/^define\\(\\s*'ABSPATH'.+\$/m", $define, file_get_contents($wp_load)));
 }
 private static function wpCli($composer, $web_dir, $command)
 {
     $cliPath = PackageLocator::getPackagePath($composer, 'wp-cli/wp-cli');
     passthru("bin/wp --path='{$web_dir}' {$command}");
 }
 public function testBasePath()
 {
     $this->assertEquals(PackageLocator::getBasePath($this->composer), dirname(dirname(__DIR__)));
 }
 public static function buildParameters(Event $event)
 {
     $extras = $event->getComposer()->getPackage()->getExtra();
     if (empty($extras['wmc-app-loader']['file'])) {
         if (empty($extras['symfony-app-dir'])) {
             throw new \InvalidArgumentException('Either extra.symfony-app-dir or extra.wmc-app-loader.file setting are required to use this script handler.');
         }
         $appDir = $extras['symfony-app-dir'];
         $appLoader = new AppLoader($appDir, null);
         $realFile = $appLoader->getDefaultOptionsFile();
     } else {
         $realFile = $extras['wmc-app-loader']['file'];
     }
     if (empty($extras['wmc-app-loader']['dist-file'])) {
         $distFile = $realFile . '.dist';
         if (!is_file($distFile)) {
             // using packaged dist file
             $distFile = PackageLocator::getPackagePath($event->getComposer(), 'wemakecustom/symfony-app-loader') . '/app/config/app_loader.ini.dist';
         }
     } else {
         $distFile = $extras['wmc-app-loader']['dist-file'];
     }
     $keepOutdatedParams = false;
     if (isset($extras['wmc-app-loader']['keep-outdated'])) {
         $keepOutdatedParams = (bool) $extras['wmc-app-loader']['keep-outdated'];
     }
     $updater = Utils::createConfigFileUpdate($event->getIO());
     $updater->getConfigMerger()->setKeepOutdatedParams($keepOutdatedParams);
     $updater->updateFile($realFile, $distFile);
 }