本文整理汇总了PHP中modResource::getGroupsList方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::getGroupsList方法的具体用法?PHP modResource::getGroupsList怎么用?PHP modResource::getGroupsList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::getGroupsList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
$this->resource = $this->getResource();
if (!is_object($this->resource) || !$this->resource instanceof modResource) {
return $this->failure($this->resource);
}
/* setup default properties */
$isLimit = $this->getProperty('limit') > 0;
$resourceGroupList = $this->resource->getGroupsList(array($this->getProperty('sort') => $this->getProperty('dir')), $isLimit ? $this->getProperty('limit') : 0, $this->getProperty('start'));
$resourceGroups = $resourceGroupList['collection'];
$parentGroups = array();
$mode = $this->getProperty('mode');
$parent = $this->getProperty('parent', 0);
$token = $this->getProperty('token', '');
// see if this request is in the context of a resource reload
if (!empty($token)) {
$rgs = $this->getRGReloadData($token);
} else {
if (!empty($parent) && $mode == 'create') {
$parent = $this->modx->getObject('modResource', $parent);
/** @var modResource $parent */
if ($parent) {
$parentResourceGroups = $parent->getMany('ResourceGroupResources');
/** @var modResourceGroupResource $parentResourceGroup */
foreach ($parentResourceGroups as $parentResourceGroup) {
$parentGroups[] = $parentResourceGroup->get('document_group');
}
$parentGroups = array_unique($parentGroups);
}
}
}
$list = array();
/** @var modResourceGroup $resourceGroup */
foreach ($resourceGroups as $resourceGroup) {
$resourceGroupArray = $resourceGroup->toArray();
$resourceGroupArray['access'] = (bool) $resourceGroupArray['access'];
if (!empty($parent) && $mode == 'create') {
$resourceGroupArray['access'] = in_array($resourceGroupArray['id'], $parentGroups) ? true : false;
}
if (is_array($rgs) && count($rgs) > 0) {
$name = $resourceGroup->get('name');
if (array_key_exists($name, $rgs)) {
$resourceGroupArray['access'] = (bool) $rgs[$name]->get('access');
}
}
$list[] = $resourceGroupArray;
}
return $this->outputArray($list, $resourceGroupList['total']);
}
示例2: getResourceGroups
public function getResourceGroups()
{
$parentGroups = array();
if ($this->resource->get('id') == 0) {
$parent = $this->modx->getObject('modResource', $this->resource->get('parent'));
/** @var modResource $parent */
if ($parent) {
$parentResourceGroups = $parent->getMany('ResourceGroupResources');
/** @var modResourceGroupResource $parentResourceGroup */
foreach ($parentResourceGroups as $parentResourceGroup) {
$parentGroups[] = $parentResourceGroup->get('document_group');
}
$parentGroups = array_unique($parentGroups);
}
}
$this->resourceArray['resourceGroups'] = array();
$resourceGroups = $this->resource->getGroupsList(array('name' => 'ASC'), 0, 0);
/** @var modResourceGroup $resourceGroup */
foreach ($resourceGroups['collection'] as $resourceGroup) {
$access = (bool) $resourceGroup->get('access');
if (!empty($parent) && $this->resource->get('id') == 0) {
$access = in_array($resourceGroup->get('id'), $parentGroups) ? true : false;
}
$resourceGroupArray = array($resourceGroup->get('id'), $resourceGroup->get('name'), $access);
$this->resourceArray['resourceGroups'][] = $resourceGroupArray;
}
return $this->resourceArray['resourceGroups'];
}
示例3: process
public function process()
{
$this->resource = $this->getResource();
if (!is_object($this->resource) || !$this->resource instanceof modResource) {
return $this->failure($this->resource);
}
/* setup default properties */
$isLimit = $this->getProperty('limit') > 0;
$resourceGroupList = $this->resource->getGroupsList(array($this->getProperty('sort') => $this->getProperty('dir')), $isLimit ? $this->getProperty('limit') : 0, $this->getProperty('start'));
$resourceGroups = $resourceGroupList['collection'];
$parentGroups = array();
$mode = $this->getProperty('mode');
$parent = $this->getProperty('parent', 0);
if (!empty($parent) && $mode == 'create') {
$parent = $this->modx->getObject('modResource', $parent);
/** @var modResource $parent */
if ($parent) {
$parentResourceGroups = $parent->getMany('ResourceGroupResources');
/** @var modResourceGroupResource $parentResourceGroup */
foreach ($parentResourceGroups as $parentResourceGroup) {
$parentGroups[] = $parentResourceGroup->get('document_group');
}
$parentGroups = array_unique($parentGroups);
}
}
$list = array();
/** @var modResourceGroup $resourceGroup */
foreach ($resourceGroups as $resourceGroup) {
$resourceGroupArray = $resourceGroup->toArray();
$resourceGroupArray['access'] = (bool) $resourceGroupArray['access'];
if (!empty($parent) && $mode == 'create') {
$resourceGroupArray['access'] = in_array($resourceGroupArray['id'], $parentGroups) ? true : false;
}
$list[] = $resourceGroupArray;
}
return $this->outputArray($list, $resourceGroupList['total']);
}