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


PHP DataObject::hasMethod方法代碼示例

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


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

示例1: testExtensionCanBeAppliedToDataObject

 public function testExtensionCanBeAppliedToDataObject()
 {
     $do = new DataObject();
     $mo = new DataExtensionTest_MyObject();
     $this->assertTrue($do->hasMethod('testMethodApplied'));
     $this->assertTrue($mo->hasMethod('testMethodApplied'));
     $this->assertEquals("hello world", $mo->testMethodApplied());
     $this->assertEquals("hello world", $do->testMethodApplied());
 }
開發者ID:SpiritLevel,項目名稱:silverstripe-framework,代碼行數:9,代碼來源:DataExtensionTest.php

示例2: getFileEditValidator

 /**
  * Determines the validator to use for the edit form
  * @example 'getCMSValidator'
  *
  * @param DataObject $file File context to generate validator from
  * @return Validator Validator object
  */
 public function getFileEditValidator(DataObject $file)
 {
     // Empty validator
     if (empty($this->fileEditValidator)) {
         return null;
     }
     // Validator instance
     if ($this->fileEditValidator instanceof Validator) {
         return $this->fileEditValidator;
     }
     // Method to call on the given file
     if ($file->hasMethod($this->fileEditValidator)) {
         return $file->{$this->fileEditValidator}();
     }
     throw new InvalidArgumentException("Invalid value for UploadField::fileEditValidator");
 }
開發者ID:SpiritLevel,項目名稱:silverstripe-framework,代碼行數:23,代碼來源:UploadField.php

示例3: markChildren

 /**
  * Mark all children of the given node that match the marking filter.
  *
  * @param DataObject $node              Parent node
  * @param mixed      $context
  * @param string     $childrenMethod    The name of the instance method to call to get the object's list of children
  * @param string     $numChildrenMethod The name of the instance method to call to count the object's children
  * @return DataList
  */
 public function markChildren($node, $context = null, $childrenMethod = "AllChildrenIncludingDeleted", $numChildrenMethod = "numChildren")
 {
     if ($node->hasMethod($childrenMethod)) {
         $children = $node->{$childrenMethod}($context);
     } else {
         user_error(sprintf("Can't find the method '%s' on class '%s' for getting tree children", $childrenMethod, get_class($node)), E_USER_ERROR);
     }
     $node->markExpanded();
     if ($children) {
         foreach ($children as $child) {
             $markingMatches = $this->markingFilterMatches($child);
             if ($markingMatches) {
                 // Mark a child node as unexpanded if it has children and has not already been expanded
                 if ($child->{$numChildrenMethod}() && !$child->isExpanded()) {
                     $child->markUnexpanded();
                 } else {
                     $child->markExpanded();
                 }
                 $this->markedNodes[$child->ID] = $child;
             }
         }
     }
     return $children;
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:33,代碼來源:Hierarchy.php

示例4: getFileEditValidator

 /**
  * Determines the validator to use for the edit form
  * @example 'getCMSValidator'
  *
  * @param DataObject $file File context to generate validator from
  * @return Validator Validator object
  */
 public function getFileEditValidator(DataObject $file)
 {
     // Empty validator
     if (empty($this->fileEditValidator)) {
         return null;
     }
     // Validator instance
     if ($this->fileEditValidator instanceof Validator) {
         return $this->fileEditValidator;
     }
     // Method to call on the given file
     if ($file->hasMethod($this->fileEditValidator)) {
         return $file->{$this->fileEditValidator}();
     }
     user_error("Invalid value for UploadField::fileEditValidator", E_USER_ERROR);
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:23,代碼來源:UploadField.php


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