1
0
Fork 0

Add parsing of keywords/authors/release date to the ArrayLoader

pull/110/merge
Jordi Boggiano 2011-11-20 16:50:53 +01:00
parent 1456a157ea
commit a13c35537c
3 changed files with 98 additions and 4 deletions

View File

@ -69,12 +69,26 @@ class ArrayLoader
$package->setRepositories($config['repositories']); $package->setRepositories($config['repositories']);
} }
if (isset($config['extra'])) { if (isset($config['extra']) && is_array($config['extra'])) {
$package->setExtra($config['extra']); $package->setExtra($config['extra']);
} }
if (isset($config['license'])) { if (!empty($config['keywords'])) {
$package->setLicense($config['license']); $package->setKeywords(is_array($config['keywords']) ? $config['keywords'] : array($config['keywords']));
if (!empty($config['license'])) {
$package->setLicense(is_array($config['license']) ? $config['license'] : array($config['license']));
}
if (!empty($config['time'])) {
try {
$package->setReleaseDate(new \DateTime($config['time']));
} catch (\Exception $e) {
}
}
if (!empty($config['authors']) && is_array($config['authors'])) {
$package->setAuthors($config['authors']);
} }
if (isset($config['installation-source'])) { if (isset($config['installation-source'])) {

View File

@ -33,6 +33,9 @@ class MemoryPackage extends BasePackage
protected $prettyVersion; protected $prettyVersion;
protected $repositories; protected $repositories;
protected $license; protected $license;
protected $releaseDate;
protected $keywords;
protected $authors;
protected $extra = array(); protected $extra = array();
protected $requires = array(); protected $requires = array();
@ -394,6 +397,60 @@ class MemoryPackage extends BasePackage
return $this->suggests; return $this->suggests;
} }
/**
* Set the releaseDate
*
* @param DateTime $releaseDate
*/
public function setReleasedate(\DateTime $releaseDate)
{
$this->releaseDate = $releaseDate;
}
/**
* {@inheritDoc}
*/
public function getReleaseDate()
{
return $this->releaseDate;
}
/**
* Set the keywords
*
* @param array $keywords
*/
public function setKeywords(array $keywords)
{
$this->keywords = $keywords;
}
/**
* {@inheritDoc}
*/
public function getKeywords()
{
return $this->keywords;
}
/**
* Set the authors
*
* @param array $authors
*/
public function setAuthors(array $authors)
{
$this->authors = $authors;
}
/**
* {@inheritDoc}
*/
public function getAuthors()
{
return $this->authors;
}
/** /**
* Set the autoload mapping * Set the autoload mapping
* *

View File

@ -259,7 +259,30 @@ interface PackageInterface
function getRepository(); function getRepository();
/** /**
* Returns package unique name, constructed from name, version and release type. * Returns the release date of the package
*
* @return DateTime
*/
function getReleaseDate();
/**
* Returns an array of keywords relating to the package
*
* @return array
*/
function getKeywords();
/**
* Returns an array of authors of the package
*
* Each item can contain name/homepage/email keys
*
* @return array
*/
function getAuthors();
/**
* Returns package unique name, constructed from name and version.
* *
* @return string * @return string
*/ */