Essai au propre
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
<?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\Config\Definition;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ReferenceDumper class is deprecated since Symfony 2.4 and will be removed in 3.0. Use the Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
* Use {@link \Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper} instead.
|
||||
*/
|
||||
class ReferenceDumper extends YamlReferenceDumper
|
||||
{
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?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\Config\Resource;
|
||||
|
||||
/**
|
||||
* Resource checker for the ResourceInterface. Exists for BC.
|
||||
*
|
||||
* @author Matthias Pigulla <mp@webfactory.de>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class BCResourceInterfaceChecker extends SelfCheckingResourceChecker
|
||||
{
|
||||
public function supports(ResourceInterface $metadata)
|
||||
{
|
||||
/* As all resources must be instanceof ResourceInterface,
|
||||
we support them all. */
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isFresh(ResourceInterface $resource, $timestamp)
|
||||
{
|
||||
@trigger_error(sprintf('The class "%s" is performing resource checking through ResourceInterface::isFresh(), which is deprecated since Symfony 2.8 and will be removed in 3.0', \get_class($resource)), E_USER_DEPRECATED);
|
||||
|
||||
return parent::isFresh($resource, $timestamp); // For now, $metadata features the isFresh() method, so off we go (quack quack)
|
||||
}
|
||||
}
|
||||
502
vendor/symfony/console/Helper/DialogHelper.php
vendored
502
vendor/symfony/console/Helper/DialogHelper.php
vendored
@@ -1,502 +0,0 @@
|
||||
<?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\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* The Dialog class provides helpers to interact with the user.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0.
|
||||
* Use {@link \Symfony\Component\Console\Helper\QuestionHelper} instead.
|
||||
*/
|
||||
class DialogHelper extends InputAwareHelper
|
||||
{
|
||||
private $inputStream;
|
||||
private static $shell;
|
||||
private static $stty;
|
||||
|
||||
public function __construct($triggerDeprecationError = true)
|
||||
{
|
||||
if ($triggerDeprecationError) {
|
||||
@trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since Symfony 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the user to select a value.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param string|array $question The question to ask
|
||||
* @param array $choices List of choices to pick from
|
||||
* @param bool|string $default The default answer if the user enters nothing
|
||||
* @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite)
|
||||
* @param string $errorMessage Message which will be shown if invalid value from choice list would be picked
|
||||
* @param bool $multiselect Select more than one value separated by comma
|
||||
*
|
||||
* @return int|string|array The selected value or values (the key of the choices array)
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
$width = max(array_map('strlen', array_keys($choices)));
|
||||
|
||||
$messages = (array) $question;
|
||||
foreach ($choices as $key => $value) {
|
||||
$messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
|
||||
}
|
||||
|
||||
$output->writeln($messages);
|
||||
|
||||
$result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
|
||||
// Collapse all spaces.
|
||||
$selectedChoices = str_replace(' ', '', $picked);
|
||||
|
||||
if ($multiselect) {
|
||||
// Check for a separated comma values
|
||||
if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
|
||||
throw new InvalidArgumentException(sprintf($errorMessage, $picked));
|
||||
}
|
||||
$selectedChoices = explode(',', $selectedChoices);
|
||||
} else {
|
||||
$selectedChoices = array($picked);
|
||||
}
|
||||
|
||||
$multiselectChoices = array();
|
||||
|
||||
foreach ($selectedChoices as $value) {
|
||||
if (empty($choices[$value])) {
|
||||
throw new InvalidArgumentException(sprintf($errorMessage, $value));
|
||||
}
|
||||
$multiselectChoices[] = $value;
|
||||
}
|
||||
|
||||
if ($multiselect) {
|
||||
return $multiselectChoices;
|
||||
}
|
||||
|
||||
return $picked;
|
||||
}, $attempts, $default);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks a question to the user.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param string|array $question The question to ask
|
||||
* @param string $default The default answer if none is given by the user
|
||||
* @param array $autocomplete List of values to autocomplete
|
||||
*
|
||||
* @return string The user answer
|
||||
*
|
||||
* @throws RuntimeException If there is no data to read in the input stream
|
||||
*/
|
||||
public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
|
||||
{
|
||||
if ($this->input && !$this->input->isInteractive()) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
$output->write($question);
|
||||
|
||||
$inputStream = $this->inputStream ?: STDIN;
|
||||
|
||||
if (null === $autocomplete || !$this->hasSttyAvailable()) {
|
||||
$ret = fgets($inputStream, 4096);
|
||||
if (false === $ret) {
|
||||
throw new RuntimeException('Aborted');
|
||||
}
|
||||
$ret = trim($ret);
|
||||
} else {
|
||||
$ret = '';
|
||||
|
||||
$i = 0;
|
||||
$ofs = -1;
|
||||
$matches = $autocomplete;
|
||||
$numMatches = \count($matches);
|
||||
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
|
||||
// Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
|
||||
shell_exec('stty -icanon -echo');
|
||||
|
||||
// Add highlighted text style
|
||||
$output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
|
||||
|
||||
// Read a keypress
|
||||
while (!feof($inputStream)) {
|
||||
$c = fread($inputStream, 1);
|
||||
|
||||
// Backspace Character
|
||||
if ("\177" === $c) {
|
||||
if (0 === $numMatches && 0 !== $i) {
|
||||
--$i;
|
||||
// Move cursor backwards
|
||||
$output->write("\033[1D");
|
||||
}
|
||||
|
||||
if (0 === $i) {
|
||||
$ofs = -1;
|
||||
$matches = $autocomplete;
|
||||
$numMatches = \count($matches);
|
||||
} else {
|
||||
$numMatches = 0;
|
||||
}
|
||||
|
||||
// Pop the last character off the end of our string
|
||||
$ret = substr($ret, 0, $i);
|
||||
} elseif ("\033" === $c) {
|
||||
// Did we read an escape sequence?
|
||||
$c .= fread($inputStream, 2);
|
||||
|
||||
// A = Up Arrow. B = Down Arrow
|
||||
if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
|
||||
if ('A' === $c[2] && -1 === $ofs) {
|
||||
$ofs = 0;
|
||||
}
|
||||
|
||||
if (0 === $numMatches) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ofs += ('A' === $c[2]) ? -1 : 1;
|
||||
$ofs = ($numMatches + $ofs) % $numMatches;
|
||||
}
|
||||
} elseif (\ord($c) < 32) {
|
||||
if ("\t" === $c || "\n" === $c) {
|
||||
if ($numMatches > 0 && -1 !== $ofs) {
|
||||
$ret = $matches[$ofs];
|
||||
// Echo out remaining chars for current match
|
||||
$output->write(substr($ret, $i));
|
||||
$i = \strlen($ret);
|
||||
}
|
||||
|
||||
if ("\n" === $c) {
|
||||
$output->write($c);
|
||||
break;
|
||||
}
|
||||
|
||||
$numMatches = 0;
|
||||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
$output->write($c);
|
||||
$ret .= $c;
|
||||
++$i;
|
||||
|
||||
$numMatches = 0;
|
||||
$ofs = 0;
|
||||
|
||||
foreach ($autocomplete as $value) {
|
||||
// If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
|
||||
if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
|
||||
$matches[$numMatches++] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Erase characters from cursor to end of line
|
||||
$output->write("\033[K");
|
||||
|
||||
if ($numMatches > 0 && -1 !== $ofs) {
|
||||
// Save cursor position
|
||||
$output->write("\0337");
|
||||
// Write highlighted text
|
||||
$output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
|
||||
// Restore cursor position
|
||||
$output->write("\0338");
|
||||
}
|
||||
}
|
||||
|
||||
// Reset stty so it behaves normally again
|
||||
shell_exec(sprintf('stty %s', $sttyMode));
|
||||
}
|
||||
|
||||
return \strlen($ret) > 0 ? $ret : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks a confirmation to the user.
|
||||
*
|
||||
* The question will be asked until the user answers by nothing, yes, or no.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param string|array $question The question to ask
|
||||
* @param bool $default The default answer if the user enters nothing
|
||||
*
|
||||
* @return bool true if the user has confirmed, false otherwise
|
||||
*/
|
||||
public function askConfirmation(OutputInterface $output, $question, $default = true)
|
||||
{
|
||||
$answer = 'z';
|
||||
while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
|
||||
$answer = $this->ask($output, $question);
|
||||
}
|
||||
|
||||
if (false === $default) {
|
||||
return $answer && 'y' == strtolower($answer[0]);
|
||||
}
|
||||
|
||||
return !$answer || 'y' == strtolower($answer[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks a question to the user, the response is hidden.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param string|array $question The question
|
||||
* @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not
|
||||
*
|
||||
* @return string The answer
|
||||
*
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response can not be hidden
|
||||
*/
|
||||
public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
||||
|
||||
// handle code running from a phar
|
||||
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||
$tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
|
||||
copy($exe, $tmpExe);
|
||||
$exe = $tmpExe;
|
||||
}
|
||||
|
||||
$output->write($question);
|
||||
$value = rtrim(shell_exec($exe));
|
||||
$output->writeln('');
|
||||
|
||||
if (isset($tmpExe)) {
|
||||
unlink($tmpExe);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($this->hasSttyAvailable()) {
|
||||
$output->write($question);
|
||||
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
|
||||
shell_exec('stty -echo');
|
||||
$value = fgets($this->inputStream ?: STDIN, 4096);
|
||||
shell_exec(sprintf('stty %s', $sttyMode));
|
||||
|
||||
if (false === $value) {
|
||||
throw new RuntimeException('Aborted');
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
$output->writeln('');
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (false !== $shell = $this->getShell()) {
|
||||
$output->write($question);
|
||||
$readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
|
||||
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
||||
$value = rtrim(shell_exec($command));
|
||||
$output->writeln('');
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($fallback) {
|
||||
return $this->ask($output, $question);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Unable to hide the response');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks for a value and validates the response.
|
||||
*
|
||||
* The validator receives the data to validate. It must return the
|
||||
* validated data when the data is valid and throw an exception
|
||||
* otherwise.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param string|array $question The question to ask
|
||||
* @param callable $validator A PHP callback
|
||||
* @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite)
|
||||
* @param string $default The default answer if none is given by the user
|
||||
* @param array $autocomplete List of values to autocomplete
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception When any of the validators return an error
|
||||
*/
|
||||
public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
|
||||
{
|
||||
$that = $this;
|
||||
|
||||
$interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
|
||||
return $that->ask($output, $question, $default, $autocomplete);
|
||||
};
|
||||
|
||||
return $this->validateAttempts($interviewer, $output, $validator, $attempts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks for a value, hide and validates the response.
|
||||
*
|
||||
* The validator receives the data to validate. It must return the
|
||||
* validated data when the data is valid and throw an exception
|
||||
* otherwise.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param string|array $question The question to ask
|
||||
* @param callable $validator A PHP callback
|
||||
* @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite)
|
||||
* @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not
|
||||
*
|
||||
* @return string The response
|
||||
*
|
||||
* @throws \Exception When any of the validators return an error
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response can not be hidden
|
||||
*/
|
||||
public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
|
||||
{
|
||||
$that = $this;
|
||||
|
||||
$interviewer = function () use ($output, $question, $fallback, $that) {
|
||||
return $that->askHiddenResponse($output, $question, $fallback);
|
||||
};
|
||||
|
||||
return $this->validateAttempts($interviewer, $output, $validator, $attempts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input stream to read from when interacting with the user.
|
||||
*
|
||||
* This is mainly useful for testing purpose.
|
||||
*
|
||||
* @param resource $stream The input stream
|
||||
*/
|
||||
public function setInputStream($stream)
|
||||
{
|
||||
$this->inputStream = $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the helper's input stream.
|
||||
*
|
||||
* @return resource|null The input stream or null if the default STDIN is used
|
||||
*/
|
||||
public function getInputStream()
|
||||
{
|
||||
return $this->inputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'dialog';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a valid Unix shell.
|
||||
*
|
||||
* @return string|bool The valid shell name, false in case no valid shell is found
|
||||
*/
|
||||
private function getShell()
|
||||
{
|
||||
if (null !== self::$shell) {
|
||||
return self::$shell;
|
||||
}
|
||||
|
||||
self::$shell = false;
|
||||
|
||||
if (file_exists('/usr/bin/env')) {
|
||||
// handle other OSs with bash/zsh/ksh/csh if available to hide the answer
|
||||
$test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
|
||||
foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
|
||||
if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
|
||||
self::$shell = $sh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$shell;
|
||||
}
|
||||
|
||||
private function hasSttyAvailable()
|
||||
{
|
||||
if (null !== self::$stty) {
|
||||
return self::$stty;
|
||||
}
|
||||
|
||||
exec('stty 2>&1', $output, $exitcode);
|
||||
|
||||
return self::$stty = 0 === $exitcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an attempt.
|
||||
*
|
||||
* @param callable $interviewer A callable that will ask for a question and return the result
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param callable $validator A PHP callback
|
||||
* @param int|false $attempts Max number of times to ask before giving up; false will ask infinitely
|
||||
*
|
||||
* @return string The validated response
|
||||
*
|
||||
* @throws \Exception In case the max number of attempts has been reached and no valid response has been given
|
||||
*/
|
||||
private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
$e = null;
|
||||
while (false === $attempts || $attempts--) {
|
||||
if (null !== $e) {
|
||||
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
|
||||
}
|
||||
|
||||
try {
|
||||
return \call_user_func($validator, $interviewer());
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
469
vendor/symfony/console/Helper/ProgressHelper.php
vendored
469
vendor/symfony/console/Helper/ProgressHelper.php
vendored
@@ -1,469 +0,0 @@
|
||||
<?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\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* The Progress class provides helpers to display progress output.
|
||||
*
|
||||
* @author Chris Jones <leeked@gmail.com>
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0
|
||||
* Use {@link ProgressBar} instead.
|
||||
*/
|
||||
class ProgressHelper extends Helper
|
||||
{
|
||||
const FORMAT_QUIET = ' %percent%%';
|
||||
const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
|
||||
const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
|
||||
const FORMAT_QUIET_NOMAX = ' %current%';
|
||||
const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
|
||||
const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
|
||||
|
||||
// options
|
||||
private $barWidth = 28;
|
||||
private $barChar = '=';
|
||||
private $emptyBarChar = '-';
|
||||
private $progressChar = '>';
|
||||
private $format = null;
|
||||
private $redrawFreq = 1;
|
||||
|
||||
private $lastMessagesLength;
|
||||
private $barCharOriginal;
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* Current step.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $current;
|
||||
|
||||
/**
|
||||
* Maximum number of steps.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $max;
|
||||
|
||||
/**
|
||||
* Start time of the progress bar.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $startTime;
|
||||
|
||||
/**
|
||||
* List of formatting variables.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $defaultFormatVars = array(
|
||||
'current',
|
||||
'max',
|
||||
'bar',
|
||||
'percent',
|
||||
'elapsed',
|
||||
);
|
||||
|
||||
/**
|
||||
* Available formatting variables.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $formatVars;
|
||||
|
||||
/**
|
||||
* Stored format part widths (used for padding).
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $widths = array(
|
||||
'current' => 4,
|
||||
'max' => 4,
|
||||
'percent' => 3,
|
||||
'elapsed' => 6,
|
||||
);
|
||||
|
||||
/**
|
||||
* Various time formats.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $timeFormats = array(
|
||||
array(0, '???'),
|
||||
array(2, '1 sec'),
|
||||
array(59, 'secs', 1),
|
||||
array(60, '1 min'),
|
||||
array(3600, 'mins', 60),
|
||||
array(5400, '1 hr'),
|
||||
array(86400, 'hrs', 3600),
|
||||
array(129600, '1 day'),
|
||||
array(604800, 'days', 86400),
|
||||
);
|
||||
|
||||
public function __construct($triggerDeprecationError = true)
|
||||
{
|
||||
if ($triggerDeprecationError) {
|
||||
@trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\Console\Helper\ProgressBar class instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar width.
|
||||
*
|
||||
* @param int $size The progress bar size
|
||||
*/
|
||||
public function setBarWidth($size)
|
||||
{
|
||||
$this->barWidth = (int) $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bar character.
|
||||
*
|
||||
* @param string $char A character
|
||||
*/
|
||||
public function setBarCharacter($char)
|
||||
{
|
||||
$this->barChar = $char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the empty bar character.
|
||||
*
|
||||
* @param string $char A character
|
||||
*/
|
||||
public function setEmptyBarCharacter($char)
|
||||
{
|
||||
$this->emptyBarChar = $char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar character.
|
||||
*
|
||||
* @param string $char A character
|
||||
*/
|
||||
public function setProgressCharacter($char)
|
||||
{
|
||||
$this->progressChar = $char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar format.
|
||||
*
|
||||
* @param string $format The format
|
||||
*/
|
||||
public function setFormat($format)
|
||||
{
|
||||
$this->format = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the redraw frequency.
|
||||
*
|
||||
* @param int $freq The frequency in steps
|
||||
*/
|
||||
public function setRedrawFrequency($freq)
|
||||
{
|
||||
$this->redrawFreq = (int) $freq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the progress output.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param int|null $max Maximum steps
|
||||
*/
|
||||
public function start(OutputInterface $output, $max = null)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
$this->startTime = time();
|
||||
$this->current = 0;
|
||||
$this->max = (int) $max;
|
||||
|
||||
// Disabling output when it does not support ANSI codes as it would result in a broken display anyway.
|
||||
$this->output = $output->isDecorated() ? $output : new NullOutput();
|
||||
$this->lastMessagesLength = 0;
|
||||
$this->barCharOriginal = '';
|
||||
|
||||
if (null === $this->format) {
|
||||
switch ($output->getVerbosity()) {
|
||||
case OutputInterface::VERBOSITY_QUIET:
|
||||
$this->format = self::FORMAT_QUIET_NOMAX;
|
||||
if ($this->max > 0) {
|
||||
$this->format = self::FORMAT_QUIET;
|
||||
}
|
||||
break;
|
||||
case OutputInterface::VERBOSITY_VERBOSE:
|
||||
case OutputInterface::VERBOSITY_VERY_VERBOSE:
|
||||
case OutputInterface::VERBOSITY_DEBUG:
|
||||
$this->format = self::FORMAT_VERBOSE_NOMAX;
|
||||
if ($this->max > 0) {
|
||||
$this->format = self::FORMAT_VERBOSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->format = self::FORMAT_NORMAL_NOMAX;
|
||||
if ($this->max > 0) {
|
||||
$this->format = self::FORMAT_NORMAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Advances the progress output X steps.
|
||||
*
|
||||
* @param int $step Number of steps to advance
|
||||
* @param bool $redraw Whether to redraw or not
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function advance($step = 1, $redraw = false)
|
||||
{
|
||||
$this->setCurrent($this->current + $step, $redraw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current progress.
|
||||
*
|
||||
* @param int $current The current progress
|
||||
* @param bool $redraw Whether to redraw or not
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function setCurrent($current, $redraw = false)
|
||||
{
|
||||
if (null === $this->startTime) {
|
||||
throw new LogicException('You must start the progress bar before calling setCurrent().');
|
||||
}
|
||||
|
||||
$current = (int) $current;
|
||||
|
||||
if ($current < $this->current) {
|
||||
throw new LogicException('You can\'t regress the progress bar');
|
||||
}
|
||||
|
||||
if (0 === $this->current) {
|
||||
$redraw = true;
|
||||
}
|
||||
|
||||
$prevPeriod = (int) ($this->current / $this->redrawFreq);
|
||||
|
||||
$this->current = $current;
|
||||
|
||||
$currPeriod = (int) ($this->current / $this->redrawFreq);
|
||||
if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the current progress string.
|
||||
*
|
||||
* @param bool $finish Forces the end result
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function display($finish = false)
|
||||
{
|
||||
if (null === $this->startTime) {
|
||||
throw new LogicException('You must start the progress bar before calling display().');
|
||||
}
|
||||
|
||||
$message = $this->format;
|
||||
foreach ($this->generate($finish) as $name => $value) {
|
||||
$message = str_replace("%{$name}%", $value, $message);
|
||||
}
|
||||
$this->overwrite($this->output, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the progress bar from the current line.
|
||||
*
|
||||
* This is useful if you wish to write some output
|
||||
* while a progress bar is running.
|
||||
* Call display() to show the progress bar again.
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->overwrite($this->output, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes the progress output.
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
if (null === $this->startTime) {
|
||||
throw new LogicException('You must start the progress bar before calling finish().');
|
||||
}
|
||||
|
||||
if (null !== $this->startTime) {
|
||||
if (!$this->max) {
|
||||
$this->barChar = $this->barCharOriginal;
|
||||
$this->display(true);
|
||||
}
|
||||
$this->startTime = null;
|
||||
$this->output->writeln('');
|
||||
$this->output = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the progress helper.
|
||||
*/
|
||||
private function initialize()
|
||||
{
|
||||
$this->formatVars = array();
|
||||
foreach ($this->defaultFormatVars as $var) {
|
||||
if (false !== strpos($this->format, "%{$var}%")) {
|
||||
$this->formatVars[$var] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->max > 0) {
|
||||
$this->widths['max'] = $this->strlen($this->max);
|
||||
$this->widths['current'] = $this->widths['max'];
|
||||
} else {
|
||||
$this->barCharOriginal = $this->barChar;
|
||||
$this->barChar = $this->emptyBarChar;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the array map of format variables to values.
|
||||
*
|
||||
* @param bool $finish Forces the end result
|
||||
*
|
||||
* @return array Array of format vars and values
|
||||
*/
|
||||
private function generate($finish = false)
|
||||
{
|
||||
$vars = array();
|
||||
$percent = 0;
|
||||
if ($this->max > 0) {
|
||||
$percent = (float) $this->current / $this->max;
|
||||
}
|
||||
|
||||
if (isset($this->formatVars['bar'])) {
|
||||
if ($this->max > 0) {
|
||||
$completeBars = floor($percent * $this->barWidth);
|
||||
} else {
|
||||
if (!$finish) {
|
||||
$completeBars = floor($this->current % $this->barWidth);
|
||||
} else {
|
||||
$completeBars = $this->barWidth;
|
||||
}
|
||||
}
|
||||
|
||||
$emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
|
||||
$bar = str_repeat($this->barChar, $completeBars);
|
||||
if ($completeBars < $this->barWidth) {
|
||||
$bar .= $this->progressChar;
|
||||
$bar .= str_repeat($this->emptyBarChar, $emptyBars);
|
||||
}
|
||||
|
||||
$vars['bar'] = $bar;
|
||||
}
|
||||
|
||||
if (isset($this->formatVars['elapsed'])) {
|
||||
$elapsed = time() - $this->startTime;
|
||||
$vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
if (isset($this->formatVars['current'])) {
|
||||
$vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
if (isset($this->formatVars['max'])) {
|
||||
$vars['max'] = $this->max;
|
||||
}
|
||||
|
||||
if (isset($this->formatVars['percent'])) {
|
||||
$vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts seconds into human-readable format.
|
||||
*
|
||||
* @param int $secs Number of seconds
|
||||
*
|
||||
* @return string Time in readable format
|
||||
*/
|
||||
private function humaneTime($secs)
|
||||
{
|
||||
$text = '';
|
||||
foreach ($this->timeFormats as $format) {
|
||||
if ($secs < $format[0]) {
|
||||
if (2 == \count($format)) {
|
||||
$text = $format[1];
|
||||
break;
|
||||
} else {
|
||||
$text = ceil($secs / $format[2]).' '.$format[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites a previous message to the output.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param string $message The message
|
||||
*/
|
||||
private function overwrite(OutputInterface $output, $message)
|
||||
{
|
||||
$length = $this->strlen($message);
|
||||
|
||||
// append whitespace to match the last line's length
|
||||
if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
|
||||
$message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
|
||||
}
|
||||
|
||||
// carriage return
|
||||
$output->write("\x0D");
|
||||
$output->write($message);
|
||||
|
||||
$this->lastMessagesLength = $this->strlen($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'progress';
|
||||
}
|
||||
}
|
||||
264
vendor/symfony/console/Helper/TableHelper.php
vendored
264
vendor/symfony/console/Helper/TableHelper.php
vendored
@@ -1,264 +0,0 @@
|
||||
<?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\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Provides helpers to display table output.
|
||||
*
|
||||
* @author Саша Стаменковић <umpirsky@gmail.com>
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0
|
||||
* Use {@link Table} instead.
|
||||
*/
|
||||
class TableHelper extends Helper
|
||||
{
|
||||
const LAYOUT_DEFAULT = 0;
|
||||
const LAYOUT_BORDERLESS = 1;
|
||||
const LAYOUT_COMPACT = 2;
|
||||
|
||||
private $table;
|
||||
|
||||
public function __construct($triggerDeprecationError = true)
|
||||
{
|
||||
if ($triggerDeprecationError) {
|
||||
@trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\Console\Helper\Table class instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->table = new Table(new NullOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets table layout type.
|
||||
*
|
||||
* @param int $layout self::LAYOUT_*
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException when the table layout is not known
|
||||
*/
|
||||
public function setLayout($layout)
|
||||
{
|
||||
switch ($layout) {
|
||||
case self::LAYOUT_BORDERLESS:
|
||||
$this->table->setStyle('borderless');
|
||||
break;
|
||||
|
||||
case self::LAYOUT_COMPACT:
|
||||
$this->table->setStyle('compact');
|
||||
break;
|
||||
|
||||
case self::LAYOUT_DEFAULT:
|
||||
$this->table->setStyle('default');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHeaders(array $headers)
|
||||
{
|
||||
$this->table->setHeaders($headers);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRows(array $rows)
|
||||
{
|
||||
$this->table->setRows($rows);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addRows(array $rows)
|
||||
{
|
||||
$this->table->addRows($rows);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addRow(array $row)
|
||||
{
|
||||
$this->table->addRow($row);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRow($column, array $row)
|
||||
{
|
||||
$this->table->setRow($column, $row);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets padding character, used for cell padding.
|
||||
*
|
||||
* @param string $paddingChar
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPaddingChar($paddingChar)
|
||||
{
|
||||
$this->table->getStyle()->setPaddingChar($paddingChar);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets horizontal border character.
|
||||
*
|
||||
* @param string $horizontalBorderChar
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHorizontalBorderChar($horizontalBorderChar)
|
||||
{
|
||||
$this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets vertical border character.
|
||||
*
|
||||
* @param string $verticalBorderChar
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVerticalBorderChar($verticalBorderChar)
|
||||
{
|
||||
$this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets crossing character.
|
||||
*
|
||||
* @param string $crossingChar
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCrossingChar($crossingChar)
|
||||
{
|
||||
$this->table->getStyle()->setCrossingChar($crossingChar);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets header cell format.
|
||||
*
|
||||
* @param string $cellHeaderFormat
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellHeaderFormat($cellHeaderFormat)
|
||||
{
|
||||
$this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets row cell format.
|
||||
*
|
||||
* @param string $cellRowFormat
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellRowFormat($cellRowFormat)
|
||||
{
|
||||
$this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets row cell content format.
|
||||
*
|
||||
* @param string $cellRowContentFormat
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellRowContentFormat($cellRowContentFormat)
|
||||
{
|
||||
$this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets table border format.
|
||||
*
|
||||
* @param string $borderFormat
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBorderFormat($borderFormat)
|
||||
{
|
||||
$this->table->getStyle()->setBorderFormat($borderFormat);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets cell padding type.
|
||||
*
|
||||
* @param int $padType STR_PAD_*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPadType($padType)
|
||||
{
|
||||
$this->table->getStyle()->setPadType($padType);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders table to output.
|
||||
*
|
||||
* Example:
|
||||
* +---------------+-----------------------+------------------+
|
||||
* | ISBN | Title | Author |
|
||||
* +---------------+-----------------------+------------------+
|
||||
* | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
|
||||
* | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
|
||||
* | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
|
||||
* +---------------+-----------------------+------------------+
|
||||
*/
|
||||
public function render(OutputInterface $output)
|
||||
{
|
||||
$p = new \ReflectionProperty($this->table, 'output');
|
||||
$p->setAccessible(true);
|
||||
$p->setValue($this->table, $output);
|
||||
|
||||
$this->table->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'table';
|
||||
}
|
||||
}
|
||||
229
vendor/symfony/console/Shell.php
vendored
229
vendor/symfony/console/Shell.php
vendored
@@ -1,229 +0,0 @@
|
||||
<?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\Console;
|
||||
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Symfony\Component\Process\ProcessBuilder;
|
||||
|
||||
/**
|
||||
* A Shell wraps an Application to add shell capabilities to it.
|
||||
*
|
||||
* Support for history and completion only works with a PHP compiled
|
||||
* with readline support (either --with-readline or --with-libedit)
|
||||
*
|
||||
* @deprecated since version 2.8, to be removed in 3.0.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Martin Hasoň <martin.hason@gmail.com>
|
||||
*/
|
||||
class Shell
|
||||
{
|
||||
private $application;
|
||||
private $history;
|
||||
private $output;
|
||||
private $hasReadline;
|
||||
private $processIsolation = false;
|
||||
|
||||
/**
|
||||
* If there is no readline support for the current PHP executable
|
||||
* a \RuntimeException exception is thrown.
|
||||
*/
|
||||
public function __construct(Application $application)
|
||||
{
|
||||
@trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
$this->hasReadline = \function_exists('readline');
|
||||
$this->application = $application;
|
||||
$this->history = getenv('HOME').'/.history_'.$application->getName();
|
||||
$this->output = new ConsoleOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the shell.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->application->setAutoExit(false);
|
||||
$this->application->setCatchExceptions(true);
|
||||
|
||||
if ($this->hasReadline) {
|
||||
readline_read_history($this->history);
|
||||
readline_completion_function(array($this, 'autocompleter'));
|
||||
}
|
||||
|
||||
$this->output->writeln($this->getHeader());
|
||||
$php = null;
|
||||
if ($this->processIsolation) {
|
||||
$finder = new PhpExecutableFinder();
|
||||
$php = $finder->find();
|
||||
$this->output->writeln(<<<'EOF'
|
||||
<info>Running with process isolation, you should consider this:</info>
|
||||
* each command is executed as separate process,
|
||||
* commands don't support interactivity, all params must be passed explicitly,
|
||||
* commands output is not colorized.
|
||||
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
$command = $this->readline();
|
||||
|
||||
if (false === $command) {
|
||||
$this->output->writeln("\n");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->hasReadline) {
|
||||
readline_add_history($command);
|
||||
readline_write_history($this->history);
|
||||
}
|
||||
|
||||
if ($this->processIsolation) {
|
||||
$pb = new ProcessBuilder();
|
||||
|
||||
$process = $pb
|
||||
->add($php)
|
||||
->add($_SERVER['argv'][0])
|
||||
->add($command)
|
||||
->inheritEnvironmentVariables(true)
|
||||
->getProcess()
|
||||
;
|
||||
|
||||
$output = $this->output;
|
||||
$process->run(function ($type, $data) use ($output) {
|
||||
$output->writeln($data);
|
||||
});
|
||||
|
||||
$ret = $process->getExitCode();
|
||||
} else {
|
||||
$ret = $this->application->run(new StringInput($command), $this->output);
|
||||
}
|
||||
|
||||
if (0 !== $ret) {
|
||||
$this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shell header.
|
||||
*
|
||||
* @return string The header string
|
||||
*/
|
||||
protected function getHeader()
|
||||
{
|
||||
return <<<EOF
|
||||
|
||||
Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
|
||||
|
||||
At the prompt, type <comment>help</comment> for some help,
|
||||
or <comment>list</comment> to get a list of available commands.
|
||||
|
||||
To exit the shell, type <comment>^D</comment>.
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a prompt.
|
||||
*
|
||||
* @return string The prompt
|
||||
*/
|
||||
protected function getPrompt()
|
||||
{
|
||||
// using the formatter here is required when using readline
|
||||
return $this->output->getFormatter()->format($this->application->getName().' > ');
|
||||
}
|
||||
|
||||
protected function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
protected function getApplication()
|
||||
{
|
||||
return $this->application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to return autocompletion for the current entered text.
|
||||
*
|
||||
* @param string $text The last segment of the entered text
|
||||
*
|
||||
* @return bool|array A list of guessed strings or true
|
||||
*/
|
||||
private function autocompleter($text)
|
||||
{
|
||||
$info = readline_info();
|
||||
$text = substr($info['line_buffer'], 0, $info['end']);
|
||||
|
||||
if ($info['point'] !== $info['end']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// task name?
|
||||
if (false === strpos($text, ' ') || !$text) {
|
||||
return array_keys($this->application->all());
|
||||
}
|
||||
|
||||
// options and arguments?
|
||||
try {
|
||||
$command = $this->application->find(substr($text, 0, strpos($text, ' ')));
|
||||
} catch (\Exception $e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$list = array('--help');
|
||||
foreach ($command->getDefinition()->getOptions() as $option) {
|
||||
$list[] = '--'.$option->getName();
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a single line from standard input.
|
||||
*
|
||||
* @return string The single line from standard input
|
||||
*/
|
||||
private function readline()
|
||||
{
|
||||
if ($this->hasReadline) {
|
||||
$line = readline($this->getPrompt());
|
||||
} else {
|
||||
$this->output->write($this->getPrompt());
|
||||
$line = fgets(STDIN, 1024);
|
||||
$line = (false === $line || '' === $line) ? false : rtrim($line);
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
public function getProcessIsolation()
|
||||
{
|
||||
return $this->processIsolation;
|
||||
}
|
||||
|
||||
public function setProcessIsolation($processIsolation)
|
||||
{
|
||||
$this->processIsolation = (bool) $processIsolation;
|
||||
|
||||
if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
|
||||
throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?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\Debug\Exception;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0.
|
||||
*/
|
||||
class DummyException extends \ErrorException
|
||||
{
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?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\DependencyInjection;
|
||||
|
||||
/**
|
||||
* A simple implementation of ContainerAwareInterface.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.8, to be removed in 3.0. Use the ContainerAwareTrait instead.
|
||||
*/
|
||||
abstract class ContainerAware implements ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?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\DependencyInjection\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown when you try to create a service of an inactive scope.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class InactiveScopeException extends RuntimeException
|
||||
{
|
||||
private $serviceId;
|
||||
private $scope;
|
||||
|
||||
public function __construct($serviceId, $scope, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope), 0, $previous);
|
||||
|
||||
$this->serviceId = $serviceId;
|
||||
$this->scope = $scope;
|
||||
}
|
||||
|
||||
public function getServiceId()
|
||||
{
|
||||
return $this->serviceId;
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?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\DependencyInjection\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown when the a scope crossing injection is detected.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ScopeCrossingInjectionException extends RuntimeException
|
||||
{
|
||||
private $sourceServiceId;
|
||||
private $sourceScope;
|
||||
private $destServiceId;
|
||||
private $destScope;
|
||||
|
||||
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'Scope Crossing Injection detected: The definition "%s" references the service "%s" which belongs to another scope hierarchy. '
|
||||
.'This service might not be available consistently. Generally, it is safer to either move the definition "%s" to scope "%s", or '
|
||||
.'declare "%s" as a child scope of "%s". If you can be sure that the other scope is always active, you can set the reference to strict=false to get rid of this error.',
|
||||
$sourceServiceId,
|
||||
$destServiceId,
|
||||
$sourceServiceId,
|
||||
$destScope,
|
||||
$sourceScope,
|
||||
$destScope
|
||||
), 0, $previous);
|
||||
|
||||
$this->sourceServiceId = $sourceServiceId;
|
||||
$this->sourceScope = $sourceScope;
|
||||
$this->destServiceId = $destServiceId;
|
||||
$this->destScope = $destScope;
|
||||
}
|
||||
|
||||
public function getSourceServiceId()
|
||||
{
|
||||
return $this->sourceServiceId;
|
||||
}
|
||||
|
||||
public function getSourceScope()
|
||||
{
|
||||
return $this->sourceScope;
|
||||
}
|
||||
|
||||
public function getDestServiceId()
|
||||
{
|
||||
return $this->destServiceId;
|
||||
}
|
||||
|
||||
public function getDestScope()
|
||||
{
|
||||
return $this->destScope;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?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\DependencyInjection\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when a scope widening injection is detected.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ScopeWideningInjectionException extends RuntimeException
|
||||
{
|
||||
private $sourceServiceId;
|
||||
private $sourceScope;
|
||||
private $destServiceId;
|
||||
private $destScope;
|
||||
|
||||
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct(sprintf(
|
||||
'Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. '
|
||||
.'Generally, it is safer to either move "%s" to scope "%s" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "%s" each time it is needed. '
|
||||
.'In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.',
|
||||
$sourceServiceId,
|
||||
$destServiceId,
|
||||
$sourceServiceId,
|
||||
$destScope,
|
||||
$destServiceId
|
||||
), 0, $previous);
|
||||
|
||||
$this->sourceServiceId = $sourceServiceId;
|
||||
$this->sourceScope = $sourceScope;
|
||||
$this->destServiceId = $destServiceId;
|
||||
$this->destScope = $destScope;
|
||||
}
|
||||
|
||||
public function getSourceServiceId()
|
||||
{
|
||||
return $this->sourceServiceId;
|
||||
}
|
||||
|
||||
public function getSourceScope()
|
||||
{
|
||||
return $this->sourceScope;
|
||||
}
|
||||
|
||||
public function getDestServiceId()
|
||||
{
|
||||
return $this->destServiceId;
|
||||
}
|
||||
|
||||
public function getDestScope()
|
||||
{
|
||||
return $this->destScope;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?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\DependencyInjection;
|
||||
|
||||
/**
|
||||
* IntrospectableContainerInterface defines additional introspection functionality
|
||||
* for containers, allowing logic to be implemented based on a Container's state.
|
||||
*
|
||||
* @author Evan Villemez <evillemez@gmail.com>
|
||||
*
|
||||
* @deprecated since version 2.8, to be merged with ContainerInterface in 3.0.
|
||||
*/
|
||||
interface IntrospectableContainerInterface extends ContainerInterface
|
||||
{
|
||||
/**
|
||||
* Check for whether or not a service has been initialized.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return bool true if the service has been initialized, false otherwise
|
||||
*/
|
||||
public function initialized($id);
|
||||
}
|
||||
41
vendor/symfony/dependency-injection/Scope.php
vendored
41
vendor/symfony/dependency-injection/Scope.php
vendored
@@ -1,41 +0,0 @@
|
||||
<?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\DependencyInjection;
|
||||
|
||||
/**
|
||||
* Scope class.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* @deprecated since version 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class Scope implements ScopeInterface
|
||||
{
|
||||
private $name;
|
||||
private $parentName;
|
||||
|
||||
public function __construct($name, $parentName = ContainerInterface::SCOPE_CONTAINER)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->parentName = $parentName;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getParentName()
|
||||
{
|
||||
return $this->parentName;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?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\DependencyInjection;
|
||||
|
||||
/**
|
||||
* Scope Interface.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* @deprecated since version 2.8, to be removed in 3.0.
|
||||
*/
|
||||
interface ScopeInterface
|
||||
{
|
||||
public function getName();
|
||||
|
||||
public function getParentName();
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
<?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\DependencyInjection;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\SimpleXMLElement class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
/**
|
||||
* SimpleXMLElement class.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0.
|
||||
*/
|
||||
class SimpleXMLElement extends \SimpleXMLElement
|
||||
{
|
||||
/**
|
||||
* Converts an attribute as a PHP type.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttributeAsPhp($name)
|
||||
{
|
||||
return self::phpize($this[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns arguments as valid PHP types.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $lowercase
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getArgumentsAsPhp($name, $lowercase = true)
|
||||
{
|
||||
$arguments = array();
|
||||
foreach ($this->$name as $arg) {
|
||||
if (isset($arg['name'])) {
|
||||
$arg['key'] = (string) $arg['name'];
|
||||
}
|
||||
$key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1);
|
||||
|
||||
// parameter keys are case insensitive
|
||||
if ('parameter' == $name && $lowercase) {
|
||||
$key = strtolower($key);
|
||||
}
|
||||
|
||||
// this is used by DefinitionDecorator to overwrite a specific
|
||||
// argument of the parent definition
|
||||
if (isset($arg['index'])) {
|
||||
$key = 'index_'.$arg['index'];
|
||||
}
|
||||
|
||||
switch ($arg['type']) {
|
||||
case 'service':
|
||||
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
|
||||
if (isset($arg['on-invalid']) && 'ignore' == $arg['on-invalid']) {
|
||||
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
|
||||
} elseif (isset($arg['on-invalid']) && 'null' == $arg['on-invalid']) {
|
||||
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
|
||||
}
|
||||
|
||||
if (isset($arg['strict'])) {
|
||||
$strict = self::phpize($arg['strict']);
|
||||
} else {
|
||||
$strict = true;
|
||||
}
|
||||
|
||||
$arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict);
|
||||
break;
|
||||
case 'expression':
|
||||
$arguments[$key] = new Expression((string) $arg);
|
||||
break;
|
||||
case 'collection':
|
||||
$arguments[$key] = $arg->getArgumentsAsPhp($name, false);
|
||||
break;
|
||||
case 'string':
|
||||
$arguments[$key] = (string) $arg;
|
||||
break;
|
||||
case 'constant':
|
||||
$arguments[$key] = \constant((string) $arg);
|
||||
break;
|
||||
default:
|
||||
$arguments[$key] = self::phpize($arg);
|
||||
}
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an xml value to a PHP type.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function phpize($value)
|
||||
{
|
||||
return XmlUtils::phpize($value);
|
||||
}
|
||||
}
|
||||
240
vendor/symfony/finder/Adapter/AbstractAdapter.php
vendored
240
vendor/symfony/finder/Adapter/AbstractAdapter.php
vendored
@@ -1,240 +0,0 @@
|
||||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\AbstractAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Interface for finder engine implementations.
|
||||
*
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
|
||||
*/
|
||||
abstract class AbstractAdapter implements AdapterInterface
|
||||
{
|
||||
protected $followLinks = false;
|
||||
protected $mode = 0;
|
||||
protected $minDepth = 0;
|
||||
protected $maxDepth = PHP_INT_MAX;
|
||||
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;
|
||||
protected $paths = array();
|
||||
protected $notPaths = array();
|
||||
protected $ignoreUnreadableDirs = false;
|
||||
|
||||
private static $areSupported = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isSupported()
|
||||
{
|
||||
$name = $this->getName();
|
||||
|
||||
if (!array_key_exists($name, self::$areSupported)) {
|
||||
self::$areSupported[$name] = $this->canBeUsed();
|
||||
}
|
||||
|
||||
return self::$areSupported[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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 = PHP_INT_MAX;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPath(array $paths)
|
||||
{
|
||||
$this->paths = $paths;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setNotPath(array $notPaths)
|
||||
{
|
||||
$this->notPaths = $notPaths;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function ignoreUnreadableDirs($ignore = true)
|
||||
{
|
||||
$this->ignoreUnreadableDirs = (bool) $ignore;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the adapter is supported in the current environment.
|
||||
*
|
||||
* This method should be implemented in all adapters. Do not implement
|
||||
* isSupported in the adapters as the generic implementation provides a cache
|
||||
* layer.
|
||||
*
|
||||
* @see isSupported()
|
||||
*
|
||||
* @return bool Whether the adapter is supported
|
||||
*/
|
||||
abstract protected function canBeUsed();
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\AbstractFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
||||
use Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Finder\Expression\Expression;
|
||||
use Symfony\Component\Finder\Iterator;
|
||||
use Symfony\Component\Finder\Shell\Command;
|
||||
use Symfony\Component\Finder\Shell\Shell;
|
||||
|
||||
/**
|
||||
* Shell engine implementation using GNU find command.
|
||||
*
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
|
||||
*/
|
||||
abstract class AbstractFindAdapter extends AbstractAdapter
|
||||
{
|
||||
protected $shell;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->shell = new Shell();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function searchInDirectory($dir)
|
||||
{
|
||||
// having "/../" in path make find fail
|
||||
$dir = realpath($dir);
|
||||
|
||||
// searching directories containing or not containing strings leads to no result
|
||||
if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
|
||||
return new Iterator\FilePathsIterator(array(), $dir);
|
||||
}
|
||||
|
||||
$command = Command::create();
|
||||
$find = $this->buildFindCommand($command, $dir);
|
||||
|
||||
if ($this->followLinks) {
|
||||
$find->add('-follow');
|
||||
}
|
||||
|
||||
$find->add('-mindepth')->add($this->minDepth + 1);
|
||||
|
||||
if (PHP_INT_MAX !== $this->maxDepth) {
|
||||
$find->add('-maxdepth')->add($this->maxDepth + 1);
|
||||
}
|
||||
|
||||
if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
|
||||
$find->add('-type d');
|
||||
} elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
|
||||
$find->add('-type f');
|
||||
}
|
||||
|
||||
$this->buildNamesFiltering($find, $this->names);
|
||||
$this->buildNamesFiltering($find, $this->notNames, true);
|
||||
$this->buildPathsFiltering($find, $dir, $this->paths);
|
||||
$this->buildPathsFiltering($find, $dir, $this->notPaths, true);
|
||||
$this->buildSizesFiltering($find, $this->sizes);
|
||||
$this->buildDatesFiltering($find, $this->dates);
|
||||
|
||||
$useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
|
||||
$useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
|
||||
|
||||
if ($useGrep && ($this->contains || $this->notContains)) {
|
||||
$grep = $command->ins('grep');
|
||||
$this->buildContentFiltering($grep, $this->contains);
|
||||
$this->buildContentFiltering($grep, $this->notContains, true);
|
||||
}
|
||||
|
||||
if ($useSort) {
|
||||
$this->buildSorting($command, $this->sort);
|
||||
}
|
||||
|
||||
$command->setErrorHandler(
|
||||
$this->ignoreUnreadableDirs
|
||||
// If directory is unreadable and finder is set to ignore it, `stderr` is ignored.
|
||||
? function ($stderr) { }
|
||||
: function ($stderr) { throw new AccessDeniedException($stderr); }
|
||||
);
|
||||
|
||||
$paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
|
||||
$iterator = new Iterator\FilePathsIterator($paths, $dir);
|
||||
|
||||
if ($this->exclude) {
|
||||
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
|
||||
}
|
||||
|
||||
if (!$useGrep && ($this->contains || $this->notContains)) {
|
||||
$iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
|
||||
}
|
||||
|
||||
if ($this->filters) {
|
||||
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
||||
}
|
||||
|
||||
if (!$useSort && $this->sort) {
|
||||
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
|
||||
$iterator = $iteratorAggregate->getIterator();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function canBeUsed()
|
||||
{
|
||||
return $this->shell->testCommand('find');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param string $dir
|
||||
*
|
||||
* @return Command
|
||||
*/
|
||||
protected function buildFindCommand(Command $command, $dir)
|
||||
{
|
||||
return $command
|
||||
->ins('find')
|
||||
->add('find ')
|
||||
->arg($dir)
|
||||
->add('-noleaf'); // the -noleaf option is required for filesystems that don't follow the '.' and '..' conventions
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param string[] $names
|
||||
* @param bool $not
|
||||
*/
|
||||
private function buildNamesFiltering(Command $command, array $names, $not = false)
|
||||
{
|
||||
if (0 === \count($names)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$command->add($not ? '-not' : null)->cmd('(');
|
||||
|
||||
foreach ($names as $i => $name) {
|
||||
$expr = Expression::create($name);
|
||||
|
||||
// Find does not support expandable globs ("*.{a,b}" syntax).
|
||||
if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
|
||||
$expr = Expression::create($expr->getGlob()->toRegex(false));
|
||||
}
|
||||
|
||||
// Fixes 'not search' and 'full path matching' regex problems.
|
||||
// - Jokers '.' are replaced by [^/].
|
||||
// - We add '[^/]*' before and after regex (if no ^|$ flags are present).
|
||||
if ($expr->isRegex()) {
|
||||
$regex = $expr->getRegex();
|
||||
$regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
|
||||
->setStartFlag(false)
|
||||
->setStartJoker(true)
|
||||
->replaceJokers('[^/]');
|
||||
if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
|
||||
$regex->setEndJoker(false)->append('[^/]*');
|
||||
}
|
||||
}
|
||||
|
||||
$command
|
||||
->add($i > 0 ? '-or' : null)
|
||||
->add($expr->isRegex()
|
||||
? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
|
||||
: ($expr->isCaseSensitive() ? '-name' : '-iname')
|
||||
)
|
||||
->arg($expr->renderPattern());
|
||||
}
|
||||
|
||||
$command->cmd(')');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param string $dir
|
||||
* @param string[] $paths
|
||||
* @param bool $not
|
||||
*/
|
||||
private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
|
||||
{
|
||||
if (0 === \count($paths)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$command->add($not ? '-not' : null)->cmd('(');
|
||||
|
||||
foreach ($paths as $i => $path) {
|
||||
$expr = Expression::create($path);
|
||||
|
||||
// Find does not support expandable globs ("*.{a,b}" syntax).
|
||||
if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
|
||||
$expr = Expression::create($expr->getGlob()->toRegex(false));
|
||||
}
|
||||
|
||||
// Fixes 'not search' regex problems.
|
||||
if ($expr->isRegex()) {
|
||||
$regex = $expr->getRegex();
|
||||
$regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
|
||||
} else {
|
||||
$expr->prepend('*')->append('*');
|
||||
}
|
||||
|
||||
$command
|
||||
->add($i > 0 ? '-or' : null)
|
||||
->add($expr->isRegex()
|
||||
? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
|
||||
: ($expr->isCaseSensitive() ? '-path' : '-ipath')
|
||||
)
|
||||
->arg($expr->renderPattern());
|
||||
}
|
||||
|
||||
$command->cmd(')');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param NumberComparator[] $sizes
|
||||
*/
|
||||
private function buildSizesFiltering(Command $command, array $sizes)
|
||||
{
|
||||
foreach ($sizes as $i => $size) {
|
||||
$command->add($i > 0 ? '-and' : null);
|
||||
|
||||
switch ($size->getOperator()) {
|
||||
case '<=':
|
||||
$command->add('-size -'.($size->getTarget() + 1).'c');
|
||||
break;
|
||||
case '>=':
|
||||
$command->add('-size +'.($size->getTarget() - 1).'c');
|
||||
break;
|
||||
case '>':
|
||||
$command->add('-size +'.$size->getTarget().'c');
|
||||
break;
|
||||
case '!=':
|
||||
$command->add('-size -'.$size->getTarget().'c');
|
||||
$command->add('-size +'.$size->getTarget().'c');
|
||||
break;
|
||||
case '<':
|
||||
default:
|
||||
$command->add('-size -'.$size->getTarget().'c');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param DateComparator[] $dates
|
||||
*/
|
||||
private function buildDatesFiltering(Command $command, array $dates)
|
||||
{
|
||||
foreach ($dates as $i => $date) {
|
||||
$command->add($i > 0 ? '-and' : null);
|
||||
|
||||
$mins = (int) round((time() - $date->getTarget()) / 60);
|
||||
|
||||
if (0 > $mins) {
|
||||
// mtime is in the future
|
||||
$command->add(' -mmin -0');
|
||||
// we will have no result so we don't need to continue
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($date->getOperator()) {
|
||||
case '<=':
|
||||
$command->add('-mmin +'.($mins - 1));
|
||||
break;
|
||||
case '>=':
|
||||
$command->add('-mmin -'.($mins + 1));
|
||||
break;
|
||||
case '>':
|
||||
$command->add('-mmin -'.$mins);
|
||||
break;
|
||||
case '!=':
|
||||
$command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
|
||||
break;
|
||||
case '<':
|
||||
default:
|
||||
$command->add('-mmin +'.$mins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param string $sort
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function buildSorting(Command $command, $sort)
|
||||
{
|
||||
$this->buildFormatSorting($command, $sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param string $sort
|
||||
*/
|
||||
abstract protected function buildFormatSorting(Command $command, $sort);
|
||||
|
||||
/**
|
||||
* @param Command $command
|
||||
* @param array $contains
|
||||
* @param bool $not
|
||||
*/
|
||||
abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
|
||||
}
|
||||
124
vendor/symfony/finder/Adapter/AdapterInterface.php
vendored
124
vendor/symfony/finder/Adapter/AdapterInterface.php
vendored
@@ -1,124 +0,0 @@
|
||||
<?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>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
interface AdapterInterface
|
||||
{
|
||||
/**
|
||||
* @param bool $followLinks
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFollowLinks($followLinks);
|
||||
|
||||
/**
|
||||
* @param int $mode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMode($mode);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setExclude(array $exclude);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setDepths(array $depths);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setNames(array $names);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setNotNames(array $notNames);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setContains(array $contains);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setNotContains(array $notContains);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setSizes(array $sizes);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setDates(array $dates);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilters(array $filters);
|
||||
|
||||
/**
|
||||
* @param \Closure|int $sort
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSort($sort);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setPath(array $paths);
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setNotPath(array $notPaths);
|
||||
|
||||
/**
|
||||
* @param bool $ignore
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreUnreadableDirs($ignore = true);
|
||||
|
||||
/**
|
||||
* @param string $dir
|
||||
*
|
||||
* @return \Iterator Result iterator
|
||||
*/
|
||||
public function searchInDirectory($dir);
|
||||
|
||||
/**
|
||||
* Tests adapter support for current platform.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported();
|
||||
|
||||
/**
|
||||
* Returns adapter name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
}
|
||||
107
vendor/symfony/finder/Adapter/BsdFindAdapter.php
vendored
107
vendor/symfony/finder/Adapter/BsdFindAdapter.php
vendored
@@ -1,107 +0,0 @@
|
||||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\BsdFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Expression\Expression;
|
||||
use Symfony\Component\Finder\Iterator\SortableIterator;
|
||||
use Symfony\Component\Finder\Shell\Command;
|
||||
use Symfony\Component\Finder\Shell\Shell;
|
||||
|
||||
/**
|
||||
* Shell engine implementation using BSD find command.
|
||||
*
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
|
||||
*/
|
||||
class BsdFindAdapter extends AbstractFindAdapter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'bsd_find';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function canBeUsed()
|
||||
{
|
||||
return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildFormatSorting(Command $command, $sort)
|
||||
{
|
||||
switch ($sort) {
|
||||
case SortableIterator::SORT_BY_NAME:
|
||||
$command->ins('sort')->add('| sort');
|
||||
|
||||
return;
|
||||
case SortableIterator::SORT_BY_TYPE:
|
||||
$format = '%HT';
|
||||
break;
|
||||
case SortableIterator::SORT_BY_ACCESSED_TIME:
|
||||
$format = '%a';
|
||||
break;
|
||||
case SortableIterator::SORT_BY_CHANGED_TIME:
|
||||
$format = '%c';
|
||||
break;
|
||||
case SortableIterator::SORT_BY_MODIFIED_TIME:
|
||||
$format = '%m';
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
|
||||
}
|
||||
|
||||
$command
|
||||
->add('-print0 | xargs -0 stat -f')
|
||||
->arg($format.'%t%N')
|
||||
->add('| sort | cut -f 2');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildFindCommand(Command $command, $dir)
|
||||
{
|
||||
parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildContentFiltering(Command $command, array $contains, $not = false)
|
||||
{
|
||||
foreach ($contains as $contain) {
|
||||
$expr = Expression::create($contain);
|
||||
|
||||
// todo: avoid forking process for each $pattern by using multiple -e options
|
||||
$command
|
||||
->add('| grep -v \'^$\'')
|
||||
->add('| xargs -I{} grep -I')
|
||||
->add($expr->isCaseSensitive() ? null : '-i')
|
||||
->add($not ? '-L' : '-l')
|
||||
->add('-Ee')->arg($expr->renderPattern())
|
||||
->add('{}')
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
108
vendor/symfony/finder/Adapter/GnuFindAdapter.php
vendored
108
vendor/symfony/finder/Adapter/GnuFindAdapter.php
vendored
@@ -1,108 +0,0 @@
|
||||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\GnuFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Expression\Expression;
|
||||
use Symfony\Component\Finder\Iterator\SortableIterator;
|
||||
use Symfony\Component\Finder\Shell\Command;
|
||||
use Symfony\Component\Finder\Shell\Shell;
|
||||
|
||||
/**
|
||||
* Shell engine implementation using GNU find command.
|
||||
*
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
|
||||
*/
|
||||
class GnuFindAdapter extends AbstractFindAdapter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'gnu_find';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildFormatSorting(Command $command, $sort)
|
||||
{
|
||||
switch ($sort) {
|
||||
case SortableIterator::SORT_BY_NAME:
|
||||
$command->ins('sort')->add('| sort');
|
||||
|
||||
return;
|
||||
case SortableIterator::SORT_BY_TYPE:
|
||||
$format = '%y';
|
||||
break;
|
||||
case SortableIterator::SORT_BY_ACCESSED_TIME:
|
||||
$format = '%A@';
|
||||
break;
|
||||
case SortableIterator::SORT_BY_CHANGED_TIME:
|
||||
$format = '%C@';
|
||||
break;
|
||||
case SortableIterator::SORT_BY_MODIFIED_TIME:
|
||||
$format = '%T@';
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
|
||||
}
|
||||
|
||||
$command
|
||||
->get('find')
|
||||
->add('-printf')
|
||||
->arg($format.' %h/%f\\n')
|
||||
->add('| sort | cut')
|
||||
->arg('-d ')
|
||||
->arg('-f2-')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function canBeUsed()
|
||||
{
|
||||
return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildFindCommand(Command $command, $dir)
|
||||
{
|
||||
return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildContentFiltering(Command $command, array $contains, $not = false)
|
||||
{
|
||||
foreach ($contains as $contain) {
|
||||
$expr = Expression::create($contain);
|
||||
|
||||
// todo: avoid forking process for each $pattern by using multiple -e options
|
||||
$command
|
||||
->add('| xargs -I{} -r grep -I')
|
||||
->add($expr->isCaseSensitive() ? null : '-i')
|
||||
->add($not ? '-L' : '-l')
|
||||
->add('-Ee')->arg($expr->renderPattern())
|
||||
->add('{}')
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
vendor/symfony/finder/Adapter/PhpAdapter.php
vendored
101
vendor/symfony/finder/Adapter/PhpAdapter.php
vendored
@@ -1,101 +0,0 @@
|
||||
<?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;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\PhpAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Iterator;
|
||||
|
||||
/**
|
||||
* PHP finder engine implementation.
|
||||
*
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
|
||||
*/
|
||||
class PhpAdapter extends AbstractAdapter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function searchInDirectory($dir)
|
||||
{
|
||||
$flags = \RecursiveDirectoryIterator::SKIP_DOTS;
|
||||
|
||||
if ($this->followLinks) {
|
||||
$flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
|
||||
}
|
||||
|
||||
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
|
||||
|
||||
if ($this->exclude) {
|
||||
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
|
||||
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
|
||||
}
|
||||
|
||||
if ($this->mode) {
|
||||
$iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
|
||||
}
|
||||
|
||||
if ($this->names || $this->notNames) {
|
||||
$iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
|
||||
}
|
||||
|
||||
if ($this->contains || $this->notContains) {
|
||||
$iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
|
||||
}
|
||||
|
||||
if ($this->sizes) {
|
||||
$iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
|
||||
}
|
||||
|
||||
if ($this->dates) {
|
||||
$iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
|
||||
}
|
||||
|
||||
if ($this->filters) {
|
||||
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
||||
}
|
||||
|
||||
if ($this->paths || $this->notPaths) {
|
||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
|
||||
}
|
||||
|
||||
if ($this->sort) {
|
||||
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
|
||||
$iterator = $iteratorAggregate->getIterator();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'php';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function canBeUsed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?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\Exception;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Adapter\AdapterInterface;
|
||||
|
||||
/**
|
||||
* Base exception for all adapter failures.
|
||||
*
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class AdapterFailureException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
private $adapter;
|
||||
|
||||
/**
|
||||
* @param AdapterInterface $adapter
|
||||
* @param string|null $message
|
||||
* @param \Exception|null $previous
|
||||
*/
|
||||
public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
return $this->adapter;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?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\Exception;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class OperationNotPermitedException extends AdapterFailureException
|
||||
{
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?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\Exception;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Finder\Shell\Command;
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class ShellCommandFailureException extends AdapterFailureException
|
||||
{
|
||||
private $command;
|
||||
|
||||
public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
|
||||
{
|
||||
$this->command = $command;
|
||||
parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Command
|
||||
*/
|
||||
public function getCommand()
|
||||
{
|
||||
return $this->command;
|
||||
}
|
||||
}
|
||||
148
vendor/symfony/finder/Expression/Expression.php
vendored
148
vendor/symfony/finder/Expression/Expression.php
vendored
@@ -1,148 +0,0 @@
|
||||
<?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\Expression;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*/
|
||||
class Expression implements ValueInterface
|
||||
{
|
||||
const TYPE_REGEX = 1;
|
||||
const TYPE_GLOB = 2;
|
||||
|
||||
/**
|
||||
* @var ValueInterface
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param string $expr
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function create($expr)
|
||||
{
|
||||
return new self($expr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expr
|
||||
*/
|
||||
public function __construct($expr)
|
||||
{
|
||||
try {
|
||||
$this->value = Regex::create($expr);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->value = new Glob($expr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->value->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderPattern()
|
||||
{
|
||||
return $this->value->renderPattern();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCaseSensitive()
|
||||
{
|
||||
return $this->value->isCaseSensitive();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->value->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepend($expr)
|
||||
{
|
||||
$this->value->prepend($expr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function append($expr)
|
||||
{
|
||||
$this->value->append($expr);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRegex()
|
||||
{
|
||||
return self::TYPE_REGEX === $this->value->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isGlob()
|
||||
{
|
||||
return self::TYPE_GLOB === $this->value->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Glob
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function getGlob()
|
||||
{
|
||||
if (self::TYPE_GLOB !== $this->value->getType()) {
|
||||
throw new \LogicException('Regex can\'t be transformed to glob.');
|
||||
}
|
||||
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Regex
|
||||
*/
|
||||
public function getRegex()
|
||||
{
|
||||
return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
|
||||
}
|
||||
}
|
||||
108
vendor/symfony/finder/Expression/Glob.php
vendored
108
vendor/symfony/finder/Expression/Glob.php
vendored
@@ -1,108 +0,0 @@
|
||||
<?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\Expression;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Glob as FinderGlob;
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*/
|
||||
class Glob implements ValueInterface
|
||||
{
|
||||
private $pattern;
|
||||
|
||||
/**
|
||||
* @param string $pattern
|
||||
*/
|
||||
public function __construct($pattern)
|
||||
{
|
||||
$this->pattern = $pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderPattern()
|
||||
{
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Expression::TYPE_GLOB;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isCaseSensitive()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepend($expr)
|
||||
{
|
||||
$this->pattern = $expr.$this->pattern;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function append($expr)
|
||||
{
|
||||
$this->pattern .= $expr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if glob is expandable ("*.{a,b}" syntax).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExpandable()
|
||||
{
|
||||
return false !== strpos($this->pattern, '{')
|
||||
&& false !== strpos($this->pattern, '}');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $strictLeadingDot
|
||||
* @param bool $strictWildcardSlash
|
||||
*
|
||||
* @return Regex
|
||||
*/
|
||||
public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
|
||||
{
|
||||
$regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
|
||||
|
||||
return new Regex($regex);
|
||||
}
|
||||
}
|
||||
321
vendor/symfony/finder/Expression/Regex.php
vendored
321
vendor/symfony/finder/Expression/Regex.php
vendored
@@ -1,321 +0,0 @@
|
||||
<?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\Expression;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*/
|
||||
class Regex implements ValueInterface
|
||||
{
|
||||
const START_FLAG = '^';
|
||||
const END_FLAG = '$';
|
||||
const BOUNDARY = '~';
|
||||
const JOKER = '.*';
|
||||
const ESCAPING = '\\';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pattern;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $startFlag;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $endFlag;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $startJoker;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $endJoker;
|
||||
|
||||
/**
|
||||
* @param string $expr
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function create($expr)
|
||||
{
|
||||
if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
|
||||
$start = substr($m[1], 0, 1);
|
||||
$end = substr($m[1], -1);
|
||||
|
||||
if (
|
||||
($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
|
||||
|| ('{' === $start && '}' === $end)
|
||||
|| ('(' === $start && ')' === $end)
|
||||
) {
|
||||
return new self(substr($m[1], 1, -1), $m[2], $end);
|
||||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Given expression is not a regex.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pattern
|
||||
* @param string $options
|
||||
* @param string $delimiter
|
||||
*/
|
||||
public function __construct($pattern, $options = '', $delimiter = null)
|
||||
{
|
||||
if (null !== $delimiter) {
|
||||
// removes delimiter escaping
|
||||
$pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
|
||||
}
|
||||
|
||||
$this->parsePattern($pattern);
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return self::BOUNDARY
|
||||
.$this->renderPattern()
|
||||
.self::BOUNDARY
|
||||
.$this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderPattern()
|
||||
{
|
||||
return ($this->startFlag ? self::START_FLAG : '')
|
||||
.($this->startJoker ? self::JOKER : '')
|
||||
.str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
|
||||
.($this->endJoker ? self::JOKER : '')
|
||||
.($this->endFlag ? self::END_FLAG : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isCaseSensitive()
|
||||
{
|
||||
return !$this->hasOption('i');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return Expression::TYPE_REGEX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepend($expr)
|
||||
{
|
||||
$this->pattern = $expr.$this->pattern;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function append($expr)
|
||||
{
|
||||
$this->pattern .= $expr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption($option)
|
||||
{
|
||||
return false !== strpos($this->options, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addOption($option)
|
||||
{
|
||||
if (!$this->hasOption($option)) {
|
||||
$this->options .= $option;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function removeOption($option)
|
||||
{
|
||||
$this->options = str_replace($option, '', $this->options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $startFlag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStartFlag($startFlag)
|
||||
{
|
||||
$this->startFlag = $startFlag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasStartFlag()
|
||||
{
|
||||
return $this->startFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $endFlag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEndFlag($endFlag)
|
||||
{
|
||||
$this->endFlag = (bool) $endFlag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEndFlag()
|
||||
{
|
||||
return $this->endFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $startJoker
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStartJoker($startJoker)
|
||||
{
|
||||
$this->startJoker = $startJoker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasStartJoker()
|
||||
{
|
||||
return $this->startJoker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $endJoker
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEndJoker($endJoker)
|
||||
{
|
||||
$this->endJoker = (bool) $endJoker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEndJoker()
|
||||
{
|
||||
return $this->endJoker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function replaceJokers($replacement)
|
||||
{
|
||||
$replace = function ($subject) use ($replacement) {
|
||||
$subject = $subject[0];
|
||||
$replace = 0 === substr_count($subject, '\\') % 2;
|
||||
|
||||
return $replace ? str_replace('.', $replacement, $subject) : $subject;
|
||||
};
|
||||
|
||||
$this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pattern
|
||||
*/
|
||||
private function parsePattern($pattern)
|
||||
{
|
||||
if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
|
||||
$pattern = substr($pattern, 1);
|
||||
}
|
||||
|
||||
if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
|
||||
$pattern = substr($pattern, 2);
|
||||
}
|
||||
|
||||
if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
|
||||
$pattern = substr($pattern, 0, -1);
|
||||
}
|
||||
|
||||
if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
|
||||
$pattern = substr($pattern, 0, -2);
|
||||
}
|
||||
|
||||
$this->pattern = $pattern;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?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\Expression;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*/
|
||||
interface ValueInterface
|
||||
{
|
||||
/**
|
||||
* Renders string representation of expression.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render();
|
||||
|
||||
/**
|
||||
* Renders string representation of pattern.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderPattern();
|
||||
|
||||
/**
|
||||
* Returns value case sensitivity.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCaseSensitive();
|
||||
|
||||
/**
|
||||
* Returns expression type.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getType();
|
||||
|
||||
/**
|
||||
* @param string $expr
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function prepend($expr);
|
||||
|
||||
/**
|
||||
* @param string $expr
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function append($expr);
|
||||
}
|
||||
135
vendor/symfony/finder/Iterator/FilePathsIterator.php
vendored
135
vendor/symfony/finder/Iterator/FilePathsIterator.php
vendored
@@ -1,135 +0,0 @@
|
||||
<?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\Iterator;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
|
||||
/**
|
||||
* Iterate over shell command result.
|
||||
*
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class FilePathsIterator extends \ArrayIterator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $baseDir;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $baseDirLength;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $subPath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $subPathname;
|
||||
|
||||
/**
|
||||
* @var SplFileInfo
|
||||
*/
|
||||
private $current;
|
||||
|
||||
/**
|
||||
* @param array $paths List of paths returned by shell command
|
||||
* @param string $baseDir Base dir for relative path building
|
||||
*/
|
||||
public function __construct(array $paths, $baseDir)
|
||||
{
|
||||
$this->baseDir = $baseDir;
|
||||
$this->baseDirLength = \strlen($baseDir);
|
||||
|
||||
parent::__construct($paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, array $arguments)
|
||||
{
|
||||
return \call_user_func_array(array($this->current(), $name), $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of SplFileInfo with support for relative paths.
|
||||
*
|
||||
* @return SplFileInfo File information
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->current;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->current->getPathname();
|
||||
}
|
||||
|
||||
public function next()
|
||||
{
|
||||
parent::next();
|
||||
$this->buildProperties();
|
||||
}
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
parent::rewind();
|
||||
$this->buildProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubPath()
|
||||
{
|
||||
return $this->subPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubPathname()
|
||||
{
|
||||
return $this->subPathname;
|
||||
}
|
||||
|
||||
private function buildProperties()
|
||||
{
|
||||
$absolutePath = parent::current();
|
||||
|
||||
if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
|
||||
$this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
|
||||
$dir = \dirname($this->subPathname);
|
||||
$this->subPath = '.' === $dir ? '' : $dir;
|
||||
} else {
|
||||
$this->subPath = $this->subPathname = '';
|
||||
}
|
||||
|
||||
$this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
|
||||
}
|
||||
}
|
||||
278
vendor/symfony/finder/Shell/Command.php
vendored
278
vendor/symfony/finder/Shell/Command.php
vendored
@@ -1,278 +0,0 @@
|
||||
<?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\Shell;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class Command
|
||||
{
|
||||
private $parent;
|
||||
private $bits = array();
|
||||
private $labels = array();
|
||||
|
||||
/**
|
||||
* @var \Closure|null
|
||||
*/
|
||||
private $errorHandler;
|
||||
|
||||
public function __construct(Command $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns command as string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->join();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Command instance.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function create(Command $parent = null)
|
||||
{
|
||||
return new self($parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes special chars from input.
|
||||
*
|
||||
* @param string $input A string to escape
|
||||
*
|
||||
* @return string The escaped string
|
||||
*/
|
||||
public static function escape($input)
|
||||
{
|
||||
return escapeshellcmd($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quotes input.
|
||||
*
|
||||
* @param string $input An argument string
|
||||
*
|
||||
* @return string The quoted string
|
||||
*/
|
||||
public static function quote($input)
|
||||
{
|
||||
return escapeshellarg($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a string or a Command instance.
|
||||
*
|
||||
* @param string|Command $bit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add($bit)
|
||||
{
|
||||
$this->bits[] = $bit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends a string or a command instance.
|
||||
*
|
||||
* @param string|Command $bit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function top($bit)
|
||||
{
|
||||
array_unshift($this->bits, $bit);
|
||||
|
||||
foreach ($this->labels as $label => $index) {
|
||||
++$this->labels[$label];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an argument, will be quoted.
|
||||
*
|
||||
* @param string $arg
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function arg($arg)
|
||||
{
|
||||
$this->bits[] = self::quote($arg);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends escaped special command chars.
|
||||
*
|
||||
* @param string $esc
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cmd($esc)
|
||||
{
|
||||
$this->bits[] = self::escape($esc);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a labeled command to feed later.
|
||||
*
|
||||
* @param string $label The unique label
|
||||
*
|
||||
* @return self|string
|
||||
*
|
||||
* @throws \RuntimeException If label already exists
|
||||
*/
|
||||
public function ins($label)
|
||||
{
|
||||
if (isset($this->labels[$label])) {
|
||||
throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
|
||||
}
|
||||
|
||||
$this->bits[] = self::create($this);
|
||||
$this->labels[$label] = \count($this->bits) - 1;
|
||||
|
||||
return $this->bits[$this->labels[$label]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a previously labeled command.
|
||||
*
|
||||
* @param string $label
|
||||
*
|
||||
* @return self|string
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function get($label)
|
||||
{
|
||||
if (!isset($this->labels[$label])) {
|
||||
throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
|
||||
}
|
||||
|
||||
return $this->bits[$this->labels[$label]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parent command (if any).
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \RuntimeException If command has no parent
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
if (null === $this->parent) {
|
||||
throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
|
||||
}
|
||||
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts bits stored in command.
|
||||
*
|
||||
* @return int The bits count
|
||||
*/
|
||||
public function length()
|
||||
{
|
||||
return \count($this->bits);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setErrorHandler(\Closure $errorHandler)
|
||||
{
|
||||
$this->errorHandler = $errorHandler;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Closure|null
|
||||
*/
|
||||
public function getErrorHandler()
|
||||
{
|
||||
return $this->errorHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes current command.
|
||||
*
|
||||
* @return array The command result
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if (null === $errorHandler = $this->errorHandler) {
|
||||
exec($this->join(), $output);
|
||||
} else {
|
||||
$process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
|
||||
$output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
if ($error = stream_get_contents($pipes[2])) {
|
||||
$errorHandler($error);
|
||||
}
|
||||
|
||||
proc_close($process);
|
||||
}
|
||||
|
||||
return $output ?: array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins bits.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function join()
|
||||
{
|
||||
return implode(' ', array_filter(
|
||||
array_map(function ($bit) {
|
||||
return $bit instanceof Command ? $bit->join() : ($bit ?: null);
|
||||
}, $this->bits),
|
||||
function ($bit) { return null !== $bit; }
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a string or a Command instance before the bit at given position $index (index starts from 0).
|
||||
*
|
||||
* @param string|Command $bit
|
||||
* @param int $index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addAtIndex($bit, $index)
|
||||
{
|
||||
array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
101
vendor/symfony/finder/Shell/Shell.php
vendored
101
vendor/symfony/finder/Shell/Shell.php
vendored
@@ -1,101 +0,0 @@
|
||||
<?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\Shell;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*
|
||||
* @deprecated since 2.8, to be removed in 3.0.
|
||||
*/
|
||||
class Shell
|
||||
{
|
||||
const TYPE_UNIX = 1;
|
||||
const TYPE_DARWIN = 2;
|
||||
const TYPE_CYGWIN = 3;
|
||||
const TYPE_WINDOWS = 4;
|
||||
const TYPE_BSD = 5;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Returns guessed OS type.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
if (null === $this->type) {
|
||||
$this->type = $this->guessType();
|
||||
}
|
||||
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a command is available.
|
||||
*
|
||||
* @param string $command
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function testCommand($command)
|
||||
{
|
||||
if (!\function_exists('exec')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// todo: find a better way (command could not be available)
|
||||
$testCommand = 'which ';
|
||||
if (self::TYPE_WINDOWS === $this->type) {
|
||||
$testCommand = 'where ';
|
||||
}
|
||||
|
||||
$command = escapeshellcmd($command);
|
||||
|
||||
exec($testCommand.$command, $output, $code);
|
||||
|
||||
return 0 === $code && \count($output) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guesses OS type.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function guessType()
|
||||
{
|
||||
$os = strtolower(PHP_OS);
|
||||
|
||||
if (false !== strpos($os, 'cygwin')) {
|
||||
return self::TYPE_CYGWIN;
|
||||
}
|
||||
|
||||
if (false !== strpos($os, 'darwin')) {
|
||||
return self::TYPE_DARWIN;
|
||||
}
|
||||
|
||||
if (false !== strpos($os, 'bsd')) {
|
||||
return self::TYPE_BSD;
|
||||
}
|
||||
|
||||
if (0 === strpos($os, 'win')) {
|
||||
return self::TYPE_WINDOWS;
|
||||
}
|
||||
|
||||
return self::TYPE_UNIX;
|
||||
}
|
||||
}
|
||||
@@ -1,268 +0,0 @@
|
||||
<?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\HttpFoundation\Session\Storage\Handler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\LegacyPdoSessionHandler class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Session handler using a PDO connection to read and write data.
|
||||
*
|
||||
* Session data is a binary string that can contain non-printable characters like the null byte.
|
||||
* For this reason this handler base64 encodes the data to be able to save it in a character column.
|
||||
*
|
||||
* This version of the PdoSessionHandler does NOT implement locking. So concurrent requests to the
|
||||
* same session can result in data loss due to race conditions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Michael Williams <michael.williams@funsational.com>
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
*
|
||||
* @deprecated since version 2.6, to be removed in 3.0. Use
|
||||
* {@link PdoSessionHandler} instead.
|
||||
*/
|
||||
class LegacyPdoSessionHandler implements \SessionHandlerInterface
|
||||
{
|
||||
private $pdo;
|
||||
|
||||
/**
|
||||
* @var string Table name
|
||||
*/
|
||||
private $table;
|
||||
|
||||
/**
|
||||
* @var string Column for session id
|
||||
*/
|
||||
private $idCol;
|
||||
|
||||
/**
|
||||
* @var string Column for session data
|
||||
*/
|
||||
private $dataCol;
|
||||
|
||||
/**
|
||||
* @var string Column for timestamp
|
||||
*/
|
||||
private $timeCol;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* List of available options:
|
||||
* * db_table: The name of the table [required]
|
||||
* * db_id_col: The column where to store the session id [default: sess_id]
|
||||
* * db_data_col: The column where to store the session data [default: sess_data]
|
||||
* * db_time_col: The column where to store the timestamp [default: sess_time]
|
||||
*
|
||||
* @param \PDO $pdo A \PDO instance
|
||||
* @param array $dbOptions An associative array of DB options
|
||||
*
|
||||
* @throws \InvalidArgumentException When "db_table" option is not provided
|
||||
*/
|
||||
public function __construct(\PDO $pdo, array $dbOptions = array())
|
||||
{
|
||||
if (!array_key_exists('db_table', $dbOptions)) {
|
||||
throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.');
|
||||
}
|
||||
if (\PDO::ERRMODE_EXCEPTION !== $pdo->getAttribute(\PDO::ATTR_ERRMODE)) {
|
||||
throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__));
|
||||
}
|
||||
|
||||
$this->pdo = $pdo;
|
||||
$dbOptions = array_merge(array(
|
||||
'db_id_col' => 'sess_id',
|
||||
'db_data_col' => 'sess_data',
|
||||
'db_time_col' => 'sess_time',
|
||||
), $dbOptions);
|
||||
|
||||
$this->table = $dbOptions['db_table'];
|
||||
$this->idCol = $dbOptions['db_id_col'];
|
||||
$this->dataCol = $dbOptions['db_data_col'];
|
||||
$this->timeCol = $dbOptions['db_time_col'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function open($savePath, $sessionName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy($sessionId)
|
||||
{
|
||||
// delete the record associated with this id
|
||||
$sql = "DELETE FROM $this->table WHERE $this->idCol = :id";
|
||||
|
||||
try {
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
} catch (\PDOException $e) {
|
||||
throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
// delete the session records that have expired
|
||||
$sql = "DELETE FROM $this->table WHERE $this->timeCol < :time";
|
||||
|
||||
try {
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (\PDOException $e) {
|
||||
throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($sessionId)
|
||||
{
|
||||
$sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id";
|
||||
|
||||
try {
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
|
||||
// We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed
|
||||
$sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM);
|
||||
|
||||
if ($sessionRows) {
|
||||
return base64_decode($sessionRows[0][0]);
|
||||
}
|
||||
|
||||
return '';
|
||||
} catch (\PDOException $e) {
|
||||
throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($sessionId, $data)
|
||||
{
|
||||
$encoded = base64_encode($data);
|
||||
|
||||
try {
|
||||
// We use a single MERGE SQL query when supported by the database.
|
||||
$mergeSql = $this->getMergeSql();
|
||||
|
||||
if (null !== $mergeSql) {
|
||||
$mergeStmt = $this->pdo->prepare($mergeSql);
|
||||
$mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(':data', $encoded, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$mergeStmt->execute();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$updateStmt = $this->pdo->prepare(
|
||||
"UPDATE $this->table SET $this->dataCol = :data, $this->timeCol = :time WHERE $this->idCol = :id"
|
||||
);
|
||||
$updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$updateStmt->bindParam(':data', $encoded, \PDO::PARAM_STR);
|
||||
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$updateStmt->execute();
|
||||
|
||||
// When MERGE is not supported, like in Postgres, we have to use this approach that can result in
|
||||
// duplicate key errors when the same session is written simultaneously. We can just catch such an
|
||||
// error and re-execute the update. This is similar to a serializable transaction with retry logic
|
||||
// on serialization failures but without the overhead and without possible false positives due to
|
||||
// longer gap locking.
|
||||
if (!$updateStmt->rowCount()) {
|
||||
try {
|
||||
$insertStmt = $this->pdo->prepare(
|
||||
"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"
|
||||
);
|
||||
$insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$insertStmt->bindParam(':data', $encoded, \PDO::PARAM_STR);
|
||||
$insertStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$insertStmt->execute();
|
||||
} catch (\PDOException $e) {
|
||||
// Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys
|
||||
if (0 === strpos($e->getCode(), '23')) {
|
||||
$updateStmt->execute();
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database.
|
||||
*
|
||||
* @return string|null The SQL string or null when not supported
|
||||
*/
|
||||
private function getMergeSql()
|
||||
{
|
||||
$driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
|
||||
|
||||
switch ($driver) {
|
||||
case 'mysql':
|
||||
return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
|
||||
"ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)";
|
||||
case 'oci':
|
||||
// DUAL is Oracle specific dummy table
|
||||
return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ".
|
||||
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
|
||||
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time";
|
||||
case 'sqlsrv' === $driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='):
|
||||
// MERGE is only available since SQL Server 2008 and must be terminated by semicolon
|
||||
// It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
|
||||
return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ".
|
||||
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
|
||||
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;";
|
||||
case 'sqlite':
|
||||
return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a PDO instance.
|
||||
*
|
||||
* @return \PDO
|
||||
*/
|
||||
protected function getConnection()
|
||||
{
|
||||
return $this->pdo;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?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\HttpKernel\Debug;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ErrorHandler class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\ErrorHandler class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Debug\ErrorHandler as DebugErrorHandler;
|
||||
|
||||
/**
|
||||
* ErrorHandler.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class ErrorHandler extends DebugErrorHandler
|
||||
{
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?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\HttpKernel\Debug;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ExceptionHandler class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\ExceptionHandler class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Debug\ExceptionHandler as DebugExceptionHandler;
|
||||
|
||||
/**
|
||||
* ExceptionHandler converts an exception to a Response object.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class ExceptionHandler extends DebugExceptionHandler
|
||||
{
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?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\HttpKernel\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Scope;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
* Adds a managed request scope.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
* @deprecated since version 2.7, to be removed in 3.0.
|
||||
*/
|
||||
class ContainerAwareHttpKernel extends HttpKernel
|
||||
{
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
|
||||
* @param ContainerInterface $container A ContainerInterface instance
|
||||
* @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
|
||||
* @param RequestStack $requestStack A stack for master/sub requests
|
||||
* @param bool $triggerDeprecation Whether or not to trigger the deprecation warning for the ContainerAwareHttpKernel
|
||||
*/
|
||||
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null, $triggerDeprecation = true)
|
||||
{
|
||||
parent::__construct($dispatcher, $controllerResolver, $requestStack);
|
||||
|
||||
if ($triggerDeprecation) {
|
||||
@trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.7 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpKernel class instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->container = $container;
|
||||
|
||||
// the request scope might have been created before (see FrameworkBundle)
|
||||
if (!$container->hasScope('request')) {
|
||||
$container->addScope(new Scope('request'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
$this->container->enterScope('request');
|
||||
$this->container->set('request', $request, 'request');
|
||||
|
||||
try {
|
||||
$response = parent::handle($request, $type, $catch);
|
||||
} catch (\Exception $e) {
|
||||
$this->container->set('request', null, 'request');
|
||||
$this->container->leaveScope('request');
|
||||
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
$this->container->set('request', null, 'request');
|
||||
$this->container->leaveScope('request');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->container->set('request', null, 'request');
|
||||
$this->container->leaveScope('request');
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?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\HttpKernel\DependencyInjection;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\RegisterListenersPass is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass as BaseRegisterListenersPass;
|
||||
|
||||
/**
|
||||
* Compiler pass to register tagged services for an event dispatcher.
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0. Use the Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass class instead.
|
||||
*/
|
||||
class RegisterListenersPass extends BaseRegisterListenersPass
|
||||
{
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?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\HttpKernel\EventListener;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ErrorsLoggerListener class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\EventListener\DebugHandlersListener class instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
* Injects the logger into the ErrorHandler, so that it can log various errors.
|
||||
*
|
||||
* @author Colin Frei <colin@colinfrei.com>
|
||||
* @author Konstantin Myakshin <koc-dp@yandex.ru>
|
||||
*
|
||||
* @deprecated since version 2.6, to be removed in 3.0. Use the DebugHandlersListener class instead.
|
||||
*/
|
||||
class ErrorsLoggerListener implements EventSubscriberInterface
|
||||
{
|
||||
private $channel;
|
||||
private $logger;
|
||||
|
||||
public function __construct($channel, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->channel = $channel;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function injectLogger()
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
ErrorHandler::setLogger($this->logger, $this->channel);
|
||||
$this->logger = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(KernelEvents::REQUEST => array('injectLogger', 2048));
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?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\HttpKernel\EventListener;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\EsiListener class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\EventListener\SurrogateListener class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.6, to be removed in 3.0. Use SurrogateListener instead
|
||||
*/
|
||||
class EsiListener extends SurrogateListener
|
||||
{
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?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\HttpKernel\Exception;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\FatalErrorException class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\Exception\FatalErrorException class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/*
|
||||
* Fatal Error Exception.
|
||||
*
|
||||
* @author Konstanton Myakshin <koc-dp@yandex.ru>
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class_exists('Symfony\Component\Debug\Exception\FatalErrorException');
|
||||
@@ -1,25 +0,0 @@
|
||||
<?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\HttpKernel\Exception;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\FlattenException class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\Exception\FlattenException class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/*
|
||||
* FlattenException wraps a PHP Exception to be able to serialize it.
|
||||
*
|
||||
* Basically, this class removes all objects from the trace.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class_exists('Symfony\Component\Debug\Exception\FlattenException');
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This code is partially based on the Rack-Cache library by Ryan Tomayko,
|
||||
* which is released under the MIT license.
|
||||
* (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\HttpCache;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategy class is deprecated since Symfony 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategy class instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* EsiResponseCacheStrategy knows how to compute the Response cache HTTP header
|
||||
* based on the different ESI response cache headers.
|
||||
*
|
||||
* This implementation changes the master response TTL to the smallest TTL received
|
||||
* or force validation if one of the ESI has validation cache strategy.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategy instead
|
||||
*/
|
||||
class EsiResponseCacheStrategy extends ResponseCacheStrategy implements EsiResponseCacheStrategyInterface
|
||||
{
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* This code is partially based on the Rack-Cache library by Ryan Tomayko,
|
||||
* which is released under the MIT license.
|
||||
* (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\HttpCache;
|
||||
|
||||
/**
|
||||
* ResponseCacheStrategyInterface implementations know how to compute the
|
||||
* Response cache HTTP header based on the different response cache headers.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategyInterface instead.
|
||||
*/
|
||||
interface EsiResponseCacheStrategyInterface extends ResponseCacheStrategyInterface
|
||||
{
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?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\HttpKernel\Log;
|
||||
|
||||
use Psr\Log\LoggerInterface as PsrLogger;
|
||||
|
||||
/**
|
||||
* LoggerInterface.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 2.2, to be removed in 3.0. Type-hint \Psr\Log\LoggerInterface instead.
|
||||
*/
|
||||
interface LoggerInterface extends PsrLogger
|
||||
{
|
||||
/**
|
||||
* @deprecated since version 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
|
||||
*/
|
||||
public function emerg($message, array $context = array());
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
|
||||
*/
|
||||
public function crit($message, array $context = array());
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
|
||||
*/
|
||||
public function err($message, array $context = array());
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
|
||||
*/
|
||||
public function warn($message, array $context = array());
|
||||
}
|
||||
44
vendor/symfony/http-kernel/Log/NullLogger.php
vendored
44
vendor/symfony/http-kernel/Log/NullLogger.php
vendored
@@ -1,44 +0,0 @@
|
||||
<?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\HttpKernel\Log;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\NullLogger class is deprecated since Symfony 2.2 and will be removed in 3.0. Use the Psr\Log\NullLogger class instead from the psr/log Composer package.', E_USER_DEPRECATED);
|
||||
|
||||
use Psr\Log\NullLogger as PsrNullLogger;
|
||||
|
||||
/**
|
||||
* NullLogger.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class NullLogger extends PsrNullLogger implements LoggerInterface
|
||||
{
|
||||
public function emerg($message, array $context = array())
|
||||
{
|
||||
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new emergency() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
public function crit($message, array $context = array())
|
||||
{
|
||||
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new critical() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
public function err($message, array $context = array())
|
||||
{
|
||||
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new error() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
public function warn($message, array $context = array())
|
||||
{
|
||||
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.2 and will be removed in 3.0. You should use the new warning() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
@@ -1,313 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\BaseMemcacheProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Base Memcache storage for profiling information in a Memcache.
|
||||
*
|
||||
* @author Andrej Hudec <pulzarraider@gmail.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface
|
||||
{
|
||||
const TOKEN_PREFIX = 'sf_profiler_';
|
||||
|
||||
protected $dsn;
|
||||
protected $lifetime;
|
||||
|
||||
/**
|
||||
* @param string $dsn A data source name
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param int $lifetime The lifetime to use for the purge
|
||||
*/
|
||||
public function __construct($dsn, $username = '', $password = '', $lifetime = 86400)
|
||||
{
|
||||
$this->dsn = $dsn;
|
||||
$this->lifetime = (int) $lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null)
|
||||
{
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
$indexContent = $this->getValue($indexName);
|
||||
if (!$indexContent) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$profileList = explode("\n", $indexContent);
|
||||
$result = array();
|
||||
|
||||
foreach ($profileList as $item) {
|
||||
if (0 === $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ('' == $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = explode("\t", $item, 7);
|
||||
list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = $values;
|
||||
$statusCode = isset($values[6]) ? $values[6] : null;
|
||||
|
||||
$itemTime = (int) $itemTime;
|
||||
|
||||
if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($start) && $itemTime < $start) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($end) && $itemTime > $end) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$itemToken] = array(
|
||||
'token' => $itemToken,
|
||||
'ip' => $itemIp,
|
||||
'method' => $itemMethod,
|
||||
'url' => $itemUrl,
|
||||
'time' => $itemTime,
|
||||
'parent' => $itemParent,
|
||||
'status_code' => $statusCode,
|
||||
);
|
||||
--$limit;
|
||||
}
|
||||
|
||||
usort($result, function ($a, $b) {
|
||||
if ($a['time'] === $b['time']) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $a['time'] > $b['time'] ? -1 : 1;
|
||||
});
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
// delete only items from index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
$indexContent = $this->getValue($indexName);
|
||||
|
||||
if (!$indexContent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$profileList = explode("\n", $indexContent);
|
||||
|
||||
foreach ($profileList as $item) {
|
||||
if ('' == $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false !== $pos = strpos($item, "\t")) {
|
||||
$this->delete($this->getItemName(substr($item, 0, $pos)));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->delete($indexName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($token)
|
||||
{
|
||||
if (empty($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$profile = $this->getValue($this->getItemName($token));
|
||||
|
||||
if (false !== $profile) {
|
||||
$profile = $this->createProfileFromData($token, $profile);
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(Profile $profile)
|
||||
{
|
||||
$data = array(
|
||||
'token' => $profile->getToken(),
|
||||
'parent' => $profile->getParentToken(),
|
||||
'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()),
|
||||
'data' => $profile->getCollectors(),
|
||||
'ip' => $profile->getIp(),
|
||||
'method' => $profile->getMethod(),
|
||||
'url' => $profile->getUrl(),
|
||||
'time' => $profile->getTime(),
|
||||
);
|
||||
|
||||
$profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken()));
|
||||
|
||||
if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) {
|
||||
if (!$profileIndexed) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
$indexRow = implode("\t", array(
|
||||
$profile->getToken(),
|
||||
$profile->getIp(),
|
||||
$profile->getMethod(),
|
||||
$profile->getUrl(),
|
||||
$profile->getTime(),
|
||||
$profile->getParentToken(),
|
||||
$profile->getStatusCode(),
|
||||
))."\n";
|
||||
|
||||
return $this->appendValue($indexName, $indexRow, $this->lifetime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve item from the memcache server.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function getValue($key);
|
||||
|
||||
/**
|
||||
* Store an item on the memcache server under the specified key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $expiration
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function setValue($key, $value, $expiration = 0);
|
||||
|
||||
/**
|
||||
* Delete item from the memcache server.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function delete($key);
|
||||
|
||||
/**
|
||||
* Append data to an existing item on the memcache server.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param int $expiration
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function appendValue($key, $value, $expiration = 0);
|
||||
|
||||
private function createProfileFromData($token, $data, $parent = null)
|
||||
{
|
||||
$profile = new Profile($token);
|
||||
$profile->setIp($data['ip']);
|
||||
$profile->setMethod($data['method']);
|
||||
$profile->setUrl($data['url']);
|
||||
$profile->setTime($data['time']);
|
||||
$profile->setCollectors($data['data']);
|
||||
|
||||
if (!$parent && $data['parent']) {
|
||||
$parent = $this->read($data['parent']);
|
||||
}
|
||||
|
||||
if ($parent) {
|
||||
$profile->setParent($parent);
|
||||
}
|
||||
|
||||
foreach ($data['children'] as $token) {
|
||||
if (!$token) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$childProfileData = $this->getValue($this->getItemName($token))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$profile->addChild($this->createProfileFromData($token, $childProfileData, $profile));
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item name.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getItemName($token)
|
||||
{
|
||||
$name = self::TOKEN_PREFIX.$token;
|
||||
|
||||
if ($this->isItemNameValid($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of index.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getIndexName()
|
||||
{
|
||||
$name = self::TOKEN_PREFIX.'index';
|
||||
|
||||
if ($this->isItemNameValid($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isItemNameValid($name)
|
||||
{
|
||||
$length = \strlen($name);
|
||||
|
||||
if ($length > 250) {
|
||||
throw new \RuntimeException(sprintf('The memcache item key "%s" is too long (%s bytes). Allowed maximum size is 250 bytes.', $name, $length));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\MemcacheProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Memcache Profiler Storage.
|
||||
*
|
||||
* @author Andrej Hudec <pulzarraider@gmail.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage
|
||||
{
|
||||
/**
|
||||
* @var \Memcache
|
||||
*/
|
||||
private $memcache;
|
||||
|
||||
/**
|
||||
* Internal convenience method that returns the instance of the Memcache.
|
||||
*
|
||||
* @return \Memcache
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getMemcache()
|
||||
{
|
||||
if (null === $this->memcache) {
|
||||
if (!preg_match('#^memcache://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) {
|
||||
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcache with an invalid dsn "%s". The expected format is "memcache://[host]:port".', $this->dsn));
|
||||
}
|
||||
|
||||
$host = $matches[1] ?: $matches[2];
|
||||
$port = $matches[3];
|
||||
|
||||
$memcache = new \Memcache();
|
||||
$memcache->addServer($host, $port);
|
||||
|
||||
$this->memcache = $memcache;
|
||||
}
|
||||
|
||||
return $this->memcache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set instance of the Memcache.
|
||||
*
|
||||
* @param \Memcache $memcache
|
||||
*/
|
||||
public function setMemcache($memcache)
|
||||
{
|
||||
$this->memcache = $memcache;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getValue($key)
|
||||
{
|
||||
return $this->getMemcache()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setValue($key, $value, $expiration = 0)
|
||||
{
|
||||
return $this->getMemcache()->set($key, $value, false, time() + $expiration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function delete($key)
|
||||
{
|
||||
return $this->getMemcache()->delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function appendValue($key, $value, $expiration = 0)
|
||||
{
|
||||
$memcache = $this->getMemcache();
|
||||
|
||||
if (method_exists($memcache, 'append')) {
|
||||
// Memcache v3.0
|
||||
if (!$result = $memcache->append($key, $value, false, $expiration)) {
|
||||
return $memcache->set($key, $value, false, $expiration);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// simulate append in Memcache <3.0
|
||||
$content = $memcache->get($key);
|
||||
|
||||
return $memcache->set($key, $content.$value, false, $expiration);
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\MemcachedProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Memcached Profiler Storage.
|
||||
*
|
||||
* @author Andrej Hudec <pulzarraider@gmail.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage
|
||||
{
|
||||
/**
|
||||
* @var \Memcached
|
||||
*/
|
||||
private $memcached;
|
||||
|
||||
/**
|
||||
* Internal convenience method that returns the instance of the Memcached.
|
||||
*
|
||||
* @return \Memcached
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getMemcached()
|
||||
{
|
||||
if (null === $this->memcached) {
|
||||
if (!preg_match('#^memcached://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) {
|
||||
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcached with an invalid dsn "%s". The expected format is "memcached://[host]:port".', $this->dsn));
|
||||
}
|
||||
|
||||
$host = $matches[1] ?: $matches[2];
|
||||
$port = $matches[3];
|
||||
|
||||
$memcached = new \Memcached();
|
||||
|
||||
// disable compression to allow appending
|
||||
$memcached->setOption(\Memcached::OPT_COMPRESSION, false);
|
||||
|
||||
$memcached->addServer($host, $port);
|
||||
|
||||
$this->memcached = $memcached;
|
||||
}
|
||||
|
||||
return $this->memcached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set instance of the Memcached.
|
||||
*
|
||||
* @param \Memcached $memcached
|
||||
*/
|
||||
public function setMemcached($memcached)
|
||||
{
|
||||
$this->memcached = $memcached;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getValue($key)
|
||||
{
|
||||
return $this->getMemcached()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setValue($key, $value, $expiration = 0)
|
||||
{
|
||||
return $this->getMemcached()->set($key, $value, time() + $expiration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function delete($key)
|
||||
{
|
||||
return $this->getMemcached()->delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function appendValue($key, $value, $expiration = 0)
|
||||
{
|
||||
$memcached = $this->getMemcached();
|
||||
|
||||
if (!$result = $memcached->append($key, $value)) {
|
||||
return $memcached->set($key, $value, $expiration);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\MongoDbProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
class MongoDbProfilerStorage implements ProfilerStorageInterface
|
||||
{
|
||||
protected $dsn;
|
||||
protected $lifetime;
|
||||
private $mongo;
|
||||
|
||||
/**
|
||||
* @param string $dsn A data source name
|
||||
* @param string $username Not used
|
||||
* @param string $password Not used
|
||||
* @param int $lifetime The lifetime to use for the purge
|
||||
*/
|
||||
public function __construct($dsn, $username = '', $password = '', $lifetime = 86400)
|
||||
{
|
||||
$this->dsn = $dsn;
|
||||
$this->lifetime = (int) $lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null)
|
||||
{
|
||||
$cursor = $this->getMongo()->find($this->buildQuery($ip, $url, $method, $start, $end), array('_id', 'parent', 'ip', 'method', 'url', 'time', 'status_code'))->sort(array('time' => -1))->limit($limit);
|
||||
|
||||
$tokens = array();
|
||||
foreach ($cursor as $profile) {
|
||||
$tokens[] = $this->getData($profile);
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
$this->getMongo()->remove(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($token)
|
||||
{
|
||||
$profile = $this->getMongo()->findOne(array('_id' => $token, 'data' => array('$exists' => true)));
|
||||
|
||||
if (null !== $profile) {
|
||||
$profile = $this->createProfileFromData($this->getData($profile));
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(Profile $profile)
|
||||
{
|
||||
$this->cleanup();
|
||||
|
||||
$record = array(
|
||||
'_id' => $profile->getToken(),
|
||||
'parent' => $profile->getParentToken(),
|
||||
'data' => base64_encode(serialize($profile->getCollectors())),
|
||||
'ip' => $profile->getIp(),
|
||||
'method' => $profile->getMethod(),
|
||||
'url' => $profile->getUrl(),
|
||||
'time' => $profile->getTime(),
|
||||
'status_code' => $profile->getStatusCode(),
|
||||
);
|
||||
|
||||
$result = $this->getMongo()->update(array('_id' => $profile->getToken()), array_filter($record, function ($v) { return !empty($v); }), array('upsert' => true));
|
||||
|
||||
return (bool) (isset($result['ok']) ? $result['ok'] : $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal convenience method that returns the instance of the MongoDB Collection.
|
||||
*
|
||||
* @return \MongoCollection
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getMongo()
|
||||
{
|
||||
if (null !== $this->mongo) {
|
||||
return $this->mongo;
|
||||
}
|
||||
|
||||
if (!$parsedDsn = $this->parseDsn($this->dsn)) {
|
||||
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://[user:pass@]host/database/collection"', $this->dsn));
|
||||
}
|
||||
|
||||
list($server, $database, $collection) = $parsedDsn;
|
||||
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? '\Mongo' : '\MongoClient';
|
||||
$mongo = new $mongoClass($server);
|
||||
|
||||
return $this->mongo = $mongo->selectCollection($database, $collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Profile
|
||||
*/
|
||||
protected function createProfileFromData(array $data)
|
||||
{
|
||||
$profile = $this->getProfile($data);
|
||||
|
||||
if ($data['parent']) {
|
||||
$parent = $this->getMongo()->findOne(array('_id' => $data['parent'], 'data' => array('$exists' => true)));
|
||||
if ($parent) {
|
||||
$profile->setParent($this->getProfile($this->getData($parent)));
|
||||
}
|
||||
}
|
||||
|
||||
$profile->setChildren($this->readChildren($data['token']));
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
*
|
||||
* @return Profile[] An array of Profile instances
|
||||
*/
|
||||
protected function readChildren($token)
|
||||
{
|
||||
$profiles = array();
|
||||
|
||||
$cursor = $this->getMongo()->find(array('parent' => $token, 'data' => array('$exists' => true)));
|
||||
foreach ($cursor as $d) {
|
||||
$profiles[] = $this->getProfile($this->getData($d));
|
||||
}
|
||||
|
||||
return $profiles;
|
||||
}
|
||||
|
||||
protected function cleanup()
|
||||
{
|
||||
$this->getMongo()->remove(array('time' => array('$lt' => time() - $this->lifetime)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ip
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param int $start
|
||||
* @param int $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function buildQuery($ip, $url, $method, $start, $end)
|
||||
{
|
||||
$query = array();
|
||||
|
||||
if (!empty($ip)) {
|
||||
$query['ip'] = $ip;
|
||||
}
|
||||
|
||||
if (!empty($url)) {
|
||||
$query['url'] = $url;
|
||||
}
|
||||
|
||||
if (!empty($method)) {
|
||||
$query['method'] = $method;
|
||||
}
|
||||
|
||||
if (!empty($start) || !empty($end)) {
|
||||
$query['time'] = array();
|
||||
}
|
||||
|
||||
if (!empty($start)) {
|
||||
$query['time']['$gte'] = $start;
|
||||
}
|
||||
|
||||
if (!empty($end)) {
|
||||
$query['time']['$lte'] = $end;
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getData(array $data)
|
||||
{
|
||||
return array(
|
||||
'token' => $data['_id'],
|
||||
'parent' => isset($data['parent']) ? $data['parent'] : null,
|
||||
'ip' => isset($data['ip']) ? $data['ip'] : null,
|
||||
'method' => isset($data['method']) ? $data['method'] : null,
|
||||
'url' => isset($data['url']) ? $data['url'] : null,
|
||||
'time' => isset($data['time']) ? $data['time'] : null,
|
||||
'data' => isset($data['data']) ? $data['data'] : null,
|
||||
'status_code' => isset($data['status_code']) ? $data['status_code'] : null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Profile
|
||||
*/
|
||||
private function getProfile(array $data)
|
||||
{
|
||||
$profile = new Profile($data['token']);
|
||||
$profile->setIp($data['ip']);
|
||||
$profile->setMethod($data['method']);
|
||||
$profile->setUrl($data['url']);
|
||||
$profile->setTime($data['time']);
|
||||
$profile->setCollectors(unserialize(base64_decode($data['data'])));
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dsn
|
||||
*
|
||||
* @return array|null Array($server, $database, $collection)
|
||||
*/
|
||||
private function parseDsn($dsn)
|
||||
{
|
||||
if (!preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $dsn, $matches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$server = $matches[1];
|
||||
$database = $matches[2];
|
||||
$collection = $matches[3];
|
||||
preg_match('#^mongodb://(([^:]+):?(.*)(?=@))?@?([^/]*)(.*)$#', $server, $matchesServer);
|
||||
|
||||
if ('' == $matchesServer[5] && '' != $matches[2]) {
|
||||
$server .= '/'.$matches[2];
|
||||
}
|
||||
|
||||
return array($server, $database, $collection);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\MysqlProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A ProfilerStorage for Mysql.
|
||||
*
|
||||
* @author Jan Schumann <js@schumann-it.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
class MysqlProfilerStorage extends PdoProfilerStorage
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initDb()
|
||||
{
|
||||
if (null === $this->db) {
|
||||
if (0 !== strpos($this->dsn, 'mysql')) {
|
||||
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Mysql with an invalid dsn "%s". The expected format is "mysql:dbname=database_name;host=host_name".', $this->dsn));
|
||||
}
|
||||
|
||||
if (!class_exists('PDO') || !\in_array('mysql', \PDO::getAvailableDrivers(), true)) {
|
||||
throw new \RuntimeException('You need to enable PDO_Mysql extension for the profiler to run properly.');
|
||||
}
|
||||
|
||||
$db = new \PDO($this->dsn, $this->username, $this->password);
|
||||
$db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token VARCHAR(255) PRIMARY KEY, data LONGTEXT, ip VARCHAR(64), method VARCHAR(6), url VARCHAR(255), time INTEGER UNSIGNED, parent VARCHAR(255), created_at INTEGER UNSIGNED, status_code SMALLINT UNSIGNED, KEY (created_at), KEY (ip), KEY (method), KEY (url), KEY (parent))');
|
||||
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildCriteria($ip, $url, $start, $end, $limit, $method)
|
||||
{
|
||||
$criteria = array();
|
||||
$args = array();
|
||||
|
||||
if ($ip = preg_replace('/[^\d\.]/', '', $ip)) {
|
||||
$criteria[] = 'ip LIKE :ip';
|
||||
$args[':ip'] = '%'.$ip.'%';
|
||||
}
|
||||
|
||||
if ($url) {
|
||||
$criteria[] = 'url LIKE :url';
|
||||
$args[':url'] = '%'.addcslashes($url, '%_\\').'%';
|
||||
}
|
||||
|
||||
if ($method) {
|
||||
$criteria[] = 'method = :method';
|
||||
$args[':method'] = $method;
|
||||
}
|
||||
|
||||
if (!empty($start)) {
|
||||
$criteria[] = 'time >= :start';
|
||||
$args[':start'] = $start;
|
||||
}
|
||||
|
||||
if (!empty($end)) {
|
||||
$criteria[] = 'time <= :end';
|
||||
$args[':end'] = $end;
|
||||
}
|
||||
|
||||
return array($criteria, $args);
|
||||
}
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\PdoProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Base PDO storage for profiling information in a PDO database.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jan Schumann <js@schumann-it.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
abstract class PdoProfilerStorage implements ProfilerStorageInterface
|
||||
{
|
||||
protected $dsn;
|
||||
protected $username;
|
||||
protected $password;
|
||||
protected $lifetime;
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @param string $dsn A data source name
|
||||
* @param string $username The username for the database
|
||||
* @param string $password The password for the database
|
||||
* @param int $lifetime The lifetime to use for the purge
|
||||
*/
|
||||
public function __construct($dsn, $username = '', $password = '', $lifetime = 86400)
|
||||
{
|
||||
$this->dsn = $dsn;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->lifetime = (int) $lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null)
|
||||
{
|
||||
if (null === $start) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if (null === $end) {
|
||||
$end = time();
|
||||
}
|
||||
|
||||
list($criteria, $args) = $this->buildCriteria($ip, $url, $start, $end, $limit, $method);
|
||||
|
||||
$criteria = $criteria ? 'WHERE '.implode(' AND ', $criteria) : '';
|
||||
|
||||
$db = $this->initDb();
|
||||
$tokens = $this->fetch($db, 'SELECT token, ip, method, url, time, parent, status_code FROM sf_profiler_data '.$criteria.' ORDER BY time DESC LIMIT '.((int) $limit), $args);
|
||||
$this->close($db);
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($token)
|
||||
{
|
||||
$db = $this->initDb();
|
||||
$args = array(':token' => $token);
|
||||
$data = $this->fetch($db, 'SELECT data, parent, ip, method, url, time FROM sf_profiler_data WHERE token = :token LIMIT 1', $args);
|
||||
$this->close($db);
|
||||
if (isset($data[0]['data'])) {
|
||||
return $this->createProfileFromData($token, $data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(Profile $profile)
|
||||
{
|
||||
$db = $this->initDb();
|
||||
$args = array(
|
||||
':token' => $profile->getToken(),
|
||||
':parent' => $profile->getParentToken(),
|
||||
':data' => base64_encode(serialize($profile->getCollectors())),
|
||||
':ip' => $profile->getIp(),
|
||||
':method' => $profile->getMethod(),
|
||||
':url' => $profile->getUrl(),
|
||||
':time' => $profile->getTime(),
|
||||
':created_at' => time(),
|
||||
':status_code' => $profile->getStatusCode(),
|
||||
);
|
||||
|
||||
try {
|
||||
if ($this->has($profile->getToken())) {
|
||||
$this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at, status_code = :status_code WHERE token = :token', $args);
|
||||
} else {
|
||||
$this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at, status_code) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at, :status_code)', $args);
|
||||
}
|
||||
$this->cleanup();
|
||||
$status = true;
|
||||
} catch (\Exception $e) {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
$this->close($db);
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
$db = $this->initDb();
|
||||
$this->exec($db, 'DELETE FROM sf_profiler_data');
|
||||
$this->close($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build SQL criteria to fetch records by ip and url.
|
||||
*
|
||||
* @param string $ip The IP
|
||||
* @param string $url The URL
|
||||
* @param string $start The start period to search from
|
||||
* @param string $end The end period to search to
|
||||
* @param string $limit The maximum number of tokens to return
|
||||
* @param string $method The request method
|
||||
*
|
||||
* @return array An array with (criteria, args)
|
||||
*/
|
||||
abstract protected function buildCriteria($ip, $url, $start, $end, $limit, $method);
|
||||
|
||||
/**
|
||||
* Initializes the database.
|
||||
*
|
||||
* @throws \RuntimeException When the requested database driver is not installed
|
||||
*/
|
||||
abstract protected function initDb();
|
||||
|
||||
protected function cleanup()
|
||||
{
|
||||
$db = $this->initDb();
|
||||
$this->exec($db, 'DELETE FROM sf_profiler_data WHERE created_at < :time', array(':time' => time() - $this->lifetime));
|
||||
$this->close($db);
|
||||
}
|
||||
|
||||
protected function exec($db, $query, array $args = array())
|
||||
{
|
||||
$stmt = $this->prepareStatement($db, $query);
|
||||
|
||||
foreach ($args as $arg => $val) {
|
||||
$stmt->bindValue($arg, $val, \is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR);
|
||||
}
|
||||
$success = $stmt->execute();
|
||||
if (!$success) {
|
||||
throw new \RuntimeException(sprintf('Error executing query "%s"', $query));
|
||||
}
|
||||
}
|
||||
|
||||
protected function prepareStatement($db, $query)
|
||||
{
|
||||
try {
|
||||
$stmt = $db->prepare($query);
|
||||
} catch (\Exception $e) {
|
||||
$stmt = false;
|
||||
}
|
||||
|
||||
if (false === $stmt) {
|
||||
throw new \RuntimeException('The database cannot successfully prepare the statement');
|
||||
}
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
protected function fetch($db, $query, array $args = array())
|
||||
{
|
||||
$stmt = $this->prepareStatement($db, $query);
|
||||
|
||||
foreach ($args as $arg => $val) {
|
||||
$stmt->bindValue($arg, $val, \is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR);
|
||||
}
|
||||
$stmt->execute();
|
||||
|
||||
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
protected function close($db)
|
||||
{
|
||||
}
|
||||
|
||||
protected function createProfileFromData($token, $data, $parent = null)
|
||||
{
|
||||
$profile = new Profile($token);
|
||||
$profile->setIp($data['ip']);
|
||||
$profile->setMethod($data['method']);
|
||||
$profile->setUrl($data['url']);
|
||||
$profile->setTime($data['time']);
|
||||
$profile->setCollectors(unserialize(base64_decode($data['data'])));
|
||||
|
||||
if (!$parent && !empty($data['parent'])) {
|
||||
$parent = $this->read($data['parent']);
|
||||
}
|
||||
|
||||
if ($parent) {
|
||||
$profile->setParent($parent);
|
||||
}
|
||||
|
||||
$profile->setChildren($this->readChildren($token, $profile));
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the child profiles for the given token.
|
||||
*
|
||||
* @param string $token The parent token
|
||||
* @param string $parent The parent instance
|
||||
*
|
||||
* @return Profile[] An array of Profile instance
|
||||
*/
|
||||
protected function readChildren($token, $parent)
|
||||
{
|
||||
$db = $this->initDb();
|
||||
$data = $this->fetch($db, 'SELECT token, data, ip, method, url, time FROM sf_profiler_data WHERE parent = :token', array(':token' => $token));
|
||||
$this->close($db);
|
||||
|
||||
if (!$data) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$profiles = array();
|
||||
foreach ($data as $d) {
|
||||
$profiles[] = $this->createProfileFromData($d['token'], $d, $parent);
|
||||
}
|
||||
|
||||
return $profiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether data for the given token already exists in storage.
|
||||
*
|
||||
* @param string $token The profile token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function has($token)
|
||||
{
|
||||
$db = $this->initDb();
|
||||
$tokenExists = $this->fetch($db, 'SELECT 1 FROM sf_profiler_data WHERE token = :token LIMIT 1', array(':token' => $token));
|
||||
$this->close($db);
|
||||
|
||||
return !empty($tokenExists);
|
||||
}
|
||||
}
|
||||
@@ -1,395 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\RedisProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* RedisProfilerStorage stores profiling information in Redis.
|
||||
*
|
||||
* @author Andrej Hudec <pulzarraider@gmail.com>
|
||||
* @author Stephane PY <py.stephane1@gmail.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
class RedisProfilerStorage implements ProfilerStorageInterface
|
||||
{
|
||||
const TOKEN_PREFIX = 'sf_profiler_';
|
||||
|
||||
const REDIS_OPT_SERIALIZER = 1;
|
||||
const REDIS_OPT_PREFIX = 2;
|
||||
const REDIS_SERIALIZER_NONE = 0;
|
||||
const REDIS_SERIALIZER_PHP = 1;
|
||||
|
||||
protected $dsn;
|
||||
protected $lifetime;
|
||||
|
||||
/**
|
||||
* @var \Redis
|
||||
*/
|
||||
private $redis;
|
||||
|
||||
/**
|
||||
* @param string $dsn A data source name
|
||||
* @param string $username Not used
|
||||
* @param string $password Not used
|
||||
* @param int $lifetime The lifetime to use for the purge
|
||||
*/
|
||||
public function __construct($dsn, $username = '', $password = '', $lifetime = 86400)
|
||||
{
|
||||
$this->dsn = $dsn;
|
||||
$this->lifetime = (int) $lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null)
|
||||
{
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
if (!$indexContent = $this->getValue($indexName, self::REDIS_SERIALIZER_NONE)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$profileList = array_reverse(explode("\n", $indexContent));
|
||||
$result = array();
|
||||
|
||||
foreach ($profileList as $item) {
|
||||
if (0 === $limit) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ('' == $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = explode("\t", $item, 7);
|
||||
list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = $values;
|
||||
$statusCode = isset($values[6]) ? $values[6] : null;
|
||||
|
||||
$itemTime = (int) $itemTime;
|
||||
|
||||
if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($start) && $itemTime < $start) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($end) && $itemTime > $end) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = array(
|
||||
'token' => $itemToken,
|
||||
'ip' => $itemIp,
|
||||
'method' => $itemMethod,
|
||||
'url' => $itemUrl,
|
||||
'time' => $itemTime,
|
||||
'parent' => $itemParent,
|
||||
'status_code' => $statusCode,
|
||||
);
|
||||
--$limit;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
// delete only items from index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
$indexContent = $this->getValue($indexName, self::REDIS_SERIALIZER_NONE);
|
||||
|
||||
if (!$indexContent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$profileList = explode("\n", $indexContent);
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($profileList as $item) {
|
||||
if ('' == $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false !== $pos = strpos($item, "\t")) {
|
||||
$result[] = $this->getItemName(substr($item, 0, $pos));
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $indexName;
|
||||
|
||||
return $this->delete($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($token)
|
||||
{
|
||||
if (empty($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$profile = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP);
|
||||
|
||||
if (false !== $profile) {
|
||||
$profile = $this->createProfileFromData($token, $profile);
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(Profile $profile)
|
||||
{
|
||||
$data = array(
|
||||
'token' => $profile->getToken(),
|
||||
'parent' => $profile->getParentToken(),
|
||||
'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()),
|
||||
'data' => $profile->getCollectors(),
|
||||
'ip' => $profile->getIp(),
|
||||
'method' => $profile->getMethod(),
|
||||
'url' => $profile->getUrl(),
|
||||
'time' => $profile->getTime(),
|
||||
);
|
||||
|
||||
$profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken()));
|
||||
|
||||
if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, self::REDIS_SERIALIZER_PHP)) {
|
||||
if (!$profileIndexed) {
|
||||
// Add to index
|
||||
$indexName = $this->getIndexName();
|
||||
|
||||
$indexRow = implode("\t", array(
|
||||
$profile->getToken(),
|
||||
$profile->getIp(),
|
||||
$profile->getMethod(),
|
||||
$profile->getUrl(),
|
||||
$profile->getTime(),
|
||||
$profile->getParentToken(),
|
||||
$profile->getStatusCode(),
|
||||
))."\n";
|
||||
|
||||
return $this->appendValue($indexName, $indexRow, $this->lifetime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal convenience method that returns the instance of Redis.
|
||||
*
|
||||
* @return \Redis
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getRedis()
|
||||
{
|
||||
if (null === $this->redis) {
|
||||
$data = parse_url($this->dsn);
|
||||
|
||||
if (false === $data || !isset($data['scheme']) || 'redis' !== $data['scheme'] || !isset($data['host']) || !isset($data['port'])) {
|
||||
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn));
|
||||
}
|
||||
|
||||
if (!\extension_loaded('redis')) {
|
||||
throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.');
|
||||
}
|
||||
|
||||
$redis = new \Redis();
|
||||
$redis->connect($data['host'], $data['port']);
|
||||
|
||||
if (isset($data['path'])) {
|
||||
$redis->select(substr($data['path'], 1));
|
||||
}
|
||||
|
||||
if (isset($data['pass'])) {
|
||||
$redis->auth($data['pass']);
|
||||
}
|
||||
|
||||
$redis->setOption(self::REDIS_OPT_PREFIX, self::TOKEN_PREFIX);
|
||||
|
||||
$this->redis = $redis;
|
||||
}
|
||||
|
||||
return $this->redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set instance of the Redis.
|
||||
*
|
||||
* @param \Redis $redis
|
||||
*/
|
||||
public function setRedis($redis)
|
||||
{
|
||||
$this->redis = $redis;
|
||||
}
|
||||
|
||||
private function createProfileFromData($token, $data, $parent = null)
|
||||
{
|
||||
$profile = new Profile($token);
|
||||
$profile->setIp($data['ip']);
|
||||
$profile->setMethod($data['method']);
|
||||
$profile->setUrl($data['url']);
|
||||
$profile->setTime($data['time']);
|
||||
$profile->setCollectors($data['data']);
|
||||
|
||||
if (!$parent && $data['parent']) {
|
||||
$parent = $this->read($data['parent']);
|
||||
}
|
||||
|
||||
if ($parent) {
|
||||
$profile->setParent($parent);
|
||||
}
|
||||
|
||||
foreach ($data['children'] as $token) {
|
||||
if (!$token) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$childProfileData = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$profile->addChild($this->createProfileFromData($token, $childProfileData, $profile));
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item name.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getItemName($token)
|
||||
{
|
||||
$name = $token;
|
||||
|
||||
if ($this->isItemNameValid($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the index.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getIndexName()
|
||||
{
|
||||
$name = 'index';
|
||||
|
||||
if ($this->isItemNameValid($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isItemNameValid($name)
|
||||
{
|
||||
$length = \strlen($name);
|
||||
|
||||
if ($length > 2147483648) {
|
||||
throw new \RuntimeException(sprintf('The Redis item key "%s" is too long (%s bytes). Allowed maximum size is 2^31 bytes.', $name, $length));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an item from the Redis server.
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $serializer
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getValue($key, $serializer = self::REDIS_SERIALIZER_NONE)
|
||||
{
|
||||
$redis = $this->getRedis();
|
||||
$redis->setOption(self::REDIS_OPT_SERIALIZER, $serializer);
|
||||
|
||||
return $redis->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an item on the Redis server under the specified key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $expiration
|
||||
* @param int $serializer
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function setValue($key, $value, $expiration = 0, $serializer = self::REDIS_SERIALIZER_NONE)
|
||||
{
|
||||
$redis = $this->getRedis();
|
||||
$redis->setOption(self::REDIS_OPT_SERIALIZER, $serializer);
|
||||
|
||||
return $redis->setex($key, $expiration, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends data to an existing item on the Redis server.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param int $expiration
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function appendValue($key, $value, $expiration = 0)
|
||||
{
|
||||
$redis = $this->getRedis();
|
||||
$redis->setOption(self::REDIS_OPT_SERIALIZER, self::REDIS_SERIALIZER_NONE);
|
||||
|
||||
if ($redis->exists($key)) {
|
||||
$redis->append($key, $value);
|
||||
|
||||
return $redis->setTimeout($key, $expiration);
|
||||
}
|
||||
|
||||
return $redis->setex($key, $expiration, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified keys.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function delete(array $keys)
|
||||
{
|
||||
return (bool) $this->getRedis()->delete($keys);
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
<?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\HttpKernel\Profiler;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\SqliteProfilerStorage class is deprecated since Symfony 2.8 and will be removed in 3.0. Use FileProfilerStorage instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* SqliteProfilerStorage stores profiling information in a SQLite database.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0.
|
||||
* Use {@link FileProfilerStorage} instead.
|
||||
*/
|
||||
class SqliteProfilerStorage extends PdoProfilerStorage
|
||||
{
|
||||
/**
|
||||
* @throws \RuntimeException When neither of SQLite3 or PDO_SQLite extension is enabled
|
||||
*/
|
||||
protected function initDb()
|
||||
{
|
||||
if (null === $this->db || $this->db instanceof \SQLite3) {
|
||||
if (0 !== strpos($this->dsn, 'sqlite')) {
|
||||
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Sqlite with an invalid dsn "%s". The expected format is "sqlite:/path/to/the/db/file".', $this->dsn));
|
||||
}
|
||||
if (class_exists('SQLite3')) {
|
||||
$db = new \SQLite3(substr($this->dsn, 7, \strlen($this->dsn)), \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE);
|
||||
if (method_exists($db, 'busyTimeout')) {
|
||||
// busyTimeout only exists for PHP >= 5.3.3
|
||||
$db->busyTimeout(1000);
|
||||
}
|
||||
} elseif (class_exists('PDO') && \in_array('sqlite', \PDO::getAvailableDrivers(), true)) {
|
||||
$db = new \PDO($this->dsn);
|
||||
} else {
|
||||
throw new \RuntimeException('You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.');
|
||||
}
|
||||
|
||||
$db->exec('PRAGMA temp_store=MEMORY; PRAGMA journal_mode=MEMORY;');
|
||||
$db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token STRING, data STRING, ip STRING, method STRING, url STRING, time INTEGER, parent STRING, created_at INTEGER, status_code INTEGER)');
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS data_created_at ON sf_profiler_data (created_at)');
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS data_ip ON sf_profiler_data (ip)');
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS data_method ON sf_profiler_data (method)');
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS data_url ON sf_profiler_data (url)');
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS data_parent ON sf_profiler_data (parent)');
|
||||
$db->exec('CREATE UNIQUE INDEX IF NOT EXISTS data_token ON sf_profiler_data (token)');
|
||||
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
protected function exec($db, $query, array $args = array())
|
||||
{
|
||||
if ($db instanceof \SQLite3) {
|
||||
$stmt = $this->prepareStatement($db, $query);
|
||||
foreach ($args as $arg => $val) {
|
||||
$stmt->bindValue($arg, $val, \is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT);
|
||||
}
|
||||
|
||||
$res = $stmt->execute();
|
||||
if (false === $res) {
|
||||
throw new \RuntimeException(sprintf('Error executing SQLite query "%s"', $query));
|
||||
}
|
||||
$res->finalize();
|
||||
} else {
|
||||
parent::exec($db, $query, $args);
|
||||
}
|
||||
}
|
||||
|
||||
protected function fetch($db, $query, array $args = array())
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if ($db instanceof \SQLite3) {
|
||||
$stmt = $this->prepareStatement($db, $query);
|
||||
foreach ($args as $arg => $val) {
|
||||
$stmt->bindValue($arg, $val, \is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT);
|
||||
}
|
||||
$res = $stmt->execute();
|
||||
while ($row = $res->fetchArray(\SQLITE3_ASSOC)) {
|
||||
$return[] = $row;
|
||||
}
|
||||
$res->finalize();
|
||||
$stmt->close();
|
||||
} else {
|
||||
$return = parent::fetch($db, $query, $args);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildCriteria($ip, $url, $start, $end, $limit, $method)
|
||||
{
|
||||
$criteria = array();
|
||||
$args = array();
|
||||
|
||||
if ($ip = preg_replace('/[^\d\.]/', '', $ip)) {
|
||||
$criteria[] = 'ip LIKE :ip';
|
||||
$args[':ip'] = '%'.$ip.'%';
|
||||
}
|
||||
|
||||
if ($url) {
|
||||
$criteria[] = 'url LIKE :url ESCAPE "\"';
|
||||
$args[':url'] = '%'.addcslashes($url, '%_\\').'%';
|
||||
}
|
||||
|
||||
if ($method) {
|
||||
$criteria[] = 'method = :method';
|
||||
$args[':method'] = $method;
|
||||
}
|
||||
|
||||
if (!empty($start)) {
|
||||
$criteria[] = 'time >= :start';
|
||||
$args[':start'] = $start;
|
||||
}
|
||||
|
||||
if (!empty($end)) {
|
||||
$criteria[] = 'time <= :end';
|
||||
$args[':end'] = $end;
|
||||
}
|
||||
|
||||
return array($criteria, $args);
|
||||
}
|
||||
|
||||
protected function close($db)
|
||||
{
|
||||
if ($db instanceof \SQLite3) {
|
||||
$db->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
vendor/symfony/polyfill-php54/LICENSE
vendored
19
vendor/symfony/polyfill-php54/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2015-2019 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
36
vendor/symfony/polyfill-php54/Php54.php
vendored
36
vendor/symfony/polyfill-php54/Php54.php
vendored
@@ -1,36 +0,0 @@
|
||||
<?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\Polyfill\Php54;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class Php54
|
||||
{
|
||||
public static function hex2bin($data)
|
||||
{
|
||||
$len = \strlen($data);
|
||||
|
||||
if (null === $len) {
|
||||
return;
|
||||
}
|
||||
if ($len % 2) {
|
||||
trigger_error('hex2bin(): Hexadecimal input string must have an even length', E_USER_WARNING);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return pack('H*', $data);
|
||||
}
|
||||
}
|
||||
17
vendor/symfony/polyfill-php54/README.md
vendored
17
vendor/symfony/polyfill-php54/README.md
vendored
@@ -1,17 +0,0 @@
|
||||
Symfony Polyfill / Php54
|
||||
========================
|
||||
|
||||
This component provides functions unavailable in releases prior to PHP 5.4:
|
||||
|
||||
- [`trait_exists`](http://php.net/trait_exists)
|
||||
- [`class_uses`](http://php.net/class_uses)
|
||||
- [`hex2bin`](http://php.net/hex2bin)
|
||||
- [`session_register_shutdown`](http://php.net/session_register_shutdown)
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
class CallbackFilterIterator extends FilterIterator
|
||||
{
|
||||
private $iterator;
|
||||
private $callback;
|
||||
|
||||
public function __construct(Iterator $iterator, $callback)
|
||||
{
|
||||
$this->iterator = $iterator;
|
||||
$this->callback = $callback;
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
public function accept()
|
||||
{
|
||||
return call_user_func($this->callback, $this->current(), $this->key(), $this->iterator);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
class RecursiveCallbackFilterIterator extends CallbackFilterIterator implements RecursiveIterator
|
||||
{
|
||||
private $iterator;
|
||||
private $callback;
|
||||
|
||||
public function __construct(RecursiveIterator $iterator, $callback)
|
||||
{
|
||||
$this->iterator = $iterator;
|
||||
$this->callback = $callback;
|
||||
parent::__construct($iterator, $callback);
|
||||
}
|
||||
|
||||
public function hasChildren()
|
||||
{
|
||||
return $this->iterator->hasChildren();
|
||||
}
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
return new static($this->iterator->getChildren(), $this->callback);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SessionHandlerInterface for PHP < 5.4.
|
||||
*
|
||||
* The order in which these methods are invoked by PHP are:
|
||||
* 1. open [session_start]
|
||||
* 2. read
|
||||
* 3. gc [optional depending on probability settings: gc_probability / gc_divisor]
|
||||
* 4. destroy [optional when session_regenerate_id(true) is used]
|
||||
* 5. write [session_write_close] or destroy [session_destroy]
|
||||
* 6. close
|
||||
*
|
||||
* Extensive documentation can be found at php.net, see links:
|
||||
*
|
||||
* @see http://php.net/sessionhandlerinterface
|
||||
* @see http://php.net/session.customhandler
|
||||
* @see http://php.net/session-set-save-handler
|
||||
*
|
||||
* @author Drak <drak@zikula.org>
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
*/
|
||||
interface SessionHandlerInterface
|
||||
{
|
||||
/**
|
||||
* Re-initializes existing session, or creates a new one.
|
||||
*
|
||||
* @see http://php.net/sessionhandlerinterface.open
|
||||
*
|
||||
* @param string $savePath Save path
|
||||
* @param string $sessionName Session name, see http://php.net/function.session-name.php
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function open($savePath, $sessionName);
|
||||
|
||||
/**
|
||||
* Closes the current session.
|
||||
*
|
||||
* @see http://php.net/sessionhandlerinterface.close
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function close();
|
||||
|
||||
/**
|
||||
* Reads the session data.
|
||||
*
|
||||
* @see http://php.net/sessionhandlerinterface.read
|
||||
*
|
||||
* @param string $sessionId Session ID, see http://php.net/function.session-id
|
||||
*
|
||||
* @return string Same session data as passed in write() or empty string when non-existent or on failure
|
||||
*/
|
||||
public function read($sessionId);
|
||||
|
||||
/**
|
||||
* Writes the session data to the storage.
|
||||
*
|
||||
* Care, the session ID passed to write() can be different from the one previously
|
||||
* received in read() when the session ID changed due to session_regenerate_id().
|
||||
*
|
||||
* @see http://php.net/sessionhandlerinterface.write
|
||||
*
|
||||
* @param string $sessionId Session ID , see http://php.net/function.session-id
|
||||
* @param string $data Serialized session data to save
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function write($sessionId, $data);
|
||||
|
||||
/**
|
||||
* Destroys a session.
|
||||
*
|
||||
* @see http://php.net/sessionhandlerinterface.destroy
|
||||
*
|
||||
* @param string $sessionId Session ID, see http://php.net/function.session-id
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function destroy($sessionId);
|
||||
|
||||
/**
|
||||
* Cleans up expired sessions (garbage collection).
|
||||
*
|
||||
* @see http://php.net/sessionhandlerinterface.gc
|
||||
*
|
||||
* @param string|int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function gc($maxlifetime);
|
||||
}
|
||||
34
vendor/symfony/polyfill-php54/bootstrap.php
vendored
34
vendor/symfony/polyfill-php54/bootstrap.php
vendored
@@ -1,34 +0,0 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Polyfill\Php54 as p;
|
||||
|
||||
if (PHP_VERSION_ID < 50400) {
|
||||
if (!function_exists('trait_exists')) {
|
||||
function trait_exists($class, $autoload = true) { return $autoload && \class_exists($class, $autoload) && false; }
|
||||
}
|
||||
if (!function_exists('class_uses')) {
|
||||
function class_uses($class, $autoload = true)
|
||||
{
|
||||
if (\is_object($class) || \class_exists($class, $autoload) || \interface_exists($class, false)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!function_exists('hex2bin')) {
|
||||
function hex2bin($data) { return p\Php54::hex2bin($data); }
|
||||
}
|
||||
if (!function_exists('session_register_shutdown')) {
|
||||
function session_register_shutdown() { register_shutdown_function('session_write_close'); }
|
||||
}
|
||||
}
|
||||
32
vendor/symfony/polyfill-php54/composer.json
vendored
32
vendor/symfony/polyfill-php54/composer.json
vendored
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"name": "symfony/polyfill-php54",
|
||||
"type": "library",
|
||||
"description": "Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions",
|
||||
"keywords": ["polyfill", "shim", "compatibility", "portable"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Polyfill\\Php54\\": "" },
|
||||
"files": [ "bootstrap.php" ],
|
||||
"classmap": [ "Resources/stubs" ]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.11-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
19
vendor/symfony/polyfill-php55/LICENSE
vendored
19
vendor/symfony/polyfill-php55/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2015-2019 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
89
vendor/symfony/polyfill-php55/Php55.php
vendored
89
vendor/symfony/polyfill-php55/Php55.php
vendored
@@ -1,89 +0,0 @@
|
||||
<?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\Polyfill\Php55;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Php55
|
||||
{
|
||||
public static function boolval($val)
|
||||
{
|
||||
return (bool) $val;
|
||||
}
|
||||
|
||||
public static function json_last_error_msg()
|
||||
{
|
||||
switch (json_last_error()) {
|
||||
case JSON_ERROR_NONE: return 'No error';
|
||||
case JSON_ERROR_DEPTH: return 'Maximum stack depth exceeded';
|
||||
case JSON_ERROR_STATE_MISMATCH: return 'State mismatch (invalid or malformed JSON)';
|
||||
case JSON_ERROR_CTRL_CHAR: return 'Control character error, possibly incorrectly encoded';
|
||||
case JSON_ERROR_SYNTAX: return 'Syntax error';
|
||||
case JSON_ERROR_UTF8: return 'Malformed UTF-8 characters, possibly incorrectly encoded';
|
||||
default: return 'Unknown error';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
|
||||
* @author Scott <scott@paragonie.com>
|
||||
*/
|
||||
public static function hash_pbkdf2($algorithm, $password, $salt, $iterations, $length = 0, $rawOutput = false)
|
||||
{
|
||||
// Pre-hash for optimization if password length > hash length
|
||||
$hashLength = \strlen(hash($algorithm, '', true));
|
||||
switch ($algorithm) {
|
||||
case 'sha224':
|
||||
case 'sha256':
|
||||
$blockSize = 64;
|
||||
break;
|
||||
case 'sha384':
|
||||
case 'sha512':
|
||||
$blockSize = 128;
|
||||
break;
|
||||
default:
|
||||
$blockSize = $hashLength;
|
||||
break;
|
||||
}
|
||||
if ($length < 1) {
|
||||
$length = $hashLength;
|
||||
if (!$rawOutput) {
|
||||
$length <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Number of blocks needed to create the derived key
|
||||
$blocks = ceil($length / $hashLength);
|
||||
$digest = '';
|
||||
if (\strlen($password) > $blockSize) {
|
||||
$password = hash($algorithm, $password, true);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $blocks; ++$i) {
|
||||
$ib = $block = hash_hmac($algorithm, $salt.pack('N', $i), $password, true);
|
||||
|
||||
// Iterations
|
||||
for ($j = 1; $j < $iterations; ++$j) {
|
||||
$ib ^= ($block = hash_hmac($algorithm, $block, $password, true));
|
||||
}
|
||||
|
||||
$digest .= $ib;
|
||||
}
|
||||
|
||||
if (!$rawOutput) {
|
||||
$digest = bin2hex($digest);
|
||||
}
|
||||
|
||||
return substr($digest, 0, $length);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Ben Ramsey <http://benramsey.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Php55;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Php55ArrayColumn
|
||||
{
|
||||
public static function array_column(array $input, $columnKey, $indexKey = null)
|
||||
{
|
||||
$output = array();
|
||||
|
||||
foreach ($input as $row) {
|
||||
$key = $value = null;
|
||||
$keySet = $valueSet = false;
|
||||
|
||||
if (null !== $indexKey && array_key_exists($indexKey, $row)) {
|
||||
$keySet = true;
|
||||
$key = (string) $row[$indexKey];
|
||||
}
|
||||
|
||||
if (null === $columnKey) {
|
||||
$valueSet = true;
|
||||
$value = $row;
|
||||
} elseif (\is_array($row) && \array_key_exists($columnKey, $row)) {
|
||||
$valueSet = true;
|
||||
$value = $row[$columnKey];
|
||||
}
|
||||
|
||||
if ($valueSet) {
|
||||
if ($keySet) {
|
||||
$output[$key] = $value;
|
||||
} else {
|
||||
$output[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
18
vendor/symfony/polyfill-php55/README.md
vendored
18
vendor/symfony/polyfill-php55/README.md
vendored
@@ -1,18 +0,0 @@
|
||||
Symfony Polyfill / Php55
|
||||
========================
|
||||
|
||||
This component provides functions unavailable in releases prior to PHP 5.5:
|
||||
|
||||
- [`boolval`](http://php.net/boolval)
|
||||
- [`json_last_error_msg`](http://php.net/json_last_error_msg)
|
||||
- [`array_column`](http://php.net/array_column)
|
||||
- [`hash_pbkdf2`](http://php.net/hash_pbkdf2)
|
||||
- `password_*` functions (from [ircmaxell/password_compat](https://github.com/ircmaxell/password_compat))
|
||||
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
27
vendor/symfony/polyfill-php55/bootstrap.php
vendored
27
vendor/symfony/polyfill-php55/bootstrap.php
vendored
@@ -1,27 +0,0 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Polyfill\Php55 as p;
|
||||
|
||||
if (PHP_VERSION_ID < 50500) {
|
||||
if (!function_exists('boolval')) {
|
||||
function boolval($val) { return p\Php55::boolval($val); }
|
||||
}
|
||||
if (!function_exists('json_last_error_msg')) {
|
||||
function json_last_error_msg() { return p\Php55::json_last_error_msg(); }
|
||||
}
|
||||
if (!function_exists('array_column')) {
|
||||
function array_column($array, $columnKey, $indexKey = null) { return p\Php55ArrayColumn::array_column($array, $columnKey, $indexKey); }
|
||||
}
|
||||
if (!function_exists('hash_pbkdf2')) {
|
||||
function hash_pbkdf2($algorithm, $password, $salt, $iterations, $length = 0, $rawOutput = false) { return p\Php55::hash_pbkdf2($algorithm, $password, $salt, $iterations, $length, $rawOutput); }
|
||||
}
|
||||
}
|
||||
32
vendor/symfony/polyfill-php55/composer.json
vendored
32
vendor/symfony/polyfill-php55/composer.json
vendored
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"name": "symfony/polyfill-php55",
|
||||
"type": "library",
|
||||
"description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions",
|
||||
"keywords": ["polyfill", "shim", "compatibility", "portable"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"ircmaxell/password-compat": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Polyfill\\Php55\\": "" },
|
||||
"files": [ "bootstrap.php" ]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.11-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
124
vendor/symfony/routing/Matcher/ApacheUrlMatcher.php
vendored
124
vendor/symfony/routing/Matcher/ApacheUrlMatcher.php
vendored
@@ -1,124 +0,0 @@
|
||||
<?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\Routing\Matcher;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ApacheUrlMatcher class is deprecated since Symfony 2.5 and will be removed in 3.0. It\'s hard to replicate the behaviour of the PHP implementation and the performance gains are minimal.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
|
||||
/**
|
||||
* ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper).
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0.
|
||||
* The performance gains are minimal and it's very hard to replicate
|
||||
* the behavior of PHP implementation.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
||||
*/
|
||||
class ApacheUrlMatcher extends UrlMatcher
|
||||
{
|
||||
/**
|
||||
* Tries to match a URL based on Apache mod_rewrite matching.
|
||||
*
|
||||
* Returns false if no route matches the URL.
|
||||
*
|
||||
* @param string $pathinfo The pathinfo to be parsed
|
||||
*
|
||||
* @return array An array of parameters
|
||||
*
|
||||
* @throws MethodNotAllowedException If the current method is not allowed
|
||||
*/
|
||||
public function match($pathinfo)
|
||||
{
|
||||
$parameters = array();
|
||||
$defaults = array();
|
||||
$allow = array();
|
||||
$route = null;
|
||||
|
||||
foreach ($this->denormalizeValues($_SERVER) as $key => $value) {
|
||||
$name = $key;
|
||||
|
||||
// skip non-routing variables
|
||||
// this improves performance when $_SERVER contains many usual
|
||||
// variables like HTTP_*, DOCUMENT_ROOT, REQUEST_URI, ...
|
||||
if (false === strpos($name, '_ROUTING_')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (0 === strpos($name, 'REDIRECT_')) {
|
||||
$name = substr($name, 9);
|
||||
}
|
||||
|
||||
// expect _ROUTING_<type>_<name>
|
||||
// or _ROUTING_<type>
|
||||
|
||||
if (0 !== strpos($name, '_ROUTING_')) {
|
||||
continue;
|
||||
}
|
||||
if (false !== $pos = strpos($name, '_', 9)) {
|
||||
$type = substr($name, 9, $pos - 9);
|
||||
$name = substr($name, $pos + 1);
|
||||
} else {
|
||||
$type = substr($name, 9);
|
||||
}
|
||||
|
||||
if ('param' === $type) {
|
||||
if ('' !== $value) {
|
||||
$parameters[$name] = $value;
|
||||
}
|
||||
} elseif ('default' === $type) {
|
||||
$defaults[$name] = $value;
|
||||
} elseif ('route' === $type) {
|
||||
$route = $value;
|
||||
} elseif ('allow' === $type) {
|
||||
$allow[] = $name;
|
||||
}
|
||||
|
||||
unset($_SERVER[$key]);
|
||||
}
|
||||
|
||||
if (null !== $route) {
|
||||
$parameters['_route'] = $route;
|
||||
|
||||
return $this->mergeDefaults($parameters, $defaults);
|
||||
} elseif (0 < \count($allow)) {
|
||||
throw new MethodNotAllowedException($allow);
|
||||
} else {
|
||||
return parent::match($pathinfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Denormalizes an array of values.
|
||||
*
|
||||
* @param string[] $values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function denormalizeValues(array $values)
|
||||
{
|
||||
$normalizedValues = array();
|
||||
foreach ($values as $key => $value) {
|
||||
if (preg_match('~^(.*)\[(\d+)\]$~', $key, $matches)) {
|
||||
if (!isset($normalizedValues[$matches[1]])) {
|
||||
$normalizedValues[$matches[1]] = array();
|
||||
}
|
||||
$normalizedValues[$matches[1]][(int) $matches[2]] = $value;
|
||||
} else {
|
||||
$normalizedValues[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $normalizedValues;
|
||||
}
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
<?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\Routing\Matcher\Dumper;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\ApacheMatcherDumper class is deprecated since Symfony 2.5 and will be removed in 3.0. It\'s hard to replicate the behaviour of the PHP implementation and the performance gains are minimal.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Dumps a set of Apache mod_rewrite rules.
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0.
|
||||
* The performance gains are minimal and it's very hard to replicate
|
||||
* the behavior of PHP implementation.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
class ApacheMatcherDumper extends MatcherDumper
|
||||
{
|
||||
/**
|
||||
* Dumps a set of Apache mod_rewrite rules.
|
||||
*
|
||||
* Available options:
|
||||
*
|
||||
* * script_name: The script name (app.php by default)
|
||||
* * base_uri: The base URI ("" by default)
|
||||
*
|
||||
* @return string A string to be used as Apache rewrite rules
|
||||
*
|
||||
* @throws \LogicException When the route regex is invalid
|
||||
*/
|
||||
public function dump(array $options = array())
|
||||
{
|
||||
$options = array_merge(array(
|
||||
'script_name' => 'app.php',
|
||||
'base_uri' => '',
|
||||
), $options);
|
||||
|
||||
$options['script_name'] = self::escape($options['script_name'], ' ', '\\');
|
||||
|
||||
$rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]");
|
||||
$methodVars = array();
|
||||
$hostRegexUnique = 0;
|
||||
$prevHostRegex = '';
|
||||
|
||||
foreach ($this->getRoutes()->all() as $name => $route) {
|
||||
if ($route->getCondition()) {
|
||||
throw new \LogicException(sprintf('Unable to dump the routes for Apache as route "%s" has a condition.', $name));
|
||||
}
|
||||
|
||||
$compiledRoute = $route->compile();
|
||||
$hostRegex = $compiledRoute->getHostRegex();
|
||||
|
||||
if (null !== $hostRegex && $prevHostRegex !== $hostRegex) {
|
||||
$prevHostRegex = $hostRegex;
|
||||
++$hostRegexUnique;
|
||||
|
||||
$rule = array();
|
||||
|
||||
$regex = $this->regexToApacheRegex($hostRegex);
|
||||
$regex = self::escape($regex, ' ', '\\');
|
||||
|
||||
$rule[] = sprintf('RewriteCond %%{HTTP:Host} %s', $regex);
|
||||
|
||||
$variables = array();
|
||||
$variables[] = sprintf('E=__ROUTING_host_%s:1', $hostRegexUnique);
|
||||
|
||||
foreach ($compiledRoute->getHostVariables() as $i => $variable) {
|
||||
$variables[] = sprintf('E=__ROUTING_host_%s_%s:%%%d', $hostRegexUnique, $variable, $i + 1);
|
||||
}
|
||||
|
||||
$variables = implode(',', $variables);
|
||||
|
||||
$rule[] = sprintf('RewriteRule .? - [%s]', $variables);
|
||||
|
||||
$rules[] = implode("\n", $rule);
|
||||
}
|
||||
|
||||
$rules[] = $this->dumpRoute($name, $route, $options, $hostRegexUnique);
|
||||
|
||||
$methodVars = array_merge($methodVars, $route->getMethods());
|
||||
}
|
||||
if (0 < \count($methodVars)) {
|
||||
$rule = array('# 405 Method Not Allowed');
|
||||
$methodVars = array_values(array_unique($methodVars));
|
||||
if (\in_array('GET', $methodVars) && !\in_array('HEAD', $methodVars)) {
|
||||
$methodVars[] = 'HEAD';
|
||||
}
|
||||
foreach ($methodVars as $i => $methodVar) {
|
||||
$rule[] = sprintf('RewriteCond %%{ENV:_ROUTING__allow_%s} =1%s', $methodVar, isset($methodVars[$i + 1]) ? ' [OR]' : '');
|
||||
}
|
||||
$rule[] = sprintf('RewriteRule .* %s [QSA,L]', $options['script_name']);
|
||||
|
||||
$rules[] = implode("\n", $rule);
|
||||
}
|
||||
|
||||
return implode("\n\n", $rules)."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps a single route.
|
||||
*
|
||||
* @param string $name Route name
|
||||
* @param Route $route The route
|
||||
* @param array $options Options
|
||||
* @param bool $hostRegexUnique Unique identifier for the host regex
|
||||
*
|
||||
* @return string The compiled route
|
||||
*/
|
||||
private function dumpRoute($name, $route, array $options, $hostRegexUnique)
|
||||
{
|
||||
$compiledRoute = $route->compile();
|
||||
|
||||
// prepare the apache regex
|
||||
$regex = $this->regexToApacheRegex($compiledRoute->getRegex());
|
||||
$regex = '^'.self::escape(preg_quote($options['base_uri']).substr($regex, 1), ' ', '\\');
|
||||
|
||||
$methods = $this->getRouteMethods($route);
|
||||
|
||||
$hasTrailingSlash = (!$methods || \in_array('HEAD', $methods)) && '/$' === substr($regex, -2) && '^/$' !== $regex;
|
||||
|
||||
$variables = array('E=_ROUTING_route:'.$name);
|
||||
foreach ($compiledRoute->getHostVariables() as $variable) {
|
||||
$variables[] = sprintf('E=_ROUTING_param_%s:%%{ENV:__ROUTING_host_%s_%s}', $variable, $hostRegexUnique, $variable);
|
||||
}
|
||||
foreach ($compiledRoute->getPathVariables() as $i => $variable) {
|
||||
$variables[] = 'E=_ROUTING_param_'.$variable.':%'.($i + 1);
|
||||
}
|
||||
foreach ($this->normalizeValues($route->getDefaults()) as $key => $value) {
|
||||
$variables[] = 'E=_ROUTING_default_'.$key.':'.strtr($value, array(
|
||||
':' => '\\:',
|
||||
'=' => '\\=',
|
||||
'\\' => '\\\\',
|
||||
' ' => '\\ ',
|
||||
));
|
||||
}
|
||||
$variables = implode(',', $variables);
|
||||
|
||||
$rule = array("# $name");
|
||||
|
||||
// method mismatch
|
||||
if (0 < \count($methods)) {
|
||||
$allow = array();
|
||||
foreach ($methods as $method) {
|
||||
$allow[] = 'E=_ROUTING_allow_'.$method.':1';
|
||||
}
|
||||
|
||||
if ($compiledRoute->getHostRegex()) {
|
||||
$rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique);
|
||||
}
|
||||
|
||||
$rule[] = "RewriteCond %{REQUEST_URI} $regex";
|
||||
$rule[] = sprintf('RewriteCond %%{REQUEST_METHOD} !^(%s)$ [NC]', implode('|', $methods));
|
||||
$rule[] = sprintf('RewriteRule .* - [S=%d,%s]', $hasTrailingSlash ? 2 : 1, implode(',', $allow));
|
||||
}
|
||||
|
||||
// redirect with trailing slash appended
|
||||
if ($hasTrailingSlash) {
|
||||
if ($compiledRoute->getHostRegex()) {
|
||||
$rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique);
|
||||
}
|
||||
|
||||
$rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$';
|
||||
$rule[] = 'RewriteRule .* $0/ [QSA,L,R=301]';
|
||||
}
|
||||
|
||||
// the main rule
|
||||
|
||||
if ($compiledRoute->getHostRegex()) {
|
||||
$rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique);
|
||||
}
|
||||
|
||||
$rule[] = "RewriteCond %{REQUEST_URI} $regex";
|
||||
$rule[] = "RewriteRule .* {$options['script_name']} [QSA,L,$variables]";
|
||||
|
||||
return implode("\n", $rule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns methods allowed for a route.
|
||||
*
|
||||
* @return array The methods
|
||||
*/
|
||||
private function getRouteMethods(Route $route)
|
||||
{
|
||||
$methods = $route->getMethods();
|
||||
|
||||
// GET and HEAD are equivalent
|
||||
if (\in_array('GET', $methods) && !\in_array('HEAD', $methods)) {
|
||||
$methods[] = 'HEAD';
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a regex to make it suitable for mod_rewrite.
|
||||
*
|
||||
* @param string $regex The regex
|
||||
*
|
||||
* @return string The converted regex
|
||||
*/
|
||||
private function regexToApacheRegex($regex)
|
||||
{
|
||||
$regexPatternEnd = strrpos($regex, $regex[0]);
|
||||
|
||||
return preg_replace('/\?P<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a string.
|
||||
*
|
||||
* @param string $string The string to be escaped
|
||||
* @param string $char The character to be escaped
|
||||
* @param string $with The character to be used for escaping
|
||||
*
|
||||
* @return string The escaped string
|
||||
*/
|
||||
private static function escape($string, $char, $with)
|
||||
{
|
||||
$escaped = false;
|
||||
$output = '';
|
||||
foreach (str_split($string) as $symbol) {
|
||||
if ($escaped) {
|
||||
$output .= $symbol;
|
||||
$escaped = false;
|
||||
continue;
|
||||
}
|
||||
if ($symbol === $char) {
|
||||
$output .= $with.$char;
|
||||
continue;
|
||||
}
|
||||
if ($symbol === $with) {
|
||||
$escaped = true;
|
||||
}
|
||||
$output .= $symbol;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes an array of values.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function normalizeValues(array $values)
|
||||
{
|
||||
$normalizedValues = array();
|
||||
foreach ($values as $key => $value) {
|
||||
if (\is_array($value)) {
|
||||
foreach ($value as $index => $bit) {
|
||||
$normalizedValues[sprintf('%s[%s]', $key, $index)] = $bit;
|
||||
}
|
||||
} else {
|
||||
$normalizedValues[$key] = (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $normalizedValues;
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
<?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\Routing\Matcher\Dumper;
|
||||
|
||||
/**
|
||||
* Prefix tree of routes preserving routes order.
|
||||
*
|
||||
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DumperPrefixCollection extends DumperCollection
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $prefix = '';
|
||||
|
||||
/**
|
||||
* Returns the prefix.
|
||||
*
|
||||
* @return string The prefix
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
*/
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route in the tree.
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function addPrefixRoute(DumperRoute $route)
|
||||
{
|
||||
$prefix = $route->getRoute()->compile()->getStaticPrefix();
|
||||
|
||||
for ($collection = $this; null !== $collection; $collection = $collection->getParent()) {
|
||||
// Same prefix, add to current leave
|
||||
if ($collection->prefix === $prefix) {
|
||||
$collection->add($route);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
// Prefix starts with route's prefix
|
||||
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
|
||||
$child = new self();
|
||||
$child->setPrefix(substr($prefix, 0, \strlen($collection->prefix) + 1));
|
||||
$collection->add($child);
|
||||
|
||||
return $child->addPrefixRoute($route);
|
||||
}
|
||||
}
|
||||
|
||||
// Reached only if the root has a non empty prefix
|
||||
throw new \LogicException('The collection root must not have a prefix');
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges nodes whose prefix ends with a slash.
|
||||
*
|
||||
* Children of a node whose prefix ends with a slash are moved to the parent node
|
||||
*/
|
||||
public function mergeSlashNodes()
|
||||
{
|
||||
$children = array();
|
||||
|
||||
foreach ($this as $child) {
|
||||
if ($child instanceof self) {
|
||||
$child->mergeSlashNodes();
|
||||
if ('/' === substr($child->prefix, -1)) {
|
||||
$children = array_merge($children, $child->all());
|
||||
} else {
|
||||
$children[] = $child;
|
||||
}
|
||||
} else {
|
||||
$children[] = $child;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setAll($children);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?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\Bridge\Twig\Node;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0. Use the helper "form_start()" instead.
|
||||
*/
|
||||
class FormEnctypeNode extends SearchAndRenderBlockNode
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user