本文整理匯總了PHP中Resource::getData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Resource::getData方法的具體用法?PHP Resource::getData怎麽用?PHP Resource::getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Resource
的用法示例。
在下文中一共展示了Resource::getData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getComposite
public function getComposite()
{
$composerName = $this->resource->getComposer();
$composer = $this->composerManager->getComposer($composerName);
$data = is_object($this->resource->getData()) ? array($this->resource->getData()) : $this->resource->getData();
// Get embeded composed models
$embededModels = $composer->getEmbededModels($this, $data);
// Compose resource
$embededModels = $embededModels ? $embededModels : array();
return $composer->compose($data, $embededModels);
}
示例2: testGetData
public function testGetData()
{
$resource = new Resource();
$resource->addSuccessMessage('foo');
$resource->addInfoMessage('bar');
$resource->addWarningMessage('baz');
$resource->addErrorMessage('boom');
$resource->setData(['key' => 'value']);
$this->assertSame(['key' => 'value', '_messages' => [['type' => 'success', 'message' => 'foo'], ['type' => 'info', 'message' => 'bar'], ['type' => 'warn', 'message' => 'baz'], ['type' => 'error', 'message' => 'boom']]], $resource->getData());
}
示例3: getFilteredAttributes
/**
* Filter attributes. Applies the visible/hidden field filter, hides owner of resource.
* If visible attributes are defined, hidden attributes filter will not be applied.
*
* @param \marius321967\BaseResource\Resource $resource
* @return array
*/
public static function getFilteredAttributes(Resource $resource)
{
$descriptor = $resource->getDescriptor();
$attributes = $resource->getData(true);
// In whatever case, client does not need to know about the owner of resource.
unset($attributes['owner_id']);
// If only fields that are visible are defined, don't use the other filter.
if (count($descriptor->getVisibleAttributes())) {
$attributes = array_intersect_key($attributes, array_flip($descriptor->getVisibleAttributes()));
} elseif (count($descriptor->getHiddenAttributes())) {
$attributes = array_diff_key($attributes, array_flip($descriptor->getHiddenAttributes()));
}
return $attributes;
}