private function getWidgets()
{
$this->widgets = array();
$this->widgetInstances = array();
$finder = new Finder();
$finder->name('*.php')->in(BACKEND_MODULES_PATH . '/*/Widgets');
foreach ($finder->files() as $file) {
/** @var $file \SplFileInfo */
$module = $file->getPathInfo()->getPathInfo()->getBasename();
if (BackendAuthentication::isAllowedModule($module)) {
$widgetName = $file->getBasename('.php');
$class = 'Backend\\Modules\\' . $module . '\\Widgets\\' . $widgetName;
if (class_exists($class)) {
// add to array
$this->widgetInstances[] = array('module' => $module, 'widget' => $widgetName, 'className' => $class);
// create reflection class
$reflection = new \ReflectionClass($class);
$phpDoc = trim($reflection->getDocComment());
if ($phpDoc != '') {
$offset = mb_strpos($reflection->getDocComment(), '*', 7);
$description = mb_substr($reflection->getDocComment(), 0, $offset);
$description = str_replace('*', '', $description);
$description = trim(str_replace('/', '', $description));
} else {
$description = '';
}
// check if model file exists
$pathName = $file->getPathInfo()->getPathInfo()->getRealPath();
if (is_file($pathName . '/engine/model.php')) {
// require model
require_once $pathName . '/engine/model.php';
}
// add to array
$this->widgets[] = array('module_name' => $module, 'checkbox_name' => \SpoonFilter::toCamelCase($module) . \SpoonFilter::toCamelCase($widgetName), 'label' => \SpoonFilter::toCamelCase($widgetName), 'value' => $widgetName, 'description' => $description);
}
}
}
}