Skip to content
Permalink
Browse files

Merge pull request #344 from crevillo/avoid-fileexists-include-calls-…

…for-registering-datatypes-workflows

Avoid fileexists include calls for registering datatypes workflows
  • Loading branch information...
andrerom committed Jun 12, 2013
2 parents fa5caa8 + a6bfaa6 commit 1e27fa165cb20e26ae63ac3ccf621f0eee277356
Showing with 184 additions and 129 deletions.
  1. +31 −0 doc/bc/5.2/changes-5.2.txt
  2. +0 −2 kernel/classes/datatypes/ezauthor/ezauthortype.php
  3. +0 −2 kernel/classes/datatypes/ezbinaryfile/ezbinaryfiletype.php
  4. +0 −2 kernel/classes/datatypes/ezboolean/ezbooleantype.php
  5. +0 −2 kernel/classes/datatypes/ezcountry/ezcountrytype.php
  6. +0 −2 kernel/classes/datatypes/ezdate/ezdatetype.php
  7. +0 −2 kernel/classes/datatypes/ezdatetime/ezdatetimetype.php
  8. +0 −2 kernel/classes/datatypes/ezemail/ezemailtype.php
  9. +0 −1 kernel/classes/datatypes/ezenum/ezenumtype.php
  10. +0 −2 kernel/classes/datatypes/ezfloat/ezfloattype.php
  11. +0 −2 kernel/classes/datatypes/ezidentifier/ezidentifiertype.php
  12. +0 −2 kernel/classes/datatypes/ezimage/ezimagetype.php
  13. +0 −2 kernel/classes/datatypes/ezinisetting/ezinisettingtype.php
  14. +0 −2 kernel/classes/datatypes/ezinteger/ezintegertype.php
  15. +0 −2 kernel/classes/datatypes/ezisbn/ezisbntype.php
  16. +0 −2 kernel/classes/datatypes/ezkeyword/ezkeywordtype.php
  17. +0 −2 kernel/classes/datatypes/ezmatrix/ezmatrixtype.php
  18. +0 −2 kernel/classes/datatypes/ezmedia/ezmediatype.php
  19. +0 −2 kernel/classes/datatypes/ezmultioption/ezmultioptiontype.php
  20. +0 −2 kernel/classes/datatypes/ezmultioption2/ezmultioption2type.php
  21. +0 −2 kernel/classes/datatypes/ezmultiprice/ezmultipricetype.php
  22. +0 −2 kernel/classes/datatypes/ezobjectrelation/ezobjectrelationtype.php
  23. +0 −2 kernel/classes/datatypes/ezobjectrelationlist/ezobjectrelationlisttype.php
  24. +0 −2 kernel/classes/datatypes/ezoption/ezoptiontype.php
  25. +0 −2 kernel/classes/datatypes/ezpackage/ezpackagetype.php
  26. +0 −2 kernel/classes/datatypes/ezprice/ezpricetype.php
  27. +0 −2 kernel/classes/datatypes/ezproductcategory/ezproductcategorytype.php
  28. +0 −2 kernel/classes/datatypes/ezrangeoption/ezrangeoptiontype.php
  29. +0 −1 kernel/classes/datatypes/ezselection/ezselectiontype.php
  30. +0 −2 kernel/classes/datatypes/ezstring/ezstringtype.php
  31. +0 −2 kernel/classes/datatypes/ezsubtreesubscription/ezsubtreesubscriptiontype.php
  32. +0 −2 kernel/classes/datatypes/eztext/eztexttype.php
  33. +0 −2 kernel/classes/datatypes/eztime/eztimetype.php
  34. +0 −2 kernel/classes/datatypes/ezurl/ezurltype.php
  35. +0 −2 kernel/classes/datatypes/ezuser/ezusertype.php
  36. +0 −2 kernel/classes/datatypes/ezxmltext/ezxmltexttype.php
  37. +48 −4 kernel/classes/ezdatatype.php
  38. +50 −3 kernel/classes/ezworkflowtype.php
  39. +0 −2 kernel/classes/workflowtypes/event/ezapprove/ezapprovetype.php
  40. +0 −1 kernel/classes/workflowtypes/event/ezfinishuserregister/ezfinishuserregistertype.php
  41. +0 −2 kernel/classes/workflowtypes/event/ezmultiplexer/ezmultiplexertype.php
  42. +0 −1 kernel/classes/workflowtypes/event/ezpaymentgateway/ezpaymentgatewaytype.php
  43. +0 −2 kernel/classes/workflowtypes/event/ezsimpleshipping/ezsimpleshippingtype.php
  44. +0 −3 kernel/classes/workflowtypes/event/ezwaituntildate/ezwaituntildatetype.php
  45. +41 −35 settings/content.ini
  46. +14 −8 settings/workflow.ini
@@ -4,6 +4,30 @@ Changes to BC and behavior in version 5.2
INI setting changes
-------------------

- content.ini[DataTypeSettings]AvailableDatatypes

Since 5.2 AvailableDataTypes can be defined with a pair of dataype/class and so take
adventage of autoload mechanism reducing the number of file_exists and include calls.
You should update those of your extensions defining datatypes accordingly.
Ex: AvailableDatatypes[mycustom]=myCustomType

Even this is now the recommended way to do it, the 'old' way is still valid.
The main adventage is that you will gain some file_exists and include calls.
You won't need to execute the eZDataType::register method from your dataype
class either.

- workflow.ini[EventSettings]AvailableEventTypes

Since 5.2 AvailableEventTypes can be defined with a pair of eventype/class and so take
adventage of autoload mechanism reducing the number of file_exists and include calls.
You should update those of your extensions defining workflows accordingly.
Ex: AvailableEventTypes[event_custom]=customType

Even this is now the recommended way to do it, the 'old' way is still valid.
The main adventage is that you will gain some file_exists and include calls.
You won't need to execute the eZWorkflowEventType::registerEventType method
from your workflow class either.


Change of behavior
------------------
@@ -44,6 +68,13 @@ Change of behavior
Links in left menu are now by default disabled in browse mode.
This can now be changed per item using the new Enabled_<link>[<ui_context>] setting.

- #019411: Avoid file_exists and include calls for registering datatypes and workflows

Kernel datatypes and kernel workflow classes take now adventage of the autoload
mechanism. Autoload generator add these clasess to the autoload array, so there's no
need to do any of the file_exists or include calls.


Removed features
----------------

@@ -304,6 +304,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZAuthorType::DATA_TYPE_STRING, "eZAuthorType" );
?>
@@ -752,6 +752,4 @@ private function isDeletingFile( eZHTTPTool $http, eZContentObjectAttribute $con
}
}
eZDataType::register( eZBinaryFileType::DATA_TYPE_STRING, "eZBinaryFileType" );
?>
@@ -245,6 +245,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZBooleanType::DATA_TYPE_STRING, "eZBooleanType" );
?>
@@ -457,6 +457,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZCountryType::DATA_TYPE_STRING, 'ezcountrytype' );
?>
@@ -375,6 +375,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZDateType::DATA_TYPE_STRING, "eZDateType" );
?>
@@ -626,6 +626,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZDateTimeType::DATA_TYPE_STRING, "eZDateTimeType" );
?>
@@ -226,6 +226,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZEmailType::DATA_TYPE_STRING, "eZEmailType" );
?>
@@ -514,6 +514,5 @@ function diff( $old, $new, $options = false )
return null;
}
}
eZDataType::register( eZEnumType::DATA_TYPE_STRING, 'eZEnumType' );
?>
@@ -410,6 +410,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
public $FloatValidator;
}
eZDataType::register( eZFloatType::DATA_TYPE_STRING, "eZFloatType" );
?>
@@ -422,6 +422,4 @@ function unserializeContentClassAttribute( $classAttribute, $attributeNode, $att
public $IntegerValidator;
}
eZDataType::register( eZIdentifierType::DATA_TYPE_STRING, "ezidentifiertype" );
?>
@@ -632,6 +632,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZImageType::DATA_TYPE_STRING, "eZImageType" );
?>
@@ -622,6 +622,4 @@ function diff( $old, $new, $options = false )
}
}
eZDataType::register( eZIniSettingType::DATA_TYPE_STRING, 'eZIniSettingType' );
?>
@@ -503,6 +503,4 @@ function supportsBatchInitializeObjectAttribute()
public $IntegerValidator;
}
eZDataType::register( eZIntegerType::DATA_TYPE_STRING, "eZIntegerType" );
?>
@@ -430,6 +430,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZISBNType::DATA_TYPE_STRING, "eZISBNType" );
?>
@@ -286,6 +286,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZKeywordType::DATA_TYPE_STRING, 'eZKeywordType' );
?>
@@ -516,6 +516,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZMatrixType::DATA_TYPE_STRING, 'ezmatrixtype' );
?>
@@ -796,6 +796,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZMediaType::DATA_TYPE_STRING, "eZMediaType" );
?>
@@ -457,6 +457,4 @@ function unserializeContentObjectAttribute( $package, $objectAttribute, $attribu
}
}
eZDataType::register( eZMultiOptionType::DATA_TYPE_STRING, "eZMultiOptionType" );
?>
@@ -669,6 +669,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZMultiOption2Type::DATA_TYPE_STRING, "eZMultiOption2Type" );
?>
@@ -525,6 +525,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZMultiPriceType::DATA_TYPE_STRING, "eZMultiPriceType" );
?>
@@ -642,6 +642,4 @@ function supportsBatchInitializeObjectAttribute()
/// \privatesection
}
eZDataType::register( eZObjectRelationType::DATA_TYPE_STRING, "eZObjectRelationType" );
?>
@@ -1864,6 +1864,4 @@ function supportsBatchInitializeObjectAttribute()
/// \privatesection
}
eZDataType::register( eZObjectRelationListType::DATA_TYPE_STRING, "eZObjectRelationListType" );
?>
@@ -442,6 +442,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZOptionType::DATA_TYPE_STRING, "eZOptionType" );
?>
@@ -222,6 +222,4 @@ function diff( $old, $new, $options = false )
}
}
eZDataType::register( eZPackageType::DATA_TYPE_STRING, 'eZPackageType' );
?>
@@ -319,6 +319,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZPriceType::DATA_TYPE_STRING, "eZPriceType" );
?>
@@ -210,6 +210,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZProductCategoryType::DATA_TYPE_STRING, "eZProductCategoryType" );
?>
@@ -271,6 +271,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZRangeOptionType::DATA_TYPE_STRING, "eZRangeOptionType" );
?>
@@ -446,5 +446,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZSelectionType::DATA_TYPE_STRING, "eZSelectionType" );
?>
@@ -383,6 +383,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
public $MaxLenValidator;
}
eZDataType::register( eZStringType::DATA_TYPE_STRING, 'eZStringType' );
?>
@@ -138,6 +138,4 @@ function diff( $old, $new, $options = false )
}
}
eZDataType::register( eZSubtreeSubscriptionType::DATA_TYPE_STRING, "eZSubtreeSubscriptionType" );
?>
@@ -262,6 +262,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZTextType::DATA_TYPE_STRING, "eZTextType" );
?>
@@ -443,6 +443,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZTimeType::DATA_TYPE_STRING, "eZTimeType" );
?>
@@ -369,6 +369,4 @@ function supportsBatchInitializeObjectAttribute()
}
}
eZDataType::register( eZURLType::DATA_TYPE_STRING, 'eZURLType' );
?>
@@ -529,6 +529,4 @@ function unserializeContentObjectAttribute( $package, $objectAttribute, $attribu
}
}
eZDataType::register( eZUserType::DATA_TYPE_STRING, "eZUserType" );
?>
@@ -845,6 +845,4 @@ function batchInitializeObjectAttributeData( $classAttribute )
}
}
eZDataType::register( eZXMLTextType::DATA_TYPE_STRING, "eZXMLTextType" );
?>
@@ -1235,27 +1235,60 @@ function postUnserializeContentObjectAttribute( $package, $objectAttribute )
return false;
}
/**
* Returns allowed datatypes
*
* Since 5.2 datatypes can be defined with a pair of
* dataype/class
* For keeping backward compability, allowedTypes will be
* filled with 'key' or 'val', depending on is_numeric( key ) value
*
* @return array
*/
static function allowedTypes()
{
$allowedTypes =& $GLOBALS["eZDataTypeAllowedTypes"];
if ( !is_array( $allowedTypes ) )
{
$contentINI = eZINI::instance( 'content.ini' );
$dataTypes = $contentINI->variable( 'DataTypeSettings', 'AvailableDataTypes' );
$allowedTypes = array_unique( $dataTypes );
$allowedTypes = array();
foreach ( $dataTypes as $key => $val )
{
$allowedTypes[] = is_numeric( $key ) ? $val : $key;
}
}
return $allowedTypes;
}
static function loadAndRegisterAllTypes()
{
$allowedTypes = eZDataType::allowedTypes();
foreach( $allowedTypes as $type )
foreach ( $allowedTypes as $type )
{
eZDataType::loadAndRegisterType( $type );
}
}
/**
* Load and register the datatype $type
*
* Since 5.2 there is no need to do file_exists and include calls
* if datatype is defined in the following way:
* AvailableDataTypes[{$type}]={$class}
* Ex: AvailableDataTypes[custom]=customType
*
* It's still possible to define datatypes in the old way, so BC
* shouldn't be a problem for this case
* Ex: AvailableDataTypes[]=custom
* In this case, you'll need to call eZDataType::register
* from your custom class.
*
* Recommendation is moving to the new way.
*
* @param string $type
* @return bool
*/
static function loadAndRegisterType( $type )
{
$types =& $GLOBALS["eZDataTypes"];
@@ -1264,9 +1297,20 @@ static function loadAndRegisterType( $type )
return false;
}
$baseDirectory = eZExtension::baseDirectory();
$contentINI = eZINI::instance( 'content.ini' );
$availableDataTypes = $contentINI->variable( 'DataTypeSettings', 'AvailableDataTypes' );
if ( array_key_exists( $type, $availableDataTypes ) )
{
if ( class_exists( $availableDataTypes[$type] ) )
{
self::register( $type, $availableDataTypes[$type] );
return true;
}
eZDebug::writeError( "Undefined datatype class: " . $availableDataTypes[$type], __METHOD__ );
}
$baseDirectory = eZExtension::baseDirectory();
$extensionDirectories = $contentINI->variable( 'DataTypeSettings', 'ExtensionDirectories' );
$extensionDirectories = array_unique( $extensionDirectories );
$repositoryDirectories = $contentINI->variable( 'DataTypeSettings', 'RepositoryDirectories' );

0 comments on commit 1e27fa1

Please sign in to comment.
You can’t perform that action at this time.