encode() public static method

Returns the JSON representation of a value.
public static encode ( $value, $options ) : string
return string
コード例 #1
0
 public function create()
 {
     $form = new Form();
     $form->addText('workStart', 'Začátek', 3, 5)->setRequired('Vyplňte pole "Začátek prac. doby".')->setDefaultValue($this->defaultItemTime['workStart'])->setHtmlId('workStart')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Začátek prac. doby" lze zadat pouze
                  čas v 24 hodinovém formátu po půlhodinách.', '([01]?[0-9]|2[0-3]):(0|3)0');
     $form->addText('workEnd', 'Konec', 3, 5)->setRequired('Vyplňte pole "Konec prac. doby".')->setDefaultValue($this->defaultItemTime['workEnd'])->setHtmlId('workEnd')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Konec prac. doby" lze zadat pouze
                  čas v 24 hodinovém formátu po půlhodinách.', '([01]?[0-9]|2[0-3]):(0|3)0');
     $form->addText('lunch', 'Oběd', 3, 5)->setRequired('Vyplňte pole "Oběd".')->setDefaultValue($this->defaultItemTime['lunch'])->setHtmlId('lunch')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Oběd" lze zadat pouze
                  čas v ve formátu s čárkou. (např. 1 nebo 1,5)', '^(0|[1-9]|1[0-9]|2[0-3])(,(0|5))?$');
     $form->addText('otherHours', 'Ostatní hod.')->setDefaultValue($this->defaultItemTime['otherHours'])->setHtmlId('otherHours')->setAttribute('class', 'input-time')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Do pole "Ostaní hodiny" lze zadat pouze
                  čas ve formátu s čárkou.(např. 6 nebo 6,5)', '^(0|[1-9]|1[0-9]|2[0-3])(,(0|5))?$');
     $form->addText('locality', 'Místo pracoviště', 28, 40)->setRequired('Vyplňte pole "Místo pracoviště".')->setHtmlId('locality')->getControlPrototype()->class = 'item-text-input';
     $form->addText('description', 'Popis práce', 28, 30)->getControlPrototype()->class = 'item-text-input';
     $form->addText('descOtherHours', 'Komentář k ostat. hod. (např. svátek)', 28, 30)->addConditionOn($form['otherHours'], Form::FILLED)->addCondition(Form::FILLED)->addRule(function ($item, $arg) {
         return \InvoiceTime::processTime($arg) == '00:00:00' ? false : true;
     }, self::OTHER_HOURS_ZERO_TIME_ERROR_MSG, $form['otherHours']);
     $form['descOtherHours']->getControlPrototype()->class = 'item-text-input';
     // time control buttons
     $form->addButton('workStartAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workStart']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 0, 'val' => -30]));
     $form->addButton('workStartSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workStart']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 0, 'val' => 30]));
     $form->addButton('workEndAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workEnd']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 1, 'val' => 30]));
     $form->addButton('workEndSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workEnd']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 1, 'val' => -30]));
     $form->addButton('lunchAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['lunch']->control->attrs['id'], 'slider' => 'slider_lunch', 'val' => -30]));
     $form->addButton('lunchSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['lunch']->control->attrs['id'], 'slider' => 'slider_lunch', 'val' => 30]));
     $form->addButton('otherHoursAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['otherHours']->control->attrs['id'], 'slider' => 'slider_time_other', 'val' => 0]));
     $form->addButton('otherHoursSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['otherHours']->control->attrs['id'], 'slider' => 'slider_time_other', 'val' => 0]));
     $form->addSubmit('save', 'Uložit řádek');
     $form->getElementPrototype()->id = 'update-form';
     return $form;
 }
コード例 #2
0
 public function __construct($domain, $apiKey = NULL, $apiSecret = NULL)
 {
     $this->domain = $domain;
     $this->apiKey = $apiKey;
     $this->apiSecret = $apiSecret;
     $config = ['base_url' => $domain];
     $curl = new Client($config);
     $curl->onBeforeRequest[] = function (Curl\Request $request) {
         $data = $request->getData();
         $timestamp = time();
         $toSign = $data;
         $toSign['timestamp'] = (int) $timestamp;
         $toSign['apiKey'] = $this->apiKey;
         ksort($toSign);
         $json = \Nette\Utils\Json::encode($toSign);
         $signature = base64_encode(hash_hmac('sha512', $json, $this->apiSecret, $raw = TRUE));
         $request->setQuery('apiKey', $this->apiKey);
         $request->setQuery('timestamp', $timestamp);
         $request->setQuery('signature', $signature);
     };
     $curl->onBeforeResponse[] = function ($response) {
         return ResponseParser::parse($response);
     };
     $this->clients = new Clients($curl);
     $this->products = new Products($curl);
     $this->orders = new Orders($curl);
     $this->invoices = new Invoices($curl);
 }
コード例 #3
0
ファイル: Mailchimp.php プロジェクト: jedenweb/mailchimp
 /**
  * @param string $method
  * @param string $endpoint
  * @param array $data
  *
  * @return \Kdyby\Curl\Response|NULL
  */
 private function call($method, $endpoint, $data = [])
 {
     $request = $this->createRequest($endpoint);
     $data = Json::encode($data);
     try {
         if ($method === Request::GET) {
             $response = $request->get($data);
         } else {
             $request->post = $data;
             $request->setMethod($method);
             $response = $request->send();
         }
     } catch (CurlException $e) {
         if ($e instanceof BadStatusException) {
             $response = $e->getResponse();
             if ($response->getCode() !== 404) {
                 Debugger::log($e);
                 return NULL;
             }
         } else {
             throw $e;
         }
     }
     return $response;
 }
コード例 #4
0
ファイル: Json.php プロジェクト: jedenweb/framework
 /**
  * Returns the JSON representation of a value.
  * @param mixed
  * @return string
  */
 public static function encode($value, $pretty = self::FORMAT_COMPACT)
 {
     if ($pretty === self::FORMAT_COMPACT) {
         return Nette\Utils\Json::encode($value);
     }
     return self::prettify(Nette\Utils\Json::encode($value), $value);
 }
コード例 #5
0
ファイル: PswdInput.php プロジェクト: lohini/framework
 /**
  * Generates control's HTML element
  *
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl()->addClass('pswdinput');
     $this->data['fid'] = $this->getForm()->getElementPrototype()->id;
     $control->data('lohini-pswd', \Nette\Utils\Json::encode(array_filter($this->data)));
     return Html::el('span', ['style' => 'position: relative; float: left;'])->add($control);
 }
コード例 #6
0
 /**
  * Funkce pro odeslání JSON odpovědi
  * @param array|object|string $data
  */
 protected function sendJsonResponse($data, $code = IResponse::S200_OK)
 {
     $httpResponse = $this->getHttpResponse();
     $httpResponse->setContentType('application/json', 'UTF-8');
     $httpResponse->setCode($code);
     $this->sendResponse(new TextResponse(is_string($data) ? $data : Json::encode($data)));
 }
コード例 #7
0
ファイル: Request.php プロジェクト: pkristian/flickrlickr
 public function __construct(OAuth\Consumer $consumer, Http\Url $url, $method = self::GET, array $post = [], array $headers = [], OAuth\Token $token = NULL)
 {
     $this->consumer = $consumer;
     $this->token = $token;
     $this->url = $url;
     $this->method = strtoupper($method);
     $this->headers = $headers;
     if (is_array($post) && !empty($post)) {
         $this->post = array_map(function ($value) {
             if ($value instanceof Http\UrlScript) {
                 return (string) $value;
             } elseif ($value instanceof \CURLFile) {
                 return $value;
             }
             return !is_string($value) ? Utils\Json::encode($value) : $value;
         }, $post);
     }
     $parameters = $this->getParameters();
     $defaults = ['oauth_version' => OAuth\DI\OAuthExtension::VERSION, 'oauth_nonce' => $this->generateNonce(), 'oauth_timestamp' => $this->generateTimestamp(), 'oauth_consumer_key' => $this->consumer->getKey()];
     if ($token && $token->getToken()) {
         $defaults['oauth_token'] = $this->token->getToken();
     }
     // Update query parameters
     $this->url->setQuery(array_merge($defaults, $parameters));
 }
コード例 #8
0
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $helperClasses = array('Symfony\\Component\\Console\\Helper\\FormatterHelper', 'Symfony\\Component\\Console\\Helper\\QuestionHelper', 'Kdyby\\Console\\Helpers\\PresenterHelper');
     $helperClasses = array_map(function ($class) {
         return new Nette\DI\Statement($class);
     }, $helperClasses);
     if (class_exists('Symfony\\Component\\Console\\Helper\\ProgressHelper')) {
         $helperClasses[] = new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\ProgressHelper', array(false));
     }
     if (class_exists('Symfony\\Component\\Console\\Helper\\DialogHelper')) {
         $helperClasses[] = new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\DialogHelper', array(false));
     }
     $builder->addDefinition($this->prefix('helperSet'))->setClass('Symfony\\Component\\Console\\Helper\\HelperSet', array($helperClasses))->setInject(FALSE);
     $builder->addDefinition($this->prefix('application'))->setClass('Kdyby\\Console\\Application', array($config['name'], $config['version']))->addSetup('setHelperSet', array($this->prefix('@helperSet')))->addSetup('injectServiceLocator')->setInject(FALSE);
     $builder->addDefinition($this->prefix('dicHelper'))->setClass('Kdyby\\Console\\ContainerHelper')->addTag(self::TAG_HELPER, 'dic');
     if ($config['disabled']) {
         return;
     }
     $builder->addDefinition($this->prefix('router'))->setClass('Kdyby\\Console\\CliRouter')->setAutowired(FALSE)->setInject(FALSE);
     Nette\Utils\Validators::assert($config, 'array');
     foreach ($config['commands'] as $command) {
         $def = $builder->addDefinition($this->prefix('command.' . md5(Nette\Utils\Json::encode($command))));
         list($def->factory) = Nette\DI\Compiler::filterArguments(array(is_string($command) ? new Nette\DI\Statement($command) : $command));
         if (class_exists($def->factory->entity)) {
             $def->class = $def->factory->entity;
         }
         $def->setAutowired(FALSE);
         $def->setInject(FALSE);
         $def->addTag(self::TAG_COMMAND);
     }
 }
コード例 #9
0
ファイル: ConsoleExtension.php プロジェクト: pixuin/console
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     $builder->addDefinition($this->prefix('helperSet'))->setClass('Symfony\\Component\\Console\\Helper\\HelperSet', array(array(new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\DialogHelper'), new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\FormatterHelper'), new Nette\DI\Statement('Symfony\\Component\\Console\\Helper\\ProgressHelper'), new Nette\DI\Statement('Kdyby\\Console\\Helpers\\PresenterHelper'))))->setInject(FALSE);
     $builder->addDefinition($this->prefix('application'))->setClass('Kdyby\\Console\\Application', array($config['name'], $config['version']))->addSetup('setHelperSet', array($this->prefix('@helperSet')))->setInject(FALSE);
     $builder->addDefinition($this->prefix('router'))->setClass('Kdyby\\Console\\CliRouter')->setAutowired(FALSE)->setInject(FALSE);
     $builder->getDefinition('router')->addSetup('Kdyby\\Console\\CliRouter::prependTo($service, ?)', array($this->prefix('@router')));
     $builder->getDefinition('nette.presenterFactory')->addSetup('if (method_exists($service, ?)) { $service->setMapping(array(? => ?)); } ' . 'elseif (property_exists($service, ?)) { $service->mapping[?] = ?; }', array('setMapping', 'Kdyby', 'KdybyModule\\*\\*Presenter', 'mapping', 'Kdyby', 'KdybyModule\\*\\*Presenter'));
     if (!empty($config['url'])) {
         if (!preg_match('~^https?://[^/]+\\.[a-z]+(/.*)?$~', $config['url'])) {
             throw new Nette\Utils\AssertionException("The url '{$config['url']}' is not valid, please use this format: 'http://domain.tld/path'.");
         }
         $builder->getDefinition('nette.httpRequestFactory')->setClass('Kdyby\\Console\\HttpRequestFactory')->addSetup('setFakeRequestUrl', array($config['url']));
     }
     $builder->addDefinition($this->prefix('dicHelper'))->setClass('Kdyby\\Console\\ContainerHelper')->addTag(self::HELPER_TAG, 'dic');
     Nette\Utils\Validators::assert($config, 'array');
     foreach ($config['commands'] as $command) {
         $def = $builder->addDefinition($this->prefix('command.' . md5(Nette\Utils\Json::encode($command))));
         list($def->factory) = Nette\DI\Compiler::filterArguments(array(is_string($command) ? new Nette\DI\Statement($command) : $command));
         if (class_exists($def->factory->entity)) {
             $def->class = $def->factory->entity;
         }
         $def->setAutowired(FALSE);
         $def->setInject(FALSE);
         $def->addTag(self::COMMAND_TAG);
     }
 }
コード例 #10
0
 /**
  * {inheritDoc}
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->getContentType(), 'utf-8');
     $httpResponse->setExpiration(FALSE);
     $httpResponse->setCode($this->code);
     echo Nette\Utils\Json::encode($this->getPayload(), Nette\Utils\Json::PRETTY);
 }
コード例 #11
0
ファイル: Api.php プロジェクト: FreezyBee/MailChimp
 /**
  * @param string $method
  * @param string $endpoint
  * @param array $parameters
  * @return mixed
  * @throws MailChimpException
  */
 public function call($method = 'GET', $endpoint = '', array $parameters = [])
 {
     $uri = $this->config['apiUrl'] . (strlen($endpoint) && $endpoint[0] == '/' ? substr($endpoint, 1) : $endpoint);
     $headers = ['Authorization' => 'apikey ' . $this->config['apiKey']];
     try {
         $body = $parameters ? Json::encode($parameters) : null;
     } catch (JsonException $e) {
         throw new MailChimpException('MailChimp request - invalid json', 667, $e);
     }
     $client = new Client();
     $request = new Request($method, $uri, $headers, $body);
     $resource = new Resource($request);
     try {
         /** @var \GuzzleHttp\Psr7\Response $response */
         $response = $client->send($request);
         $resource->setSuccessResponse($response);
     } catch (GuzzleException $e) {
         $resource->setErrorResponse($e);
     }
     $this->onResponse($resource);
     if ($resource->getException()) {
         throw new MailChimpException('MailChimp response - error', 666, $resource->getException());
     } else {
         return $resource->getResult();
     }
 }
コード例 #12
0
ファイル: JsonMapper.php プロジェクト: lucien144/Restful
 /**
  * Convert array or Traversable input to string output response
  * @param array|\Traversable $data
  * @param bool $prettyPrint
  * @return mixed
  *
  * @throws MappingException
  */
 public function stringify($data, $prettyPrint = TRUE)
 {
     try {
         return Json::encode($data, $prettyPrint && defined('Nette\\Utils\\Json::PRETTY') ? Json::PRETTY : 0);
     } catch (JsonException $e) {
         throw new MappingException('Error in parsing response: ' . $e->getMessage());
     }
 }
コード例 #13
0
ファイル: FlotRenderer.php プロジェクト: librette/flot
 /**
  * @param Flot\Plot $plot
  * @return string
  */
 public function renderJavascript(Flot\Plot $plot)
 {
     $args = array();
     $args[] = Utils\Json::encode('#' . $plot->getName());
     $args[] = Utils\Json::encode($this->exportData($plot));
     $args[] = Utils\Json::encode($this->exportOptions($plot));
     return sprintf(self::PLOT_METHOD, implode(', ', $args));
 }
コード例 #14
0
ファイル: JsonResponse.php プロジェクト: dzibma/rest-api
 /**
  * @param Http\IRequest $request
  * @param Http\IResponse $response
  */
 public function send(Http\IRequest $request, Http\IResponse $response)
 {
     $response->setContentType($this->contentType);
     $response->setCode($this->code ?: Http\IResponse::S200_OK);
     $response->setExpiration($this->expiration);
     $response->setHeader('Pragma', $this->expiration ? 'cache' : 'no-cache');
     echo Json::encode($this->data);
 }
コード例 #15
0
 /**
  * {@inheritDoc}
  */
 public function preSend(RequestInterface $request)
 {
     $content = $request->getContent();
     if (is_array($content) || $content instanceof \JsonSerializable) {
         $request->setContent(Json::encode($content));
         $request->addHeader('Content-Type: application/json');
     }
 }
コード例 #16
0
ファイル: RedisLuaJournal.php プロジェクト: JanPetr/Redis
 private static function flattenDp($array)
 {
     if (isset($array[Cache::TAGS])) {
         $array[Cache::TAGS] = (array) $array[Cache::TAGS];
     }
     $filtered = array_intersect_key($array, array_flip(array(Cache::TAGS, Cache::PRIORITY, Cache::ALL, self::DELETE_ENTRIES)));
     return Nette\Utils\Json::encode($filtered);
 }
コード例 #17
0
 /**
  *
  * @param EmailAddressesEntity $emails
  * @param int $recipientsListId
  */
 public function addRecipientListUnsubscribers(EmailAddressesEntity $emails, $recipientsListId)
 {
     $request = Request::post("{$this->getCompanyId()}/recipients-lists/{$recipientsListId}/unsubscribers");
     $data = $emails->toArray();
     $json = Json::encode($data['emails']);
     $request->setContent($json);
     $this->getConnector()->sendRequest($request);
 }
コード例 #18
0
 /**
  * @param string $body
  * @return string
  */
 public function format($body)
 {
     try {
         return Json::encode(Json::decode($body), Json::PRETTY);
     } catch (JsonException $e) {
         return $body;
     }
 }
コード例 #19
0
 /**
  * @param Screenplay[] $scenarios
  */
 public function publish(array $scenarios)
 {
     $ids = [];
     foreach ($scenarios as $screenplay) {
         $ids[] = $screenplay->getId();
     }
     $this->producer->publish(Json::encode($ids));
 }
コード例 #20
0
 public function render()
 {
     $settings = $this->settings;
     $settings['onSuccess'] = $this->link('this');
     $settings['onUploadStart'] = $this->link('checkDirectory!');
     $this->template->uploadSettings = \Nette\Utils\Json::encode($settings);
     $this->template->setFile(__DIR__ . '/template.latte');
     $this->template->render();
 }
コード例 #21
0
 /**
  * @param string $propertyName
  * @throws InvalidPropertyException
  */
 public function addJsonMapping($propertyName)
 {
     $this->validateProperty($propertyName);
     $this->storageReflection->addMapping($propertyName, $this->storageReflection->convertEntityToStorageKey($propertyName), function ($value) {
         return Json::decode($value, Json::FORCE_ARRAY);
     }, function ($value) {
         return Json::encode($value);
     });
 }
コード例 #22
0
 protected function dataDecodeToType($data, $contentType)
 {
     if ($contentType == self::CONTENT_TYPE_JSON) {
         return \Nette\Utils\Json::encode((object) $data);
     } else {
         if ($contentType == self::CONTENT_TYPE_QUERY) {
             return http_build_query($data, null, "&", PHP_QUERY_RFC3986);
         }
     }
 }
コード例 #23
0
ファイル: JsonpResponse.php プロジェクト: frosty22/ale
 /**
  * @param Nette\Http\IRequest $httpRequest
  * @param Nette\Http\IResponse $httpResponse
  * @throws \Nette\Application\BadRequestException
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setExpiration(FALSE);
     $callback = $httpRequest->getQuery(self::$callbackName);
     if (is_null($callback)) {
         throw new \Nette\Application\BadRequestException("Invalid JSONP request.");
     }
     echo $callback . "(" . Nette\Utils\Json::encode($this->payload) . ")";
 }
コード例 #24
0
 /**
  * @param array|object|string $params
  * @throws JsonException
  */
 public function setParams($params)
 {
     if (is_array($params) || is_object($params)) {
         $this->row->params = Json::encode($params);
     } elseif (is_string($params)) {
         $this->row->params = $params;
     } else {
         $this->row->params = '';
     }
 }
コード例 #25
0
ファイル: Sender.php プロジェクト: ondrs/idefend-api
 /**
  * @param string $url
  * @param string|array $data
  * @return \Kdyby\Curl\Response
  * @throws iDefendCurlException
  */
 public function send($url, $data = '')
 {
     try {
         $request = new Request($this->url . $url);
         $request->setSender($this->curlSender);
         return $request->post(Json::encode($data));
     } catch (CurlException $e) {
         throw new iDefendCurlException($e->getMessage());
     }
 }
コード例 #26
0
 /**
  * @param int $remoteId
  * @param array $rating
  * @throws BadResponseException
  */
 public function rateCourier($remoteId, array $rating)
 {
     $payload = Json::encode($rating);
     $request = $this->requestFactory->createRequest('orders/' . intval($remoteId) . '/courier-rating', $payload)->setMethod(Request::PUT);
     $request->headers['Content-Type'] = self::JSON_CONTENT_TYPE;
     $response = $this->connector->send($request);
     if (($responseCode = $response->getCode()) !== Http\Response::S202_ACCEPTED) {
         $this->unexpectedResponseCode($responseCode);
     }
 }
コード例 #27
0
ファイル: Json.php プロジェクト: appcia/utils
 /**
  * {@inheritdoc}
  */
 public static function encode($data)
 {
     // Cast objects to string whenever it is possible
     array_walk_recursive($data, function (&$value) {
         if (is_object($value) and Val::stringable($value)) {
             $value = (string) $value;
         }
     });
     $json = parent::encode($data);
     return $json;
 }
コード例 #28
0
ファイル: JsonResponse.php プロジェクト: pogodi/OCApi
 /**
  * Sends response to output.
  * @return void
  */
 public function send(IRequest $httpRequest, \Nette\Http\IResponse $httpResponse)
 {
     if ($this->error) {
         $this->payload = ['error' => TRUE, 'message' => $this->errorMessage];
     } else {
         $this->payload['error'] = FALSE;
     }
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setExpiration(FALSE);
     echo Json::encode($this->payload);
 }
コード例 #29
0
 public function dump()
 {
     $allMessages = [];
     $locales = $this->translator->getAvailableLocales();
     foreach ($locales as $locale) {
         $catalogue = $this->translator->getCatalogue($locale);
         $messages = $catalogue->all();
         $shortLocale = $this->getShortLocale($locale);
         $allMessages[$shortLocale] = $messages;
     }
     return Json::encode($allMessages, Json::PRETTY);
 }
コード例 #30
0
 /**
  * Funkce pro nastavení timestampu poslední kontroly přístupu do DB
  * @param string $dbType
  * @param int $timestamp
  */
 public function setLastDbCheck($dbType, $timestamp)
 {
     $data = $this->getLastDbCheck();
     $data[$dbType] = $timestamp;
     try {
         /** @noinspection PhpUndefinedFieldInspection */
         $this->row->last_db_check = Json::encode($data);
     } catch (JsonException $e) {
         /** @noinspection PhpUndefinedFieldInspection */
         $this->row->last_db_check = '';
     }
 }