Revision: 180
http://sourceforge.net/p/beeframework/code/180
Author: m_plomer
Date: 2014-07-12 15:54:40 +0000 (Sat, 12 Jul 2014)
Log Message:
-----------
- MVC: namespaced ViewResolvers
Modified Paths:
--------------
trunk/framework/Bee/MVC/ViewResolver/Basic.php
trunk/framework/Bee/MVC/ViewResolver/Loopback.php
Added Paths:
-----------
trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php
trunk/framework/Bee/MVC/ViewResolver/LoopbackViewResolver.php
Modified: trunk/framework/Bee/MVC/ViewResolver/Basic.php
===================================================================
--- trunk/framework/Bee/MVC/ViewResolver/Basic.php 2014-07-10 17:17:48 UTC (rev 179)
+++ trunk/framework/Bee/MVC/ViewResolver/Basic.php 2014-07-12 15:54:40 UTC (rev 180)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-use Bee\MVC\IViewResolver;
+use Bee\MVC\ViewResolver\BasicViewResolver;
/**
* Basic implementation of the IViewResolver interface. Uses a Bee_IContext for view name resolution, looking up
@@ -22,90 +22,7 @@
*
* @author Benjamin Hartmann
* @author Michael Plomer <mic...@it...>
+ * @deprecated replaced by BasicViewResolver
*/
-class Bee_MVC_ViewResolver_Basic implements IViewResolver {
-
- /**
- * @var Logger
- */
- protected $log;
-
- /**
- * @return Logger
- */
- protected function getLog() {
- if (!$this->log) {
- $this->log = Logger::getLogger(get_class($this));
- }
- return $this->log;
- }
-
- /**
- * Enter description here...
- *
- * @var Bee_IContext
- */
- private $context;
-
- /**
- * @var string
- */
- private $ajaxViewNameSuffix = '.ajax';
-
- /**
- * Enter description here...
- *
- * @param Bee_IContext $context
- * @return void
- */
- public function setContext(Bee_IContext $context) {
- $this->context = $context;
- }
-
- /**
- * Enter description here...
- *
- * @return Bee_IContext
- */
- public function getContext() {
- return $this->context;
- }
-
- /**
- * @param String $viewName
- * @param Bee_MVC_IHttpRequest $request
- * @return Bee\MVC\IView|Object
- */
- public function resolveViewName($viewName, Bee_MVC_IHttpRequest $request) {
- $modifiedViewName = $this->modifyViewName($viewName, $request);
- if ($modifiedViewName != $viewName) {
- try {
- return $this->getViewForName($viewName);
- } catch (Bee_Context_BeansException $bex) {
- if($this->getLog()->isDebugEnabled()) {
- $this->getLog()->debug('Modified view name "' . $modifiedViewName . '" not found, trying base bean name "' . $viewName . '"', $bex);
- }
- }
- }
- return $this->getViewForName($viewName);
- }
-
- /**
- * @param string $viewName
- * @return Bee\MVC\IView
- */
- protected function getViewForName($viewName) {
- return $this->context->getBean($viewName, 'Bee\MVC\IView');
- }
-
- /**
- * Modify the view name according to request specifics. By default, the suffix '.ajax' is appended to the view names
- * for AJAX requests. Otherwise, the view name is left untouched.
- * @param $viewName
- * @param Bee_MVC_IHttpRequest $request
- * @return string
- */
- protected function modifyViewName($viewName, Bee_MVC_IHttpRequest $request) {
- return $request->getAjax() ? $viewName . $this->ajaxViewNameSuffix : $viewName;
- }
+class Bee_MVC_ViewResolver_Basic extends BasicViewResolver {
}
\ No newline at end of file
Added: trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php
===================================================================
--- trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php (rev 0)
+++ trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php 2014-07-12 15:54:40 UTC (rev 180)
@@ -0,0 +1,117 @@
+<?php
+namespace Bee\MVC\ViewResolver;
+/*
+ * Copyright 2008-2014 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.
+ */
+use Bee\MVC\IView;
+use Bee\MVC\IViewResolver;
+use Bee_Context_BeansException;
+use Bee_IContext;
+use Bee_MVC_IHttpRequest;
+use Logger;
+
+/**
+ * Basic implementation of the IViewResolver interface. Uses a Bee_IContext for view name resolution, looking up
+ * beans of type IView by using the view name as bean name.
+ *
+ * @author Benjamin Hartmann
+ * @author Michael Plomer <mic...@it...>
+ */
+class BasicViewResolver implements IViewResolver {
+
+ /**
+ * @var Logger
+ */
+ protected $log;
+
+ /**
+ * @return Logger
+ */
+ protected function getLog() {
+ if (!$this->log) {
+ $this->log = Logger::getLogger(get_class($this));
+ }
+ return $this->log;
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @var Bee_IContext
+ */
+ private $context;
+
+ /**
+ * @var string
+ */
+ private $ajaxViewNameSuffix = '.ajax';
+
+ /**
+ * Enter description here...
+ *
+ * @param Bee_IContext $context
+ * @return void
+ */
+ public function setContext(Bee_IContext $context) {
+ $this->context = $context;
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @return Bee_IContext
+ */
+ public function getContext() {
+ return $this->context;
+ }
+
+ /**
+ * @param String $viewName
+ * @param Bee_MVC_IHttpRequest $request
+ * @return IView|Object
+ */
+ public function resolveViewName($viewName, Bee_MVC_IHttpRequest $request) {
+ $modifiedViewName = $this->modifyViewName($viewName, $request);
+ if ($modifiedViewName != $viewName) {
+ try {
+ return $this->getViewForName($viewName);
+ } catch (Bee_Context_BeansException $bex) {
+ if($this->getLog()->isDebugEnabled()) {
+ $this->getLog()->debug('Modified view name "' . $modifiedViewName . '" not found, trying base bean name "' . $viewName . '"', $bex);
+ }
+ }
+ }
+ return $this->getViewForName($viewName);
+ }
+
+ /**
+ * @param string $viewName
+ * @return IView
+ */
+ protected function getViewForName($viewName) {
+ return $this->context->getBean($viewName, 'Bee\MVC\IView');
+ }
+
+ /**
+ * Modify the view name according to request specifics. By default, the suffix '.ajax' is appended to the view names
+ * for AJAX requests. Otherwise, the view name is left untouched.
+ * @param $viewName
+ * @param Bee_MVC_IHttpRequest $request
+ * @return string
+ */
+ protected function modifyViewName($viewName, Bee_MVC_IHttpRequest $request) {
+ return $request->getAjax() ? $viewName . $this->ajaxViewNameSuffix : $viewName;
+ }
+}
\ No newline at end of file
Property changes on: trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/framework/Bee/MVC/ViewResolver/Loopback.php
===================================================================
--- trunk/framework/Bee/MVC/ViewResolver/Loopback.php 2014-07-10 17:17:48 UTC (rev 179)
+++ trunk/framework/Bee/MVC/ViewResolver/Loopback.php 2014-07-12 15:54:40 UTC (rev 180)
@@ -1,15 +1,24 @@
<?php
-class Bee_MVC_ViewResolver_Loopback extends Bee_MVC_ViewResolver_Basic implements Bee_Context_Config_IContextAware{
+/*
+ * Copyright 2008-2014 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.
+ */
+use Bee\MVC\ViewResolver\LoopbackViewResolver;
- /**
- * Callback that supplies the owning context to a bean instance.
- * <p>Invoked after the population of normal bean properties
- * but before an initialization callback such as
- * {@link InitializingBean#afterPropertiesSet()} or a custom init-method.
- * @param Bee_IContext $context owning context (never <code>null</code>).
- * The bean can immediately call methods on the context.
- */
- public function setBeeContext(Bee_IContext $context) {
- $this->setContext($context);
- }
+/**
+ * Class Bee_MVC_ViewResolver_Loopback
+ * @deprecated replaced by LoopbackViewResolver
+ */
+class Bee_MVC_ViewResolver_Loopback extends LoopbackViewResolver {
}
Added: trunk/framework/Bee/MVC/ViewResolver/LoopbackViewResolver.php
===================================================================
--- trunk/framework/Bee/MVC/ViewResolver/LoopbackViewResolver.php (rev 0)
+++ trunk/framework/Bee/MVC/ViewResolver/LoopbackViewResolver.php 2014-07-12 15:54:40 UTC (rev 180)
@@ -0,0 +1,19 @@
+<?php
+namespace Bee\MVC\ViewResolver;
+use Bee_Context_Config_IContextAware;
+use Bee_IContext;
+
+class LoopbackViewResolver extends BasicViewResolver implements Bee_Context_Config_IContextAware{
+
+ /**
+ * Callback that supplies the owning context to a bean instance.
+ * <p>Invoked after the population of normal bean properties
+ * but before an initialization callback such as
+ * {@link InitializingBean#afterPropertiesSet()} or a custom init-method.
+ * @param Bee_IContext $context owning context (never <code>null</code>).
+ * The bean can immediately call methods on the context.
+ */
+ public function setBeeContext(Bee_IContext $context) {
+ $this->setContext($context);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|