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

hotfix : restrict other "in db" modules to be download-able #90

Merged
merged 1 commit into from
Dec 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is loop in factory ok ? or create new service just to collect array of moduleName ? or use loop in controller instead ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any problem

Alejandro Celaya Alastrué
http://www.alejandrocelaya.com
El 27/12/2014 03:26, "Abdul Malik Ikhsan" notifications@github.com
escribió:

In
module/Application/src/Application/Factory/Controller/DownloadControllerFactory.php
#90 (diff):

@@ -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();
    
  •    }
    

is loop in factory ok ? or create new service just to collect array of
moduleName ? or use loop in controller instead ?


Reply to this email directly or view it on GitHub
https://github.com/sitrunlab/LearnZF2/pull/90/files#r22290687.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, merging ;)


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