forked from phalcon/phalcon-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request phalcon#1120 from phalcon/3.2.x
3.2.6
- Loading branch information
Showing
24 changed files
with
1,260 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Developer Tools | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Sergii Svyrydenko <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Console; | ||
|
||
/** | ||
* \Phalcon\Utils\OptionParserTrait | ||
* | ||
* Parsing CLI options | ||
* | ||
* @package Phalcon\Utils | ||
* @copyright Copyright (c) 2011-2017 Phalcon Team ([email protected]) | ||
* @license New BSD License | ||
*/ | ||
trait OptionParserTrait | ||
{ | ||
/** | ||
* Get prefix from the option | ||
* | ||
* @param string $prefix | ||
* @param mixed $prefixEnd | ||
* | ||
* @return mixed | ||
*/ | ||
public function getPrefixOption($prefix, $prefixEnd = '*') | ||
{ | ||
if (substr($prefix, -1) != $prefixEnd) { | ||
return ''; | ||
} | ||
|
||
return substr($prefix, 0, -1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
|
||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Developer Tools | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Sergii Svyrydenko <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Console; | ||
|
||
use Phalcon\Console\OptionParserTrait; | ||
|
||
/** | ||
* Phalcon\Console\OptionStack | ||
* | ||
* CLI options | ||
* | ||
* @package Phalcon\Console; | ||
* @copyright Copyright (c) 2011-2017 Phalcon Team ([email protected]) | ||
* @license New BSD License | ||
*/ | ||
class OptionStack | ||
{ | ||
use OptionParserTrait; | ||
|
||
/** | ||
* Parameters received by the script. | ||
* @var array | ||
*/ | ||
protected $options = []; | ||
|
||
/** | ||
* Set recieved options | ||
* | ||
* @param array $options | ||
*/ | ||
public function setOptions(array $options) | ||
{ | ||
$this->options = array_merge($this->options, $options); | ||
} | ||
|
||
/** | ||
* Add option to array | ||
* | ||
* @param mixed $key | ||
* @param mixed $option | ||
* @param mixed $defaultValue | ||
*/ | ||
public function setOption($key, $option, $defaultValue = '') | ||
{ | ||
if (!empty($option)) { | ||
$this->options[$key] = $option; | ||
|
||
return; | ||
} | ||
|
||
$this->options[$key] = $defaultValue; | ||
} | ||
|
||
/** | ||
* Set option if value isn't exist | ||
* | ||
* @param string $key | ||
* @param mixed $defaultValue | ||
*/ | ||
public function setDefaultOption($key, $defaultValue) | ||
{ | ||
if (!isset($this->options[$key])) { | ||
$this->options[$key] = $defaultValue; | ||
} | ||
} | ||
|
||
/** | ||
* Get recieved options | ||
* | ||
* @return mixed | ||
*/ | ||
public function getOptions() | ||
{ | ||
return $this->options; | ||
} | ||
|
||
/** | ||
* Get option | ||
* @param string $key | ||
* | ||
* @return mixed | ||
*/ | ||
public function getOption($key) | ||
{ | ||
if (!isset($this->options[$key])) { | ||
return ''; | ||
} | ||
|
||
return $this->options[$key]; | ||
} | ||
|
||
/** | ||
* Get option if existence or get default option | ||
* | ||
* @param string $key | ||
* @param mixed $defaultOption | ||
* | ||
* @return mixed | ||
*/ | ||
public function getValidOption($key, $defaultOption = '') | ||
{ | ||
if (isset($this->options[$key])) { | ||
return $this->options[$key]; | ||
} | ||
|
||
return $defaultOption; | ||
} | ||
|
||
/** | ||
* Count options | ||
* | ||
* @return integer | ||
*/ | ||
public function countOptions() | ||
{ | ||
return count($this->options); | ||
} | ||
|
||
/** | ||
* Indicates whether the script was a particular option. | ||
* | ||
* @param string $key | ||
* @return boolean | ||
*/ | ||
public function isReceivedOption($key) | ||
{ | ||
return isset($this->options[$key]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Developer Tools | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Sergii Svyrydenko <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Listeners; | ||
|
||
use Phalcon\Mvc\Model\Migration\Profiler; | ||
use Phalcon\Events\Event; | ||
|
||
/** | ||
* Phalcon\Listeners\DbProfilerListener | ||
* | ||
* Db event listener | ||
* | ||
* @package Phalcon\Listeners | ||
*/ | ||
class DbProfilerListener | ||
{ | ||
protected $_profiler; | ||
|
||
public function __construct() | ||
{ | ||
$this->_profiler = new Profiler(); | ||
} | ||
|
||
public function beforeQuery(Event $event, $connection) | ||
{ | ||
$this->_profiler->startProfile( | ||
$connection->getSQLStatement() | ||
); | ||
} | ||
|
||
public function afterQuery() | ||
{ | ||
$this->_profiler->stopProfile(); | ||
} | ||
} |
Oops, something went wrong.