Ejemplo n.º 1
0
 public function executeRender()
 {
     $this->user = $this->getUser();
     $this->menu = array();
     $this->menu = sfYaml::load(sfConfig::get('sf_app_config_dir') . '/' . sfConfig::get('app_menu_file'));
     foreach ($this->menu as $navItemsLabel => $navItems) {
         echo "{$navItemsLabel}:<br />";
         foreach ($navItems as $navItemLabel => $navItem) {
             if (!is_array($navItem)) {
                 echo "+{$navItemLabel}: {$navItem}<br />";
             } else {
                 echo "+{$navItemLabel}:<br />";
                 foreach ($navItem as $childItemsLabel => $childItems) {
                     echo "++{$childItemsLabel}:<br />";
                     foreach ($childItems as $childItemLabel => $childItem) {
                         if (!is_array($childItem)) {
                             echo "+++{$childItemLabel}: {$childItem}<br />";
                         } else {
                             echo "+++{$childItemLabel}: <br />";
                             foreach ($childItem as $babyItemsLabel => $babyItems) {
                                 echo "++++{$babyItemsLabel}: {$babyItems}<br />";
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 private function _init()
 {
     $pluginsPath = sfConfig::get('sf_plugins_dir');
     $directoryIterator = new DirectoryIterator($pluginsPath);
     foreach ($directoryIterator as $fileInfo) {
         if ($fileInfo->isDir()) {
             $pluginName = $fileInfo->getFilename();
             $configuraitonPath = $pluginsPath . '/' . $pluginName . '/config/action_extensions.yml';
             if (is_file($configuraitonPath)) {
                 $configuraiton = sfYaml::load($configuraitonPath);
                 if (!is_array($configuraiton)) {
                     continue;
                 }
                 foreach ($configuraiton as $module => $extentionsForActions) {
                     if (!isset($this->preExecuteMethodStack[$module])) {
                         $this->preExecuteMethodStack[$module] = array();
                     }
                     if (!isset($this->postExecuteMethodStack[$module])) {
                         $this->postExecuteMethodStack[$module] = array();
                     }
                     foreach ($extentionsForActions as $action => $extentions) {
                         if (!isset($this->preExecuteMethodStack[$module][$action])) {
                             $this->preExecuteMethodStack[$module][$action] = array();
                         }
                         if (!isset($this->postExecuteMethodStack[$module][$action])) {
                             $this->postExecuteMethodStack[$module][$action] = array();
                         }
                         $this->preExecuteMethodStack[$module][$action] = array_merge($this->preExecuteMethodStack[$module][$action], $extentions['pre']);
                         $this->postExecuteMethodStack[$module][$action] = array_merge($this->postExecuteMethodStack[$module][$action], $extentions['post']);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 protected function addParameters()
 {
     if (!$this->container->getParameters()) {
         return '';
     }
     return sfYaml::dump(array('parameters' => $this->prepareParameters($this->container->getParameters())), 2);
 }
 protected function execute($arguments = array(), $options = array())
 {
     $file = sfConfig::get('sf_apps_dir') . '/' . $options['app'] . '/config/app.yml';
     $config = file_exists($file) ? sfYaml::load($file) : array();
     $config = $this->switchConfig($config, strtolower($options['option']), strtolower($options['status']));
     file_put_contents($file, sfYaml::dump($config, 4));
 }
Ejemplo n.º 5
0
/**
 * Get the package configuration
 *
 * @param   string $yaml    Pathname of the YAML configuration file
 * @return  array
 */
function configure($yaml)
{
    $cfg = \sfYaml::load($yaml);
    $name = $cfg['name'];
    $options = $cfg['options'];
    if (!isset($options['filelistgenerator'])) {
        $cfg['options']['filelistgenerator'] = 'file';
    }
    if (!isset($options['baseinstalldir'])) {
        $cfg['options']['baseinstalldir'] = '/';
    }
    if (!isset($options['packagedirectory'])) {
        $cfg['options']['packagedirectory'] = __DIR__;
    }
    // ignored files
    $ignore = array('package.php', 'package.xml', 'package.xml.orig', 'package.yml', 'config.w32', "{$name}.dsp", "{$name}-*.tgz");
    if (isset($options['ignore'])) {
        $ignore = array_merge($ignore, $options['ignore']);
    }
    $cfg['options']['ignore'] = glob_values($ignore);
    // directory roles
    $dir_roles = array('examples' => 'data', 'manual' => 'doc', 'tests' => 'test');
    if (isset($options['dir_roles'])) {
        $dir_roles = array_merge($dir_roles, $options['dir_roles']);
    }
    $cfg['options']['dir_roles'] = $dir_roles;
    // role exceptions
    $exceptions = array('CREDITS' => 'doc', 'EXPERIMENTAL' => 'doc', 'LICENSE' => 'doc', 'README' => 'doc');
    if (isset($options['exceptions'])) {
        $exceptions = array_merge($exceptions, $options['exceptions']);
    }
    $cfg['options']['exceptions'] = glob_keys($exceptions);
    return $cfg;
}
 protected function _init_()
 {
     $data = sfYaml::load(sfConfig::get('sf_lib_dir') . '/task/RandomData.yml');
     $this->series = SeriesTable::getChoicesForSelect();
     $this->letters = $data['letters'];
     $this->tags = $data['tags'];
     $this->items = $data['short_texts'];
     $this->terms = $data['long_texts'];
     $this->companies = $data['company_names'];
     $this->names = $data['names'];
     $this->lastnames = $data['lastnames'];
     $this->taxes = array();
     foreach ($q = Doctrine_Query::create()->from('Tax t')->execute() as $tax) {
         $this->taxes[] = $tax->getId();
     }
     $customers = array('name' => array(), 'email' => array(), 'id' => array(), 'company' => array());
     for ($i = 0; $i < mt_rand(20, 100); $i++) {
         $customers['id'][] = str_pad(mt_rand(11111, 99999) . mt_rand(11111, 99999), 10, '0', STR_PAD_LEFT) . $this->letters[array_rand($this->letters)];
         $name = $this->names[array_rand($this->names)] . " " . $this->lastnames[array_rand($this->lastnames)];
         $customers['name'][] = $name;
         $customers['email'][] = str_replace(' ', '_', strtolower($name)) . '@example.com';
         $customers['company'][] = $this->companies[array_rand($this->companies)];
     }
     $this->customers = $customers;
 }
Ejemplo n.º 7
0
 public function executeImportSentences(dmWebRequest $request)
 {
     $catalogue = $this->getObjectOrForward404($request);
     $form = new DmCatalogueImportForm();
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $file = $form->getValue('file');
         $override = $form->getValue('override');
         $dataFile = $file->getTempName();
         $table = dmDb::table('DmTransUnit');
         $existQuery = $table->createQuery('t')->select('t.id, t.source, t.target, t.created_at, t.updated_at')->where('t.dm_catalogue_id = ? AND t.source = ?');
         $catalogueId = $catalogue->get('id');
         $nbAdded = 0;
         $nbUpdated = 0;
         try {
             if (!is_array($data = sfYaml::load(file_get_contents($dataFile)))) {
                 $this->getUser()->logError($this->getI18n()->__('Could not load file: %file%', array('%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             }
         } catch (Exception $e) {
             $this->getUser()->logError($this->getI18n()->__('Unable to parse file: %file%', array('%file%' => $file->getOriginalName())));
             return $this->renderPartial('dmInterface/flash');
         }
         $addedTranslations = new Doctrine_Collection($table);
         $line = 0;
         foreach ($data as $source => $target) {
             ++$line;
             if (!is_string($source) || !is_string($target)) {
                 $this->getUser()->logError($this->getI18n()->__('Error line %line%: %file%', array('%line%' => $line, '%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             } else {
                 $existing = $existQuery->fetchOneArray(array($catalogueId, $source));
                 if (!empty($existing) && $existing['source'] === $source) {
                     if ($existing['target'] !== $target) {
                         if ($override || $existing['created_at'] === $existing['updated_at']) {
                             $table->createQuery()->update('DmTransUnit')->set('target', '?', array($target))->where('id = ?', $existing['id'])->execute();
                             ++$nbUpdated;
                         }
                     }
                 } elseif (empty($existing)) {
                     $addedTranslations->add(dmDb::create('DmTransUnit', array('dm_catalogue_id' => $catalogue->get('id'), 'source' => $source, 'target' => $target)));
                     ++$nbAdded;
                 }
             }
         }
         $addedTranslations->save();
         if ($nbAdded) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: added %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbAdded)));
         }
         if ($nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: updated %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbUpdated)));
         }
         if (!$nbAdded && !$nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: nothing to add and update', array('%catalogue%' => $catalogue->get('name'))));
         }
         return $this->renderText(url_for1($this->getRouteArrayForAction('index')));
     }
     $action = url_for1($this->getRouteArrayForAction('importSentences', $catalogue));
     return $this->renderText($form->render('.dm_form.list.little action="' . $action . '"'));
 }
 private function _init()
 {
     $pluginsPath = sfConfig::get('sf_plugins_dir');
     $directoryIterator = new DirectoryIterator($pluginsPath);
     foreach ($directoryIterator as $fileInfo) {
         if ($fileInfo->isDir()) {
             $pluginName = $fileInfo->getFilename();
             $configuraitonPath = $pluginsPath . '/' . $pluginName . '/config/external_configurations.yml';
             if (is_file($configuraitonPath)) {
                 $configuraiton = sfYaml::load($configuraitonPath);
                 if (!is_array($configuraiton)) {
                     continue;
                 }
                 foreach ($configuraiton as $component => $configuraitonForComponent) {
                     if (!isset($this->externalConfigurations[$component])) {
                         $this->externalConfigurations[$component] = array();
                     }
                     foreach ($configuraitonForComponent as $property => $value) {
                         if (!isset($this->externalConfigurations[$component][$property])) {
                             $this->externalConfigurations[$component][$property] = array();
                         }
                         if (is_array($value)) {
                             foreach ($value as $k => $v) {
                                 $this->externalConfigurations[$component][$property]["{$pluginName}_{$k}"] = $v;
                             }
                         } else {
                             $this->externalConfigurations[$component][$property][] = $value;
                         }
                     }
                 }
             }
         }
     }
 }
    /**
     * @see sfTask
     */
    protected function execute($arguments = array(), $options = array())
    {
        $r = new ReflectionClass($arguments['model']);
        if (!$r->isSubclassOf('Doctrine_Record')) {
            throw new sfCommandException(sprintf('"%s" is not a Doctrine class.', $arguments['model']));
        }
        // create a route
        $model = $arguments['model'];
        $module = $arguments['module'];
        $app = $arguments['application'];
        $routing = sfConfig::get('sf_app_config_dir') . '/routing.yml';
        $content = file_get_contents($routing);
        $routesArray = sfYaml::load($content);
        if (!isset($routesArray[$name])) {
            $databaseManager = new sfDatabaseManager($this->configuration);
            $primaryKey = Doctrine_Core::getTable($model)->getIdentifier();
            $content = sprintf(<<<EOF
%s:
  class:   sfObjectRouteCollection
  options:
    model:   %s
    actions: [ create, delete, list, show, update ]
    module:  %s
    column:  %s
    default_params:
      sf_format:  json

EOF
, $module, $model, $module, $primaryKey) . $content;
            $this->logSection('file+', $routing);
            file_put_contents($routing, $content);
        }
        return $this->generate($app, $module, $model);
    }
Ejemplo n.º 10
0
 protected function setUp()
 {
     $this->leaveRequestDao = new LeaveRequestDao();
     $fixtureFile = sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/LeaveRequestDao.yml';
     TestDataService::populate($fixtureFile);
     $this->fixture = sfYaml::load($fixtureFile);
 }
Ejemplo n.º 11
0
 /**
  * Create an instance of pmJSCookMenu from a yaml file.
  * 
  * @param string $yaml_file The yaml file path
  * @return pmJSCookMenu
  */
 public static function createFromYaml($yaml_file)
 {
     $yaml = sfYaml::load($yaml_file);
     $yaml = array_pop($yaml);
     $root = new pmJSCookMenu();
     $root_attrs = array("credentials", "description", "icon", "orientation", "target", "theme", "title", "url");
     foreach ($root_attrs as $attr) {
         if (isset($yaml[$attr])) {
             $method = "set" . ucfirst($attr);
             call_user_func(array($root, $method), $yaml[$attr]);
             unset($yaml[$attr]);
         }
     }
     if (isset($yaml["root"]) && $yaml["root"] == true) {
         $root->setRoot();
         unset($yaml["root"]);
     }
     $separator_count = 0;
     foreach ($yaml as $name => $arr_menu) {
         if ($name == "separator") {
             $item = new pmJSCookMenuSeparator();
             $root->addChild("{$name}{$separator_count}", $item);
             $separator_count++;
         } else {
             $item = self::createMenu($arr_menu);
             $root->addChild($name, $item);
         }
     }
     return $root;
 }
Ejemplo n.º 12
0
/**
 * a function that allows link_to between apps
 * @param  $app    string      the app we want to go to
 * @param  $route  string      the route in the app. Must be valid
 * @param  $args   array       the arguments required by the route. Optional
 * @author Cf. http://ivanramirez.fr/2011/08/09/faire-un-lien-dune-application-a-une-autre/
 *
 */
function cross_app_link_to($app, $route, $args = null)
{
    /* get the host to build the absolute paths
         needed because this menu lets switch between sf apps
      */
    $host = sfContext::getInstance()->getRequest()->getHost();
    /* get the current environment. Needed to switch between the apps preserving
         the environment
      */
    $env = sfConfig::get('sf_environment');
    /* get the routing file
     */
    $appRoutingFile = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'routing.yml';
    /* get the route in the routing file */
    /* first, substract the @ from the route name */
    $route = substr($route, 1, strlen($route));
    if (file_exists($appRoutingFile)) {
        $yml = sfYaml::load($appRoutingFile);
        $routeUrl = $yml[$route]['url'];
        if ($args) {
            foreach ($args as $k => $v) {
                $routeUrl = str_replace(':' . $k, $v, $routeUrl);
            }
        }
        if (strrpos($routeUrl, '*') == strlen($routeUrl) - 1) {
            $routeUrl = substr($routeUrl, 0, strlen($routeUrl) - 2);
        }
    }
    if ($env == 'dev') {
        $path = '//' . $host . '/' . $app . '_dev.php' . $routeUrl;
    } else {
        $path = '//' . $host . $routeUrl;
    }
    return $path;
}
Ejemplo n.º 13
0
 public function generateMenu()
 {
     $menu = new ioMenu();
     if ($this->getCurrentApp() == Menu::FRONTEND_APP) {
         $routings = sfYaml::load(sfConfig::get('sf_apps_dir') . '/' . Menu::FRONTEND_APP . '/config/routing.yml');
     } else {
         $routings = sfYaml::load(sfConfig::get('sf_apps_dir') . '/' . Menu::BACKEND_APP . '/config/routing.yml');
     }
     foreach ($this->getItems() as $item) {
         foreach ($routings as $key => $routing) {
             if ("@" . $key == $item->routing) {
                 if (!empty($item->section)) {
                     //Set class "active" if the item is a link to the current page
                     if ($menu->getChild($item->section, false) == null) {
                         $menu->addChild($item->section, $item->section_routing)->setLinkOptions(array('class' => 'link'));
                     }
                     $menu->getChild($item->section)->addChild($item->text, $item->routing)->setLinkOptions(array('class' => 'link large'));
                 } else {
                     //Set class "active" if the item is a link to the current page
                     $menu->addChild($item->text, $item->routing)->setLinkOptions(array('class' => 'link'));
                 }
             }
         }
     }
     return $menu;
 }
Ejemplo n.º 14
0
 public function executeRun(sfWebRequest $request)
 {
     // Cargo definicion
     $def = sfYaml::load($request->getParameter('definicion'));
     // Extraigo nombre del patron y parametros
     $patternClassName = key($def) . 'Pattern';
     $params = $def[key($def)]['Params'];
     // Instancio el patron
     $ptn = new $patternClassName();
     // Seteo parametros de entrada
     foreach ($params as $key => $value) {
         $ptn->setParameter($key, $value);
     }
     // Logica particular del patron antes de visualizar interfaz
     $ptn->execute();
     if ($ptn->hasTemplate()) {
         // Con interfaz. Paso parametros a la interfaz
         $this->include = $ptn->getTemplate();
         $this->patternName = $ptn->getName();
         // Tomo los datos del patron que van a la interfaz
         foreach ($ptn->getTplParameters() as $name => $value) {
             $this->{$name} = $value;
         }
     }
     // Seteo instancia del patron en la sesion del usuario
     // para leerlo cuando vuelva de la interfaz del patron
     // y/o finalize.
     $this->getUser()->setFlash('patron_class_test', $ptn);
     // Si el patron no tiene interfaz, finalizo redireccionando al index.
     if (!$ptn->hasTemplate()) {
         $this->redirect('psdfTestPattern/index');
     }
 }
Ejemplo n.º 15
0
 public function configure()
 {
     $yamlConf = sfYaml::load(sfConfig::get('sf_apps_dir') . '/backend/config/app.yml');
     $this->setWidget('fichier_source', new sfWidgetFormInputFileEditable(array('file_src' => $yamlConf['all']['document_upload_dir'] . $this->getObject()->getFichierSource(), 'with_delete' => false, 'edit_mode' => false)));
     $this->validatorSchema['fichier_source'] = new sfValidatorFile(array('required' => false, 'path' => $yamlConf['all']['document_upload_dir']));
     $this->validatorSchema['date_document'] = new sfValidatorDate(array('required' => false, 'date_format' => '~(?P<day>\\d{2})/(?P<month>\\d{2})/(?P<year>\\d{2})~'));
 }
Ejemplo n.º 16
0
/**
 * UI.Layout creates a 'page-layout' that has auto-sizing 'center pane'
 * surrounded by up to four collapsible and resizable 'border panes'
 * (north, south, east & west). It can also create multiple headers &
 * footers inside each pane.
 * @param string $layoutName The layout name
 * @param string $selector jQuery Selector
 * @param array() $configurations Array. See the options and events in
 *        http://layout.jquery-dev.net/documentation.html#Options
 */
function ui_layout_configure_to($layoutName, $selector, $configurations = array())
{
    $configurations = get_default_widget_configuration('app_ys_jquery_ui_layout_defaults', $configurations);
    if (isset($configurations['yml'])) {
        $ymlItems = sfYaml::load($configurations['yml']);
        $ymlIndex = isset($configurations['ymlKey']) ? $configurations['ymlKey'] : 'layout';
        $ymlConfigurations = isset($ymlItems[$ymlIndex]) ? $ymlItems[$ymlIndex] : array();
        $configurations = array_merge($ymlConfigurations, $configurations);
        unset($configurations['yml'], $configurations['ymlKey']);
    }
    $support = core_init_javasacript_tag();
    $support .= 'var ' . $layoutName . ';';
    $pattern = ui_layout_pattern($configurations);
    $utilityMethods = '';
    if (!is_array($configurations) || !sizeof($configurations) > 0) {
        $configurations = array('applyDefaultStyles' => true);
    } else {
        if (!isset($configurations['name'])) {
            $configurations['name'] = $layoutName;
        }
        $utilityMethods = ui_layout_utility_methods_pattern($layoutName, $configurations);
    }
    if (isset($configurations['cache']) && $configurations['cache'] === true) {
        echo add_jquery_support('window', 'unload', like_function("layoutState.save('{$layoutName}')"));
        $pattern = "\$.extend( {$pattern} , layoutState.load('{$layoutName}'))";
    }
    $jsVar = like_function($layoutName . ' = ' . jquery_support($selector, 'layout', $pattern, true, $utilityMethods));
    $support .= jquery_support($selector, 'ready', $jsVar);
    echo $support .= core_end_javasacript_tag();
}
 public function setup()
 {
     $this->dispatcher->connect('component.method_not_found', array('sfActionExtra', 'observeMethodNotFound'));
     sfYaml::setSpecVersion('1.1');
     // for compatibility / remove and enable only the plugins you want
     $this->enablePlugins(array('sfDoctrinePlugin', 'sfDoctrineGuardPlugin', 'sfFormExtraPlugin', 'sfGoogleAnalyticsPlugin', 'sfTaskExtraPlugin', 'csDoctrineActAsSortablePlugin', 'sfThemeGeneratorPlugin', 'sfHadoriThemePlugin'));
 }
Ejemplo n.º 18
0
 /**
  * Establece la conexion a la base de datos.
  * Abre el fichero de configuracion '$fileConfig', o en su defecto config/config.yml
  * y lee el nodo $conection donde se definen los parametros de conexion.
  * 
  * En entorno de poducción los parámetros de conexión se fuerzan a:
  *
  *      host    =   localhost
  *      user    =   $conection
  *      password=   $conection
  *      dataBase=   $conection
  *
  * Si la conexion es exitosa, getDblink() devolvera valor y si no getError() nos indica
  * el error producido.
  *
  * @param mixed $conection Nombre de la conexion
  * @param string $fileConfig Nombre del fichero de configuracion
  */
 public function __construct($conection, $fileConfig = '')
 {
     if (is_array($conection)) {
         $this->dbEngine = $conection['dbEngine'];
         $this->host = $conection['host'];
         $this->user = $conection['user'];
         $this->password = $conection['password'];
         $this->dataBase = $conection['database'];
         $this->conecta();
     } else {
         if ($fileConfig == '') {
             $fileConfig = $_SERVER['DOCUMENT_ROOT'] . $_SESSION['appPath'] . "/" . $this->file;
         }
         if (file_exists($fileConfig)) {
             $yaml = sfYaml::load($fileConfig);
             $params = $yaml['config']['conections'][$conection];
             $this->dbEngine = $params['dbEngine'];
             $this->host = $params['host'];
             /**if ($_SESSION['EntornoDesarrollo']) {
                    $this->user = $conection;
                    $this->password = $conection;
                    $this->dataBase = $conection;
                } else {*/
             $this->user = $params['user'];
             $this->password = $params['password'];
             $this->dataBase = $params['database'];
             //}
             $this->conecta();
         } else {
             $this->error[] = "EntityManager []: ERROR AL LEER EL ARCHIVO DE CONFIGURACION. " . $fileConfig . " NO EXISTE\n";
         }
     }
 }
 public function execute($request)
 {
     $head = sfYaml::load(sfConfig::get('sf_app_dir') . '/lib/list/seller_list.yml');
     $sellerlist_headers = array($head['listSeller']['header1'], $head['listSeller']['header2'], $head['listSeller']['header3'], $head['listSeller']['header4']);
     $columns = 'id,name,address,tp_hp';
     $recordsLimit = 5;
     //have to take from lists
     if (!$request->hasParameter('pageNo')) {
         $pageNo = 1;
     } else {
         $pageNo = $request->getParameter('pageNo', 1);
     }
     $pager = new SimplePager('Seller', $recordsLimit);
     $pager->setPage($pageNo);
     $pager->setNumResults($this->getSellerService()->countSellers());
     $pager->init();
     $offset = $pager->getOffset();
     $offset = empty($offset) ? 0 : $offset;
     $paramHolder = new sfParameterHolder();
     $paramHolder->set('columns', $columns);
     $paramHolder->set('offset', $offset);
     $paramHolder->set('limit', $recordsLimit);
     $sellerlist_data = $this->getSellerService()->getSellers($paramHolder);
     $listContainer = new ListContainer();
     $listContainer->setListName('SellerList');
     $listContainer->setListHeaders($sellerlist_headers);
     $listContainer->setListContent($sellerlist_data);
     $listContainer->setRowLink("seller/showSeller?id=");
     $listContainer->setPager($pager);
     $this->listcontainer = $listContainer;
 }
Ejemplo n.º 20
0
    /**
     * Adds a new yaml file to the dataset.
     * @param string $yamlFile
     */
    public function addYamlFile($yamlFile)
    {
        $data = sfYaml::load($yamlFile);

        foreach ($data as $tableName => $rows)
        {
            if (!is_array($rows)) {
                continue;
            }

            if (!array_key_exists($tableName, $this->tables))
            {
                $columns = count($rows) ? array_keys(current($rows)) : array();

                $tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);

                $this->tables[$tableName] = new PHPUnit_Extensions_Database_DataSet_DefaultTable($tableMetaData);
            }

            foreach ($rows as $row)
            {
                $this->tables[$tableName]->addRow($row);
            }
        }
    }
 public function testFeature($name)
 {
     $features = sfYaml::load(sfConfig::get('sf_test_dir') . '/data/features/' . $name . '_features.yml');
     include_once sfConfig::get('sf_test_dir') . '/data/features/steps/' . $name . '_steps.php';
     include_once sfConfig::get('sf_test_dir') . '/data/features/steps/steps.php';
     foreach ($features as $name => $feature) {
         $this->info($name);
         foreach ((array) $this['Given'] as $statement) {
             $matches = array();
             foreach ($this->givens as $given => $function) {
                 if (preg_match_all($statement, $given, $matches)) {
                     $function($this, $mathces);
                 }
             }
         }
         foreach ((array) $this['When'] as $statement) {
             $matches = array();
             foreach ($this->whens as $when => $function) {
                 if (preg_match_all($statement, $when, $matches)) {
                     $function($this, $mathces);
                 }
             }
         }
         foreach ((array) $this['Then'] as $statement) {
             $matches = array();
             foreach ($this->thens as $then => $function) {
                 if (preg_match_all($statement, $then, $matches)) {
                     $function($this, $mathces);
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
 protected function setUp()
 {
     TestDataService::truncateSpecificTables(array('Employee', 'Leave', 'LeaveRequest', 'LeaveType', 'EmployeeLeaveEntitlement', 'LeavePeriod'));
     // Save leave type
     $leaveTypeData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveType.yml');
     $leaveTypeDao = new LeaveTypeDao();
     $leaveType = new LeaveType();
     $leaveType->setLeaveTypeName($leaveTypeData['leaveType']['LT_001']['name']);
     //                $leaveType->setLeaveRules($leaveTypeData['leaveType']['LT_001']['rule']);
     $leaveTypeDao->saveLeaveType($leaveType);
     $this->leaveType = $leaveType;
     $this->leaveTypeId = $leaveType->getLeaveTypeId();
     // Save leave Period
     $leavePeriodData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leavePeriod.yml');
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao());
     $leavePeriod = new LeavePeriod();
     $leavePeriod->setStartDate($leavePeriodData['leavePeriod']['1']['startDate']);
     $leavePeriod->setEndDate($leavePeriodData['leavePeriod']['1']['endDate']);
     $leavePeriodService->saveLeavePeriod($leavePeriod);
     $this->leavePeriod = $leavePeriod;
     $this->leavePeriodId = $leavePeriod->getLeavePeriodId();
     // Save Employee
     $employeeservice = new EmployeeService();
     $this->employee = new Employee();
     $employeeservice->saveEmployee($this->employee);
     $this->empNumber = $this->employee->getEmpNumber();
     // save leave quota
     $this->leaveEntitlement = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveEntitlement.yml');
     $this->leaveEntitlementDao = new LeaveEntitlementDao();
 }
 /**
  * Execute /../stock/listItem
  * 
  * @param type $request 
  */
 public function execute($request)
 {
     $head = sfYaml::load(sfConfig::get('sf_app_dir') . '/lib/list/item_list.yml');
     $itemlist_headers = array($head['listItem']['header1'], $head['listItem']['header2'], $head['listItem']['header3'], $head['listItem']['header6']);
     $columns = 'id,name,sales_unit_price,stock_available';
     $recordsLimit = 5;
     //have to take from lists
     if (!$request->hasParameter('pageNo')) {
         $pageNo = 1;
     } else {
         $pageNo = $request->getParameter('pageNo', 1);
     }
     $pager = new SimplePager('Item', $recordsLimit);
     $pager->setPage($pageNo);
     $pager->setNumResults($this->getItemService()->countItems());
     $pager->init();
     $offset = $pager->getOffset();
     $offset = empty($offset) ? 0 : $offset;
     $paramHolder = new sfParameterHolder();
     $paramHolder->set('columns', $columns);
     $paramHolder->set('offset', $offset);
     $paramHolder->set('limit', $recordsLimit);
     $itemlist_data = $this->getItemService()->getItems($paramHolder);
     $listContainer = new ListContainer();
     $listContainer->setListName('ItemList');
     $listContainer->setListHeaders($itemlist_headers);
     $listContainer->setListContent($itemlist_data);
     $listContainer->setRowLink("stock/showItem?id=");
     $listContainer->setPager($pager);
     $this->listcontainer = $listContainer;
 }
Ejemplo n.º 24
0
 /**
  * @covers OperationalCountryDao::getLocationsMappedToOperationalCountry
  */
 public function testGetLocationsMappedToOperationalCountry_Successful()
 {
     $sampleData = sfYaml::load($this->fixture);
     $sampleData = $sampleData['Location'];
     $result = $this->dao->getLocationsMappedToOperationalCountry('LK');
     $this->assertTrue($result instanceof Doctrine_Collection);
     $this->assertEquals(2, $result->count());
     $sampleDataIndices = array(0, 1);
     foreach ($result as $i => $location) {
         $index = $sampleDataIndices[$i];
         $this->assertTrue($location instanceof Location);
         $this->assertEquals($sampleData[$index]['id'], $location->getId());
         $this->assertEquals($sampleData[$index]['name'], $location->getName());
     }
     $result = $this->dao->getLocationsMappedToOperationalCountry('US');
     $this->assertTrue($result instanceof Doctrine_Collection);
     $this->assertEquals(1, $result->count());
     $sampleDataIndices = array(2);
     foreach ($result as $i => $location) {
         $index = $sampleDataIndices[$i];
         $this->assertTrue($location instanceof Location);
         $this->assertEquals($sampleData[$index]['id'], $location->getId());
         $this->assertEquals($sampleData[$index]['name'], $location->getName());
     }
 }
Ejemplo n.º 25
0
 public function setDpendencies($package, $dir)
 {
     $file = $dir . 'dependencies.yml';
     if (!is_file($file)) {
         $package->setPhpDep('5.2.3');
         $package->setPearinstallerDep('1.4.0');
         return $package;
     }
     $list = sfYaml::load($file);
     foreach ($list as $type => $v) {
         if (empty($v)) {
             continue;
         }
         if ('php' === $type) {
             $v = array_merge(array('min' => false, 'max' => false, 'exclude' => false), $v);
             $package->setPhpDep($v['min'], $v['max'], $v['exclude']);
         }
         if ('pearinstaller' === $type) {
             $v = array_merge(array('min' => false, 'max' => false, 'recommended' => false, 'exclude' => false), $v);
             $package->setPearinstallerDep($v['min'], $v['max'], $v['recommended'], $v['exclude']);
         } elseif ('package' === $type || 'extension' === $type) {
             foreach ($v as $name => $dep) {
                 $dep = array_merge(array('min' => false, 'max' => false, 'recommended' => false, 'exclude' => false, 'conflicts' => false, 'channel' => false), $dep);
                 if ('extension' === $type) {
                     $package->addExtensionDep('required', $name, $dep['min'], $dep['max'], $dep['recommended'], $dep['exclude']);
                 } elseif ($dep['conflicts']) {
                     $package->addConflictingPackageDepWithChannel($name, $dep['channel'], false, $dep['min'], $dep['max'], $dep['exclude']);
                 } else {
                     $package->addPackageDepWithChannel('required', $name, $dep['channel'], $dep['min'], $dep['max'], $dep['recommended'], $dep['exclude']);
                 }
             }
         }
     }
     return $package;
 }
 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     // disable security on login and secure actions
     if (sfConfig::get('sf_login_module') == $this->context->getModuleName() && sfConfig::get('sf_login_action') == $this->context->getActionName() || sfConfig::get('sf_secure_module') == $this->context->getModuleName() && sfConfig::get('sf_secure_action') == $this->context->getActionName()) {
         $filterChain->execute();
         return;
     }
     // NOTE: the nice thing about the Action class is that getCredential()
     //       is vague enough to describe any level of security and can be
     //       used to retrieve such data and should never have to be altered
     if (!$this->context->getUser()->isAuthenticated()) {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('Action "%s/%s" requires authentication, forwarding to "%s/%s"', $this->context->getModuleName(), $this->context->getActionName(), sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')))));
         }
         // the user is not authenticated
         $this->forwardToLoginAction();
     }
     // the user is authenticated
     $credential = $this->getUserCredential();
     if (null !== $credential && !$this->context->getUser()->hasCredential($credential)) {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('Action "%s/%s" requires credentials "%s", forwarding to "%s/%s"', $this->context->getModuleName(), $this->context->getActionName(), sfYaml::dump($credential, 0), sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')))));
         }
         // the user doesn't have access
         $this->forwardToSecureAction();
     }
     // the user has access, continue
     $filterChain->execute();
 }
Ejemplo n.º 27
0
 /**
  * Sets the YAML specification version to use.
  *
  * @param string $version The YAML specification version
  */
 public static function setSpecVersion($version)
 {
     if (!in_array($version, array('1.1', '1.2'))) {
         throw new InvalidArgumentException(sprintf('Version %s of the YAML specifications is not supported', $version));
     }
     self::$spec = $version;
 }
 public function setup()
 {
     require_once dirname(__FILE__) . '/../lib/vendor/php-github-api/lib/phpGithubApi.php';
     $this->dispatcher->connect('component.method_not_found', array('sfActionExtra', 'observeMethodNotFound'));
     sfYaml::setSpecVersion('1.1');
     $this->enablePlugins(array('sfDoctrinePlugin', 'csAdminGeneratorPlugin', 'csDoctrineActAsAttachablePlugin', 'csDoctrineActAsSortablePlugin', 'csDoctrineMarkdownPlugin', 'csFormTransformPlugin', 'csNavigationPlugin', 'csSEOToolkitPlugin', 'csThumbnailPlugin', 'sfCommentsPlugin', 'sfDoctrineGuardPlugin', 'sfDoctrineSettingsPlugin', 'sfFormExtraPlugin', 'sfGoogleAnalyticsPlugin', 'sfGravatarPlugin', 'sfJqueryReloadedPlugin', 'sfLucenePlugin', 'sfTaskExtraPlugin'));
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     // update databases.yml
     if (!is_null($options['app'])) {
         $file = sfConfig::get('sf_apps_dir') . '/' . $options['app'] . '/config/databases.yml';
     } else {
         $file = sfConfig::get('sf_config_dir') . '/databases.yml';
     }
     $config = file_exists($file) ? sfYaml::load($file) : array();
     $config[$options['env']][$options['name']] = array('class' => $options['class'], 'param' => array_merge(isset($config[$options['env']][$options['name']]['param']) ? $config[$options['env']][$options['name']]['param'] : array(), array('dsn' => $arguments['dsn'], 'username' => $arguments['username'], 'password' => $arguments['password'])));
     file_put_contents($file, sfYaml::dump($config, 4));
     // update propel.ini
     if (is_null($options['app']) && false !== strpos($options['class'], 'Propel') && 'all' == $options['env']) {
         $propelini = sfConfig::get('sf_config_dir') . '/propel.ini';
         if (file_exists($propelini)) {
             $content = file_get_contents($propelini);
             if (preg_match('/^(.+?):/', $arguments['dsn'], $match)) {
                 $content = preg_replace('/^propel\\.database(\\s*)=(\\s*)(.+?)$/m', 'propel.database$1=${2}' . $match[1], $content);
                 $content = preg_replace('/^propel\\.database.driver(\\s*)=(\\s*)(.+?)$/m', 'propel.database.driver$1=${2}' . $match[1], $content);
                 $content = preg_replace('/^propel\\.database\\.createUrl(\\s*)=(\\s*)(.+?)$/m', 'propel.database.createUrl$1=${2}' . $arguments['dsn'], $content);
                 $content = preg_replace('/^propel\\.database\\.url(\\s*)=(\\s*)(.+?)$/m', 'propel.database.url$1=${2}' . $arguments['dsn'], $content);
                 $content = preg_replace('/^propel\\.database\\.user(\\s*)=(\\s*)(.+?)$/m', 'propel.database.user$1=${2}' . $arguments['username'], $content);
                 $content = preg_replace('/^propel\\.database\\.password(\\s*)=(\\s*)(.+?)$/m', 'propel.database.password$1=${2}' . $arguments['password'], $content);
                 file_put_contents($propelini, $content);
             }
         }
     }
 }
Ejemplo n.º 30
0
 public function executeTableManager()
 {
   $class = $this->getRequestParameter('class');
   $generator_configuration = array(
     'model_class' =>  $class,
     'theme'       => 'sfControlPanel',
     'moduleName'  => $class.'ControlPanel',
     'list' => array(
         'title' => $class.' list',
     ),
     'edit' => array(
         'title' => 'edit '.$class,
     ),
   );
   if(file_exists(SF_ROOT_DIR.'/config/sfControlPanel_generator.yml'))
   {
     $custom_configuration = sfYaml::load(SF_ROOT_DIR.'/config/sfControlPanel_generator.yml');
     if(isset($custom_configuration[$class]))
     {
       $generator_configuration = sfToolkit::arrayDeepMerge($generator_configuration, $custom_configuration[$class]);
     }
   }
   $generatorManager = new sfGeneratorManager();
   $generatorManager->initialize(); 
   $data = $generatorManager->generate('sfControlPanelGenerator', $generator_configuration);
   $this->redirect('auto'.$class.'ControlPanel/list');
 }