|
|
|
@ -22,6 +22,7 @@ use Composer\Cache;
|
|
|
|
|
use Composer\Config;
|
|
|
|
|
use Composer\IO\IOInterface;
|
|
|
|
|
use Composer\Util\RemoteFilesystem;
|
|
|
|
|
use Composer\Util\StreamContextFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
@ -79,13 +80,15 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function notifyInstall(PackageInterface $package)
|
|
|
|
|
public function notifyInstalls(array $packages)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->notifyUrl || !$this->config->get('notify-on-install')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO use an optional curl_multi pool for all the notifications
|
|
|
|
|
// non-batch API, deprecated
|
|
|
|
|
if (strpos($this->notifyUrl, '%package%')) {
|
|
|
|
|
foreach ($packages as $package) {
|
|
|
|
|
$url = str_replace('%package%', $package->getPrettyName(), $this->notifyUrl);
|
|
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
@ -101,10 +104,34 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$context = stream_context_create($opts);
|
|
|
|
|
$context = StreamContextFactory::getContext($opts);
|
|
|
|
|
@file_get_contents($url, false, $context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$postData = array('downloads' => array());
|
|
|
|
|
foreach ($packages as $package) {
|
|
|
|
|
$postData['downloads'][] = array(
|
|
|
|
|
'name' => $package->getPrettyName(),
|
|
|
|
|
'version' => $package->getVersion(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$opts = array('http' =>
|
|
|
|
|
array(
|
|
|
|
|
'method' => 'POST',
|
|
|
|
|
'header' => 'Content-Type: application/json',
|
|
|
|
|
'content' => json_encode($postData),
|
|
|
|
|
'timeout' => 6,
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$context = StreamContextFactory::getContext($opts);
|
|
|
|
|
@file_get_contents($this->notifyUrl, false, $context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setRootAliases(array $rootAliases)
|
|
|
|
|
{
|
|
|
|
|
$this->rootAliases = $rootAliases;
|
|
|
|
@ -340,7 +367,15 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
|
|
|
|
|
|
|
|
|
|
$data = $this->fetchFile($jsonUrl, 'packages.json');
|
|
|
|
|
|
|
|
|
|
if (!empty($data['notify'])) {
|
|
|
|
|
if (!empty($data['notify_batch'])) {
|
|
|
|
|
if ('/' === $data['notify_batch'][0]) {
|
|
|
|
|
$this->notifyUrl = preg_replace('{(https?://[^/]+).*}i', '$1' . $data['notify_batch'], $this->url);
|
|
|
|
|
} else {
|
|
|
|
|
$this->notifyUrl = $data['notify_batch'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$this->notifyUrl && !empty($data['notify'])) {
|
|
|
|
|
if ('/' === $data['notify'][0]) {
|
|
|
|
|
$this->notifyUrl = preg_replace('{(https?://[^/]+).*}i', '$1' . $data['notify'], $this->url);
|
|
|
|
|
} else {
|
|
|
|
|