Skip to content

[2.2] [WIP] [Finder] Adding native finders implementations #4061

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

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
331e3ad
[Finder] Added adapter interface.
jfsimon Apr 21, 2012
a05f449
[Finder] Added abstract adapter.
jfsimon Apr 21, 2012
d340849
[Finder] Moved current implementation to php adapter.
jfsimon Apr 21, 2012
c3cdda3
[Finder] Moved min/max depth calculation to abstract adapter.
jfsimon Apr 21, 2012
411cb8b
[Finder] Fixed depth iterator tests.
jfsimon Apr 21, 2012
c47c5de
[Finder] Moved glob/regex methods to new Expr class.
jfsimon Apr 22, 2012
432a3fe
[Finder] Added Expr class tests.
jfsimon Apr 22, 2012
524ebe9
[Finder] Added file paths iterator and its tests.
jfsimon Apr 22, 2012
f6acae0
[Finder] Added minimalist gnu find adapter.
jfsimon Apr 22, 2012
de2ae38
[Finder] Added adapter validity control.
jfsimon Apr 22, 2012
dc4bf1f
[Finder] Added adapter selection method.
jfsimon Apr 22, 2012
c23ebf9
[Finder] Updated tests to use all valid adapters.
jfsimon Apr 22, 2012
bf74c89
[Finder] Added native names/notNames support to gnu find adapter.
jfsimon Apr 22, 2012
7b593ee
[Finder] Added native sizes support to gnu find adapter.
jfsimon Apr 22, 2012
3b3ee8f
[Finder] Added native dates support to gnu find adapter.
jfsimon Apr 22, 2012
530f229
[Finder] Performed some cleanup.
jfsimon Apr 22, 2012
05897a4
[Finder] Improved command class.
jfsimon Apr 22, 2012
da79cc4
[Finder] Refactored command building.
jfsimon Apr 23, 2012
19f055e
[Finder] Updated shell command test.
jfsimon Apr 23, 2012
daa9b31
[Finder] Added adapter registration method.
jfsimon Apr 23, 2012
cba5bca
[Finder] Cleaned code.
jfsimon Apr 24, 2012
f131e27
[Finder] Added possibility for adapter to fail.
Apr 24, 2012
8a3b2de
[Finder] Added adapters registration tests.
Apr 24, 2012
eefba16
[Finder] Added grep support for gnu find adapter.
May 10, 2012
924561c
[Finder] Fixed typo & removed debug output.
jfsimon Jul 4, 2012
f924d85
[Finder] Added native sorting support to gnu find adapter.
jfsimon Jul 10, 2012
4229962
[Finder] Refactored expression (regex/glob) handling.
jfsimon Jul 31, 2012
e80e115
[Finder] Added expression tests & fixed related bugs.
jfsimon Aug 1, 2012
8b9ffc6
[Finder] Moved Shell & Command classes to Shell namespace.
jfsimon Aug 1, 2012
0e61db9
[Finder] Fixed regex escaped flag/joker bug.
jfsimon Aug 1, 2012
60e69fe
[Finder] Fixed 'regex are not search' problem.
jfsimon Aug 1, 2012
4e3b017
[Finder] Fixed master rebase.
jfsimon Aug 1, 2012
144c61b
[Finder] Fixed search directory.
jfsimon Aug 1, 2012
aa84e2d
[Finder] Fixed typos, CS and small errors.
jfsimon Aug 1, 2012
46cc2d4
[Finder] Fixed namespace.
jfsimon Aug 2, 2012
5fc01f2
[Finder] Changed method name for gnu find adapter.
jfsimon Aug 2, 2012
ef0ebb8
[Finder] Fixed gnu find regex name filtering problems.
jfsimon Aug 3, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions src/Symfony/Component/Finder/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Finder\Adapter;

/**
* Interface for finder engine implementations.
*
* @author Jean-François Simon <contact@jfsimon.fr>
*/
abstract class AbstractAdapter implements AdapterInterface
{
protected $followLinks = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

properties should be initialized in the __construct method

Copy link
Contributor

Choose a reason for hiding this comment

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

@hhamon I think no.
See the Request class for instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hum not sure but I guess it should not be hardcoded in the property.

Copy link
Contributor

Choose a reason for hiding this comment

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

These values act as default values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

no pbe here.

protected $mode = 0;
protected $minDepth = 0;
protected $maxDepth = INF;
protected $exclude = array();
protected $names = array();
protected $notNames = array();
protected $contains = array();
protected $notContains = array();
protected $sizes = array();
protected $dates = array();
protected $filters = array();
protected $sort = false;

/**
* {@inheritdoc}
*/
public function setFollowLinks($followLinks)
{
$this->followLinks = $followLinks;

return $this;
}

/**
* {@inheritdoc}
*/
public function setMode($mode)
{
$this->mode = $mode;

return $this;
}

/**
* {@inheritdoc}
*/
public function setDepths(array $depths)
{
$this->minDepth = 0;
$this->maxDepth = INF;

foreach ($depths as $comparator) {
switch ($comparator->getOperator()) {
case '>':
$this->minDepth = $comparator->getTarget() + 1;
break;
case '>=':
$this->minDepth = $comparator->getTarget();
break;
case '<':
$this->maxDepth = $comparator->getTarget() - 1;
break;
case '<=':
$this->maxDepth = $comparator->getTarget();
break;
default:
$this->minDepth = $this->maxDepth = $comparator->getTarget();
}
}

return $this;
}

/**
* {@inheritdoc}
*/
public function setExclude(array $exclude)
{
$this->exclude = $exclude;

return $this;
}

/**
* {@inheritdoc}
*/
public function setNames(array $names)
{
$this->names = $names;

return $this;
}

/**
* {@inheritdoc}
*/
public function setNotNames(array $notNames)
{
$this->notNames = $notNames;

return $this;
}

/**
* {@inheritdoc}
*/
public function setContains(array $contains)
{
$this->contains = $contains;

return $this;
}

/**
* {@inheritdoc}
*/
public function setNotContains(array $notContains)
{
$this->notContains = $notContains;

return $this;
}

/**
* {@inheritdoc}
*/
public function setSizes(array $sizes)
{
$this->sizes = $sizes;

return $this;
}

/**
* {@inheritdoc}
*/
public function setDates(array $dates)
{
$this->dates = $dates;

return $this;
}

/**
* {@inheritdoc}
*/
public function setFilters(array $filters)
{
$this->filters = $filters;

return $this;
}

/**
* {@inheritdoc}
*/
public function setSort($sort)
{
$this->sort = $sort;

return $this;
}
}
123 changes: 123 additions & 0 deletions src/Symfony/Component/Finder/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Finder\Adapter;

/**
* @author Jean-François Simon <contact@jfsimon.fr>
*/
interface AdapterInterface
{
/**
* @param bool $followLinks
*
* @return AdapterInterface Current instance
*/
function setFollowLinks($followLinks);

/**
* @param int $mode
*
* @return AdapterInterface Current instance
*/
function setMode($mode);

/**
* @param array $exclude
*
* @return AdapterInterface Current instance
*/
function setExclude(array $exclude);

/**
* @param array $depths
*
* @return AdapterInterface Current instance
*/
function setDepths(array $depths);

/**
* @param array $names
*
* @return AdapterInterface Current instance
*/
function setNames(array $names);

/**
* @param array $notNames
*
* @return AdapterInterface Current instance
*/
function setNotNames(array $notNames);

/**
* @param array $contains
*
* @return AdapterInterface Current instance
*/
function setContains(array $contains);

/**
* @param array $notContains
*
* @return AdapterInterface Current instance
*/
function setNotContains(array $notContains);

/**
* @param array $sizes
*
* @return AdapterInterface Current instance
*/
function setSizes(array $sizes);

/**
* @param array $dates
*
* @return AdapterInterface Current instance
*/
function setDates(array $dates);

/**
* @param array $filters
*
* @return AdapterInterface Current instance
*/
function setFilters(array $filters);

/**
* @param \Closure|int $sort
*
* @return AdapterInterface Current instance
*/
function setSort($sort);

/**
* @param string $dir
*
* @return \Iterator Result iterator
*/
function searchInDirectory($dir);

/**
* Tests adapter support for current platform.
*
* @return bool
*/
function isSupported();

/**
* Returns adapter name.
*
* @return string
*/
function getName();
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy