Skip to content

Commit

Permalink
design_class resolver fix
Browse files Browse the repository at this point in the history
convert dashes to underscores when checking if design class exists
  • Loading branch information
ackspony authored Jan 9, 2020
1 parent 102f17f commit c63e2e6
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions src/flat/core/controller/tmpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* PHP version >=7.2
*
* Copyright (c) 2012-2019 Doug Bird - <retran@gmail.com>. All Rights Reserved.
* Copyright (c) 2012-2020 Doug Bird - <retran@gmail.com>. All Rights Reserved.
* This software is distributed under the terms of the MIT license or the GNU General Public License v3.0.
*/
namespace flat\core\controller;
Expand Down Expand Up @@ -321,14 +321,12 @@ public static function display($design, $data = null, $check_only = false)
*/
if (substr($design, 0, 1) !== '\\') {

// $r = new \ReflectionClass(get_called_class());
// if ($r->isSubclassOf(design_base::class)) {
if (is_a(get_called_class(), design_base::class, true)) {

$design_base = trim(static::get_design_base(), '\\');
if (substr($design, 0, strlen($design_base)) !== $design_base) {
$design = $design_base . '\\' . $design;
}
//$design = static::get_design_base() . '\\' . $design;
}
}

Expand All @@ -342,18 +340,10 @@ public static function display($design, $data = null, $check_only = false)
}
}


$design_class = "$design_class_prefix\\$design_class_suffix";

// if (!$check_only) {
// var_dump($design);
// var_dump($orig_design);
// var_dump($design_class);
// echo \flat\core\encode\text::serialize(debug_backtrace());
// die(__LINE__.':'.__FILE__);
// }
$design_class = str_replace('-','_',"$design_class_prefix\\$design_class_suffix");

if (class_exists($design_class) && is_a($design_class, resolvable_design::class, true)) {

if ($check_only) return;
static::design_log('resolvable_design class', $design_class);

Expand Down Expand Up @@ -394,16 +384,6 @@ public static function display($design, $data = null, $check_only = false)
$file_base .= str_replace('\\', DIRECTORY_SEPARATOR, $design);

$file_base = rtrim($file_base, DIRECTORY_SEPARATOR);

// if (!$check_only) {
// echo "orig:";
// var_dump($orig_design);
// var_dump($design);
// var_dump($file_base);

// die(__LINE__.':'.__FILE__);
// }

$file = $file_base . '.php';
}

Expand All @@ -430,7 +410,7 @@ public static function display($design, $data = null, $check_only = false)
$tried = array(
$file
);
//$display = self::get_display_handler();

foreach (array(
'html',
'htm'
Expand Down

0 comments on commit c63e2e6

Please sign in to comment.