/** * Symlink each known Git hook to the PHP Composter bootstrapping script. * * @since 0.1.0 * * @param Filesystem $filesystem Reference to the Filesystem instance. */ protected function createGitHooks(Filesystem $filesystem) { $hooksPath = Paths::getPath('root_hooks'); $gitScriptPath = Paths::getPath('git_script'); foreach ($this->getGitHookNames() as $githook) { $hookPath = $hooksPath . $githook; if (static::$io->isDebug()) { static::$io->write(sprintf(_('Symlinking %1$s to %2$s'), $hookPath, $gitScriptPath)); } $filesystem->relativeSymlink($gitScriptPath, $hookPath); } }
/** * Get the installation path of the package. * * @since 0.1.0 * * @param PackageInterface $package The package to install. * * @return string Relative installation path. * @throws InvalidArgumentException If the package name does not match the required pattern. */ public function getInstallPath(PackageInterface $package) { return Paths::getPath('actions') . $this->getSuffix($package); }
* @author Alain Schlesser <*****@*****.**> * @license MIT * @link http://www.brightnucleus.com/ * @copyright 2016 Alain Schlesser, Bright Nucleus */ use PHPComposter\PHPComposter\Paths; // Get the command-line arguments passed from the shell script. global $argv; $hook = $argv[1]; $root = $argv[2]; // Initialize Composer Autoloader. if (file_exists($root . '/vendor/autoload.php')) { require_once $root . '/vendor/autoload.php'; } // Read the configuration file. $config = (include Paths::getPath('git_config')); // Iterate over hook methods. if (array_key_exists($hook, $config)) { $actions = $config[$hook]; // Sort by priority. ksort($actions); // Launch each method. foreach ($actions as $calls) { foreach ($calls as $call) { // Make sure we could parse the call correctly. $array = explode('::', $call); if (count($array) !== 2) { throw new RuntimeException(sprintf(_('Configuration error in PHP Composter data, could not parse method "%1$s"'), $call)); } list($class, $method) = $array; // Instantiate a new action object and call its method.