當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ModelInterface::serialize方法代碼示例

本文整理匯總了PHP中Zend\View\Model\ModelInterface::serialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP ModelInterface::serialize方法的具體用法?PHP ModelInterface::serialize怎麽用?PHP ModelInterface::serialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\View\Model\ModelInterface的用法示例。


在下文中一共展示了ModelInterface::serialize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: render

 /**
  * Render values as XML
  *
  * @param  string|ModelInterface $nameOrModel The script/resource process, or a view model
  * @param  null|array|\ArrayAccess $values Values to use during rendering
  * @return string The script output.
  */
 public function render($nameOrModel, $values = null)
 {
     if ($nameOrModel instanceof XmlModel) {
         return $nameOrModel->serialize();
     }
     // use case 3: Both $nameOrModel and $values are populated
     throw new Exception\DomainException(sprintf('%s: Do not know how to handle operation when both $nameOrModel and $values are populated', __METHOD__));
 }
開發者ID:zpetr,項目名稱:ApigilityXml,代碼行數:15,代碼來源:XmlRenderer.php

示例2: render

 /**
  * Renders values as Icalendar
  *
  * @param string|\Zend\View\Model\ModelInterface $oNameOrModel : the script/resource process, or a view model
  * @param null|array|\ArrayAccess $aValues : values to use during rendering
  *
  * @throws \DomainException
  * @return string The script output.
  */
 public function render($oNameOrModel, $aValues = null)
 {
     // Use case 1: View Models
     // Serialize variables in view model
     if (!$oNameOrModel instanceof IcalendarModel) {
         throw new \DomainException(__METHOD__ . ': Do not know how to handle operation when both $oNameOrModel and $aValues are populated');
     }
     return $oNameOrModel->serialize();
 }
開發者ID:krsreenatha,項目名稱:php.ug,代碼行數:18,代碼來源:IcalendarRenderer.php

示例3: render

 /**
  * Renders values as JSON
  *
  * @todo   Determine what use case exists for accepting both $nameOrModel and $values
  * @param  string|Model $nameOrModel The script/resource process, or a view model
  * @param  null|array|\ArrayAccess $values Values to use during rendering
  * @throws Exception\DomainException
  * @return string The script output.
  */
 public function render($nameOrModel, $values = null)
 {
     // use case 1: View Models
     // Serialize variables in view model
     if ($nameOrModel instanceof Model) {
         if ($nameOrModel instanceof JsonModel) {
             $values = $nameOrModel->serialize();
         } else {
             $values = $this->recurseModel($nameOrModel);
             $values = Json::encode($values);
         }
         if ($this->hasJsonpCallback()) {
             $values = $this->jsonpCallback . '(' . $values . ');';
         }
         return $values;
     }
     // use case 2: $nameOrModel is populated, $values is not
     // Serialize $nameOrModel
     if (null === $values) {
         if (!is_object($nameOrModel) || $nameOrModel instanceof JsonSerializable) {
             $return = Json::encode($nameOrModel);
         } elseif ($nameOrModel instanceof Traversable) {
             $nameOrModel = ArrayUtils::iteratorToArray($nameOrModel);
             $return = Json::encode($nameOrModel);
         } else {
             $return = Json::encode(get_object_vars($nameOrModel));
         }
         if ($this->hasJsonpCallback()) {
             $return = $this->jsonpCallback . '(' . $return . ');';
         }
         return $return;
     }
     // use case 3: Both $nameOrModel and $values are populated
     throw new Exception\DomainException(sprintf('%s: Do not know how to handle operation when both $nameOrModel and $values are populated', __METHOD__));
 }
開發者ID:Baft,項目名稱:Zend-Form,代碼行數:44,代碼來源:JsonRenderer.php

示例4: render

 /**
  * Renders values as XML
  *
  * @todo   Determine what use case exists for accepting both $nameOrModel and $values
  * @param  string|Model $nameOrModel The script/resource process, or a view model
  * @param  null|array|\ArrayAccess $values Values to use during rendering
  * @throws Exception\DomainException
  * @return string The script output.
  */
 public function render($nameOrModel, $values = null)
 {
     if ($nameOrModel instanceof \ShinyRest\View\Model\XmlModel) {
         return $nameOrModel->serialize();
     }
     #echo "<pre>";
     #print_r($nameOrModel);
     throw new \DomainException(get_class($nameOrModel) . " is not an instance of XmlModel");
 }
開發者ID:shinymayhem,項目名稱:shiny-rest,代碼行數:18,代碼來源:XmlRenderer.php


注:本文中的Zend\View\Model\ModelInterface::serialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。