-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.2] ResourceWatcher component (final?) #4605
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
"require": { | ||
"php": ">=5.3.3", | ||
"symfony/config": "self.version", | ||
"symfony/event-dispatcher": "self.version" |
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.
Can these versions be more specific? This component may be going into 2.2, but does it require the 2.2 version of these deps?
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.
Nice catch. Nope for event-dispatcher
, but yest for config
, as PR provides couple of commits into Config
.
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.
I think you can use 2.0 unless you use $event->getName()
, which was added in 2.1.
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.
Currently, all Symfony2 components are requiring self.version
for the other components to simplify the management of the composer.json files. As long as all components are released together, this works.
and for your suggestion, requiring >=2.1.0
is wrong anyway. It would mark it as compatible with Symfony 4.2 too, which is wrong as nobody can know what such version will be if it exists.
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.
@stof so, we should keep it as it is now (self.version
), you think?
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.
@everzet until we change the way it works for all components, yes
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.
ok :) @kriswallsmith ?
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.
👍 for moving away from self.version
but I understand these things take time
I'm very excited about this component. Thank you everyone who has worked on it. |
@everzet Can you make another PR for the Config component changes so that I can merge that part into Symfony 2.1? Thanks. |
this is a basic state checker, which checks all files and directories recursively for changes
this resources tracker uses recursive iterator state checker internally
if no tracker were specified in watcher constructor it will use best one (inotify if available and rec otherwise)
…istent with other parts of the framework.
…FilteredChilds method
…heir own method.
…ource->exists()` check
Makes sure that directory and the file resources with the same name will have different ids
file resource existence check shouldn't return true if there's directory with same name instead of file.
protected function createDirectoryChildCheckers(DirectoryResource $resource) | ||
{ | ||
$checkers = array(); | ||
foreach ($resource->getFilteredResources() as $resource) { |
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.
Isn't array_map more appropriate here ?
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.
It is, but it doesn't really matter :)
btw, merging it will require fixing the serialization of the resource in AsseticBundle. Currently, it serializes far too much things. |
#4619 should be fixed before we can merge this PR. |
ping @fabpot |
will this make 2.3? |
This code has been moved to a separate library: https://github.com/henrikbjorn/Lurker Reusing the existing resources was causing issues as the component has different needs (see the changes done here on one hand and the discussion about config resources on the other hand). Keeping the config resources with their current purpose will make things easier. I'm closing this PR in favor of Lurker. People wanting this feature can get Lurker through Composer (even in their 2.2 projects) |
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
This is final rebased version of #3961, which was a refactoring of #391
Short overview
This component is here for tracking filesystem changes. You're registering directory or file resources to track with specific track name (
tracking_id
) andstart()
watcher. Watcher checks for FS changes after specific timespan and if some change occur (file/directory create/update/delete) - watcher dispatchesEventDispatcher
event withresource_watcher.all
,resource_watcher.tracking_id
names andFilesystemEvent
as argument.Usage
Simplest possible way of FS tracking
Simplest tracking code would look like this:
best suitable
Tracker
andEventDispatcher
would be instantiated for you, implicitlytrack()
methodExtended usage looks like that:
addListener()
methodIf you don't want to deal with
EventDispatcher
,ResourceWatcher
can hide this detail for you: