public function indexAction()
 {
     echo __METHOD__;
     $configArray = array('website' => '<h3>www.zend.vn</h3>', 'account' => array('email' => '*****@*****.**', 'password' => '123456', 'title' => 'Zend Config', 'content' => 'Training Zend Config', 'port' => '465'));
     // 01 Chuyen 1 mang config thanh 1 doi tuong config cua Zend Framework
     //$config 	=	new \Zend\Config\Config($configArray);
     //echo '<br />'. $config->account->get('port_abc', 500);
     // 02 Chuyen file config thanh 1 doi tuong config
     //$config 	=	new \Zend\Config\Config(include __DIR__ . '/../../../config/module.config.php');
     /*echo '<pre>';
     		print_r($config);
     		echo '</pre>';*/
     // 03 Zend\Config\Processor\ thuc hien mot so hanh dong tren doi tuong Zend\Config\Config
     /*define('MYCONST', 'This is a constant');
     		$processor	=	new \Zend\Config\Processor\Constant();
     		
     		$config 	=	new \Zend\Config\Config(array('const' => 'MYCONST'), true);
     		
     		$processor->process($config);*/
     /*echo '<pre>';
     		print_r($configArray);
     		echo '</pre>';*/
     // Zend\Config\Processor\Filter
     $config = new \Zend\Config\Config($configArray, true);
     $filter = new \Zend\Filter\StringToUpper();
     $processor = new \Zend\Config\Processor\Filter($filter);
     $processor->process($config);
     echo '<br />' . $config->account->content;
     // Zend\Config\Processor\Queue
     // FIFO logic (First In, First Out)
     $config = new \Zend\Config\Config($configArray, true);
     $filterUpper = new \Zend\Filter\StringToUpper();
     $filterStripTags = new \Zend\Filter\StripTags();
     $processorUpper = new \Zend\Config\Processor\Filter($filterUpper);
     $processStripTags = new \Zend\Config\Processor\Filter($filterStripTags);
     $queue = new \Zend\Config\Processor\Queue();
     $queue->insert($processorUpper);
     $queue->insert($processStripTags);
     $queue->process($config);
     // Zend\Config\Processor\Token
     $config = new ZCConfig(array('token' => 'Token value: TOKEN'), true);
     $processor = new ZCPToken();
     $processor->addToken('TOKEN', 'Hello');
     $processor->process($config);
     echo '<pre>';
     print_r($config);
     echo '</pre>';
     // Disable View
     // Method 1: return false;
     // Method 2: return '';
     // Disable layout
     // $viewModel 	=	new ViewModel();
     // $viewModel->setTerminal(true);
     // return $viewModel;
     // Disable Layout & Disable View
     // Method 1: return $this->getResponse();
     // Method 2:
     return false;
 }
 /**
  * Substitute defined variables, if any found and return the new configuration object
  *
  * @param Config $config
  * @param string $prefix
  * @param string $suffix
  * @return Config
  */
 protected function substituteVars(Config $config, $prefix = '{', $suffix = '}')
 {
     $arrayConfig = $config->toArray();
     if (isset($arrayConfig['variables'])) {
         $vars = array_map(function ($x) use($prefix, $suffix) {
             return $prefix . $x . $suffix;
         }, array_keys($arrayConfig['variables']));
         $vals = array_values($arrayConfig['variables']);
         $tokens = array_combine($vars, $vals);
         $processor = new Token();
         $processor->setTokens($tokens);
         $processor->process($config);
         // Remove variables node
         unset($config->variables);
     }
     return $config;
 }
 /**
  * @depends testTokenSurround
  */
 public function testTokenChangeParams()
 {
     $config = new Config($this->tokenSurroundMixed, true);
     $processor = new TokenProcessor(array('TOKEN' => 'some replaced value'), '##', '##');
     $processor->process($config);
     $this->assertEquals('some replaced value', $config->simple);
     $this->assertEquals('## some text with some replaced value inside ##', $config->inside);
     $this->assertEquals('@@TOKEN@@', $config->nested->simple);
     $this->assertEquals('@@ some text with @@TOKEN@@ inside @@', $config->nested->inside);
     /**
      * Now change prefix and suffix on the processor
      */
     $processor->setPrefix('@@');
     $processor->setSuffix('@@');
     /**
      * Parse the config again
      */
     $processor->process($config);
     $this->assertEquals('some replaced value', $config->simple);
     $this->assertEquals('## some text with some replaced value inside ##', $config->inside);
     $this->assertEquals('some replaced value', $config->nested->simple);
     $this->assertEquals('@@ some text with some replaced value inside @@', $config->nested->inside);
 }
Exemple #4
0
/**
 * Test Bootstrapper
 *
 * @copyright Copyright (c) 2012 WebPT, INC
 */
date_default_timezone_set('UTC');
error_reporting(E_ALL | E_STRICT);
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(__DIR__ . '/../..'));
chdir(APPLICATION_PATH);
require_once __DIR__ . "/../../vendor/autoload.php";
// special import for the module class as it doesn't appear to namespace structure
require_once __DIR__ . '/../../Module.php';
use EMRCore\Config\Application as ApplicationConfig;
use Zend\Config\Config as ZendConfig;
use Zend\Config\Processor\Token;
// Core global config.
$moduleConfig = new ZendConfig(include __DIR__ . '/../../vendor/WebPT/EMRCore/src/EMRCore/Config/config/global.php', true);
// Module config.
$module = new DeskModule\Module();
$moduleConfig->merge(new ZendConfig($module->getConfig()));
// Integration global config.
$moduleConfig->merge(new ZendConfig(include __DIR__ . '/config/global.php'));
// Integration local config.
if (file_exists(__DIR__ . '/config/local.php') == true) {
    $localTestConfig = new ZendConfig(include __DIR__ . '/config/local.php', true);
    $moduleConfig->merge($localTestConfig);
}
$processor = new Token($moduleConfig->get('tokens'));
$processor->process($moduleConfig);
ApplicationConfig::getInstance()->setConfiguration($moduleConfig->toArray(), false);
Exemple #5
0
 /**
  * @group ZF2-5772
  */
 public function testIgnoresEmptyStringReplacement()
 {
     $config = new Config(array('foo' => 'bar'), true);
     $processor = new TokenProcessor(array('' => 'invalid'));
     $processor->process($config);
     $this->assertSame('bar', $config['foo']);
 }
Exemple #6
0
 /**
  * @param string $prefix                Optional prefix
  * @param string $suffix                Optional suffix
  */
 public function __construct($prefix = '', $suffix = '')
 {
     // if $_ENV is empty, check php.ini option 'variables_order'
     // it must contain 'E'
     parent::__construct($_ENV, $prefix, $suffix);
 }