public function __construct($directory, $extension, $namespace = NULL)
 {
     $this->extension = $extension;
     $this->directory = $directory;
     $this->namespace = empty($namespace) ? '' : $namespace;
     if (($systemCache = $this->extension->getApp()->getCacheRepository('system')) != NULL && is_array($controllerClassFiles = $systemCache->get($this->directory . '::fileList'))) {
     } else {
         // Make sure all PHP files in the directory are included
         $controllerClassFiles = DirectoryHelper::directoryToArray($this->directory, TRUE, '.php');
         if ($systemCache != NULL) {
             $systemCache->forever($this->directory . '::fileList', $controllerClassFiles);
         }
     }
     foreach ($controllerClassFiles as $controllerClassFile) {
         include_once $controllerClassFile;
         $controllerClass = ReflectionHelper::createClassName($this->namespace, basename($controllerClassFile, '.php'));
         $this->controllerClasses[] = $controllerClass;
         $controller = new $controllerClass($this->extension);
         $rclass = new \ReflectionClass($controller);
         if ($rclass->isSubclassOf('\\MABI\\ModelController')) {
             /**
              * @var $controller \MABI\ModelController
              */
             $this->overriddenModelClasses[] = $controller->getModelClass();
         }
         $this->controllers[] = $controller;
     }
 }
Example #2
0
 /**
  * public function deleteDirectory, recursively deletes directory and all its content
  * 
  * @param string $dirPath
  * @return bool
  */
 public static function deleteDirectory($dirPath)
 {
     if (is_dir($dirPath)) {
         $files = array_diff(scandir($dirPath), array('.', '..'));
         foreach ($files as $file) {
             is_dir($dirPath . $file) ? DirectoryHelper::deleteDirectory($dirPath . "/" . $file) : unlink($dirPath . "/" . $file);
         }
         return rmdir($dirPath);
     }
     return true;
 }
 /**
  * todo: docs
  *
  * @param $directory string
  * @param $extension \MABI\Extension
  * @param $namespace string|null
  */
 public function __construct($directory, $extension, $namespace = NULL)
 {
     $this->directory = $directory;
     $this->namespace = $namespace;
     $this->extension = $extension;
     if (($systemCache = $this->extension->getApp()->getCacheRepository('system')) != NULL && is_array($modelClassFiles = $systemCache->get($this->directory . '::fileList'))) {
         $this->modelClassFiles = $modelClassFiles;
     } else {
         // Make sure all PHP files in the directory are included
         $this->modelClassFiles = DirectoryHelper::directoryToArray($this->directory, TRUE, '.php');
         if ($systemCache != NULL) {
             $systemCache->forever($this->directory . '::fileList', $this->modelClassFiles);
         }
     }
     foreach ($this->modelClassFiles as $modelClassFile) {
         include_once $modelClassFile;
     }
 }
 public function renderDeleteProduct($id)
 {
     // delete files
     \DirectoryHelper::deleteDirectory($this->getPathToImagesByProduct($id));
     // delete all from database
     $this->db->deleteProduct($id);
     $this->flashMessage('Product byl smazán.');
     $this->redirect('Page:edit', array('id' => $this->module->page_id));
 }
Example #5
0
}
if (file_exists($pathToNewModule) && is_dir($pathToNewModule)) {
    echo "ERROR: module with name '{$newModuleName}' already exists. Use different name for new module. Use '-h' for help.\n";
    exit(-1);
}
if (!file_exists($moduleToCreateFromPath) && !is_dir($moduleToCreateFromPath)) {
    echo "ERROR: module '{$moduleToCreateFromName}' doesnt exists. Please use another module as the image. Use '-h' for help.\n";
    exit(-1);
}
/*****************************************************************************
 * Code itself
 *****************************************************************************/
/**
 * Copy code of image module to new module.
 */
DirectoryHelper::recurseCopy($moduleToCreateFromPath, $pathToNewModule);
/**
 * Renaming files. Renaming classes. Renaming folder.
 */
$adminPresenters = $pathToNewModule . "AdminModule/presenters/";
$frontPresenters = $pathToNewModule . "FrontModule/presenters/";
$oldClassName = "Module" . $moduleToCreateFromName . "Presenter";
$newClassName = "Module" . $newModuleName . "Presenter";
$adminPresenter = $adminPresenters . $newClassName . ".php";
$frontPresenter = $frontPresenters . $newClassName . ".php";
$newModuleFile = $pathToNewModule . "model/Module" . $newModuleName . ".php";
if (file_exists($adminPresenters . $oldClassName . ".php")) {
    rename($adminPresenters . $oldClassName . ".php", $adminPresenter);
} else {
    echo "ERROR: file '" . $adminPresenters . $oldClassName . ".php' does not exists. Check it.\n";
}