protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
         $new = !$form->getObject()->exists();
         $site = $form->save();
         if ($new) {
             $dispatcher = $this->getContext()->getEventDispatcher();
             $formatter = new sfFormatter();
             chdir(sfConfig::get('sf_root_dir'));
             $task = new sfGenerateAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalEnableForAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalCreateSiteTask($dispatcher, $formatter);
             $task->run(array($site->slug), array('no-confirmation'));
             $site = Doctrine_Core::getTable('sfSympalSite')->findOneByTitle($site->title);
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $site)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice') . ' You can add another one below.');
             $this->redirect('@sympal_sites_new');
         } else {
             $this->redirect('@sympal_sites_edit?id=' . $site->getId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 protected function _generateApplication($application)
 {
     try {
         $task = new sfGenerateAppTask($this->dispatcher, $this->formatter);
         $task->run(array($application), array());
     } catch (Exception $e) {
     }
 }
 /**
  * Generates an application by the given name if one doesn't exist
  */
 protected function _generateApplication($application)
 {
     try {
         $task = new sfGenerateAppTask($this->dispatcher, $this->formatter);
         $task->run(array($application), array());
     } catch (Exception $e) {
         // In case the app already exists, swallow the error
     }
 }
 public function execute($arguments = array(), $options = array())
 {
     $this->logSection('psdf:generate-macro', sprintf("Generando macro '%s'...", $arguments['macro']));
     // --------------------------------
     // Creo el aplicativo correspondiente
     // --------------------------------
     $task = new sfGenerateAppTask($this->dispatcher, $this->formatter);
     $task->run(array($arguments['macro']), array());
     // --------------------------------
     // Personalizacion comun a todos los macros
     // --------------------------------
     $appDir = sfConfig::get('sf_apps_dir') . '/' . $arguments['macro'];
     $skeletonDir = dirname(__FILE__) . '/skeleton/macro';
     // Clase user propia del psdf
     $this->getFilesystem()->copy($skeletonDir . '/app/lib/myUser.class.php', $appDir . '/lib/myUser.class.php', array("override" => true));
     // Layout redefinido
     $this->getFilesystem()->copy($skeletonDir . '/app/templates/layout.php', $appDir . '/templates/layout.php', array("override" => true));
     $emTask = new psdfEnabledModuleTask($this->dispatcher, $this->formatter);
     // Modulo seguridad sfDoctrineGuardPlugin
     $emTask->run(array('sfGuardAuth', $arguments['macro']), array());
     $file = sfConfig::get('sf_apps_dir') . DIRECTORY_SEPARATOR . $arguments['macro'] . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'settings.yml';
     if (file_exists($file)) {
         $config = sfYaml::load($file);
         $config['all']['.settings']['login_module'] = 'sfGuardAuth';
         $config['all']['.settings']['login_action'] = 'signin';
         $config['all']['.settings']['secure_module'] = 'sfGuardAuth';
         $config['all']['.settings']['secure_action'] = 'secure';
         file_put_contents($file, sfYaml::dump($config, 4));
     }
     // Modulos del psdf
     $emTask->run(array('default', $arguments['macro']), array());
     $emTask->run(array('psdfComponents', $arguments['macro']), array());
     // --------------------------------
     // Personalizacion particular del macro (debería leer de alguna configuracion)
     // --------------------------------
     // Modulos administracion sfDoctrineGuardPlugin y psdfCorePlugin para el macro psdf
     if ($arguments['macro'] == 'psdf') {
         $emTask->run(array('sfGuardGroup', $arguments['macro']));
         $emTask->run(array('sfGuardUser', $arguments['macro']));
         $emTask->run(array('sfGuardPermission', $arguments['macro']));
         $emTask->run(array('psdfOrganizacion', $arguments['macro']));
         $emTask->run(array('psdfUnidadorg', $arguments['macro']));
         $emTask->run(array('psdfProyecto', $arguments['macro']));
         $emTask->run(array('psdfPaquete', $arguments['macro']));
         $emTask->run(array('psdfProceso', $arguments['macro']));
     }
     $this->logSection('psdf', sprintf('Generando macro %s... Ok!', $arguments['macro']));
 }
Пример #5
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../../bootstrap/task.php';
$t = new lime_test(2);
$dispatcher = new sfEventDispatcher();
$formatter = new sfFormatter();
$task = new sfGenerateProjectTask($dispatcher, $formatter);
$task->run(array('test'));
$task = new sfGenerateAppTask($dispatcher, $formatter);
$task->run(array('frontend'));
require_once sfConfig::get('sf_root_dir') . '/config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
// Put something in the cache
$file = sfConfig::get('sf_config_cache_dir') . DIRECTORY_SEPARATOR . 'test';
touch($file);
$t->ok(file_exists($file), 'The test file is in the cache');
$task = new sfCacheClearTask($dispatcher, $formatter);
$task->run();
$t->ok(!file_exists($file), 'The test file is removed by the cache:clear task');
$customTemplateDir = $root . '/data/sfPhpunitPlugin/unit';
if (!file_exists($customTemplateDir)) {
    mkdir($customTemplateDir, 0777, true);
}
$customTemplate = $customTemplateDir . '/file.tpl';
// cleanup
@unlink($bootstrapFile);
@unlink($baseTestClass);
@unlink($customTemplate);
@unlink($allTestsFile);
// @unlink($testClass);
// @unlink($testClass2);
// copy the test class
copy($template, $source);
// create the test application
$task = new sfGenerateAppTask($dispatcher, $formatter);
$task->run(array($application));
// --------------------------------------------
// 1. unit test generation (common tests)
// --------------------------------------------
try {
    $arguments = array($application);
    $options = array('overwrite', '--class=sfPhpunitPluginTestClass', '--class_path=lib');
    // create functional test file
    // with default base class
    $task = new sfPhpunitCreateTestTask($dispatcher, $formatter);
    $task->run($arguments, $options);
} catch (Exception $e) {
    $t->fail($e->getMessage());
}
// START: check bootstrap class