Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
hotfix : restrict other "in db" module to be download-able
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 27, 2014
1 parent 534a927 commit d172544
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ class DownloadController extends AbstractActionController
/**
* @var array
*/
private $applicationConfig;
private $modulesList;

/**
* Construct applicationConfig
* Construct $modulesList
*
* @param array $applicationConfig
* @param array $modulesList
*/
public function __construct(array $applicationConfig)
public function __construct(array $modulesList)
{
$this->applicationConfig = $applicationConfig;
$this->modulesList = $modulesList;
}

/**
Expand All @@ -32,10 +32,9 @@ public function learnmoduleAction()
{
$module = $this->params()->fromRoute('module', '');
$compress = $this->params()->fromRoute('compress', 'zip');
$modules = $this->applicationConfig['modules'];

$response = $this->getResponse();
if (in_array($module, $modules)) {
if (in_array($module, $this->modulesList)) {
$currDateTime = date('Y-m-dHis');

$fileToArchive = $module.'.'.(($compress == 'zip') ? 'zip' : 'bz2');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Application\Factory\Controller;

use Application\Controller\DownloadController;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Application\Controller\DownloadController;

class DownloadControllerFactory implements FactoryInterface
{
Expand All @@ -14,7 +14,13 @@ class DownloadControllerFactory implements FactoryInterface
public function createService(ServiceLocatorInterface $serviceLocator)
{
$services = $serviceLocator->getServiceLocator();
$moduleList = [];
foreach ($services->get('Doctrine\ORM\EntityManager')
->getRepository('Application\Entity\ModuleList')
->findAll() as $module) {
$moduleList[] = $module->getModuleName();
}

return new DownloadController($services->get('ApplicationConfig'));
return new DownloadController($moduleList);
}
}

0 comments on commit d172544

Please sign in to comment.