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


PHP Document::getOpType方法代码示例

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


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

示例1: create

 /**
  * @param \Elastica\Document $document
  * @param string $opType
  * @return \Elastica\Bulk\Action\AbstractDocument
  */
 public static function create(Document $document, $opType = null)
 {
     if (null === $opType && $document->hasOpType()) {
         $opType = $document->getOpType();
     }
     switch ($opType) {
         case self::OP_TYPE_DELETE:
             $action = new DeleteDocument($document);
             break;
         case self::OP_TYPE_CREATE:
             $action = new CreateDocument($document);
             break;
         case self::OP_TYPE_UPDATE:
             $action = new UpdateDocument($document);
             break;
         case self::OP_TYPE_INDEX:
         default:
             $action = new IndexDocument($document);
             break;
     }
     return $action;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:27,代码来源:AbstractDocument.php

示例2: create

 /**
  * @param \Elastica\Document|\Elastica\Script\AbstractScript $data
  * @param string                                             $opType
  *
  * @return static
  */
 public static function create($data, $opType = null)
 {
     //Check type
     if (!$data instanceof Document && !$data instanceof AbstractScript) {
         throw new \InvalidArgumentException('The data needs to be a Document or a Script.');
     }
     if (null === $opType && $data->hasOpType()) {
         $opType = $data->getOpType();
     }
     //Check that scripts can only be used for updates
     if ($data instanceof AbstractScript) {
         if ($opType === null) {
             $opType = self::OP_TYPE_UPDATE;
         } elseif ($opType != self::OP_TYPE_UPDATE) {
             throw new \InvalidArgumentException('Scripts can only be used with the update operation type.');
         }
     }
     switch ($opType) {
         case self::OP_TYPE_DELETE:
             $action = new DeleteDocument($data);
             break;
         case self::OP_TYPE_CREATE:
             $action = new CreateDocument($data);
             break;
         case self::OP_TYPE_UPDATE:
             $action = new UpdateDocument($data);
             break;
         case self::OP_TYPE_INDEX:
         default:
             $action = new IndexDocument($data);
             break;
     }
     return $action;
 }
开发者ID:makeandship,项目名称:wordpress-fantastic-elasticsearch,代码行数:40,代码来源:AbstractDocument.php

示例3: create

 /**
  * @param \Elastica\Document|\Elastica\Script $data
  * @param string $opType
  * @return \Elastica\Bulk\Action\AbstractDocument
  */
 public static function create($data, $opType = null)
 {
     //Check type
     if (!$data instanceof Document && !$data instanceof Script) {
         throw new \InvalidArgumentException("The data needs to be a Document or a Script.");
     }
     if (null === $opType && $data->hasOpType()) {
         $opType = $data->getOpType();
     }
     //Check that scripts can only be used for updates
     if ($data instanceof Script && isset($opType) && $opType != self::OP_TYPE_UPDATE) {
         throw new \InvalidArgumentException("When performing an update action, the data needs to be a Document or a Script.");
     }
     switch ($opType) {
         case self::OP_TYPE_DELETE:
             $action = new DeleteDocument($data);
             break;
         case self::OP_TYPE_CREATE:
             $action = new CreateDocument($data);
             break;
         case self::OP_TYPE_UPDATE:
             $action = new UpdateDocument($data);
             break;
         case self::OP_TYPE_INDEX:
         default:
             $action = new IndexDocument($data);
             break;
     }
     return $action;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:35,代码来源:AbstractDocument.php


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