Example #1
0
 /**
  * {@inheritdoc}
  */
 public function setValue($data)
 {
     if (is_string($data)) {
         $data = json_decode($data);
     }
     return parent::setValue($data);
 }
Example #2
0
 /**
  * Push new document to end of set. Set second argument to false to keep Compositor in solid
  * state and save it as one big array of data.
  *
  * @param DocumentEntity $document
  * @param bool           $resetState Set to true to reset compositor solid state.
  * @return $this|DocumentEntity[]
  * @throws CompositorException
  */
 public function push(DocumentEntity $document, $resetState = true)
 {
     if ($resetState) {
         $this->solidState = false;
     }
     $this->documents[] = $document->embed($this);
     if ($this->solidState) {
         $this->changedDirectly = true;
         return $this;
     }
     if (!empty($this->atomics) && !isset($this->atomics['$push'])) {
         throw new CompositorException("Unable to apply multiple atomic operation to one Compositor.");
     }
     $this->atomics['$push'][] = $document;
     return $this;
 }
Example #3
0
 /**
  * {@inheritdoc}
  *
  * Accessor options include field type resolved by DocumentSchema.
  *
  * @throws ODMException
  * @throws DefinitionException
  */
 protected function createAccessor($accessor, $value)
 {
     $accessor = parent::createAccessor($accessor, $value);
     if ($accessor instanceof CompositableInterface && !$this->isLoaded() && !$this->isEmbedded()) {
         //Newly created object
         $accessor->invalidate();
     }
     return $accessor;
 }