astorm/Pulsestorm — Issue #2: Developer Manual: Helper Methods Reference breaks on .svn and reflector
Author: Mondane
Created: 2012-01-19 09:43:39+00:00
State: open

Taken from http://alanstorm.com/magento_api_helper_manual#comment-415066561

I just upgraded to Developer Manual 1.1 and as it turns out, the 'Helper Methods Reference' breaks on folders which don't have a subfolder 'Helper'. See this warning:

```bash
Warning: DirectoryIterator::__construct(app/code/core/Mage/.svn/Helper) [directoryiterator.--construct]: failed to open dir: No such file or directory in /home/eva/bax-magento/bax-shop/app/code/community/Alanstormdotcom/Developermanual/Model/Source/Helper.php on line 68

#0 [internal function]: mageCoreErrorHandler(2, 'DirectoryIterat...', '/home/eva/bax-m...', 68, Array)
#1 /home/eva/bax-magento/bax-shop/app/code/community/Alanstormdotcom/Developermanual/Model/Source/Helper.php(68): DirectoryIterator->__construct('app/code/core/M...')
#2 /home/eva/bax-magento/bax-shop/app/code/community/Alanstormdotcom/Developermanual/Model/Source/Helper.php(16): Alanstormdotcom_Developermanual_Model_Source_Helper->_getDirsContainingHelperDir('app/code/core/M...')
#3 /home/eva/bax-magento/bax-shop/app/code/community/Alanstormdotcom/Developermanual/controllers/Alanstormdotcom/Developermanual/HelperController.php(27): Alanstormdotcom_Developermanual_Model_Source_Helper->getModules('app/code/core/M...')
#4 /home/eva/bax-magento/magento-core/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Alanstormdotcom_Developermanual_Alanstormdotcom_Developermanual_HelperController->modulesAction()
#5 /home/eva/bax-magento/magento-core/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('modules')
#6 /home/eva/bax-magento/magento-core/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#7 /home/eva/bax-magento/bax-shop/app/code/local/Mage/Core/Model/App.php(350): Mage_Core_Controller_Varien_Front->dispatch()
#8 /home/eva/bax-magento/magento-core/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#9 /home/eva/bax-magento/magento-core/index.php(82): Mage::run('', 'store')
#10 {main}
```

*Even worse, all .svn folders also appear in the selects.*

Update: After "fixing" the .svn problem:

```diff
Index: Model/Source/Helper.php
===================================================================
--- Model/Source/Helper.php (revision 2024)
+++ Model/Source/Helper.php (working copy)
@@ -66,7 +66,7 @@
if(! $fileinfo->isDot() && $fileinfo->isDir()) {
try {
$tmp = new DirectoryIterator($fileinfo->getPathName() . '/Helper');
- } catch(UnexpectedValueException $e) {
+ } catch(Exception $e) {
continue;
}
$dirs[] = $fileinfo->getFilename();
@@ -85,7 +85,9 @@
$options .= '
Select...
';
}
foreach($labels as $label) {
- $options .= '
' . $label . '
';
+ if (strpos($label, '.svn') === false) {
+ $options .= '
' . $label . '
';
+ }
}

return $options;
@@ -97,7 +99,9 @@

$return = '
Select...
';
foreach($options as $key => $value) {
- $return .= '
' . $value . '
';
+ if (strpos($key, '.svn') === false) {
+ $return .= '
' . $value . '
';
+ }
}

return $return;
```
NB probably a better option would be to only show dirs if the helper folder exists and not exclude dirs based on a substring.

Selecting something from the 'helper' dropdown, gives this error:

```bash
Fatal error: Call to undefined method ReflectionProperty::setAccessible() in /home/eva/bax-magento/bax-shop/app/code/community/Alanstormdotcom/Developermanual/Model/Reflector/Helper.php on line 119
```