本文整理汇总了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());
}
示例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");
}
示例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;
}
示例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);
}