当前位置: 首页>>代码示例>>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;未经允许,请勿转载。