Slim3: Routing with "where" (like on Laravel) - slim

i'm looking for a similar solution for Slim3:
Route::get('/{name}', function ($name) {
//
}) ->where('name', 'bars|clubs|discos');
So a route should handle 3 different names.
Any idea?
Thanks!

According to docs, you can add a regular expression inside the placeholder definition
$app->get('/{name:bars|clubs|discos}', callback);

Related

How to use object filter with softlayer rest api?

I read this article and have some problems trying to follow the examples. The following is one of the examples given in that article. The first parameter in the object filter is virtualGuests. This object filter can be used in api https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests.
object_filter = {
'virtualGuests': {
'datacenter': {
'name': {'operation': 'dal05'}
}
}
}
I want to use the object filter in other api methods, like SoftLayer_Account/getBlockDeviceTemplateGroups for example. My question is how to get/set the first parameter like virtualGuests? I tried several times but failed.
Try to follow these recomendations: Getting first parameter through Service Datatype or How to define the first parameter as simple way?
Getting first parameter through Service Datatype
You are trying to get
SoftLayer_Account::getBlockDeviceTemplateGroups
As you see, you are using SoftLayer_Account service, you need to open its datatype from this service:
You can go here:
http://sldn.softlayer.com/reference/services/SoftLayer_Account and
click on "datatypes" label/option
Or go directly here:
SoftLayer_Account
So, you need to start here, the method that you are using is getBlockDeviceTemplateGroups, if you want to get this information in the datatypes, you should skip the word "get" and looking for "BlockDeviceTemplateGroups" property, so you will have the correct parameter that you need to set at first.
How to define the first parameter as simple way?
If you notice, the only changes were: skip "get" word from the method, in this case is "getBlockDeviceTemplateGroups", so it will be:
"BlockDeviceTemplateGroups"
The next step should be set the first char in lowercase like:
"blockDeviceTemplateGroups"
So, it should be the filter:
object_filter = {
'blockDeviceTemplateGroups': {
'datacenter': {
'name': {'operation': 'dal05'}
}
}
}
References:
Object Filters
Going Further with the SoftLayer API Python Client - Part
1

Multiples document s types refinementfilters

i am using rest api search to get documents with certain extensions types.
I am having this code:
&refinementfilters=or'(fileExtension:equals("aspx"),fileExtension:equals("wmv"))'
The whole code is:
https://myUrl/_api/search/query?selectproperties='Path,Url,Title,Size,IsDocument,PictureUrl,LastModifiedTime'&querytext='wildlife'&refinementfilters= '(fileExtension:equals("aspx"))'
i would like to use rest api refinementfilters fileExtension using or, but the syntax with the OR condition doesn' t work, can you halp me point out
where the problem can be ?
Cheers
To apply multiple filters via refinementfilters property, replace
refinementfilters='(fileExtension:equals("aspx"))'
with
refinementfilters='fileExtension:or("aspx","wmv")'
Example
/_api/search/query?selectproperties='Path,Url,Title,Size,IsDocument,PictureUrl,LastModifiedTime'&querytext='*'&refinementfilters= 'fileExtension:or("docx","pdf")'
As far as general syntax, the quotes for the OR are in the wrong place:
Original version:
&refinementfilters=or'(fileExtension:equals("aspx"),fileExtension:equals("wmv"))'
Corrected version:
&refinementfilters='or(fileExtension:equals("aspx"),fileExtension:equals("wmv"))'

SAPUI5 TableSelectDialog Search Value

I'm using TableSelectDialog control where I'm also performing some search. In order to get the search value on livesearch, i'm using oControlEvent.getParameters.value but it returns me undefined as I see it in an alert box.
Any idea why it is giving me undefined or any other way I can get the value I typed in search field.
This works with oEvent.getParameters().value.
Another idea, as most used way to find the query value is for a SeachField, we use
oEvent.getSource().getValue
Here, you can also find the query string similarly:
oEvent.getSource()._oSearchField.getValue()
Adding to the other answers here you can also do:
onSearch: function(oControlEvent) {
oControlEvent.getParameters("value");
}
https://sapui5.hana.ondemand.com/#/api/sap.m.TableSelectDialog/events/search

Laravel Eloquent query similar to findorfail

I would like to look up and return an object referenced by a different column to that of id.
As far as I know there isn't another method similar to Task::findOrFail($id) but that can reference another field. For example:
Task::findOrFail('column_name' = 'column_data');
I'm currently using
Task::where('tid' , '=', $tid)->first();
Is this possible?
Maybe you can use the firstOrFail() function of Laravel.
Task::where('column_name', '=' ,'column_data')->firstOrFail();

How to use "not" in XPath?

I want to write something of the sort:
//a[not contains(#id, 'xx')]
(meaning all the links that there 'id' attribute doesn't contain the string 'xx')
I can't find the right syntax.
not() is a function in XPath (as opposed to an operator), so
//a[not(contains(#id, 'xx'))]
you can use not(expression) function
or
expression != true()
None of these answers worked for me for python. I solved by this
a[not(#id='XX')]
Also you can use or condition in your xpath by | operator. Such as
a[not(#id='XX')]|a[not(#class='YY')]
Sometimes we want element which has no class. So you can do like
a[not(#class)]
Use boolean function like below:
//a[(contains(#id, 'xx'))=false]