beeframework-svn Mailing List for Bee Framework (Page 9)
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...> - 2013-09-30 16:41:26
|
Revision: 96 http://sourceforge.net/p/beeframework/code/96 Author: m_plomer Date: 2013-09-30 16:41:22 +0000 (Mon, 30 Sep 2013) Log Message: ----------- - adapted Bee_Exception_Base to the Exception hierarchy of PHP 5.3 (and deprecated it in the process) Modified Paths: -------------- trunk/framework/Bee/Exceptions/Base.php Modified: trunk/framework/Bee/Exceptions/Base.php =================================================================== --- trunk/framework/Bee/Exceptions/Base.php 2013-09-25 23:33:37 UTC (rev 95) +++ trunk/framework/Bee/Exceptions/Base.php 2013-09-30 16:41:22 UTC (rev 96) @@ -17,29 +17,24 @@ /** * Base class for framework exception hierarchies. Adds support for root causes (i.e. Exceptions, as a result - * of which this exception has been thrown). + * of which this exception has been thrown). + * + * @deprecated base the Bee Exception hierarchy on the regular PHP exception (which has a "previous" property starting + * with PHP 5.3.0) */ class Bee_Exceptions_Base extends Exception { - /** - * Enter description here... - * - * @var Exception - */ - private $cause; - public function __construct($message, Exception $cause = null) { - parent::__construct($message); - $this->cause = $cause; + parent::__construct($message, 0, $cause); } /** * Enter description here... * + * for backward-compatibility... * @return Exception */ public final function getCause() { - return $this->cause; + return $this->getPrevious(); } -} -?> \ No newline at end of file +} \ 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...> - 2013-09-25 23:33:41
|
Revision: 95 http://sourceforge.net/p/beeframework/code/95 Author: m_plomer Date: 2013-09-25 23:33:37 +0000 (Wed, 25 Sep 2013) Log Message: ----------- - bee cache augmented with some logging Modified Paths: -------------- trunk/framework/Bee/Cache/Manager.php trunk/framework/Bee/Cache/Provider/APC.php trunk/framework/Bee/Cache/Provider/Base.php trunk/framework/Bee/Cache/Provider/File.php Modified: trunk/framework/Bee/Cache/Manager.php =================================================================== --- trunk/framework/Bee/Cache/Manager.php 2013-09-24 23:33:38 UTC (rev 94) +++ trunk/framework/Bee/Cache/Manager.php 2013-09-25 23:33:37 UTC (rev 95) @@ -47,7 +47,22 @@ private static $useSessionCacheFallback = true; /** - * Map PHP cache extension names to class name of the respective cache provider adapter + * @var \Logger + */ + private static $log; + + /** + * @return \Logger + */ + protected static function getLog() { + if (!self::$log) { + self::$log = \Bee_Framework::getLoggerForClass(__CLASS__); + } + return self::$log; + } + + /** + * Map PHP cache extension names to class name of the respective cache provider adapter * * @var array */ @@ -79,9 +94,11 @@ } private static function initProviderClass($providerClass) { + static::getLog()->info('initializing cache provider class ' . $providerClass); $loc = Bee_Framework::getClassFileLocations($providerClass); require_once $loc[0]; self::$provider = new $providerClass(); + static::getLog()->info('cache initialized : ' . static::$provider); } public static function init($providerInstanceOrClassName = false) { Modified: trunk/framework/Bee/Cache/Provider/APC.php =================================================================== --- trunk/framework/Bee/Cache/Provider/APC.php 2013-09-24 23:33:38 UTC (rev 94) +++ trunk/framework/Bee/Cache/Provider/APC.php 2013-09-25 23:33:37 UTC (rev 95) @@ -68,6 +68,5 @@ // // protected final function doRetrieveSerialized($key) { // return apc_fetch($key); -// } +// } } -?> \ No newline at end of file Modified: trunk/framework/Bee/Cache/Provider/Base.php =================================================================== --- trunk/framework/Bee/Cache/Provider/Base.php 2013-09-24 23:33:38 UTC (rev 94) +++ trunk/framework/Bee/Cache/Provider/Base.php 2013-09-25 23:33:37 UTC (rev 95) @@ -51,5 +51,8 @@ protected final function getTTL($etime) { return $etime - time(); } + + function __toString() { + return get_class($this)."{}"; + } } -?> \ No newline at end of file Modified: trunk/framework/Bee/Cache/Provider/File.php =================================================================== --- trunk/framework/Bee/Cache/Provider/File.php 2013-09-24 23:33:38 UTC (rev 94) +++ trunk/framework/Bee/Cache/Provider/File.php 2013-09-25 23:33:37 UTC (rev 95) @@ -96,4 +96,8 @@ } return true; } + + function __toString() { + return __CLASS__."{cacheDir={$this->cacheDir},cacheFile={$this->cacheFile}}"; + } } \ 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...> - 2013-09-24 23:33:41
|
Revision: 94 http://sourceforge.net/p/beeframework/code/94 Author: m_plomer Date: 2013-09-24 23:33:38 +0000 (Tue, 24 Sep 2013) Log Message: ----------- Prelim tag Added Paths: ----------- tags/0.9.2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-24 23:03:52
|
Revision: 93 http://sourceforge.net/p/beeframework/code/93 Author: m_plomer Date: 2013-09-24 23:03:47 +0000 (Tue, 24 Sep 2013) Log Message: ----------- - SimpleUserDetailsService : adding / removing users Added Paths: ----------- trunk/composer.json Added: trunk/composer.json =================================================================== --- trunk/composer.json (rev 0) +++ trunk/composer.json 2013-09-24 23:03:47 UTC (rev 93) @@ -0,0 +1,30 @@ +{ + "name": "bee-framework/bee-framework", + "type": "library", + "description": "Bee Framework - PHP 5 DI/IoC application framework", + "keywords": ["framework"], + "homepage": "http://sourceforge.net/projects/beeframework/", + "license": "Apache License V2.0", + "authors": [ + { + "name": "Michael Plomer", + "email": "mic...@it..." + }, + { + "name": "Benjamin Hartmann" + } + ], + "require": { + "php": ">=5.3", + "doctrine/orm": "~2.4@RC", + "doctrine/doctrine1": "~1.2@stable", + "niktux/addendum": "0.4.1", + "apache/log4php": "~2.3@stable" + }, + "minimum-stability": "RC", + "autoload": { + "psr-0": { + "Bee": "" + } + } +} \ 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...> - 2013-09-24 17:45:50
|
Revision: 92 http://sourceforge.net/p/beeframework/code/92 Author: m_plomer Date: 2013-09-24 17:45:47 +0000 (Tue, 24 Sep 2013) Log Message: ----------- - SimpleUserDetailsService : adding / removing users Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-23 17:18:24 UTC (rev 91) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-24 17:45:47 UTC (rev 92) @@ -23,26 +23,6 @@ private $userEntityName = 'Bee\Security\UserDetails\Doctrine2\SimpleUser'; /** - * Locates the user based on the username. In the actual implementation, the search may possibly be case - * insensitive, or case insensitive depending on how the implementaion instance is configured. In this case, the - * <code>Bee_Security_IUserDetails</code> object that comes back may have a username that is of a different case - * than what was actually requested. - * - * @param $username - * @throws \Bee_Security_Exception_UsernameNotFound - * @return Bee_Security_IUserDetails a fully populated user record (never <code>null</code>) - */ - function loadUserByUsername($username) { - try { - return $this->entityManager - ->createQuery('SELECT u FROM ' . $this->getUserEntityName() . ' u WHERE u.username = :username') - ->setParameter('username', $username)->getSingleResult(); - } catch (NoResultException $e) { - throw new Bee_Security_Exception_UsernameNotFound('User name ' . $username . ' not found', null, $e); - } - } - - /** * @param EntityManager $entityManager */ public function setEntityManager(EntityManager $entityManager) { @@ -71,14 +51,54 @@ } /** + * Locates the user based on the username. In the actual implementation, the search may possibly be case + * insensitive, or case insensitive depending on how the implementaion instance is configured. In this case, the + * <code>Bee_Security_IUserDetails</code> object that comes back may have a username that is of a different case + * than what was actually requested. * + * @param $username + * @throws \Bee_Security_Exception_UsernameNotFound + * @return Bee_Security_IUserDetails a fully populated user record (never <code>null</code>) */ + function loadUserByUsername($username) { + try { + return $this->getEntityManager() + ->createQuery('SELECT u FROM ' . $this->getUserEntityName() . ' u WHERE u.username = :username') + ->setParameter('username', $username)->getSingleResult(); + } catch (NoResultException $e) { + throw new Bee_Security_Exception_UsernameNotFound('User name ' . $username . ' not found', null, $e); + } + } + + /** + * @return UserBase[] + */ public function listUsers() { - return $this->entityManager-> + return $this->getEntityManager()-> createQuery('SELECT u FROM ' . $this->getUserEntityName() . ' u ORDER BY u.username ASC')->execute(); } + /** + * @param $id + * @return null|UserBase + */ public function loadById($id) { - return $this->entityManager->find($this->getUserEntityName(), $id); + return $this->getEntityManager()->find($this->getUserEntityName(), $id); } + + /** + * @param UserBase $user + */ + public function addUser(UserBase $user) { + $this->getEntityManager()->persist($user); + $this->getEntityManager()->flush($user); + } + + /** + * @param UserBase $user + */ + public function removeUser(UserBase $user) { + $this->getEntityManager()->remove($user); + $this->getEntityManager()->flush($user); + } } \ 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...> - 2013-09-23 17:18:27
|
Revision: 91 http://sourceforge.net/p/beeframework/code/91 Author: m_plomer Date: 2013-09-23 17:18:24 +0000 (Mon, 23 Sep 2013) Log Message: ----------- - SimpleUserDetailsService : some more fixes Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-23 16:05:04 UTC (rev 90) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-23 17:18:24 UTC (rev 91) @@ -77,4 +77,8 @@ return $this->entityManager-> createQuery('SELECT u FROM ' . $this->getUserEntityName() . ' u ORDER BY u.username ASC')->execute(); } + + public function loadById($id) { + return $this->entityManager->find($this->getUserEntityName(), $id); + } } \ No newline at end of file Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php 2013-09-23 16:05:04 UTC (rev 90) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php 2013-09-23 17:18:24 UTC (rev 91) @@ -22,7 +22,7 @@ /** * @var string - * @Column(name="username", type="string", length=20, nullable=false) + * @Column(name="username", type="string", length=20, nullable=false, unique=true) */ private $username; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-23 16:05:06
|
Revision: 90 http://sourceforge.net/p/beeframework/code/90 Author: m_plomer Date: 2013-09-23 16:05:04 +0000 (Mon, 23 Sep 2013) Log Message: ----------- - SimpleUserDetailsService : basic listUsers() method introduced Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-16 20:30:50 UTC (rev 89) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-23 16:05:04 UTC (rev 90) @@ -69,4 +69,12 @@ public function getUserEntityName() { return $this->userEntityName; } + + /** + * + */ + public function listUsers() { + return $this->entityManager-> + createQuery('SELECT u FROM ' . $this->getUserEntityName() . ' u ORDER BY u.username ASC')->execute(); + } } \ 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...> - 2013-09-16 20:30:54
|
Revision: 89 http://sourceforge.net/p/beeframework/code/89 Author: m_plomer Date: 2013-09-16 20:30:50 +0000 (Mon, 16 Sep 2013) Log Message: ----------- - fixed smarty block function bee_auth_has_role Modified Paths: -------------- trunk/framework/resources/smarty/block.bee_auth_has_role.php Modified: trunk/framework/resources/smarty/block.bee_auth_has_role.php =================================================================== --- trunk/framework/resources/smarty/block.bee_auth_has_role.php 2013-09-16 20:15:39 UTC (rev 88) +++ trunk/framework/resources/smarty/block.bee_auth_has_role.php 2013-09-16 20:30:50 UTC (rev 89) @@ -35,15 +35,15 @@ if($repeat) { $roles = Bee_Security_Helper::getRoles(); - $requiredRoles = array_map('trim', explode(',', $params['all'])); - $possibleRoles = array_map('trim', explode(',', $params['any'])); - $forbiddenRoles = array_map('trim', explode(',', $params['none'])); + $requiredRoles = array_filter(array_map('trim', explode(',', $params['all']))); + $possibleRoles = array_filter(array_map('trim', explode(',', $params['any']))); + $forbiddenRoles = array_filter(array_map('trim', explode(',', $params['none']))); // check if all required roles present $repeat = array_intersect($roles, $requiredRoles) === $requiredRoles; // check if any of the possible roles are present - $repeat = $repeat && count($possibleRoles) > 0 ? count(array_intersect($roles, $possibleRoles)) > 0 : true; + $repeat = $repeat && (count($possibleRoles) > 0 ? count(array_intersect($roles, $possibleRoles)) > 0 : true); // check that none of the forbidden roles are present $repeat = $repeat && count(array_intersect($roles, $forbiddenRoles)) === 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-16 20:15:42
|
Revision: 88 http://sourceforge.net/p/beeframework/code/88 Author: m_plomer Date: 2013-09-16 20:15:39 +0000 (Mon, 16 Sep 2013) Log Message: ----------- - minor fix in SimpleMappingExceptionResolver Modified Paths: -------------- trunk/framework/Bee/MVC/SimpleMappingExceptionResolver.php Modified: trunk/framework/Bee/MVC/SimpleMappingExceptionResolver.php =================================================================== --- trunk/framework/Bee/MVC/SimpleMappingExceptionResolver.php 2013-09-16 20:10:46 UTC (rev 87) +++ trunk/framework/Bee/MVC/SimpleMappingExceptionResolver.php 2013-09-16 20:15:39 UTC (rev 88) @@ -67,6 +67,7 @@ public function resolveException(Bee_MVC_IHttpRequest $request, Bee_MVC_IController $handler = null, Exception $ex) { $exceptionClass = get_class($ex); + $viewName = false; if(is_array($this->exceptionMapping) && array_key_exists($exceptionClass, $this->exceptionMapping)) { $viewName = $this->exceptionMapping[$exceptionClass]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-16 20:10:48
|
Revision: 87 http://sourceforge.net/p/beeframework/code/87 Author: m_plomer Date: 2013-09-16 20:10:46 +0000 (Mon, 16 Sep 2013) Log Message: ----------- - smarty block function for Auth::hasRole Added Paths: ----------- trunk/framework/resources/ trunk/framework/resources/smarty/ trunk/framework/resources/smarty/block.bee_auth_has_role.php Added: trunk/framework/resources/smarty/block.bee_auth_has_role.php =================================================================== --- trunk/framework/resources/smarty/block.bee_auth_has_role.php (rev 0) +++ trunk/framework/resources/smarty/block.bee_auth_has_role.php 2013-09-16 20:10:46 UTC (rev 87) @@ -0,0 +1,53 @@ +<?php +/* + * Copyright 2008-2013 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. + */ + +/** + * Smarty + * + */ +/** + * Smarty block displayed if the currently authenticated user has a given role. + * Parameters: + * - all (string) - comma-separated list of roles the user is required to have + * - any (string) - comma-separated list of roles the user may have + * - none (string) - comma-separated list of roles the user must not have + * @param $params + * @param $content + * @param $smarty + * @param $repeat + * @return mixed + */ +function smarty_block_bee_auth_has_role ($params, $content, &$smarty, &$repeat) { + if($repeat) { + $roles = Bee_Security_Helper::getRoles(); + + $requiredRoles = array_map('trim', explode(',', $params['all'])); + $possibleRoles = array_map('trim', explode(',', $params['any'])); + $forbiddenRoles = array_map('trim', explode(',', $params['none'])); + + // check if all required roles present + $repeat = array_intersect($roles, $requiredRoles) === $requiredRoles; + + // check if any of the possible roles are present + $repeat = $repeat && count($possibleRoles) > 0 ? count(array_intersect($roles, $possibleRoles)) > 0 : true; + + // check that none of the forbidden roles are present + $repeat = $repeat && count(array_intersect($roles, $forbiddenRoles)) === 0; + } + return $content; +} + \ 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...> - 2013-09-10 09:51:47
|
Revision: 86 http://sourceforge.net/p/beeframework/code/86 Author: m_plomer Date: 2013-09-10 09:51:43 +0000 (Tue, 10 Sep 2013) Log Message: ----------- - fixed wrong array implode in Doctrine2 Log4PHP logger Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php 2013-09-08 23:14:32 UTC (rev 85) +++ trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php 2013-09-10 09:51:43 UTC (rev 86) @@ -46,7 +46,7 @@ * @return void */ public function startQuery($sql, array $params = null, array $types = null) { - self::getLog()->trace('SQL : [' . $sql . '] PARAMS : [' . var_export($params, true) . '] TYPES: ['. implode(', ', $types) . ']'); + self::getLog()->trace('SQL : [' . $sql . '] PARAMS : [' . var_export($params, true) . '] TYPES: ['. var_export($types, true) . ']'); $this->startTime = microtime(true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-08 23:14:34
|
Revision: 85 http://sourceforge.net/p/beeframework/code/85 Author: m_plomer Date: 2013-09-08 23:14:32 +0000 (Sun, 08 Sep 2013) Log Message: ----------- - MVC Dispatcher: bypass view resolution and rendering if controller did not return MAV object - HandlerExecutionChain: fixed interceptor type hints Modified Paths: -------------- trunk/framework/Bee/MVC/Dispatcher.php trunk/framework/Bee/MVC/HandlerExecutionChain.php Modified: trunk/framework/Bee/MVC/Dispatcher.php =================================================================== --- trunk/framework/Bee/MVC/Dispatcher.php 2013-09-02 20:36:30 UTC (rev 84) +++ trunk/framework/Bee/MVC/Dispatcher.php 2013-09-08 23:14:32 UTC (rev 85) @@ -257,17 +257,19 @@ throw $e; } } - - $mav->addModelValue(Bee_MVC_Model::CURRENT_REQUEST_KEY, $request); - $this->resolveModelAndView($mav); - - // Apply postHandle methods of registered interceptors. - for ($i = $interceptors_length - 1; $i >= 0; $i--) { - $interceptor = $interceptors[$i]; - $interceptor->postHandle($request, $handler, $mav); + + if($mav instanceof Bee_MVC_ModelAndView) { + $mav->addModelValue(Bee_MVC_Model::CURRENT_REQUEST_KEY, $request); + $this->resolveModelAndView($mav); + + // Apply postHandle methods of registered interceptors. + for ($i = $interceptors_length - 1; $i >= 0; $i--) { + $interceptor = $interceptors[$i]; + $interceptor->postHandle($request, $handler, $mav); + } + + $mav->renderModelInView(); } - - $mav->renderModelInView(); } catch (Exception $e) { throw $e; } Modified: trunk/framework/Bee/MVC/HandlerExecutionChain.php =================================================================== --- trunk/framework/Bee/MVC/HandlerExecutionChain.php 2013-09-02 20:36:30 UTC (rev 84) +++ trunk/framework/Bee/MVC/HandlerExecutionChain.php 2013-09-08 23:14:32 UTC (rev 85) @@ -38,13 +38,13 @@ * @var array */ private $interceptors = array(); - - - + + /** * Enter description here... * - * @param Bee_MVC_IController $controller + * @param Bee_MVC_IController $handler + * @internal param \Bee_MVC_IController $controller */ public function __construct(Bee_MVC_IController $handler) { $this->handler = $handler; @@ -55,10 +55,10 @@ /** * Enter description here... * - * @param Bee_MVC_Controller_IHandlerInterceptor $interceptor + * @param Bee_MVC_IHandlerInterceptor $interceptor * @return void */ - public function addInterceptor(Bee_MVC_Controller_IHandlerInterceptor $interceptor) { + public function addInterceptor(Bee_MVC_IHandlerInterceptor $interceptor) { array_push($this->interceptors, $interceptor); } @@ -67,7 +67,7 @@ /** * Enter description here... * - * @param array $interceptors + * @param Bee_MVC_IHandlerInterceptor[] $interceptors * @return void */ public function addInterceptors(array $interceptors) { @@ -89,11 +89,9 @@ /** * Enter description here... * - * @return array + * @return Bee_MVC_IHandlerInterceptor[] */ public function getInterceptors() { return $this->interceptors; } -} - -?> \ No newline at end of file +} \ 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...> - 2013-09-02 20:36:55
|
Revision: 84 http://sourceforge.net/p/beeframework/code/84 Author: m_plomer Date: 2013-09-02 20:36:30 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - DaoBase / AbstractGenericDao (input from SGE) Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php Modified: trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php 2013-09-02 18:56:31 UTC (rev 83) +++ trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php 2013-09-02 20:36:30 UTC (rev 84) @@ -33,36 +33,8 @@ * @return mixed */ public function getById($id) { - $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(); $qb = $this->getBaseQuery(); - 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; - }); - $qb->where(implode(' AND ', $whereParts))->setParameters($id); - } else { - $qb->where($baseEntityAlias . '.' . $idFields . ' = :id')->setParameter('id', $id); - } - + $this->applyWhereId($id, $qb); return $this->getSingleResult($qb); } @@ -119,4 +91,40 @@ $idFields = $classMetadata->getIdentifierFieldNames(); return count($idFields) > 1 ? $idFields : $idFields[0]; } + + /** + * @param mixed $id + * @param QueryBuilder $qb + * @throws \UnexpectedValueException + */ + protected function applyWhereId($id, QueryBuilder $qb) { + $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; + }); + $qb->where(implode(' AND ', $whereParts))->setParameters($id); + } else { + $qb->where($baseEntityAlias . '.' . $idFields . ' = :id')->setParameter('id', $id); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-02 18:56:35
|
Revision: 83 http://sourceforge.net/p/beeframework/code/83 Author: m_plomer Date: 2013-09-02 18:56:31 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - DaoBase / AbstractGenericDao (input from SGE) Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php Added Paths: ----------- trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php trunk/framework/Bee/Persistence/Doctrine2/DaoUtils.php Added: trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php (rev 0) +++ trunk/framework/Bee/Persistence/Doctrine2/AbstractGenericDao.php 2013-09-02 18:56:31 UTC (rev 83) @@ -0,0 +1,122 @@ +<?php +namespace Bee\Persistence\Doctrine2; +/* + * 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 Doctrine\ORM\Query; +use Doctrine\ORM\QueryBuilder; +use UnexpectedValueException; + +/** + * User: mp + * Date: 02.09.13 + * Time: 20:35 + */ + +abstract class AbstractGenericDao extends DaoBase { + + /** + * @param mixed $id + * @throws UnexpectedValueException + * @return mixed + */ + public function getById($id) { + $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(); + $qb = $this->getBaseQuery(); + 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; + }); + $qb->where(implode(' AND ', $whereParts))->setParameters($id); + } else { + $qb->where($baseEntityAlias . '.' . $idFields . ' = :id')->setParameter('id', $id); + } + + return $this->getSingleResult($qb); + } + + /** + * @param QueryBuilder $qb + * @return mixed + */ + protected function getSingleResult(QueryBuilder $qb) { + $q = $qb->getQuery(); + $this->decorateQuery($q); + return $q->getSingleResult($this->getHydrationMode()); + } + + /** + * @param Query $q + */ + protected function decorateQuery(Query $q) { + } + + /** + * @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); + } + + /** + * @return string + */ + protected function getEntityAlias() { + return 'e'; + } + + /** + * @return null + */ + protected function getHydrationMode() { + return null; + } + + /** + * @return string + */ + public abstract function getEntity(); + + /** + * @return string|array + */ + protected function getIdFieldName() { + $classMetadata = $this->getEntityManager()->getClassMetadata($this->getEntity()); + $idFields = $classMetadata->getIdentifierFieldNames(); + return count($idFields) > 1 ? $idFields : $idFields[0]; + } +} Modified: trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2013-09-02 03:36:46 UTC (rev 82) +++ trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2013-09-02 18:56:31 UTC (rev 83) @@ -1,7 +1,9 @@ <?php namespace Bee\Persistence\Doctrine2; +use Bee_Framework; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use Logger; /** * User: mp @@ -11,11 +13,27 @@ 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 \Doctrine\ORM\QueryBuilder $queryBuilder * @param \Bee_Persistence_IRestrictionHolder $restrictionHolder * @param \Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder * @param array $defaultOrderMapping * + * @param null $hydrationMode * @internal param \Doctrine\ORM\QueryBuilder $query * @return array */ @@ -114,20 +132,22 @@ * @return mixed */ public function doInTransaction($func) { - $this->getDoctrineConnection()->beginTransaction(); + $this->getLog()->info('Begin transaction.'); + $this->getEntityManager()->beginTransaction(); try { - $result = $func($this, self::getLog()); + $result = $func($this, $this->getLog()); - $this->getDoctrineConnection()->commit(); - $this->getDoctrineConnection()->flush(); + $this->getLog()->info('Transaction committing...'); + $this->getEntityManager()->commit(); + $this->getEntityManager()->flush(); + + $this->getLog()->info('Transaction committed!'); return $result; - } catch(\Exception $e) { - self::getLog()->debug('exception caught', $e); - $this->getDoctrineConnection()->rollBack(); + } catch (\Exception $e) { + $this->getLog()->warn('Exception caught, rolling back!', $e); + $this->getEntityManager()->rollBack(); throw $e; } - } - } Added: trunk/framework/Bee/Persistence/Doctrine2/DaoUtils.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/DaoUtils.php (rev 0) +++ trunk/framework/Bee/Persistence/Doctrine2/DaoUtils.php 2013-09-02 18:56:31 UTC (rev 83) @@ -0,0 +1,49 @@ +<?php +namespace Bee\Persistence\Doctrine2; +/* + * 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 UnexpectedValueException; + +/** + * User: mp + * Date: 02.09.13 + * Time: 20:42 + */ + +class DaoUtils { + + /** + * @param array $ids + * @return string + */ + public static function buildScalarId(array $ids) { + return implode(':', $ids); + } + + /** + * @param $scalarId + * @param array $idKeys + * @return array + * @throws \UnexpectedValueException + */ + public static function explodeScalarId($scalarId, array $idKeys) { + $res = explode(':', $scalarId); + if(!count($res) === count($idKeys)) { + throw new UnexpectedValueException('Scalar ID representation "'. $scalarId .'" malformed, must represent values for ' . count($idKeys) . ' fields.'); + } + return array_combine($idKeys, $res); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-02 03:36:49
|
Revision: 82 http://sourceforge.net/p/beeframework/code/82 Author: m_plomer Date: 2013-09-02 03:36:46 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - convenience UserDetails impl based on Doctrine 2 Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-02 03:36:09 UTC (rev 81) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-02 03:36:46 UTC (rev 82) @@ -22,7 +22,7 @@ */ private $rolesTransformed = null; - /* + /** * Returns the authorities granted to the user. Cannot return <code>null</code>. * * @return Bee_Security_IGrantedAuthority[] the authorities, sorted by natural key (never <code>null</code>) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-02 03:36:13
|
Revision: 81 http://sourceforge.net/p/beeframework/code/81 Author: m_plomer Date: 2013-09-02 03:36:09 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - convenience UserDetails impl based on Doctrine 2 Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-02 02:50:53 UTC (rev 80) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-02 03:36:09 UTC (rev 81) @@ -22,7 +22,7 @@ */ private $rolesTransformed = null; - /** + /* * Returns the authorities granted to the user. Cannot return <code>null</code>. * * @return Bee_Security_IGrantedAuthority[] the authorities, sorted by natural key (never <code>null</code>) Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php 2013-09-02 02:50:53 UTC (rev 80) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php 2013-09-02 03:36:09 UTC (rev 81) @@ -141,4 +141,18 @@ public function __toString() { return $this->getUsername(); } + + /** + * @param string $name + */ + public function setName($name) { + $this->name = $name; + } + + /** + * @return string + */ + public function getName() { + return $this->name ? $this->name : $this->getUsername(); + } } \ 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...> - 2013-09-02 02:50:58
|
Revision: 80 http://sourceforge.net/p/beeframework/code/80 Author: m_plomer Date: 2013-09-02 02:50:53 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - convenience UserDetails impl based on Doctrine 2 Modified Paths: -------------- trunk/framework/Bee/Security/Helper.php Modified: trunk/framework/Bee/Security/Helper.php =================================================================== --- trunk/framework/Bee/Security/Helper.php 2013-09-02 02:30:57 UTC (rev 79) +++ trunk/framework/Bee/Security/Helper.php 2013-09-02 02:50:53 UTC (rev 80) @@ -39,9 +39,9 @@ */ private static $userDetailsService; - public static function construct(Bee_Security_IAccessDecisionManager $accessDecisionManager, - Bee_Security_IAfterInvocationManager $afterInvocationProviderManager, - Bee_Security_IUserDetailsService $userDetailsService) { + public static function construct(Bee_Security_IAccessDecisionManager $accessDecisionManager = null, + Bee_Security_IAfterInvocationManager $afterInvocationProviderManager = null, + Bee_Security_IUserDetailsService $userDetailsService = null) { self::$accessDecisionManager = $accessDecisionManager; self::$afterInvocationProviderManager = $afterInvocationProviderManager; self::$userDetailsService = $userDetailsService; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-02 02:31:00
|
Revision: 79 http://sourceforge.net/p/beeframework/code/79 Author: m_plomer Date: 2013-09-02 02:30:57 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - convenience UserDetails impl based on Doctrine 2 Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-02 02:28:29 UTC (rev 78) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-02 02:30:57 UTC (rev 79) @@ -13,7 +13,7 @@ /** * @var array - * @Column(name="roles", type="simple_array", nullable=false) + * @Column(name="roles", type="simple_array", nullable=true) */ private $roles = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-02 02:28:32
|
Revision: 78 http://sourceforge.net/p/beeframework/code/78 Author: m_plomer Date: 2013-09-02 02:28:29 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - convenience UserDetails impl based on Doctrine 2 Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-02 00:03:44 UTC (rev 77) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-02 02:28:29 UTC (rev 78) @@ -20,7 +20,7 @@ /** * @var string */ - private $userEntityName = 'Bee\Tools\Security\Auth\Doctrine2\SimpleUser'; + private $userEntityName = 'Bee\Security\UserDetails\Doctrine2\SimpleUser'; /** * Locates the user based on the username. In the actual implementation, the search may possibly be case This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-02 00:03:51
|
Revision: 77 http://sourceforge.net/p/beeframework/code/77 Author: m_plomer Date: 2013-09-02 00:03:44 +0000 (Mon, 02 Sep 2013) Log Message: ----------- - convenience UserDetails impl based on Doctrine 2 Modified Paths: -------------- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php Added Paths: ----------- trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php Modified: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-01 23:18:53 UTC (rev 76) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-02 00:03:44 UTC (rev 77) @@ -9,148 +9,53 @@ * @Entity * @Table(name="bee_security_user") */ -class SimpleUser implements Bee_Security_IUserDetails { +class SimpleUser extends UserBase { /** - * @var integer - * - * @Id - * @GeneratedValue - * @Column(type="integer") + * @var array + * @Column(name="roles", type="simple_array", nullable=false) */ - private $id; + private $roles = array(); /** - * @var string - * @Column(name="username", type="string", length=20, nullable=false) + * @var null|array */ - private $username; + private $rolesTransformed = null; /** - * @var string - * @Column(name="password", type="string", length=20, nullable=false) - */ - private $password; - - /** - * @var boolean - * @Column(name="disabled", type="boolean", nullable=false) - */ - private $disabled = false; - - /** - * @var string - * @Column(name="name", type="string", length=200, nullable=true) - */ - private $name; - - /** - * Get the identifier - * - * @return integer - */ - public function getId() { - return $this->id; - } - - - /** * Returns the authorities granted to the user. Cannot return <code>null</code>. * * @return Bee_Security_IGrantedAuthority[] the authorities, sorted by natural key (never <code>null</code>) */ - function getAuthorities() { - return array(); + public function getAuthorities() { + if(!$this->rolesTransformed) { + $this->rolesTransformed = array_fill_keys($this->roles, true); + } + return $this->rolesTransformed; } /** - * Returns the password used to authenticate the user. Cannot return <code>null</code>. - * - * @return String the password (never <code>null</code>) + * @param string $role */ - function getPassword() { - return $this->password; + public function addRole($role) { + $this->getAuthorities(); + $this->rolesTransformed[$role] = true; + $this->updateRoles(); } - /** - * @param string $password - */ - public function setPassword($password) { - $this->password = $password; + public function removeRole($role) { + $this->getAuthorities(); + unset($this->rolesTransformed[$role]); + $this->updateRoles(); } - /** - * Returns the username used to authenticate the user. Cannot return <code>null</code>. - * - * @return String the username (never <code>null</code>) - */ - public function getUsername() { - return $this->username; + public function hasRole($role) { + return array_key_exists($role, $this->getAuthorities()); } - /** - * @param string $username - */ - public function setUsername($username) { - $this->username = $username; + private function updateRoles() { + $this->roles = array_keys($this->rolesTransformed); } - - /** - * Indicates whether the user's account has expired. An expired account cannot be authenticated. - * - * @return boolean <code>true</code> if the user's account is valid (ie non-expired), <code>false</code> if no longer valid - * (ie expired) - */ - public function isAccountNonExpired() { - return true; - } - - /** - * Indicates whether the user is locked or unlocked. A locked user cannot be authenticated. - * - * @return boolean <code>true</code> if the user is not locked, <code>false</code> otherwise - */ - public function isAccountNonLocked() { - return true; - } - - /** - * Indicates whether the user's credentials (password) has expired. Expired credentials prevent - * authentication. - * - * @return boolean <code>true</code> if the user's credentials are valid (ie non-expired), <code>false</code> if no longer - * valid (ie expired) - */ - public function isCredentialsNonExpired() { - return true; - } - - /** - * Indicates whether the user is enabled or disabled. A disabled user cannot be authenticated. - * - * @return boolean <code>true</code> if the user is enabled, <code>false</code> otherwise - */ - public function isEnabled() { - return !$this->getDisabled(); - } - - /** - * @return boolean - */ - public function getDisabled() { - return $this->disabled; - } - - /** - * @param boolean $disabled - */ - public function setDisabled($disabled) { - $this->disabled = $disabled; - } - - public function __toString() { - return $this->getUsername(); - } } Added: trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php (rev 0) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/UserBase.php 2013-09-02 00:03:44 UTC (rev 77) @@ -0,0 +1,144 @@ +<?php + +namespace Bee\Security\UserDetails\Doctrine2; +use Bee_Security_IUserDetails; + + +/** + * Class UserBase + * @package Bee\Security\UserDetails\Doctrine2 + * @MappedSuperclass + */ +abstract class UserBase implements Bee_Security_IUserDetails { + + /** + * @var integer + * + * @Id + * @GeneratedValue + * @Column(type="integer") + */ + private $id; + + /** + * @var string + * @Column(name="username", type="string", length=20, nullable=false) + */ + private $username; + + /** + * @var string + * @Column(name="password", type="string", length=20, nullable=false) + */ + private $password; + + /** + * @var boolean + * @Column(name="disabled", type="boolean", nullable=false) + */ + private $disabled = false; + + /** + * @var string + * @Column(name="name", type="string", length=200, nullable=true) + */ + private $name; + + /** + * Get the identifier + * + * @return integer + */ + public function getId() { + return $this->id; + } + + /** + * Returns the password used to authenticate the user. Cannot return <code>null</code>. + * + * @return String the password (never <code>null</code>) + */ + function getPassword() { + return $this->password; + } + + /** + * @param string $password + */ + public function setPassword($password) { + $this->password = $password; + } + + /** + * Returns the username used to authenticate the user. Cannot return <code>null</code>. + * + * @return String the username (never <code>null</code>) + */ + public function getUsername() { + return $this->username; + } + + /** + * @param string $username + */ + public function setUsername($username) { + $this->username = $username; + } + + /** + * Indicates whether the user's account has expired. An expired account cannot be authenticated. + * + * @return boolean <code>true</code> if the user's account is valid (ie non-expired), <code>false</code> if no longer valid + * (ie expired) + */ + public function isAccountNonExpired() { + return true; + } + + /** + * Indicates whether the user is locked or unlocked. A locked user cannot be authenticated. + * + * @return boolean <code>true</code> if the user is not locked, <code>false</code> otherwise + */ + public function isAccountNonLocked() { + return true; + } + + /** + * Indicates whether the user's credentials (password) has expired. Expired credentials prevent + * authentication. + * + * @return boolean <code>true</code> if the user's credentials are valid (ie non-expired), <code>false</code> if no longer + * valid (ie expired) + */ + public function isCredentialsNonExpired() { + return true; + } + + /** + * Indicates whether the user is enabled or disabled. A disabled user cannot be authenticated. + * + * @return boolean <code>true</code> if the user is enabled, <code>false</code> otherwise + */ + public function isEnabled() { + return !$this->getDisabled(); + } + + /** + * @return boolean + */ + public function getDisabled() { + return $this->disabled; + } + + /** + * @param boolean $disabled + */ + public function setDisabled($disabled) { + $this->disabled = $disabled; + } + + public function __toString() { + return $this->getUsername(); + } +} \ 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...> - 2013-09-01 23:18:57
|
Revision: 76 http://sourceforge.net/p/beeframework/code/76 Author: m_plomer Date: 2013-09-01 23:18:53 +0000 (Sun, 01 Sep 2013) Log Message: ----------- - Env: added PATH_INFO query param for mod_rewrite with FastcGI Modified Paths: -------------- trunk/framework/Bee/Utils/Env.php Modified: trunk/framework/Bee/Utils/Env.php =================================================================== --- trunk/framework/Bee/Utils/Env.php 2013-09-01 21:29:45 UTC (rev 75) +++ trunk/framework/Bee/Utils/Env.php 2013-09-01 23:18:53 UTC (rev 76) @@ -26,6 +26,8 @@ const PATH_INFO = 'PATH_INFO'; const ORIG_PATH_INFO = 'ORIG_PATH_INFO'; + const PATH_INFO_REWRITE_QUERY_PARAM = 'BEE_PATH_INFO_REWRITE'; + public static $USER_AGENTS = array('msie', 'firefox', 'safari', 'webkit', 'opera', 'netscape', 'konqueror', 'gecko'); private static $pathInfo; @@ -210,21 +212,18 @@ if (is_null(self::$pathInfo)) { $pathInfo = array_key_exists(self::PATH_INFO, $_SERVER) ? $_SERVER[self::PATH_INFO] : null; - if (Bee_Utils_Strings::hasText($pathInfo)) { - self::$pathInfo = $pathInfo; - - } else { + if (!Bee_Utils_Strings::hasText($pathInfo) && array_key_exists(self::PATH_INFO_REWRITE_QUERY_PARAM, $_GET)) { + $pathInfo = '/' . $_GET['BEE_PATH_INFO_REWRITE']; + } + if (!Bee_Utils_Strings::hasText($pathInfo)) { $pathInfo = array_key_exists(self::ORIG_PATH_INFO, $_SERVER) ? $_SERVER[self::ORIG_PATH_INFO] : null; if (Bee_Utils_Strings::hasText($pathInfo)) { - if ($pathInfo == $_SERVER['ORIG_SCRIPT_NAME']) { - return ''; + if ($pathInfo == $_SERVER['ORIG_SCRIPT_NAME'] || $_SERVER['SCRIPT_NAME']) { + $pathInfo = ''; } - if ($pathInfo == $_SERVER['SCRIPT_NAME']) { - return ''; - } - self::$pathInfo = $pathInfo; } } + self::$pathInfo = $pathInfo; } return self::$pathInfo; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-09-01 21:29:50
|
Revision: 75 http://sourceforge.net/p/beeframework/code/75 Author: m_plomer Date: 2013-09-01 21:29:45 +0000 (Sun, 01 Sep 2013) Log Message: ----------- - convenience UserDetails impl based on Doctrine 2 - Doctrine 2 ConnectionAugmenter Added Paths: ----------- trunk/framework/Bee/Persistence/Doctrine2/ConnectionAugmenter.php trunk/framework/Bee/Security/UserDetails/ trunk/framework/Bee/Security/UserDetails/Doctrine2/ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php Added: trunk/framework/Bee/Persistence/Doctrine2/ConnectionAugmenter.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/ConnectionAugmenter.php (rev 0) +++ trunk/framework/Bee/Persistence/Doctrine2/ConnectionAugmenter.php 2013-09-01 21:29:45 UTC (rev 75) @@ -0,0 +1,49 @@ +<?php +namespace Bee\Persistence\Doctrine2; +use Doctrine\Common\EventSubscriber; +use Doctrine\DBAL\Event\ConnectionEventArgs; +use Doctrine\DBAL\Events; + + +/** + * Class ConnectionAugmenter + * @package Bee\Persistence\Doctrine2 + */ +class ConnectionAugmenter implements EventSubscriber { + + /** + * @var string + */ + private $postConnectScript; + + /** + * @param string $postConnectScript + */ + public function setPostConnectScript($postConnectScript) { + $this->postConnectScript = $postConnectScript; + } + + /** + * @return string + */ + public function getPostConnectScript() { + return $this->postConnectScript; + } + + /** + * Returns an array of events this subscriber wants to listen to. + * + * @return array + */ + public function getSubscribedEvents() { + return array(Events::postConnect); + } + + public function postConnect(ConnectionEventArgs $eventArgs) { + $eventArgs->getConnection()->beginTransaction(); + if(\Bee_Utils_Strings::hasText($this->getPostConnectScript())) { + $eventArgs->getConnection()->exec($this->getPostConnectScript()); + } + $eventArgs->getConnection()->commit(); + } +} \ No newline at end of file Added: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php (rev 0) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUser.php 2013-09-01 21:29:45 UTC (rev 75) @@ -0,0 +1,156 @@ +<?php +namespace Bee\Security\UserDetails\Doctrine2; +use Bee_Security_IGrantedAuthority; +use Bee_Security_IUserDetails; + +/** + * Base class for user entities - also usable as simple user entity (WIP) + * @package Bee\Security\UserDetails\Doctrine2 + * @Entity + * @Table(name="bee_security_user") + */ +class SimpleUser implements Bee_Security_IUserDetails { + + /** + * @var integer + * + * @Id + * @GeneratedValue + * @Column(type="integer") + */ + private $id; + + /** + * @var string + * @Column(name="username", type="string", length=20, nullable=false) + */ + private $username; + + /** + * @var string + * @Column(name="password", type="string", length=20, nullable=false) + */ + private $password; + + /** + * @var boolean + * @Column(name="disabled", type="boolean", nullable=false) + */ + private $disabled = false; + + /** + * @var string + * @Column(name="name", type="string", length=200, nullable=true) + */ + private $name; + + /** + * Get the identifier + * + * @return integer + */ + public function getId() { + return $this->id; + } + + + /** + * Returns the authorities granted to the user. Cannot return <code>null</code>. + * + * @return Bee_Security_IGrantedAuthority[] the authorities, sorted by natural key (never <code>null</code>) + */ + function getAuthorities() { + return array(); + } + + /** + * Returns the password used to authenticate the user. Cannot return <code>null</code>. + * + * @return String the password (never <code>null</code>) + */ + function getPassword() { + return $this->password; + } + + /** + * @param string $password + */ + public function setPassword($password) { + $this->password = $password; + } + + /** + * Returns the username used to authenticate the user. Cannot return <code>null</code>. + * + * @return String the username (never <code>null</code>) + */ + public function getUsername() { + return $this->username; + } + + /** + * @param string $username + */ + public function setUsername($username) { + $this->username = $username; + } + + /** + * Indicates whether the user's account has expired. An expired account cannot be authenticated. + * + * @return boolean <code>true</code> if the user's account is valid (ie non-expired), <code>false</code> if no longer valid + * (ie expired) + */ + public function isAccountNonExpired() { + return true; + } + + /** + * Indicates whether the user is locked or unlocked. A locked user cannot be authenticated. + * + * @return boolean <code>true</code> if the user is not locked, <code>false</code> otherwise + */ + public function isAccountNonLocked() { + return true; + } + + /** + * Indicates whether the user's credentials (password) has expired. Expired credentials prevent + * authentication. + * + * @return boolean <code>true</code> if the user's credentials are valid (ie non-expired), <code>false</code> if no longer + * valid (ie expired) + */ + public function isCredentialsNonExpired() { + return true; + } + + /** + * Indicates whether the user is enabled or disabled. A disabled user cannot be authenticated. + * + * @return boolean <code>true</code> if the user is enabled, <code>false</code> otherwise + */ + public function isEnabled() { + return !$this->getDisabled(); + } + + /** + * @return boolean + */ + public function getDisabled() { + return $this->disabled; + } + + /** + * @param boolean $disabled + */ + public function setDisabled($disabled) { + $this->disabled = $disabled; + } + + public function __toString() { + return $this->getUsername(); + } +} + + Added: trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php =================================================================== --- trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php (rev 0) +++ trunk/framework/Bee/Security/UserDetails/Doctrine2/SimpleUserDetailsService.php 2013-09-01 21:29:45 UTC (rev 75) @@ -0,0 +1,72 @@ +<?php +namespace Bee\Security\UserDetails\Doctrine2; +use Bee_Security_Exception_UsernameNotFound; +use Bee_Security_IUserDetails; +use Bee_Security_IUserDetailsService; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\NoResultException; + +/** + * Class SimpleUserDetailsService + * @package Bee\Security\UserDetails\Doctrine2 + */ +class SimpleUserDetailsService implements Bee_Security_IUserDetailsService { + + /** + * @var EntityManager + */ + private $entityManager; + + /** + * @var string + */ + private $userEntityName = 'Bee\Tools\Security\Auth\Doctrine2\SimpleUser'; + + /** + * Locates the user based on the username. In the actual implementation, the search may possibly be case + * insensitive, or case insensitive depending on how the implementaion instance is configured. In this case, the + * <code>Bee_Security_IUserDetails</code> object that comes back may have a username that is of a different case + * than what was actually requested. + * + * @param $username + * @throws \Bee_Security_Exception_UsernameNotFound + * @return Bee_Security_IUserDetails a fully populated user record (never <code>null</code>) + */ + function loadUserByUsername($username) { + try { + return $this->entityManager + ->createQuery('SELECT u FROM ' . $this->getUserEntityName() . ' u WHERE u.username = :username') + ->setParameter('username', $username)->getSingleResult(); + } catch (NoResultException $e) { + throw new Bee_Security_Exception_UsernameNotFound('User name ' . $username . ' not found', null, $e); + } + } + + /** + * @param EntityManager $entityManager + */ + public function setEntityManager(EntityManager $entityManager) { + $this->entityManager = $entityManager; + } + + /** + * @return EntityManager + */ + public function getEntityManager() { + return $this->entityManager; + } + + /** + * @param string $userEntityName + */ + public function setUserEntityName($userEntityName) { + $this->userEntityName = $userEntityName; + } + + /** + * @return string + */ + public function getUserEntityName() { + return $this->userEntityName; + } +} \ 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...> - 2013-08-29 10:34:13
|
Revision: 74 http://sourceforge.net/p/beeframework/code/74 Author: m_plomer Date: 2013-08-29 10:34:11 +0000 (Thu, 29 Aug 2013) Log Message: ----------- - EnumBase fix (toString) Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php 2013-08-29 10:18:51 UTC (rev 73) +++ trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php 2013-08-29 10:34:11 UTC (rev 74) @@ -46,7 +46,7 @@ * @return void */ public function startQuery($sql, array $params = null, array $types = null) { - self::getLog()->trace('SQL : [' . $sql . '] PARAMS : [' . var_export($params) . '] TYPES: ['. implode(', ', $types) . ']'); + self::getLog()->trace('SQL : [' . $sql . '] PARAMS : [' . var_export($params, true) . '] TYPES: ['. implode(', ', $types) . ']'); $this->startTime = microtime(true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-29 10:18:56
|
Revision: 73 http://sourceforge.net/p/beeframework/code/73 Author: m_plomer Date: 2013-08-29 10:18:51 +0000 (Thu, 29 Aug 2013) Log Message: ----------- - EnumBase fix (toString) Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php trunk/framework/Bee/Utils/EnumBase.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php 2013-08-27 09:05:44 UTC (rev 72) +++ trunk/framework/Bee/Persistence/Doctrine2/Log4PHPLogger.php 2013-08-29 10:18:51 UTC (rev 73) @@ -46,7 +46,7 @@ * @return void */ public function startQuery($sql, array $params = null, array $types = null) { - self::getLog()->trace('SQL : [' . $sql . '] PARAMS : [' . implode(', ', $params) . '] TYPES: ['. implode(', ', $types) . ']'); + self::getLog()->trace('SQL : [' . $sql . '] PARAMS : [' . var_export($params) . '] TYPES: ['. implode(', ', $types) . ']'); $this->startTime = microtime(true); } Modified: trunk/framework/Bee/Utils/EnumBase.php =================================================================== --- trunk/framework/Bee/Utils/EnumBase.php 2013-08-27 09:05:44 UTC (rev 72) +++ trunk/framework/Bee/Utils/EnumBase.php 2013-08-29 10:18:51 UTC (rev 73) @@ -118,4 +118,10 @@ private function __wakeup() { } + + // todo: + function __toString() { + return $this->val(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-27 09:05:47
|
Revision: 72 http://sourceforge.net/p/beeframework/code/72 Author: m_plomer Date: 2013-08-27 09:05:44 +0000 (Tue, 27 Aug 2013) Log Message: ----------- - EnumBase / EnumType fixes - classloading fix Modified Paths: -------------- trunk/framework/Bee/Framework.php trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php trunk/framework/Bee/Utils/EnumBase.php Modified: trunk/framework/Bee/Framework.php =================================================================== --- trunk/framework/Bee/Framework.php 2013-08-25 02:09:27 UTC (rev 71) +++ trunk/framework/Bee/Framework.php 2013-08-27 09:05:44 UTC (rev 72) @@ -168,7 +168,7 @@ } foreach(self::getClassFileLocations($className) as $loc) { - include $loc; + include_once $loc; if (class_exists($className, false) || interface_exists($className, false)) { return true; } Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-25 02:09:27 UTC (rev 71) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-27 09:05:44 UTC (rev 72) @@ -38,8 +38,11 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (!$this->reflClass) self::init(); + if(is_null($val)) { + return $value; + } if (!$this->reflClass->isInstance($value)) { - throw new \UnexpectedValueException('Not a valid enum element for "' . self::ENUM_BASE_TYPE . '": ' . $value); + throw new \UnexpectedValueException('Not a valid enum element for "' . static::getEnumClassName() . '": ' . $value); } // check if value is valid self::convertToPHPValue($value->val(), $platform); Modified: trunk/framework/Bee/Utils/EnumBase.php =================================================================== --- trunk/framework/Bee/Utils/EnumBase.php 2013-08-25 02:09:27 UTC (rev 71) +++ trunk/framework/Bee/Utils/EnumBase.php 2013-08-27 09:05:44 UTC (rev 72) @@ -24,22 +24,17 @@ abstract class EnumBase { /** - * @var ReflectionClass - */ - private static $reflClass = null; - - /** * @var array */ private static $valueToName = null; /** - * @var EnumBase + * @var EnumBase[] */ private static $instancesByValue = null; /** - * @var EnumBase + * @var EnumBase[] */ private static $instancesByOid = null; @@ -63,8 +58,8 @@ * @return array */ public static function getValues() { - self::init(); - return array_keys(self::$valueToName); + static::init(); + return array_keys(self::$valueToName[get_called_class()]); } /** @@ -85,31 +80,36 @@ * @throws \UnexpectedValueException */ public static function get($value) { - self::init(); - if(!isset(self::$valueToName[$value])) { - throw new \UnexpectedValueException('Invalid value "' . $value . '" for enum ' . self::$reflClass->getShortName()); + if(is_null($value)) { + return $value; } + static::init(); + $calledClass = get_called_class(); + if(!isset(self::$valueToName[$calledClass][$value])) { + throw new \UnexpectedValueException('Invalid value "' . $value . '" for enum ' . $calledClass); + } - if(!isset(self::$instancesByValue[$value])) { - $name = self::$valueToName[$value]; - $className = self::$reflClass->getName(); - $instanceClassName = class_exists($className . '_' . $name, false) ? $className . '_' . $name : $className; + if(!isset(self::$instancesByValue[$calledClass][$value])) { + $name = self::$valueToName[$calledClass][$value]; + $instanceClassName = class_exists($calledClass . '_' . $name, false) ? $calledClass . '_' . $name : $calledClass; $inst = new $instanceClassName($value); - self::$instancesByValue[$value] = $inst; + self::$instancesByValue[$calledClass][$value] = $inst; self::$instancesByOid[spl_object_hash($inst)] = $inst; } - return self::$instancesByValue[$value]; + return self::$instancesByValue[$calledClass][$value]; } private static function init() { - if(is_null(self::$reflClass)) { - self::$reflClass = new \ReflectionClass(new static(false)); - $constants = self::$reflClass->getConstants(); - self::$valueToName = array_flip($constants); - if(count($constants) !== count(self::$valueToName)) { - throw new \UnexpectedValueException('Invalid enum definition ' . self::$reflClass->getName() .' : const values probably not unique'); + $calledClass = get_called_class(); + if(!isset(self::$valueToName[$calledClass])) { + $reflClass = new \ReflectionClass($calledClass); + $constants = $reflClass->getConstants(); + $flipped = array_flip($constants); + if(count($constants) !== count($flipped)) { + throw new \UnexpectedValueException('Invalid enum definition ' . $reflClass->getName() .' : const values probably not unique'); } + self::$valueToName[$calledClass] = $flipped; } } @@ -119,4 +119,3 @@ private function __wakeup() { } } - \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |