예제 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $licenses = new \LicenseData\Repository();
     $ctx = array();
     $ctx['type'] = 'module';
     $ctx['fullName'] = $input->getArgument('<full.ext.name>');
     $ctx['basedir'] = $ctx['fullName'];
     if (preg_match('/^[a-z0-9\\.]+\\.([a-z0-9]+)$/', $ctx['fullName'], $matches)) {
         $ctx['mainFile'] = $matches[1];
         $ctx['namespace'] = 'CRM/' . strtoupper($ctx['mainFile'][0]) . substr($ctx['mainFile'], 1);
     } else {
         $output->writeln('<error>Malformed package name</error>');
         return;
     }
     if ($input->getOption('author') && $input->getOption('email')) {
         $ctx['author'] = $input->getOption('author');
         $ctx['email'] = $input->getOption('email');
     } else {
         $output->writeln("<error>Missing author name or email address</error>");
         $output->writeln("<error>Please pass --author and --email, or set defaults in ~/.gitconfig</error>");
         return;
     }
     $ctx['license'] = $input->getOption('license');
     if ($licenses->get($ctx['license'])) {
         $output->writeln(sprintf('<comment>License set to %s (authored by %s \\<%s>)</comment>', $ctx['license'], $ctx['author'], $ctx['email']));
         $output->writeln('<comment>If this is in error, please correct info.xml and LICENSE.txt</comment>');
     } else {
         $output->writeln('<error>Unrecognized license (' . $ctx['license'] . ')</error>');
         return;
     }
     $ext = new Collection();
     $output->writeln("<info>Initalize module " . $ctx['fullName'] . "</info>");
     $basedir = new Path($ctx['basedir']);
     $ext->builders['dirs'] = new Dirs(array($basedir->string('build'), $basedir->string('templates'), $basedir->string('xml'), $basedir->string($ctx['namespace'])));
     $ext->builders['info'] = new Info($basedir->string('info.xml'));
     $ext->builders['module'] = new Module($this->getContainer()->get('templating'));
     $ext->builders['license'] = new License($licenses->get($ctx['license']), $basedir->string('LICENSE.txt'), FALSE);
     $ext->loadInit($ctx);
     $ext->save($ctx, $output);
     $this->tryEnable($input, $output, $ctx['fullName']);
 }
예제 #2
0
파일: Info.php 프로젝트: twomice/civix
 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);
 }
예제 #3
0
 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());
 }