Bug fix changes

This commit is contained in:
Dennis Eichhorn 2017-09-05 18:47:01 +02:00
parent 160eebdc21
commit 61d1353023
6 changed files with 69 additions and 36 deletions

View File

@ -1498,8 +1498,6 @@ class DataMapperAbstract implements DataMapperInterface
foreach ($primaryKey as $key => $value) { foreach ($primaryKey as $key => $value) {
if(self::isInitialized(static::class, $value)) { if(self::isInitialized(static::class, $value)) {
$obj[$value] = self::getInitialized(static::class, $value);
continue; continue;
} }
@ -1708,12 +1706,7 @@ class DataMapperAbstract implements DataMapperInterface
public static function getRaw($primaryKey) : array public static function getRaw($primaryKey) : array
{ {
$query = self::getQuery(); $query = self::getQuery();
$query->where(static::$table . '.' . static::$primaryField, '=', $primaryKey);
if(is_array($primaryKey)) {
$query->where(static::$table . '.' . static::$primaryField, 'in', $primaryKey);
} else {
$query->where(static::$table . '.' . static::$primaryField, '=', $primaryKey);
}
$sth = self::$db->con->prepare($query->toSql()); $sth = self::$db->con->prepare($query->toSql());
$sth->execute(); $sth->execute();
@ -1918,21 +1911,6 @@ class DataMapperAbstract implements DataMapperInterface
{ {
return isset(self::$initObjects[$mapper]) && isset(self::$initObjects[$mapper][$id]); return isset(self::$initObjects[$mapper]) && isset(self::$initObjects[$mapper][$id]);
} }
/**
* Get initialized object
*
* @param string $mapper Mapper name
* @param mixed $id Object id
*
* @return object
*
* @since 1.0.0
*/
private static function getInitialized($mapper, $id)
{
return self::$initObjects[$mapper][$id];
}
/** /**
* Define the highest mapper of this request * Define the highest mapper of this request

View File

@ -15,6 +15,8 @@ declare(strict_types=1);
namespace phpOMS\Message; namespace phpOMS\Message;
use phpOMS\Localization\Localization;
/** /**
* Response class. * Response class.
* *
@ -57,9 +59,23 @@ abstract class HeaderAbstract
* @since 1.0.0 * @since 1.0.0
*/ */
protected $status = 0; protected $status = 0;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->l11n = new Localization();
}
/** /**
* {@inheritdoc} * Get Localization
*
* @return Localization
*
* @since 1.0.0
*/ */
public function getL11n() : Localization public function getL11n() : Localization
{ {
@ -67,7 +83,13 @@ abstract class HeaderAbstract
} }
/** /**
* {@inheritdoc} * Set localization
*
* @param int $localization Localization
*
* @return void
*
* @since 1.0.0
*/ */
public function setL11n(Localization $l11n) /* : void */ public function setL11n(Localization $l11n) /* : void */
{ {
@ -75,7 +97,11 @@ abstract class HeaderAbstract
} }
/** /**
* {@inheritdoc} * Get account id
*
* @return int
*
* @since 1.0.0
*/ */
public function getAccount() : int public function getAccount() : int
{ {
@ -83,7 +109,13 @@ abstract class HeaderAbstract
} }
/** /**
* {@inheritdoc} * Set account id
*
* @param int $account Account id
*
* @return void
*
* @since 1.0.0
*/ */
public function setAccount(int $account) /* : void */ public function setAccount(int $account) /* : void */
{ {
@ -92,8 +124,13 @@ abstract class HeaderAbstract
/** /**
* {@inheritdoc} * Set status code
* todo: shouldn't this only be available in the header?! *
* @param int $status Status code
*
* @return void
*
* @since 1.0.0
*/ */
public function setStatusCode(int $status) /* : void */ public function setStatusCode(int $status) /* : void */
{ {
@ -102,8 +139,11 @@ abstract class HeaderAbstract
} }
/** /**
* {@inheritdoc} * Get status code
* todo: shouldn't this only be available in the header?! *
* @return int
*
* @since 1.0.0
*/ */
public function getStatusCode() : int public function getStatusCode() : int
{ {

View File

@ -46,6 +46,7 @@ class Header extends HeaderAbstract
public function __construct() public function __construct()
{ {
$this->set('Content-Type', 'text/html; charset=utf-8'); $this->set('Content-Type', 'text/html; charset=utf-8');
parent::__construct();
} }
/** /**
@ -123,7 +124,7 @@ class Header extends HeaderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getStatusCode() : int public function getStatusCode() : int
{ {
if($this->status === 0) { if($this->status === 0) {
$this->status = \http_response_code(); $this->status = \http_response_code();

View File

@ -236,10 +236,12 @@ class Request extends RequestAbstract
public function createRequestHashs(int $start = 0) /* : void */ public function createRequestHashs(int $start = 0) /* : void */
{ {
$this->hash = []; $this->hash = [];
foreach ($this->path as $key => $path) { $pathArray = $this->uri->getPathElements();
foreach ($pathArray as $key => $path) {
$paths = []; $paths = [];
for ($i = $start; $i < $key + 1; $i++) { for ($i = $start; $i < $key + 1; $i++) {
$paths[] = $this->path[$i]; $paths[] = $pathArray[$i];
} }
$this->hash[] = sha1(implode('', $paths)); $this->hash[] = sha1(implode('', $paths));

View File

@ -257,6 +257,13 @@ class Http implements UriInterface
return $this->path; return $this->path;
} }
/**
* Get path offset.
*
* @return int
*
* @since 1.0.0
*/
public function getPathOffset() : int public function getPathOffset() : int
{ {
return substr_count($this->rootPath, '/') - 1; return substr_count($this->rootPath, '/') - 1;
@ -274,11 +281,16 @@ class Http implements UriInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPathElement(int $pos) : string public function getPathElement(int $pos = null) : string
{ {
return explode('/', $this->path)[$pos]; return explode('/', $this->path)[$pos];
} }
public function getPathElements() : array
{
return explode('/', $this->path);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -87,7 +87,7 @@ class View extends ViewAbstract
$this->app = $app; $this->app = $app;
$this->request = $request; $this->request = $request;
$this->response = $response; $this->response = $response;
$this->l11n = $response->getL11n(); $this->l11n = $response->getHeader()->getL11n();
} }
/** /**