getProjectRoot() public method

Find the root of the current project.
public getProjectRoot ( ) : string | false
return string | false
コード例 #1
1
 /**
  * @inheritdoc
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     // Validate we can run.
     if ($this->platformConfig === null) {
         $output->writeln('<error>Must run command within a Platform.sh project</error>');
         exit(1);
     }
     $this->projectPath = LocalProject::getProjectRoot();
     $this->projectName = Platform::projectName();
     $this->stdOut = $output;
     $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $this->stdIn = $input;
     self::$interactive = $input->isInteractive();
 }
コード例 #2
0
 /**
  * @return string|false
  */
 public function getProjectRoot()
 {
     if (!isset(self::$projectRoot)) {
         $this->debug('Finding the project root based on the CWD');
         self::$projectRoot = $this->localProject->getProjectRoot();
         $this->debug(self::$projectRoot ? 'Project root found: ' . self::$projectRoot : 'Project root not found');
     }
     return self::$projectRoot;
 }
コード例 #3
0
 /**
  * Builds Docker Compose YML file.
  *
  * @param $name
  */
 function __construct($name)
 {
     $this->path = LocalProject::getProjectRoot();
     $this->name = $name;
     // Add required containers.
     $this->addPhpFpm();
     $this->addDatabase();
     $this->addWebserver();
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $xhpfg = LocalProject::getProjectRoot() . '/docker/xhpfg/xhprof-sample-to-flamegraph-stacks';
     $fg = LocalProject::getProjectRoot() . '/docker/fg/flamegraph.pl';
     $xhprof = LocalProject::getProjectRoot() . '/xhprof';
     $graphName = $input->getArgument('filename');
     $graphDestination = LocalProject::getProjectRoot() . '/' . $graphName . '.svg';
     exec("{$xhpfg} {$xhprof} | {$fg} > {$graphDestination}");
     $url = 'file://' . $graphDestination;
     $this->openUrl($url);
 }
コード例 #5
0
 public function testGetProjectRoot()
 {
     $tempDir = $this->root->getName();
     $testDir = tempnam($tempDir, '');
     unlink($testDir);
     mkdir("{$testDir}/1/2/3/4/5", 0755, true);
     $expectedRoot = "{$testDir}/1";
     touch("{$expectedRoot}/.platform-project");
     chdir($testDir);
     $this->assertFalse(LocalProject::getProjectRoot());
     chdir($expectedRoot);
     $this->assertEquals($expectedRoot, LocalProject::getProjectRoot());
     chdir("{$testDir}/1/2/3/4/5");
     $this->assertEquals($expectedRoot, LocalProject::getProjectRoot());
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ShellHelper $shell */
     $shell = $this->getHelper('shell');
     $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
     $shell->setOutput($output);
     if (!is_dir(LocalProject::getProjectRoot() . '/docker/fg')) {
         $shell->execute(['git', 'clone', 'https://github.com/brendangregg/FlameGraph.git', LocalProject::getProjectRoot() . '/docker/fg']);
     }
     if (!is_dir(LocalProject::getProjectRoot() . '/docker/xhpfg')) {
         $shell->execute(['git', 'clone', 'https://github.com/msonnabaum/xhprof-flamegraphs.git', LocalProject::getProjectRoot() . '/docker/xhpfg']);
     }
     $this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>");
     $process = new Process('patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir());
     $process->mustRun(null);
 }
コード例 #7
0
 /**
  * @return string|false
  */
 public function getProjectRoot()
 {
     if (empty(self::$projectRoot)) {
         self::$projectRoot = LocalProject::getProjectRoot();
     }
     return self::$projectRoot;
 }
コード例 #8
0
 public static function webDir()
 {
     return LocalProject::getProjectRoot() . '/' . LocalProject::WEB_ROOT;
 }
コード例 #9
0
 /**
  * @return string|false
  */
 protected function getProjectRoot()
 {
     return $this->projectRoot ?: LocalProject::getProjectRoot();
 }
コード例 #10
0
 /**
  *
  */
 public function __construct()
 {
     $this->resourcesDir = CLI_ROOT . '/resources';
     $this->projectPath = LocalProject::getProjectRoot();
     $this->fs = new Filesystem();
 }