Scalr_UI_Controller_Images::xUpdateNameAction PHP Méthode

xUpdateNameAction() public méthode

public xUpdateNameAction ( string $hash, string $name )
$hash string
$name string
    public function xUpdateNameAction($hash, $name)
    {
        $this->request->restrictAccess('IMAGES', 'MANAGE');
        if (!\Scalr\Model\Entity\Role::isValidName($name)) {
            $this->response->failure('Invalid name for image');
            return;
        }
        /* @var $image Image */
        $image = Image::findPk($hash);
        if (!$image) {
            $this->response->failure('Image not found');
            return;
        }
        $this->request->checkPermissions($image, true);
        $image->name = $name;
        $image->save();
        $this->response->data(['name' => $name]);
        $this->response->success('Image\'s name was updated');
    }