replaceFullStop() статический публичный Метод

|---------------------------------------------------------------------------
static public replaceFullStop ( $array )
 static function replaceFullStop($array)
 {
     $output = [];
     if (!empty($array)) {
         foreach ($array as $key => $value) {
             if (is_array($value)) {
                 $new = Helpers::replaceFullStopInKeys($key);
                 $output[$new] = Helpers::replaceFullStop($value);
             } else {
                 $new = Helpers::replaceFullStopInKeys($key);
                 $output[$new] = $value;
             }
         }
     }
     return $output;
 }
 /**
  * Constructs a update.
  * @param Model $model Model to be updated.
  * @param [String => Mixed] $data Properties to be changed on the model.
  * @param [String => Mixed] $opts
  * @return Model
  */
 protected function constructUpdate(Model $model, array $data, array $opts)
 {
     $this->validateData($data);
     // Sets properties on model.
     if (isset($data['name'])) {
         $model->name = $data['name'];
     }
     if (isset($data['description'])) {
         $model->description = $data['description'];
     }
     if (isset($data['query'])) {
         $model->query = Helpers::replaceFullStop($data['query']);
     }
     if (isset($data['since'])) {
         $model->since = $data['since'];
     }
     if (isset($data['until'])) {
         $model->until = $data['until'];
     }
     return $model;
 }
 /**
  * Constructs a model from the given statement and options.
  * @param \stdClass $statement
  * @param StoreOptions $opts
  * @return [String => Mixed] $model
  */
 private function constructModel(\stdClass $statement, StoreOptions $opts)
 {
     return ['lrs' => ['_id' => $opts->getOpt('lrs_id')], 'client_id' => $opts->getOpt('client')->_id, 'statement' => Helpers::replaceFullStop(json_decode(json_encode($statement), true)), 'active' => false, 'voided' => false, 'timestamp' => new \MongoDate(strtotime($statement->timestamp))];
 }
Пример #4
0
 /**
  * Updates the refs for the given statement.
  * @param \stdClass $statement
  * @param [\stdClass] $refs Statements that are referenced by the given statement.
  * @param StoreOptions $opts
  */
 private function setRefs(\stdClass $statement, array $refs, StoreOptions $opts)
 {
     $this->where($opts)->where('statement.id', $statement->id)->update(['refs' => array_map(function ($ref) {
         return Helpers::replaceFullStop(json_decode(json_encode($ref->statement), true));
     }, $refs)]);
 }
 /**
  * Constructs a model from the given statement and options.
  * @param \stdClass $statement
  * @param StoreOptions $opts
  * @return [String => Mixed] $model
  */
 private function constructModel(\stdClass $statement, StoreOptions $opts)
 {
     $timestamp = new \Carbon\Carbon($statement->timestamp);
     $stored = new \Carbon\Carbon($statement->stored);
     return ['lrs' => ['_id' => $opts->getOpt('lrs_id')], 'lrs_id' => $opts->getOpt('lrs_id'), 'client_id' => $opts->getOpt('client')->_id, 'statement' => Helpers::replaceFullStop(json_decode(json_encode($statement), true)), 'active' => false, 'voided' => false, 'timestamp' => new \MongoDate($timestamp->timestamp, $timestamp->micro), 'stored' => new \MongoDate($stored->timestamp, $stored->micro)];
 }
 /**
  * Updates the refs for the given statement.
  * @param \stdClass $statement
  * @param [\stdClass] $refs Statements that are referenced by the given statement.
  * @param StoreOptions $opts
  */
 private function setRefs(\stdClass $statement, array $refs, StoreOptions $opts)
 {
     $this->where($opts)->where('statement.id', $statement->id)->update(['refs' => array_map(function ($ref) {
         $statement = Helpers::replaceFullStop(json_decode(json_encode($ref->statement), true));
         $stored = new Carbon($statement['stored']);
         $timestamp = new Carbon($statement['timestamp']);
         $statement['stored'] = new MongoDate($stored->timestamp, $stored->micro);
         $statement['timestamp'] = new MongoDate($timestamp->timestamp, $timestamp->micro);
         return $statement;
     }, $refs)]);
 }