當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。