beeframework-svn Mailing List for Bee Framework (Page 10)
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-08-25 02:09:32
|
Revision: 71 http://sourceforge.net/p/beeframework/code/71 Author: m_plomer Date: 2013-08-25 02:09:27 +0000 (Sun, 25 Aug 2013) Log Message: ----------- - EnumBase / EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-25 01:18:00 UTC (rev 70) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-25 02:09:27 UTC (rev 71) @@ -59,7 +59,7 @@ } public static function getEnumName() { - return 'enum'.substr(static::getEnumClassName(), strrpos(static::getEnumClassName(), '\\')); + return 'enum'.substr(static::getEnumClassName(), strrpos(static::getEnumClassName(), '\\') + 1); } public function getMappedDatabaseTypes(AbstractPlatform $platform) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-25 01:18:03
|
Revision: 70 http://sourceforge.net/p/beeframework/code/70 Author: m_plomer Date: 2013-08-25 01:18:00 +0000 (Sun, 25 Aug 2013) Log Message: ----------- - EnumBase / EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 21:24:29 UTC (rev 69) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-25 01:18:00 UTC (rev 70) @@ -61,4 +61,8 @@ public static function getEnumName() { return 'enum'.substr(static::getEnumClassName(), strrpos(static::getEnumClassName(), '\\')); } + + public function getMappedDatabaseTypes(AbstractPlatform $platform) { + return array('enum'); + } } \ 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-24 21:24:32
|
Revision: 69 http://sourceforge.net/p/beeframework/code/69 Author: m_plomer Date: 2013-08-24 21:24:29 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - EnumBase / EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 20:49:39 UTC (rev 68) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 21:24:29 UTC (rev 69) @@ -59,6 +59,6 @@ } public static function getEnumName() { - return 'enum_' . str_replace('\\', '', static::getEnumClassName()); + return 'enum'.substr(static::getEnumClassName(), strrpos(static::getEnumClassName(), '\\')); } } \ 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-24 20:49:43
|
Revision: 68 http://sourceforge.net/p/beeframework/code/68 Author: m_plomer Date: 2013-08-24 20:49:39 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - EnumBase / EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 18:24:57 UTC (rev 67) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 20:49:39 UTC (rev 68) @@ -12,11 +12,6 @@ const ENUM_BASE_TYPE = 'Bee\Utils\EnumBase'; /** - * @var array - */ - private $values; - - /** * @var \ReflectionClass */ private $reflClass; @@ -28,14 +23,8 @@ return null; } - public function __construct() { - $this->reflClass = new \ReflectionClass(static::getEnumClassName()); - if (!$this->reflClass->isSubclassOf(self::ENUM_BASE_TYPE)) { - throw new \UnexpectedValueException('"' . $this->reflClass . '" is not a subclass of "' . self::ENUM_BASE_TYPE . '"'); - } - } - public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { + if (!$this->reflClass) self::init(); $values = array_map(function ($val) { return "'" . $val . "'"; }, $this->reflClass->getMethod('getValues')->invoke(null)); @@ -43,10 +32,12 @@ } public function convertToPHPValue($value, AbstractPlatform $platform) { + if (!$this->reflClass) self::init(); return $this->reflClass->getMethod('get')->invoke(null, $value); } public function convertToDatabaseValue($value, AbstractPlatform $platform) { + if (!$this->reflClass) self::init(); if (!$this->reflClass->isInstance($value)) { throw new \UnexpectedValueException('Not a valid enum element for "' . self::ENUM_BASE_TYPE . '": ' . $value); } @@ -56,6 +47,13 @@ return $value->val(); } + private function init() { + $this->reflClass = new \ReflectionClass(static::getEnumClassName()); + if (!$this->reflClass->isSubclassOf(self::ENUM_BASE_TYPE)) { + throw new \UnexpectedValueException('"' . $this->reflClass . '" is not a subclass of "' . self::ENUM_BASE_TYPE . '"'); + } + } + public function getName() { return self::getEnumName(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-24 18:25:00
|
Revision: 67 http://sourceforge.net/p/beeframework/code/67 Author: m_plomer Date: 2013-08-24 18:24:57 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - EnumBase / EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 17:25:17 UTC (rev 66) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 18:24:57 UTC (rev 67) @@ -17,11 +17,6 @@ private $values; /** - * @var string - */ - private $name; - - /** * @var \ReflectionClass */ private $reflClass; @@ -29,22 +24,22 @@ /** * @return string */ - protected abstract function getEnumClassName(); + protected static function getEnumClassName() { + return null; + } public function __construct() { - $this->reflClass = new \ReflectionClass($this->getEnumClassName()); + $this->reflClass = new \ReflectionClass(static::getEnumClassName()); if (!$this->reflClass->isSubclassOf(self::ENUM_BASE_TYPE)) { throw new \UnexpectedValueException('"' . $this->reflClass . '" is not a subclass of "' . self::ENUM_BASE_TYPE . '"'); } - - $this->name = 'enum_' . str_replace('\\', '', $this->getEnumClassName()); } public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { $values = array_map(function ($val) { return "'" . $val . "'"; }, $this->reflClass->getMethod('getValues')->invoke(null)); - return "ENUM(" . implode(", ", $values) . ") COMMENT '(DC2Type:" . $this->name . ")'"; + return "ENUM(" . implode(", ", $values) . ") COMMENT '(DC2Type:" . $this->getName() . ")'"; } public function convertToPHPValue($value, AbstractPlatform $platform) { @@ -62,6 +57,10 @@ } public function getName() { - return $this->name; + return self::getEnumName(); } + + public static function getEnumName() { + return 'enum_' . str_replace('\\', '', static::getEnumClassName()); + } } \ 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-24 17:25:20
|
Revision: 66 http://sourceforge.net/p/beeframework/code/66 Author: m_plomer Date: 2013-08-24 17:25:17 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - EnumBase / EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 17:16:44 UTC (rev 65) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 17:25:17 UTC (rev 66) @@ -10,6 +10,7 @@ abstract class EnumType extends Type { const ENUM_BASE_TYPE = 'Bee\Utils\EnumBase'; + /** * @var array */ @@ -20,8 +21,14 @@ */ private $name; + /** + * @var \ReflectionClass + */ private $reflClass; + /** + * @return string + */ protected abstract function getEnumClassName(); public function __construct() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-24 17:16:48
|
Revision: 65 http://sourceforge.net/p/beeframework/code/65 Author: m_plomer Date: 2013-08-24 17:16:44 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - EnumBase / EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Added Paths: ----------- trunk/framework/Bee/Utils/EnumBase.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 14:04:11 UTC (rev 64) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 17:16:44 UTC (rev 65) @@ -7,8 +7,9 @@ * Class EnumType * @package Bee\Persistence\Doctrine2\Types */ -abstract class EnumType extends Type -{ +abstract class EnumType extends Type { + + const ENUM_BASE_TYPE = 'Bee\Utils\EnumBase'; /** * @var array */ @@ -19,37 +20,41 @@ */ private $name; + private $reflClass; + + protected abstract function getEnumClassName(); + public function __construct() { - $reflClass = new \ReflectionClass($this); - $this->values = array_diff_key($reflClass->getConstants(), array('ENUM_NAME')); - $this->name = $reflClass->getConstant('ENUM_NAME'); + $this->reflClass = new \ReflectionClass($this->getEnumClassName()); + if (!$this->reflClass->isSubclassOf(self::ENUM_BASE_TYPE)) { + throw new \UnexpectedValueException('"' . $this->reflClass . '" is not a subclass of "' . self::ENUM_BASE_TYPE . '"'); + } + + $this->name = 'enum_' . str_replace('\\', '', $this->getEnumClassName()); } - protected function getValues() { - return $this->values; + public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { + $values = array_map(function ($val) { + return "'" . $val . "'"; + }, $this->reflClass->getMethod('getValues')->invoke(null)); + return "ENUM(" . implode(", ", $values) . ") COMMENT '(DC2Type:" . $this->name . ")'"; } - public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) - { - $values = array_map(function($val) { return "'".$val."'"; }, $this->getValues()); - return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'"; - } + public function convertToPHPValue($value, AbstractPlatform $platform) { + return $this->reflClass->getMethod('get')->invoke(null, $value); + } - public function convertToPHPValue($value, AbstractPlatform $platform) - { - return $value; - } + public function convertToDatabaseValue($value, AbstractPlatform $platform) { + if (!$this->reflClass->isInstance($value)) { + throw new \UnexpectedValueException('Not a valid enum element for "' . self::ENUM_BASE_TYPE . '": ' . $value); + } + // check if value is valid + self::convertToPHPValue($value->val(), $platform); + // return actual value + return $value->val(); + } - public function convertToDatabaseValue($value, AbstractPlatform $platform) - { - if (!in_array($value, $this->getValues())) { - throw new \InvalidArgumentException("Invalid '".$this->name."' value."); - } - return $value; - } - - public function getName() - { - return $this->name; - } + public function getName() { + return $this->name; + } } \ No newline at end of file Added: trunk/framework/Bee/Utils/EnumBase.php =================================================================== --- trunk/framework/Bee/Utils/EnumBase.php (rev 0) +++ trunk/framework/Bee/Utils/EnumBase.php 2013-08-24 17:16:44 UTC (rev 65) @@ -0,0 +1,122 @@ +<?php +namespace Bee\Utils; +/* + * 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 ReflectionClass; + +/** + * Class EnumBase + * @package Bee\Utils + */ +abstract class EnumBase { + + /** + * @var ReflectionClass + */ + private static $reflClass = null; + + /** + * @var array + */ + private static $valueToName = null; + + /** + * @var EnumBase + */ + private static $instancesByValue = null; + + /** + * @var EnumBase + */ + private static $instancesByOid = null; + + /** + * @var mixed + */ + private $value; + + private final function __construct($value) { + $this->value = $value; + } + + /** + * @return mixed + */ + public final function val() { + return $this->value; + } + + /** + * @return array + */ + public static function getValues() { + self::init(); + return array_keys(self::$valueToName); + } + + /** + * Check if valid instance + * @param EnumBase $inst + * @return bool + */ + public static function has(EnumBase $inst) { + // no need to call init, as + return isset(self::$instancesByOid[spl_object_hash($inst)]); + } + + /** + * Retrieve singleton instance + * + * @param $value + * @return EnumBase + * @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(!isset(self::$instancesByValue[$value])) { + $name = self::$valueToName[$value]; + $className = self::$reflClass->getName(); + $instanceClassName = class_exists($className . '_' . $name, false) ? $className . '_' . $name : $className; + $inst = new $instanceClassName($value); + self::$instancesByValue[$value] = $inst; + self::$instancesByOid[spl_object_hash($inst)] = $inst; + } + + return self::$instancesByValue[$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'); + } + } + } + + private function __clone() { + } + + 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. |
From: <m_p...@us...> - 2013-08-24 14:04:15
|
Revision: 64 http://sourceforge.net/p/beeframework/code/64 Author: m_plomer Date: 2013-08-24 14:04:11 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - fixed Doctrine2 EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:53:48 UTC (rev 63) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 14:04:11 UTC (rev 64) @@ -23,10 +23,6 @@ $reflClass = new \ReflectionClass($this); $this->values = array_diff_key($reflClass->getConstants(), array('ENUM_NAME')); $this->name = $reflClass->getConstant('ENUM_NAME'); - - echo '<hr/>EnumType ' . get_class($this) . '<br/>'; - var_dump($this); - echo '<hr/>'; } protected function getValues() { @@ -46,7 +42,6 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) { - if (!in_array($value, $this->getValues())) { throw new \InvalidArgumentException("Invalid '".$this->name."' value."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-24 13:53:52
|
Revision: 63 http://sourceforge.net/p/beeframework/code/63 Author: m_plomer Date: 2013-08-24 13:53:48 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - fixed Doctrine2 EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:41:15 UTC (rev 62) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:53:48 UTC (rev 63) @@ -9,21 +9,33 @@ */ abstract class EnumType extends Type { + /** + * @var array + */ private $values; + /** + * @var string + */ private $name; - protected abstract function getEnumClassName(); + public function __construct() { + $reflClass = new \ReflectionClass($this); + $this->values = array_diff_key($reflClass->getConstants(), array('ENUM_NAME')); + $this->name = $reflClass->getConstant('ENUM_NAME'); - public function __construct() { - $reflClass = new \ReflectionClass($this->getEnumClassName()); - $this->values = $reflClass->getConstants(); - $this->name = 'enum_' . str_replace('\\', '_', $this->getEnumClassName()); + echo '<hr/>EnumType ' . get_class($this) . '<br/>'; + var_dump($this); + echo '<hr/>'; } + protected function getValues() { + return $this->values; + } + public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { - $values = array_map(function($val) { return "'".$val."'"; }, $this->values); + $values = array_map(function($val) { return "'".$val."'"; }, $this->getValues()); return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'"; } @@ -35,7 +47,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) { - if (!in_array($value, $this->values)) { + if (!in_array($value, $this->getValues())) { throw new \InvalidArgumentException("Invalid '".$this->name."' value."); } return $value; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-24 13:41:20
|
Revision: 62 http://sourceforge.net/p/beeframework/code/62 Author: m_plomer Date: 2013-08-24 13:41:15 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - fixed Doctrine2 EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:26:16 UTC (rev 61) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:41:15 UTC (rev 62) @@ -9,31 +9,21 @@ */ abstract class EnumType extends Type { - /** - * @var \ReflectionClass - */ - private $reflClass; - private $values; private $name; + protected abstract function getEnumClassName(); + public function __construct() { - $this->reflClass = new \ReflectionClass($this); - $this->values = array_diff_key($this->reflClass->getConstants(), array('ENUM_NAME')); - - echo '<hr/>EnumType ' . get_class($this) . '<br/>'; - var_dump($this); - echo '<hr/>'; + $reflClass = new \ReflectionClass($this->getEnumClassName()); + $this->values = $reflClass->getConstants(); + $this->name = 'enum_' . str_replace('\\', '_', $this->getEnumClassName()); } - protected function getValues() { - return $this->values; - } - public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { - $values = array_map(function($val) { return "'".$val."'"; }, $this->getValues()); + $values = array_map(function($val) { return "'".$val."'"; }, $this->values); return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'"; } @@ -45,7 +35,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) { - if (!in_array($value, $this->getValues())) { + if (!in_array($value, $this->values)) { throw new \InvalidArgumentException("Invalid '".$this->name."' value."); } return $value; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-24 13:26:21
|
Revision: 61 http://sourceforge.net/p/beeframework/code/61 Author: m_plomer Date: 2013-08-24 13:26:16 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - fixed Doctrine2 EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 12:48:31 UTC (rev 60) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:26:16 UTC (rev 61) @@ -9,18 +9,22 @@ */ abstract class EnumType extends Type { - protected $name; - /** * @var \ReflectionClass */ - protected $reflClass; + private $reflClass; private $values; + private $name; + public function __construct() { $this->reflClass = new \ReflectionClass($this); - $this->values = $this->reflClass->getConstants(); + $this->values = array_diff_key($this->reflClass->getConstants(), array('ENUM_NAME')); + + echo '<hr/>EnumType ' . get_class($this) . '<br/>'; + var_dump($this); + echo '<hr/>'; } protected function getValues() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-24 12:48:38
|
Revision: 60 http://sourceforge.net/p/beeframework/code/60 Author: m_plomer Date: 2013-08-24 12:48:31 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - fixed Doctrine2 EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 12:32:07 UTC (rev 59) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 12:48:31 UTC (rev 60) @@ -10,12 +10,26 @@ abstract class EnumType extends Type { protected $name; - protected $values = array(); + /** + * @var \ReflectionClass + */ + protected $reflClass; + + private $values; + + public function __construct() { + $this->reflClass = new \ReflectionClass($this); + $this->values = $this->reflClass->getConstants(); + } + + protected function getValues() { + return $this->values; + } + public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { - $values = array_map(function($val) { return "'".$val."'"; }, $this->values); - + $values = array_map(function($val) { return "'".$val."'"; }, $this->getValues()); return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'"; } @@ -26,7 +40,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) { - if (!in_array($value, $this->values)) { + + if (!in_array($value, $this->getValues())) { throw new \InvalidArgumentException("Invalid '".$this->name."' value."); } return $value; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-24 12:32:10
|
Revision: 59 http://sourceforge.net/p/beeframework/code/59 Author: m_plomer Date: 2013-08-24 12:32:07 +0000 (Sat, 24 Aug 2013) Log Message: ----------- - restructured libs - added Doctrine2 EnumType Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php Added Paths: ----------- trunk/framework/Bee/Persistence/Doctrine2/Types/ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php Removed Paths: ------------- trunk/libs/addendum-0.4.0/ trunk/libs/addendum-0.4.1/ trunk/libs/apache-log4php-2.3.0/ Property Changed: ---------------- trunk/ Index: trunk =================================================================== --- trunk 2013-08-19 22:44:55 UTC (rev 58) +++ trunk 2013-08-24 12:32:07 UTC (rev 59) Property changes on: trunk ___________________________________________________________________ Modified: svn:ignore ## -1 +1,3 ## .idea +vendor/** +composer.lock Modified: trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2013-08-19 22:44:55 UTC (rev 58) +++ trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2013-08-24 12:32:07 UTC (rev 59) @@ -1,5 +1,7 @@ <?php namespace Bee\Persistence\Doctrine2; +use Doctrine\ORM\Query; +use Doctrine\ORM\QueryBuilder; /** * User: mp @@ -17,13 +19,21 @@ * @internal param \Doctrine\ORM\QueryBuilder $query * @return array */ - public function executeListQuery(\Doctrine\ORM\QueryBuilder $queryBuilder, \Bee_Persistence_IRestrictionHolder $restrictionHolder = null, \Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping) { + public function executeListQuery(\Doctrine\ORM\QueryBuilder $queryBuilder, \Bee_Persistence_IRestrictionHolder $restrictionHolder = null, \Bee_Persistence_IOrderAndLimitHolder $orderAndLimitHolder = null, array $defaultOrderMapping, $hydrationMode = null) { $this->applyFilterRestrictions($queryBuilder, $restrictionHolder); $this->applyOrderAndLimit($queryBuilder, $orderAndLimitHolder, $defaultOrderMapping); - return $queryBuilder->getQuery()->execute(); + return $this->getQueryFromBuilder($queryBuilder)->execute(null, $hydrationMode); } /** + * @param QueryBuilder $qb + * @return Query + */ + protected function getQueryFromBuilder(QueryBuilder $qb) { + return $qb->getQuery(); + } + + /** * @param \Doctrine\ORM\QueryBuilder $queryBuilder * @param \Bee_Persistence_IRestrictionHolder $restrictionHolder * @internal param \Doctrine\ORM\QueryBuilder $query @@ -87,7 +97,7 @@ $queryBuilder->setMaxResults($orderAndLimitHolder->getPageSize()); // TODO: build a performant count-query! This is simply bullshit! - $pageCount = ceil(count($queryBuilder->getQuery()->execute()) / $orderAndLimitHolder->getPageSize()); + $pageCount = ceil(count($this->getQueryFromBuilder($queryBuilder)->execute()) / $orderAndLimitHolder->getPageSize()); $orderAndLimitHolder->setPageCount($pageCount); if ($orderAndLimitHolder->getCurrentPage() > $pageCount) { Added: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php (rev 0) +++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 12:32:07 UTC (rev 59) @@ -0,0 +1,39 @@ +<?php +namespace Bee\Persistence\Doctrine2\Types; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\Type; + +/** + * Class EnumType + * @package Bee\Persistence\Doctrine2\Types + */ +abstract class EnumType extends Type +{ + protected $name; + protected $values = array(); + + public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + { + $values = array_map(function($val) { return "'".$val."'"; }, $this->values); + + return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'"; + } + + public function convertToPHPValue($value, AbstractPlatform $platform) + { + return $value; + } + + public function convertToDatabaseValue($value, AbstractPlatform $platform) + { + if (!in_array($value, $this->values)) { + throw new \InvalidArgumentException("Invalid '".$this->name."' value."); + } + return $value; + } + + public function getName() + { + return $this->name; + } +} \ 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-19 22:45:01
|
Revision: 58 http://sourceforge.net/p/beeframework/code/58 Author: m_plomer Date: 2013-08-19 22:44:55 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - method-invocation extension for Context Modified Paths: -------------- trunk/framework/Bee/Context/BeanDefinitionValueResolver.php Modified: trunk/framework/Bee/Context/BeanDefinitionValueResolver.php =================================================================== --- trunk/framework/Bee/Context/BeanDefinitionValueResolver.php 2013-08-19 22:41:20 UTC (rev 57) +++ trunk/framework/Bee/Context/BeanDefinitionValueResolver.php 2013-08-19 22:44:55 UTC (rev 58) @@ -40,21 +40,12 @@ /** * Enter description here... * - * @var Bee_Context_Config_IBeanDefinition - */ - private $beanDefinition; - - /** - * Enter description here... - * * @param Bee_Context_Abstract $context * @param String $beanName - * @param Bee_Context_Config_IBeanDefinition $beanDefinition */ - public function __construct(Bee_Context_Abstract $context, $beanName, Bee_Context_Config_IBeanDefinition $beanDefinition) { + public function __construct(Bee_Context_Abstract $context, $beanName) { $this->context = $context; $this->beanName = $beanName; - $this->beanDefinition = $beanDefinition; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-19 22:41:23
|
Revision: 57 http://sourceforge.net/p/beeframework/code/57 Author: m_plomer Date: 2013-08-19 22:41:20 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - method-invocation extension for Context Modified Paths: -------------- trunk/framework/Bee/Context/Xml/ParserDelegate.php Modified: trunk/framework/Bee/Context/Xml/ParserDelegate.php =================================================================== --- trunk/framework/Bee/Context/Xml/ParserDelegate.php 2013-08-19 22:40:02 UTC (rev 56) +++ trunk/framework/Bee/Context/Xml/ParserDelegate.php 2013-08-19 22:41:20 UTC (rev 57) @@ -750,4 +750,3 @@ return (!Bee_Utils_Strings::hasLength($namespaceUri) || self::BEANS_NAMESPACE_URI === $namespaceUri); } } -?> \ 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-19 22:40:07
|
Revision: 56 http://sourceforge.net/p/beeframework/code/56 Author: m_plomer Date: 2013-08-19 22:40:02 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - method-invocation extension for Context Modified Paths: -------------- trunk/framework/Bee/Context/Xml/ParserDelegate.php Modified: trunk/framework/Bee/Context/Xml/ParserDelegate.php =================================================================== --- trunk/framework/Bee/Context/Xml/ParserDelegate.php 2013-08-19 22:30:57 UTC (rev 55) +++ trunk/framework/Bee/Context/Xml/ParserDelegate.php 2013-08-19 22:40:02 UTC (rev 56) @@ -278,7 +278,7 @@ // parseLookupOverrideSubElements(ele, bd.getMethodOverrides()); // parseReplacedMethodSubElements(ele, bd.getMethodOverrides()); - $this->parseConstructorArgElements($ele, $bd); + $this->parseConstructorArgElements($ele, $bd, $bd); $this->parsePropertyElements($ele, $bd); $this->parseMethodInvocationElements($ele, $bd); @@ -308,11 +308,11 @@ * @param Bee\Context\Config\IMethodArguments $argsHolder * @return void */ - public function parseConstructorArgElements(DOMElement $beanEle, Bee\Context\Config\IMethodArguments $argsHolder) { + public function parseConstructorArgElements(DOMElement $beanEle, Bee\Context\Config\IMethodArguments $argsHolder, Bee_Context_Config_IBeanDefinition $bd) { $nl = $beanEle->childNodes; foreach($nl as $node) { if ($node instanceof DOMElement && Bee_Utils_Dom::nodeNameEquals($node, self::CONSTRUCTOR_ARG_ELEMENT)) { - $this->parseConstructorArgElement($node, $argsHolder); + $this->parseConstructorArgElement($node, $argsHolder, $bd); } } } @@ -354,7 +354,7 @@ /** * Parse a constructor-arg element. */ - public function parseConstructorArgElement(DOMElement $ele, Bee\Context\Config\IMethodArguments $argsHolder) { + public function parseConstructorArgElement(DOMElement $ele, Bee\Context\Config\IMethodArguments $argsHolder, Bee_Context_Config_IBeanDefinition $bd) { $indexAttr = $ele->getAttribute(self::INDEX_ATTRIBUTE); @@ -365,7 +365,7 @@ } else { try { array_push($this->parseState, "Constructor_Arg_Idx_$index"); - $value = $this->parsePropertyValue($ele, $argsHolder, null); + $value = $this->parsePropertyValue($ele, $bd, null); $valueHolder = new Bee_Beans_PropertyValue($index, $value); $argsHolder->addConstructorArgumentValue($valueHolder); array_pop($this->parseState); @@ -420,7 +420,7 @@ array_push($this->parseState, $methodName); try { $methodInvocation = new \Bee\Beans\MethodInvocation($methodName); - $this->parseConstructorArgElements($ele, $methodInvocation); + $this->parseConstructorArgElements($ele, $methodInvocation, $bd); $bd->addMethodInvocation($methodInvocation); array_pop($this->parseState); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-19 22:31:00
|
Revision: 55 http://sourceforge.net/p/beeframework/code/55 Author: m_plomer Date: 2013-08-19 22:30:57 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - method-invocation extension for Context Modified Paths: -------------- trunk/framework/bee-beans-1.2.xsd Modified: trunk/framework/bee-beans-1.2.xsd =================================================================== --- trunk/framework/bee-beans-1.2.xsd 2013-08-19 22:24:45 UTC (rev 54) +++ trunk/framework/bee-beans-1.2.xsd 2013-08-19 22:30:57 UTC (rev 55) @@ -601,6 +601,7 @@ <xsd:any namespace="##other" processContents="strict"/> </xsd:choice> </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> <xsd:complexType name="propertyType"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-19 22:24:48
|
Revision: 54 http://sourceforge.net/p/beeframework/code/54 Author: m_plomer Date: 2013-08-19 22:24:45 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - method-invocation extension for Context Modified Paths: -------------- trunk/framework/bee-beans-1.2.xsd Modified: trunk/framework/bee-beans-1.2.xsd =================================================================== --- trunk/framework/bee-beans-1.2.xsd 2013-08-19 22:16:31 UTC (rev 53) +++ trunk/framework/bee-beans-1.2.xsd 2013-08-19 22:24:45 UTC (rev 54) @@ -419,19 +419,12 @@ </xsd:annotation> </xsd:element> - <xsd:element name="method-invocation"> + <xsd:element name="method-invocation" type="methodInvocationType"> <xsd:annotation> <xsd:documentation><![CDATA[ - Bean definitions can have zero or more properties. - Property elements correspond to JavaBean setter methods exposed - by the bean classes. Spring supports primitives, references to other - beans in the same or related factories, lists, maps and properties. + Bean definitions can have zero or more method invocations defined. These will be invoked upon initialization. ]]></xsd:documentation> </xsd:annotation> - <xsd:complexType> - <xsd:choice minOccurs="0" maxOccurs="unbounded"> - </xsd:choice> - </xsd:complexType> </xsd:element> <xsd:element name="ref"> @@ -600,6 +593,16 @@ <xsd:attributeGroup ref="collectionBeanAttributes"/> </xsd:complexType> + <xsd:complexType name="methodInvocationType"> + <xsd:sequence> + <xsd:element ref="description" minOccurs="0"/> + <xsd:choice minOccurs="0" maxOccurs="unbounded"> + <xsd:element ref="constructor-arg" /> + <xsd:any namespace="##other" processContents="strict"/> + </xsd:choice> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="propertyType"> <xsd:sequence> <xsd:element ref="description" minOccurs="0"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-19 22:16:35
|
Revision: 53 http://sourceforge.net/p/beeframework/code/53 Author: m_plomer Date: 2013-08-19 22:16:31 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - method-invocation extension for Context Modified Paths: -------------- trunk/framework/Bee/Context/Abstract.php trunk/framework/Bee/Context/Config/BeanDefinition/Abstract.php trunk/framework/Bee/Context/Config/BeanDefinition/Generic.php trunk/framework/Bee/Context/Config/IBeanDefinition.php trunk/framework/Bee/Context/Support/BeanUtils.php trunk/framework/Bee/Context/Xml/ParserDelegate.php trunk/framework/bee-beans-1.2.xsd Added Paths: ----------- trunk/framework/Bee/Beans/MethodInvocation.php trunk/framework/Bee/Context/Config/IMethodArguments.php trunk/framework/Bee/Context/Config/MethodArgumentsHolder.php Removed Paths: ------------- trunk/examples/vendor/ Added: trunk/framework/Bee/Beans/MethodInvocation.php =================================================================== --- trunk/framework/Bee/Beans/MethodInvocation.php (rev 0) +++ trunk/framework/Bee/Beans/MethodInvocation.php 2013-08-19 22:16:31 UTC (rev 53) @@ -0,0 +1,50 @@ +<?php +namespace Bee\Beans; +/* + * Copyright 2008-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +use Bee\Context\Config\IMethodArguments; +use Bee\Context\Config\MethodArgumentsHolder; +use Bee_Beans_PropertyValue; + +class MethodInvocation extends MethodArgumentsHolder implements IMethodArguments { + + /** + * @var string + */ + private $methodName; + + /** + * @param string $methodName + */ + function __construct($methodName) { + $this->methodName = $methodName; + } + + /** + * @param string $methodName + */ + public function setMethodName($methodName) { + $this->methodName = $methodName; + } + + /** + * @return string + */ + public function getMethodName() { + return $this->methodName; + } +} Modified: trunk/framework/Bee/Context/Abstract.php =================================================================== --- trunk/framework/Bee/Context/Abstract.php 2013-08-19 12:58:55 UTC (rev 52) +++ trunk/framework/Bee/Context/Abstract.php 2013-08-19 22:16:31 UTC (rev 53) @@ -1,4 +1,5 @@ <?php +use Bee\Beans\MethodInvocation; /* * Copyright 2008-2010 the original author or authors. * @@ -203,6 +204,7 @@ try { $this->applyPropertyValues($beanName, $beanDefinition, $instanceWrapper, $beanDefinition->getPropertyValues()); + $this->invokeMethods($beanName, $beanInstance, $beanDefinition->getMethodInvocations()); $exposedObject = $this->initializeBean($beanName, $beanInstance, $beanDefinition); } catch (Exception $ex) { if ($ex instanceof Bee_Context_BeanCreationException && $beanName === $ex->getBeanName()) { @@ -253,7 +255,7 @@ if (is_null($beanDefinition) || !$beanDefinition->isSynthetic()) { $wrappedBean = $this->applyBeanPostProcessorsBeforeInitialization($wrappedBean, $beanName); } - + try { $this->invokeInitMethods($beanName, $wrappedBean, $beanDefinition); } catch (Exception $ex) { @@ -412,15 +414,13 @@ return $beanClass->newInstanceArgs($this->createArgsArray($beanName, $beanDefinition)); } - - - private function createArgsArray($beanName, Bee_Context_Config_IBeanDefinition $beanDefinition) { + private function createArgsArray($beanName, \Bee\Context\Config\IMethodArguments $methodArguments) { // $typeConverter = null; // @todo: ??????????????????????????????????????????? // $valueResolver = new Bee_Context_BeanDefinitionValueResolver($this, $beanName, $beanDefinition, $typeConverter); - $valueResolver = new Bee_Context_BeanDefinitionValueResolver($this, $beanName, $beanDefinition); + $valueResolver = new Bee_Context_BeanDefinitionValueResolver($this, $beanName, $methodArguments); $args = array(); - foreach ($beanDefinition->getConstructorArgumentValues() as $propValue) { + foreach ($methodArguments->getConstructorArgumentValues() as $propValue) { // $value = $valueResolver->resolveValueIfNecessary('constructor/factory method argument', $propValue->getValue()); // $args[] = $typeConverter->convertIfNecessary($value, $propValue->getTypeName()); $args[] = $valueResolver->resolveValueIfNecessary('constructor/factory method argument', $propValue->getValue()); @@ -428,8 +428,6 @@ return $args; } - - /** * Apply the given property values, resolving any runtime references * to other beans in this context. @@ -459,6 +457,22 @@ } } + /** + * @param $beanName + * @param $beanInstance + * @param MethodInvocation[] $methodInvocations + */ + protected function invokeMethods($beanName, $beanInstance, array $methodInvocations = array()) { + foreach($methodInvocations as $methodInvocation) { + $method = array($beanInstance, $methodInvocation->getMethodName()); + if(!is_callable($method)) { + throw new Bee_Context_InvalidPropertyException($methodInvocation->getMethodName(), Bee_Utils_Types::getType($beanInstance), 'no such method found: '.$methodInvocation->getMethodName()); + } + // todo: validate method signature?? + call_user_func_array($method, $this->createArgsArray($beanName, $methodInvocation)); + } + } + abstract protected function loadBeanDefinitions(); /** @@ -858,6 +872,4 @@ function getModificationTimestamp() { return $this->context->getModificationTimestamp(); } -} - -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Context/Config/BeanDefinition/Abstract.php =================================================================== --- trunk/framework/Bee/Context/Config/BeanDefinition/Abstract.php 2013-08-19 12:58:55 UTC (rev 52) +++ trunk/framework/Bee/Context/Config/BeanDefinition/Abstract.php 2013-08-19 22:16:31 UTC (rev 53) @@ -14,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\Beans\MethodInvocation; +use Bee\Context\Config\MethodArgumentsHolder; /** * Enter description here... @@ -21,7 +23,7 @@ * @author Benjamin Hartmann * @author Michael Plomer <mic...@it...> */ -abstract class Bee_Context_Config_BeanDefinition_Abstract implements Bee_Context_Config_IBeanDefinition { +abstract class Bee_Context_Config_BeanDefinition_Abstract extends MethodArgumentsHolder implements Bee_Context_Config_IBeanDefinition { /** * String representation of the scope that this bean should live in. @@ -56,21 +58,17 @@ */ private $dependsOn = array(); - /** * Enter description here... * - * @var Bee_Beans_PropertyValue[] + * @var Bee_Beans_PropertyValue[] array of PropertyValue instances */ - private $constructorArgumentValues = array(); - + private $propertyValues = array(); /** - * Enter description here... - * - * @var Bee_Beans_PropertyValue[] array of PropertyValue instances + * @var MethodInvocation[] */ - private $propertyValues = array(); + private $methodInvocations = array(); /** * Name of the factory bean, if this bean should be obtained by using another bean instance from the container as its factory. @@ -137,6 +135,7 @@ $this->setAbstract($original->isAbstract()); $this->setConstructorArgumentValues($original->getConstructorArgumentValues()); $this->setPropertyValues($original->getPropertyValues()); + $this->setMethodInvocations($original->getMethodInvocations()); $this->setDependsOn($original->getDependsOn()); $this->setInitMethodName($original->getInitMethodName()); $this->setEnforceInitMethod($original->isEnforceInitMethod()); @@ -159,12 +158,10 @@ return $this->beanClassName; } - public function setBeanClassName($beanClassName) { $this->beanClassName = $beanClassName; } - /** * Set if this bean is "abstract", i.e. not meant to be instantiated itself but * rather just serving as parent for concrete child bean definitions. @@ -199,42 +196,7 @@ public function setDependsOn(array $dependsOn) { $this->dependsOn = $dependsOn; } - - - public function getConstructorArgumentValues() { - return $this->constructorArgumentValues; - } - - - public function setConstructorArgumentValues(array $args) { - $this->constructorArgumentValues = $args; - } - - public function addConstructorArgumentValues(array $args) { - foreach($args as $arg) { - $this->addConstructorArgumentValue($arg); - } - } - - public function addConstructorArgumentValue(Bee_Beans_PropertyValue $arg) { - $idx = $arg->getName(); - if(!is_int($idx) || $idx < 0) { - trigger_error("Constructor argument index is not an integer or lower than 0 : $idx", E_USER_ERROR); - } else { - if(array_key_exists($idx, $this->constructorArgumentValues)) { - $this->mergePropertyValuesIfPossible($this->constructorArgumentValues[$idx], $arg); - } - $this->constructorArgumentValues[$idx] = $arg; - } - } - - private function mergePropertyValuesIfPossible (Bee_Beans_PropertyValue $parent, Bee_Beans_PropertyValue $child) { - $childValue = $child->getValue(); - if($childValue instanceof Bee_Context_Config_IMergeable && $childValue->getMergeEnabled() && $parent->getValue() instanceof Traversable) { - $childValue->merge($parent->getValue()); - } - } - + public function getPropertyValues() { return $this->propertyValues; } @@ -255,14 +217,44 @@ trigger_error("Property must have a name set", E_USER_ERROR); } else { if(array_key_exists($name, $this->propertyValues)) { - $this->mergePropertyValuesIfPossible($this->propertyValues[$name], $prop); + Bee_Context_Support_BeanUtils::mergePropertyValuesIfPossible($this->propertyValues[$name], $prop); } $this->propertyValues[$name] = $prop; } return $this; } - + /** + * @return MethodInvocation[] + */ + public function getMethodInvocations() { + return $this->methodInvocations; + } + + /** + * @param MethodInvocation[] $methodInvocations + */ + public function setMethodInvocations(array $methodInvocations) { + $this->methodInvocations = $methodInvocations; + } + + /** + * @param MethodInvocation[] $methodInvocations + */ + public function addMethodInvocations(array $methodInvocations) { + foreach($methodInvocations as $invocation) { + $this->addMethodInvocation($invocation); + } + } + + /** + * @param MethodInvocation $methodInvocation + * @return void + */ + public function addMethodInvocation(MethodInvocation $methodInvocation) { + array_push($this->methodInvocations, $methodInvocation); + } + public function getFactoryBeanName() { return $this->factoryBeanName; } @@ -389,6 +381,7 @@ $this->setAbstract($other->isAbstract()); $this->addConstructorArgumentValues($other->getConstructorArgumentValues()); $this->addPropertyValues($other->getPropertyValues()); + $this->addMethodInvocations($other->getMethodInvocations()); $this->addDependsOn($other->getDependsOn()); if(!is_null($other->getInitMethodName())) { @@ -404,6 +397,4 @@ $this->setSynthetic($other->isSynthetic()); } -} - -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Context/Config/BeanDefinition/Generic.php =================================================================== --- trunk/framework/Bee/Context/Config/BeanDefinition/Generic.php 2013-08-19 12:58:55 UTC (rev 52) +++ trunk/framework/Bee/Context/Config/BeanDefinition/Generic.php 2013-08-19 22:16:31 UTC (rev 53) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\Beans\MethodInvocation; /** * Enter description here... @@ -74,5 +75,3 @@ echo '<hr/>'; } } - -?> \ No newline at end of file Modified: trunk/framework/Bee/Context/Config/IBeanDefinition.php =================================================================== --- trunk/framework/Bee/Context/Config/IBeanDefinition.php 2013-08-19 12:58:55 UTC (rev 52) +++ trunk/framework/Bee/Context/Config/IBeanDefinition.php 2013-08-19 22:16:31 UTC (rev 53) @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +use Bee\Beans\MethodInvocation; /** * Enter description here... @@ -21,7 +22,7 @@ * @author Benjamin Hartmann * @author Michael Plomer <mic...@it...> */ -interface Bee_Context_Config_IBeanDefinition { +interface Bee_Context_Config_IBeanDefinition extends Bee\Context\Config\IMethodArguments { const SCOPE_CACHE = 'cache'; const SCOPE_SESSION = 'session'; @@ -35,7 +36,6 @@ */ public function getParentName(); - /** * Set the name of the parent definition of this bean definition, if any. * @@ -55,8 +55,6 @@ */ public function getBeanClassName(); - - /** * Override the bean class name of this bean definition. * <p>The class name can be modified during bean factory post-processing, @@ -67,8 +65,6 @@ */ public function setBeanClassName($beanClassName); - - /** * Return the factory bean name, if any. * @@ -76,8 +72,6 @@ */ public function getFactoryBeanName(); - - /** * Specify the factory bean to use, if any. * @@ -86,8 +80,6 @@ */ public function setFactoryBeanName($factoryBeanName); - - /** * Return a factory method, if any. * @@ -95,8 +87,6 @@ */ public function getFactoryMethodName(); - - /** * Specify a factory method, if any. This method will be invoked with * constructor arguments, or with no arguments if none are specified. @@ -110,8 +100,6 @@ */ public function setFactoryMethodName($factoryMethodName); - - /** * Override the target scope of this bean, specifying a new scope name. * @see #SCOPE_SINGLETON @@ -120,9 +108,7 @@ * @return String */ public function getScope(); - - - + /** * Enter description here... * @@ -130,28 +116,8 @@ * @return void */ public function setScope($scope); - - - - /** - * Return the constructor argument values for this bean. - * <p>The returned instance can be modified during bean factory post-processing. - * - * @return Bee_Beans_PropertyValue[] - */ - public function getConstructorArgumentValues(); - /** - * Enter description here... - * - * @param Bee_Beans_PropertyValue $arg - * @return void - */ - public function addConstructorArgumentValue(Bee_Beans_PropertyValue $arg); - - - /** * Return the property values to be applied to a new instance of the bean. * <p>The returned instance can be modified during bean factory post-processing. * @@ -159,7 +125,6 @@ */ public function getPropertyValues(); - /** * Add a PropertyValue object, replacing any existing one * for the corresponding property. @@ -169,17 +134,25 @@ * PropertyValues in a single statement */ public function addPropertyValue(Bee_Beans_PropertyValue $prop); - - + /** + * @return MethodInvocation[] + */ + public function getMethodInvocations(); + + /** + * @param MethodInvocation $methodInvocation + * @return void + */ + public function addMethodInvocation(MethodInvocation $methodInvocation); + + /** * Return whether this bean is "abstract", that is, not meant to be instantiated. * * @return boolean */ public function isAbstract(); - - /** * Enter description here... * @@ -187,8 +160,6 @@ */ public function getDependsOn(); - - /** * Enter description here... * @@ -196,8 +167,6 @@ */ public function setDependsOn(array $dependsOn); - - /** * Enter description here... * @@ -206,8 +175,6 @@ */ public function setInitMethodName($initMethodName); - - /** * Enter description here... * @@ -274,6 +241,4 @@ * @return boolean */ public function isSynthetic(); -} - -?> \ No newline at end of file +} \ No newline at end of file Added: trunk/framework/Bee/Context/Config/IMethodArguments.php =================================================================== --- trunk/framework/Bee/Context/Config/IMethodArguments.php (rev 0) +++ trunk/framework/Bee/Context/Config/IMethodArguments.php 2013-08-19 22:16:31 UTC (rev 53) @@ -0,0 +1,44 @@ +<?php +namespace Bee\Context\Config; +/* + * Copyright 2008-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +use Bee_Beans_PropertyValue; + +/** + * User: mp + * Date: 19.08.13 + * Time: 23:31 + */ + +interface IMethodArguments { + + /** + * Return the constructor argument values for this bean. + * <p>The returned instance can be modified during bean factory post-processing. + * + * @return Bee_Beans_PropertyValue[] + */ + public function getConstructorArgumentValues(); + + + /** + * Enter description here... + * + * @param Bee_Beans_PropertyValue $arg + * @return void + */ + public function addConstructorArgumentValue(Bee_Beans_PropertyValue $arg); +} Added: trunk/framework/Bee/Context/Config/MethodArgumentsHolder.php =================================================================== --- trunk/framework/Bee/Context/Config/MethodArgumentsHolder.php (rev 0) +++ trunk/framework/Bee/Context/Config/MethodArgumentsHolder.php 2013-08-19 22:16:31 UTC (rev 53) @@ -0,0 +1,73 @@ +<?php +namespace Bee\Context\Config; +/* + * Copyright 2008-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +use Bee_Beans_PropertyValue; +use Bee_Context_Support_BeanUtils; + +/** + * User: mp + * Date: 19.08.13 + * Time: 23:35 + */ + +class MethodArgumentsHolder implements IMethodArguments { + + /** + * Enter description here... + * + * @var Bee_Beans_PropertyValue[] + */ + private $constructorArgumentValues = array(); + + /** + * Return the constructor argument values for this bean. + * <p>The returned instance can be modified during bean factory post-processing. + * + * @return Bee_Beans_PropertyValue[] + */ + public function getConstructorArgumentValues() { + return $this->constructorArgumentValues; + } + + /** + * Enter description here... + * + * @param Bee_Beans_PropertyValue $arg + * @return void + */ + public function addConstructorArgumentValue(Bee_Beans_PropertyValue $arg) { + $idx = $arg->getName(); + if(!is_int($idx) || $idx < 0) { + trigger_error("Constructor argument index is not an integer or lower than 0 : $idx", E_USER_ERROR); + } else { + if(array_key_exists($idx, $this->constructorArgumentValues)) { + Bee_Context_Support_BeanUtils::mergePropertyValuesIfPossible($this->constructorArgumentValues[$idx], $arg); + } + $this->constructorArgumentValues[$idx] = $arg; + } + } + + public function setConstructorArgumentValues(array $args) { + $this->constructorArgumentValues = $args; + } + + public function addConstructorArgumentValues(array $args) { + foreach($args as $arg) { + $this->addConstructorArgumentValue($arg); + } + } +} Modified: trunk/framework/Bee/Context/Support/BeanUtils.php =================================================================== --- trunk/framework/Bee/Context/Support/BeanUtils.php 2013-08-19 12:58:55 UTC (rev 52) +++ trunk/framework/Bee/Context/Support/BeanUtils.php 2013-08-19 22:16:31 UTC (rev 53) @@ -24,4 +24,11 @@ } return $class->newInstanceArgs($args); } + + public static function mergePropertyValuesIfPossible (Bee_Beans_PropertyValue $parent, Bee_Beans_PropertyValue $child) { + $childValue = $child->getValue(); + if($childValue instanceof Bee_Context_Config_IMergeable && $childValue->getMergeEnabled() && $parent->getValue() instanceof Traversable) { + $childValue->merge($parent->getValue()); + } + } } Modified: trunk/framework/Bee/Context/Xml/ParserDelegate.php =================================================================== --- trunk/framework/Bee/Context/Xml/ParserDelegate.php 2013-08-19 12:58:55 UTC (rev 52) +++ trunk/framework/Bee/Context/Xml/ParserDelegate.php 2013-08-19 22:16:31 UTC (rev 53) @@ -59,6 +59,8 @@ const PROPERTY_ELEMENT = 'property'; + const METHOD_INVOCATION_ELEMENT = 'method-invocation'; + const REF_ELEMENT = 'ref'; const IDREF_ELEMENT = 'idref'; @@ -278,6 +280,7 @@ $this->parseConstructorArgElements($ele, $bd); $this->parsePropertyElements($ele, $bd); + $this->parseMethodInvocationElements($ele, $bd); // bd.setResource(this.readerContext.getResource()); // bd.setSource(extractSource(ele)); @@ -302,14 +305,14 @@ * Parse constructor-arg sub-elements of the given bean element. * * @param DOMElement $beanEle - * @param Bee_Context_Config_IBeanDefinition $bd + * @param Bee\Context\Config\IMethodArguments $argsHolder * @return void */ - public function parseConstructorArgElements(DOMElement $beanEle, Bee_Context_Config_IBeanDefinition $bd) { + public function parseConstructorArgElements(DOMElement $beanEle, Bee\Context\Config\IMethodArguments $argsHolder) { $nl = $beanEle->childNodes; foreach($nl as $node) { if ($node instanceof DOMElement && Bee_Utils_Dom::nodeNameEquals($node, self::CONSTRUCTOR_ARG_ELEMENT)) { - $this->parseConstructorArgElement($node, $bd); + $this->parseConstructorArgElement($node, $argsHolder); } } } @@ -331,24 +334,40 @@ } } - /** + * Parse method-invocation sub-elements of the given bean element. + * + * @param DOMElement $beanEle + * @param Bee_Context_Config_IBeanDefinition $bd + * @return void + */ + public function parseMethodInvocationElements(DOMElement $beanEle, Bee_Context_Config_IBeanDefinition $bd) { + $nl = $beanEle->childNodes; + foreach($nl as $node) { + if ($node instanceof DOMElement && Bee_Utils_Dom::nodeNameEquals($node, self::METHOD_INVOCATION_ELEMENT)) { + $this->parseMethodInvocationElement($node, $bd); + } + } + } + + + /** * Parse a constructor-arg element. */ - public function parseConstructorArgElement(DOMElement $ele, Bee_Context_Config_IBeanDefinition $bd) { + public function parseConstructorArgElement(DOMElement $ele, Bee\Context\Config\IMethodArguments $argsHolder) { $indexAttr = $ele->getAttribute(self::INDEX_ATTRIBUTE); if (Bee_Utils_Strings::hasLength($indexAttr) && is_numeric($indexAttr) && ($index = intval($indexAttr)) >= 0) { - $existingArgs = $bd->getConstructorArgumentValues(); + $existingArgs = $argsHolder->getConstructorArgumentValues(); if(isset($existingArgs[$index])) { $this->readerContext->error("Multiple occurrences of value $index for attribute 'index' of tag 'constructor-arg'", $ele); } else { try { array_push($this->parseState, "Constructor_Arg_Idx_$index"); - $value = $this->parsePropertyValue($ele, $bd, null); + $value = $this->parsePropertyValue($ele, $argsHolder, null); $valueHolder = new Bee_Beans_PropertyValue($index, $value); - $bd->addConstructorArgumentValue($valueHolder); + $argsHolder->addConstructorArgumentValue($valueHolder); array_pop($this->parseState); } catch (Exception $ex) { array_pop($this->parseState); @@ -364,7 +383,7 @@ * Parse a property element. */ public function parsePropertyElement(DOMElement $ele, Bee_Context_Config_IBeanDefinition $bd) { - + $propertyName = $ele->getAttribute(self::NAME_ATTRIBUTE); if (!Bee_Utils_Strings::hasText($propertyName)) { $this->readerContext->error("Tag 'property' must have a 'name' attribute", $ele); @@ -388,8 +407,31 @@ } } - /** + * Parse a property element. + */ + public function parseMethodInvocationElement(DOMElement $ele, Bee_Context_Config_IBeanDefinition $bd) { + + $methodName = $ele->getAttribute(self::NAME_ATTRIBUTE); + if (!Bee_Utils_Strings::hasText($methodName)) { + $this->readerContext->error("Tag 'method-invocation' must have a 'name' attribute", $ele); + return; + } + array_push($this->parseState, $methodName); + try { + $methodInvocation = new \Bee\Beans\MethodInvocation($methodName); + $this->parseConstructorArgElements($ele, $methodInvocation); + $bd->addMethodInvocation($methodInvocation); + + array_pop($this->parseState); + } catch (Exception $ex) { + array_pop($this->parseState); + throw $ex; + } + } + + + /** * Get the value of a property element. May be a list etc. * Also used for constructor arguments, "propertyName" being null in this case. */ Modified: trunk/framework/bee-beans-1.2.xsd =================================================================== --- trunk/framework/bee-beans-1.2.xsd 2013-08-19 12:58:55 UTC (rev 52) +++ trunk/framework/bee-beans-1.2.xsd 2013-08-19 22:16:31 UTC (rev 53) @@ -138,6 +138,7 @@ <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="constructor-arg"/> <xsd:element ref="property"/> + <xsd:element ref="method-invocation"/> <xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:sequence> @@ -418,6 +419,21 @@ </xsd:annotation> </xsd:element> + <xsd:element name="method-invocation"> + <xsd:annotation> + <xsd:documentation><![CDATA[ + Bean definitions can have zero or more properties. + Property elements correspond to JavaBean setter methods exposed + by the bean classes. Spring supports primitives, references to other + beans in the same or related factories, lists, maps and properties. + ]]></xsd:documentation> + </xsd:annotation> + <xsd:complexType> + <xsd:choice minOccurs="0" maxOccurs="unbounded"> + </xsd:choice> + </xsd:complexType> + </xsd:element> + <xsd:element name="ref"> <xsd:annotation> <xsd:documentation><![CDATA[ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-19 12:58:59
|
Revision: 52 http://sourceforge.net/p/beeframework/code/52 Author: m_plomer Date: 2013-08-19 12:58:55 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - committing MVC namespace handler Modified Paths: -------------- trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php Modified: trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php =================================================================== --- trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php 2013-08-19 12:52:03 UTC (rev 51) +++ trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php 2013-08-19 12:58:55 UTC (rev 52) @@ -42,7 +42,7 @@ $resolverDefinition = Bee_Context_Support_BeanDefinitionReaderUtils::createBeanDefinition(null, 'Bee_MVC_ViewResolver_Basic'); $resolverDefinition->addPropertyValue(new Bee_Beans_PropertyValue('context', new Bee_Context_Config_RuntimeBeanReference(array(self::DEFAULT_VIEW_CONTEXT_BEAN_NAME)))); - $resolverDefHolder = new Bee_Context_Config_BeanDefinitionHolder($contextDefinition, Bee_MVC_Dispatcher::VIEW_RESOLVER_BEAN_NAME); + $resolverDefHolder = new Bee_Context_Config_BeanDefinitionHolder($resolverDefinition, Bee_MVC_Dispatcher::VIEW_RESOLVER_BEAN_NAME); Bee_Context_Support_BeanDefinitionReaderUtils::registerBeanDefinition($resolverDefHolder, $parserContext->getRegistry()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-08-19 12:52:08
|
Revision: 51 http://sourceforge.net/p/beeframework/code/51 Author: m_plomer Date: 2013-08-19 12:52:03 +0000 (Mon, 19 Aug 2013) Log Message: ----------- - committing MVC namespace handler Modified Paths: -------------- trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php Added Paths: ----------- trunk/framework/Bee/MVC/XmlNamespace/ trunk/framework/Bee/MVC/XmlNamespace/Handler.php trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php trunk/framework/bee-mvc-1.0.xsd Modified: trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php =================================================================== --- trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php 2013-08-17 14:55:22 UTC (rev 50) +++ trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php 2013-08-19 12:52:03 UTC (rev 51) @@ -27,7 +27,8 @@ 'http://www.beeframework.org/schema/security' => 'Bee_Security_Namespace_Handler', 'http://www.beeframework.org/schema/tx' => null, 'http://www.beeframework.org/schema/util' => 'Bee_Context_Util_Namespace_Handler', - 'http://www.beeframework.org/schema/batch' => 'Bee\Tools\Batch\XmlNamespace\Handler' + 'http://www.beeframework.org/schema/batch' => 'Bee\Tools\Batch\XmlNamespace\Handler', + 'http://www.beeframework.org/schema/mvc' => 'Bee\MVC\XmlNamespace\Handler' ); public function resolve($namespaceUri) { Added: trunk/framework/Bee/MVC/XmlNamespace/Handler.php =================================================================== --- trunk/framework/Bee/MVC/XmlNamespace/Handler.php (rev 0) +++ trunk/framework/Bee/MVC/XmlNamespace/Handler.php 2013-08-19 12:52:03 UTC (rev 51) @@ -0,0 +1,13 @@ +<?php +namespace Bee\MVC\XmlNamespace; + +/** + * Class Handler + * @package Bee\MVC\XmlNamespace + */ +class Handler extends \Bee_Context_Xml_Namespace_HandlerSupport { + + function init() { + $this->registerBeanDefinitionParser('viewresolver', new ViewResolverBeanDefinitionCreator()); + } +} Added: trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php =================================================================== --- trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php (rev 0) +++ trunk/framework/Bee/MVC/XmlNamespace/ViewResolverBeanDefinitionCreator.php 2013-08-19 12:52:03 UTC (rev 51) @@ -0,0 +1,48 @@ +<?php +namespace Bee\MVC\XmlNamespace; + +use Bee_Beans_PropertyValue; +use Bee_Context_Config_BeanDefinitionHolder; +use Bee_Context_Config_IBeanDefinition; +use Bee_Context_Config_RuntimeBeanReference; +use Bee_Context_Support_BeanDefinitionReaderUtils; +use Bee_Context_Xml_ParserContext; +use Bee_MVC_Dispatcher; +use DOMElement; + +/** + * Class ViewResolverBeanDefinitionCreator + * @package Bee\MVC\XmlNamespace + */ +class ViewResolverBeanDefinitionCreator implements \Bee_Context_Xml_Namespace_IBeanDefinitionParser { + + const DEFAULT_VIEW_CONTEXT_BEAN_NAME = '__viewContext'; + + const CONTEXT_LOCATION_PROPERTY_NAME = 'contextLocation'; + + /** + * Enter description here... + * + * @param DOMElement $element + * @param Bee_Context_Xml_ParserContext $parserContext + * @return Bee_Context_Config_IBeanDefinition + */ + function parse(DOMElement $element, Bee_Context_Xml_ParserContext $parserContext) { + $contextDefinition = Bee_Context_Support_BeanDefinitionReaderUtils::createBeanDefinition(null, 'Bee_Context_Xml'); + + $contextLoc = $element->hasAttribute(self::CONTEXT_LOCATION_PROPERTY_NAME) ? $element->getAttribute(self::CONTEXT_LOCATION_PROPERTY_NAME) : false; + if(!$contextLoc) { + $contextLoc = 'conf/views.xml'; + } + $contextDefinition->addConstructorArgumentValue(new Bee_Beans_PropertyValue(0, $contextLoc)); + + $contextDefHolder = new Bee_Context_Config_BeanDefinitionHolder($contextDefinition, self::DEFAULT_VIEW_CONTEXT_BEAN_NAME); + $parserContext->getDelegate()->decorateBeanDefinitionIfRequired($element, $contextDefHolder); + Bee_Context_Support_BeanDefinitionReaderUtils::registerBeanDefinition($contextDefHolder, $parserContext->getRegistry()); + + $resolverDefinition = Bee_Context_Support_BeanDefinitionReaderUtils::createBeanDefinition(null, 'Bee_MVC_ViewResolver_Basic'); + $resolverDefinition->addPropertyValue(new Bee_Beans_PropertyValue('context', new Bee_Context_Config_RuntimeBeanReference(array(self::DEFAULT_VIEW_CONTEXT_BEAN_NAME)))); + $resolverDefHolder = new Bee_Context_Config_BeanDefinitionHolder($contextDefinition, Bee_MVC_Dispatcher::VIEW_RESOLVER_BEAN_NAME); + Bee_Context_Support_BeanDefinitionReaderUtils::registerBeanDefinition($resolverDefHolder, $parserContext->getRegistry()); + } +} Added: trunk/framework/bee-mvc-1.0.xsd =================================================================== --- trunk/framework/bee-mvc-1.0.xsd (rev 0) +++ trunk/framework/bee-mvc-1.0.xsd 2013-08-19 12:52:03 UTC (rev 51) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> + +<xsd:schema xmlns="http://www.beeframework.org/schema/mvc" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:beans="http://www.beeframework.org/schema/beans" + targetNamespace="http://www.beeframework.org/schema/mvc" + elementFormDefault="qualified" + attributeFormDefault="unqualified"> + + <xsd:import namespace="http://www.beeframework.org/schema/beans" + schemaLocation="http://www.beeframework.org/schema/beans/bee-beans-1.2.xsd"/> + + <xsd:annotation> + <xsd:documentation> + <![CDATA[Defines standard configuration elements for the MVC framework.]]></xsd:documentation> + </xsd:annotation> + + <xsd:element name="viewresolver"> + <xsd:annotation> + <xsd:documentation><![CDATA[ + Configures a view resolver based on an XML context. + ]]></xsd:documentation> + </xsd:annotation> + <xsd:complexType> + <xsd:complexContent> + <xsd:extension base="beans:identifiedType"> + <xsd:attribute name="contextLocation" type="xsd:string"/> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> + </xsd:element> + +</xsd:schema> \ 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-17 14:55:27
|
Revision: 50 http://sourceforge.net/p/beeframework/code/50 Author: m_plomer Date: 2013-08-17 14:55:22 +0000 (Sat, 17 Aug 2013) Log Message: ----------- - updated Bee_Utils_Strings (added $strict parameter to some methods) Modified Paths: -------------- trunk/framework/Bee/Utils/Strings.php Modified: trunk/framework/Bee/Utils/Strings.php =================================================================== --- trunk/framework/Bee/Utils/Strings.php 2013-07-30 20:03:50 UTC (rev 49) +++ trunk/framework/Bee/Utils/Strings.php 2013-08-17 14:55:22 UTC (rev 50) @@ -22,26 +22,36 @@ * @author Michael Plomer <mic...@it...> */ class Bee_Utils_Strings { - + /** * Enter description here... * * @param String $text + * @param bool $strict * @return boolean */ - public static function hasLength($text) { + public static function hasLength($text, $strict=false) { if(is_null($text)) { return false; } - self::checkIsString($text); + if ($strict) { + self::checkIsString($text); + } return (mb_strlen($text) > 0); } - public static function hasText($text) { + /** + * @param $text + * @param bool $strict + * @return bool + */ + public static function hasText($text, $strict=false) { if(is_null($text)) { return false; } - self::checkIsString($text); + if ($strict) { + self::checkIsString($text); + } return self::hasLength(trim(strval($text))); } @@ -118,17 +128,25 @@ } } return $result; - } - - public static function startsWith($string, $prefix) { + } + + /** + * @param $string + * @param $prefix + * @param bool $strict + * @return bool + */ + public static function startsWith($string, $prefix, $strict=false) { if(is_null($string)) { return is_null($prefix); } if(is_null($prefix)) { return false; } - self::checkIsString($string); - self::checkIsString($prefix); + if ($strict) { + self::checkIsString($string); + self::checkIsString($prefix); + } $prefTest = substr($string, 0, strlen($prefix)); return $prefTest === false ? "" === $prefix : $prefTest === $prefix; } @@ -152,18 +170,25 @@ } return $str; } - - public static function endsWith($string, $suffix) { + + /** + * @param $string + * @param $suffix + * @param bool $strict + * @return bool + */ + public static function endsWith($string, $suffix, $strict=false) { if(is_null($string)) { return is_null($suffix); } if(is_null($suffix)) { return false; } - self::checkIsString($string); - self::checkIsString($suffix); + if ($strict) { + self::checkIsString($string); + self::checkIsString($suffix); + } $sufTest = substr($string, (-strlen($suffix))); return $sufTest === $string || $sufTest === false ? "" === $suffix : $sufTest === $suffix; } } -?> \ 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-07-30 20:03:53
|
Revision: 49 http://sourceforge.net/p/beeframework/code/49 Author: m_plomer Date: 2013-07-30 20:03:50 +0000 (Tue, 30 Jul 2013) Log Message: ----------- - added reference for batch namespace to HardcodedNamespaceHandlerResolver Modified Paths: -------------- trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php trunk/framework/Bee/Context/Xml/Namespace/HandlerSupport.php Modified: trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php =================================================================== --- trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php 2013-07-30 15:33:04 UTC (rev 48) +++ trunk/framework/Bee/Context/Xml/HardcodedNamespaceHandlerResolver.php 2013-07-30 20:03:50 UTC (rev 49) @@ -26,7 +26,8 @@ 'http://www.beeframework.org/schema/aop' => 'Bee_AOP_Namespace_Handler', 'http://www.beeframework.org/schema/security' => 'Bee_Security_Namespace_Handler', 'http://www.beeframework.org/schema/tx' => null, - 'http://www.beeframework.org/schema/util' => 'Bee_Context_Util_Namespace_Handler' + 'http://www.beeframework.org/schema/util' => 'Bee_Context_Util_Namespace_Handler', + 'http://www.beeframework.org/schema/batch' => 'Bee\Tools\Batch\XmlNamespace\Handler' ); public function resolve($namespaceUri) { @@ -45,5 +46,4 @@ } throw new Exception("Could not resolve namespace handler for namespace $namespaceUri."); } -} -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Context/Xml/Namespace/HandlerSupport.php =================================================================== --- trunk/framework/Bee/Context/Xml/Namespace/HandlerSupport.php 2013-07-30 15:33:04 UTC (rev 48) +++ trunk/framework/Bee/Context/Xml/Namespace/HandlerSupport.php 2013-07-30 20:03:50 UTC (rev 49) @@ -58,7 +58,7 @@ private function findParserForElement(DOMElement $element, Bee_Context_Xml_ParserContext $parserContext) { $parser = $this->parsers[$element->localName]; if (is_null($parser)) { - $parserContext->getReaderContext()->error('Cannot locate BeanDefinitionParser for element [' + $element->localName + ']', $element); + $parserContext->getReaderContext()->error('Cannot locate BeanDefinitionParser for element [' . $element->localName . ']', $element); } return $parser; } @@ -117,5 +117,4 @@ $this->attributeDecorators[$attributeName] = $decorator; } -} -?> \ 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-07-30 15:33:08
|
Revision: 48 http://sourceforge.net/p/beeframework/code/48 Author: m_plomer Date: 2013-07-30 15:33:04 +0000 (Tue, 30 Jul 2013) Log Message: ----------- - new exception subclass ProcExecException Modified Paths: -------------- trunk/framework/Bee/Exceptions/ProcExecException.php Modified: trunk/framework/Bee/Exceptions/ProcExecException.php =================================================================== --- trunk/framework/Bee/Exceptions/ProcExecException.php 2013-07-30 15:27:31 UTC (rev 47) +++ trunk/framework/Bee/Exceptions/ProcExecException.php 2013-07-30 15:33:04 UTC (rev 48) @@ -32,7 +32,7 @@ private $stdErr; - function __construct($message, $returnValue, $stdOut, $stdErr) { + function __construct($message, $returnValue = false, $stdOut = false, $stdErr = false) { parent::__construct($message); $this->returnValue = $returnValue; $this->stdOut = $stdOut; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m_p...@us...> - 2013-07-30 15:27:35
|
Revision: 47 http://sourceforge.net/p/beeframework/code/47 Author: m_plomer Date: 2013-07-30 15:27:31 +0000 (Tue, 30 Jul 2013) Log Message: ----------- - new exception subclass ProcExecException Modified Paths: -------------- trunk/framework/Bee/Exceptions/ProcExecException.php Modified: trunk/framework/Bee/Exceptions/ProcExecException.php =================================================================== --- trunk/framework/Bee/Exceptions/ProcExecException.php 2013-07-30 15:26:33 UTC (rev 46) +++ trunk/framework/Bee/Exceptions/ProcExecException.php 2013-07-30 15:27:31 UTC (rev 47) @@ -1,5 +1,5 @@ <?php -namespace Bee\Tools; +namespace Bee\Exceptions; /* * Copyright 2008-2010 the original author or authors. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |