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