function init(&$ctx) { $xml = new SimpleXMLElement('<extension></extension>'); $xml->addAttribute('key', $ctx['fullName']); $xml->addAttribute('type', $ctx['type']); // $xml->addChild('downloadUrl', 'http://FIXME/' . $ctx['fullName'] . '.zip'); $xml->addChild('file', $ctx['mainFile']); $xml->addChild('name', 'FIXME'); $xml->addChild('description', 'FIXME'); // urls $xml->addChild('license', isset($ctx['license']) ? $ctx['license'] : 'FIXME'); $maint = $xml->addChild('maintainer'); $maint->addChild('author', isset($ctx['author']) ? $ctx['author'] : 'FIXME'); $maint->addChild('email', isset($ctx['email']) ? $ctx['email'] : '*****@*****.**'); $urls = $xml->addChild('urls'); $urls->addChild('url', 'http://FIXME')->addAttribute('desc', 'Main Extension Page'); $urls->addChild('url', 'http://FIXME')->addAttribute('desc', 'Documentation'); $urls->addChild('url', 'http://FIXME')->addAttribute('desc', 'Support'); $licenses = new \LicenseData\Repository(); if (isset($ctx['license']) && ($license = $licenses->get($ctx['license']))) { $urls->addChild('url', $license->getUrl())->addAttribute('desc', 'Licensing'); } else { $urls->addChild('url', 'http://FIXME')->addAttribute('desc', 'Licensing'); } $xml->addChild('releaseDate', date('Y-m-d')); $xml->addChild('version', '1.0'); $xml->addChild('develStage', 'alpha'); $xml->addChild('compatibility')->addChild('ver', '4.2'); $xml->addChild('comments', 'This is a new, undeveloped module'); // store extra metadata to facilitate code manipulation $civix = $xml->addChild('civix'); if (isset($ctx['namespace'])) { $civix->addChild('namespace', $ctx['namespace']); } if (isset($ctx['typeInfo'])) { $typeInfo = $xml->addChild('typeInfo'); foreach ($ctx['typeInfo'] as $key => $value) { $typeInfo->addChild($key, $value); } } $this->set($xml); }
function testByName() { $licenses = new \LicenseData\Repository(); $this->assertEquals('GNU Lesser General Public License v2.1 or later', $licenses->get('LGPL-2.1+')->getTitle()); $this->assertEquals('http://www.gnu.org/licenses/lgpl-2.1.html', $licenses->get('LGPL-2.1+')->getUrl()); }
protected function getLicenses() { $licenses = new \LicenseData\Repository(); return array_keys($licenses->getAll()); }