Select what you want to copy and in doing so you will keep the formatting when pasting it.
The problem is, the first message would have to be an error message, which is fine... however, the second needs to be a confirmation message... how do i pass that data to the add_message method of the messages class?
The solution... pass an array (optional), like this...
Select what you want to copy and in doing so you will keep the formatting when pasting it.
and it will automatically extract the second element from the array it recieves and use that as the type... otherwise, if it gets a string, it uses the second parameter in the method.
I've never used this technique before... but it saved me! Just wondering if there is a name or anything for it... like if a function calls itself it's called recursion... you got factory patterns, decorator patterns, etc... is there a name?
That's what I've always done, use an array. I wouldn't use text for the type though, I always use integers there and just make a key somewhere in my code to remember what each int means. I don't think I have to give you an example though!
C# offers better functionality in this dept, but as far as I know, this is really the only way of doing so in PHP.
$message->add_message("Warning though, don't do this again");
$message->add_message(array("Warning though, don't do this again"));
$message->add_message("Warning though, don't do this again", "error");
$message->add_message(array("Warning though, don't do this again",
"error"));
Select what you want to copy and in doing so you will keep the formatting when pasting it.
Which all produce exactly the same result.
Also, i know using text for type is not really very good... using global definitions i don't like either though... having shit loads of those is just confusing. What would be really good is if i could enum it like:
It does, but that don't solve the problem. If a function returns a message and needs to change the default type then you can't. Thats the exact problem my solution solved.
Anyway, here's a new version of that class for izzmo...
You do not have permission to post replies to topics in this board. If you want to join in with discussions and create new topics please register. If you want to register your own free account with us, please click here.