forked from pyrus/Pyrus
/
Base.php
60 lines (56 loc) · 1.79 KB
/
Base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* \Pyrus\Registry\Base
*
* PHP version 5
*
* @category Pyrus
* @package Pyrus
* @author Greg Beaver <cellog@php.net>
* @copyright 2010 The PEAR Group
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @link https://github.com/pyrus/Pyrus
*/
namespace Pyrus\Registry;
/**
* Base class for a Pyrus Registry
*
* @category Pyrus
* @package Pyrus
* @author Greg Beaver <cellog@php.net>
* @copyright 2010 The PEAR Group
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @link https://github.com/pyrus/Pyrus
*/
abstract class Base implements \Pyrus\RegistryInterface
{
protected $packagename;
protected $packageList = array();
/**
* Used by the registry package classes to update info in an installed package
*/
public function replace(\Pyrus\PackageFileInterface $info)
{
return $this->install($info, true);
}
function cloneRegistry(Base $registry)
{
try {
$packageiterator = $registry->package;
foreach (\Pyrus\Config::current()->channelregistry->listChannels() as $channel) {
$packageiterator->setIteratorChannel($channel);
foreach ($packageiterator as $package) {
if ($this->exists($package->name, $package->channel)) {
$old = $this->toPackageFile($package->name, $package->channel);
if ($old->date == $package->date && $old->time == $package->time) {
continue;
}
}
$this->replace($package);
}
}
} catch (\Exception $e) {
throw new Exception('Cannot clone registry', $e);
}
}
}