PHPComposter\PHPComposter\HookConfig::addEntry PHP Method

addEntry() public static method

Add an entry to the configuration data.
Since: 0.1.0
public static addEntry ( string $hook, string $method, integer $priority = 10 )
$hook string Name of the Git hook to add to.
$method string Fully qualified method name to add.
$priority integer Optional. Priority of the hook. Defaults to 10.
    public static function addEntry($hook, $method, $priority = 10)
    {
        static::$config[$hook][$priority][] = $method;
    }

Usage Example

 /**
  * Install the package.
  *
  * @since 0.1.0
  *
  * @param InstalledRepositoryInterface $repo    The repository from where the package was fetched.
  * @param PackageInterface             $package The package to install.
  *
  * @throws InvalidArgumentException If the package name does not match the required pattern.
  */
 public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     $path = $this->getInstallPath($package);
     if ($this->io->isVerbose()) {
         $this->io->write(sprintf(_('Symlinking PHP Composter action %1$s'), $path), true);
     }
     parent::install($repo, $package);
     foreach ($this->getHooks($package) as $prioritizedHook => $method) {
         $array = explode('.', $prioritizedHook);
         if (count($array) > 1) {
             list($priority, $hook) = $array;
         } else {
             $hook = $array[0];
             $priority = 10;
         }
         if ($this->io->isVeryVerbose()) {
             $this->io->write(sprintf(_('Adding method "%1$s" to hook "%2$s" with priority %3$s'), $method, $hook, $priority), true);
         }
         HookConfig::addEntry($hook, $method, $priority);
     }
 }