[Beeframework-svn] SF.net SVN: beeframework:[287] trunk/framework
Brought to you by:
b_hartmann,
m_plomer
From: <m_p...@us...> - 2015-02-24 12:56:18
|
Revision: 287 http://sourceforge.net/p/beeframework/code/287 Author: m_plomer Date: 2015-02-24 12:56:16 +0000 (Tue, 24 Feb 2015) Log Message: ----------- - moved request-storing view hierarchy to trait base - BeeFramework now requires PHP 5.4!!! Modified Paths: -------------- trunk/framework/Bee/MVC/Model.php trunk/framework/Bee/MVC/View/RequestStoringRedirectView.php trunk/framework/composer.json Added Paths: ----------- trunk/framework/Bee/MVC/View/RequestStoringJsonView.php trunk/framework/Bee/MVC/View/TRequestStoringView.php Modified: trunk/framework/Bee/MVC/Model.php =================================================================== --- trunk/framework/Bee/MVC/Model.php 2015-02-24 12:51:47 UTC (rev 286) +++ trunk/framework/Bee/MVC/Model.php 2015-02-24 12:56:16 UTC (rev 287) @@ -1,6 +1,6 @@ <?php /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ * * @param array $values */ - public static function addValuesToModel(Array $values) { + public static function addValuesToModel(array $values) { self::$modelValues = array_merge(self::$modelValues, $values); } Added: trunk/framework/Bee/MVC/View/RequestStoringJsonView.php =================================================================== --- trunk/framework/Bee/MVC/View/RequestStoringJsonView.php (rev 0) +++ trunk/framework/Bee/MVC/View/RequestStoringJsonView.php 2015-02-24 12:56:16 UTC (rev 287) @@ -0,0 +1,35 @@ +<?php +/* + * Copyright 2008-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +namespace Bee\MVC\View; + +use MODEL; + +/** + * Class RequestStoringJsonView + * @package Bee\MVC\View + */ +class RequestStoringJsonView extends JsonServiceView { + use TRequestStoringView; + + /** + * + */ + protected function renderMergedOutputModel() { + MODEL::addValuesToModel($this->createStoreParams(MODEL::getModel())); + parent::renderMergedOutputModel(); + } +} \ No newline at end of file Modified: trunk/framework/Bee/MVC/View/RequestStoringRedirectView.php =================================================================== --- trunk/framework/Bee/MVC/View/RequestStoringRedirectView.php 2015-02-24 12:51:47 UTC (rev 286) +++ trunk/framework/Bee/MVC/View/RequestStoringRedirectView.php 2015-02-24 12:56:16 UTC (rev 287) @@ -1,7 +1,7 @@ <?php namespace Bee\MVC\View; /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,70 +15,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -use Bee\MVC\Redirect\AbstractRedirectStorage; /** * Class RequestStoringRedirectView * @package Bee\MVC\View */ class RequestStoringRedirectView extends RedirectView { + use TRequestStoringView; - /** - * @var string - */ - private $requestIdParamName = 'requestId'; - - /** - * @var AbstractRedirectStorage[] - */ - private $stores = array(); - - /** - * @param string $requestIdParamName - */ - public function setRequestIdParamName($requestIdParamName) { - $this->requestIdParamName = $requestIdParamName; - } - - /** - * @return string - */ - public function getRequestIdParamName() { - return $this->requestIdParamName; - } - - /** - * @param array $stores - */ - public function setStores(array $stores) { - $this->stores = $stores; - } - - /** - * @return array - */ - public function getStores() { - return $this->stores; - } - - /** - * @param array $model - */ - public function render(array $model = array()) { - $this->augmentModel($model); - $getParams = array_key_exists(self::MODEL_KEY_GET_PARAMS, $model) ? $model[self::MODEL_KEY_GET_PARAMS] : array(); - foreach($this->stores as $paramName => $store) { - $getParams[$paramName] = $store->storeData($model); - } - $model[self::MODEL_KEY_GET_PARAMS] = $getParams; - parent::render($model); - } - - /** - * Extension point for subclasses - * @param array $model - */ - protected function augmentModel(array &$model) { - // do nothing by default - } + /** + * @param array $model + */ + public function render(array $model = array()) { + $getParams = array_key_exists(RedirectView::MODEL_KEY_GET_PARAMS, $model) ? $model[RedirectView::MODEL_KEY_GET_PARAMS] : array(); + $model[RedirectView::MODEL_KEY_GET_PARAMS] = array_merge($getParams, $this->createStoreParams($model)); + parent::render($model); + } } \ No newline at end of file Added: trunk/framework/Bee/MVC/View/TRequestStoringView.php =================================================================== --- trunk/framework/Bee/MVC/View/TRequestStoringView.php (rev 0) +++ trunk/framework/Bee/MVC/View/TRequestStoringView.php 2015-02-24 12:56:16 UTC (rev 287) @@ -0,0 +1,90 @@ +<?php +/* + * Copyright 2008-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +namespace Bee\MVC\View; + + +use Bee\MVC\Redirect\AbstractRedirectStorage; + +/** + * Class TRequestStoringView + * @package Bee\MVC\View + */ +trait TRequestStoringView { + + /** + * @var string + */ + private $requestIdParamName = 'requestId'; + + /** + * @var AbstractRedirectStorage[] + */ + private $stores = array(); + + /** + * @param $model + * @return array + */ + protected function createStoreParams($model) { + $this->augmentModel($model); + $storeParams = array(); + foreach($this->stores as $paramName => $store) { + $storeParams[$paramName] = $store->storeData($model); + } + return $storeParams; + } + + /** + * Extension point for subclasses + * @param array $model + */ + protected function augmentModel(array &$model) { + // do nothing by default + } + + // ================================================================================================================= + // == GETTERS & SETTERS ============================================================================================ + // ================================================================================================================= + + /** + * @param string $requestIdParamName + */ + public function setRequestIdParamName($requestIdParamName) { + $this->requestIdParamName = $requestIdParamName; + } + + /** + * @return string + */ + public function getRequestIdParamName() { + return $this->requestIdParamName; + } + + /** + * @param array $stores + */ + public function setStores(array $stores) { + $this->stores = $stores; + } + + /** + * @return array + */ + public function getStores() { + return $this->stores; + } +} \ No newline at end of file Modified: trunk/framework/composer.json =================================================================== --- trunk/framework/composer.json 2015-02-24 12:51:47 UTC (rev 286) +++ trunk/framework/composer.json 2015-02-24 12:56:16 UTC (rev 287) @@ -21,7 +21,7 @@ } ], "require": { - "php": ">=5.3", + "php": ">=5.4", "niktux/addendum": "0.4.1", "apache/log4php": "~2.3@stable" }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |