/** * Pushes a class manifest instance onto the top of the stack. This will * also include any module configuration files at the same time. * * @param SS_ClassManifest $manifest * @param Boolean Marks the manifest as exclusive. If set to FALSE, will * look for classes in earlier manifests as well. */ public function pushManifest(SS_ClassManifest $manifest, $exclusive = true) { $this->manifests[] = array('exclusive' => $exclusive, 'instance' => $manifest); foreach ($manifest->getConfigs() as $config) { require_once $config; } }
/** * Pushes a class manifest instance onto the top of the stack. This will * also include any module configuration files at the same time. * * @param SS_ClassManifest $manifest */ public function pushManifest(SS_ClassManifest $manifest) { $this->manifests[] = $manifest; foreach ($manifest->getConfigs() as $config) { require_once $config; } }
/** * manipulates the cms fields * * @param FieldList $fields cms fields * * @return void * * @author Patrick Schneider <*****@*****.**> * @since 04.01.2013 */ public function updateCMSFields(FieldList $fields) { if (!$this->owner->isInDB()) { $manifest = new SS_ClassManifest(BASE_PATH); $descendants = $manifest->getDescendantsOf('Widget'); $descendants = array_flip($descendants); foreach (self::$hiddenWidgets as $className) { unset($descendants[$className]); } foreach ($descendants as $descendant => $index) { $descendants[$descendant] = _t($descendant . '.TITLE', $descendant); } $fields->push(new DropdownField('ClassName', _t('WidgetSetWidget.TYPE'), $descendants)); } }
public function testGetImportedNamespaceParser() { $file = file_get_contents($this->base . DIRECTORY_SEPARATOR . 'module/classes/ClassI.php'); $tokens = token_get_all($file); $parsedTokens = SS_ClassManifest::get_imported_namespace_parser()->findAll($tokens); $expectedItems = array(array('ModelAdmin'), array('Controller', ' ', 'as', ' ', 'Cont'), array('SS_HTTPRequest', ' ', 'as', ' ', 'Request', ',', 'SS_HTTPResponse', ' ', 'AS', ' ', 'Response', ',', 'PermissionProvider', ' ', 'AS', ' ', 'P'), array('silverstripe', '\\', 'test', '\\', 'ClassA'), array('\\', 'DataObject')); $this->assertEquals(count($expectedItems), count($parsedTokens)); foreach ($expectedItems as $i => $item) { $this->assertEquals($item, $parsedTokens[$i]['importString']); } }
/** * Constructs and initialises a new trait manifest, either loading the data * from the cache or re-scanning for traits. * * @param string $base The manifest base path. * @param bool $forceRegen Force the manifest to be regenerated. */ public function __construct($base, $forceRegen = false) { parent::__construct($base, false, $forceRegen, true); $cacheClass = defined('SS_MANIFESTCACHE') ? SS_MANIFESTCACHE : 'ManifestCache_File'; $this->cache = new $cacheClass('traitmanifest'); $this->cacheKey = 'traits'; if (!$forceRegen && ($data = $this->cache->load($this->cacheKey))) { $this->traits = $data['traits']; } else { $this->regenerateTrait(true); } }
function testInterfaceDefParser() { $parser = SS_ClassManifest::get_interface_parser(); $tokens = $this->getTokens(); $matches = $parser->findAll($tokens); $interfaces = array(); if ($matches) { foreach ($matches as $match) { $interfaces[$match['interfaceName']] = $match; } } $this->assertArrayHasKey('InterfaceA', $interfaces); $this->assertArrayHasKey('InterfaceB', $interfaces); $this->assertArrayHasKey('InterfaceC', $interfaces); $this->assertArrayHasKey('InterfaceD', $interfaces); }
/** * Clears the class loader manifest * @return void */ function clear_class_manifest() { $manifest = new \SS_ClassManifest(BASE_PATH); $manifest->regenerate(true); }
public function testNamespaceDefParser() { $parser = SS_ClassManifest::get_namespace_parser(); $namespacedTokens = $this->getNamespaceTokens(); $tokens = $this->getTokens(); $namespacedMatches = $parser->findAll($namespacedTokens); $matches = $parser->findAll($tokens); $this->assertEquals(array(), $matches); $this->assertEquals(array('silverstripe', '\\', 'test'), $namespacedMatches[0]['namespaceName']); }
public function testGetModules() { $expect = array("module" => "{$this->base}/module", "moduleb" => "{$this->base}/moduleb"); $this->assertEquals($expect, $this->manifest->getModules()); }