Skip to content
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

MINOR: better anchors #32

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

sunnysideup
Copy link
Contributor

No description provided.

Copy link
Collaborator

@Firesphere Firesphere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also explain what this PR tries to resolve.

@@ -17,9 +17,16 @@
"require": {
"silverstripe/framework": "^4 || ^5",
"unclecheese/display-logic": "^2 || ^3",
"giggsey/libphonenumber-for-php": "^8.0"
"giggsey/libphonenumber-for-php": "^8.0",
"sheadawson/silverstripe-dependentdropdownfield": "dev-master"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A library shouldn't rely on a dev-master requirement

"repositories": [
{
"type": "vcs",
"url": "https://github.com/anhld/silverstripe-dependentdropdownfield"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't propagate through to the root composer install.

$owner->Title = $element->Title;
}
$owner->Querystring = $owner->Querystring ? str_replace('?', '', (string) $owner->QueryString) : $owner->Querystring;
$owner->Anchor = $owner->Anchor ? str_replace('#', '', (string) $owner->Anchor) : $owner->Anchor;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks overly complicated.
A simple $owner->Querystring = ltrim((string)$owner->Querystring, '?'); would suffice.


// add QueryString
if(!empty($this->QueryString)) {
if(strpos($LinkURL, '?') === false && strpos($this->QueryString, '?') === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strpos should be str_contains

The check on the QueryString seems pointless, as this is stripped out already earlier.


// add anchor
if(!empty($this->Anchor)) {
if(strpos($LinkURL, '#') === false && strpos($this->Anchor, '#') === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

$sitetree_field_label = $config->get('sitetree_field_label') ?: 'MenuTitle';

// Get source data for the ElementID field
$anchorOptions = function ($pageID) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, semantics and debug-ability, this should be an actual method, instead of an anonymous function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants