本文整理汇总了PHP中sfYaml::load方法的典型用法代码示例。如果您正苦于以下问题:PHP sfYaml::load方法的具体用法?PHP sfYaml::load怎么用?PHP sfYaml::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfYaml
的用法示例。
在下文中一共展示了sfYaml::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* Load form data (if applicable)
*
* @param sfTestFunctionalBase $browser A browser
* @param lime_test $tester A tester object
*/
public function __construct(sfTestFunctionalBase $browser, $tester)
{
parent::__construct($browser, $tester);
if (file_exists(sfConfig::get('sf_test_dir') . '/data/forms.yml')) {
$this->setFormData(sfYaml::load(sfConfig::get('sf_test_dir') . '/data/forms.yml'));
}
}
示例2: 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;
}
示例3: _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']);
}
}
}
}
}
}
示例4: 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 . '"'));
}
示例5: 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));
}
示例6: testGetLocationsMappedToOperationalCountry_Successful
/**
* @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());
}
}
示例7: _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;
}
示例8: 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;
}
示例9: 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);
}
示例10: 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');
}
}
示例11: 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;
}
示例12: 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 />";
}
}
}
}
}
}
}
}
示例13: executeTableManager
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');
}
示例14: _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/ui_extensions.yml';
if (is_file($configuraitonPath)) {
$configuraiton = sfYaml::load($configuraitonPath);
if (!is_array($configuraiton)) {
continue;
}
foreach ($configuraiton as $module => $uiExtentionsForActions) {
if (!isset($this->uiSubComponents[$module])) {
$this->uiSubComponents[$module] = array();
}
foreach ($uiExtentionsForActions as $action => $extensions) {
if (!isset($this->uiSubComponents[$module][$action])) {
$this->uiSubComponents[$module][$action] = array();
}
foreach ($extensions as $location => $subComponents) {
if (isset($this->uiSubComponents[$module][$action][$location])) {
$this->uiSubComponents[$module][$action][$location] = array_merge($this->uiSubComponents[$module][$action][$location], $subComponents);
} else {
$this->uiSubComponents[$module][$action][$location] = $subComponents;
}
}
}
}
}
}
}
}
示例15: addYamlFile
/**
* 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);
}
}
}