Last active
August 29, 2015 14:18
-
-
Save fleeting/ffbf82230c721de10050 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function get_templates() { | |
$dir = new Folder(ROOT . '/MbCmsPlugin/AbcPages/View/Pages/Templates'); | |
$files = $dir->find('.*\.ctp', true); | |
$templates = array(); | |
foreach ($files as $k => $file) { | |
$file = new File($dir->pwd() . DS . $file); | |
$name = $file->name(); | |
$contents = $file->read(); | |
$file->close(); | |
$tokens = token_get_all($contents); | |
$comment = array( | |
T_COMMENT, // All comments since PHP5 | |
T_DOC_COMMENT // PHPDoc comments | |
); | |
foreach($tokens as $token) { | |
if(!in_array($token[0], $comment)) | |
continue; | |
$templates[$name] = str_replace(array('/* ', ' */'), '', $token[1]); | |
} | |
} | |
return $templates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment