-
Notifications
You must be signed in to change notification settings - Fork 497
Adds bot-parsers as injectionable objects #5712
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
Conversation
Handles the botparser equivalent to the client/device parsers. This way users of the library can add their own botparser that might not be usefull for the library, but are needed in their own situation. As there does not seem to be any usecase for adding multple bot-parsers in this project, there is no separte directory with bot-parsers, nor can we add a botparser by string.
I wasn't sure if it was better to start a discussion (issue?) first before just doing a pull-request for this, but as the amount of code is small and most is based upon code that's in different equivalent functions, this seemed to be the best way :) |
$botParser->setYamlParser($this->getYamlParser()); | ||
$botParser->setCache($this->getCache()); | ||
if ($this->discardBotInformation) { | ||
$botParser->discardDetails(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the special discardDetails
for the bot parser. This is quite important, as it speeds up the detection for bots a lot if no detailed bot information is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ow, that's really bad, sorry for that! I'll write a fix for that tomorrow, tried to make it too much te same as the other 2 functions, and then I stopped paying attention.
Are you open for the concept of this MR though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, why not allowing multiple / custom bot parsers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test that picks up this bug (again, that was careless, sorry), and added a fix. Needed to add an abstract class to define the discardDetails()
method for the bots.
Re-adds the discardDetails() that accidently got removed in the refactor. To be able to do this on all added bots, an abstract is created. It could have been an interface, but all other (client, device) do this with an abstract, so that pattern is followed Adds a test that catches the problem in previous commit, and passes now
Have you had time to look at the update? Is there anything else I could/should update? |
will have a closer look on Monday |
Handles the botparser equivalent to the client/device parsers. This way
users of the library can add their own botparser that might not be
usefull for the library, but are needed in their own situation. (for instance:
add a botparser that can recognize internal bots with specific user-agents,
that would never be encountered in the wild and therefore not very usefull
in the library)
Notes:
parseBot()
function uses the same logic as theparsClient()
andparseDevice()
functions.addBotParser()
function is simpeler as there is only a single botparser in the library: we don't need the string version and/or a separate directory with multiple botparsers