OptomPortalConnection::createNewSignatureImage PHP Method

createNewSignatureImage() public method

Creates a new ProtectedFile for the new signature image
public createNewSignatureImage ( $imageData, $fileId ) : ProtectedFile
$imageData
return ProtectedFile
    public function createNewSignatureImage($imageData, $fileId)
    {
        $protected_file = new \ProtectedFile();
        $protected_file = $protected_file->createForWriting('cvi_signature_' . $fileId);
        if (file_put_contents($protected_file->getPath(), $imageData)) {
            $protected_file->save();
            return $protected_file;
        }
    }

Usage Example

Example #1
0
 public function actionGetSignatureFromPortal()
 {
     if (Yii::app()->user->id) {
         // TODO: query the portal here:
         // TODO: get current unique ID for the user
         // TODO: query the portal with the current unique ID
         // TODO: if successfull save the signature as a ProtectedFile
         // from the portal we receive binary data:
         $user = User::model()->findByPk(Yii::app()->user->id);
         $portal_conn = new OptomPortalConnection();
         if ($portal_conn) {
             $signature_data = $portal_conn->signatureSearch(null, $user->generateUniqueCodeWithChecksum($this->getUniqueCodeForUser()));
             if (is_array($signature_data) && isset($signature_data["image"])) {
                 $signature_file = $portal_conn->createNewSignatureImage($signature_data["image"], Yii::app()->user->id);
                 if ($signature_file) {
                     $user->signature_file_id = $signature_file->id;
                     if ($user->save()) {
                         echo true;
                     }
                 }
             }
         }
     }
     echo false;
 }
All Usage Examples Of OptomPortalConnection::createNewSignatureImage