Example #1
0
 /**
  * Save configurations to database
  *
  * @param string $selector - config selector
  * @param mixed $value - config value
  * @void                    - save configurations to database
  */
 public function setSession($selector = null, $value = null)
 {
     $this->_data = $this->_system->navigate($this->_data, $selector, $value);
     $empty = $this->_db->getItem();
     $empty->id = $this->_id;
     $empty->value = $this->_data;
     $this->_db->save($empty);
 }
Example #2
0
 /**
  * Set config to block`s file named like bBlock__bConfig.php
  *
  * @param string $selector - config selector
  * @param mixed $value - config value
  * @return int
  * @throws Exception
  * @void                    - store configuration in block's file
  */
 public function setConfig($selector = '', $value = null, $parent = null)
 {
     /** @var string $name - block`s name */
     $name = strpos($selector, '.') ? strstr($selector, '.', true) : $selector;
     if (!array_key_exists($name, $this->_config)) {
         $this->_config[$name] = array();
     }
     // Extend local configuration
     $this->_config = $this->_system->navigate($this->_config, $selector, $value);
     // Convert it to string
     $config = json_encode($this->_config[$name], 256);
     // Check folder
     $path = bBlib::path($name . '__bConfig');
     if (!is_dir($path)) {
         mkdir($path);
     }
     // Save file
     $file = bBlib::path($name . '__bConfig', 'php');
     $content = sprintf('{
         "name":"%s",
         "value":%s,
         "parent":"%s"
     }', $name, addslashes($config), $parent);
     return file_put_contents($file, "<?php defined('_BLIB') or die(); return '" . $content . "';");
 }
Example #3
0
 /**
  * Save configurations to database
  *
  * @param string $selector	- config selector
  * @param mixed $value 		- config value
  * @void 					- save configurations to database
  */
 public function setConfig($selector = '', $value = null)
 {
     // Protect from loop
     if ($selector == 'bDatabase') {
         /** @var bConfig $bConfig   - parent block */
         $bConfig = $this->_parent;
         /** @var bConfig__local $bConfig__local - default config strategy */
         $bConfig__local = $bConfig->getInstance('bConfig__local');
         return $bConfig__local->setConfig($selector, $value);
     }
     $config = $this->_db->getItem($selector);
     $config->value = $value;
     $config->name = $selector;
     $this->_config = $this->_system->navigate($this->_config, $selector, $config->value);
     $this->_db->save($config);
 }
Example #4
0
 /**
  * Save configurations to database
  *
  * @param string $selector	- config selector
  * @param mixed $value 		- config value
  * @void 					- save configurations to database
  */
 public function setSession($selector = null, $value = null)
 {
     $this->_data = $this->_system->navigate($this->_data, $selector, $value);
     $_SESSION[__CLASS__] = $this->_data;
 }