public function offsetGet($index) { if ($index == 'db' && !parent::offsetExists($index)) { $v = Kwf_Setup::createDb(); $this->offsetSet('db', $v); return $v; } else { if ($index == 'config' && !parent::offsetExists($index)) { $v = Kwf_Config_Web::getInstance(); $this->offsetSet('config', $v); return $v; } else { if ($index == 'dao' && !parent::offsetExists($index)) { $v = Kwf_Setup::createDao(); $this->offsetSet('dao', $v); return $v; } else { if ($index == 'acl' && !parent::offsetExists($index)) { $v = Kwf_Acl::getInstance(); $this->offsetSet('acl', $v); return $v; } else { if ($index == 'userModel' && !parent::offsetExists($index)) { $v = self::get('config')->user->model; if ($v) { $v = Kwf_Model_Abstract::getInstance($v); } $this->offsetSet('userModel', $v); return $v; } else { if ($index == 'trl' && !parent::offsetExists($index)) { $v = Kwf_Trl::getInstance(); $this->offsetSet('trl', $v); return $v; } } } } } } return parent::offsetGet($index); }
public static function getValue($var) { $cacheId = 'config-' . $var; $ret = Kwf_Cache_SimpleStatic::fetch($cacheId, $success); if ($success) { return $ret; } $cfg = Kwf_Config_Web::getInstance(); foreach (explode('.', $var) as $i) { if (!isset($cfg->{$i})) { $cfg = null; break; } $cfg = $cfg->{$i}; } $ret = $cfg; if (is_object($ret)) { throw new Kwf_Exception("this would return an object, use getValueArray instead"); } Kwf_Cache_SimpleStatic::add($cacheId, $ret); return $ret; }
public static function getValue($var) { $cacheId = 'config-' . $var; $ret = Kwf_Cache_SimpleStatic::fetch($cacheId, $success); if ($success) { return $ret; } $cfg = Kwf_Config_Web::getInstance(); foreach (explode('.', $var) as $i) { if (!isset($cfg->{$i})) { $cfg = null; break; } $cfg = $cfg->{$i}; } $ret = $cfg; if (is_object($ret)) { $ret = $ret->toArray(); } Kwf_Cache_SimpleStatic::add($cacheId, $ret); return $ret; }
protected function execute(InputInterface $input, OutputInterface $output) { if (!file_exists($_SERVER['HOME'] . '/.aws/config')) { throw new \Exception("Can't get aws config, set up eb cli first"); } $awsConfig = parse_ini_file($_SERVER['HOME'] . '/.aws/config', true); $awsConfig = array('key' => $awsConfig['profile eb-cli']['aws_access_key_id'], 'secret' => $awsConfig['profile eb-cli']['aws_secret_access_key']); $s3 = new \Kwf_Util_Aws_S3($awsConfig); \Kwf_Setup::setUp(); $prodSection = $input->getOption('server'); $prodConfig = \Kwf_Config_Web::getInstance($prodSection); $bucket = $prodConfig->aws->uploadsBucket; if (!$bucket) { throw new \Exception("No aws.uploadBucket configured for '{$prodSection}'"); } $model = \Kwf_Model_Abstract::getInstance('Kwf_Uploads_Model'); $select = new \Kwf_Model_Select(); $it = new \Kwf_Model_Iterator_Packages(new \Kwf_Model_Iterator_Rows($model, $select)); $it = new \Kwf_Iterator_ConsoleProgressBar($it); foreach ($it as $row) { $file = $row->getFileSource(); if (file_exists($file)) { if ($s3->if_object_exists($bucket, $row->id)) { echo "already existing: {$row->id}\n"; } else { echo "uploading: {$row->id}"; $contents = file_get_contents($file); $r = $s3->create_object($bucket, $row->id, array('body' => $contents, 'length' => strlen($contents), 'contentType' => $row->mime_type)); if (!$r->isOk()) { throw new \Exception($r->body); } echo " OK\n"; } } } }
protected static function _getConfigSectionsWithHost() { $webConfigFull = new Zend_Config_Ini('config.ini', null); $sections = array(); $processedDomains = array(); foreach ($webConfigFull as $k => $i) { if ($k == 'dependencies') { continue; } $config = Kwf_Config_Web::getInstance($k); if ($config->server && $config->server->host) { $sections[] = $k; } } return $sections; }