Binding Resolution Laravel 5.3 - laravel

What is the difference between
$this->app->when('App\Http\Controllers\StaffController')
->needs('App\Repositories\User\UserInterface')
->give('App\Repositories\User\StaffRepository');
This one works!
$this->app->when(StaffController::class)
->needs(UserInterface::class)
->give(StaffRepository::class);
But this one doesn't work. What's the problem?

Given that this works:
$this->app->when(\App\Http\Controllers\StaffController::clas‌​s)
->needs(\App\Repos‌​itories\User\UserInt‌​erface::class)
->give‌​(\App\Repositories\U‌​ser\StaffRepository:‌​:class);
you have a namespace issue. You can use this as-is with the leading \s, but chances are putting this at the top of the file will resolve it:
use App\Http\Controllers\StaffController;
use App\Repos‌​itories\User\UserInt‌​erface;
use App\Repositories\U‌​ser\StaffRepository;

Related

Suffix and Prefix Asterisk in combination with Wildcard in Datadog Metrics

It's quite simple: I have
a datadog-dashbaord
a template-variable named env, which can have following values ['prod', 'test']
And I want to display metrics based on the env:
from-resource for test is unified-importer-test-sqsimportdlq11419573-xl6dn7o5wqtj
from-resource for prod is unified-importer-prod-sqsimportdlq11419573-prmohksrvxxg
So naturally I'd use following syntax:
unified-importer-$env.value-sqsimportdlq*
But this does not display anything, nor shows it any error.
This, however, works as expected: unified-importer-test-sqsimportdlq* (or unified-importer-prod-sqsimportdlq* respectively).
It looks like asterisk in combination with wildcards is not working.
Additionally, DD seems to dislike using two asterisks (as prefix and suffix):
How can I leverage the template-var env easily in this situation?
Well, it turned out that following solution works:
sum:aws.sqs.approximate_number_of_messages_visible{service:unified-importer AND env:$env.value AND queuename IN (unified-importer-test-sqsimportdlq86419573-al6dn7o5wqtj,unified-importer-prod-sqsimportdlq86419573-prmohksrvmxg)}
There's no way to use the template variable in the middle of a string, it can only go at the end. That would be a feature request to the Datadog team

Graphite storage-aggregation.conf regex scope

I have had a good read through the doc on this but am still none the wiser.
http://graphite.readthedocs.io/en/latest/config-carbon.html
If we have a metric like so:
/var/lib/graphite/whisper/p1/p2/account/count_num_events.wsp
Does anyone know for sure exactly what part of this path graphite is applying the storage-aggregation regex to?
I assume that it will be just
"count_num_events"
and as such I could use a regex "^count.*" to match it. Or will it be applied to all or part of the rest of the path?
Cheers.
You are correct. that will be the thing you need. BUT note the metric will be using dots not slashes
p1.p2.account.count_num_events
So what you'll need in storage-aggregation is any of the following
*count_num_events
p1.p2.*.count_num_events
p1.*.account.count_num_events
*.account.count_num_events
*.count_num_events
*count_num_events$
p1.p2.account.count_num_events
I have finally got round to doing some testing on this.
Thanks for the answer Fred S I wish I had seen the response before doing the testing, would have helped.
So the answer is that graphite matches on the full metric name which is . separated. Which for the example metric file:
/var/lib/graphite/whisper/p1/p2/account/count_num_events.wsp
Would be:
p1.p2.account.count_num_events
So the most strict regex you could do would be:
^p1\.p2\.account\.count_num_events$

Kamailio 4.4 seturi Only Accepts Explicit Strings?

I've been working at implementing a simple serial forking described in the TM module's documentation (the Q values are stored as a priority weight in a mysql table) where my proxy is querying a database to determine to what domain to forward to.
I've verified through extensive use of xlog that a variable I'm using to build the new URI to use with seturi is getting everything correctly. I use an append_branch call in a subsequent while loop iterating over my sql query results, which doesn't have any problems with taking a very similarly formatted parameter. However, when I go to restart Kamailio it simply gripes at me that a string is expected. The line it corresponds to from console is just the seturi call. I've tried casting as a string, but that doesn't seem to be part of 4.4 (or my syntax is wrong).
I've thought about building the URI strings and storing into avp, but I suspect I'd have the same problem.
For reference, this is what I'm doing:
$var(basedest) = "sip:" + $var(number) + "#" + $(dbr(destination=>[0,0]))+ ":" + $var(port);
seturi($var(basedest));
And what it's outputting when trying to load the config:
<core> [cfg.y:3368]: yyerror_at(): parse error in config file //etc/kamailio/kamailio.cfg, line 570, column 9-22: syntax error
<core> [cfg.y:3371]: yyerror_at(): parse error in config file //etc/kamailio/kamailio.cfg, line 570, column 23: bad argument, string expected
Naturally, when I put $var(basedest) in double quotes, it's literally interpreted as a string. Single quotes behave similarly. Is there something I can do to work around this? When I feed it an explicit hardcoded string, it's happy as a can be and the routing works fine. When I try to do something very simple like the above, it gets upset. If possible, I'd like to avoid updating as I initially grabbed Kamailio from the yum repo.
Thanks in advance - this has been bugging me a good while.
Apparently, not a new problem. I ended up finding out what I can do to work around it.
For reference, seturi and $ru pseudo variable refer to the same thing. So basically you'd just do:
$var(mynewru) = "sip:user#domain:5060";
$ru = $var(mynewru);
This would achieve the same thing I was originally attempting to do before based on the TM module's documentation. For serial forking, issuing some number of append_branch calls is fine.

Spring SpEL escape package name in T() function

I have simple question, Is it possible to escape package name in Spring-EL function T(..)?
The reason why I need this is because I live in Lithuania and all our packages start with country code lt f.e. lt.aaa.bbb.ccc. As you could expect this something we can not change.
Now, when I try to use SpEL to access some constant or static function in my classes I write:
#{T(lt.aaa.bbb.ccc).CONSTANR_VAR}, but this doesn't work, because SpEL parses expression and interprets lt as 'Less Then' not as part of package. This should be a problem for country codes gt, eq etc.
Is there any way around this, or are we just wery unlucky?
I can't immediately think of a workaround. I created:
https://jira.springsource.org/browse/SPR-10942
against the spring framework to cover the problem. I have SpEL open up at the moment as I'm working on something so I might try to get this fixed soon.

XPath: using or

I need to find elements on a dynamic website that contain either test.gif or test2.gif. Tt my be that one of those is not present. Whats the correct synax to do it? My take with:
'.//*[#src="http://test/test1.gif"] or .//*[#src="http://test/test2.gif"]'
doesn't seem to work.
have you tried with:
#src="http://test/test1.gif" or #src="http://test/test2.gif"

Resources