/**
  * Create a controller in the current module named for the given service
  *
  * @param  string $serviceName
  * @return mixed
  */
 public function createController($serviceName)
 {
     $module = $this->module;
     $version = $this->moduleEntity->getLatestVersion();
     $serviceName = str_replace("\\", "/", $serviceName);
     $srcPath = $this->modules->getRpcPath($module, $version, $serviceName);
     if (!file_exists($srcPath)) {
         mkdir($srcPath, 0775, true);
     }
     $className = sprintf('%sController', $serviceName);
     $classPath = sprintf('%s/%s.php', $srcPath, $className);
     $controllerService = sprintf('%s\\V%s\\Rpc\\%s\\Controller', $module, $version, $serviceName);
     if (file_exists($classPath)) {
         throw new Exception\RuntimeException(sprintf('The controller "%s" already exists', $className));
     }
     $view = new ViewModel(array('module' => $module, 'classname' => $className, 'servicename' => $serviceName, 'version' => $version));
     $resolver = new Resolver\TemplateMapResolver(array('code-connected/rpc-controller' => __DIR__ . '/../../../view/doctrine/rpc-controller.phtml'));
     $view->setTemplate('code-connected/rpc-controller');
     $renderer = new PhpRenderer();
     $renderer->setResolver($resolver);
     if (!file_put_contents($classPath, "<" . "?php\n" . $renderer->render($view))) {
         return false;
     }
     $fullClassName = sprintf('%s\\V%s\\Rpc\\%s\\%s', $module, $version, $serviceName, $className);
     $this->configResource->patch(array('controllers' => array('invokables' => array($controllerService => $fullClassName))), true);
     return (object) array('class' => $fullClassName, 'file' => $classPath, 'service' => $controllerService);
 }
Exemplo n.º 2
0
 function testGetAllInstalledModules()
 {
     ModuleUtils::set_modules_path(FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/");
     Storage::set_storage_root(DS . FRAMEWORK_CORE_PATH . "tests/modules/test_installed_modules_storage/");
     $all_installed_modules = InstalledModules::get_all_installed_modules();
     $this->assertEqual(count($all_installed_modules), 2, "Il numero di moduli installati non corrisponde!!");
     Storage::set_storage_root(Storage::get_default_storage_root());
 }
 /**
  * Get the source path for the module
  *
  * @param  string $resourceName
  * @return string
  */
 protected function getSourcePath($resourceName)
 {
     $sourcePath = $this->modules->getRestPath($this->module, $this->moduleEntity->getLatestVersion(), $resourceName);
     if (!file_exists($sourcePath)) {
         mkdir($sourcePath, 0777, true);
     }
     return $sourcePath;
 }
Exemplo n.º 4
0
 static function extract_from_archive($filename)
 {
     $modules_archive_dir = new Dir(self::MODULES_ARCHIVE_DIR);
     $modules_archive_dir->touch();
     $module_archive = $modules_archive_dir->newFile($filename);
     $properties = FFArchive::getArchiveProperties($module_archive);
     $module_dir = new Dir(ModuleUtils::get_modules_path() . "/" . $properties["category_name"] . "/" . $properties["module_name"]);
     return FFArchive::extract($module_archive, $module_dir);
 }
Exemplo n.º 5
0
 static function set_modules_path($new_modules_path)
 {
     $dir = new Dir(DS . $new_modules_path);
     if (!$dir->exists()) {
         Log::error("ModuleUtils::set_modules_path", "Error : modules root directory must exist -> " . $new_modules_path);
     } else {
         self::$modules_path = $new_modules_path;
     }
 }
Exemplo n.º 6
0
 function testGetRequiredModules()
 {
     ModuleUtils::set_modules_path(FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/");
     $def = AvailableModules::get_available_module_definition("ecommerce", "cart");
     $required_modules = $def->get_required_modules();
     $this->assertEqual(2, count($required_modules), "Il numero di moduli richiesti non corrisponde!!");
     $k = array_keys($required_modules);
     $this->assertEqual($k[0], "ecommerce/base", "Il modulo richiesto 0 non corrisponde!!");
     $this->assertEqual($k[1], "ecommerce/forms", "Il modulo richiesto 1 non corrisponde!!");
 }
Exemplo n.º 7
0
 function testExtractFromArchive()
 {
     $result_file = new File(ModuleArchiver::MODULES_ARCHIVE_DIR . "test__category-1_2_3.ffa");
     $this->assertFalse($result_file->exists(), "Il file del modulo non e' stato creato!!");
     ModuleUtils::set_modules_path("/" . FRAMEWORK_CORE_PATH . "tests/modules/fakeroot2/modules/");
     ModuleArchiver::save_as_archive("test", "category");
     ModuleUtils::set_modules_path("/" . FRAMEWORK_CORE_PATH . "tests/modules/fakeroot2/modules_out/");
     ModuleArchiver::extract_from_archive("test__category-1_2_3.ffa");
     $extracted_module_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/modules/fakeroot2/modules_out/test/category/");
     $this->assertTrue($extracted_module_dir->exists(), "La cartella del modulo non e' stata creata!!");
     $module_file = $extracted_module_dir->newFile(AvailableModules::MODULE_DEFINITION_FILE);
     $this->assertTrue($module_file->exists(), "Il file di definizione del modulo non esiste!!");
     $parent_module_dir = $extracted_module_dir->getParentDir();
     $parent_module_dir->delete(true);
     ModuleUtils::set_modules_path("/framework/modules/");
 }
Exemplo n.º 8
0
 function execute_action()
 {
     $nome_categoria = Params::get("nome_categoria");
     $nome_modulo = Params::get("nome_modulo");
     $command = Params::get("command");
     if ($command != "install" && $command != "uninstall" && $command != null) {
         $def = AvailableModules::get_available_module_definition($nome_categoria, $nome_modulo);
         $action_data = $def->get_action_data($command);
         $plug = ModuleUtils::getModulePlug($nome_categoria, $nome_modulo);
         $plug->execute($action_data);
         Flash::ok("Azione '" . $command . "' eseguita con successo.");
         return Redirect::success();
     } else {
         return Redirect::failure();
     }
 }
Exemplo n.º 9
0
 static function uninstall($nome_categoria, $nome_modulo)
 {
     if (!InstalledModules::is_installed($nome_categoria, $nome_modulo)) {
         throw new InvalidParametersException();
     }
     $mod_def = InstalledModules::get_installed_module_definition($nome_categoria, $nome_modulo);
     $uninstall_data = $mod_def->get_action_data("uninstall");
     $module_plug = ModuleUtils::getModulePlug($nome_categoria, $nome_modulo);
     $module_plug->execute($uninstall_data);
     //deleting module data : properties
     $prop_storage = self::__get_properties_storage($nome_categoria, $nome_modulo);
     if ($prop_storage->exists()) {
         return $prop_storage->delete();
     }
     //definition file
     $xml_storage = self::__get_xml_storage($nome_categoria, $nome_modulo);
     if ($xml_storage->exists()) {
         return $xml_storage->delete();
     }
     return true;
 }
Exemplo n.º 10
0
<?php

/* This software is released under the BSD license. Full text at project root -> license.txt */
require_once "../init.php";
$modules = AvailableModules::get_all_available_modules();
echo "Validating all available modules ...<br /><br />";
foreach ($modules as $mod) {
    echo "Modulo : " . $mod["nome_categoria"] . "/" . $mod["nome_modulo"] . "<br />";
    $ok = ModuleUtils::validate_module($mod["nome_categoria"], $mod["nome_modulo"]);
    if ($ok) {
        echo "Ok.<br />";
    }
    echo "<br /><br />";
}
Exemplo n.º 11
0
 function testDropView()
 {
     ModuleUtils::set_modules_path(FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/");
     $db_desc = DB::newDatabaseDescription();
     $this->assertFalse($db_desc->hasTable("vendite_full"), "La vista vendite_full esiste gia'!!");
     DB::newDirectSql($this->create_for_view)->exec();
     DB::newDirectSql($this->create_view)->exec();
     $db_desc = DB::newDatabaseDescription();
     $this->assertTrue($db_desc->hasTable("vendite_full"), "La vista vendite_full non e' stata creata!!");
     $plug = new ModulePlug(new Dir("/" . FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/ecommerce/cart/"));
     $def = AvailableModules::get_available_module_definition("ecommerce", "cart");
     $drop_view = $def->get_action_data("drop_view");
     $plug->execute($drop_view);
     $db_desc = DB::newDatabaseDescription();
     $this->assertFalse($db_desc->hasTable("vendite_full"), "La vista vendite_full non e' stata rimossa!!");
     DB::newDirectSql($this->drop_for_view)->exec();
 }
Exemplo n.º 12
0
 private static function initializeModule($nome_categoria, $nome_modulo)
 {
     ModuleUtils::runScriptIfFound($nome_categoria, $nome_modulo, "load");
 }
Exemplo n.º 13
0
 static function install($nome_categoria, $nome_modulo)
 {
     $def = self::get_available_module_definition($nome_categoria, $nome_modulo);
     //checking for required modules ...
     $properties_storage = InstalledModules::__get_properties_storage($nome_categoria, $nome_modulo);
     $properties_storage->create();
     $properties_storage->add("global", array("nome_categoria" => $nome_categoria, "nome_modulo" => $nome_modulo));
     $version = $def->get_current_version();
     $properties_storage->add("properties", $version);
     //eventualmente altro ...
     $module_def_storage = InstalledModules::__get_xml_storage($nome_categoria, $nome_modulo);
     $module_def_storage->saveXML($def->get_data());
     $install_data = $def->get_action_data("install");
     $module_plug = ModuleUtils::getModulePlug($nome_categoria, $nome_modulo);
     $module_plug->execute($install_data);
 }
Exemplo n.º 14
0
 function testDescription()
 {
     ModuleUtils::set_modules_path(FRAMEWORK_CORE_PATH . "tests/base/fakeroot/modules/");
     $def = AvailableModules::get_available_module_definition("ecommerce", "cart");
     $this->assertEqual($def->get_description(), "Modulo ecommerce cart di test.", "La descrizione del modulo non corrisponde!!");
 }