GrumPHP\Configuration\GrumPHP::getHooksDir PHP Метод

getHooksDir() публичный Метод

public getHooksDir ( ) : string
Результат string
    public function getHooksDir()
    {
        return $this->container->getParameter('hooks_dir');
    }

Usage Example

Пример #1
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $gitHooksPath = $this->paths()->getGitHooksDir();
     $resourceHooksPath = $this->paths()->getGitHookTemplatesDir() . $this->grumPHP->getHooksPreset();
     $resourceHooksPath = $this->paths()->getPathWithTrailingSlash($resourceHooksPath);
     $customHooksPath = $this->paths()->getPathWithTrailingSlash($this->grumPHP->getHooksDir());
     // Some git clients do not automatically create a git hooks folder.
     if (!$this->filesystem->exists($gitHooksPath)) {
         $this->filesystem->mkdir($gitHooksPath);
         $output->writeln(sprintf('<fg=yellow>Created git hooks folder at: %s</fg=yellow>', $gitHooksPath));
     }
     foreach (self::$hooks as $hook) {
         $gitHook = $gitHooksPath . $hook;
         $hookTemplate = new SplFileInfo($resourceHooksPath . $hook);
         if ($customHooksPath && $this->filesystem->exists($customHooksPath . $hook)) {
             $hookTemplate = new SplFileInfo($customHooksPath . $hook);
         }
         if (!$this->filesystem->exists($hookTemplate)) {
             throw new RuntimeException(sprintf('Could not find hook template for %s at %s.', $hook, $hookTemplate));
         }
         $content = $this->parseHookBody($hook, $hookTemplate);
         $this->filesystem->dumpFile($gitHook, $content);
         $this->filesystem->chmod($gitHook, 0775);
     }
     $output->writeln('<fg=yellow>Watch out! GrumPHP is sniffing your commits!<fg=yellow>');
 }