FIX getRegionObj syntax error exception

This commit is contained in:
Igor 2015-04-07 16:24:13 +12:00
parent 4615ef823c
commit f7b380ad8e

View File

@ -137,16 +137,16 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
* @return MinkElement|null * @return MinkElement|null
*/ */
public function getRegionObj($region) { public function getRegionObj($region) {
// Try to find regions directly by CSS selector.
$regionObj = null; $regionObj = null;
try{ $startsWithNumber = is_numeric(substr($region, 0, 1));
// Try to find regions directly by CSS selector.
if(!$startsWithNumber){ // conditional, otherwise will throw a syntax error
$regionObj = $this->getSession()->getPage()->find( $regionObj = $this->getSession()->getPage()->find(
'css', 'css',
// Escape CSS selector // Escape CSS selector
(false !== strpos($region, "'")) ? str_replace("'", "\'", $region) : $region (false !== strpos($region, "'")) ? str_replace("'", "\'", $region) : $region
); );
}catch(Exception $e){
// ignore syntax errors... we tried our best...
} }
if($regionObj) { if($regionObj) {
return $regionObj; return $regionObj;