当前位置: 首页>>代码示例>>PHP>>正文


PHP Serializer::deserialize方法代码示例

本文整理汇总了PHP中Symfony\Component\Serializer\Serializer::deserialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Serializer::deserialize方法的具体用法?PHP Serializer::deserialize怎么用?PHP Serializer::deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Serializer\Serializer的用法示例。


在下文中一共展示了Serializer::deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deserialize

 public function deserialize($data, $type, $format, array $context = array())
 {
     if (!$type) {
         $temp = $this->serializer->decode($data, $format, $context);
         $type = isset($this->map[$temp['type']]) ? $this->map[$temp['type']] : 'Bangpound\\oEmbed\\Response\\Response';
     }
     return $this->serializer->deserialize($data, $type, $format, $context);
 }
开发者ID:bangpound,项目名称:oembed,代码行数:8,代码来源:Serializer.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("CONECTANDO A WEBSERVICE VIA SOAP");
     try {
         $normalizer = new GetSetMethodNormalizer();
         $encoder = new JsonEncoder();
         $serializer = new Serializer(array($normalizer), array($encoder));
         //retrieve WSDL
         $this->client = new \nusoap_client("http://crm.cam-la.com/service/v4/soap.php?wsdl", 'true');
         $this->executeLogin($input, $output);
         //Obtengo todos los archivos que hay en la carpeta:
         $path = $this->getApplication()->getKernel()->getContainer()->get('kernel')->getRootDir() . '/Resources/data/';
         $files = scandir($path);
         foreach ($files as $file) {
             if (is_readable($path . $file) == false) {
                 continue;
             }
             if (is_file($path . $file) == false) {
                 continue;
             }
             $output->writeln("EJECUTANDO DATA " . $file);
             $content = file_get_contents($path . $file);
             $data = json_decode(json_encode($content), true);
             $obj = $serializer->deserialize($data, 'BcTic\\Bundle\\AtencionCrmCamBundle\\Entity\\CustomerCase', 'json');
             $this->uploadToDataBase($obj, $input, $output);
             //Ahora debo eliminar el archivo, pues con otro comando los obtengo y los voy actualizando para consulta cada 5 minutos.
             unlink($path . $file);
         }
     } catch (Exception $e) {
         $output->writeln("ERROR: " . $e->getMessage());
     }
     $output->writeln("EJECUCION FINALIZADA. Good Bye!");
 }
开发者ID:ramiroavila,项目名称:SugarCRM-CAM-CHILE,代码行数:33,代码来源:AtencionClientesCrmCommand.php

示例3: mapJsonToConnection

 /**
  * @param $json
  * @return Connection
  */
 private function mapJsonToConnection($json)
 {
     /* @var ConnectionDto $dto */
     $dto = $this->serializer->deserialize($json, ConnectionDto::CLASS_NAME, 'json');
     $connection = $this->assembler->assemble($dto);
     return $connection;
 }
开发者ID:janus-ssp,项目名称:client,代码行数:11,代码来源:ConnectionRepository.php

示例4: deserialize

 /**
  * Deserializes a Json into readable datas
  * @param string $string
  *
  * @return RZ\Roadiz\Core\Entities\Group
  */
 public function deserialize($string)
 {
     if ($string == "") {
         throw new \Exception('File is empty.');
     }
     $encoder = new JsonEncoder();
     $nameConverter = new CamelCaseToSnakeCaseNameConverter(['name']);
     $normalizer = new GetSetMethodNormalizer(null, $nameConverter);
     $serializer = new Serializer([$normalizer], [$encoder]);
     $group = $serializer->deserialize($string, 'RZ\\Roadiz\\Core\\Entities\\Group', 'json');
     /*
      * Importing Roles.
      *
      * We need to extract roles from group and to re-encode them
      * to pass to RoleJsonSerializer.
      */
     $tempArray = json_decode($string, true);
     $data = [];
     if (!empty($tempArray['roles'])) {
         foreach ($tempArray['roles'] as $roleAssoc) {
             $role = $this->roleSerializer->deserialize(json_encode($roleAssoc));
             $role = $this->em->getRepository('RZ\\Roadiz\\Core\\Entities\\Role')->findOneByName($role->getName());
             $group->addRole($role);
         }
         $data[] = $group;
     }
     return $data;
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:34,代码来源:GroupJsonSerializer.php

示例5: deserialize

 /**
  * Deserializes a json file into a readable array of datas.
  *
  * @param string $jsonString
  *
  * @return RZ\Roadiz\Core\Entities\NodeTypeField
  */
 public static function deserialize($jsonString)
 {
     $encoder = new JsonEncoder();
     $nameConverter = new CamelCaseToSnakeCaseNameConverter(['name', 'label', 'description', 'visible', 'type', 'indexed', 'virtual', 'default_values']);
     $normalizer = new GetSetMethodNormalizer(null, $nameConverter);
     $serializer = new Serializer([$normalizer], [$encoder]);
     return $serializer->deserialize($jsonString, 'RZ\\Roadiz\\Core\\Entities\\NodeTypeField', 'json');
 }
开发者ID:bryanbanda,项目名称:roadiz,代码行数:15,代码来源:NodeTypeFieldJsonSerializer.php

示例6: deserialize

 private function deserialize($json, $entityName)
 {
     $encoders = array(new XmlEncoder(), new JsonEncoder());
     $normalizers = array(new ObjectNormalizer());
     $serializer = new Serializer($normalizers, $encoders);
     $object = $serializer->deserialize($json, $entityName, 'json');
     return $object;
 }
开发者ID:RAFnut,项目名称:Competition-REFU.G,代码行数:8,代码来源:ApiController.php

示例7: send

 /**
  * Sends the passed Request and returns the response or a hydrated object.
  *
  * @param RequestInterface $request The Request to send.
  * @param string $entityClass Optional entity class to hydrate.
  * @return mixed The response or a hydrated object.
  */
 protected function send(RequestInterface $request, $entityClass = null)
 {
     $response = $this->client->send($request);
     $retVal = $response->getBody();
     if ($entityClass !== null) {
         $retVal = $this->serializer->deserialize($retVal, $entityClass, 'json');
     }
     return $retVal;
 }
开发者ID:pradodigital,项目名称:php-rackspace-apps-bindings,代码行数:16,代码来源:GuzzleClientAdapter.php

示例8: getAction

 public function getAction()
 {
     $normalizer = new ObjectNormalizer(new ClassMetadataFactory(new YamlFileLoader(CONFIG_PATH . 'test_entity.yml')), new CamelCaseToSnakeCaseNameConverter());
     $serializer = new Serializer([$normalizer], [new JsonEncoder(), new XmlEncoder()]);
     $test = new TestEntity();
     $test->setMessage('Test');
     $test = $serializer->deserialize('<test><id>1</id></test>', 'DG\\SymfonyCert\\Entity\\TestEntity', 'xml', ['object_to_populate' => $test]);
     return new Response($serializer->serialize($test, 'xml', ['groups' => ['group2']]), 200, ['Content-Type' => 'text/xml']);
 }
开发者ID:GrizliK1988,项目名称:symfony-certification-prepare-project,代码行数:9,代码来源:ApiTestController.php

示例9: synchronise

 /**
  * @override \ComponentRegistry\PackageRepository\PackageRepository
  */
 public function synchronise($task)
 {
     $client = new Client();
     // TODO: this is really shit
     $data = $client->get(static::PLUGIN_LIST_URL)->getBody()->getContents();
     // TODO: this is even shitter
     $data = preg_replace(['/^{"timestamp":[0-9]+,"plugins":/', '/}$/'], '', $data);
     $serialiser = new Serializer([new ArrayDenormalizer(), new GetSetMethodNormalizer(), new ObjectNormalizer()], [new JsonEncoder()]);
     $components = $serialiser->deserialize($data, 'ComponentRegistry\\Entity\\Component[]', 'json');
 }
开发者ID:LukeCarrier,项目名称:moodle-componentregistry,代码行数:13,代码来源:BitbucketPackageRepository.php

示例10: deserialize

 /**
  * Deserializes a json file into a readable array of datas.
  *
  * @param string $jsonString
  *
  * @return RZ\Roadiz\Core\Entities\Role
  */
 public function deserialize($jsonString)
 {
     if ($jsonString == "") {
         throw new \Exception('File is empty.');
     }
     $encoder = new JsonEncoder();
     $nameConverter = new CamelCaseToSnakeCaseNameConverter(['name']);
     $normalizer = new GetSetMethodNormalizer(null, $nameConverter);
     $serializer = new Serializer([$normalizer], [$encoder]);
     return $serializer->deserialize($jsonString, 'RZ\\Roadiz\\Core\\Entities\\Role', 'json');
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:18,代码来源:RoleJsonSerializer.php

示例11: factory

 /**
  * @param HttpRequest $httpRequest
  * @param Serializer  $serializer
  * @param array       $context
  *
  * @return Request
  */
 public static function factory(HttpRequest $httpRequest, Serializer $serializer, array $context = [])
 {
     $attributes = $httpRequest->attributes;
     $content = $httpRequest->getContent();
     $method = $attributes->get('method');
     $params = $serializer->deserialize($content, ParamsDenormalizer::TYPE, 'rest', $context);
     $id = $attributes->get('id');
     $request = new static();
     $request->setMethod($method);
     $request->setParams($params);
     $request->setId($id);
 }
开发者ID:mihai-stancu,项目名称:rpc-bundle,代码行数:19,代码来源:Request.php

示例12: mapJsonToHost

 /**
  * @param $response
  * @return Host
  */
 private function mapJsonToHost($json)
 {
     /** @var Host $host */
     $host = $this->serializer->deserialize($json, Host::CLASS_NAME, 'json');
     if (empty($host->endpoints)) {
         $host->endpoints = array();
         return $host;
     }
     $endpointDtos = array();
     foreach ($host->endpoints as $endpoint) {
         $endpointDto = new Endpoint();
         foreach ($endpoint as $key => $value) {
             $endpointDto->{$key} = $value;
         }
         $endpointDtos[] = $endpointDto;
     }
     $host->endpoints = $endpointDtos;
     return $host;
 }
开发者ID:mabrahamde,项目名称:ssllabs-client,代码行数:23,代码来源:Client.php

示例13: mapJsonToConnectionDescriptors

 /**
  * @param $json
  * @return array
  */
 private function mapJsonToConnectionDescriptors($json)
 {
     $decoded_connections = json_decode($json, true);
     if (!$decoded_connections) {
         $this->logger->error('Mapping received invalid JSON', array('json' => $json));
         throw new \RuntimeException('Mapping received invalid JSON');
     }
     if (!is_array($decoded_connections['connections'])) {
         $this->logger->error('JSON does not contain connection', array('json' => $json));
         throw new RuntimeException('Connections is not an array!');
     }
     $connections = array();
     foreach ($decoded_connections['connections'] as $decoded_connection) {
         /* @var ConnectionDto $dto */
         $dto = $this->serializer->deserialize(json_encode($decoded_connection), ConnectionDescriptorDto::CLASS_NAME, 'json');
         $connections[] = $this->assembler->assemble($dto);
     }
     return $connections;
 }
开发者ID:janus-ssp,项目名称:client,代码行数:23,代码来源:ConnectionDescriptorRepository.php

示例14: deserialize

 /**
  * Deserializes a Json into readable datas.
  *
  * @param string $string
  *
  * @return RZ\Roadiz\Core\Entities\NodeType
  */
 public static function deserialize($string)
 {
     $encoder = new JsonEncoder();
     $nameConverter = new CamelCaseToSnakeCaseNameConverter(['name', 'displayName', 'display_name', 'description', 'visible', 'newsletterType', 'hidingNodes']);
     $normalizer = new GetSetMethodNormalizer(null, $nameConverter);
     $serializer = new Serializer([$normalizer], [$encoder]);
     $nodeType = $serializer->deserialize($string, 'RZ\\Roadiz\\Core\\Entities\\NodeType', 'json');
     /*
      * Importing Fields.
      *
      * We need to extract fields from node-type and to re-encode them
      * to pass to NodeTypeFieldJsonSerializer.
      */
     $tempArray = json_decode($string, true);
     foreach ($tempArray['fields'] as $fieldAssoc) {
         $ntField = NodeTypeFieldJsonSerializer::deserialize(json_encode($fieldAssoc));
         $nodeType->addField($ntField);
     }
     return $nodeType;
 }
开发者ID:bryanbanda,项目名称:roadiz,代码行数:27,代码来源:NodeTypeJsonSerializer.php

示例15: __construct

 public function __construct($ezpage, $container, $blockMapper)
 {
     $this->xml = $ezpage['data_text'];
     $this->blockMapper = $blockMapper;
     $this->container = $container;
     $serializer = new Serializer([new ObjectNormalizer()], [new XmlEncoder()]);
     try {
         $page = new PageValue();
         if ($this->xml) {
             $page = $serializer->deserialize($this->xml, 'EzSystems\\EzFlowMigrationToolkit\\HelperObject\\PageValue', 'xml');
         }
     } catch (InvalidArgumentException $e) {
         // Not valid or empty page
         $page = new PageValue();
     }
     $this->layout = $page->zone_layout;
     if (is_array($page->zone)) {
         foreach ($page->zone as $legacyZone) {
             $zone = new Zone($legacyZone, $blockMapper);
             $this->zones[] = $zone;
         }
     }
 }
开发者ID:ezsystems,项目名称:ezflow-migration-toolkit,代码行数:23,代码来源:Page.php


注:本文中的Symfony\Component\Serializer\Serializer::deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。