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

main
Jordi Boggiano 13 years ago
parent 1456a157ea
commit a13c35537c

@ -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'])) {

@ -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
* *

@ -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
*/ */

Loading…
Cancel
Save