-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
detect dev for install command #1413
Conversation
src/Entity/Package.php
Outdated
$command = 'require'; | ||
|
||
/** @var Version $version */ | ||
$version = $this->getVersions()->first(); |
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.
not sure which version to use ...
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.
The view_package
template already receive a version
variable (which can be null
). this is the version that should be used for the install command IMO (which would be done by keeping the command in the template as it is done right now, but adding a {% if version and version.hasDevTag %} --dev{% endif %}
)
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.
yea, i know that moving it from the template to PHP feels like the more complex solution at first, but i tend to kill every if in twig that i can replace with sth that is easily unit tested.
but sure, that's a debatable design decision
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.
Twig already has the right version to use passed to it by the controller. The Package entity does not have it. So moving this to the entity itself looks like the bad decision IMO.
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.
wasn't aware of that controller code to sort out the most relevant version - thanks for that pointer!
will give it another thought later 👍
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.
IMO this function should just accept a version as argument, and then the template can pass it in.
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.
easy solution, true - done
23a56fb
to
943a092
Compare
src/Entity/Version.php
Outdated
@@ -635,6 +635,13 @@ public function getTags(): Collection | |||
return $this->tags; | |||
} | |||
|
|||
public function hasDevTag(): bool | |||
{ | |||
return [] !== array_filter($this->getTags()->toArray(), static function (Tag $tag) { |
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.
looping over the tags and stopping when we find a dev tag would be more efficient than filtering the whole list all the time.
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.
true
src/Entity/Package.php
Outdated
$command = 'require'; | ||
|
||
/** @var Version $version */ | ||
$version = $this->getVersions()->first(); |
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.
The view_package
template already receive a version
variable (which can be null
). this is the version that should be used for the install command IMO (which would be done by keeping the command in the template as it is done right now, but adding a {% if version and version.hasDevTag %} --dev{% endif %}
)
943a092
to
4a6ad77
Compare
cd4cbab
to
020a71d
Compare
Thanks! |
@@ -46,7 +46,7 @@ | |||
|
|||
<div class="row"> | |||
<div class="col-md-8"> | |||
<p class="requireme"><i class="glyphicon glyphicon-save"></i> <input type="text" readonly="readonly" value="composer {% if package.type == 'project' %}create-project{% else %}require{% endif %} {{ "#{package.vendor}/#{package.packageName}" }}" /></p> | |||
<p class="requireme"><i class="glyphicon glyphicon-save"></i> <input type="text" readonly="readonly" value="{{ package.installCommand(expandedVersion) }}" /></p> |
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.
shouldn't this use version
instead of expandedVersion
to be consistent with the sidebar showing the support
action.
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.
Yes true it should be version, I'll fix that.
Fixes #1412