51 if (!is_null($moduleDir)) {
52 $moduleDir = rtrim($moduleDir,
'\\/');
55 $this->_moduleDir = $moduleDir;
73 if (is_string($file)) {
74 $file = new \SplFileObject($file);
96 if (!$file->isReadable()) {
97 throw new \ErrorException(sprintf(
'Package file "%s" not readable', $file->getPathname()));
100 $map = $this->_parseMappings();
109 protected function _parseMappings()
114 $package = simplexml_load_file($this->
getFile()->getPathname());
115 if (isset($package)) {
116 foreach ($package->xpath(
'//contents/target') as
$target) {
120 foreach (
$target->children() as $child) {
128 catch (RuntimeException $e) {
147 if (! isset($targets[
$name])) {
148 throw new RuntimeException(
'Invalid target type ' .
$name);
150 return $targets[
$name];
158 if (! $this->_targets) {
160 $targets = simplexml_load_file(
__DIR__ .
'/../../../../res/target.xml');
161 foreach ($targets as
$target) {
163 $this->_targets[
"{$attributes->name}"] =
"{$attributes->uri}";
177 $elementPaths = array();
182 foreach (
$element->children() as $child) {
184 $elementPaths[] =
$name ==
'.' ? $elementPath :
$name .
'/' . $elementPath;
188 $elementPaths[] =
$name;
193 $elementPaths[] =
$name;
197 throw new RuntimeException(
'Unknown path type: ' .
$type);
200 return $elementPaths;
209 foreach (
$element->children() as $child) {
getElementPaths(\SimpleXMLElement $element)
defined('TESTS_BP')||define('TESTS_BP' __DIR__
__construct($moduleDir, $packageXmlFile, $translations=array(), $pathSuffix)
translatePathMappings($mappings)
getTargetPath(\SimpleXMLElement $target)
getFirstChild(\SimpleXMLElement $element)
if(!isset($_GET['name'])) $name