コード例 #1
0
ファイル: Serializer.php プロジェクト: vicenteguerra/Flashbuy
 public function SerializeClass($ObjectInstance, $ClassName)
 {
     Serializer::$Data .= "<" . $ClassName . ">";
     $Class = new ReflectionClass($ClassName);
     $ClassArray = array($ObjectInstance);
     $Properties = $Class->getProperties();
     $i = 0;
     foreach ($ClassArray as $ClassMember) {
         $prpName = $Properties[$i]->getName();
         Serializer::$Data .= "<" . $prpName . ">";
         $prpType = gettype($ClassMember);
         if ($prpType == 'object') {
             $serializerinstance = new Serializer();
             $serializerinstance->SerializeClass($ClassMember, get_class($ClassMember));
         }
         if ($prpType == 'array') {
             $this->GetaArray($ClassMember);
         } else {
             Serializer::$Data .= $ClassMember;
         }
         Serializer::$Data .= "</" . $prpName . ">";
         $i++;
     }
     Serializer::$Data .= "</" . $ClassName . ">";
     return Serializer::$Data;
 }
コード例 #2
0
ファイル: Loader.php プロジェクト: gravitymedia/commander
 /**
  * Load config.
  *
  * @param string $filename
  *
  * @return Config
  *
  * @throws \InvalidArgumentException
  */
 public function load($filename)
 {
     $data = file_get_contents($filename);
     try {
         $config = $this->serializer->deserialize($data, Config::class, 'json');
     } catch (UnexpectedValueException $exception) {
         throw new \InvalidArgumentException('Invalid configuration file', 0, $exception);
     }
     return $config;
 }
コード例 #3
0
ファイル: rest.php プロジェクト: jawngee/HeavyMetal
 public function after($controller, $metadata, &$data)
 {
     if ($metadata->map && $metadata->item && isset($data[$metadata->item])) {
         switch ($_SERVER['HTTP_ACCEPT']) {
             case 'application/xml':
             case 'text/xml':
                 content_type('application/xml');
                 echo Serializer::SerializeObject($data[$metadata->item], Serializer::FORMAT_XML, null, $metadata->map);
                 die;
                 break;
             case 'application/json':
             case 'text/json':
             case '*/*, application/json':
                 content_type('text/json');
                 $response = Serializer::SerializeObject($data[$metadata->item], Serializer::FORMAT_JSON, null, $metadata->map);
                 header("X-JSON:{$response}");
                 echo $response;
                 die;
                 break;
             case 'text/yaml':
                 content_type('text/yaml');
                 echo Serializer::SerializeObject($data[$metadata->item], Serializer::FORMAT_YAML, null, $metadata->map);
                 die;
                 break;
         }
     }
 }
コード例 #4
0
 static function deSerializeArray($array)
 {
     $newArray = array();
     foreach ($array as $string) {
         array_push($newArray, Serializer::deserialize($string));
     }
     return $newArray;
 }
コード例 #5
0
ファイル: Reviver.php プロジェクト: koolkode/context
 /**
  * Registers the reviver with the serializer.
  * 
  * @throws UnserializationException
  */
 public function __wakeup()
 {
     try {
         Serializer::registerReviver($this);
     } catch (\Exception $e) {
         // Preserving the exception trace by re-throwing or nesting crashes PHP...
         throw new UnserializationException($e->getMessage());
     }
 }
コード例 #6
0
ファイル: XSLTView.class.php プロジェクト: tejdeeps/tejcs.com
 /**
  * Sets common parameters and arguments for all XSLT views and displays this view.
  * @param Request $request Request
  * @param Response $response Response
  */
 public function display(Request $request, Response $response)
 {
     $this->proc->importStyleSheet($this->template);
     if ($this->resource != null) {
         $xml = Serializer::serialize($this->resource);
         $this->doc->loadXML($xml);
     }
     $xml = $this->proc->transformToXML($this->doc);
     $response->write($xml);
 }
コード例 #7
0
 private function makeVideo(VideoServiceDetector $detector)
 {
     $user = Session::get('user');
     $video = new Video();
     $video->setSourceId($detector->getId());
     $video->setUserid($user->getId());
     $video->setAdded(null);
     $video->setType($detector->getType()->getId());
     $video->setFeed(Serializer::serialize($detector->getFeed()));
     return $video;
 }
コード例 #8
0
 public function testUnserializeString()
 {
     //Valid string
     $result = Serializer::unserializeString('O:1:"a":1:{s:5:"value";s:3:"100";}');
     $this->assertNotNull($result);
     $this->assertIsA($result, "Object");
     //Invalid string
     $this->expectException("SerializerException");
     $result = Serializer::unserializeString("{'Organization': 'ThinkUp Documentation Team'}");
     $this->assertNull($result);
 }
コード例 #9
0
ファイル: Filesystem.php プロジェクト: fwk/cache
 /**
  *
  * @param string $fileName
  * 
  * @return CacheEntry 
  */
 public function readEntry($key)
 {
     if (!$this->exists($key)) {
         return false;
     }
     $fileInfos = implode(DIRECTORY_SEPARATOR, array($this->cacheDirectory, md5('cacheKey:' . $key) . '.cache'));
     $contents = file_get_contents($fileInfos);
     $entry = $this->serializer->unserialize($contents);
     if (!$entry instanceof \Fwk\Cache\CacheEntry) {
         throw new \Fwk\Cache\Exceptions\ReadError("contents is not a valid CacheEntry");
     }
     $entry->setSerializer($this->serializer);
     return $entry;
 }
コード例 #10
0
 public function __construct()
 {
     header('access-control-allow-origin: *');
     if ($this->checkMethod($_SERVER['REQUEST_METHOD']) && ($file = $this->getInputFile())) {
         $parser = new Parser($this->getPostValue('from'), $_FILES['input']['name'], $this->getPostValue('title'));
         $this->logs = [];
         $parser->setLogger($this);
         try {
             $dictionary = $parser->parse($file);
             $parserLogs = $this->logs;
             $serializer = new Serializer($this->getPostValue('to') ?? '汎用辞書');
             $this->logs = [];
             $serializer->setLogger($this);
             $outputFile = $serializer->serialize($dictionary);
             $serializerLogs = $this->logs;
             $formData = new xmlhttprequest\FormData();
             $formData->append('output', $outputFile['bytes'], $outputFile['name'], $outputFile['type']);
             if ($parserLogs) {
                 $parserLogsFile = $this->convertLogsToFile($parserLogs, _('構文解析時に1つ以上のロギングが発生しました。'));
                 $formData->append('parser-logs', $parserLogsFile['bytes'], null, $parserLogsFile['type']);
             }
             if ($serializerLogs) {
                 $serializerLogsFile = $this->convertLogsToFile($serializerLogs, _('直列化時に1つ以上のロギングが発生しました。'));
                 $formData->append('serializer-logs', $serializerLogsFile['bytes'], null, $serializerLogsFile['type']);
             }
             header($formData->getContentType());
             echo $formData->encode();
         } catch (SyntaxException $e) {
             $this->responseError(['type' => 'https://github.com/esperecyan/dictionary-api/blob/master/malformed-syntax.md', 'title' => 'Malformed Syntax', 'status' => 400, 'detail' => $e->getMessage()]);
         } catch (SerializeExceptionInterface $e) {
             $this->responseError(['type' => 'https://github.com/esperecyan/dictionary-api/blob/master/serialize-error.md', 'title' => 'Serialize Error', 'status' => 400, 'detail' => $e->getMessage()]);
         } catch (\Throwable $e) {
             $this->responseError(['title' => 'Internal Server Error', 'status' => 500, 'detail' => _('ファイルの変換に失敗しました。')]);
             throw $e;
         }
     }
 }
コード例 #11
0
ファイル: Client.php プロジェクト: spinx/sidekiq-job-php
 /**
  * Push job to redis
  *
  * @param string     $jobId
  * @param string     $class
  * @param array      $args
  * @param string     $queue
  * @param bool       $retry
  * @param float|null $doAt
  * @throws exception Exception
  */
 private function atomicPush($jobId, $class, $args = [], $queue = self::QUEUE, $retry = true, $doAt = null)
 {
     if (array_values($args) !== $args) {
         throw new Exception('Associative arrays in job args are not allowed');
     }
     if (!is_null($doAt) && !is_float($doAt) && is_string($doAt)) {
         throw new Exception('at argument needs to be in a unix epoch format. Use microtime(true).');
     }
     $job = $this->serializer->serialize($jobId, $class, $args, $retry);
     if ($doAt === null) {
         $this->redis->sadd($this->name('queues'), $queue);
         $this->redis->lpush($this->name('queue', $queue), $job);
     } else {
         $this->redis->zadd($this->name('schedule'), [$job => $doAt]);
     }
 }
コード例 #12
0
 /**
  * Get fully-rendered HTML markup for this insight.
  * @param  Insight $insight Test insight to render in HTML.
  * @return str Insight HTML with this insight
  */
 protected function getRenderedInsightInHTML(Insight $insight)
 {
     if ($insight->related_data !== null && is_string($insight->related_data)) {
         $insight->related_data = Serializer::unserializeString($insight->related_data);
     }
     $view = new ViewManager();
     $view->caching = false;
     $view->assign('insights', array($insight));
     $view->assign('expand', true);
     $view->assign('tpl_path', THINKUP_WEBAPP_PATH . 'plugins/insightsgenerator/view/');
     $view->assign('enable_bootstrap', true);
     $view->assign('thinkup_application_url', Utils::getApplicationURL());
     $view->assign('site_root_path', 'https://thinkup.thinkup.com/');
     $html_insight = $view->fetch(THINKUP_WEBAPP_PATH . '_lib/view/insights.tpl');
     return $html_insight;
 }
コード例 #13
0
ファイル: Database.php プロジェクト: fwk/cache
 /**
  *
  * @param string $fileName
  * 
  * @return CacheEntry 
  */
 public function readEntry($key)
 {
     $query = "SELECT * FROM %s WHERE `key` = ? LIMIT 1";
     $stmt = $this->pdo->prepare(sprintf($query, $this->options['table.infos']));
     $stmt->execute(array($key));
     $res = $stmt->fetch();
     if (!$res) {
         throw new \Fwk\Cache\Exceptions\ReadError("invalid CacheEntry key: {$key}");
     }
     $entry = new \Fwk\Cache\CacheEntry(null, $key);
     $entry->setCreatedOn($res['created_on']);
     $entry->setKey($res['key']);
     if (strlen($res['max_age']) > 50) {
         $maxAge = $this->serializer->unserialize($res['max_age']);
     } else {
         $maxAge = $res['max_age'];
     }
     $entry->setMaxAge($maxAge);
     $entry->setSerializer($this->serializer);
     return $entry;
 }
コード例 #14
0
ファイル: Serializable.php プロジェクト: kernelstudio/config
 /**
  * {@inheritdoc}
  */
 public function unserializeable($data)
 {
     return Serializer::unserializeable($data);
 }
コード例 #15
0
ファイル: SerializerTest.php プロジェクト: link0/profiler
 /**
  * @expectedException \Link0\Profiler\SerializerException
  * @expectedExceptionMessage Unable to unserialize data: FDSAfoobar
  */
 public function testUnexpectedDataToThrowException()
 {
     $this->serializer->unserialize('FDSAfoobar');
 }
コード例 #16
0
ファイル: ArrayConverter.php プロジェクト: martyn82/apha
 /**
  * @param array $data
  * @param string $type
  * @return object
  */
 private function reconstructType(array $data, string $type)
 {
     return $this->serializer->deserialize($this->serializer->serialize($data), $type);
 }
コード例 #17
0
ファイル: ArraySerializable.php プロジェクト: cawaphp/cawa
 /**
  * @param array $serialized
  */
 public function arrayUnserialize(array $serialized)
 {
     Serializer::unserialize($this, $serialized);
 }
コード例 #18
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'Serializer.php';
//borramos todas las estrellas guardadas
$arrId = Serializer::showIds();
$arrId = array_filter($arrId);
asort($arrId);
$respon = array();
foreach ($arrId as $arr) {
    echo unlink("./database/{$arr}");
}
コード例 #19
0
ファイル: JsonSerializable.php プロジェクト: cawaphp/cawa
 /**
  * @param string $serialized
  */
 public function jsonUnserialize(string $serialized)
 {
     Serializer::unserialize($this, json_decode($serialized, true));
 }
コード例 #20
0
 /**
  * Get serializer with default visitors
  * @return Serializer
  */
 public static function getSerializer()
 {
     $serializer = new Serializer();
     $serializer->setVisitor(new Visitors\Json())->setVisitor(new Visitors\UrlEncode())->setVisitor(new Visitors\MultipartFormData());
     return $serializer;
 }
コード例 #21
0
ファイル: class.paginat.php プロジェクト: prabhatse/olx_hack
 public function getMostRecentInsight($slug, $instance_id)
 {
     $q = "SELECT * FROM #prefix#insights WHERE instance_id=:instance_id ";
     $q .= " AND slug=:slug ";
     $q .= "ORDER BY time_updated DESC LIMIT 1";
     $vars = array(':instance_id' => $instance_id, ":slug" => $slug);
     if ($this->profiler_enabled) {
         Profiler::setDAOMethod(__METHOD__);
     }
     $ps = $this->execute($q, $vars);
     $insight = $this->getDataRowAsObject($ps, "Insight");
     if ($insight->related_data !== null) {
         try {
             $insight->related_data = Serializer::unserializeString($insight->related_data);
         } catch (SerializerException $e) {
             $insight->related_data = null;
         }
     }
     return $insight;
 }
コード例 #22
0
ファイル: Save.php プロジェクト: salvarubiomartinez/stars
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'Serializer.php';
require_once 'Star.php';
//Actualizamos al estrella recibida
$starString = $_REQUEST['star'];
$obj = json_decode($starString);
$star = new Star($obj->id, $obj->posX, $obj->posY, $obj->size, $obj->type, $obj->playerName);
Serializer::save($star, $star->id);
//devolvemos un array con todas las estrellas
$arrId = Serializer::showIds();
$arrId = array_filter($arrId);
asort($arrId);
$respon = array();
foreach ($arrId as $arr) {
    $obj = Serializer::restore($arr);
    array_push($respon, $obj);
}
$json = json_encode($respon);
echo $json;
コード例 #23
0
ファイル: Error.php プロジェクト: xud/jimber-php-framework
 public function serialize()
 {
     return Serializer::serialize($this);
 }
コード例 #24
0
ファイル: Primate.php プロジェクト: linkorb/primate
 public function getDataByPath($path, $expands)
 {
     $part = explode('/', $path);
     if ($part[0] != '') {
         throw new InvalidArgument("URI should start with a slash: " . $path);
     }
     $serializer = new Serializer($this);
     $typeName = $part[1];
     $type = $this->getType($typeName);
     if (isset($part[2])) {
         $resourceId = $part[2];
         $resource = new Resource($type, $resourceId);
         $resource = $this->loadResource($resource, $expands);
         $data = $serializer->serializeResource($resource);
         return $data;
     } else {
         $collection = $this->getResourceCollection($typeName);
         $data = $serializer->serializeCollection($collection);
         return $data;
     }
 }
コード例 #25
0
 public function toJSON()
 {
     $serializer = new Serializer();
     return $serializer->serialize($this);
 }
コード例 #26
0
 protected function getVideoDetails()
 {
     $unserialized = Serializer::unserialize($this->video->getFeed());
     return XMLLoader::loadString($unserialized);
 }
コード例 #27
0
 /**
  * @param  resource|string $stream
  * @param  mixed           $object
  * @param  string          $format
  * @return mixed
  */
 public function unserialize($stream, &$object = null, $format = null)
 {
     return $this->serializer->unserialize($stream, $format ?: $this->format, $this->type, $this->options, $object);
 }
コード例 #28
0
ファイル: Fetcher.php プロジェクト: moneyphp/iso-currencies
 /**
  * @param $fileName
  * @param Serializer $serializer
  */
 public function saveTo($fileName, Serializer $serializer)
 {
     $this->fetch();
     file_put_contents($fileName, $serializer->serialize($this->countries));
 }
コード例 #29
0
ファイル: Serializable.php プロジェクト: cawaphp/cawa
 /**
  * @param string $serialized
  */
 public function unserialize($serialized)
 {
     Serializer::unserialize($this, unserialize($serialized));
 }
コード例 #30
0
 /**
  * @param int    $maxDepth
  * @param string $configurationPath
  */
 public function __construct($maxDepth = self::MAX_DEPTH_NOT_SET, $configurationPath = '')
 {
     parent::__construct(self::FORMAT_JSON, $maxDepth, $configurationPath);
 }