public function getJson($type = '')
 {
     $json = new JsonObject();
     $json->withValue('name', $this->getName());
     $json->withValue('label', $this->getLabel());
     return $json;
 }
 public static function fromPhpType($phpValue)
 {
     if (is_numeric($phpValue)) {
         return new JsonNumber($phpValue);
     }
     if (is_string($phpValue)) {
         return new JsonString($phpValue);
     }
     if (is_array($phpValue)) {
         if (0 !== key($phpValue)) {
             $type = new JsonObject();
             foreach ($phpValue as $key => $value) {
                 $type->add($key, self::fromPhpType($value));
             }
         } else {
             $type = new JsonArray();
             foreach ($phpValue as $key => $value) {
                 $type->add(self::fromPhpType($value));
             }
         }
         return $type;
     }
     if (is_null($phpValue)) {
         return new JsonNull();
     }
     if (is_bool($phpValue)) {
         return new JsonBoolean($phpValue);
     }
     throw new \InvalidArgumentException('Unknown value type');
 }
 /**
  * Genera el json con los registros que vienen de la coleccion 
  *
  */
 public function generateJson($record)
 {
     $json = new JsonObject();
     $json->addValue('id', $record->getId());
     $previous = array();
     foreach ($this->fields as $field) {
         if (!in_array($field->completeName(), $previous)) {
             $json->addValue($field->completeName(), $field->getValue($record));
         }
         $previous[count($previous)] = $field->getName();
     }
     return $json;
 }
 public function getJson($type = '')
 {
     $json = new JsonObject();
     $json->withValue('id', $this->getId())->withValue('numero', $this->getNumero())->withValue('fechaAbierta', $this->getFechaAbierta())->withValue('mozo', $this->getMozo()->getNombreCompleto())->withValue('estado', $this->getEstado()->getNombre())->withObject('pedido', $this->getPedido());
     return $json;
 }
示例#5
0
 public static function fromArray(RootPackage $root, array $packageConfig) : self
 {
     return self::create($root, JsonObject::fromArray($packageConfig));
 }
 public function getJson($type = '')
 {
     $json = new JsonObject();
     $json->withValue('id', $this->getId())->withValue('codigo', $this->getCodigo())->withValue('nombre', $this->getNombre())->withValue('descripcion', $this->getDescripcion())->withValue('precio', $this->getPrecio());
     return $json;
 }
 public function generateJsonConfiguration($records)
 {
     //$this->setDoc($doc = new DOMDocument());
     $json = new JsonObject();
     $json->withValue('record_finder', 'record_finder');
     $json->withValue('title', $this->getTitle());
     $collectionSearchFields = new SearchableReadonlyCollection();
     $collectionSearchFields->addAll($this->searchFields);
     $json->withObject('search_fields', $this->searchFields());
     $collectionTitles = new SearchableReadonlyCollection();
     $collectionTitles->addAll($this->titleFields);
     $json->withObject('record_title', $collectionTitles);
     $collectionDescriptions = new SearchableReadonlyCollection();
     $collectionDescriptions->addAll($this->descriptionFields);
     $json->withObject('record_description', $collectionDescriptions);
     $mapper = new AsyncSearchRecordMapper();
     foreach ($this->searchFields as $searchField) {
         $mapper->addField($searchField);
     }
     foreach ($this->titleFields as $titleField) {
         $mapper->addField($titleField);
     }
     foreach ($this->descriptionFields as $descriptionField) {
         $mapper->addField($descriptionField);
     }
     $jsonArray = new JsonArray();
     if ($records != null) {
         foreach ($records as $record) {
             $jsonObject = $mapper->generateJson($record);
             $jsonArray->addObject($jsonObject);
         }
     }
     $json->addArray('records', $jsonArray);
     return $json;
 }
 public function getJson($type = '')
 {
     $json = new JsonObject();
     $json->withValue('id', $this->getId())->withValue('cantidad', $this->getCantidad())->withObject('producto', $this->getProducto());
     return $json;
 }
 public static function fromFilePath(RootPackage $root, string $filePath) : self
 {
     return new self($root, JsonObject::fromFilePath($filePath));
 }
 public function getJson($type = '')
 {
     $json = new JsonObject();
     $json->withValue('id', $this->getId())->withValue('numero', $this->getNumero())->withValue('fecha', $this->getFecha())->withObject('estado', $this->getEstado())->withObject('detalle', $this->detalle())->withValue('total', $this->calcularTotal());
     return $json;
 }
示例#11
0
 public static function createFromPath(string $dirPath) : self
 {
     return new static($dirPath, JsonObject::fromFilePath($dirPath . DIRECTORY_SEPARATOR . 'composer.json'));
 }
 public function getJson($type = '')
 {
     $json = new JsonObject();
     $json->withValue('id', $this->getId())->withValue('nombre', $this->getNombre())->withValue('apellido', $this->getApellido());
     return $json;
 }
 /**
  * Get the unencoded value of the writer
  *
  * @return mixed
  */
 public function getUnencoded()
 {
     return $this->json->getData();
 }