8000 [Component][Finder] path(), notPath() methods · symfony/symfony-docs@f8edb9f · GitHub
[go: up one dir, main page]

Skip to content

Commit f8edb9f

Browse files
committed
[Component][Finder] path(), notPath() methods
1 parent 07fcced commit f8edb9f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

components/finder.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,34 @@ The ``notContains()`` method excludes files containing given pattern::
175175

176176
$finder->files()->notContains('dolor sit amet');
177177

178+
Path
179+
~~~~
180+
181+
.. versionadded:: 2.2
182+
Methods ``path()`` and ``notPath()`` have been
183+
introduced in version 2.2.
184+
185+
Restrict files and directories by path with the
186+
:method:`Symfony\\Component\\Finder\\Finder::path` method::
187+
188+
$finder->path('some/special/dir');
189+
190+
On all platforms slash (i.e. ``/``) should be used as a separator.
191+
192+
The ``path()`` method accepts strings or regexes::
193+
194+
$finder->path('foo/bar');
195+
$finder->path('/^foo\/bar/');
196+
197+
Strings are converted into regexes by escaping slashes and adding delimiters:
198+
199+
dirname ===> /dirname/
200+
a/b/c ===> /a\/b\/c/
201+
202+
The ``notPath()`` method excludes files by path::
203+
204+
$finder->notPath('other/dir');
205+
178206
File Size
179207
~~~~~~~~~
180208

0 commit comments

Comments
 (0)
0