本文整理匯總了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);
}