From e52506b0dd139c11cc9f9d9426b43d419c455372 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Apr 2013 17:01:52 +1200 Subject: [PATCH] CRM-12305 - Remove eval functions to tidy up code base --- CRM/Contact/Form/Location.php | 3 ++- CRM/Contribute/Form/Contribution.php | 3 ++- CRM/Core/BAO/Block.php | 5 +++-- CRM/Core/BAO/Location.php | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/Form/Location.php b/CRM/Contact/Form/Location.php index 03ea2dfb23..1ff967e4ae 100644 --- a/CRM/Contact/Form/Location.php +++ b/CRM/Contact/Form/Location.php @@ -107,7 +107,8 @@ class CRM_Contact_Form_Location { } $form->set($blockName . '_Block_Count', $instance); - eval('CRM_Contact_Form_Edit_' . $blockName . '::buildQuickForm( $form );'); + $formName = 'CRM_Contact_Form_Edit_' . $blockName; + $formName::buildQuickForm( $form ); } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index ebee68fff2..614ce01408 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -595,7 +595,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP CRM_Core_Payment_Form::buildDirectDebit($this, TRUE); } else { - eval('CRM_Contribute_Form_AdditionalInfo::build' . $type . '( $this );'); + $additionalInfoFormFunction = 'build' . $type ; + CRM_Contribute_Form_AdditionalInfo::$additionalInfoFormFunction( $this ); } } if (empty($this->_recurPaymentProcessors)) { diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index 92ff98a561..1c86b2c8da 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -64,7 +64,8 @@ class CRM_Core_BAO_Block { if (empty($params)) { return NULL; } - eval('$block = new CRM_Core_BAO_' . $blockName . '( );'); + $BAOString = 'CRM_Core_BAO_' . $blockName; + $block = new $BAOString( ); $blocks = array(); if (!isset($params['entity_table'])) { @@ -83,7 +84,7 @@ class CRM_Core_BAO_Block { $count = 1; foreach ($blockIds as $blockId) { - eval('$block = new CRM_Core_BAO_' . $blockName . '( );'); + $block = new $BAOString( ); $block->id = $blockId['id']; $getBlocks = self::retrieveBlock($block, $blockName); $blocks[$count++] = array_pop($getBlocks); diff --git a/CRM/Core/BAO/Location.php b/CRM/Core/BAO/Location.php index b008ad1a5a..31a4bbad8c 100644 --- a/CRM/Core/BAO/Location.php +++ b/CRM/Core/BAO/Location.php @@ -250,7 +250,7 @@ WHERE e.id = %1"; 'im' => 'IM', 'openid' => 'OpenID', ); - + $blocks = array(); //get all the blocks for this contact foreach (self::$blocks as $block) { if (array_key_exists($block, $name_map)) { @@ -259,7 +259,8 @@ WHERE e.id = %1"; else { $name = ucfirst($block); } - eval('$blocks[$block] = CRM_Core_BAO_' . $name . '::getValues( $entityBlock, $microformat );'); + $baoString = 'CRM_Core_BAO_' . $name ; + $blocks[$block] = $baoString::getValues( $entityBlock, $microformat ); } return $blocks; } -- 2.25.1