Add getNames methods to managers
modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php modifié: core/lib/Thelia/Core/FileFormat/Formatter/FormatterManager.php
This commit is contained in:
@@ -20,6 +20,7 @@ use Thelia\Core\Translation\Translator;
|
|||||||
*/
|
*/
|
||||||
class ArchiveBuilderManager
|
class ArchiveBuilderManager
|
||||||
{
|
{
|
||||||
|
/** @var array */
|
||||||
protected $archiveBuilders = array();
|
protected $archiveBuilders = array();
|
||||||
|
|
||||||
protected $environment;
|
protected $environment;
|
||||||
@@ -29,15 +30,15 @@ class ArchiveBuilderManager
|
|||||||
$this->environment = $environment;
|
$this->environment = $environment;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param AbstractArchiveBuilder $archiveCreator
|
* @param AbstractArchiveBuilder $archiveBuilder
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function add(AbstractArchiveBuilder $archiveCreator)
|
public function add(AbstractArchiveBuilder $archiveBuilder)
|
||||||
{
|
{
|
||||||
if (null !== $archiveCreator) {
|
if (null !== $archiveBuilder) {
|
||||||
$archiveCreator->setEnvironment($this->environment);
|
$archiveBuilder->setEnvironment($this->environment);
|
||||||
|
|
||||||
$this->archiveBuilders[$archiveCreator->getName()] = $archiveCreator;
|
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -60,13 +61,28 @@ class ArchiveBuilderManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[AbstractArchiveBuilder]
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getAll()
|
public function getAll()
|
||||||
{
|
{
|
||||||
return $this->archiveBuilders;
|
return $this->archiveBuilders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getNames()
|
||||||
|
{
|
||||||
|
$names = [];
|
||||||
|
|
||||||
|
/** @var AbstractArchiveBuilder $builder */
|
||||||
|
foreach($this->archiveBuilders as $builder) {
|
||||||
|
$names[] = $builder->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
|
||||||
public function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
if (!array_key_exists($name, $this->archiveBuilders)) {
|
if (!array_key_exists($name, $this->archiveBuilders)) {
|
||||||
|
|||||||
@@ -69,6 +69,21 @@ class FormatterManager
|
|||||||
return $this->formatters;
|
return $this->formatters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getNames()
|
||||||
|
{
|
||||||
|
$names = [];
|
||||||
|
|
||||||
|
/** @var AbstractFormatter $formatter */
|
||||||
|
foreach($this->formatters as $formatter) {
|
||||||
|
$names[] = $formatter->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @throws \OutOfBoundsException
|
* @throws \OutOfBoundsException
|
||||||
|
|||||||
Reference in New Issue
Block a user