-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Finder] adds adapter selection/unselection capabilities #7212
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
*/ | ||
public function setAdapter(Adapter\AdapterInterface $adapter, $priority = 0) | ||
{ | ||
if (!isset($this->adapters[$adapter->getName()])) { |
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.
I think we need two methods here: one to add/register a new adapter (already covered by the addAdapter()
method) and one to select the adapter to be used by default (the name can be setAdapter()
as in this PR but it should take the adapter name as its only argument).
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.
@fabpot yep, done.
public function setAdapter($name) | ||
{ | ||
if (!isset($this->adapters[$name])) { | ||
throw new \InvalidArgumentException(sprintf('There is no registered adapter with "%s" name.', $name)); |
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.
Adapter "%s" does not exist.
.
@fabpot I just applied all your good advices, there was no bad one :) |
This PR was squashed before being merged into the 2.2 branch (closes #7212). Commits ------- f40adbc [Finder] adds adapter selection/unselection capabilities Discussion ---------- [Finder] adds adapter selection/unselection capabilities As we have many issues with the native finder adapter, it would be good to: * permit selection of a particular adapter which will be choosed over the others until its unselection * permit unselection of adapters to get the finder select trhe best on (by priority) * have `PhpAdapter` selected by default This PR adds 2 methods to the `Finder`: * `setAdapter($adapter)`: selects an adapter by its name * `useBestAdapter()`: tells the finder to select best adapter by their priority | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes --------------------------------------------------------------------------- by jfsimon at 2013-02-28T14:05:25Z @fabpot I just applied all your good advices, there was no bad one :)
* | ||
* @return Finder The current Finder instance | ||
*/ | ||
public function setAdapter($name) |
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.
Do we have something like getSupportedAdapeters
?
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.
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.
"Supported" ?
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.
Adapters support is determined in searchInDirectory
.
There is no way to get them.
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.
Adapters support is determined in searchInDirectory.
true but only when canBeUsed()
returns true, right ?
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.
(I am not sure if my suggestion makes sense, just asking)
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.
Do you think it would be useful?
I can't see any use case.
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.
don't know... I have to think more about it.
What triggers the idea is setAdapter
(ie you would not want to set something that is not supported)
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.
Hmm, this is not stupid...
I'll open an RFC tomorrow, could you keep your ideas in mind and feed comments with them?
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, please also link this comment. thanks.
chat to you tomorrow.
On 02/28/2013 05:49 PM, Jean-François Simon wrote:
In src/Symfony/Component/Finder/Finder.php:
- {
$this->resetAdapterSelection();
return $this->sortAdapters();
- }
- /**
\* Selects the adapter to use.
*
\* @param string $name
*
\* @throws \InvalidArgumentException
*
\* @return Finder The current Finder instance
*/
- public function setAdapter($name)
Hmm, this is not stupid...
I'll open an RFC tomorrow, could you keep your ideas in mind and feed
comments with them?—
Reply to this email directly or view it on GitHub
https://github.com/symfony/symfony/pull/7212/files#r3191594.
I just had to disable useBestAdapter() in composer since it was causing issues on solaris (composer/composer#2168). Is there no way to check if find is the proper gnu find before enabling this adapter? |
As we have many issues with the native finder adapter, it would be good to:
PhpAdapter
selected by defaultThis PR adds 2 methods to the
Finder
:setAdapter($adapter)
: selects an adapter by its nameuseBestAdapter()
: tells the finder to select best adapter by their priority