Scalr\Api\Service\User\V1beta0\Controller\Roles::describeImagesAction PHP Method

describeImagesAction() public method

Retrieves the list of the Images associated with this Role
public describeImagesAction ( integer $roleId ) : array
$roleId integer The identifier of the role
return array
    public function describeImagesAction($roleId)
    {
        $this->checkScopedPermissions('IMAGES');
        //Finds out the Role object
        $role = $this->getRole($roleId);
        $criteria = [];
        $requestQuery = $this->params();
        if (isset($requestQuery['image'])) {
            $criteria[] = ['hash' => static::getBareId($requestQuery, 'image')];
        }
        $requestQuery = array_diff_key($requestQuery, array_flip(['image', 'role', ApiController::QUERY_PARAM_MAX_RESULTS, ApiController::QUERY_PARAM_PAGE_NUM]));
        if (!empty($requestQuery)) {
            throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, sprintf("Unsupported filter(s) [%s]. Fields which are available for filtering: [role, image]", implode(', ', array_keys($requestQuery))));
        }
        $images = $role->getImages($criteria, null, null, $this->getMaxResults(), $this->getPageOffset(), true);
        $roleImages = [];
        foreach ($images as $image) {
            /* @var $image Entity\Image */
            $roleImages[] = ['image' => ['id' => $image->hash], 'role' => ['id' => $roleId]];
        }
        return $this->resultList($roleImages, $images->totalNumber);
    }