public function edit(Resource $instance, $form, $userId = null)
    {
        try {
            $uploadedFile = $this->fetchUploadedFile($form);

            $xmlFile = $this->getSharedStimulusFile($uploadedFile);

            $this->getUploadService()->remove($uploadedFile);

            // throws an exception of invalid
            SharedStimulusImporter::isValidSharedStimulus($xmlFile);

            $embeddedFile = static::embedAssets($xmlFile);

            $report = $this->replaceSharedStimulus($instance, $this->getDecodedUri($form), $embeddedFile, $userId);
        } catch (\Exception $e) {
            $message = $e instanceof common_exception_UserReadableException
                ? $e->getUserMessage()
                : __('An error has occurred. Please contact your administrator.');
            $report = Report::createFailure($message);
            $this->logError($e->getMessage());
            $report->setData(['uriResource' => '']);
        }

        return $report;
    }
public function edit(Resource $instance, $form, $userId = null)
    {
        try {
            $uploadedFile = $this->fetchUploadedFile($form);

            $xmlFile = $this->getSharedStimulusFile($uploadedFile);

            $this->getUploadService()->remove($uploadedFile);

            // throws an exception of invalid
            SharedStimulusImporter::isValidSharedStimulus($xmlFile);

            $embeddedFile = static::embedAssets($xmlFile);

            $report = $this->replaceSharedStimulus($instance, $this->getDecodedUri($form), $embeddedFile, $userId);
        } catch (\Exception $e) {
            $message = $e instanceof common_exception_UserReadableException
                ? $e->getUserMessage()
                : __('An error has occurred. Please contact your administrator.');
            $report = Report::createFailure($message);
            $this->logError($e->getMessage());
            $report->setData(['uriResource' => '']);
        }

        return $report;
    }
public function edit ( Resource $ instance , $ form , $ userId = null ) { try { $ uploadedFile = $ this -> fetchUploadedFile ( $ form ) ; $ xmlFile = $ this -> getSharedStimulusFile ( $ uploadedFile ) ; $ this -> getUploadService ( ) -> remove ( $ uploadedFile ) ; // throws an exception of invalid SharedStimulusImporter :: isValidSharedStimulus ( $ xmlFile ) ; $ embeddedFile = static :: embedAssets ( $ xmlFile ) ; $ report = $ this -> replaceSharedStimulus ( $ instance , $ this -> getDecodedUri ( $ form ) , $ embeddedFile , $ userId ) ; } catch ( \ Exception $ e ) { $ message = $ e instanceof common_exception_UserReadableException ? $ e -> getUserMessage ( ) : __ ( 'An error has occurred. Please contact your administrator.' ) ; $ report = Report :: createFailure ( $ message ) ; $ this -> logError ( $ e -> getMessage ( ) ) ; $ report -> setData ( [ 'uriResource' => '' ] ) ; } return $ report ; }
Edit a shared stimulus package

@param \core_kernel_classes_Resource $instance
@param Form|array $form
@param null|string $userId
@return Report
Edit a shared stimulus package