diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 56f3e5902..d117baba4 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -1498,8 +1498,6 @@ class DataMapperAbstract implements DataMapperInterface foreach ($primaryKey as $key => $value) { if(self::isInitialized(static::class, $value)) { - $obj[$value] = self::getInitialized(static::class, $value); - continue; } @@ -1708,12 +1706,7 @@ class DataMapperAbstract implements DataMapperInterface public static function getRaw($primaryKey) : array { $query = self::getQuery(); - - if(is_array($primaryKey)) { - $query->where(static::$table . '.' . static::$primaryField, 'in', $primaryKey); - } else { - $query->where(static::$table . '.' . static::$primaryField, '=', $primaryKey); - } + $query->where(static::$table . '.' . static::$primaryField, '=', $primaryKey); $sth = self::$db->con->prepare($query->toSql()); $sth->execute(); @@ -1918,21 +1911,6 @@ class DataMapperAbstract implements DataMapperInterface { 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 diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index fb3e4a4e1..0fd00cc2b 100644 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -15,6 +15,8 @@ declare(strict_types=1); namespace phpOMS\Message; +use phpOMS\Localization\Localization; + /** * Response class. * @@ -57,9 +59,23 @@ abstract class HeaderAbstract * @since 1.0.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 { @@ -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 */ { @@ -75,7 +97,11 @@ abstract class HeaderAbstract } /** - * {@inheritdoc} + * Get account id + * + * @return int + * + * @since 1.0.0 */ 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 */ { @@ -92,8 +124,13 @@ abstract class HeaderAbstract /** - * {@inheritdoc} - * todo: shouldn't this only be available in the header?! + * Set status code + * + * @param int $status Status code + * + * @return void + * + * @since 1.0.0 */ public function setStatusCode(int $status) /* : void */ { @@ -102,8 +139,11 @@ abstract class HeaderAbstract } /** - * {@inheritdoc} - * todo: shouldn't this only be available in the header?! + * Get status code + * + * @return int + * + * @since 1.0.0 */ public function getStatusCode() : int { diff --git a/Message/Http/Header.php b/Message/Http/Header.php index ebb6298b1..0a8e341b0 100644 --- a/Message/Http/Header.php +++ b/Message/Http/Header.php @@ -46,6 +46,7 @@ class Header extends HeaderAbstract public function __construct() { $this->set('Content-Type', 'text/html; charset=utf-8'); + parent::__construct(); } /** @@ -123,7 +124,7 @@ class Header extends HeaderAbstract * * @since 1.0.0 */ - public static function getStatusCode() : int + public function getStatusCode() : int { if($this->status === 0) { $this->status = \http_response_code(); diff --git a/Message/Http/Request.php b/Message/Http/Request.php index ff3d1817b..6f29e33c4 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -236,10 +236,12 @@ class Request extends RequestAbstract public function createRequestHashs(int $start = 0) /* : void */ { $this->hash = []; - foreach ($this->path as $key => $path) { + $pathArray = $this->uri->getPathElements(); + + foreach ($pathArray as $key => $path) { $paths = []; for ($i = $start; $i < $key + 1; $i++) { - $paths[] = $this->path[$i]; + $paths[] = $pathArray[$i]; } $this->hash[] = sha1(implode('', $paths)); diff --git a/Uri/Http.php b/Uri/Http.php index 406924df5..b05155738 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -257,6 +257,13 @@ class Http implements UriInterface return $this->path; } + /** + * Get path offset. + * + * @return int + * + * @since 1.0.0 + */ public function getPathOffset() : int { return substr_count($this->rootPath, '/') - 1; @@ -274,11 +281,16 @@ class Http implements UriInterface /** * {@inheritdoc} */ - public function getPathElement(int $pos) : string + public function getPathElement(int $pos = null) : string { return explode('/', $this->path)[$pos]; } + public function getPathElements() : array + { + return explode('/', $this->path); + } + /** * {@inheritdoc} */ diff --git a/Views/View.php b/Views/View.php index 8d124a8c5..678ce9b3e 100644 --- a/Views/View.php +++ b/Views/View.php @@ -87,7 +87,7 @@ class View extends ViewAbstract $this->app = $app; $this->request = $request; $this->response = $response; - $this->l11n = $response->getL11n(); + $this->l11n = $response->getHeader()->getL11n(); } /**