Пример #1
0
 /**
  * Sets a data value.
  *
  * @param string $key
  * @param mixed  $value
  */
 public function set($key, $value)
 {
     if (null === $this->data) {
         $this->data = [];
     }
     Arr::set($this->data, $key, $value);
 }
Пример #2
0
 /**
  * @param string $key
  * @param null $default
  * @return array|mixed
  */
 public function get($key, $default = null)
 {
     if (is_array($key)) {
         return Arr::extract($this->data, $key);
     }
     return Arr::get($this->data, $key, $default);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function config($key = null, $default = null)
 {
     if (is_array($key)) {
         return Arr::extract($this->config, $key);
     }
     return Arr::get($this->config, $key, $default);
 }
Пример #4
0
 /**
  * Note: If the mailer is accessed prior to this controller action, this will possibly test the wrong mailer
  *
  * @Request({"option": "array"}, csrf=true)
  */
 public function emailAction($option = [])
 {
     try {
         $config = Arr::merge(App::module('system/mail')->config(), $option);
         $response['success'] = (bool) App::mailer()->create(__('Test email!'), __('Testemail'), $config['from_address'])->send();
         $response['message'] = $response['success'] ? __('Mail successfully sent!') : __('Mail delivery failed!');
     } catch (\Exception $e) {
         $response = ['success' => false, 'message' => sprintf(__('Mail delivery failed! (%s)'), $e->getMessage())];
     }
     return $response;
 }
Пример #5
0
 /**
  * @Request({"config": "array"})
  */
 public function checkAction($config = [])
 {
     $status = 'no-connection';
     $message = '';
     try {
         try {
             if (!$this->config) {
                 foreach ($config as $name => $values) {
                     if ($module = App::module($name)) {
                         $module->config = Arr::merge($module->config, $values);
                     }
                 }
             }
             App::db()->connect();
             if (App::db()->getUtility()->tableExists('@system_config')) {
                 $status = 'tables-exist';
                 $message = __('Existing Rimbo installation detected. Choose different table prefix?');
             } else {
                 $status = 'no-tables';
             }
         } catch (ConnectionException $e) {
             if ($e->getPrevious()->getCode() == 1049) {
                 $this->createDatabase();
                 $status = 'no-tables';
             } else {
                 throw $e;
             }
         }
     } catch (\Exception $e) {
         $message = __('Database connection failed!');
         if ($e->getCode() == 1045) {
             $message = __('Database access denied!');
         }
     }
     return ['status' => $status, 'message' => $message];
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     Arr::set($this->data, $key, $value);
 }
 /**
  * JsonSerializable constructor.
  * @param array  $data
  */
 public function __construct(array $data = [])
 {
     foreach (get_object_vars($this) as $key => $default) {
         $this->{$key} = Arr::get($data, $key, $default);
     }
 }
Пример #8
0
 /**
  * @param  mixed $values
  * @param  bool  $replace
  * @return self
  */
 public function addParameters(array $values, $replace = false)
 {
     $this->parameters = Arr::merge($this->parameters, $values, $replace);
     return $this;
 }
Пример #9
0
 /**
  * Extracts config values.
  *
  * @param  array $keys
  * @param  bool  $include
  * @return array
  */
 public function extract($keys, $include = true)
 {
     return Arr::extract($this->values, $keys, $include);
 }
Пример #10
0
 /**
  * Unset a value.
  * @param string $key
  */
 public function offsetUnset($key)
 {
     $config = $this->getConfig();
     Arr::remove($config, $key);
 }
Пример #11
0
 /**
  * Sets a data value.
  * @param string $key
  * @param mixed  $value
  * @param array  $valuedata
  */
 public function set($key, $value, $valuedata = [])
 {
     $this->getProfile();
     Arr::set($this->data, $key, $value);
     if (isset($this->fieldValues[$key])) {
         $this->fieldValues[$key]->setValue($value, $valuedata);
     }
 }