mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 07:18:39 +00:00
Add comments
This commit is contained in:
parent
95a38e5e6d
commit
3631e4918f
|
|
@ -32,8 +32,6 @@ use phpOMS\Pattern\Mediator;
|
||||||
*/
|
*/
|
||||||
class EventManager implements Mediator
|
class EventManager implements Mediator
|
||||||
{
|
{
|
||||||
const DELIM = ':';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Events.
|
* Events.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,9 @@ class Http implements UriInterface
|
||||||
return $this->path ?? '';
|
return $this->path ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function getRoute() : string
|
public function getRoute() : string
|
||||||
{
|
{
|
||||||
return ($this->path ?? '') . '?' . $this->getQuery();
|
return ($this->path ?? '') . '?' . $this->getQuery();
|
||||||
|
|
|
||||||
|
|
@ -87,27 +87,39 @@ class UriFactory
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simplify url
|
||||||
|
*
|
||||||
|
* While adding, and removing elements to a uri it can have multiple parameters or empty parameters which need to be cleaned up
|
||||||
|
*
|
||||||
|
* @param string $url Url to simplify
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
private static function unique(string $url) : string
|
private static function unique(string $url) : string
|
||||||
{
|
{
|
||||||
$parts = explode('?', $url);
|
$parts = explode('?', $url);
|
||||||
|
|
||||||
if (count($parts) >= 2) {
|
if (count($parts) >= 2) {
|
||||||
$full = $parts[1];
|
$full = $parts[1];
|
||||||
$pars = explode('&', $full);
|
$pars = explode('&', $full);
|
||||||
$comps = [];
|
$comps = [];
|
||||||
$spl = null;
|
$spl = null;
|
||||||
$length = count($pars);
|
$length = count($pars);
|
||||||
|
|
||||||
for ($i = 0; $i < $length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
$spl = explode('=', $pars[$i]);
|
$spl = explode('=', $pars[$i]);
|
||||||
|
|
||||||
if(isset($spl[1])) {
|
if (isset($spl[1])) {
|
||||||
$comps[$spl[0]] = $spl[1];
|
$comps[$spl[0]] = $spl[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pars = [];
|
$pars = [];
|
||||||
foreach($comps as $key => $value) {
|
foreach ($comps as $key => $value) {
|
||||||
$pars[] = $key . '=' . $value;
|
$pars[] = $key . '=' . $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,7 +158,7 @@ class UriFactory
|
||||||
}, $uri);
|
}, $uri);
|
||||||
|
|
||||||
// todo: maybe don't do this and adjust unique?!
|
// todo: maybe don't do this and adjust unique?!
|
||||||
if(strpos($parsed, '?')) {
|
if (strpos($parsed, '?')) {
|
||||||
str_replace('&', '?', $parsed);
|
str_replace('&', '?', $parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,16 @@ interface UriInterface
|
||||||
*/
|
*/
|
||||||
public function getBase() : string;
|
public function getBase() : string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get route representation of uri.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getRoute() : string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set uri.
|
* Set uri.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -301,15 +301,28 @@ class Repository
|
||||||
return implode("\n", $this->run('add ' . $files . ' -v'));
|
return implode("\n", $this->run('add ' . $files . ' -v'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove file(s) from repository
|
||||||
|
*
|
||||||
|
* @param string|array $files Files to remove
|
||||||
|
* @param bool $cached ?
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function rm($files = '*', bool $cached = false) : string
|
public function rm($files = '*', bool $cached = false) : string
|
||||||
{
|
{
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
$files = '"' . implode('" "', $files) . '"';
|
$files = '"' . implode('" "', $files) . '"';
|
||||||
} elseif (!is_string($files)) {
|
} elseif (!is_string($files)) {
|
||||||
throw new \Exception('Wrong type');
|
throw new \InvalidArgumentException('Wrong type for $files.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->run('rm ' . ($cached ? '--cached ' : '') . $files);
|
return implode("\n", $this->run('rm ' . ($cached ? '--cached ' : '') . $files));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -328,31 +341,65 @@ class Repository
|
||||||
return implode("\n", $this->run('commit ' . ($all ? '-av' : '-v') . ' -m ' . escapeshellarg($commit->getMessage())));
|
return implode("\n", $this->run('commit ' . ($all ? '-av' : '-v') . ' -m ' . escapeshellarg($commit->getMessage())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone repository to different directory
|
||||||
|
*
|
||||||
|
* @param string $target Target clone directory
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws PathException in case the target is not a valid directory
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function cloneTo(string $target) : string
|
public function cloneTo(string $target) : string
|
||||||
{
|
{
|
||||||
if (!is_dir($target)) {
|
if (!is_dir($target)) {
|
||||||
throw new \Exception('Not a directory');
|
throw new PathException($target);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->run('clone --local ' . $this->path . ' ' . $target);
|
return implode("\n", $this->run('clone --local ' . $this->path . ' ' . $target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone repository to current directory
|
||||||
|
*
|
||||||
|
* @param string $source Source repository to clone
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws PathException in case the source repository is not valid
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function cloneFrom(string $source) : string
|
public function cloneFrom(string $source) : string
|
||||||
{
|
{
|
||||||
if (!is_dir($source)) {
|
if (!is_dir($source)) {
|
||||||
throw new \Exception('Not a directory');
|
throw new PathException($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: is valid git repository?
|
// todo: is valid git repository?
|
||||||
|
|
||||||
return $this->run('clone --local ' . $source . ' ' . $this->path);
|
return implode("\n", $this->run('clone --local ' . $source . ' ' . $this->path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone remote repository to current directory
|
||||||
|
*
|
||||||
|
* @param string $source Source repository to clone
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function cloneRemote(string $source) : string
|
public function cloneRemote(string $source) : string
|
||||||
{
|
{
|
||||||
// todo: is valid remote git repository?
|
// todo: is valid remote git repository?
|
||||||
|
|
||||||
return $this->run('clone ' . $source . ' ' . $this->path);
|
return implode("\n", $this->run('clone ' . $source . ' ' . $this->path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -853,7 +900,7 @@ class Repository
|
||||||
throw new \Exception('Invalid commit id');
|
throw new \Exception('Invalid commit id');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtils::startsWith($lines[1], 'Merge')) {
|
if (StringUtils::startsWith($lines[1], 'Merge')) {
|
||||||
return new Commit();
|
return new Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user