[Beeframework-svn] SF.net SVN: beeframework:[27] trunk
Brought to you by:
b_hartmann,
m_plomer
From: <m_p...@us...> - 2013-05-02 13:22:29
|
Revision: 27 http://sourceforge.net/p/beeframework/code/27 Author: m_plomer Date: 2013-05-02 13:22:26 +0000 (Thu, 02 May 2013) Log Message: ----------- - further PHP 5.3 related changes Modified Paths: -------------- trunk/framework/Bee/Annotations/Utils.php trunk/framework/Bee/Cache/Manager.php trunk/framework/Bee/Cache/Provider/File.php trunk/framework/Bee/Context/Xml/ReaderContext.php trunk/framework/Bee/Context/Xml.php trunk/framework/Bee/MVC/Controller/Multiaction/MethodNameResolver/AnnotationBased.php trunk/framework/Bee/MVC/Controller/Multiaction/RequestHandler.php trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php trunk/framework/Bee/Weaving/Enhancer.php trunk/tests/bootstrap.php Added Paths: ----------- trunk/framework/Bee/Framework.php trunk/framework/composer.json Removed Paths: ------------- trunk/composer.json trunk/framework/BeeFramework.php Deleted: trunk/composer.json =================================================================== --- trunk/composer.json 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/composer.json 2013-05-02 13:22:26 UTC (rev 27) @@ -1,22 +0,0 @@ -{ - "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.2.3", - "niktux/addendum": "0.4.1", - "apache/log4php": "2.3.0" - } -} \ No newline at end of file Modified: trunk/framework/Bee/Annotations/Utils.php =================================================================== --- trunk/framework/Bee/Annotations/Utils.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/Annotations/Utils.php 2013-05-02 13:22:26 UTC (rev 27) @@ -15,6 +15,7 @@ * limitations under the License. */ +use Addendum\ReflectionAnnotatedClass; /** * User: mp * Date: Feb 19, 2010 Modified: trunk/framework/Bee/Cache/Manager.php =================================================================== --- trunk/framework/Bee/Cache/Manager.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/Cache/Manager.php 2013-05-02 13:22:26 UTC (rev 27) @@ -79,7 +79,7 @@ } private static function initProviderClass($providerClass) { - $loc = BeeFramework::getClassFileLocations($providerClass); + $loc = Bee_Framework::getClassFileLocations($providerClass); require_once $loc[0]; self::$provider = new $providerClass(); } @@ -191,7 +191,7 @@ } private static function getQualifiedKey($key) { - return (BeeFramework::getApplicationId()!==false ? BeeFramework::getApplicationId().'_' : '') . $key; + return (Bee_Framework::getApplicationId()!==false ? Bee_Framework::getApplicationId().'_' : '') . $key; } public static function clearCache() { Modified: trunk/framework/Bee/Cache/Provider/File.php =================================================================== --- trunk/framework/Bee/Cache/Provider/File.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/Cache/Provider/File.php 2013-05-02 13:22:26 UTC (rev 27) @@ -81,7 +81,7 @@ if (Bee_Utils_Strings::hasText($dir) && !preg_match('#'.DIRECTORY_SEPARATOR.'$#i', $dir)) { $dir .= DIRECTORY_SEPARATOR; } - $tmpName = $dir . $this->cacheFile . (BeeFramework::getApplicationId() ? '_'.BeeFramework::getApplicationId() : ''); + $tmpName = $dir . $this->cacheFile . (Bee_Framework::getApplicationId() ? '_'.Bee_Framework::getApplicationId() : ''); return $tmpName; } Modified: trunk/framework/Bee/Context/Xml/ReaderContext.php =================================================================== --- trunk/framework/Bee/Context/Xml/ReaderContext.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/Context/Xml/ReaderContext.php 2013-05-02 13:22:26 UTC (rev 27) @@ -47,7 +47,7 @@ Bee_Context_Config_IBeanDefinitionRegistry $registry, Bee_Context_Xml_Namespace_IHandlerResolver $namespaceHandlerResolver) { - $this->log = BeeFramework::getLoggerForClass(__CLASS__); + $this->log = Bee_Framework::getLoggerForClass(__CLASS__); $this->registry = $registry; $this->namespaceHandlerResolver = $namespaceHandlerResolver; Modified: trunk/framework/Bee/Context/Xml.php =================================================================== --- trunk/framework/Bee/Context/Xml.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/Context/Xml.php 2013-05-02 13:22:26 UTC (rev 27) @@ -80,7 +80,7 @@ } public function getModificationTimestamp() { - if(BeeFramework::getProductionMode()) { + if(Bee_Framework::getProductionMode()) { return 0; } if($this->modificationTimestamp === false) { Copied: trunk/framework/Bee/Framework.php (from rev 25, trunk/framework/BeeFramework.php) =================================================================== --- trunk/framework/Bee/Framework.php (rev 0) +++ trunk/framework/Bee/Framework.php 2013-05-02 13:22:26 UTC (rev 27) @@ -0,0 +1,351 @@ +<?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. + */ + +class Bee_Framework { + + const WEAVING_PACKAGE_PREFIX = 'Bee_'; + + const CLASS_FILE_CACHE_PREFIX = '__BeeClassFileCache_'; + + const GENERATED_CLASS_CODE_MARKER = '__CLASS_IS_GENERATED'; + + private static $beeHiveLocation; + + private static $applicationId = false; + + /** + * @var Bee_Weaving_IEnhancedClassesStore + */ + private static $enhancedClassesStore = null; + + /** + * todo: quick n dirty + * @var array + */ + private static $weavingExcludedClasses = array(); + + private static $weaveDuringClassloading = false; + + private static $missedClassNames = array(); + + private static $classFileMap; + + private static $productionMode = false; + + /** + * @param Bee_Weaving_IEnhancedClassesStore $enhancedClassesStore + */ + public static function setEnhancedClassesStore(Bee_Weaving_IEnhancedClassesStore $enhancedClassesStore) { + self::$enhancedClassesStore = $enhancedClassesStore; + } + + /** + * @return Bee_Weaving_IEnhancedClassesStore + */ + public static function getEnhancedClassesStore() { + return self::$enhancedClassesStore; + } + + public static function excludeFromWeaving($className) { + self::$weavingExcludedClasses[$className] = true; + } + + public static function setApplicationId($applicationId) { + self::$applicationId = $applicationId; + } + + public static function getApplicationId() { + return self::$applicationId; + } + + /** + * Main bootstrap method for the framework. Basically just initializes the framework classloader. + * + * @return void + */ + static function init() { + self::$beeHiveLocation = dirname(__FILE__); + self::addApplicationIncludePath(self::$beeHiveLocation); + + require_once dirname(__FILE__) . '/Cache/Manager.php'; + + spl_autoload_register(array(__CLASS__, 'autoload')); + + register_shutdown_function(array(__CLASS__, 'shutdown')); +// Bee_Cache_Manager::init(); + } + + public static function handleError($errno, $errstr, $errfile, $errline) { + error_log("HANDLING ERROR $errno"); + if((E_ERROR | E_RECOVERABLE_ERROR) & $errno) { + + error_log($errno .' : ' . $errstr); + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); + } else if (E_ALL & ~E_NOTICE & ~E_WARNING & $errno) { + error_log($errno .' : ' . $errstr); + } + } + + /** + * Register application-specific include path with the framework classloader. + * + * @param String $includePath + * @return void + */ + public static function addApplicationIncludePath($includePath) { + $incPath = get_include_path(); + set_include_path($includePath . PATH_SEPARATOR . $incPath); + } + + + /** + * Main SPL autoloader function for the framework + * + * @param string $className + * @return boolean + */ + public static function autoload($className) { + + if (class_exists($className, false) || interface_exists($className, false)) { + return false; + } + + if(self::$productionMode) { + if(!is_array(self::$classFileMap)) { + self::$classFileMap = Bee_Cache_Manager::retrieve(self::CLASS_FILE_CACHE_PREFIX); + if(!is_array(self::$classFileMap)) { + self::$classFileMap = array(); + } + } + + if(array_key_exists($className, self::$classFileMap)) { + $cachedPath = self::$classFileMap[$className]; + if($cachedPath === self::GENERATED_CLASS_CODE_MARKER) { + return false; + } + + include $cachedPath; + if (class_exists($className, false) || interface_exists($className, false)) { + return false; + } + } + + if (class_exists($className)) { + array_push(self::$missedClassNames, $className); + } + // TODO: What to do if class-loading fails?? + } + + if(self::$enhancedClassesStore != null && !array_key_exists($className, self::$weavingExcludedClasses) && substr($className, 0, strlen(self::WEAVING_PACKAGE_PREFIX)) != self::WEAVING_PACKAGE_PREFIX) { + // possibly a woven class + + if(self::$enhancedClassesStore->loadClass($className)) { + return true; + } + + if(self::$weaveDuringClassloading) { + require_once dirname(__FILE__) . 'Bee/Weaving/Enhancer.php'; + + $enhancer = new Bee_Weaving_Enhancer($className); + if($enhancer->createEnhancedClass() !== false) { + return true; + } + } + } + + foreach(self::getClassFileLocations($className) as $loc) { + include $loc; + if (class_exists($className, false) || interface_exists($className, false)) { + return true; + } + } + + return false; + } + + public static function getClassFileLocations($className) { + return array( + str_replace('_', DIRECTORY_SEPARATOR, str_replace('\\', DIRECTORY_SEPARATOR, $className)) . '.php', + $className . '.php' + ); + } + + public static function shutdown() { + if(self::$productionMode) { + foreach(self::$missedClassNames as $missedClassName) { + $ref = new ReflectionClass($missedClassName); + self::$classFileMap[$missedClassName] = file_exists($ref->getFileName()) ? $ref->getFileName() : self::GENERATED_CLASS_CODE_MARKER; + } + Bee_Cache_Manager::store(self::CLASS_FILE_CACHE_PREFIX, self::$classFileMap); + } + + Bee_Cache_Manager::shutdown(); + } + + /** + * Convenience method, dispatches current request using a dispatcher context configured from the + * given set of XML config locations. + * + * @param String $configLocation comma-separated string XML config files to load the bean definitions from + * @return void + */ + public static function dispatchRequestUsingXmlContext($configLocation) { + try { + Bee_Utils_Assert::notNull($configLocation); + $ctx = new Bee_Context_Xml($configLocation); + self::dispatchRequestUsingContext($ctx); + } catch (Exception $e) { + self::handleException($e); + } + } + + /** + * Convenience method, dispatches current request using the given dispatcher context. + * + * @param Bee_IContext $ctx + * @return void + */ + public static function dispatchRequestUsingContext(Bee_IContext $ctx) { + try { + Bee_Utils_Assert::notNull($ctx); + $dp = new Bee_MVC_Dispatcher($ctx); + $dp->dispatch(); + } catch (Exception $e) { + self::handleException($e); + } + } + + public static function handleException(Exception $e) { + $topLevelMessage = $e->getMessage(); + + $js = '<script>'."\n"; + $js .= 'function toggle(event) {'."\n"; + + $js .= 'console.dir(event)'."\n"; + $js .= 'event.cancelBubble = true;'."\n"; + $js .= 'event.stopImmediatePropagation();'."\n"; + $js .= 'var ele = event.target.nextElementSibling;'."\n"; + $js .= 'if (ele.style.display == "none") {'."\n"; + $js .= 'ele.style.display = "block";'."\n"; + $js .= '} else {'."\n"; + $js .= 'ele.style.display = "none";'."\n"; + $js .= '}'."\n"; + $js .= '}'."\n"; + $js .= '</script>'."\n"; + + echo $js; + + + $excCnt = 0; + + while (!is_null($e)) { + $excCnt += 1; + echo '<div style="padding: 0 0 2px 0; margin: 0 2px 10px 2px; border: solid 1px #666;">'; + echo '<div style="background-color: #666; color: #fff; margin-bottom: 5px; padding: 5px; cursor: pointer;" onclick="javascript:toggle(event);">'.$excCnt.'. Exception: "'.get_class($e).'"</div>'; + + echo '<div>'; + echo '<div style="padding: 0 0 2px 0; margin: 10px; border: solid 1px #aaa; color: #aaa;">'; + echo '<div style="background-color: #aaa; color: #666; padding: 5px; cursor: pointer;" onclick="javascript:toggle(event);">Message</div>'; + echo '<div style="padding: 5px;">'; + echo $e->getMessage(); + echo '</div>'; + echo '</div>'; + + echo '<div style="padding: 0 0 2px 0; margin: 10px; border: solid 1px #aaa; color: #aaa;">'; + echo '<div style="background-color: #aaa; color: #666; padding: 5px; cursor: pointer;" onclick="javascript:toggle(event);">Stracktrace</div>'; + echo '<div style="padding: 5px; font-size: 10px; display: none;">'; + self::printArray($e->getTrace()); + echo '</div>'; + echo '</div>'; + echo '</div>'; + echo '</div>'; + + +// echo 'Root-Cause: '; + if ($e instanceof Bee_Exceptions_Base) { + $e = $e->getCause(); + } else { + $e = null; + } + + } + + error_log($topLevelMessage, E_USER_WARNING); + } + + private static function printSpaces($count) { + for ($i=0; $i<$count; $i++) { + echo ' '; + } + } + + public static function printArray($output, $level=0) { + if (is_array($output)) { + foreach ($output as $key => $value) { + self::printSpaces($level*4); + echo $key; + if (is_array($value)) { + echo '<br/>'; + } + self::printArray($value, $level+1); + } + } else { + self::printSpaces($level*4); + if (is_object($output)) { + echo 'Object - Class: '; + echo get_class($output); + } else { + echo $output; + } + echo '<br/>'; + } + if ($level==1) { + echo '<hr/>'; + } + } + + + /** + * The applicationName is an identifier that can be used + * to uniquely identify the application - e.g. in the + * SessionContext - even from a different entry page. + * + * @return String + */ + public static final function getApplicationName() { + return self::$applicationName; + } + + public static function setProductionMode($productionMode) { + self::$productionMode = $productionMode; + } + + public static function getProductionMode() { + return self::$productionMode; + } + + public static function getLoggerForClass($className) { + return Logger::getLogger(str_replace('_', '.', str_replace('\\', '.', $className))); + } +} + +Bee_Framework::init(); + +//require_once dirname(__FILE__) . '/Utils/ITypeDefinitions.php'; + +interface TYPES extends Bee_Utils_ITypeDefinitions { +} \ No newline at end of file Modified: trunk/framework/Bee/MVC/Controller/Multiaction/MethodNameResolver/AnnotationBased.php =================================================================== --- trunk/framework/Bee/MVC/Controller/Multiaction/MethodNameResolver/AnnotationBased.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/MVC/Controller/Multiaction/MethodNameResolver/AnnotationBased.php 2013-05-02 13:22:26 UTC (rev 27) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Addendum\ReflectionAnnotatedClass; /** * Method name resolver implementation based on Addendum Annotations. This is a very powerful implementation, capable of invoking different @@ -68,7 +69,7 @@ $delegateClassName = get_class($this->getController()->getDelegate()); - if(BeeFramework::getProductionMode()) { + if(Bee_Framework::getProductionMode()) { $this->methodResolvers = Bee_Cache_Manager::retrieve(self::CACHE_KEY_PREFIX.$delegateClassName); } @@ -110,7 +111,7 @@ } } - if(BeeFramework::getProductionMode()) { + if(Bee_Framework::getProductionMode()) { Bee_Cache_Manager::store(self::CACHE_KEY_PREFIX.$delegateClassName, $this->methodResolvers); } } Modified: trunk/framework/Bee/MVC/Controller/Multiaction/RequestHandler.php =================================================================== --- trunk/framework/Bee/MVC/Controller/Multiaction/RequestHandler.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/MVC/Controller/Multiaction/RequestHandler.php 2013-05-02 13:22:26 UTC (rev 27) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Addendum\Annotation; /** * Addendum annotation for the annotation-based method name resolver. Modified: trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php =================================================================== --- trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/Security/Annotations/SecuredMethodDefinitionSource.php 2013-05-02 13:22:26 UTC (rev 27) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Addendum\ReflectionAnnotatedClass; /** * Created by IntelliJ IDEA. Modified: trunk/framework/Bee/Weaving/Enhancer.php =================================================================== --- trunk/framework/Bee/Weaving/Enhancer.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/Bee/Weaving/Enhancer.php 2013-05-02 13:22:26 UTC (rev 27) @@ -98,15 +98,15 @@ return $classNameToCreate; } - if(!BeeFramework::getEnhancedClassesStore()->hasStoredClass($classNameToCreate)) { + if(!Bee_Framework::getEnhancedClassesStore()->hasStoredClass($classNameToCreate)) { $incPaths = explode(PATH_SEPARATOR, get_include_path()); - foreach(BeeFramework::getClassFileLocations($templateClassName) as $loc) { + foreach(Bee_Framework::getClassFileLocations($templateClassName) as $loc) { foreach($incPaths as $incPath) { $classFile = $incPath . DIRECTORY_SEPARATOR . $loc; if(file_exists($classFile)) { $this->enhanceClass(file_get_contents($classFile)); - BeeFramework::getEnhancedClassesStore()->storeClass($classNameToCreate, $this->toSourceCode()); + Bee_Framework::getEnhancedClassesStore()->storeClass($classNameToCreate, $this->toSourceCode()); // file_put_contents($enhancedClassLocation, $this->toSourceCode()); break 2; } @@ -114,7 +114,7 @@ } } - if (BeeFramework::getEnhancedClassesStore()->loadClass($classNameToCreate)) { + if (Bee_Framework::getEnhancedClassesStore()->loadClass($classNameToCreate)) { return $classNameToCreate; } return false; Deleted: trunk/framework/BeeFramework.php =================================================================== --- trunk/framework/BeeFramework.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/framework/BeeFramework.php 2013-05-02 13:22:26 UTC (rev 27) @@ -1,353 +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. - */ - -//require_once dirname(__FILE__).'/../libs/addendum/annotations.php'; - -class BeeFramework { - - const WEAVING_PACKAGE_PREFIX = 'Bee_'; - - const CLASS_FILE_CACHE_PREFIX = '__BeeClassFileCache_'; - - const GENERATED_CLASS_CODE_MARKER = '__CLASS_IS_GENERATED'; - - private static $beeHiveLocation; - - private static $applicationId = false; - - /** - * @var Bee_Weaving_IEnhancedClassesStore - */ - private static $enhancedClassesStore = null; - - /** - * todo: quick n dirty - * @var array - */ - private static $weavingExcludedClasses = array(); - - private static $weaveDuringClassloading = false; - - private static $missedClassNames = array(); - - private static $classFileMap; - - private static $productionMode = false; - - /** - * @param Bee_Weaving_IEnhancedClassesStore $enhancedClassesStore - */ - public static function setEnhancedClassesStore(Bee_Weaving_IEnhancedClassesStore $enhancedClassesStore) { - self::$enhancedClassesStore = $enhancedClassesStore; - } - - /** - * @return Bee_Weaving_IEnhancedClassesStore - */ - public static function getEnhancedClassesStore() { - return self::$enhancedClassesStore; - } - - public static function excludeFromWeaving($className) { - self::$weavingExcludedClasses[$className] = true; - } - - public static function setApplicationId($applicationId) { - self::$applicationId = $applicationId; - } - - public static function getApplicationId() { - return self::$applicationId; - } - - /** - * Main bootstrap method for the framework. Basically just initializes the framework classloader. - * - * @return void - */ - static function init() { - self::$beeHiveLocation = dirname(__FILE__); - self::addApplicationIncludePath(self::$beeHiveLocation); - - require_once dirname(__FILE__).'/Bee/Cache/Manager.php'; - - spl_autoload_register(array(__CLASS__, 'autoload')); - - register_shutdown_function(array(__CLASS__, 'shutdown')); -// Bee_Cache_Manager::init(); - } - - public static function handleError($errno, $errstr, $errfile, $errline) { - error_log("HANDLING ERROR $errno"); - if((E_ERROR | E_RECOVERABLE_ERROR) & $errno) { - - error_log($errno .' : ' . $errstr); - throw new ErrorException($errstr, 0, $errno, $errfile, $errline); - } else if (E_ALL & ~E_NOTICE & ~E_WARNING & $errno) { - error_log($errno .' : ' . $errstr); - } - } - - /** - * Register application-specific include path with the framework classloader. - * - * @param String $includePath - * @return void - */ - public static function addApplicationIncludePath($includePath) { - $incPath = get_include_path(); - set_include_path($includePath . PATH_SEPARATOR . $incPath); - } - - - /** - * Main SPL autoloader function for the framework - * - * @param string $className - * @return boolean - */ - public static function autoload($className) { - - if (class_exists($className, false) || interface_exists($className, false)) { - return false; - } - - if(self::$productionMode) { - if(!is_array(self::$classFileMap)) { - self::$classFileMap = Bee_Cache_Manager::retrieve(self::CLASS_FILE_CACHE_PREFIX); - if(!is_array(self::$classFileMap)) { - self::$classFileMap = array(); - } - } - - if(array_key_exists($className, self::$classFileMap)) { - $cachedPath = self::$classFileMap[$className]; - if($cachedPath === self::GENERATED_CLASS_CODE_MARKER) { - return false; - } - - include $cachedPath; - if (class_exists($className, false) || interface_exists($className, false)) { - return false; - } - } - - if (class_exists($className)) { - array_push(self::$missedClassNames, $className); - } - // TODO: What to do if class-loading fails?? - } - - if(self::$enhancedClassesStore != null && !array_key_exists($className, self::$weavingExcludedClasses) && substr($className, 0, strlen(self::WEAVING_PACKAGE_PREFIX)) != self::WEAVING_PACKAGE_PREFIX) { - // possibly a woven class - - if(self::$enhancedClassesStore->loadClass($className)) { - return true; - } - - if(self::$weaveDuringClassloading) { - require_once dirname(__FILE__).'Bee/Weaving/Enhancer.php'; - - $enhancer = new Bee_Weaving_Enhancer($className); - if($enhancer->createEnhancedClass() !== false) { - return true; - } - } - } - - foreach(self::getClassFileLocations($className) as $loc) { - include $loc; - if (class_exists($className, false) || interface_exists($className, false)) { - return true; - } - } - - return false; - } - - public static function getClassFileLocations($className) { - return array( - str_replace('_', DIRECTORY_SEPARATOR, str_replace('\\', DIRECTORY_SEPARATOR, $className)) . '.php', - $className . '.php' - ); - } - - public static function shutdown() { - if(self::$productionMode) { - foreach(self::$missedClassNames as $missedClassName) { - $ref = new ReflectionClass($missedClassName); - self::$classFileMap[$missedClassName] = file_exists($ref->getFileName()) ? $ref->getFileName() : self::GENERATED_CLASS_CODE_MARKER; - } - Bee_Cache_Manager::store(self::CLASS_FILE_CACHE_PREFIX, self::$classFileMap); - } - - Bee_Cache_Manager::shutdown(); - } - - /** - * Convenience method, dispatches current request using a dispatcher context configured from the - * given set of XML config locations. - * - * @param String $configLocation comma-separated string XML config files to load the bean definitions from - * @return void - */ - public static function dispatchRequestUsingXmlContext($configLocation) { - try { - Bee_Utils_Assert::notNull($configLocation); - $ctx = new Bee_Context_Xml($configLocation); - self::dispatchRequestUsingContext($ctx); - } catch (Exception $e) { - self::handleException($e); - } - } - - /** - * Convenience method, dispatches current request using the given dispatcher context. - * - * @param Bee_IContext $ctx - * @return void - */ - public static function dispatchRequestUsingContext(Bee_IContext $ctx) { - try { - Bee_Utils_Assert::notNull($ctx); - $dp = new Bee_MVC_Dispatcher($ctx); - $dp->dispatch(); - } catch (Exception $e) { - self::handleException($e); - } - } - - public static function handleException(Exception $e) { - $topLevelMessage = $e->getMessage(); - - $js = '<script>'."\n"; - $js .= 'function toggle(event) {'."\n"; - - $js .= 'console.dir(event)'."\n"; - $js .= 'event.cancelBubble = true;'."\n"; - $js .= 'event.stopImmediatePropagation();'."\n"; - $js .= 'var ele = event.target.nextElementSibling;'."\n"; - $js .= 'if (ele.style.display == "none") {'."\n"; - $js .= 'ele.style.display = "block";'."\n"; - $js .= '} else {'."\n"; - $js .= 'ele.style.display = "none";'."\n"; - $js .= '}'."\n"; - $js .= '}'."\n"; - $js .= '</script>'."\n"; - - echo $js; - - - $excCnt = 0; - - while (!is_null($e)) { - $excCnt += 1; - echo '<div style="padding: 0 0 2px 0; margin: 0 2px 10px 2px; border: solid 1px #666;">'; - echo '<div style="background-color: #666; color: #fff; margin-bottom: 5px; padding: 5px; cursor: pointer;" onclick="javascript:toggle(event);">'.$excCnt.'. Exception: "'.get_class($e).'"</div>'; - - echo '<div>'; - echo '<div style="padding: 0 0 2px 0; margin: 10px; border: solid 1px #aaa; color: #aaa;">'; - echo '<div style="background-color: #aaa; color: #666; padding: 5px; cursor: pointer;" onclick="javascript:toggle(event);">Message</div>'; - echo '<div style="padding: 5px;">'; - echo $e->getMessage(); - echo '</div>'; - echo '</div>'; - - echo '<div style="padding: 0 0 2px 0; margin: 10px; border: solid 1px #aaa; color: #aaa;">'; - echo '<div style="background-color: #aaa; color: #666; padding: 5px; cursor: pointer;" onclick="javascript:toggle(event);">Stracktrace</div>'; - echo '<div style="padding: 5px; font-size: 10px; display: none;">'; - self::printArray($e->getTrace()); - echo '</div>'; - echo '</div>'; - echo '</div>'; - echo '</div>'; - - -// echo 'Root-Cause: '; - if ($e instanceof Bee_Exceptions_Base) { - $e = $e->getCause(); - } else { - $e = null; - } - - } - - error_log($topLevelMessage, E_USER_WARNING); - } - - private static function printSpaces($count) { - for ($i=0; $i<$count; $i++) { - echo ' '; - } - } - - public static function printArray($output, $level=0) { - if (is_array($output)) { - foreach ($output as $key => $value) { - self::printSpaces($level*4); - echo $key; - if (is_array($value)) { - echo '<br/>'; - } - self::printArray($value, $level+1); - } - } else { - self::printSpaces($level*4); - if (is_object($output)) { - echo 'Object - Class: '; - echo get_class($output); - } else { - echo $output; - } - echo '<br/>'; - } - if ($level==1) { - echo '<hr/>'; - } - } - - - /** - * The applicationName is an identifier that can be used - * to uniquely identify the application - e.g. in the - * SessionContext - even from a different entry page. - * - * @return String - */ - public static final function getApplicationName() { - return self::$applicationName; - } - - public static function setProductionMode($productionMode) { - self::$productionMode = $productionMode; - } - - public static function getProductionMode() { - return self::$productionMode; - } - - public static function getLoggerForClass($className) { - return Logger::getLogger(str_replace('_', '.', str_replace('\\', '.', $className))); - } -} - -BeeFramework::init(); - -require_once dirname(__FILE__).'/Bee/Utils/ITypeDefinitions.php'; - -interface TYPES extends Bee_Utils_ITypeDefinitions { -} \ No newline at end of file Copied: trunk/framework/composer.json (from rev 26, trunk/composer.json) =================================================================== --- trunk/framework/composer.json (rev 0) +++ trunk/framework/composer.json 2013-05-02 13:22:26 UTC (rev 27) @@ -0,0 +1,27 @@ +{ + "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.2.3", + "niktux/addendum": "0.4.1", + "apache/log4php": "2.3.0" + }, + "autoload": { + "psr-0": { + "Bee": "framework/" + } + } +} \ No newline at end of file Property changes on: trunk/framework/composer.json ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/tests/bootstrap.php =================================================================== --- trunk/tests/bootstrap.php 2013-05-02 10:50:42 UTC (rev 26) +++ trunk/tests/bootstrap.php 2013-05-02 13:22:26 UTC (rev 27) @@ -22,6 +22,6 @@ */ require_once '../libs/addendum-0.4.1/annotations.php'; -require_once '../libs/log4php-2.1.0/Logger.php'; -require_once '../framework/BeeFramework.php'; +require_once '../libs/apache-log4php-2.3.0/Logger.php'; +require_once '../framework/Bee/Framework.php'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |