Skip to content
Browse files

made self install much harder to use

added module whitelist for self install
added requirement for separate autoinstall/upgrade methods

This now means that in order for self install to be possible
you must define all three of the following manager options

enable_self_installation
manifest_dir
self_install_whitelist
  • Loading branch information...
1 parent 8ff266c commit ae04da697d4202795c273a93c942448a80015aac @phpboyscout phpboyscout committed with EvanDotPro Oct 11, 2011
Showing with 35 additions and 3 deletions.
  1. +6 −3 library/Zend/Module/Manager.php
  2. +29 −0 library/Zend/Module/ManagerOptions.php
View
9 library/Zend/Module/Manager.php
@@ -2,6 +2,8 @@
namespace Zend\Module;
+use Zend\Service\Amazon\Authentication\V1;
+
use Traversable,
Zend\Config\Config,
Zend\Config\Writer\ArrayWriter,
@@ -126,7 +128,8 @@ public function loadModule($moduleName)
$this->addProvision($module);
$this->addDependency($module);
}
- if ($this->getOptions()->getEnableSelfInstallation()) {
+ if ($this->getOptions()->getEnableSelfInstallation() &&
+ in_array($this->getOptions()->getSelfInstallWhitelist(), $moduleName)) {
$this->installModule($module);
}
$this->runModuleInit($module);
@@ -155,7 +158,7 @@ public function installModule($module)
$this->loadInstallationManifest();
foreach ($module->getProvides() as $moduleName => $data) {
if (!isset($this->manifest->{$moduleName})) { // if doesnt exist in manifest
- if (is_callable(array($module, 'install'))) {
+ if (is_callable(array($module, 'autoInstall'))) {
if ($module->install()) {
$this->manifest->{$moduleName} = $data;
$this->manifest->{'_dirty'} = true;
@@ -166,7 +169,7 @@ public function installModule($module)
} elseif (isset($this->manifest->{$moduleName}) && // does exists in manifest
version_compare($this->manifest->{$moduleName}->version, $data['version']) < 0 // and manifest version is less than current version
){
- if (is_callable(array($module, 'upgrade'))) {
+ if (is_callable(array($module, 'autoUpgrade'))) {
if ($module->upgrade($this->manifest->{$moduleName}->version)) {
$this->manifest->{$moduleName} = $data;
$this->manifest->{'_dirty'} = true;
View
29 library/Zend/Module/ManagerOptions.php
@@ -31,6 +31,13 @@ class ManagerOptions
* @var bool
*/
protected $enableSelfInstallation = false;
+
+ /**
+ * array of modules that have been whitelisted to allow self installation
+ *
+ * @var array
+ */
+ protected $selfInstallWhiteList = array();
/**
* Check if the config cache is enabled
@@ -158,6 +165,28 @@ public function setEnableSelfInstallation($bool)
*
* @return bool
*/
+ public function getSelfInstallWhitelist()
+ {
+ return $this->selfInstallWhitelist;
+ }
+
+/**
+ * set if self installation is enabled
+ *
+ * @param bool $bool
+ * @return Manager
+ */
+ public function setSelfInstallWhitelist(array $list)
+ {
+ $this->selfInstallWhitelist = $list;
+ return $this;
+ }
+
+ /**
+ * gets if self installation is enabled
+ *
+ * @return bool
+ */
public function getEnableSelfInstallation()
{
return $this->enableSelfInstallation;

0 comments on commit ae04da6

Please sign in to comment.
Something went wrong with that request. Please try again.