-
Notifications
You must be signed in to change notification settings - Fork 3
/
HordeSplit.php
113 lines (107 loc) · 3.26 KB
/
HordeSplit.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* Horde_Pear_Package_Type_Horde:: deals with packages provided by Horde.
*
* PHP version 5
*
* @category Horde
* @package Pear
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
*/
/**
* Deals with packages provided by Horde in the split repository structure.
*
* Copyright 2011-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Pear
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
*/
class Horde_Pear_Package_Type_HordeSplit extends Horde_Pear_Package_Type_Horde
{
/**
* Get the package type.
*
* @return string The type: "Application" or "Component".
* @throws Horde_Pear_Exception
*/
public function getType()
{
if (!file_exists($this->getRootPath() . '/.horde.yml')) {
throw new Horde_Pear_Exception('Cannot find the horde.yml file.');
}
$yml = Horde_Yaml::loadFile($this->getRootPath() . '/.horde.yml');
return ($yml['type'] == 'application') ? 'Application' : 'Component';
}
/**
* Get the package name.
*
* @return string The package name.
*/
public function getName()
{
if ($this->getType() == 'Application') {
return basename($this->getRootPath());
} else {
return 'Horde_' . basename($this->getRootPath());
}
}
/**
* Return the ignore handler for this package.
*
* @return Horde_Pear_Package_Contents_Ignore The ignore handler.
*/
public function getIgnore()
{
return new Horde_Pear_Package_Contents_Ignore_Composite(
array(
new Horde_Pear_Package_Contents_Ignore_Dot(),
new Horde_Pear_Package_Contents_Ignore_Symlink(),
new Horde_Pear_Package_Contents_Ignore_Patterns(
array(
'/package.xml',
'*~',
'conf.php',
'CVS/*',
'bin/.htaccess',
'composer.*',
'.horde.yml',
'.git/*',
'.gitignore'
),
$this->getRepositoryRoot()
),
new Horde_Pear_Package_Contents_Ignore_Git(
$this->getGitIgnore(),
$this->getRepositoryRoot()
),
new Horde_Pear_Package_Contents_Ignore_Composer()
)
);
}
/**
* Return the contents of the Horde .gitignore file.
*
* @return string The .gitignore patterns.
*/
public function getGitIgnore()
{
return file_get_contents($this->getRepositoryRoot() . '/.gitignore');
}
/**
* The repository root is the same as the package root.
*
* @return string The repository path.
*/
public function getRepositoryRoot()
{
return $this->getRootPath();
}
}