Inheritance: extends Data
Beispiel #1
0
 /**
  * Send message for admin when created new user.
  *
  * @return void
  */
 public function adminNewUserMsg()
 {
     $adminMail = Plugin::params('Union/Core')->get('admin_mail', '*****@*****.**');
     $tpl = $this->_params->get('msg_adm_new_registration');
     $msg = $this->_macros->text($tpl);
     $subject = $this->_params->get('msg_adm_new_reg_subject', __d('community', 'Registered a new user'));
     $this->send($subject, $msg, $adminMail);
 }
Beispiel #2
0
 /**
  * Write data in json file.
  *
  * @return void
  */
 protected function _write()
 {
     $this->_bufferActivated();
     $this->_bufferLoaded();
     $JSON = new JSON($this->_buffer);
     $file = Path::loadedFolder() . $this->_config['file'];
     $File = new File($file);
     $File->write($JSON->write());
 }
Beispiel #3
0
 /**
  * @return JSON
  */
 public function getJSON()
 {
     if (null === $this->_jsonData) {
         $this->_jsonData = new JSON($this->get('body'));
         $this->_jsonData->setFlags(\ArrayObject::ARRAY_AS_PROPS);
         // For JBZoo/Data less 1.4.2
     }
     return $this->_jsonData;
 }
Beispiel #4
0
 /**
  * Response constructor.
  * @param array|string $data
  */
 public function __construct($data = array())
 {
     foreach ($this->_default as $key => $value) {
         $this[$key] = $value;
     }
     parent::__construct($data);
 }
Beispiel #5
0
 /**
  * Sending notifications to the administrator of the new user registration.
  *
  * @return void
  */
 public function sendAdminMessageNewReg()
 {
     $emailTo = $this->config->get('site_email', '*****@*****.**');
     $message = $this->_community->get('msg_adm_new_registration', null);
     $message = Macros::getInstance($this->_arrayData)->text($message);
     if (isset($this->_entityId) && $message) {
         $subject = __d('community', 'New user registration at the site: {0}', $this->_serverName);
         $this->_send($subject, $message, $emailTo);
     }
 }
Beispiel #6
0
 /**
  * Email constructor.
  *
  * @param Entity $entity
  */
 public function __construct(Entity $entity)
 {
     $config = PluginConfig::getInstance()->getGroup('union_core');
     $this->_entity = $entity;
     $this->config = $config->params();
     $this->_entityId = $entity->get('id');
     $this->_arrayData = $entity->toArray();
     $this->_serverName = Union::serverName();
     $this->mailer = $this->config->get('mailer', 'mail');
     $this->fromName = $this->config->get('mailfrom', 'Union CMS');
     $this->fromEmail = $this->config->get('mailname', '*****@*****.**');
 }
Beispiel #7
0
 public function testSend_headers()
 {
     $uniq = uniqid();
     $resp = $this->_cms['http']->request('http://mockbin.org/headers', array(), array('headers' => array('x-custom-header' => $uniq)));
     $data = new JSON($resp->body);
     $dataFlat = $data->flattenRecursive();
     isTrue(in_array('x-custom-header', $dataFlat, true));
     isTrue(in_array($uniq, $dataFlat, true));
 }
Beispiel #8
0
 /**
  * Get JSON from php://input stream
  *
  * @param string $name
  * @param null   $default
  * @param null   $filters
  * @return Data|mixed
  */
 public function getJSON($name = null, $default = null, $filters = null)
 {
     static $data;
     $input = null;
     if (null === $data) {
         if ($this->getHeader('Content-Type', 'text/html', 'low') === 'application/json') {
             $input = file_get_contents('php://input');
         }
         $data = new JSON($input);
     }
     if (null === $name) {
         return $data;
     }
     $result = $data->find($name, $default, $filters);
     return $result;
 }
Beispiel #9
0
 /**
  * Callback before request data is converted into entities.
  *
  * @param Event $event
  * @param \ArrayObject $data
  * @param \ArrayObject $options
  * @return $this
  * @SuppressWarnings("unused")
  */
 public function beforeMarshal(Event $event, \ArrayObject $data, \ArrayObject $options)
 {
     if (isset($data[$this->_paramsFiled]) && is_array($data[$this->_paramsFiled])) {
         $params = new JSON($data[$this->_paramsFiled]);
         $data[$this->_paramsFiled] = $params->write();
     }
     return $this;
 }