mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #146 from simonwelsh/namespace-manifest
BUGFIX Namespaced classes were always having their namespace prepended t...
This commit is contained in:
commit
2c770a6f8f
@ -354,7 +354,7 @@ class SS_ClassManifest {
|
|||||||
$extends = isset($class['extends']) ? implode('', $class['extends']) : null;
|
$extends = isset($class['extends']) ? implode('', $class['extends']) : null;
|
||||||
$implements = isset($class['interfaces']) ? $class['interfaces'] : null;
|
$implements = isset($class['interfaces']) ? $class['interfaces'] : null;
|
||||||
|
|
||||||
if($extends && $extends[0] != '/\\') {
|
if($extends && $extends[0] != '\\') {
|
||||||
$extends = $namespace . $extends;
|
$extends = $namespace . $extends;
|
||||||
} elseif($extends) {
|
} elseif($extends) {
|
||||||
$extends = substr($extends, 1);
|
$extends = substr($extends, 1);
|
||||||
|
@ -48,9 +48,12 @@ class Aggregate extends ViewableData {
|
|||||||
|
|
||||||
if (!$class || $class == 'DataObject') {
|
if (!$class || $class == 'DataObject') {
|
||||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('aggregate'));
|
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('aggregate'));
|
||||||
|
} else {
|
||||||
|
$tags = ClassInfo::ancestry($class);
|
||||||
|
foreach($tags as &$tag) {
|
||||||
|
$tag = preg_replace('/[^a-zA-Z0-9_]/', '_', $tag);
|
||||||
}
|
}
|
||||||
else {
|
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
|
||||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, ClassInfo::ancestry($class));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +111,7 @@ class Aggregate extends ViewableData {
|
|||||||
|
|
||||||
if (!($result = $cache->load($cachekey))) {
|
if (!($result = $cache->load($cachekey))) {
|
||||||
$result = (string)$query->execute()->value(); if (!$result) $result = '0';
|
$result = (string)$query->execute()->value(); if (!$result) $result = '0';
|
||||||
$cache->save($result, null, array('aggregate', $this->type));
|
$cache->save($result, null, array('aggregate', preg_replace('/[^a-zA-Z0-9_]/', '_', $this->type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -44,7 +44,8 @@ class NamespacedClassManifestTest extends SapphireTest {
|
|||||||
'sapphire\test\classd' => "{$this->base}/module/classes/ClassD.php",
|
'sapphire\test\classd' => "{$this->base}/module/classes/ClassD.php",
|
||||||
'sapphire\test\classe' => "{$this->base}/module/classes/ClassE.php",
|
'sapphire\test\classe' => "{$this->base}/module/classes/ClassE.php",
|
||||||
'sapphire\test\classf' => "{$this->base}/module/classes/ClassF.php",
|
'sapphire\test\classf' => "{$this->base}/module/classes/ClassF.php",
|
||||||
'sapphire\test\classg' => "{$this->base}/module/classes/ClassG.php"
|
'sapphire\test\classg' => "{$this->base}/module/classes/ClassG.php",
|
||||||
|
'sapphire\test\classh' => "{$this->base}/module/classes/ClassH.php"
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expect, $this->manifest->getClasses());
|
$this->assertEquals($expect, $this->manifest->getClasses());
|
||||||
@ -52,13 +53,13 @@ class NamespacedClassManifestTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testGetClassNames() {
|
public function testGetClassNames() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('sapphire\test\classa', 'sapphire\test\classb', 'sapphire\test\classc', 'sapphire\test\classd', 'sapphire\test\classe', 'sapphire\test\classf', 'sapphire\test\classg'),
|
array('sapphire\test\classa', 'sapphire\test\classb', 'sapphire\test\classc', 'sapphire\test\classd', 'sapphire\test\classe', 'sapphire\test\classf', 'sapphire\test\classg', 'sapphire\test\classh'),
|
||||||
$this->manifest->getClassNames());
|
$this->manifest->getClassNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDescendants() {
|
public function testGetDescendants() {
|
||||||
$expect = array(
|
$expect = array(
|
||||||
'sapphire\test\classa' => array('sapphire\test\ClassB')
|
'sapphire\test\classa' => array('sapphire\test\ClassB', 'sapphire\test\ClassH'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expect, $this->manifest->getDescendants());
|
$this->assertEquals($expect, $this->manifest->getDescendants());
|
||||||
@ -66,8 +67,8 @@ class NamespacedClassManifestTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testGetDescendantsOf() {
|
public function testGetDescendantsOf() {
|
||||||
$expect = array(
|
$expect = array(
|
||||||
'SAPPHIRE\TEST\CLASSA' => array('sapphire\test\ClassB'),
|
'SAPPHIRE\TEST\CLASSA' => array('sapphire\test\ClassB', 'sapphire\test\ClassH'),
|
||||||
'sapphire\test\classa' => array('sapphire\test\ClassB'),
|
'sapphire\test\classa' => array('sapphire\test\ClassB', 'sapphire\test\ClassH'),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($expect as $class => $desc) {
|
foreach ($expect as $class => $desc) {
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace sapphire\test;
|
||||||
|
|
||||||
|
class ClassH extends \sapphire\test\ClassA { }
|
@ -490,6 +490,7 @@ class SSTemplateParser extends Parser {
|
|||||||
$block = ++$res['subblocks'];
|
$block = ++$res['subblocks'];
|
||||||
// Build the key for this block from the passed cache key, the block index, and the sha hash of the template itself
|
// Build the key for this block from the passed cache key, the block index, and the sha hash of the template itself
|
||||||
$key = "'" . sha1($sub['php']) . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") . ".'_$block'";
|
$key = "'" . sha1($sub['php']) . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") . ".'_$block'";
|
||||||
|
$key = preg_replace('/[^a-zA-Z0-9_]/', '_', $key);
|
||||||
// Get any condition
|
// Get any condition
|
||||||
$condition = isset($res['condition']) ? $res['condition'] : '';
|
$condition = isset($res['condition']) ? $res['condition'] : '';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user