当前位置: 首页>>代码示例>>PHP>>正文


PHP sfYaml类代码示例

本文整理汇总了PHP中sfYaml的典型用法代码示例。如果您正苦于以下问题:PHP sfYaml类的具体用法?PHP sfYaml怎么用?PHP sfYaml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了sfYaml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeRender

 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 />";
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:ner0tic,项目名称:scss,代码行数:29,代码来源:components.class.php

示例2: _init

 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']);
                     }
                 }
             }
         }
     }
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:35,代码来源:PluginExecutionManager.php

示例3: addParameters

 protected function addParameters()
 {
     if (!$this->container->getParameters()) {
         return '';
     }
     return sfYaml::dump(array('parameters' => $this->prepareParameters($this->container->getParameters())), 2);
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:7,代码来源:Yaml.php

示例4: execute

 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));
 }
开发者ID:noreiller,项目名称:sfPlopPlugin,代码行数:7,代码来源:sfPlopSwitchOptionTask.class.php

示例5: configure

/**
 * 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;
}
开发者ID:dong777,项目名称:qrcode,代码行数:40,代码来源:package.php

示例6: _init_

 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;
 }
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:25,代码来源:RandomDataLoadTask.class.php

示例7: executeImportSentences

 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 . '"'));
 }
开发者ID:theolymp,项目名称:diem,代码行数:60,代码来源:actions.class.php

示例8: _init

 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;
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:34,代码来源:PluginConfigurationManager.php

示例9: execute

    /**
     * @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);
    }
开发者ID:Atyz,项目名称:sfDoctrineRestGeneratorPlugin,代码行数:37,代码来源:sfDoctrineRestGenerateModuleTask.class.php

示例10: setUp

 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);
 }
开发者ID:THM068,项目名称:orangehrm,代码行数:7,代码来源:LeaveRequestDaoTest.php

示例11: createFromYaml

 /**
  * 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;
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:36,代码来源:pmJSCookMenu.class.php

示例12: cross_app_link_to

/**
 * 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;
}
开发者ID:TheoJD,项目名称:portail,代码行数:43,代码来源:CrossLinkHelper.php

示例13: generateMenu

 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;
 }
开发者ID:nvieirafelipe,项目名称:graviola-project,代码行数:26,代码来源:Menu.class.php

示例14: executeRun

 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');
     }
 }
开发者ID:psdf,项目名称:psdfCorePlugin,代码行数:33,代码来源:actions.class.php

示例15: configure

 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})~'));
 }
开发者ID:njch,项目名称:PatBati,代码行数:7,代码来源:DocumentsForm.class.php


注:本文中的sfYaml类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。