I'm working on a symfony 5 project.
I use ramsey/uuid.
My doctrine.yaml
dbal:
types:
uuid: Ramsey\Uuid\Doctrine\UuidType
My route in my controller
/**
* #Route(
* "/job/{id}",
* name="job_show",
* methods={"GET"}
* )
*/
I would like to add the requirements to verify if the "id" parameter is a uuid.
I tried with several regex but none work :
Regex tried :
requirements={"id"="/^[a-f0-9]{8}\-[a-f0-9]{4}\-4[a-f0-9]{3}\-[a-f0-9]{4}\-[a-f0-9]{12}$/"}
requirements={"id"="/^[a-f0-9\-]{36}$/"}
Every time I get this error:
No route found for "GET /job/dc5a945c-25a1-4760-bd69-970d94560cce"
I have watch severals similar questions like Searching for UUIDs in text with regex but none helped me.
Does anyone know where my error may come from or how to do it differently ?
You can use:
requirements={"id"="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"})
Related
I updated a website to Drupal 8.9.6 version. I saw that the global variable $pager_total_items was used, but is deprecated since D8.8.0.
So, I'm looking for an alternative to retrieve the total items of the pager.
This was used on a Search API page.
The old code looks like this :
$variables['count_results'] = empty($GLOBALS['pager_total_items']) ? 0 : $GLOBALS['pager_total_items'][0];
And now, looking this change record : https://www.drupal.org/node/2779457 I try to replace this like this :
/** #var \Drupal\Core\Pager\PagerManager $pagerManager */
$pagerManager = \Drupal::service('pager.manager');
dpm($pagerManager->getPager());
This renders nothing in the dpm(), so no Pager was found. It appears that Search API doesn't use a Pager...
This works for me:
$pager = \Drupal::service('pager.manager')->getPager();
$count_results = $pager->getTotalItems();
I tried to query Loopback js Model using "inq" (mongo $in) syntax
like this:
let itemNames = [/test/i, /test2/i];
app.models.skill.find({where: {name: {inq: itemNames}}}, ....
But loopback is changing regexp to strings.
loopback sends strings like
{ name: { $in: [ "/test/i", "/test2/i" ] } }
expected to work like described here:
https://docs.mongodb.com/manual/reference/operator/query/in/#use-the-in-operator-with-a-regular-expression
Can you suggest a fix or a workaround for this (but I can't patch loopback itself it is a business requirement)
Loopback accepted my changes,
https://github.com/strongloop/loopback-datasource-juggler/pull/1279
so it should be possible to use regexps like in mongo.
You may create inq item like this:
let itemNames = [new RegExp('/test/i'), new RegExp('/test2/i')];
It worked for me.
I am using a Parse OR query to find user matches based on regex and emails within an array. The regex can be quite long as I am generating it from names in the user's address book. My code is below:
PFQuery *emailQuery = [WPUser query];
[emailQuery whereKey:#"email" containedIn:emails];
PFQuery *nameQuery = [WPUser query];
[nameQuery whereKey:#"name" matchesRegex:regex modifiers:#"i"];
PFQuery *query = [PFQuery orQueryWithSubqueries:#[emailQuery, nameQuery]];
[query whereKey:#"objectId" notEqualTo:[WPUser currentUser].objectId];
[query whereKeyExists:#"signedUp"];
[query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
self.registeredContacts = objects;
BLOCK_ON_MAINTHREAD()
}];
The regex format is (^First.*Last$)|(^First.*Last$) etc. for each name in the address book. I use the i modifier to make it case insensitive.
However, I get a weird error with this query and it seems to have only begun recently: [Error]: geo query within or is not supported (Code: 102, Version: 1.14.2). I am not adding any geo constraints to this query as you can see. If my regex somehow causing Parse to add a geoquery? If I comment out the line of matchesRegex:modifiers: then the query returns as normal...however I am obviously losing the functionality I need.
I do not have symbols or anything as I am also validating names with an NSCharacterSet.
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet letterCharacterSet];
[validCharacters formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
Why is Parse giving me an error that has no relation to my actual query? If it is related to my regex, any ideas on avoiding it?
I have some Chinese names in my address book and for some reason these names were causing the error I added a line in checking my regex to skip these names and the error is gone.
For reference I added a BOOL check:
BOOL isLatin = [regexName canBeConvertedToEncoding:NSISOLatin1StringEncoding];
Context
SDN 3.3.0.RELEASE / 3.4.0.M1
Neo4j 2.1.7 in distant server mode.
Use case
I have an existing Person in database which can have multiple PersonTranslatedContent that can be in several languages.
So basicaly, my modelisation is like :
(:Person)-[:TRANSLATION {lang:"fr}]->(:PersonTranslatedContent)
Problem
When I create a PersonTranslatedContent node and a TRANSLATION relation to link with my Person, the 'lang' property is not persisted on the relationship.
The nodes are corecctly created, but when I query the database from the Neo4j browser, my relationship has only one property : _type__ : PersonToPersonTranslatedContent
Analysis
When logging the HTTP request received by Neo4j, the requets performed are in this order :
1. MATCH (n) WHERE id(n) = {id_n} MATCH (m) WHERE id(m) = {id_m} CREATE (n)-[r:`TRANSLATION`]->(m) SET r={props} RETURN id(r) as id, type(r) as type, r as properties, id(startNode(r)) as start, id(endNode(r)) as end
2. START r=rel({id}) SET r.`_ _type_ _` = {value}
3. START r=rel({id}) RETURN id(r) as id, type(r) as type, r as properties, id(startNode(r)) as start, id(endNode(r)) as end
4. **START r=rel({id}) SET r.`lang` = {value}** <-- here the lang property seems to be correctly set !
5. START r=rel({id}) SET r = {props} <- here, props = {"_ _type_ _" : PersonToPersonTranslatedContent"}
All those REST calls are done within a simple call to personToPersonTranslatedContentRepository.save(). I followed the white rabit in debug mode and here is the shortened call stack :
Neo4jEntityConverterImpl.write() --> entityStateHandler.useOrCreateState() --> RestAPICypherImpl.createRelationship() (correspond to bullet 1)
Neo4jEntityConverterImpl.write() --> typeMapper.writeType() --> RestAPICypherImpl.setPropertyOnEntity() (correspond to bullet 2)
Neo4jEntityConverterImpl.write() --> sourceStateTransmitter.copyPropertiesTo() --> persistentEntity.doWithProperties() --> RestAPICypherImpl.setPropertyOnEntity() (correspond to bullet 4)
Neo4jEntityConverterImpl.write() --> sourceStateTransmitter.copyPropertiesTo() --> ((UpdateableState)target).flush() --> RestAPICypherImpl.setPropertiesOnEntity() (correspond to bullet 5)
So, in my opinion considering what I know and what I saw during debug, the problem seems to be around the "propertyData" attribute of class RestEntity which is used in the ((UpdateableState)target).flush() ! It always hold the value {"_ type _" : PersonToPersonTranslatedContent"} but never contains my "lang" property.
Note : my problem is the same as the one explain here 3.3.0.M1 : Properties on RelationShipEntity not saved when using CypherRestGraphDatabase?. His post has no satisfying answer.
Can you help me (and him I guess) ?
Thx :)
13/07/15 : Updated
I finally manage to resolve my problem by using :
Map<String, Object> properties = new HashMap<>();
properties.put("lang", lang);
properties.put("__type__", "UserToUserTranslatedContent");
neo4jOperations.createRelationshipBetween(neo4jOperations.getNode(user.getId()), neo4jOperations.getNode(translatedContent.getId()), RelationNames.TRANSLATION, properties);
But it is still strange that simple save() operation do not work as expected
For people looking for a fix, I made a report concerning this problem (https://jira.spring.io/browse/DATAGRAPH-699) and a quick way to use SDN like before (< 3.3.x) is doing like this:
remove "spring-data-neo4j" and "spring-data-neo4j-rest" from your build.gradle and add these lines:
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'org.springframework:spring-orm:4.1.7.RELEASE'
compile 'org.springframework:spring-aspects:4.1.7.RELEASE'
compile 'com.github.nousmotards:spring-data-neo4j:3.3.1.NM1'
}
Hope this will help in the mean time of having a real fix ;)
I've been struggling with this problem the last 2 hours. I'm trying to add a regex-route to my Zend Framework (V1) application. My other routes are static and stored in my application.ini file and that is where i want to put some new regex-routes.
Before i continue to work on more complex regex routes i started to translate the following (working) route to a regex route:
resources.router.routes.shift-display.route = /shift/display/:id
resources.router.routes.shift-display.defaults.module = shift
resources.router.routes.shift-display.defaults.controller = index
resources.router.routes.shift-display.defaults.action = display
Here is what i came up with:
resources.router.routes.shift-display.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.shift-display.regex = "shift/display/(\d+)"
resources.router.routes.shift-display.defaults.module = shift
resources.router.routes.shift-display.defaults.controller = index
resources.router.routes.shift-display.defaults.action = display
resources.router.routes.shift-display.map.1 = id
resources.router.routes.shift-display.reverse = "shift/display/%d"
But it's not working. It seems the route isn't recognized by the router. When trying to open e.g. vh.localhost/shift/display/7 i get "Invalid controller specified (display)" so the router uses the default route. I also tried to prepend the regex-route with a slash. I tried to use the url-helper to generate links (with passed ID param) using the new regex-route and it works.
Anyone has a clue?
Sometimes is it just that simple. When definining the route, the mistake was made in that line:
resources.router.routes.shift-display.regex = "shift/display/(\d+)"
It has to be
resources.router.routes.shift-display.route = "shift/display/(\d+)"
4 hours for nothing. But at least I finally found it ;-)