Permalink
Browse files

Improve the research of operators list

  • Loading branch information...
1 parent a7f65d4 commit 339832935764f6287dc2c883b35f2fac2fcbe5b6 @tzi tzi committed Oct 10, 2011
Showing with 47 additions and 6 deletions.
  1. +47 −6 autoloads/owsimpleoperator.php
View
53 autoloads/owsimpleoperator.php
@@ -239,7 +239,7 @@ public function modify( $tpl, $operator_name, $operator_parameters, $root_namesp
}
else
{
- $this->output_error('modify', 'the method "'.$operator_name.'" doesn\'t exists.');
+ $this->output_error('modify', 'The method "'.$operator_name.'" doesn\'t exists.');
$operator_value = null;
}
}
@@ -266,14 +266,55 @@ public function operatorList()
$operator_list = array();
// We will search the template operator in the eztemplateautoload.php
- $eZTemplate = eZTemplate::instance();
- foreach( $eZTemplate->Operators as $operator_definition )
+ $class_name = get_class( $this );
+ $folder_path = OWEzpAutoloader::get_class_folder_path( $class_name );
+ if ( !empty( $folder_path ) )
{
- if ( is_array($operator_definition) && $operator_definition['class'] == get_class( $this ) )
+ $autoload_file = $folder_path . '/eztemplateautoload.php';
@lolautruche
lolautruche added a line comment Oct 12, 2011

The problem now is that you assume ezteamplateautoload.php is in the same folder as the PHP class... Could be a convention though and added to the extension doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if ( file_exists( $autoload_file ) )
{
- $operator_list = $operator_definition['operator_names'];
- break;
+ include( $autoload_file );
+ if ( isset( $eZTemplateOperatorArray ) )
+ {
+ if ( is_array( $eZTemplateOperatorArray ) )
+ {
+ $found = false;
+ foreach ( $eZTemplateOperatorArray as $operator_definition )
+ {
+ if ( is_array($operator_definition) && $operator_definition['class'] == $class_name )
+ {
+ $operator_list = $operator_definition['operator_names'];
+ $found = true;
+ break;
+ }
+ }
+ if (!$found)
+ {
+ $this->output_error('operatorList', 'The variable "eZTemplateOperatorArray" does not contains the operator_names for the class "'.$class_name.'".');
+ }
+ }
+ else
+ {
+ $this->output_error('operatorList', 'The variable "eZTemplateOperatorArray" must be an array in the "'.$autoload_file.'" file.');
+ }
+ }
+ else
+ {
+ $this->output_error('operatorList', 'There are no "eZTemplateOperatorArray" variable in the "'.$autoload_file.'" file.');
+ }
}
+ else
+ {
+ $this->output_error('operatorList', 'The file "'.$autoload_file.'" does not exist.');
+ }
+ }
+ else
+ {
+ $this->output_error('operatorList', 'The class "'.$class_name.'" is not registered in the autoload array.');
+ }
+ if (empty($operator_list))
+ {
+ $this->output_error('operatorList', 'There are no operators registered for the class "'.$class_name.'".');
}
$this->operator_list = $operator_list;
}

1 comment on commit 3398329

@tzi

Hi !
In the README file, we already wrote that the class & the ezptemplateautoload have to be in the autoloads folder of the extension.
That's why we changed the implementation.
Thanks for the note.
Thomas

Please sign in to comment.