本文整理汇总了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;
}