beeframework-svn Mailing List for Bee Framework (Page 2)
Brought to you by:
b_hartmann,
m_plomer
You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(12) |
Jun
(5) |
Jul
(6) |
Aug
(25) |
Sep
(25) |
Oct
(6) |
Nov
(29) |
Dec
|
2014 |
Jan
(2) |
Feb
(10) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(5) |
Jul
(35) |
Aug
(9) |
Sep
(33) |
Oct
(30) |
Nov
(4) |
Dec
(1) |
2015 |
Jan
(3) |
Feb
(13) |
Mar
(13) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <m_p...@us...> - 2015-02-04 14:02:36
|
Revision: 280 http://sourceforge.net/p/beeframework/code/280 Author: m_plomer Date: 2015-02-04 14:02:28 +0000 (Wed, 04 Feb 2015) Log Message: ----------- - Security/UserDetails: refactored UserManagerBase for better extensibility through subclassing - BeanWrapper: added getPropertyValues() / setWritablePropertyValues() Modified Paths: -------------- trunk/framework/Bee/Beans/BeanWrapper.php trunk/framework/Bee/Framework.php Added Paths: ----------- trunk/framework/Bee/Security/UserDetails/PasswordConfirmationMismatchException.php Modified: trunk/framework/Bee/Beans/BeanWrapper.php =================================================================== --- trunk/framework/Bee/Beans/BeanWrapper.php 2015-01-29 11:24:41 UTC (rev 279) +++ trunk/framework/Bee/Beans/BeanWrapper.php 2015-02-04 14:02:28 UTC (rev 280) @@ -1,5 +1,6 @@ <?php namespace Bee\Beans; + /* * Copyright 2008-2014 the original author or authors. * @@ -17,6 +18,8 @@ */ use Bee\Context\InvalidPropertyException; use Bee\Utils\Types; +use ReflectionClass; +use ReflectionMethod; /** * Enter description here... @@ -24,47 +27,89 @@ * @author Benjamin Hartmann */ class BeanWrapper { - - /** - * The target object - * - * @var object - */ - private $object; - - - public function __construct($object) { - $this->object = $object; - } - - public final function setPropertyValue($name, $value) { - call_user_func($this->findPropertyAccessor($name, 'set'), $value); - } - public final function getPropertyValue($name) { - return call_user_func($this->findPropertyAccessor($name, 'get')); - } - - protected function findPropertyAccessor($propertyName, $prefix) { - $methodName = $prefix.ucfirst($propertyName); - $method = array($this->object, $methodName); - if(!is_callable($method)) { - throw new InvalidPropertyException($propertyName, Types::getType($this->object), 'no such method found: '.$methodName); - } - return $method; - } - - public final function setPropertyValueWithPropertyValue(PropertyValue $propertyValue) { - $this->setPropertyValue($propertyValue->getName(), $propertyValue->getValue()); - } + const GETTER_REGEX = '#^get[A-Z]#'; - public final function setPropertyValues(array $propertyValues) { - foreach ($propertyValues as $name => $propertyValue) { - if (!is_string($propertyValue) && Types::isAssignable($propertyValue, 'Bee\Beans\PropertyValue')) { - $this->setPropertyValueWithPropertyValue($propertyValue); - } else { - $this->setPropertyValue($name, $propertyValue); - } - } - } + /** + * The target object + * + * @var object + */ + private $object; + + + public function __construct($object) { + $this->object = $object; + } + + public final function setPropertyValue($name, $value) { + call_user_func($this->findPropertyAccessor($name, 'set'), $value); + } + + public final function getPropertyValue($name) { + return call_user_func($this->findPropertyAccessor($name, 'get')); + } + + protected function findPropertyAccessor($propertyName, $prefix) { + $methodName = $prefix . ucfirst($propertyName); + $method = array($this->object, $methodName); + if (!is_callable($method)) { + throw new InvalidPropertyException($propertyName, Types::getType($this->object), 'no such method found: ' . $methodName); + } + return $method; + } + + public final function setPropertyValueWithPropertyValue(PropertyValue $propertyValue) { + $this->setPropertyValue($propertyValue->getName(), $propertyValue->getValue()); + } + + /** + * @param array $propertyValues + */ + public final function setPropertyValues(array $propertyValues) { + foreach ($propertyValues as $name => $propertyValue) { + if (!is_string($propertyValue) && Types::isAssignable($propertyValue, 'Bee\Beans\PropertyValue')) { + $this->setPropertyValueWithPropertyValue($propertyValue); + } else { + $this->setPropertyValue($name, $propertyValue); + } + } + } + + /** + * @param array $propertyValues + */ + public final function setWritablePropertyValues(array $propertyValues) { + foreach ($propertyValues as $name => $propertyValue) { + try { + if (!is_string($propertyValue) && Types::isAssignable($propertyValue, 'Bee\Beans\PropertyValue')) { + $this->setPropertyValueWithPropertyValue($propertyValue); + } else { + $this->setPropertyValue($name, $propertyValue); + } + } catch (InvalidPropertyException $e) { + // ignored + } + } + } + + /** + * @return array|null + */ + public final function getPropertyValues() { + if (is_null($this->object)) { + return null; + } + $result = array(); + $reflClass = new ReflectionClass($this->object); + $publicMethods = $reflClass->getMethods(ReflectionMethod::IS_PUBLIC); + foreach ($publicMethods as $method) { + $propName = $method->getShortName(); + if (!$method->isStatic() && preg_match(self::GETTER_REGEX, $propName) && $method->getNumberOfRequiredParameters() == 0) { + $propName = lcfirst(substr($propName, 3)); + $result[$propName] = $method->invoke($this->object); + } + } + return $result; + } } \ No newline at end of file Modified: trunk/framework/Bee/Framework.php =================================================================== --- trunk/framework/Bee/Framework.php 2015-01-29 11:24:41 UTC (rev 279) +++ trunk/framework/Bee/Framework.php 2015-02-04 14:02:28 UTC (rev 280) @@ -375,9 +375,11 @@ * @deprecated replaced by Bee\Framework */ class Bee_Framework extends Framework { + } interface TYPES extends ITypeDefinitions { + } } Added: trunk/framework/Bee/Security/UserDetails/PasswordConfirmationMismatchException.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/PasswordConfirmationMismatchException.php (rev 0) +++ trunk/framework/Bee/Security/UserDetails/PasswordConfirmationMismatchException.php 2015-02-04 14:02:28 UTC (rev 280) @@ -0,0 +1,12 @@ +<?php +namespace Bee\Security\UserDetails; + +use Exception; + +/** + * Class PasswordConfirmationMismatchException + * @package Bee\Security\UserDetails + */ +class PasswordConfirmationMismatchException extends Exception { + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2015-01-29 11:24:43
|
Revision: 279 http://sourceforge.net/p/beeframework/code/279 Author: m_plomer Date: 2015-01-29 11:24:41 +0000 (Thu, 29 Jan 2015) Log Message: ----------- - Security/UserDetails: refactored UserManagerBase for better extensibility through subclassing - MVC: moved model and view resolution from Dispatcher to ViewResolver Modified Paths: -------------- trunk/framework/Bee/MVC/Dispatcher.php trunk/framework/Bee/MVC/IViewResolver.php trunk/framework/Bee/MVC/ModelAndView.php trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php trunk/framework/Bee/Security/UserDetails/UserManagerBase.php Modified: trunk/framework/Bee/MVC/Dispatcher.php =================================================================== --- trunk/framework/Bee/MVC/Dispatcher.php 2015-01-16 14:37:32 UTC (rev 278) +++ trunk/framework/Bee/MVC/Dispatcher.php 2015-01-29 11:24:41 UTC (rev 279) @@ -1,7 +1,7 @@ <?php namespace Bee\MVC; /* - * 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. @@ -20,8 +20,6 @@ use Bee\Context\NoSuchBeanDefinitionException; use Bee\IContext; use Bee\MVC\Session\DispatcherAdapter; -use Bee\MVC\View\AbstractView; -use Bee\MVC\View\ViewBase; use Bee\Utils\Assert; use Exception; use Logger; @@ -321,7 +319,7 @@ if ($mav instanceof ModelAndView) { $mav->addModelValue(Model::CURRENT_REQUEST_KEY, $request); - $this->resolveModelAndView($mav, $request); + $this->viewResolver->resolveModelAndView($mav, $request); if(!is_null($handlerException) && !count($interceptors)) { // We were unable to resolve a handler and its interceptors due to an exception being thrown along @@ -341,36 +339,4 @@ throw $e; } } - - /** - * @param ModelAndView $mav - * @param IHttpRequest $request - */ - public function resolveModelAndView(ModelAndView $mav, IHttpRequest $request) { - $resolvedView = $this->viewResolver->resolveViewName($mav->getViewName(), $request); - $mav->setResolvedView($resolvedView); - if ($resolvedView instanceof ViewBase) { - $statics = $resolvedView->getStaticAttributes(); - if (!$statics) { - $statics = array(); - } - $model = array_merge($statics, $mav->getModel()); - $mav->setModel($model); - } - $this->resolveModelInternals($mav->getModel(), $request); - } - - /** - * @param array $model - * @param IHttpRequest $request - */ - private function resolveModelInternals(array $model, IHttpRequest $request) { - foreach ($model as $modelElem) { - if ($modelElem instanceof ModelAndView) { - $this->resolveModelAndView($modelElem, $request); - } else if (is_array($modelElem)) { - $this->resolveModelInternals($modelElem, $request); - } - } - } } Modified: trunk/framework/Bee/MVC/IViewResolver.php =================================================================== --- trunk/framework/Bee/MVC/IViewResolver.php 2015-01-16 14:37:32 UTC (rev 278) +++ trunk/framework/Bee/MVC/IViewResolver.php 2015-01-29 11:24:41 UTC (rev 279) @@ -42,4 +42,10 @@ * (optional, to allow for ViewResolver chaining) */ public function resolveViewName($viewName, IHttpRequest $request); + + /** + * @param ModelAndView $mav + * @param IHttpRequest $request + */ + public function resolveModelAndView(ModelAndView $mav, IHttpRequest $request); } Modified: trunk/framework/Bee/MVC/ModelAndView.php =================================================================== --- trunk/framework/Bee/MVC/ModelAndView.php 2015-01-16 14:37:32 UTC (rev 278) +++ trunk/framework/Bee/MVC/ModelAndView.php 2015-01-29 11:24:41 UTC (rev 279) @@ -1,7 +1,7 @@ <?php namespace Bee\MVC; /* - * 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. @@ -155,5 +155,4 @@ // @todo: assert a resolvedView is set $this->resolvedView->render($this->getModel()); } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php =================================================================== --- trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php 2015-01-16 14:37:32 UTC (rev 278) +++ trunk/framework/Bee/MVC/ViewResolver/BasicViewResolver.php 2015-01-29 11:24:41 UTC (rev 279) @@ -1,7 +1,7 @@ <?php namespace Bee\MVC\ViewResolver; /* - * 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. @@ -20,6 +20,8 @@ use Bee\MVC\IHttpRequest; use Bee\MVC\IView; use Bee\MVC\IViewResolver; +use Bee\MVC\ModelAndView; +use Bee\MVC\View\ViewBase; use Logger; /** @@ -114,4 +116,36 @@ protected function modifyViewName($viewName, IHttpRequest $request) { return $request->getAjax() ? $viewName . $this->ajaxViewNameSuffix : $viewName; } + + /** + * @param ModelAndView $mav + * @param IHttpRequest $request + */ + public function resolveModelAndView(ModelAndView $mav, IHttpRequest $request) { + $resolvedView = $this->resolveViewName($mav->getViewName(), $request); + $mav->setResolvedView($resolvedView); + if ($resolvedView instanceof ViewBase) { + $statics = $resolvedView->getStaticAttributes(); + if (!$statics) { + $statics = array(); + } + $model = array_merge($statics, $mav->getModel()); + $mav->setModel($model); + } + $this->resolveModelInternals($mav->getModel(), $request); + } + + /** + * @param array $model + * @param IHttpRequest $request + */ + private function resolveModelInternals(array $model, IHttpRequest $request) { + foreach ($model as $modelElem) { + if ($modelElem instanceof ModelAndView) { + $this->resolveModelAndView($modelElem, $request); + } else if (is_array($modelElem)) { + $this->resolveModelInternals($modelElem, $request); + } + } + } } \ No newline at end of file Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2015-01-16 14:37:32 UTC (rev 278) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2015-01-29 11:24:41 UTC (rev 279) @@ -127,7 +127,7 @@ * @return UserBase */ public function setRoles(array $frmdata, UserBase $user) { - /** @var SimpleUser $user */ + /** @var SimpleUserBase $user */ if ($frmdata['admin']) { $user->addRole('ROLE_ADMINISTRATOR'); } else { Modified: trunk/framework/Bee/Security/UserDetails/UserManagerBase.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/UserManagerBase.php 2015-01-16 14:37:32 UTC (rev 278) +++ trunk/framework/Bee/Security/UserDetails/UserManagerBase.php 2015-01-29 11:24:41 UTC (rev 279) @@ -76,12 +76,29 @@ * @throws Exception */ public function createOrUpdateUser(array $frmdata) { - $user = is_numeric($frmdata['id']) ? $this->loadById($frmdata['id']) : $this->createUserInstance(); + return $this->updateUser($this->findOrCreateUser($frmdata), $frmdata); + } + + /** + * @param array $frmdata + * @return UserBase + */ + protected function findOrCreateUser(array $frmdata) { + return is_numeric($frmdata['id']) ? $this->loadById($frmdata['id']) : $this->createUserInstance(); + } + + /** + * @param UserBase $user + * @param array $frmdata + * @return UserBase + * @throws PasswordConfirmationMismatchException + */ + protected function updateUser(UserBase $user, array $frmdata) { $user->setUsername($frmdata['username']); $user->setName($frmdata['fullname']); if (Strings::hasText($frmdata['password'])) { if ($frmdata['password'] !== $frmdata['password2']) { - throw new Exception("Passwords do not match!"); + throw new PasswordConfirmationMismatchException("Passwords do not match!"); } $this->setPassword($user, $frmdata['password']); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2015-01-16 14:37:35
|
Revision: 278 http://sourceforge.net/p/beeframework/code/278 Author: m_plomer Date: 2015-01-16 14:37:32 +0000 (Fri, 16 Jan 2015) Log Message: ----------- - MVC: added IWidgetController PHPDoc Modified Paths: -------------- trunk/framework/Bee/MVC/IWidgetController.php Modified: trunk/framework/Bee/MVC/IWidgetController.php =================================================================== --- trunk/framework/Bee/MVC/IWidgetController.php 2015-01-16 08:39:28 UTC (rev 277) +++ trunk/framework/Bee/MVC/IWidgetController.php 2015-01-16 14:37:32 UTC (rev 278) @@ -21,5 +21,10 @@ * @package Bee\MVC */ interface IWidgetController extends IController { + + /** + * @param IHttpRequest $request + * @return ModelAndView + */ function handleDefault(IHttpRequest $request); } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2015-01-16 08:39:36
|
Revision: 277 http://sourceforge.net/p/beeframework/code/277 Author: m_plomer Date: 2015-01-16 08:39:28 +0000 (Fri, 16 Jan 2015) Log Message: ----------- - MVC: added IWidgetController and proper handling of its handleDefault() invocation Modified Paths: -------------- trunk/framework/Bee/MVC/Controller/MultiActionController.php trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php trunk/framework/Bee/MVC/Controller/Multiaction/IHandlerMethodInvocator.php Added Paths: ----------- trunk/framework/Bee/MVC/IWidgetController.php Modified: trunk/framework/Bee/MVC/Controller/MultiActionController.php =================================================================== --- trunk/framework/Bee/MVC/Controller/MultiActionController.php 2014-12-19 23:21:30 UTC (rev 276) +++ trunk/framework/Bee/MVC/Controller/MultiActionController.php 2015-01-16 08:39:28 UTC (rev 277) @@ -20,6 +20,7 @@ use Bee\MVC\Controller\Multiaction\NoHandlerMethodFoundException; use Bee\MVC\IDelegatingHandler; use Bee\MVC\IHttpRequest; +use Bee\MVC\IWidgetController; use Bee\MVC\ModelAndView; use Bee\Utils\Assert; use Bee\Utils\Reflection; @@ -39,7 +40,7 @@ * @author Michael Plomer <mic...@it...> * @author Benjamin Hartmann */ -class MultiActionController extends AbstractController implements IDelegatingHandler { +class MultiActionController extends AbstractController implements IDelegatingHandler, IWidgetController { /** * Enter description here... @@ -94,12 +95,7 @@ if (!Strings::hasText($methodName)) { $methodName = $this->getDefaultMethodName(); } - - // @todo: this might pose a security risk. introduce a set of allowed method names - $method = new ReflectionMethod($this->delegate, $methodName); - if (!$this->isHandlerMethod($method)) { - throw new NoHandlerMethodFoundException('No request handling method with name ' . $methodName . ' in class [' . Types::getType($this->delegate) . ']'); - } + $method = $this->getReflectionMethodForName($methodName); } return $method->invokeArgs($this->delegate, array($request)); } @@ -203,4 +199,30 @@ public function getMethodNameResolver() { return $this->methodNameResolver; } + + /** + * @param IHttpRequest $request + * @return mixed + * @throws NoHandlerMethodFoundException + */ + public function handleDefault(IHttpRequest $request) { + if(!is_null($this->methodInvocator)) { + return $this->methodInvocator->invokeDefaultHandlerMethod($request); + } + return $this->getReflectionMethodForName($this->getDefaultMethodName())->invokeArgs($this->delegate, array($request)); + } + + /** + * @param string $methodName + * @return ReflectionMethod + * @throws NoHandlerMethodFoundException + */ + protected function getReflectionMethodForName($methodName) { + // @todo: this might pose a security risk. introduce a set of allowed method names + $method = new ReflectionMethod($this->delegate, $methodName); + if (!$this->isHandlerMethod($method)) { + throw new NoHandlerMethodFoundException('No request handling method with name ' . $methodName . ' in class [' . Types::getType($this->delegate) . ']'); + } + return $method; + } } \ No newline at end of file Modified: trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php =================================================================== --- trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php 2014-12-19 23:21:30 UTC (rev 276) +++ trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/AnnotationBasedInvocator.php 2015-01-16 08:39:28 UTC (rev 277) @@ -20,7 +20,6 @@ use Bee\IContext; use Bee\MVC\Controller\Multiaction\AbstractAnnotationBasedResolver; use Bee\MVC\Controller\Multiaction\IHandlerMethodInvocator; -use Bee\MVC\IController; use Bee\MVC\IHttpRequest; use Bee\MVC\ModelAndView; @@ -93,6 +92,16 @@ } // todo: + return $this->invokeResolvedMethod($resolvedMethod, $request, $fixedParams); + } + + /** + * @param MethodInvocation $resolvedMethod + * @param IHttpRequest $request + * @param array $fixedParams + * @return mixed + */ + protected function invokeResolvedMethod(MethodInvocation $resolvedMethod, IHttpRequest $request, array $fixedParams = array()) { $methodMeta = $resolvedMethod->getMethodMeta(); $method = $methodMeta->getMethod(); $args = array(); @@ -107,7 +116,7 @@ $propEditor = $this->propertyEditorRegistry->getEditor($type); $posMap = $resolvedMethod->getUrlParameterPositions(); $value = array_key_exists($pos, $posMap) ? $resolvedMethod->getParamValue($posMap[$pos]) : - (array_key_exists($parameter->getName(), $_REQUEST) ? $_REQUEST[$parameter->getName()] : null); + (array_key_exists($parameter->getName(), $_REQUEST) ? $_REQUEST[$parameter->getName()] : null); if (!is_null($value) || !$parameter->isOptional()) { $args[$pos] = $propEditor->fromString($value); } else { @@ -162,4 +171,12 @@ public function setDefaultMethodName($defaultMethodName) { $this->defaultMethodName = $defaultMethodName; } + + /** + * @param IHttpRequest $request + * @return mixed + */ + public function invokeDefaultHandlerMethod(IHttpRequest $request) { + return $this->invokeResolvedMethod($this->getDefaultMethodInvocation(), $request); + } } \ No newline at end of file Modified: trunk/framework/Bee/MVC/Controller/Multiaction/IHandlerMethodInvocator.php =================================================================== --- trunk/framework/Bee/MVC/Controller/Multiaction/IHandlerMethodInvocator.php 2014-12-19 23:21:30 UTC (rev 276) +++ trunk/framework/Bee/MVC/Controller/Multiaction/IHandlerMethodInvocator.php 2015-01-16 08:39:28 UTC (rev 277) @@ -37,4 +37,6 @@ * @return ModelAndView */ public function invokeHandlerMethod(IHttpRequest $request, array $fixedParams = array()); + + public function invokeDefaultHandlerMethod(IHttpRequest $request); } \ No newline at end of file Added: trunk/framework/Bee/MVC/IWidgetController.php =================================================================== --- trunk/framework/Bee/MVC/IWidgetController.php (rev 0) +++ trunk/framework/Bee/MVC/IWidgetController.php 2015-01-16 08:39:28 UTC (rev 277) @@ -0,0 +1,25 @@ +<?php +namespace Bee\MVC; +/* + * 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. + */ + +/** + * Interface IWidgetController - IController instance that has a default handler method. + * @package Bee\MVC + */ +interface IWidgetController extends IController { + function handleDefault(IHttpRequest $request); +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-12-19 23:21:43
|
Revision: 276 http://sourceforge.net/p/beeframework/code/276 Author: m_plomer Date: 2014-12-19 23:21:30 +0000 (Fri, 19 Dec 2014) Log Message: ----------- - AntPathToRegexTransformer: extended the ant path syntax to allow for an optional trainling slash (default, one slash) or a mandatory one (designated by a double trailing slash) Modified Paths: -------------- trunk/framework/Bee/Utils/AntPathToRegexTransformer.php trunk/tests/Bee/Utils/AntPathDataProvider.php Modified: trunk/framework/Bee/Utils/AntPathToRegexTransformer.php =================================================================== --- trunk/framework/Bee/Utils/AntPathToRegexTransformer.php 2014-11-08 13:34:09 UTC (rev 275) +++ trunk/framework/Bee/Utils/AntPathToRegexTransformer.php 2014-12-19 23:21:30 UTC (rev 276) @@ -28,7 +28,9 @@ '#\(\[\^/\]\*\)\(\[\^/\]\*\)/#' => '((?:[^/]+/)*?)', // "**/" - replaced by "([^/]+)" above - matches 0:n path elements '#\(\[\^/\]\*\)\(\[\^/\]\*\)#' => '(.*?)', '#(^|(?<=[^(*]))\?#' => '[^/]', - '#/\(\.\*\?\)$#' => '(?:/(.*?))??' + '#/\(\.\*\?\)$#' => '(?:/(.*?))??', + '#([^/])/$#' => '$1/?', + '#//$#' => '/' ); public static $TYPE_EXPRESSION_MAP = array( Modified: trunk/tests/Bee/Utils/AntPathDataProvider.php =================================================================== --- trunk/tests/Bee/Utils/AntPathDataProvider.php 2014-11-08 13:34:09 UTC (rev 275) +++ trunk/tests/Bee/Utils/AntPathDataProvider.php 2014-12-19 23:21:30 UTC (rev 276) @@ -25,91 +25,90 @@ public function matchDataProvider() { return array( // test exact matching - array("test", "test", True), // #0 - array("/test", "/test", True), // #1 - array("/test.jpg", "test.jpg", False), // #2 - array("test", "/test", False), // #3 - array("/test", "test", False), // #4 +/* 0 */ array("test", "test", True), // #0 +/* 1 */ array("/test", "/test", True), // #1 +/* 2 */ array("/test.jpg", "test.jpg", False), // #2 +/* 3 */ array("test", "/test", False), // #3 +/* 4 */ array("/test", "test", False), // #4 +/* */ // test matching with ?'s +/* 5 */ array("t?st", "test", True), // #5 +/* 6 */ array("??st", "test", True), // #6 +/* 7 */ array("tes?", "test", True), // #7 +/* 8 */ array("te??", "test", True), // #8 +/* 9 */ array("?es?", "test", True), // #9 +/* 10 */ array("tes?", "tes", False), // #10 +/* 11 */ array("tes?", "testt", False), +/* 12 */ array("tes?", "tsst", False), +/* */ // test matchin with *'s +/* 13 */ array("*", "test", True), +/* 14 */ array("test*", "test", True), +/* 15 */ array("test*", "testTest", True), // #15 +/* 16 */ array("test/*", "test/Test", True), +/* 17 */ array("test/*", "test/t", True), +/* 18 */ array("test/*", "test/", True), +/* 19 */ array("*test*", "AnothertestTest", True), +/* 20 */ array("*test", "Anothertest", True), // #20 +/* 21 */ array("*.*", "test.", True), +/* 22 */ array("*.*", "test.test", True), +/* 23 */ array("*.*", "test.test.test", True), +/* 24 */ array("test*aaa", "testblaaaa", True), +/* 25 */ array("test*", "tst", False), // #25 +/* 26 */ array("test*", "tsttest", False), +/* 27 */ array("test*", "test/", False), +/* 28 */ array("test*", "test/t", False), +/* 29 */ array("test/*", "test", False), +/* 30 */ array("*test*", "tsttst", False), // #30 +/* 31 */ array("*test", "tsttst", False), +/* 32 */ array("*.*", "tsttst", False), +/* 33 */ array("test*aaa", "test", False), +/* 34 */ array("test*aaa", "testblaaab", False), +/* */ // test matching with ?'s and /'s +/* 35 */ array("/?", "/a", True), // #35 +/* 36 */ array("/?/a", "/a/a", True), +/* 37 */ array("/a/?", "/a/b", True), +/* 38 */ array("/??/a", "/aa/a", True), +/* 39 */ array("/a/??", "/a/bb", True), +/* 40 */ array("/?", "/a", True), // #40 +/* */ // test matching with **'s +/* 41 */ array("/**", "/testing/testing", True), // #41 +/* 42 */ array("/*/**", "/testing/testing", True), // #42 +/* 43 */ array("/**/*", "/testing/testing", True), // #43 +/* 44 */ array("/bla/**/bla", "/bla/testing/testing/bla", True), // #44 +/* 45 */ array("/bla/**/bla", "/bla/testing/testing/bla/bla", True), // #45 +/* 46 */ array("/**/test", "/bla/bla/test", True), // #48 +/* 47 */ array("/**/test", "/test", True), // #47 +/* 48 */ array("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla", True), // #48 +/* 49 */ array("/bla*bla/test", "/blaXXXbla/test", True), // #49 +/* 50 */ array("/*bla/test", "/XXXbla/test", True), // #50 +/* 51 */ array("/bla*bla/test", "/blaXXXbl/test", False), // #51 +/* 52 */ array("/*bla/test", "XXXblab/test", False), // #52 +/* 53 */ array("/*bla/test", "XXXbl/test", False), // #53 +/* 54 */ array("/*bla/test", "/bla/test", true), // #54 +/* 55 */ array("/????", "/bala/bla", False), +/* 56 */ array("/**/*bla", "/bla/bla/bla/bbb", False), +/* 57 */ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/", True), // #55 +/* 58 */ array("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing", True), +/* 59 */ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing", True), +/* 60 */ array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg", True), +/* 61 */ array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/", True), +/* 62 */ array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing", True), // #60 +/* 63 */ array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing", True), +/* 64 */ array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing", False), +/* 65 */ array("/x/x/**/bla", "/x/x/x/", False), +/* 66 */ array("/x/x/**/bla", "/x/x/bla", true), +/* */ // trailing slash tests +/* 67 */ array("/x/x/**/bla/", "/x/x/bla/", true), +/* 68 */ array("/x/x/**/bla/", "/x/x/bla", true), +/* 69 */ array("/x/x/**/bla", "/x/x/bla/", false), +/* 70 */ array("/x/x/**/bla", "/x/x/bla", true), +/* 71 */ array("/x/x/**/bla//", "/x/x/bla/", true),// fails +/* 72 */ array("/x/x/**/bla//", "/x/x/bla", false), - // test matching with ?'s - array("t?st", "test", True), // #5 - array("??st", "test", True), // #6 - array("tes?", "test", True), // #7 - array("te??", "test", True), // #8 - array("?es?", "test", True), // #9 - array("tes?", "tes", False), // #10 - array("tes?", "testt", False), - array("tes?", "tsst", False), +/* 73 */ array("/test/**", "/test", true), - // test matchin with *'s - array("*", "test", True), - array("test*", "test", True), - array("test*", "testTest", True), // #15 - array("test/*", "test/Test", True), - array("test/*", "test/t", True), - array("test/*", "test/", True), - array("*test*", "AnothertestTest", True), - array("*test", "Anothertest", True), // #20 - array("*.*", "test.", True), - array("*.*", "test.test", True), - array("*.*", "test.test.test", True), - array("test*aaa", "testblaaaa", True), - array("test*", "tst", False), // #25 - array("test*", "tsttest", False), - array("test*", "test/", False), - array("test*", "test/t", False), - array("test/*", "test", False), - array("*test*", "tsttst", False), // #30 - array("*test", "tsttst", False), - array("*.*", "tsttst", False), - array("test*aaa", "test", False), - array("test*aaa", "testblaaab", False), +/* 74 */ array("/**", "", true), // fails +/* 75 */ array("", "", true)//, - // test matching with ?'s and /'s - array("/?", "/a", True), // #35 - array("/?/a", "/a/a", True), - array("/a/?", "/a/b", True), - array("/??/a", "/aa/a", True), - array("/a/??", "/a/bb", True), - array("/?", "/a", True), // #40 - - // test matching with **'s - array("/**", "/testing/testing", True), // #41 - array("/*/**", "/testing/testing", True), // #42 - array("/**/*", "/testing/testing", True), // #43 - array("/bla/**/bla", "/bla/testing/testing/bla", True), // #44 - array("/bla/**/bla", "/bla/testing/testing/bla/bla", True), // #45 - array("/**/test", "/bla/bla/test", True), // #48 - array("/**/test", "/test", True), // #47 - array("/bla/**/**/bla", "/bla/bla/bla/bla/bla/bla", True), // #48 - array("/bla*bla/test", "/blaXXXbla/test", True), // #49 - array("/*bla/test", "/XXXbla/test", True), // #50 - array("/bla*bla/test", "/blaXXXbl/test", False), // #51 - array("/*bla/test", "XXXblab/test", False), // #52 - array("/*bla/test", "XXXbl/test", False), // #53 - array("/*bla/test", "/bla/test", true), // #54 - - array("/????", "/bala/bla", False), - array("/**/*bla", "/bla/bla/bla/bbb", False), - - array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing/", True), // #55 - array("/*bla*/**/bla/*", "/XXXblaXXXX/testing/testing/bla/testing", True), - array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing", True), - array("/*bla*/**/bla/**", "/XXXblaXXXX/testing/testing/bla/testing/testing.jpg", True), - - array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing/", True), - array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing", True), // #60 - array("*bla*/**/bla/**", "XXXblaXXXX/testing/testing/bla/testing/testing", True), - array("*bla*/**/bla/*", "XXXblaXXXX/testing/testing/bla/testing/testing", False), - - array("/x/x/**/bla", "/x/x/x/", False), - array("/x/x/**/bla", "/x/x/bla", true), - - array("/test/**", "/test", true), - - array("/**", "", true), - array("", "", true)//, - // array("/{bla}.*", "/testing.html", True) // #65 ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-11-08 13:34:16
|
Revision: 275 http://sourceforge.net/p/beeframework/code/275 Author: m_plomer Date: 2014-11-08 13:34:09 +0000 (Sat, 08 Nov 2014) Log Message: ----------- - Framework::getLoggerForClass: allow for object instance to be passed Modified Paths: -------------- trunk/framework/Bee/Framework.php Modified: trunk/framework/Bee/Framework.php =================================================================== --- trunk/framework/Bee/Framework.php 2014-11-08 11:15:01 UTC (rev 274) +++ trunk/framework/Bee/Framework.php 2014-11-08 13:34:09 UTC (rev 275) @@ -352,11 +352,14 @@ } /** - * @param string $className + * @param string|object $classOrClassName * @return Logger */ - public static function getLoggerForClass($className) { - return Logger::getLogger(str_replace('_', '.', str_replace('\\', '.', $className))); + public static function getLoggerForClass($classOrClassName) { + if(is_object($classOrClassName)) { + $classOrClassName = get_class($classOrClassName); + } + return Logger::getLogger(str_replace('_', '.', str_replace('\\', '.', $classOrClassName))); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-11-08 11:15:11
|
Revision: 274 http://sourceforge.net/p/beeframework/code/274 Author: m_plomer Date: 2014-11-08 11:15:01 +0000 (Sat, 08 Nov 2014) Log Message: ----------- - DaoAuthentication: fixed regression from namespace refactorings Modified Paths: -------------- trunk/framework/Bee/Security/Provider/DaoAuthentication.php Modified: trunk/framework/Bee/Security/Provider/DaoAuthentication.php =================================================================== --- trunk/framework/Bee/Security/Provider/DaoAuthentication.php 2014-11-07 16:40:36 UTC (rev 273) +++ trunk/framework/Bee/Security/Provider/DaoAuthentication.php 2014-11-08 11:15:01 UTC (rev 274) @@ -22,8 +22,8 @@ use Bee\Security\IPasswordEncoder; use Bee\Security\IUserDetails; use Bee\Security\IUserDetailsService; +use Bee\Security\PasswordEncoder\PlainTextEncoder; use Bee\Security\UsernamePasswordAuthenticationToken; -use Bee_Security_PasswordEncoder_PlainText; /** * Class DaoAuthentication @@ -53,7 +53,7 @@ private $userDetailsService; public function __construct() { - $this->passwordEncoder = new Bee_Security_PasswordEncoder_PlainText(); + $this->passwordEncoder = new PlainTextEncoder(); } protected function additionalAuthenticationChecks(IUserDetails $userDetails, UsernamePasswordAuthenticationToken $authentication) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-11-07 16:40:40
|
Revision: 273 http://sourceforge.net/p/beeframework/code/273 Author: m_plomer Date: 2014-11-07 16:40:36 +0000 (Fri, 07 Nov 2014) Log Message: ----------- - EntityManagerHolder: proper Logger selection through BeeFramework class Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php Modified: trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php 2014-11-06 10:39:07 UTC (rev 272) +++ trunk/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php 2014-11-07 16:40:36 UTC (rev 273) @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use BeeFramework; use \Doctrine\ORM\EntityManager; use Logger; @@ -36,7 +37,7 @@ */ public function getLog() { if (!$this->log) { - $this->log = Logger::getLogger(get_class($this)); + $this->log = BeeFramework::getLoggerForClass(get_class($this)); } return $this->log; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-11-06 10:39:16
|
Revision: 272 http://sourceforge.net/p/beeframework/code/272 Author: m_plomer Date: 2014-11-06 10:39:07 +0000 (Thu, 06 Nov 2014) Log Message: ----------- - PaginationBase: changed default page size to zero (no pagination) Modified Paths: -------------- branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php Modified: branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php =================================================================== --- branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php 2014-10-31 07:51:50 UTC (rev 271) +++ branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php 2014-11-06 10:39:07 UTC (rev 272) @@ -28,7 +28,7 @@ /** * @var int */ - private $pageSize = 10; + private $pageSize = 0; /** * @var int This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-31 07:51:54
|
Revision: 271 http://sourceforge.net/p/beeframework/code/271 Author: m_plomer Date: 2014-10-31 07:51:50 +0000 (Fri, 31 Oct 2014) Log Message: ----------- - backport of proper Doctrine2 pagination from trunk Modified Paths: -------------- branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php Modified: branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php =================================================================== --- branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php 2014-10-31 07:35:38 UTC (rev 270) +++ branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php 2014-10-31 07:51:50 UTC (rev 271) @@ -28,7 +28,7 @@ /** * @var int */ - private $pageSize = 50; + private $pageSize = 10; /** * @var int This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-31 07:35:47
|
Revision: 270 http://sourceforge.net/p/beeframework/code/270 Author: m_plomer Date: 2014-10-31 07:35:38 +0000 (Fri, 31 Oct 2014) Log Message: ----------- - backport of proper Doctrine2 pagination from trunk Modified Paths: -------------- branches/0.9-dev/framework/Bee/Persistence/Doctrine/DaoBase.php branches/0.9-dev/framework/Bee/Persistence/Doctrine2/DaoBase.php branches/0.9-dev/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php branches/0.9-dev/framework/Bee/Persistence/IOrderAndLimitHolder.php Added Paths: ----------- branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php Modified: branches/0.9-dev/framework/Bee/Persistence/Doctrine/DaoBase.php =================================================================== --- branches/0.9-dev/framework/Bee/Persistence/Doctrine/DaoBase.php 2014-10-31 07:15:22 UTC (rev 269) +++ branches/0.9-dev/framework/Bee/Persistence/Doctrine/DaoBase.php 2014-10-31 07:35:38 UTC (rev 270) @@ -1,6 +1,6 @@ <?php /* - * Copyright 2008-2010 the original author or authors. + * 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. @@ -141,7 +141,6 @@ } foreach ($orderMapping as $orderField => $orderDir) { -// $query->orderBy($orderField.' '.$orderDir); $query->addOrderBy($orderField . ' ' . $orderDir); } @@ -151,13 +150,7 @@ if ($orderAndLimitHolder->getPageSize() > 0) { $query->limit($orderAndLimitHolder->getPageSize()); - - $pageCount = ceil($query->count($params) / $orderAndLimitHolder->getPageSize()); - $orderAndLimitHolder->setPageCount($pageCount); - - if ($orderAndLimitHolder->getCurrentPage() > $pageCount) { - $orderAndLimitHolder->setCurrentPage($pageCount); - } + $orderAndLimitHolder->setResultCount($query->count($params)); $query->offset($orderAndLimitHolder->getCurrentPage() * $orderAndLimitHolder->getPageSize()); } } Modified: branches/0.9-dev/framework/Bee/Persistence/Doctrine2/DaoBase.php =================================================================== --- branches/0.9-dev/framework/Bee/Persistence/Doctrine2/DaoBase.php 2014-10-31 07:15:22 UTC (rev 269) +++ branches/0.9-dev/framework/Bee/Persistence/Doctrine2/DaoBase.php 2014-10-31 07:35:38 UTC (rev 270) @@ -1,12 +1,28 @@ <?php namespace Bee\Persistence\Doctrine2; + +/* + * 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_Persistence_IOrderAndLimitHolder; use Bee_Persistence_IRestrictionHolder; use Bee_Utils_Strings; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\Tools\Pagination\Paginator; use Exception; -use Logger; /** * User: mp @@ -16,21 +32,6 @@ class DaoBase extends EntityManagerHolder { /** - * @var Logger - */ - protected $log; - - /** - * @return Logger - */ - protected function getLog() { - if (!$this->log) { - $this->log = Logger::getLogger(get_class($this)); - } - return $this->log; - } - - /** * @param QueryBuilder $queryBuilder * @param Bee_Persistence_IRestrictionHolder $restrictionHolder * @param Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder @@ -38,11 +39,15 @@ * @param null $hydrationMode * @return array */ - public function executeListQuery(QueryBuilder $queryBuilder, Bee_Persistence_IRestrictionHolder $restrictionHolder = null, Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping, $hydrationMode = null) { - $this->applyFilterRestrictions($queryBuilder, $restrictionHolder); - $this->applyOrderAndLimit($queryBuilder, $orderAndLimitHolder, $defaultOrderMapping); - return $this->getQueryFromBuilder($queryBuilder)->execute(null, $hydrationMode); - } + public function executeListQuery(QueryBuilder $queryBuilder, Bee_Persistence_IRestrictionHolder $restrictionHolder = null, Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping, $hydrationMode = null) { + $this->applyFilterRestrictions($queryBuilder, $restrictionHolder); + $this->applyOrderMapping($queryBuilder, $orderAndLimitHolder, $defaultOrderMapping); + $q = $this->getQueryFromBuilder($queryBuilder); + if(!is_null($hydrationMode)) { + $q->setHydrationMode($hydrationMode); + } + return $this->getPaginatedOrderedResultFromQuery($q, $orderAndLimitHolder); + } /** * @param QueryBuilder $qb @@ -57,81 +62,68 @@ * @param Bee_Persistence_IRestrictionHolder $restrictionHolder * @internal param QueryBuilder $query */ - protected final function applyFilterRestrictions(QueryBuilder &$queryBuilder, Bee_Persistence_IRestrictionHolder $restrictionHolder = null) { - if (is_null($restrictionHolder)) { - return; - } + protected final function applyFilterRestrictions(QueryBuilder &$queryBuilder, Bee_Persistence_IRestrictionHolder $restrictionHolder = null) { + if (is_null($restrictionHolder)) { + return; + } - if (!Bee_Utils_Strings::hasText($restrictionHolder->getFilterString())) { - return; - } + if (!Bee_Utils_Strings::hasText($restrictionHolder->getFilterString())) { + return; + } - $filterTokens = Bee_Utils_Strings::tokenizeToArray($restrictionHolder->getFilterString(), ' '); - foreach ($filterTokens as $no => $token) { - $andWhereString = ''; - $params = array(); + $filterTokens = Bee_Utils_Strings::tokenizeToArray($restrictionHolder->getFilterString(), ' '); + foreach ($filterTokens as $no => $token) { + $andWhereString = ''; + $params = array(); - $tokenName = 'filtertoken'.$no; - $params[$tokenName] = '%'.$token.'%'; + $tokenName = 'filtertoken' . $no; + $params[$tokenName] = '%' . $token . '%'; - foreach ($restrictionHolder->getFilterableFields() as $fieldName) { - // $fieldName MUST BE A DOCTRINE NAME - if (Bee_Utils_Strings::hasText($andWhereString)) { - $andWhereString .= ' OR '; - } + foreach ($restrictionHolder->getFilterableFields() as $fieldName) { + // $fieldName MUST BE A DOCTRINE NAME + if (Bee_Utils_Strings::hasText($andWhereString)) { + $andWhereString .= ' OR '; + } - $andWhereString .= $fieldName.' LIKE :'.$tokenName; - } + $andWhereString .= $fieldName . ' LIKE :' . $tokenName; + } - if (Bee_Utils_Strings::hasText($andWhereString)) { - $queryBuilder->andWhere($andWhereString); + if (Bee_Utils_Strings::hasText($andWhereString)) { + $queryBuilder->andWhere($andWhereString); - foreach ($params as $key => $value) { - $queryBuilder->setParameter($key, $value); - } - } - } - } + foreach ($params as $key => $value) { + $queryBuilder->setParameter($key, $value); + } + } + } + } /** * @param QueryBuilder $queryBuilder * @param Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder * @param array $defaultOrderMapping */ - protected final function applyOrderAndLimit(QueryBuilder &$queryBuilder, Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping = array()) { - if (is_null($orderAndLimitHolder)) { - $orderMapping = $defaultOrderMapping; - } else { - $orderMapping = count($orderAndLimitHolder->getOrderMapping()) > 0 ? $orderAndLimitHolder->getOrderMapping() : $defaultOrderMapping; - } + protected final function applyOrderMapping(QueryBuilder &$queryBuilder, Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping = null) { + if (is_null($defaultOrderMapping)) { + $defaultOrderMapping = array(); + } + if (is_null($orderAndLimitHolder)) { + $orderMapping = $defaultOrderMapping; + } else { + $orderMapping = count($orderAndLimitHolder->getOrderMapping()) > 0 ? $orderAndLimitHolder->getOrderMapping() : $defaultOrderMapping; + } - foreach ($orderMapping as $orderField => $orderDir) { - $queryBuilder->addOrderBy($orderField, $orderDir); - } + foreach ($orderMapping as $orderField => $orderDir) { + $queryBuilder->addOrderBy($orderField, $orderDir); + } + } - if (is_null($orderAndLimitHolder)) { - return; - } - - if ($orderAndLimitHolder->getPageSize() > 0) { - $queryBuilder->setMaxResults($orderAndLimitHolder->getPageSize()); - - // TODO: build a performant count-query! This is simply bullshit! - $pageCount = ceil(count($this->getQueryFromBuilder($queryBuilder)->execute()) / $orderAndLimitHolder->getPageSize()); - $orderAndLimitHolder->setPageCount($pageCount); - - if ($orderAndLimitHolder->getCurrentPage() > $pageCount) { - $orderAndLimitHolder->setCurrentPage($pageCount); - } - $queryBuilder->setFirstResult($orderAndLimitHolder->getCurrentPage() * $orderAndLimitHolder->getPageSize()); - $queryBuilder->setMaxResults($orderAndLimitHolder->getPageSize()); - } - } - /** * @param callback $func * @throws Exception * @return mixed + * + * @deprecated use EntityManagerHolder::transactional() instead */ public function doInTransaction($func) { $this->getLog()->info('Begin transaction.'); @@ -152,4 +144,29 @@ throw $e; } } + + /** + * @param Query $q + * @param Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder + * @return array|Paginator + */ + protected function getPaginatedOrderedResultFromQuery(Query $q, Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder = null) { + if (!is_null($orderAndLimitHolder) && $orderAndLimitHolder->getPageSize() > 0) { + $q->setFirstResult($orderAndLimitHolder->getCurrentPage() * $orderAndLimitHolder->getPageSize()); + $q->setMaxResults($orderAndLimitHolder->getPageSize()); + $paginator = new Paginator($q, $this->useWhereInPagination()); + $paginator->setUseOutputWalkers(false); + $orderAndLimitHolder->setResultCount(count($paginator)); + return $paginator; + } else { + return $q->getResult($q->getHydrationMode()); + } + } + + /** + * @return bool + */ + protected function useWhereInPagination() { + return true; + } } Modified: branches/0.9-dev/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php =================================================================== --- branches/0.9-dev/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php 2014-10-31 07:15:22 UTC (rev 269) +++ branches/0.9-dev/framework/Bee/Persistence/Doctrine2/EntityManagerHolder.php 2014-10-31 07:35:38 UTC (rev 270) @@ -1,7 +1,7 @@ <?php namespace Bee\Persistence\Doctrine2; /* - * Copyright 2008-2010 the original author or authors. + * 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. @@ -16,6 +16,7 @@ * limitations under the License. */ use \Doctrine\ORM\EntityManager; +use Logger; /** * User: mp @@ -26,6 +27,21 @@ class EntityManagerHolder { /** + * @var Logger + */ + protected $log; + + /** + * @return Logger + */ + public function getLog() { + if (!$this->log) { + $this->log = Logger::getLogger(get_class($this)); + } + return $this->log; + } + + /** * @var EntityManager */ private $entityManager; @@ -43,4 +59,16 @@ public function setEntityManager(EntityManager $entityManager) { $this->entityManager = $entityManager; } + + /** + * Convenience wrapper around EntityManager::transactional() + * @param $callback + * @return mixed + */ + public function transactional($callback) { + $that = $this; + return $this->getEntityManager()->transactional(function (EntityManager $em) use ($callback, $that) { + return $callback($that); + }); + } } Modified: branches/0.9-dev/framework/Bee/Persistence/IOrderAndLimitHolder.php =================================================================== --- branches/0.9-dev/framework/Bee/Persistence/IOrderAndLimitHolder.php 2014-10-31 07:15:22 UTC (rev 269) +++ branches/0.9-dev/framework/Bee/Persistence/IOrderAndLimitHolder.php 2014-10-31 07:35:38 UTC (rev 270) @@ -1,5 +1,23 @@ <?php +/* + * 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. + */ +/** + * Interface Bee_Persistence_IOrderAndLimitHolder + */ interface Bee_Persistence_IOrderAndLimitHolder { /** @@ -18,11 +36,6 @@ public function getPageCount(); /** - * @param $pageCount - */ - public function setPageCount($pageCount); - - /** * @return int */ public function getCurrentPage(); @@ -32,6 +45,8 @@ */ public function setCurrentPage($currentPage); + /** + * @param int $resultCount + */ + public function setResultCount($resultCount); } - -?> \ No newline at end of file Added: branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php =================================================================== --- branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php (rev 0) +++ branches/0.9-dev/framework/Bee/Persistence/PaginationBase.php 2014-10-31 07:35:38 UTC (rev 270) @@ -0,0 +1,103 @@ +<?php +namespace Bee\Persistence; +/* + * 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_Persistence_IOrderAndLimitHolder; + +/** + * Class BasicListStateHolder + * + * Implements the pagination aspect of the IOrderAndLimitHolder and embodies generic logic for + * @package Bee\Persistence + */ +abstract class PaginationBase implements Bee_Persistence_IOrderAndLimitHolder { + + /** + * @var int + */ + private $pageSize = 50; + + /** + * @var int + */ + private $currentPage = 0; + + /** + * @var int + */ + private $resultCount; + + /** + * @return int + */ + public function getPageSize() { + return $this->pageSize; + } + + /** + * @param int $pageSize + */ + public function setPageSize($pageSize) { + $this->pageSize = $pageSize; + } + + /** + * @return int + */ + public function getPageCount() { + return ceil($this->getResultCount() / $this->getPageSize()); + } + + /** + * @return int + */ + public function getCurrentPage() { + return $this->currentPage; + } + + /** + * @param $currentPage + */ + public function setCurrentPage($currentPage) { + $currentPage = $currentPage < 0 ? 0 : $currentPage; + $this->currentPage = $currentPage; + } + + /** + * @param int $resultCount + */ + public function setResultCount($resultCount) { + $this->resultCount = $resultCount; + if($this->getCurrentPage() >= $this->getPageCount()) { + $this->setCurrentPage($this->getPageCount() - 1); + } + } + + /** + * @return int + */ + public function getResultCount() { + return $this->resultCount; + } + + /** + * Implements the default behavior in case the current page is beyond the acceptable limit. By default, sets the + * current page to the last page. + */ + protected function adjustCurrentPageOnOverflow() { + $this->setCurrentPage($this->getPageCount() - 1); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-31 07:15:25
|
Revision: 269 http://sourceforge.net/p/beeframework/code/269 Author: m_plomer Date: 2014-10-31 07:15:22 +0000 (Fri, 31 Oct 2014) Log Message: ----------- - updated svn:ignore Property Changed: ---------------- trunk/ Index: trunk =================================================================== --- trunk 2014-10-31 07:08:22 UTC (rev 268) +++ trunk 2014-10-31 07:15:22 UTC (rev 269) Property changes on: trunk ___________________________________________________________________ Modified: svn:ignore ## -1,3 +1,3 ## .idea -vendor/** composer.lock +vendor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-31 07:08:33
|
Revision: 268 http://sourceforge.net/p/beeframework/code/268 Author: m_plomer Date: 2014-10-31 07:08:22 +0000 (Fri, 31 Oct 2014) Log Message: ----------- - namespacing for PasswordEncoders Modified Paths: -------------- trunk/framework/Bee/Security/IPasswordEncoder.php Added Paths: ----------- trunk/framework/Bee/Security/PasswordEncoder/CryptEncoder.php trunk/framework/Bee/Security/PasswordEncoder/MD5Encoder.php trunk/framework/Bee/Security/PasswordEncoder/PlainTextEncoder.php Removed Paths: ------------- trunk/framework/Bee/Security/PasswordEncoder/Base.php trunk/framework/Bee/Security/PasswordEncoder/Crypt.php trunk/framework/Bee/Security/PasswordEncoder/MD5.php trunk/framework/Bee/Security/PasswordEncoder/PlainText.php Modified: trunk/framework/Bee/Security/IPasswordEncoder.php =================================================================== --- trunk/framework/Bee/Security/IPasswordEncoder.php 2014-10-27 22:39:25 UTC (rev 267) +++ trunk/framework/Bee/Security/IPasswordEncoder.php 2014-10-31 07:08:22 UTC (rev 268) @@ -1,20 +1,20 @@ <?php namespace Bee\Security; -/* - * 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. - */ + /* + * 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. + */ /** * <p> @@ -23,45 +23,45 @@ * */ interface IPasswordEncoder { - + /** * <p>Encodes the specified raw password with an implementation specific algorithm.</p> - * <P>This will generally be a one-way message digest such as MD5 or SHA, but may also be a plaintext - * variant which does no encoding at all, but rather returns the same password it was fed. The latter is useful to - * plug in when the original password must be stored as-is.</p> - * <p>The specified salt will potentially be used by the implementation to "salt" the initial value before - * encoding. A salt is usually a user-specific value which is added to the password before the digest is computed. - * This means that computation of digests for common dictionary words will be different than those in the backend - * store, because the dictionary word digests will not reflect the addition of the salt. If a per-user salt is - * used (rather than a system-wide salt), it also means users with the same password will have different digest - * encoded passwords in the backend store.</p> - * <P>If a salt value is provided, the same salt value must be use when calling the {@link - * #isPasswordValid(String, String, Object)} method. Note that a specific implementation may choose to ignore the - * salt value (via <code>null</code>), or provide its own.</p> + * <P>This will generally be a one-way message digest such as MD5 or SHA, but may also be a plaintext + * variant which does no encoding at all, but rather returns the same password it was fed. The latter is useful to + * plug in when the original password must be stored as-is.</p> + * <p>The specified salt will potentially be used by the implementation to "salt" the initial value before + * encoding. A salt is usually a user-specific value which is added to the password before the digest is computed. + * This means that computation of digests for common dictionary words will be different than those in the backend + * store, because the dictionary word digests will not reflect the addition of the salt. If a per-user salt is + * used (rather than a system-wide salt), it also means users with the same password will have different digest + * encoded passwords in the backend store.</p> + * <P>If a salt value is provided, the same salt value must be use when calling the {@link + * #isPasswordValid(String, String, Object)} method. Note that a specific implementation may choose to ignore the + * salt value (via <code>null</code>), or provide its own.</p> * - * @param String $rawPass the password to encode + * @param string $rawPass the password to encode * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A - * <code>null</code> value is legal. - * - * @return String encoded password - * + * <code>null</code> value is legal. + * + * @return string encoded password + * */ - function encodePassword($rawPass, $salt); - - /** - * <p>Validates a specified "raw" password against an encoded password.</p> - * <P>The encoded password should have previously been generated by {@link #encodePassword(String, - * Object)}. This method will encode the <code>rawPass</code> (using the optional <code>salt</code>), and then - * compared it with the presented <code>encPass</code>.</p> - * <p>For a discussion of salts, please refer to {@link #encodePassword(String, Object)}.</p> - * - * @param string $encPass a pre-encoded password - * @param string $rawPass a raw password to encode and compare against the pre-encoded password - * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A - * <code>null</code> value is legal. - * - * @return boolean true if the password is valid , false otherwise - */ - function isPasswordValid($encPass, $rawPass, $salt); - + function encodePassword($rawPass, $salt); + + /** + * <p>Validates a specified "raw" password against an encoded password.</p> + * <P>The encoded password should have previously been generated by {@link #encodePassword(String, + * Object)}. This method will encode the <code>rawPass</code> (using the optional <code>salt</code>), and then + * compared it with the presented <code>encPass</code>.</p> + * <p>For a discussion of salts, please refer to {@link #encodePassword(String, Object)}.</p> + * + * @param string $encPass a pre-encoded password + * @param string $rawPass a raw password to encode and compare against the pre-encoded password + * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A + * <code>null</code> value is legal. + * + * @return boolean true if the password is valid , false otherwise + */ + function isPasswordValid($encPass, $rawPass, $salt); + } \ No newline at end of file Deleted: trunk/framework/Bee/Security/PasswordEncoder/Base.php =================================================================== --- trunk/framework/Bee/Security/PasswordEncoder/Base.php 2014-10-27 22:39:25 UTC (rev 267) +++ trunk/framework/Bee/Security/PasswordEncoder/Base.php 2014-10-31 07:08:22 UTC (rev 268) @@ -1,74 +0,0 @@ -<?php -/* - * Copyright 2008-2010 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\Security\IPasswordEncoder; -use Bee\Utils\Assert; - -abstract class Bee_Security_PasswordEncoder_Base implements IPasswordEncoder { - - /** - * Enter description here... - * - * @param String $mergedPasswordSalt - * - * @return array<String>(2) - */ - protected function demergePasswordAndSalt($mergedPasswordSalt) { - Assert::hasText($mergedPasswordSalt, 'Cannot pass a null or empty String'); - - $password = $mergedPasswordSalt; - $salt = ''; - - $saltBegins = strrpos($mergedPasswordSalt, '{'); - - $mergedLen = strlen($mergedPasswordSalt); - if (($saltBegins != -1) && (($saltBegins + 1) < $mergedLen)) { - $salt = substr($mergedPasswordSalt, $saltBegins + 1, $mergedLen - 1); - $password = substr($mergedPasswordSalt, 0, $saltBegins); - } - - return array($password, $salt); - } - - /** - * Enter description here... - * - * @param String $password - * @param mixed $salt - * @param boolean $strict - * - * @return String - */ - protected function mergePasswordAndSalt($password, $salt, $strict) { - if (is_null($password)) { - $password = ""; - } - - if ($strict && !is_null($salt)) { - if (($salt.toString().lastIndexOf("{") != -1) || (salt.toString().lastIndexOf("}") != -1)) { - throw new IllegalArgumentException("Cannot use { or } in salt.toString()"); - } - } - - if ((salt == null) || "".equals(salt)) { - return password; - } else { - return password + "{" + salt.toString() + "}"; - } - } - -} \ No newline at end of file Deleted: trunk/framework/Bee/Security/PasswordEncoder/Crypt.php =================================================================== --- trunk/framework/Bee/Security/PasswordEncoder/Crypt.php 2014-10-27 22:39:25 UTC (rev 267) +++ trunk/framework/Bee/Security/PasswordEncoder/Crypt.php 2014-10-31 07:08:22 UTC (rev 268) @@ -1,35 +0,0 @@ -<?php -/* - * Copyright 2008-2010 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\Security\IPasswordEncoder; - -class Bee_Security_PasswordEncoder_Crypt implements IPasswordEncoder { - - public function encodePassword($rawPass, $salt) { - return crypt($rawPass, $salt); - } - - /** - * @param string $encPass - * @param string $rawPass - * @param mixed $salt - * @return bool - */ - public function isPasswordValid($encPass, $rawPass, $salt) { - return $encPass === $this->encodePassword($rawPass, $salt); - } -} Copied: trunk/framework/Bee/Security/PasswordEncoder/CryptEncoder.php (from rev 261, trunk/framework/Bee/Security/PasswordEncoder/Crypt.php) =================================================================== --- trunk/framework/Bee/Security/PasswordEncoder/CryptEncoder.php (rev 0) +++ trunk/framework/Bee/Security/PasswordEncoder/CryptEncoder.php 2014-10-31 07:08:22 UTC (rev 268) @@ -0,0 +1,46 @@ +<?php +namespace Bee\Security\PasswordEncoder; + +/* + * 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\Security\IPasswordEncoder; + +class CryptEncoder implements IPasswordEncoder { + + /** + * @param string $rawPass the password to encode + * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A + * <code>null</code> value is legal. + * + * @return string encoded password + */ + public function encodePassword($rawPass, $salt) { + return crypt($rawPass, $salt); + } + + /** + * @param string $encPass a pre-encoded password + * @param string $rawPass a raw password to encode and compare against the pre-encoded password + * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A + * <code>null</code> value is legal. + * + * @return boolean true if the password is valid , false otherwise + */ + public function isPasswordValid($encPass, $rawPass, $salt) { + return $encPass === $this->encodePassword($rawPass, $salt); + } +} Deleted: trunk/framework/Bee/Security/PasswordEncoder/MD5.php =================================================================== --- trunk/framework/Bee/Security/PasswordEncoder/MD5.php 2014-10-27 22:39:25 UTC (rev 267) +++ trunk/framework/Bee/Security/PasswordEncoder/MD5.php 2014-10-31 07:08:22 UTC (rev 268) @@ -1,30 +0,0 @@ -<?php -/* - * Copyright 2008-2010 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\Security\IPasswordEncoder; - -class Bee_Security_PasswordEncoder_MD5 implements IPasswordEncoder { - - public function encodePassword($rawPass, $salt) { - return md5($rawPass); - } - - public function isPasswordValid($encPass, $rawPass, $salt) { - return $encPass === md5($rawPass); - } - -} \ No newline at end of file Copied: trunk/framework/Bee/Security/PasswordEncoder/MD5Encoder.php (from rev 261, trunk/framework/Bee/Security/PasswordEncoder/MD5.php) =================================================================== --- trunk/framework/Bee/Security/PasswordEncoder/MD5Encoder.php (rev 0) +++ trunk/framework/Bee/Security/PasswordEncoder/MD5Encoder.php 2014-10-31 07:08:22 UTC (rev 268) @@ -0,0 +1,47 @@ +<?php +namespace Bee\Security\PasswordEncoder; + +/* + * 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\Security\IPasswordEncoder; + +class MD5Encoder implements IPasswordEncoder { + + /** + * todo: implement password salting + * @param string $rawPass the password to encode + * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A + * <code>null</code> value is legal. + * + * @return string encoded password + */ + public function encodePassword($rawPass, $salt) { + return md5($rawPass); + } + + /** + * @param string $encPass a pre-encoded password + * @param string $rawPass a raw password to encode and compare against the pre-encoded password + * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A + * <code>null</code> value is legal. + * + * @return boolean true if the password is valid , false otherwise + */ + public function isPasswordValid($encPass, $rawPass, $salt) { + return $encPass === md5($rawPass); + } +} \ No newline at end of file Deleted: trunk/framework/Bee/Security/PasswordEncoder/PlainText.php =================================================================== --- trunk/framework/Bee/Security/PasswordEncoder/PlainText.php 2014-10-27 22:39:25 UTC (rev 267) +++ trunk/framework/Bee/Security/PasswordEncoder/PlainText.php 2014-10-31 07:08:22 UTC (rev 268) @@ -1,28 +0,0 @@ -<?php -/* - * Copyright 2008-2010 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\Security\IPasswordEncoder; - -class Bee_Security_PasswordEncoder_PlainText implements IPasswordEncoder { - public function encodePassword($rawPass, $salt) { - return $rawPass; - } - - public function isPasswordValid($encPass, $rawPass, $salt) { - return $encPass === $rawPass; - } -} \ No newline at end of file Copied: trunk/framework/Bee/Security/PasswordEncoder/PlainTextEncoder.php (from rev 261, trunk/framework/Bee/Security/PasswordEncoder/PlainText.php) =================================================================== --- trunk/framework/Bee/Security/PasswordEncoder/PlainTextEncoder.php (rev 0) +++ trunk/framework/Bee/Security/PasswordEncoder/PlainTextEncoder.php 2014-10-31 07:08:22 UTC (rev 268) @@ -0,0 +1,45 @@ +<?php +namespace Bee\Security\PasswordEncoder; +/* + * 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\Security\IPasswordEncoder; + +class PlainTextEncoder implements IPasswordEncoder { + + /** + * @param string $rawPass the password to encode + * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A + * <code>null</code> value is legal. + * + * @return string encoded password + */ + public function encodePassword($rawPass, $salt) { + return $rawPass; + } + + /** + * @param string $encPass a pre-encoded password + * @param string $rawPass a raw password to encode and compare against the pre-encoded password + * @param mixed $salt optionally used by the implementation to "salt" the raw password before encoding. A + * <code>null</code> value is legal. + * + * @return boolean true if the password is valid , false otherwise + */ + public function isPasswordValid($encPass, $rawPass, $salt) { + return $encPass === $rawPass; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-27 22:39:30
|
Revision: 267 http://sourceforge.net/p/beeframework/code/267 Author: m_plomer Date: 2014-10-27 22:39:25 +0000 (Mon, 27 Oct 2014) Log Message: ----------- - extracted ViewBase from AbstractView Modified Paths: -------------- trunk/framework/Bee/MVC/Dispatcher.php Modified: trunk/framework/Bee/MVC/Dispatcher.php =================================================================== --- trunk/framework/Bee/MVC/Dispatcher.php 2014-10-27 22:33:34 UTC (rev 266) +++ trunk/framework/Bee/MVC/Dispatcher.php 2014-10-27 22:39:25 UTC (rev 267) @@ -21,6 +21,7 @@ use Bee\IContext; use Bee\MVC\Session\DispatcherAdapter; use Bee\MVC\View\AbstractView; +use Bee\MVC\View\ViewBase; use Bee\Utils\Assert; use Exception; use Logger; @@ -348,7 +349,7 @@ public function resolveModelAndView(ModelAndView $mav, IHttpRequest $request) { $resolvedView = $this->viewResolver->resolveViewName($mav->getViewName(), $request); $mav->setResolvedView($resolvedView); - if ($resolvedView instanceof AbstractView) { + if ($resolvedView instanceof ViewBase) { $statics = $resolvedView->getStaticAttributes(); if (!$statics) { $statics = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-27 22:33:56
|
Revision: 266 http://sourceforge.net/p/beeframework/code/266 Author: m_plomer Date: 2014-10-27 22:33:34 +0000 (Mon, 27 Oct 2014) Log Message: ----------- - extracted ViewBase from AbstractView Modified Paths: -------------- trunk/framework/Bee/MVC/View/AbstractView.php trunk/framework/Bee/MVC/View/RedirectView.php Added Paths: ----------- trunk/framework/Bee/MVC/View/ViewBase.php Modified: trunk/framework/Bee/MVC/View/AbstractView.php =================================================================== --- trunk/framework/Bee/MVC/View/AbstractView.php 2014-10-18 07:56:39 UTC (rev 265) +++ trunk/framework/Bee/MVC/View/AbstractView.php 2014-10-27 22:33:34 UTC (rev 266) @@ -24,31 +24,12 @@ * @author Benjamin Hartmann * @author Michael Plomer <mic...@it...> */ -abstract class AbstractView implements IView { +abstract class AbstractView extends ViewBase { private $statusCode = 200; private $contentType; - private $staticAttributes = array(); - - /** - * @Return void - * @Param name String - * @Param object Object - */ - public final function addStaticAttribute($name, $object) { - $this->staticAttributes[$name] = $object; - } - - public function setStaticAttributes(array $staticAttributes) { - $this->staticAttributes = array_merge($this->staticAttributes, $staticAttributes); - } - - public function getStaticAttributes() { - return $this->staticAttributes; - } - public function getStatusCode() { return $this->statusCode; } Modified: trunk/framework/Bee/MVC/View/RedirectView.php =================================================================== --- trunk/framework/Bee/MVC/View/RedirectView.php 2014-10-18 07:56:39 UTC (rev 265) +++ trunk/framework/Bee/MVC/View/RedirectView.php 2014-10-27 22:33:34 UTC (rev 266) @@ -23,7 +23,7 @@ * Class RedirectView * @package Bee\MVC\View */ -class RedirectView implements IView, IHttpStatusCodes { +class RedirectView extends ViewBase { const MODEL_KEY_REDIRECT_URL = 'redirectUrl'; const MODEL_KEY_GET_PARAMS = 'getParams'; Added: trunk/framework/Bee/MVC/View/ViewBase.php =================================================================== --- trunk/framework/Bee/MVC/View/ViewBase.php (rev 0) +++ trunk/framework/Bee/MVC/View/ViewBase.php 2014-10-27 22:33:34 UTC (rev 266) @@ -0,0 +1,34 @@ +<?php +namespace Bee\MVC\View; + +use Bee\MVC\IHttpStatusCodes; +use Bee\MVC\IView; + +/** + * Class ViewBase + * @package Bee\MVC\View + */ +abstract class ViewBase implements IView, IHttpStatusCodes { + + /** + * @var array + */ + private $staticAttributes = array(); + + /** + * @Return void + * @Param name String + * @Param object Object + */ + public final function addStaticAttribute($name, $object) { + $this->staticAttributes[$name] = $object; + } + + public function setStaticAttributes(array $staticAttributes) { + $this->staticAttributes = array_merge($this->staticAttributes, $staticAttributes); + } + + public function getStaticAttributes() { + return $this->staticAttributes; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-18 07:56:46
|
Revision: 265 http://sourceforge.net/p/beeframework/code/265 Author: m_plomer Date: 2014-10-18 07:56:39 +0000 (Sat, 18 Oct 2014) Log Message: ----------- - added indexBy option in base query building Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php Modified: trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2014-10-18 07:52:17 UTC (rev 264) +++ trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2014-10-18 07:56:39 UTC (rev 265) @@ -171,7 +171,7 @@ // $indexBy = count($this->getIdFieldName()) > 1 ? null : $baseEntityAlias . '.' . $this->getIdFieldName(); // return $this->getEntityManager()->createQueryBuilder()->select($baseEntityAlias) // ->from($this->getEntity(), $baseEntityAlias, $indexBy); - $qb = $this->getEntityManager()->createQueryBuilder()->select($baseEntityAlias)->from($this->getEntity(), $baseEntityAlias); + $qb = $this->getEntityManager()->createQueryBuilder()->select($baseEntityAlias)->from($this->getEntity(), $baseEntityAlias, $this->getIndexBy()); $this->addJoinsToBaseQuery($qb); $this->addRestrictionsToBaseQuery($qb); return $qb; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-18 07:52:26
|
Revision: 264 http://sourceforge.net/p/beeframework/code/264 Author: m_plomer Date: 2014-10-18 07:52:17 +0000 (Sat, 18 Oct 2014) Log Message: ----------- - added indexBy option in base query building Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php Modified: trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2014-10-18 05:50:48 UTC (rev 263) +++ trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2014-10-18 07:52:17 UTC (rev 264) @@ -228,6 +228,13 @@ */ public abstract function getEntity(); + /** + * @return null + */ + protected function getIndexBy() { + return null; + } + // ================================================================================================================= // == GETTERS & SETTERS ============================================================================================ // ================================================================================================================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-18 05:50:51
|
Revision: 263 http://sourceforge.net/p/beeframework/code/263 Author: m_plomer Date: 2014-10-18 05:50:48 +0000 (Sat, 18 Oct 2014) Log Message: ----------- - some more namespacing Modified Paths: -------------- trunk/framework/Bee/Context/Xml/DefaultNamespaceHandlerResolver.php trunk/framework/Bee/Security/XmlNamespace/AbstractInterceptorDrivenBeanDefinitionDecorator.php trunk/framework/Bee/Security/XmlNamespace/GlobalMethodSecurityBeanDefinitionParser.php trunk/framework/Bee/Security/XmlNamespace/Handler.php trunk/framework/Bee/Security/XmlNamespace/InterceptMethodsBeanDefinitionDecorator.php Added Paths: ----------- trunk/framework/Bee/Security/XmlNamespace/ trunk/framework/Bee/Security/XmlNamespace/HttpSecurityBeanDefinitionParser.php Removed Paths: ------------- trunk/framework/Bee/Security/HttpSecurityBeanDefinitionParser.php trunk/framework/Bee/Security/Namespace/ trunk/framework/Bee/Security/NamespaceHandler.php Modified: trunk/framework/Bee/Context/Xml/DefaultNamespaceHandlerResolver.php =================================================================== --- trunk/framework/Bee/Context/Xml/DefaultNamespaceHandlerResolver.php 2014-10-18 05:40:51 UTC (rev 262) +++ trunk/framework/Bee/Context/Xml/DefaultNamespaceHandlerResolver.php 2014-10-18 05:50:48 UTC (rev 263) @@ -29,8 +29,8 @@ private static $NAMESPACE_HANDLERS = array( 'http://www.beeframework.org/schema/aop' => 'Bee_AOP_Namespace_Handler', - 'http://www.beeframework.org/schema/security' => 'Bee_Security_Namespace_Handler', - 'http://www.beeframework.org/schema/tx' => null, + 'http://www.beeframework.org/schema/security' => 'Bee\Security\XmlNamespace\Handler', +// 'http://www.beeframework.org/schema/tx' => null, 'http://www.beeframework.org/schema/util' => 'Bee\Context\Util\XmlNamespace\Handler', 'http://www.beeframework.org/schema/mvc' => 'Bee\MVC\XmlNamespace\Handler' ); Deleted: trunk/framework/Bee/Security/HttpSecurityBeanDefinitionParser.php =================================================================== --- trunk/framework/Bee/Security/HttpSecurityBeanDefinitionParser.php 2014-10-18 05:40:51 UTC (rev 262) +++ trunk/framework/Bee/Security/HttpSecurityBeanDefinitionParser.php 2014-10-18 05:50:48 UTC (rev 263) @@ -1,31 +0,0 @@ -<?php -namespace Bee\Security; -/* - * 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\Context\Xml\ParserContext; -use Bee\Context\Xml\XmlNamespace\IBeanDefinitionParser; -use DOMElement; - -/** - * Class HttpSecurityBeanDefinitionParser - * @package Bee\Security - */ -class HttpSecurityBeanDefinitionParser implements IBeanDefinitionParser { - - public function parse(DOMElement $element, ParserContext $parserContext) { - trigger_error('Bee\Security\HttpSecurityBeanDefinitionParser.parse() : TO BE IMPLEMENTED', E_USER_ERROR); - } -} \ No newline at end of file Deleted: trunk/framework/Bee/Security/NamespaceHandler.php =================================================================== --- trunk/framework/Bee/Security/NamespaceHandler.php 2014-10-18 05:40:51 UTC (rev 262) +++ trunk/framework/Bee/Security/NamespaceHandler.php 2014-10-18 05:50:48 UTC (rev 263) @@ -1,30 +0,0 @@ -<?php -namespace Bee\Security; -/* - * 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\Context\Xml\XmlNamespace\HandlerSupport; - -/** - * Class Bee_Security_NamespaceHandler - * @package Bee\Security - */ -class Bee_Security_NamespaceHandler extends HandlerSupport { - - public function init() { - $this->registerBeanDefinitionParser(Elements::HTTP, new HttpSecurityBeanDefinitionParser()); - } -} \ No newline at end of file Modified: trunk/framework/Bee/Security/XmlNamespace/AbstractInterceptorDrivenBeanDefinitionDecorator.php =================================================================== --- trunk/framework/Bee/Security/Namespace/AbstractInterceptorDrivenBeanDefinitionDecorator.php 2014-10-15 00:20:24 UTC (rev 257) +++ trunk/framework/Bee/Security/XmlNamespace/AbstractInterceptorDrivenBeanDefinitionDecorator.php 2014-10-18 05:50:48 UTC (rev 263) @@ -1,4 +1,5 @@ <?php +namespace Bee\Security\XmlNamespace; /* * Copyright 2008-2014 the original author or authors. * @@ -23,7 +24,7 @@ * To change this template use File | Settings | File Templates. */ // todo: work in progress... -//class Bee_Security_Namespace_AbstractInterceptorDrivenBeanDefinitionDecorator implements IBeanDefinitionDecorator { +//class AbstractInterceptorDrivenBeanDefinitionDecorator implements IBeanDefinitionDecorator { // // public final function decorate(DOMNode $node, BeanDefinitionHolder $definitionHolder, ParserContext $parserContext) { // $registry = $parserContext->getRegistry(); Modified: trunk/framework/Bee/Security/XmlNamespace/GlobalMethodSecurityBeanDefinitionParser.php =================================================================== --- trunk/framework/Bee/Security/Namespace/GlobalMethodSecurityBeanDefinitionParser.php 2014-10-15 00:20:24 UTC (rev 257) +++ trunk/framework/Bee/Security/XmlNamespace/GlobalMethodSecurityBeanDefinitionParser.php 2014-10-18 05:50:48 UTC (rev 263) @@ -1,4 +1,5 @@ <?php +namespace Bee\Security\XmlNamespace; /* * Copyright 2008-2014 the original author or authors. * @@ -22,6 +23,10 @@ use Bee\Context\Xml\ParserContext; use Bee\Context\Xml\XmlNamespace\IBeanDefinitionParser; use Bee\Utils\Strings; +use Bee_AOP_Namespace_Utils; +use Bee_Security_Config_IBeanIds; +use Bee_Security_Config_Utils; +use DOMElement; /** * Created by IntelliJ IDEA. @@ -31,7 +36,7 @@ * To change this template use File | Settings | File Templates. */ -class Bee_Security_Namespace_GlobalMethodSecurityBeanDefinitionParser implements IBeanDefinitionParser { +class GlobalMethodSecurityBeanDefinitionParser implements IBeanDefinitionParser { const SECURED_METHOD_DEFINITION_SOURCE_CLASS = 'Bee\Security\Annotations\SecuredMethodDefinitionSource'; Modified: trunk/framework/Bee/Security/XmlNamespace/Handler.php =================================================================== --- trunk/framework/Bee/Security/Namespace/Handler.php 2014-10-15 00:20:24 UTC (rev 257) +++ trunk/framework/Bee/Security/XmlNamespace/Handler.php 2014-10-18 05:50:48 UTC (rev 263) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\XmlNamespace; /* - * Copyright 2008-2010 the original author or authors. + * 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. @@ -15,6 +16,7 @@ * limitations under the License. */ use Bee\Context\Xml\XmlNamespace\HandlerSupport; +use Bee\Security\Elements; /** * Created by IntelliJ IDEA. @@ -24,7 +26,7 @@ * To change this template use File | Settings | File Templates. */ -class Bee_Security_Namespace_Handler extends HandlerSupport { +class Handler extends HandlerSupport { const INTERCEPT_METHODS = "intercept-methods"; const GLOBAL_METHOD_SECURITY = 'global-method-security'; @@ -33,11 +35,11 @@ // $this->registerBeanDefinitionParser(Elements.LDAP_PROVIDER, new LdapProviderBeanDefinitionParser()); // $this->registerBeanDefinitionParser(Elements.LDAP_SERVER, new LdapServerBeanDefinitionParser()); // $this->registerBeanDefinitionParser(Elements.LDAP_USER_SERVICE, new LdapUserServiceBeanDefinitionParser()); -// $this->registerBeanDefinitionParser(Elements.HTTP, new HttpSecurityBeanDefinitionParser()); + $this->registerBeanDefinitionParser(Elements::HTTP, new HttpSecurityBeanDefinitionParser()); // $this->registerBeanDefinitionParser(Elements.USER_SERVICE, new UserServiceBeanDefinitionParser()); // $this->registerBeanDefinitionParser(Elements.JDBC_USER_SERVICE, new JdbcUserServiceBeanDefinitionParser()); // $this->registerBeanDefinitionParser(Elements.AUTHENTICATION_PROVIDER, new AuthenticationProviderBeanDefinitionParser()); - $this->registerBeanDefinitionParser(self::GLOBAL_METHOD_SECURITY, new Bee_Security_Namespace_GlobalMethodSecurityBeanDefinitionParser()); + $this->registerBeanDefinitionParser(self::GLOBAL_METHOD_SECURITY, new GlobalMethodSecurityBeanDefinitionParser()); // $this->registerBeanDefinitionParser(Elements.AUTHENTICATION_MANAGER, new AuthenticationManagerBeanDefinitionParser()); // $this->registerBeanDefinitionParser(Elements.FILTER_INVOCATION_DEFINITION_SOURCE, new FilterInvocationDefinitionSourceBeanDefinitionParser()); Copied: trunk/framework/Bee/Security/XmlNamespace/HttpSecurityBeanDefinitionParser.php (from rev 261, trunk/framework/Bee/Security/HttpSecurityBeanDefinitionParser.php) =================================================================== --- trunk/framework/Bee/Security/XmlNamespace/HttpSecurityBeanDefinitionParser.php (rev 0) +++ trunk/framework/Bee/Security/XmlNamespace/HttpSecurityBeanDefinitionParser.php 2014-10-18 05:50:48 UTC (rev 263) @@ -0,0 +1,31 @@ +<?php +namespace Bee\Security\XmlNamespace; +/* + * 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\Context\Xml\ParserContext; +use Bee\Context\Xml\XmlNamespace\IBeanDefinitionParser; +use DOMElement; + +/** + * Class HttpSecurityBeanDefinitionParser + * @package Bee\Security + */ +class HttpSecurityBeanDefinitionParser implements IBeanDefinitionParser { + + public function parse(DOMElement $element, ParserContext $parserContext) { + trigger_error('Bee\Security\HttpSecurityBeanDefinitionParser.parse() : TO BE IMPLEMENTED', E_USER_ERROR); + } +} \ No newline at end of file Modified: trunk/framework/Bee/Security/XmlNamespace/InterceptMethodsBeanDefinitionDecorator.php =================================================================== --- trunk/framework/Bee/Security/Namespace/InterceptMethodsBeanDefinitionDecorator.php 2014-10-15 00:20:24 UTC (rev 257) +++ trunk/framework/Bee/Security/XmlNamespace/InterceptMethodsBeanDefinitionDecorator.php 2014-10-18 05:50:48 UTC (rev 263) @@ -1,4 +1,5 @@ <?php +namespace Bee\Security\XmlNamespace; /* * Copyright 2008-2014 the original author or authors. * @@ -17,6 +18,7 @@ use Bee\Context\Config\BeanDefinitionHolder; use Bee\Context\Xml\ParserContext; use Bee\Context\Xml\XmlNamespace\IBeanDefinitionDecorator; +use DOMNode; /** * Created by IntelliJ IDEA. @@ -26,7 +28,7 @@ * To change this template use File | Settings | File Templates. */ -class Bee_Security_Namespace_InterceptMethodsBeanDefinitionDecorator implements IBeanDefinitionDecorator { +class InterceptMethodsBeanDefinitionDecorator implements IBeanDefinitionDecorator { function decorate(DOMNode $node, BeanDefinitionHolder $definition, ParserContext $parserContext) { // TODO: Implement decorate() method. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-18 05:41:00
|
Revision: 262 http://sourceforge.net/p/beeframework/code/262 Author: m_plomer Date: 2014-10-18 05:40:51 +0000 (Sat, 18 Oct 2014) Log Message: ----------- - some more namespacing Modified Paths: -------------- trunk/framework/Bee/Security/Helper.php Modified: trunk/framework/Bee/Security/Helper.php =================================================================== --- trunk/framework/Bee/Security/Helper.php 2014-10-18 05:11:17 UTC (rev 261) +++ trunk/framework/Bee/Security/Helper.php 2014-10-18 05:40:51 UTC (rev 262) @@ -1,5 +1,4 @@ <?php -namespace Bee\Security; /* * Copyright 2008-2014 the original author or authors. * @@ -15,117 +14,122 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -use Bee\Security\Context\SecurityContextHolder; -use Bee\Security\Exception\AuthenticationException; +namespace Bee\Security { + use Bee\Security\Context\SecurityContextHolder; + use Bee\Security\Exception\AuthenticationException; -/** - * Class Helper - * @package Bee\Security - */ -class Helper { - /** - * @var IAccessDecisionManager + * Class Helper + * @package Bee\Security */ - private static $accessDecisionManager; + class Helper { - /** - * @var IAfterInvocationManager - */ - private static $afterInvocationProviderManager; + /** + * @var IAccessDecisionManager + */ + private static $accessDecisionManager; - /** - * @var IUserDetailsService - */ - private static $userDetailsService; + /** + * @var IAfterInvocationManager + */ + private static $afterInvocationProviderManager; - public static function construct(IAccessDecisionManager $accessDecisionManager = null, - IAfterInvocationManager $afterInvocationProviderManager = null, - IUserDetailsService $userDetailsService = null) { - self::$accessDecisionManager = $accessDecisionManager; - self::$afterInvocationProviderManager = $afterInvocationProviderManager; - self::$userDetailsService = $userDetailsService; - } + /** + * @var IUserDetailsService + */ + private static $userDetailsService; - /** - * @return bool - */ - public static function isAuthenticated() { - $auth = SecurityContextHolder::getContext()->getAuthentication(); - return is_null($auth) ? false : $auth->isAuthenticated(); - } + public static function construct(IAccessDecisionManager $accessDecisionManager = null, + IAfterInvocationManager $afterInvocationProviderManager = null, + IUserDetailsService $userDetailsService = null) { + self::$accessDecisionManager = $accessDecisionManager; + self::$afterInvocationProviderManager = $afterInvocationProviderManager; + self::$userDetailsService = $userDetailsService; + } - /** - * @return array - */ - public static function getRoles() { - $auth = SecurityContextHolder::getContext()->getAuthentication(); - if (is_null($auth) || !$auth->isAuthenticated()) { - return array(); + /** + * @return bool + */ + public static function isAuthenticated() { + $auth = SecurityContextHolder::getContext()->getAuthentication(); + return is_null($auth) ? false : $auth->isAuthenticated(); } - return (array_keys($auth->getAuthorities())); - } - /** - * @param $role - * @return bool - * @throws AuthenticationException - */ - public static function checkRole($role) { - self::$accessDecisionManager->decide( - self::getAuthIfAuthenticated(), null, - new ConfigAttributeDefinition($role) - ); - return true; - } + /** + * @return array + */ + public static function getRoles() { + $auth = SecurityContextHolder::getContext()->getAuthentication(); + if (is_null($auth) || !$auth->isAuthenticated()) { + return array(); + } + return (array_keys($auth->getAuthorities())); + } - /** - * @param $configAttribute - * @param null $secureObject - * @return bool - * @throws AuthenticationException - */ - public static function checkAccess($configAttribute, $secureObject = null) { - self::$accessDecisionManager->decide( - self::getAuthIfAuthenticated(), $secureObject, - new ConfigAttributeDefinition($configAttribute) - ); - return true; - } + /** + * @param $role + * @return bool + * @throws AuthenticationException + */ + public static function checkRole($role) { + self::$accessDecisionManager->decide( + self::getAuthIfAuthenticated(), null, + new ConfigAttributeDefinition($role) + ); + return true; + } - /** - * @param $configAttribute - * @param null $secureObject - * @param null $returnedObject - * @return mixed - * @throws AuthenticationException - */ - public static function checkResultAccess($configAttribute, $secureObject = null, $returnedObject = null) { - return self::$afterInvocationProviderManager->decide( - self::getAuthIfAuthenticated(), $secureObject, - new ConfigAttributeDefinition($configAttribute), $returnedObject - ); - } + /** + * @param $configAttribute + * @param null $secureObject + * @return bool + * @throws AuthenticationException + */ + public static function checkAccess($configAttribute, $secureObject = null) { + self::$accessDecisionManager->decide( + self::getAuthIfAuthenticated(), $secureObject, + new ConfigAttributeDefinition($configAttribute) + ); + return true; + } - /** - * @return mixed - */ - public static function getPrincipal() { - return self::getAuthIfAuthenticated()->getPrincipal(); - } + /** + * @param $configAttribute + * @param null $secureObject + * @param null $returnedObject + * @return mixed + * @throws AuthenticationException + */ + public static function checkResultAccess($configAttribute, $secureObject = null, $returnedObject = null) { + return self::$afterInvocationProviderManager->decide( + self::getAuthIfAuthenticated(), $secureObject, + new ConfigAttributeDefinition($configAttribute), $returnedObject + ); + } - /** - * @return IAuthentication - * @throws AuthenticationException - */ - private static function getAuthIfAuthenticated() { - $auth = SecurityContextHolder::getContext()->getAuthentication(); - if (is_null($auth) || !$auth->isAuthenticated()) { - throw new AuthenticationException('Not authenticated'); + /** + * @return mixed + */ + public static function getPrincipal() { + return self::getAuthIfAuthenticated()->getPrincipal(); } - return $auth; + + /** + * @return IAuthentication + * @throws AuthenticationException + */ + private static function getAuthIfAuthenticated() { + $auth = SecurityContextHolder::getContext()->getAuthentication(); + if (is_null($auth) || !$auth->isAuthenticated()) { + throw new AuthenticationException('Not authenticated'); + } + return $auth; + } } + } -class SEC extends Helper { -} \ No newline at end of file +namespace { + class SEC extends Bee\Security\Helper { + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-15 23:20:08
|
Revision: 260 http://sourceforge.net/p/beeframework/code/260 Author: m_plomer Date: 2014-10-15 23:20:05 +0000 (Wed, 15 Oct 2014) Log Message: ----------- - fixed getById() optimization Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php Modified: trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2014-10-15 19:49:12 UTC (rev 259) +++ trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2014-10-15 23:20:05 UTC (rev 260) @@ -91,7 +91,8 @@ } } - $this->idRestrictor($qb = $this->getBaseQuery(), $id); + $setter = $this->idRestrictor; + $setter($qb = $this->getBaseQuery(), $id); return $this->getSingleResult($qb); } @@ -100,8 +101,6 @@ * @param IOrderAndLimitHolder $orderAndLimitHolder * @param array $defaultOrderMapping * @return array - * - * @deprecated use executeListQuery() instead */ public function getList(IRestrictionHolder $restrictionHolder = null, IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping = null) { return $this->executeListQuery($this->getBaseQuery(), $restrictionHolder, $orderAndLimitHolder, $defaultOrderMapping, null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-15 19:49:22
|
Revision: 259 http://sourceforge.net/p/beeframework/code/259 Author: m_plomer Date: 2014-10-15 19:49:12 +0000 (Wed, 15 Oct 2014) Log Message: ----------- - fixed some tests Modified Paths: -------------- trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/RegexMappingInvocationResolver.php trunk/tests/Bee/Cache/Provider/AbstractSerializingTest.php trunk/tests/Bee/Cache/Provider/FileTest.php Modified: trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/RegexMappingInvocationResolver.php =================================================================== --- trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/RegexMappingInvocationResolver.php 2014-10-15 18:59:03 UTC (rev 258) +++ trunk/framework/Bee/MVC/Controller/Multiaction/HandlerMethodInvocator/RegexMappingInvocationResolver.php 2014-10-15 19:49:12 UTC (rev 259) @@ -48,7 +48,7 @@ /** * @var HandlerMethodMetadata[] */ - private static $methodMetadataMap; + private static $methodMetadataMap = array(); /** * @var MethodInvocation[] Modified: trunk/tests/Bee/Cache/Provider/AbstractSerializingTest.php =================================================================== --- trunk/tests/Bee/Cache/Provider/AbstractSerializingTest.php 2014-10-15 18:59:03 UTC (rev 258) +++ trunk/tests/Bee/Cache/Provider/AbstractSerializingTest.php 2014-10-15 19:49:12 UTC (rev 259) @@ -24,7 +24,7 @@ * Time: 15:16 */ -class Bee_Cache_Provider_AbstractSerializingTest extends PHPUnit_Framework_TestCase { +class AbstractSerializingTest extends PHPUnit_Framework_TestCase { // /** // * Initialize the cache provider if necessary. Called once per request, before the first cache access is made. @@ -79,7 +79,7 @@ private $provider; protected function setUp() { - $this->provider = new Bee_Cache_Provider_AbstractSerializingMock(array( + $this->provider = new AbstractSerializingMock(array( 'foo' => serialize('bar'), 'foo__ETIME__' => time() )); @@ -106,10 +106,10 @@ $value2 = array( 'level-1-1' => 'level-1-1 value', 'level-1-2' => 17, - 'level-1-3' => new stdClass(), + 'level-1-3' => new \stdClass(), 'level-1-4' => array( - 'level-2-1' => new stdClass(), - 'level-2-2' => new stdClass(), + 'level-2-1' => new \stdClass(), + 'level-2-2' => new \stdClass(), 'level-2-3' => 'level-2-3 value', 'level-2-3' => array( 'value-true' => true, Modified: trunk/tests/Bee/Cache/Provider/FileTest.php =================================================================== --- trunk/tests/Bee/Cache/Provider/FileTest.php 2014-10-15 18:59:03 UTC (rev 258) +++ trunk/tests/Bee/Cache/Provider/FileTest.php 2014-10-15 19:49:12 UTC (rev 259) @@ -1,4 +1,5 @@ <?php +namespace Bee\Cache\Provider; /* * Copyright 2008-2010 the original author or authors. * @@ -15,6 +16,7 @@ * limitations under the License. */ use Bee\Cache\IProvider; +use PHPUnit_Framework_TestCase; /** * User: mp @@ -22,7 +24,7 @@ * Time: 15:16 */ -class Bee_Cache_Provider_FileTest extends PHPUnit_Framework_TestCase { +class FileTest extends PHPUnit_Framework_TestCase { // /** // * Initialize the cache provider if necessary. Called once per request, before the first cache access is made. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-15 18:59:11
|
Revision: 258 http://sourceforge.net/p/beeframework/code/258 Author: m_plomer Date: 2014-10-15 18:59:03 +0000 (Wed, 15 Oct 2014) Log Message: ----------- - refactored DaoBase hierarchy - fixed parameteralignment in BeanCreationException::__construct() Added Paths: ----------- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php trunk/framework/Bee/Persistence/Doctrine2/SimpleDao.php Property Changed: ---------------- trunk/libs/ Added: trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php (rev 0) +++ trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2014-10-15 18:59:03 UTC (rev 258) @@ -0,0 +1,284 @@ +<?php +namespace Bee\Persistence\Doctrine2; + +use Bee\Persistence\IOrderAndLimitHolder; +use Bee\Persistence\IRestrictionHolder; +use Bee\Utils\Strings; +use Doctrine\ORM\QueryBuilder; +use UnexpectedValueException; + +/** + * Class GenericDaoBase + * @package Bee\Persistence\Doctrine2 + */ +abstract class GenericDaoBase extends DaoBase { + + const ALIAS_MATCHER = '#^([a-zA-Z0-9_]{2,})\.#'; + + /** + * @var callable + */ + private $idRestrictor; + + /** + * @var array + */ + private $aliases; + + /** + * @var array + * + * todo: this is only for one-time use during a request. should be ok for MOST cases... + */ + private $addedAliases = array(); + + /** + * @var array + */ + private $joins = array(); + + /** + * @var array + */ + private $restrictions = array(); + + /** + * @var array + */ + private $defaultOrderMapping = array(); + + /** + * @param mixed $id + * @throws UnexpectedValueException + * @return mixed + */ + public function getById($id) { + if(!is_callable($this->idRestrictor)) { + $idFields = $this->getIdFieldName(); + + $expectedDim = count($idFields); + $actualDim = count($id); + + // unpack single-valued id if necessary + if (is_array($id) && $actualDim === 1) { + $id = $id[0]; + } + + $baseEntityAlias = $this->getEntityAlias(); + if ($expectedDim > 1) { + // composite key + if ($actualDim === 1) { + $id = DaoUtils::explodeScalarId($id, $idFields); + } else if ($actualDim !== $expectedDim) { + throw new UnexpectedValueException('Dimension of given ID (' . count($id) . ') does not match expected dimension (' . count($idFields) . ').'); + } + + // here we can be sure that the dimensions match - both branches above would have thrown otherwise + $whereParts = array(); + array_walk($id, function ($value, $key) use ($baseEntityAlias, &$whereParts) { + $whereParts[] = $baseEntityAlias . '.' . $key . ' = ' . ':' . $key; + }); + + $where = implode(' AND ', $whereParts); + $this->idRestrictor = function(QueryBuilder $qb, $id) use ($where) { + $qb->where($where)->setParameters($id); + }; + } else { + $where = $baseEntityAlias . '.' . $idFields . ' = :id'; + $this->idRestrictor = function(QueryBuilder $qb, $id) use ($where) { + $qb->where($where)->setParameter('id', $id); + }; + } + } + + $this->idRestrictor($qb = $this->getBaseQuery(), $id); + return $this->getSingleResult($qb); + } + + /** + * @param IRestrictionHolder $restrictionHolder + * @param IOrderAndLimitHolder $orderAndLimitHolder + * @param array $defaultOrderMapping + * @return array + * + * @deprecated use executeListQuery() instead + */ + public function getList(IRestrictionHolder $restrictionHolder = null, IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping = null) { + return $this->executeListQuery($this->getBaseQuery(), $restrictionHolder, $orderAndLimitHolder, $defaultOrderMapping, null); + } + + /** + * @param string $expr + */ + protected function addAliasForExpression(QueryBuilder $queryBuilder, $expr) { + if(preg_match(self::ALIAS_MATCHER, $expr, $matches)) { + $this->addAlias($queryBuilder, $matches[1]); + } + } + + /** + * @param QueryBuilder $queryBuilder + * @param string $alias + */ + protected function addAlias(QueryBuilder $queryBuilder, $alias) { + if(!$this->containsAlias($alias)) { + $this->addedAliases[$alias] = true; + $this->addAliasForExpression($queryBuilder, $this->aliases[$alias]); + $queryBuilder->leftJoin($this->aliases[$alias], $alias); + } + } + + /** + * @param $alias + * @return boolean + */ + protected function containsAlias($alias) { + // todo: Alias presence could in theory also be detected by examining the query builders DQL parts. Feasibility / performance? + // pros: more thorough and consistent + // cons: more overhead? + return $alias == $this->getEntityAlias() || array_key_exists($alias, $this->addedAliases) || array_key_exists($alias, $this->getJoins()); + } + + public function executeListQuery(QueryBuilder $queryBuilder, IRestrictionHolder $restrictionHolder = null, IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping = null, $hydrationMode = null) { + if(!is_null($restrictionHolder)) { + if(Strings::hasText($restrictionHolder->getFilterString())) { + foreach($restrictionHolder->getFilterableFields() as $field) { + $this->addAliasForExpression($queryBuilder, $field); + } + } + if(count($restrictionHolder->getFieldRestrictions()) > 0) { + foreach($restrictionHolder->getFieldRestrictions() as $field => $value) { + $this->addAliasForExpression($queryBuilder, $field); + } + } + } + + if(!is_null($orderAndLimitHolder)) { + if(count($orderAndLimitHolder->getOrderMapping()) > 0) { + foreach($orderAndLimitHolder->getOrderMapping() as $field => $dir) { + $this->addAliasForExpression($queryBuilder, $field); + } + } + } + + return parent::executeListQuery($queryBuilder, $restrictionHolder, $orderAndLimitHolder, $defaultOrderMapping ?: $this->getDefaultOrderMapping(), $hydrationMode ?: $this->getHydrationMode()); + } + + /** + * @return QueryBuilder + */ + protected function getBaseQuery() { + $baseEntityAlias = $this->getEntityAlias(); +// $indexBy = count($this->getIdFieldName()) > 1 ? null : $baseEntityAlias . '.' . $this->getIdFieldName(); +// return $this->getEntityManager()->createQueryBuilder()->select($baseEntityAlias) +// ->from($this->getEntity(), $baseEntityAlias, $indexBy); + $qb = $this->getEntityManager()->createQueryBuilder()->select($baseEntityAlias)->from($this->getEntity(), $baseEntityAlias); + $this->addJoinsToBaseQuery($qb); + $this->addRestrictionsToBaseQuery($qb); + return $qb; + } + + /** + * @param QueryBuilder $q + */ + protected function addJoinsToBaseQuery(QueryBuilder $q) { + foreach($this->joins as $alias => $relation) { + $q->addSelect($alias)->leftJoin($relation, $alias); + } + } + + /** + * @param QueryBuilder $q + */ + protected function addRestrictionsToBaseQuery(QueryBuilder $q) { + foreach($this->restrictions as $restriction) { + $q->andWhere($restriction); + } + } + + /** + * @param QueryBuilder $qb + * @return mixed + */ + protected function getSingleResult(QueryBuilder $qb) { + $q = $this->getQueryFromBuilder($qb); + return $q->getSingleResult($this->getHydrationMode()); + } + + /** + * @return null|string + */ + protected function getHydrationMode() { + return null; + } + + /** + * @return string + */ + protected function getEntityAlias() { + return 'e'; + } + + /** + * @return mixed + */ + abstract protected function getIdFieldName(); + + /** + * @return string + */ + public abstract function getEntity(); + + // ================================================================================================================= + // == GETTERS & SETTERS ============================================================================================ + // ================================================================================================================= + + /** + * @return array + */ + public function getAliases() { + return $this->aliases; + } + + /** + * @param array $aliases + */ + public function setAliases(array $aliases) { + $this->aliases = $aliases; + } + + /** + * @param array $joins + */ + public function setJoins(array $joins) { + $this->joins = $joins; + } + + /** + * @return array + */ + public function getJoins() { + return $this->joins; + } + + /** + * @param array $restrictions + */ + public function setRestrictions(array $restrictions) { + $this->restrictions = $restrictions; + } + + /** + * @return array + */ + public function getDefaultOrderMapping() { + return $this->defaultOrderMapping; + } + + /** + * @param array $defaultOrderMapping + */ + public function setDefaultOrderMapping(array $defaultOrderMapping) { + $this->defaultOrderMapping = $defaultOrderMapping; + } +} \ No newline at end of file Added: trunk/framework/Bee/Persistence/Doctrine2/SimpleDao.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/SimpleDao.php (rev 0) +++ trunk/framework/Bee/Persistence/Doctrine2/SimpleDao.php 2014-10-15 18:59:03 UTC (rev 258) @@ -0,0 +1,87 @@ +<?php +namespace Bee\Persistence\Doctrine2; + +/** + * Class GenericDao - provides generic CRUD/L operations for a given entity class. The entity class name must be + * configured via the $entity property. + * + * @package Bee\Persistence\Doctrine2 + */ +class SimpleDao extends GenericDaoBase { + + /** + * @var string + */ + private $entity; + + /** + * @return string|array + */ + protected function getIdFieldName() { + $classMetadata = $this->getEntityManager()->getClassMetadata($this->getEntity()); + $idFields = $classMetadata->getIdentifierFieldNames(); + return count($idFields) > 1 ? $idFields : $idFields[0]; + } + + // ================================================================================================================= + // == CRUD operations : create / update ============================================================================ + // ================================================================================================================= + + /** + * @param mixed $entity + * @param bool $flush + * @return mixed + */ + public function persist($entity, $flush = true) { + $this->prePersist($entity); + $this->getEntityManager()->persist($entity); + $this->postPersist($entity); + if ($flush) { + $this->getEntityManager()->flush(); + } + return $entity; + } + + protected function prePersist($entity) { + } + + protected function postPersist($entity) { + } + + // ================================================================================================================= + // == CRUD operations : delete ===================================================================================== + // ================================================================================================================= + /** + * @param $entity + * @param bool $flush + * @return void + */ + public function delete($entity, $flush = true) { + $this->preDelete($entity); + $this->getEntityManager()->remove($entity); + if ($flush) { + $this->getEntityManager()->flush(); + } + } + + protected function preDelete($entity) { + } + + // ================================================================================================================= + // == GETTERS & SETTERS ============================================================================================ + // ================================================================================================================= + + /** + * @return string + */ + public function getEntity() { + return $this->entity; + } + + /** + * @param string $entity + */ + public function setEntity($entity) { + $this->entity = $entity; + } +} \ No newline at end of file Index: trunk/libs =================================================================== --- trunk/libs 2014-10-15 00:20:24 UTC (rev 257) +++ trunk/libs 2014-10-15 18:59:03 UTC (rev 258) Property changes on: trunk/libs ___________________________________________________________________ Modified: svn:externals ## -1,2 +1 ## -log4php-2.1.0 https://svn.apache.org/repos/asf/logging/log4php/tags/apache-log4php-2.1.0/src/main/php php-aop http://php-aop.googlecode.com/svn/trunk/aop This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-15 00:20:31
|
Revision: 257 http://sourceforge.net/p/beeframework/code/257 Author: m_plomer Date: 2014-10-15 00:20:24 +0000 (Wed, 15 Oct 2014) Log Message: ----------- - tuned logging levels in Bee\MVC\Dispatcher Modified Paths: -------------- trunk/framework/Bee/MVC/Dispatcher.php Modified: trunk/framework/Bee/MVC/Dispatcher.php =================================================================== --- trunk/framework/Bee/MVC/Dispatcher.php 2014-10-14 20:48:38 UTC (rev 256) +++ trunk/framework/Bee/MVC/Dispatcher.php 2014-10-15 00:20:24 UTC (rev 257) @@ -211,7 +211,7 @@ try { $this->requestBuilder = $this->context->getBean(self::REQUEST_BUILDER_BEAN_NAME, '\Bee\MVC\IRequestBuilder'); } catch (NoSuchBeanDefinitionException $ex) { - $this->getLog()->info('no RequestBuilder configured, using DefaultRequestBuilder'); + $this->getLog()->debug('no RequestBuilder configured, using DefaultRequestBuilder'); $this->requestBuilder = new DefaultRequestBuilder(); } @@ -223,13 +223,13 @@ try { $this->filterChainProxy = $this->context->getBean(self::FILTER_CHAIN_PROXY_NAME, 'Bee\MVC\IFilter'); } catch (NoSuchBeanDefinitionException $ex) { - $this->getLog()->info('no filter chain proxy configured'); + $this->getLog()->debug('no filter chain proxy configured'); } try { $this->handlerExceptionResolver = $this->context->getBean(self::HANDLER_EXCEPTION_RESOLVER_NAME, 'Bee\MVC\IHandlerExceptionResolver'); } catch (NoSuchBeanDefinitionException $ex) { - $this->getLog()->info('no exception resolver configured'); + $this->getLog()->debug('no exception resolver configured'); } } @@ -304,7 +304,7 @@ } } catch (Exception $e) { - $this->getLog()->warn('handler or interceptor exception caught, trying to resolve appropriate error view', $e); + $this->getLog()->info('handler or interceptor exception caught, trying to resolve appropriate error view', $e); // @todo: handle exceptions caused by handlers properly (i.e. as application level exceptions) if ($this->handlerExceptionResolver) { $mav = $this->handlerExceptionResolver->resolveException($request, $handler, $e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-14 20:48:43
|
Revision: 256 http://sourceforge.net/p/beeframework/code/256 Author: m_plomer Date: 2014-10-14 20:48:38 +0000 (Tue, 14 Oct 2014) Log Message: ----------- - added constructor parameter for exception cause Modified Paths: -------------- trunk/framework/Bee/Context/BeanNotOfRequiredTypeException.php trunk/framework/Bee/Context/NoSuchBeanDefinitionException.php Modified: trunk/framework/Bee/Context/BeanNotOfRequiredTypeException.php =================================================================== --- trunk/framework/Bee/Context/BeanNotOfRequiredTypeException.php 2014-10-09 11:59:29 UTC (rev 255) +++ trunk/framework/Bee/Context/BeanNotOfRequiredTypeException.php 2014-10-14 20:48:38 UTC (rev 256) @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Exception; /** * Enter description here... @@ -47,10 +48,11 @@ * @param String $name * @param String $requiredType * @param String $actualType + * @param Exception $prev * @return BeanNotOfRequiredTypeException */ - public function __construct($name, $requiredType, $actualType=null) { - parent::__construct(sprintf(self::EXCEPTION_MESSAGE, $name, $actualType, $requiredType)); + public function __construct($name, $requiredType, $actualType=null, Exception $prev = null) { + parent::__construct(sprintf(self::EXCEPTION_MESSAGE, $name, $actualType, $requiredType), 0, $prev); $this->name = $name; $this->requiredType = $requiredType; $this->actualType = $actualType; Modified: trunk/framework/Bee/Context/NoSuchBeanDefinitionException.php =================================================================== --- trunk/framework/Bee/Context/NoSuchBeanDefinitionException.php 2014-10-09 11:59:29 UTC (rev 255) +++ trunk/framework/Bee/Context/NoSuchBeanDefinitionException.php 2014-10-14 20:48:38 UTC (rev 256) @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Exception; /** * Enter description here... @@ -36,10 +37,11 @@ * @param String $name * @param String $type * @param null $message + * @param Exception $prev * @return NoSuchBeanDefinitionException */ - public function __construct($name, $type=null, $message = null) { - parent::__construct(is_null($message) ? sprintf(self::EXCEPTION_MESSAGE, $name, $type) : $message); + public function __construct($name, $type=null, $message = null, Exception $prev = null) { + parent::__construct(is_null($message) ? sprintf(self::EXCEPTION_MESSAGE, $name, $type) : $message, 0, $prev); $this->name = $name; $this->type = $type; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2014-10-09 11:59:38
|
Revision: 255 http://sourceforge.net/p/beeframework/code/255 Author: m_plomer Date: 2014-10-09 11:59:29 +0000 (Thu, 09 Oct 2014) Log Message: ----------- - implemented request-based filtering of interceptors in AntPathHandlerMapping - omissions from previous namespace refactoring Modified Paths: -------------- trunk/framework/Bee/Annotations/Utils.php trunk/framework/Bee/MVC/HandlerMapping/AbstractHandlerMapping.php trunk/framework/Bee/MVC/HandlerMapping/AntPathHandlerMapping.php trunk/framework/Bee/Persistence/Pdo/IResultSetExtractor.php trunk/framework/Bee/Persistence/Pdo/IStatementCallback.php trunk/framework/Bee/Persistence/Pdo/RowMapper/SingleColumn.php trunk/framework/Bee/Persistence/Pdo/Template.php trunk/framework/Bee/Security/Acls/Pdo/AclService.php trunk/framework/Bee/Security/Annotations/Secured.php trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php trunk/framework/Bee/Security/Namespace/GlobalMethodSecurityBeanDefinitionParser.php trunk/framework/Bee/Security/Provider/DaoAuthentication.php trunk/tests/Bee/Annotations/UtilsTest.php Added Paths: ----------- trunk/framework/Bee/Persistence/Exception/DataAccessException.php Removed Paths: ------------- trunk/framework/Bee/Persistence/Exception/DataAccess.php Modified: trunk/framework/Bee/Annotations/Utils.php =================================================================== --- trunk/framework/Bee/Annotations/Utils.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Annotations/Utils.php 2014-10-09 11:59:29 UTC (rev 255) @@ -1,6 +1,7 @@ <?php +namespace Bee\Annotations; /* - * Copyright 2008-2010 the original author or authors. + * 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. @@ -14,17 +15,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - use Addendum\ReflectionAnnotatedClass; use Addendum\ReflectionAnnotatedMethod; +use ReflectionMethod; + /** * User: mp * Date: Feb 19, 2010 * Time: 7:14:44 PM */ +class Utils { -class Bee_Annotations_Utils { - /** * Get a single {@link Annotation} of <code>annotationType</code> from the * supplied {@link Method}, traversing its super methods if no annotation @@ -33,7 +34,7 @@ * this explicitly. Tge * @param ReflectionMethod $method * @param $annotationClassName - * @return the annotation found, or <code>null</code> if none found + * @return mixed the annotation found, or <code>null</code> if none found */ public static function findAnnotation(ReflectionMethod $method, $annotationClassName) { $annotatedMethod = self::getReflectionAnnotatedMethodIfNecessary($method); Modified: trunk/framework/Bee/MVC/HandlerMapping/AbstractHandlerMapping.php =================================================================== --- trunk/framework/Bee/MVC/HandlerMapping/AbstractHandlerMapping.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/MVC/HandlerMapping/AbstractHandlerMapping.php 2014-10-09 11:59:29 UTC (rev 255) @@ -19,6 +19,7 @@ use Bee\IContext; use Bee\MVC\HandlerExecutionChain; use Bee\MVC\IController; +use Bee\MVC\IHandlerInterceptor; use Bee\MVC\IHandlerMapping; use Bee\MVC\IHttpRequest; use Exception; @@ -48,7 +49,7 @@ /** * Enter description here... * - * @var \Bee\MVC\IHandlerInterceptor[] + * @var IHandlerInterceptor[] */ private $interceptors = array(); @@ -81,7 +82,7 @@ /** * Enter description here... * - * @param \Bee\MVC\IHandlerInterceptor[] $interceptors + * @param IHandlerInterceptor[] $interceptors */ public function setInterceptors(array $interceptors) { $this->interceptors = $interceptors; @@ -90,7 +91,7 @@ /** * Enter description here... * - * @return \Bee\MVC\IHandlerInterceptor[] + * @return IHandlerInterceptor[] */ public function getInterceptors() { return $this->interceptors; @@ -112,11 +113,20 @@ } $hec = new HandlerExecutionChain($handlerBean); - $hec->addInterceptors($this->interceptors); + $hec->addInterceptors($this->filterInterceptors($request)); return $hec; } /** + * Default implementation returns unfiltered view of the interceptors collection. + * @param IHttpRequest $request + * @return IHandlerInterceptor[] + */ + protected function filterInterceptors(IHttpRequest $request) { + return $this->interceptors; + } + + /** * Resolves the actual controller bean name (may also return a controller instance directly) * @param IHttpRequest $request * @return mixed Modified: trunk/framework/Bee/MVC/HandlerMapping/AntPathHandlerMapping.php =================================================================== --- trunk/framework/Bee/MVC/HandlerMapping/AntPathHandlerMapping.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/MVC/HandlerMapping/AntPathHandlerMapping.php 2014-10-09 11:59:29 UTC (rev 255) @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\MVC\IHandlerInterceptor; use Bee\MVC\IHttpRequest; use Bee\Utils\AntPathMatcher; use Bee\Utils\IPathMatcher; @@ -50,7 +51,7 @@ * @return IPathMatcher */ public function getPathMatcher() { - return $this->pathMatcher; + return $this->pathMatcher ?: ($this->pathMatcher = new AntPathMatcher()); } /** @@ -65,8 +66,7 @@ * @return mixed */ protected function getControllerBeanName(IHttpRequest $request) { - $pathInfo = $request->getPathInfo(); - return $this->getElementByMatchingArrayKey($pathInfo, $this->handlerMappings, $this->getDefaultControllerBeanName()); + return $this->getElementByMatchingArrayKey($request->getPathInfo(), $this->handlerMappings, $this->getDefaultControllerBeanName()); } /** @@ -82,7 +82,7 @@ // shortcut for direct path matches $result = $array[$path]; } else { - $matcher = is_null($this->pathMatcher) ? new AntPathMatcher() : $this->pathMatcher; + $matcher = $this->getPathMatcher(); foreach($array as $mapping => $element) { if($matcher->match($mapping, $path)) { // if(($matcher->isPattern($mapping) && $matcher->match($mapping, $pathInfo)) || Strings::startsWith($pathInfo, $mapping)) { @@ -94,4 +94,20 @@ } return $result; } + + /** + * @param IHttpRequest $request + * @return IHandlerInterceptor[] + */ + protected function filterInterceptors(IHttpRequest $request) { + $result = array(); + $pathInfo = $request->getPathInfo(); + $matcher = $this->getPathMatcher(); + foreach($this->getInterceptors() as $key => $interceptor) { + if(!is_string($key) || $key == $pathInfo || $matcher->match($key, $pathInfo)) { + $result[] = $interceptor; + } + } + return $result; + } } \ No newline at end of file Deleted: trunk/framework/Bee/Persistence/Exception/DataAccess.php =================================================================== --- trunk/framework/Bee/Persistence/Exception/DataAccess.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Persistence/Exception/DataAccess.php 2014-10-09 11:59:29 UTC (rev 255) @@ -1,22 +0,0 @@ -<?php -/* - * 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. - */ - -class Bee_Persistence_Exception_DataAccess extends Exception { - public function __construct($message, Exception $cause = null) { - parent::__construct($message, 0, $cause); - } -} Copied: trunk/framework/Bee/Persistence/Exception/DataAccessException.php (from rev 251, trunk/framework/Bee/Persistence/Exception/DataAccess.php) =================================================================== --- trunk/framework/Bee/Persistence/Exception/DataAccessException.php (rev 0) +++ trunk/framework/Bee/Persistence/Exception/DataAccessException.php 2014-10-09 11:59:29 UTC (rev 255) @@ -0,0 +1,25 @@ +<?php +namespace Bee\Persistence\Exception; +/* + * 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 Exception; + +class DataAccessException extends Exception { + public function __construct($message, Exception $cause = null) { + parent::__construct($message, 0, $cause); + } +} Modified: trunk/framework/Bee/Persistence/Pdo/IResultSetExtractor.php =================================================================== --- trunk/framework/Bee/Persistence/Pdo/IResultSetExtractor.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Persistence/Pdo/IResultSetExtractor.php 2014-10-09 11:59:29 UTC (rev 255) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\Persistence\Exception\DataAccessException; /** * User: mp @@ -30,9 +31,7 @@ * (the extractor will typically be stateful in the latter case). * @throws PDOException if a PDOException is encountered getting column * values or navigating (that is, there's no need to catch PDOException) - * @throws Bee_Persistence_Exception_DataAccess in case of custom exceptions + * @throws DataAccessException in case of custom exceptions */ public function extractData(PDOStatement $rs); - -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Persistence/Pdo/IStatementCallback.php =================================================================== --- trunk/framework/Bee/Persistence/Pdo/IStatementCallback.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Persistence/Pdo/IStatementCallback.php 2014-10-09 11:59:29 UTC (rev 255) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\Persistence\Exception\DataAccessException; /** * User: mp @@ -44,9 +45,7 @@ * @param ps active JDBC PreparedStatement * @return a result object, or <code>null</code> if none * @throws PDOException - * @throws Bee_Persistence_Exception_DataAccess in case of custom exceptions + * @throws DataAccessException in case of custom exceptions */ public function doInPreparedStatement(PDOStatement $ps); - -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Persistence/Pdo/RowMapper/SingleColumn.php =================================================================== --- trunk/framework/Bee/Persistence/Pdo/RowMapper/SingleColumn.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Persistence/Pdo/RowMapper/SingleColumn.php 2014-10-09 11:59:29 UTC (rev 255) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\Persistence\Exception\DataAccessException; /** * User: mp @@ -26,9 +27,8 @@ public function mapRow(PDOStatement $rs, $rowNum) { $colCount = $rs->columnCount(); if($colCount != 1) { - throw new Bee_Persistence_Exception_DataAccess('Incorrect column count, is ' . $colCount . ', should be 1'); + throw new DataAccessException('Incorrect column count, is ' . $colCount . ', should be 1'); } return $rs->fetchColumn(); } -} -?> +} \ No newline at end of file Modified: trunk/framework/Bee/Persistence/Pdo/Template.php =================================================================== --- trunk/framework/Bee/Persistence/Pdo/Template.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Persistence/Pdo/Template.php 2014-10-09 11:59:29 UTC (rev 255) @@ -15,6 +15,7 @@ * limitations under the License. */ use Bee\Framework; +use Bee\Persistence\Exception\DataAccessException; use Bee\Utils\Assert; /** @@ -86,7 +87,7 @@ new Bee_Persistence_Pdo_RowMapper_SingleColumn())); $count = count($results); if($count != 1) { - throw new Bee_Persistence_Exception_DataAccess('Incorrect result size, is ' .$count. ', expected 1'); + throw new DataAccessException('Incorrect result size, is ' .$count. ', expected 1'); } return $results[0]; } @@ -100,7 +101,7 @@ * @param pss object that knows how to set values on the prepared statement. * If this is null, the SQL will be assumed to contain no bind parameters. * @param rse object that will extract results. - * @return an arbitrary result object, as returned by the ResultSetExtractor + * @return mixed an arbitrary result object, as returned by the ResultSetExtractor * @throws DataAccessException if there is any problem */ public function query(Bee_Persistence_Pdo_IStatementCreator $psc, Bee_Persistence_Pdo_IStatementSetter $pss, @@ -158,7 +159,7 @@ // Release Connection early, to avoid potential connection pool deadlock // in the case when the exception translator hasn't been initialized yet. // $sql = $this->getSql($psc); - throw new Bee_Persistence_Exception_DataAccess('Bee_Persistence_Pdo_Template caught an exception', $ex); + throw new DataAccessException('Bee_Persistence_Pdo_Template caught an exception', $ex); // throw getExceptionTranslator().translate("PreparedStatementCallback", sql, ex); } } Modified: trunk/framework/Bee/Security/Acls/Pdo/AclService.php =================================================================== --- trunk/framework/Bee/Security/Acls/Pdo/AclService.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Security/Acls/Pdo/AclService.php 2014-10-09 11:59:29 UTC (rev 255) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\Persistence\Exception\DataAccessException; use Bee\Utils\Assert; /** @@ -211,7 +212,7 @@ try { return $this->pdoTemplate->queryScalarBySqlStringAndArgsArray(self::SELECT_OBJECT_IDENTITY_PRIMARY_KEY, array($oid->getType(), $oid->getIdentifier())); - } catch (Bee_Persistence_Exception_DataAccess $notFound) { + } catch (DataAccessException $notFound) { return null; } } @@ -419,5 +420,4 @@ return count($this->acl->getEntries()); } -} -?> +} \ No newline at end of file Modified: trunk/framework/Bee/Security/Annotations/Secured.php =================================================================== --- trunk/framework/Bee/Security/Annotations/Secured.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Security/Annotations/Secured.php 2014-10-09 11:59:29 UTC (rev 255) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Annotations; /* - * Copyright 2008-2010 the original author or authors. + * 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. @@ -14,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Addendum\Annotation; /** * Created by IntelliJ IDEA. @@ -23,5 +25,4 @@ * To change this template use File | Settings | File Templates. */ -class Bee_Security_Annotations_Secured extends Annotation {} -?> +class Secured extends Annotation {} Modified: trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php =================================================================== --- trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php 2014-10-09 11:59:29 UTC (rev 255) @@ -1,6 +1,7 @@ <?php +namespace Bee\Security\Annotations; /* - * Copyright 2008-2010 the original author or authors. + * 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. @@ -14,7 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Addendum\Annotation; use Addendum\ReflectionAnnotatedClass; +use Bee\Annotations\Utils; +use Bee_Security_ConfigAttributeDefinition; +use Bee_Security_Intercept_AbstractFallbackMethodDefinitionSource; +use ReflectionClass; +use ReflectionMethod; /** * Created by IntelliJ IDEA. @@ -24,9 +31,9 @@ * To change this template use File | Settings | File Templates. */ -class Bee_Security_Annotations_SecuredMethodDefinitionSource extends Bee_Security_Intercept_AbstractFallbackMethodDefinitionSource { +class SecuredMethodDefinitionSource extends Bee_Security_Intercept_AbstractFallbackMethodDefinitionSource { - const SECURED_ANNOTATION_CLASS_NAME = 'Bee_Security_Annotations_Secured'; + const SECURED_ANNOTATION_CLASS_NAME = 'Bee\Security\Annotations\Secured'; /** * @access protected @@ -51,7 +58,7 @@ * @return Bee_Security_ConfigAttributeDefinition */ protected function findAttributesForMethod(ReflectionMethod $method, $targetClassOrClassName) { - return $this->processAnnotation(Bee_Annotations_Utils::findAnnotation($method, self::SECURED_ANNOTATION_CLASS_NAME)); + return $this->processAnnotation(Utils::findAnnotation($method, self::SECURED_ANNOTATION_CLASS_NAME)); } /** @@ -67,10 +74,9 @@ * @return Bee_Security_ConfigAttributeDefinition */ private function processAnnotation(Annotation $a) { - if ($a == null || !($a instanceof Bee_Security_Annotations_Secured)) { + if ($a == null || !($a instanceof Secured)) { return null; } return new Bee_Security_ConfigAttributeDefinition($a->value); } } -?> Modified: trunk/framework/Bee/Security/Namespace/GlobalMethodSecurityBeanDefinitionParser.php =================================================================== --- trunk/framework/Bee/Security/Namespace/GlobalMethodSecurityBeanDefinitionParser.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Security/Namespace/GlobalMethodSecurityBeanDefinitionParser.php 2014-10-09 11:59:29 UTC (rev 255) @@ -33,7 +33,7 @@ class Bee_Security_Namespace_GlobalMethodSecurityBeanDefinitionParser implements IBeanDefinitionParser { - const SECURED_METHOD_DEFINITION_SOURCE_CLASS = 'Bee_Security_Annotations_SecuredMethodDefinitionSource'; + const SECURED_METHOD_DEFINITION_SOURCE_CLASS = 'Bee\Security\Annotations\SecuredMethodDefinitionSource'; const ATT_USE_SECURED = 'secured-annotations'; const ATT_ACCESS_MGR = "access-decision-manager-ref"; Modified: trunk/framework/Bee/Security/Provider/DaoAuthentication.php =================================================================== --- trunk/framework/Bee/Security/Provider/DaoAuthentication.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/framework/Bee/Security/Provider/DaoAuthentication.php 2014-10-09 11:59:29 UTC (rev 255) @@ -15,6 +15,8 @@ * limitations under the License. */ +use Bee\Persistence\Exception\DataAccessException; + class Bee_Security_Provider_DaoAuthentication extends Bee_Security_Provider_AbstractUserDetailsAuthentication { /** @@ -69,7 +71,7 @@ try { $loadedUser = $this->getUserDetailsService()->loadUserByUsername($username); - } catch (Bee_Persistence_Exception_DataAccess $repositoryProblem) { + } catch (DataAccessException $repositoryProblem) { throw new Bee_Security_Exception_Authentication($repositoryProblem->getMessage(), null, $repositoryProblem); } Modified: trunk/tests/Bee/Annotations/UtilsTest.php =================================================================== --- trunk/tests/Bee/Annotations/UtilsTest.php 2014-10-09 02:29:34 UTC (rev 254) +++ trunk/tests/Bee/Annotations/UtilsTest.php 2014-10-09 11:59:29 UTC (rev 255) @@ -1,6 +1,7 @@ <?php +namespace Bee\Annotations; /* - * Copyright 2008-2010 the original author or authors. + * 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. @@ -15,6 +16,7 @@ * limitations under the License. */ use Addendum\Annotation; +use ReflectionClass; /** * User: mp @@ -22,46 +24,46 @@ * Time: 14:49 */ -class Bee_Annotations_UtilsTest /*extends PHPUnit_Framework_TestCase*/ { +class UtilsTest /*extends PHPUnit_Framework_TestCase*/ { public function testFindInheritedAnnotation() { - $class = new ReflectionClass('Bee_Annotations_UtilsTestChildAnnotatedClass'); + $class = new ReflectionClass('UtilsTestChildAnnotatedClass'); $method = $class->getMethod('testMethod'); - $annot = Bee_Annotations_Utils::findAnnotation($method, 'Bee_Annotations_UtilsTestAnnotation1'); + $annot = Utils::findAnnotation($method, 'UtilsTestAnnotation1'); -// $this->assertNotNull($annot, 'Annotation Bee_Annotations_UtilsTestAnnotation1 not found on Bee_Annotations_UtilsTestChildAnnotatedClass::testMethod()'); +// $this->assertNotNull($annot, 'Annotation UtilsTestAnnotation1 not found on UtilsTestChildAnnotatedClass::testMethod()'); // // $this->assertEquals('parentAnnotation', $annot->value); } } -class Bee_Annotations_UtilsTestAnnotation1 extends Annotation { +class UtilsTestAnnotation1 extends Annotation { public $value; } -class Bee_Annotations_UtilsTestAnnotation2 extends Annotation { +class UtilsTestAnnotation2 extends Annotation { public $value; } -class Bee_Annotations_UtilsTestParentAnnotatedClass { +class UtilsTestParentAnnotatedClass { /** * @return void * - * @Bee_Annotations_UtilsTestAnnotation1(value = "parentAnnotation") + * @UtilsTestAnnotation1(value = "parentAnnotation") */ public function testMethod() { } } -class Bee_Annotations_UtilsTestChildAnnotatedClass extends Bee_Annotations_UtilsTestParentAnnotatedClass { +class UtilsTestChildAnnotatedClass extends UtilsTestParentAnnotatedClass { /** * @return void * - * @Bee_Annotations_UtilsTestAnnotation2(value = "childAnnotation") + * @UtilsTestAnnotation2(value = "childAnnotation") */ public function testMethod() { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |