-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cloneRow exception #950
Comments
Have you tried to print
My output: "Can not clone row, template variable not found or variable contains markup." |
Hi @jslirola, yes I've the same output, but this is the cloneRow output, not $e->getMessage() output. I need to continue the execution if template variable not found... Thanks |
Hi, You need to continue because is a loop? |
Hi, no! Because if the placeholder is not present, the script call an exception... I need to continue.
Thanks
Stefano
… Il giorno 29 nov 2016, alle ore 16:05, Pedro Jose ***@***.***> ha scritto:
Hi, You need to continue because is a loop?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Continue writing your code in the catch section |
Hi Pedro, the code stop execution... I don't know the reason...
This is the problem.
Thanks
Stefano
… Il giorno 30 nov 2016, alle ore 08:49, Pedro Jose ***@***.***> ha scritto:
Continue writing your code in the catch section
try{ $template->cloneRow('placeHolder', "aaa"); } catch (Exception $e) { // do nothing... php will ignore the exception and continue }
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Are you using TemplateProcessor class for the creation of the object template?. |
Yes!
Il giorno 30 novembre 2016 @ 09:34:31, Pedro Jose ([email protected])
ha scritto:
Are you using TemplateProcessor class for the creation of the object
template?.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#950 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGEZydyYi0x01UyC12EO1G3jaz5NnVQ_ks5rDTUWgaJpZM4K4wb_>
.
|
What do you want to do?. I need see some code... |
Pedro, I create a method to create a doc from template with a lot of
placeholders (and some table row to clone). I can not know which
placeholders I will find in the template so, if a placeholder is not
present I need to continue the execution. The function
$templateProcessor->setValue(‘…’,’…') does
not generate an exception if the placeholder is not present. The
$templateProcessor->cloneRow(‘…’,’…’) generate an exception.
Thanks!
Stefano
Il giorno 30 novembre 2016 @ 09:39:45, Pedro Jose ([email protected])
ha scritto:
What do you want to do?. I need see some code...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#950 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGEZyfB55BSkG-o2ioGleJ8zUBA3BSICks5rDTZRgaJpZM4K4wb_>
.
|
Yes, the develop branch.
Il giorno 30 novembre 2016 @ 10:15:48, Pedro Jose ([email protected])
ha scritto:
Which version is your Library of PhpWord?, The last?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#950 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGEZyY4vxpOKarHTICN6wVT6h83i0d7dks5rDT7DgaJpZM4K4wb_>
.
|
I've already seen your mistake. You are mistakenly changing the parameters
|
Ok Pedro, I’ve write a string instead of interior only for example. In my
code is correct.
Try with $template->cloneRow('placeHolder', 10) and you will get the same
behavior. If the placeholder is not present, che cloneRow method goes in
exception. The setValue method no.
thank you for your interest
Stefano
Il giorno 30 novembre 2016 @ 10:28:54, Pedro Jose ([email protected])
ha scritto:
I've already seen your mistake. You are mistakenly changing the parameters
You are passing two strings to the method cloneRow
$template->cloneRow('placeHolder', "aaa");
The cloneRow Method accepts two parameters: A string and a Integer.
The string is you placeHolder, that is right.
But the next parameter is the number of clones that you want.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#950 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGEZyfnFKFnOs5RNzcjXXzjupNd71TWdks5rDUHUgaJpZM4K4wb_>
.
|
Because the setValue not thows any exception. |
Yes, I saw :) But, how to resolve this problem? I think the behavior of
setValue and cloreRow should be the same (without exception).
Thanks
Il giorno 30 novembre 2016 @ 10:47:20, Pedro Jose ([email protected])
ha scritto:
Because the setValue not thows any exception.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#950 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGEZyeLRN1nKkZwo_F_FpnXu7q3mS_8Fks5rDUYogaJpZM4K4wb_>
.
|
A solution would be using I did a pull request with the ability to disable the exception:
|
Hello, I have this Problem too. Rappi |
Hello, Using a try catch block did not work because the exception is already caught and thrown in the cloneRow method. So my solution is to check weather the marker / tag / variable / placeholder exists in the template like so: Perhaps it helps someone, even if the thread is old. |
Hi, if $templateProcessor->cloneRow doesn't find the placeholder, go in exception.
How to prevent this behaviour? I don't know if in this particular template exist the placeHolder.
I try to catch the exception, but without results...
try { $template->cloneRow('placeHolder', "aaa"); } catch (Exception $e) {}
Thanks
Stefano
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: