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


PHP sfFilesystem::replaceTokens方法代码示例

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


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

示例1: execute

 public static function execute($arguments = array(), $options = array())
 {
     $app = $arguments['application'];
     $module = $arguments['module'];
     $action = $arguments['action'];
     $process = $arguments['process'];
     $activity = $arguments['activity'];
     $scripts = $arguments['scripts'];
     // Fuerzo el cero (0) si no contiene valor
     if (!$activity['is_autocomplete']) {
         $activity['is_autocomplete'] = '0';
     }
     $actionDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module . '/actions';
     $templateDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module . '/templates';
     $actionFile = $action . 'Action.class.php';
     $templateFile = $action . 'Success.php';
     $errorFile = $action . 'Error.php';
     $filesystem = new sfFilesystem();
     if (!is_dir($actionDir)) {
         throw new sfCommandException(sprintf("No se pudo identificar el modulo symfony '%s' implementacion del paquete '%s'", $actionDir, $module));
     }
     if (is_file($actionDir . '/' . $actionFile)) {
         // Borro el archivo porque lo voy a recrear
         $filesystem->remove($actionDir . '/' . $actionFile);
         //throw new sfCommandException(sprintf('The action "%s" already exists.', $actionFile));
     }
     if (is_file($templateDir . '/' . $templateFile)) {
         // Borro el archivo porque lo voy a recrear
         $filesystem->remove($templateDir . '/' . $templateFile);
         //throw new sfCommandException(sprintf('The template "%s" already exists.', $templateFile));
     }
     // Activity Type determine skeleton
     if ($activity['type'] == 'StartEvent') {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/startAction.class.php';
     } elseif ($activity['type'] == 'EndEvent') {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/endAction.class.php';
     } elseif ($activity['type'] == 'TaskUser' or $activity['type'] == 'TaskManual') {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserAction.class.php';
         $skeletonTemplate = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserSuccess.php';
         $skeletonError = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityUserError.php';
     } else {
         $skeletonAction = dirname(__FILE__) . '/../../data/generator/skeleton/psdfActivity/activityAction.class.php';
     }
     // create basic action
     $filesystem->copy($skeletonAction, $actionDir . '/' . $actionFile);
     // customize action
     $constants = array('ACTIVITY' => $action, 'ACTIVITY_NAME' => $activity['name'], 'MODULE' => $module, 'PROCESS_ID' => $process['id'], 'PROCESS_NAME' => $process['name'], 'SET_DATAFIELDS' => $scripts['set_datafields'], 'PTN_NAME' => $scripts['ptn_name'], 'PTN_SET_PARAMS' => $scripts['ptn_set_params'], 'PTN_URL_TEMPLATE' => file_exists($scripts['ptn_url_template']) ? file_get_contents($scripts['ptn_url_template']) : '', 'RULES_NEXT' => $scripts['rules_next'], 'ACTIVITY_AUTOCOMPLETE' => $activity['is_autocomplete']);
     $finder = sfFinder::type('file')->name($actionFile);
     $filesystem->replaceTokens($finder->in($actionDir), '##', '##', $constants);
     // Personalize template Success y Error
     if ($activity['type'] == 'TaskUser' or $activity['type'] == 'TaskManual') {
         $filesystem->copy($skeletonTemplate, $templateDir . '/' . $templateFile);
         $finder = sfFinder::type('file')->name($templateFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
         $filesystem->copy($skeletonError, $templateDir . '/' . $errorFile);
         $finder = sfFinder::type('file')->name($errorFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
     }
 }
开发者ID:psdf,项目名称:psdfCorePlugin,代码行数:59,代码来源:psdfGenerateActivity.class.php

示例2: execute

 public function execute($arguments = array(), $options = array())
 {
     $projectDir = UtilPsdf::fixPath($arguments['pjpath']);
     $packagesDir = $projectDir . DIRECTORY_SEPARATOR . $arguments['pkpath'] . DIRECTORY_SEPARATOR;
     if (is_dir($projectDir)) {
         throw new sfCommandException(sprintf('The project "%s" already exists.', $projectDir));
     }
     $filesystem = new sfFilesystem();
     // Create basic workspace structure
     $skeletonDir = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProject';
     $finder = sfFinder::type('any')->discard('.sf');
     $filesystem->mirror($skeletonDir, $projectDir, $finder);
     // Actualizo tokens
     $constants = array('PROJECT_NAME' => $arguments['pjname']);
     $finder = sfFinder::type('file')->name('.project');
     $filesystem->replaceTokens($finder->in($projectDir), '##', '##', $constants);
     // Create packages files (subdir por cada macro)
     $packages = $arguments['packages'];
     foreach ($packages as $pack) {
         if (!is_dir($packagesDir . $pack['macro'])) {
             $filesystem->mkdirs($packagesDir . $pack['macro']);
         }
         $file = $packagesDir . $pack['macro'] . DIRECTORY_SEPARATOR . $pack['name'] . '.xpdl';
         $filesystem->touch($file);
         file_put_contents($file, $pack['xpdl']);
     }
 }
开发者ID:psdf,项目名称:psdfCorePlugin,代码行数:27,代码来源:psdfGenerateProject.class.php

示例3: replaceTokens

 /**
  *
  */
 protected function replaceTokens($file)
 {
     $properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
     $constants = array('PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 'PACKAGE_NAME' => !is_null($this->package) ? $this->package : 'package name');
     if (!is_readable($file)) {
         throw new sfCommandException("Failed to replace tokens as file is not accessible.");
     }
     // customize service file
     $sfFilesystem = new sfFilesystem();
     $sfFilesystem->replaceTokens($file, '##', '##', $constants);
 }
开发者ID:rande,项目名称:sfAmfPlugin,代码行数:14,代码来源:sfAmfPluginGenerator.class.php

示例4: execute

 public static function execute($arguments = array(), $options = array())
 {
     $app = $arguments['application'];
     $module = $arguments['module'];
     $process_id = $arguments['process_id'];
     $process_name = $arguments['process_name'];
     $process_display_name = $arguments['process_display_name'];
     $moduleDir = sfConfig::get('sf_apps_dir') . '/' . $app . '/modules/' . $module;
     $file_pack_xpdl = $moduleDir . '/data/package.xpdl';
     $file_proc_xpdl = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProcess/process.part.xpdl';
     $file_pool_xpdl = dirname(__FILE__) . '/../../data/generator/skeleton/psdfProcess/pool.part.xpdl';
     if (!is_file($file_pack_xpdl) || !is_file($file_proc_xpdl) || !is_file($file_pool_xpdl)) {
         throw new sfCommandException(sprintf('No se pudo identificar un paquete, parte de proceso o pool'));
     }
     $contentPack = file_get_contents($file_pack_xpdl);
     $contentProc = file_get_contents($file_proc_xpdl);
     $contentPool = file_get_contents($file_pool_xpdl);
     $pos = strpos($contentPack, '<xpdl2:WorkflowProcess Id="' . $process_id . '"');
     if ($pos > 0) {
         throw new sfCommandException(sprintf('El proceso ' . $process_name . ' ya existe en el xpdl'));
     }
     // Pool
     // Defino etiqueta Pools si es el primero
     $pos = strpos($contentPack, '<xpdl2:Pools>');
     if ($pos <= 0) {
         $contentPool = '<xpdl2:Pools>' . $contentPool . '</xpdl2:Pools>';
     }
     // Inserto despues de la etiqueta de header redefinibles del paquete
     $key = '</xpdl2:RedefinableHeader>';
     $contentPack = str_replace($key, $key . $contentPool, $contentPack);
     file_put_contents($file_pack_xpdl, $contentPack);
     // Proceso
     // Defino etiqueta WorkflowProcesses si es el primero
     $pos = strpos($contentPack, '<xpdl2:WorkflowProcesses>');
     if ($pos <= 0) {
         $contentProc = '<xpdl2:WorkflowProcesses>' . $contentProc . '</xpdl2:WorkflowProcesses>';
     }
     // Inserto antes de la etiqueta de atributos extendidos del paquete
     $key = '<xpdl2:ExtendedAttributes>';
     $contentPack = str_replace($key, $contentProc . $key, $contentPack);
     file_put_contents($file_pack_xpdl, $contentPack);
     // customize xpdl
     $constants = array('PROCESS_ID' => $process_id, 'PROCESS_DISPLAY_NAME' => $process_name, 'PROCESS_NAME' => str_replace(' ', '', $process_name), 'POOL_ID' => UtilXpdl::genRandId(), 'POOL_DISPLAY_NAME' => 'Pool', 'POOL_NAME' => 'Pool', 'LANE_ID' => UtilXpdl::genRandId(), 'LANE_DISPLAY_NAME' => 'Lane', 'LANE_NAME' => 'Lane');
     $filesystem = new sfFilesystem();
     $finder = sfFinder::type('file')->name('*.xpdl');
     $filesystem->replaceTokens($finder->in($moduleDir), '##', '##', $constants);
 }
开发者ID:psdf,项目名称:psdfCorePlugin,代码行数:47,代码来源:psdfGenerateProcess.class.php

示例5: isValid

 /**
  * Validates the response.
  *
  * @param mixed $checkDTD Either true to validate against the response DTD or
  *                        provide the path to a *.xsd, *.rng or *.rnc schema
  *
  * @return sfTestFunctionalBase|sfTester
  *
  * @throws LogicException If the response is neither XML nor (X)HTML
  */
 public function isValid($checkDTD = false)
 {
     if (preg_match('/(x|ht)ml/i', $this->response->getContentType())) {
         $revert = libxml_use_internal_errors(true);
         $dom = new DOMDocument('1.0', $this->response->getCharset());
         $content = $this->response->getContent();
         if (true === $checkDTD) {
             $cache = sfConfig::get('sf_cache_dir') . '/sf_tester_response/w3';
             if ($cache[1] == ':') {
                 // On Windows systems the path will be like c:\symfony\cache\xml.dtd
                 // I did not manage to get DOMDocument loading a file protocol url including the drive letter
                 // file://c:\symfony\cache\xml.dtd or file://c:/symfony/cache/xml.dtd
                 // The first one simply doesnt work, the second one is treated as remote call.
                 // However the following works. Unfortunatly this means we can only access the current disk
                 // file:///symfony/cache/xml.dtd
                 // Note that all work for file_get_contents so the bug is most likely in DOMDocument.
                 $local = 'file://' . substr(str_replace(DIRECTORY_SEPARATOR, '/', $cache), 2);
             } else {
                 $local = 'file://' . $cache;
             }
             if (!file_exists($cache . '/TR/xhtml11/DTD/xhtml11.dtd')) {
                 $filesystem = new sfFilesystem();
                 $finder = sfFinder::type('any')->discard('.sf');
                 $filesystem->mirror(dirname(__FILE__) . '/w3', $cache, $finder);
                 $finder = sfFinder::type('file');
                 $filesystem->replaceTokens($finder->in($cache), '##', '##', array('LOCAL_W3' => $local));
             }
             $content = preg_replace('#(<!DOCTYPE[^>]+")http://www.w3.org(.*")#i', '\\1' . $local . '\\2', $content);
             $dom->validateOnParse = $checkDTD;
         }
         $dom->loadXML($content);
         switch (pathinfo($checkDTD, PATHINFO_EXTENSION)) {
             case 'xsd':
                 $dom->schemaValidate($checkDTD);
                 $message = sprintf('response validates per XSD schema "%s"', basename($checkDTD));
                 break;
             case 'rng':
             case 'rnc':
                 $dom->relaxNGValidate($checkDTD);
                 $message = sprintf('response validates per relaxNG schema "%s"', basename($checkDTD));
                 break;
             default:
                 $message = $dom->validateOnParse ? sprintf('response validates as "%s"', $dom->doctype->name) : 'response is well-formed "xml"';
         }
         if (count($errors = libxml_get_errors())) {
             foreach ($errors as $error) {
                 $message .= sprintf("\n * (line:%d) %s", $error->line, $error->message);
             }
             $this->tester->fail($message);
         } else {
             $this->tester->pass($message);
         }
         libxml_use_internal_errors($revert);
     } else {
         throw new LogicException(sprintf('Unable to validate responses of content type "%s"', $this->response->getContentType()));
     }
     return $this->getObjectToReturn();
 }
开发者ID:ru-easyfinance,项目名称:Symfony,代码行数:68,代码来源:sfTesterResponse.class.php

示例6: sprintf

    // make a PEAR compatible version
    $version = $version_prefix . '.' . $version;
} else {
    $version = $argv[1];
}
print sprintf("Releasing symfony version \"%s\".\n", $version);
// tests
$result = $filesystem->sh('php data/bin/symfony symfony:test');
if (0 != $result) {
    throw new Exception('Some tests failed. Release process aborted!');
}
if (is_file('package.xml')) {
    $filesystem->remove(getcwd() . DIRECTORY_SEPARATOR . 'package.xml');
}
$filesystem->copy(getcwd() . '/package.xml.tmpl', getcwd() . '/package.xml');
// add class files
$finder = sfFinder::type('file')->relative();
$xml_classes = '';
$dirs = array('lib' => 'php', 'data' => 'data');
foreach ($dirs as $dir => $role) {
    $class_files = $finder->in($dir);
    foreach ($class_files as $file) {
        $xml_classes .= '<file role="' . $role . '" baseinstalldir="symfony" install-as="' . $file . '" name="' . $dir . '/' . $file . '" />' . "\n";
    }
}
// replace tokens
$filesystem->replaceTokens(getcwd() . DIRECTORY_SEPARATOR . 'package.xml', '##', '##', array('SYMFONY_VERSION' => $version, 'CURRENT_DATE' => date('Y-m-d'), 'CLASS_FILES' => $xml_classes, 'STABILITY' => $stability));
$results = $filesystem->sh('pear package');
echo $results;
$filesystem->remove(getcwd() . DIRECTORY_SEPARATOR . 'package.xml');
exit(0);
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:31,代码来源:release.php

示例7: isValid

 /**
  * Validates the response.
  *
  * @param mixed $checkDTD Either true to validate against the response DTD or
  *                        provide the path to a *.xsd, *.rng or *.rnc schema
  *
  * @return sfTestFunctionalBase|sfTester
  *
  * @throws LogicException If the response is neither XML nor (X)HTML
  */
 public function isValid($checkDTD = false)
 {
     if (preg_match('/(x|ht)ml/i', $this->response->getContentType())) {
         $revert = libxml_use_internal_errors(true);
         $dom = new DOMDocument('1.0', $this->response->getCharset());
         $content = $this->response->getContent();
         if (true === $checkDTD) {
             $cache = sfConfig::get('sf_cache_dir') . '/sf_tester_response/w3';
             $local = 'file://' . str_replace(DIRECTORY_SEPARATOR, '/', $cache);
             if (!file_exists($cache . '/TR/xhtml11/DTD/xhtml11.dtd')) {
                 $filesystem = new sfFilesystem();
                 $finder = sfFinder::type('any')->discard('.sf');
                 $filesystem->mirror(dirname(__FILE__) . '/w3', $cache, $finder);
                 $finder = sfFinder::type('file');
                 $filesystem->replaceTokens($finder->in($cache), '##', '##', array('LOCAL_W3' => $local));
             }
             $content = preg_replace('#(<!DOCTYPE[^>]+")http://www.w3.org(.*")#i', '\\1' . $local . '\\2', $content);
             $dom->validateOnParse = $checkDTD;
         }
         $dom->loadXML($content);
         switch (pathinfo($checkDTD, PATHINFO_EXTENSION)) {
             case 'xsd':
                 $dom->schemaValidate($checkDTD);
                 $message = sprintf('response validates per XSD schema "%s"', basename($checkDTD));
                 break;
             case 'rng':
             case 'rnc':
                 $dom->relaxNGValidate($checkDTD);
                 $message = sprintf('response validates per relaxNG schema "%s"', basename($checkDTD));
                 break;
             default:
                 $message = $dom->validateOnParse ? sprintf('response validates as "%s"', $dom->doctype->name) : 'response is well-formed "xml"';
         }
         if (count($errors = libxml_get_errors())) {
             $lines = explode(PHP_EOL, $this->response->getContent());
             $this->tester->fail($message);
             foreach ($errors as $error) {
                 $this->tester->diag('    ' . trim($error->message));
                 if (preg_match('/line (\\d+)/', $error->message, $match) && $error->line != $match[1]) {
                     $this->tester->diag('      ' . str_pad($match[1] . ':', 6) . trim($lines[$match[1] - 1]));
                 }
                 $this->tester->diag('      ' . str_pad($error->line . ':', 6) . trim($lines[$error->line - 1]));
             }
         } else {
             $this->tester->pass($message);
         }
         libxml_use_internal_errors($revert);
     } else {
         throw new LogicException(sprintf('Unable to validate responses of content type "%s"', $this->response->getContentType()));
     }
     return $this->getObjectToReturn();
 }
开发者ID:sundesz,项目名称:crafthouse,代码行数:62,代码来源:sfTesterResponse.class.php

示例8: execute

 public function execute($arguments = array(), $options = array())
 {
     $this->logSection('psdf:generate-activity', sprintf("Generando actividad '%s'...", $arguments['activity']));
     $this->logSection('psdf:generate-activity', sprintf("Nombre: '%s' Id: '%s' Type: '%s'", $arguments['activity'], $this->psdf_activity_data['id'], $this->psdf_activity_data['type']));
     //$this->log( 'Datos de la actividad:' );
     //$this->log( sfYaml::dump($this->psdf_activity_data) );
     // --------------------------------
     // Creo la accion y template correspondiente
     // --------------------------------
     // Nombres de actividad parseado a implementar
     $action = str_replace(' ', '_', $arguments['activity']);
     $actionDir = sfConfig::get('sf_apps_dir') . '/' . $arguments['macro'] . '/modules/' . $arguments['package'] . '/actions';
     $templateDir = sfConfig::get('sf_apps_dir') . '/' . $arguments['macro'] . '/modules/' . $arguments['package'] . '/templates';
     $actionFile = $action . 'Action.class.php';
     $templateFile = $action . 'Success.php';
     $errorFile = $action . 'Error.php';
     $filesystem = new sfFilesystem();
     if (!is_dir($actionDir)) {
         throw new sfCommandException(sprintf("No existe el directorio '%s' del modulo '%s' sobre el cual implementar la accion '%s'", $actionDir, $arguments['package'], $action));
     }
     if (is_file($actionDir . '/' . $actionFile)) {
         // Borro el archivo porque lo voy a recrear
         $filesystem->remove($actionDir . '/' . $actionFile);
         //throw new sfCommandException(sprintf('The action "%s" already exists.', $actionFile));
     }
     if (is_file($templateDir . '/' . $templateFile)) {
         // Borro el archivo porque lo voy a recrear
         $filesystem->remove($templateDir . '/' . $templateFile);
         //throw new sfCommandException(sprintf('The template "%s" already exists.', $templateFile));
     }
     // Activity Type determine skeleton
     $skeletonAction = dirname(__FILE__) . sprintf('/skeleton/activity/action/%sAction.class.php', $this->psdf_activity_data['type']);
     $skeletonTemplate = dirname(__FILE__) . sprintf('/skeleton/activity/template/%sSuccess.php', $this->psdf_activity_data['type']);
     $skeletonError = dirname(__FILE__) . sprintf('/skeleton/activity/template/%sError.php', $this->psdf_activity_data['type']);
     if (!is_file($skeletonAction)) {
         throw new sfCommandException(sprintf("No hay definido un esqueleto para crear la actividad del tipo '%s'", $this->psdf_activity_data['type']));
     }
     // --------------------------------
     // Personalizacion comun a todas las actividades
     // --------------------------------
     $scripts['set_datafields'] = $this->genScriptSetDatafield();
     $scripts['rules_next'] = $this->genScriptNextActivity();
     $scripts['pattern'] = $this->genScriptsPattern();
     // customize action
     $constants = array('ACTION' => $action, 'MODULE' => $arguments['package'], 'PROCESS_ID' => $arguments['process_id'], 'RULES_NEXT' => $scripts['rules_next'], 'SET_DATAFIELDS' => $scripts['set_datafields'], 'PTN_NAME' => $scripts['pattern']['name'], 'PTN_SET_PARAMS' => $scripts['pattern']['set_parameter'], 'PTN_SET_TEMPLATE' => $scripts['pattern']['set_template'], 'PTN_SET_DATAFIELDS' => $scripts['pattern']['set_datafield'], 'PROCESS_NAME' => $arguments['process'], 'ACTIVITY_NAME' => $arguments['activity']);
     // create basic action
     $filesystem->copy($skeletonAction, $actionDir . '/' . $actionFile);
     $finder = sfFinder::type('file')->name($actionFile);
     $filesystem->replaceTokens($finder->in($actionDir), '##', '##', $constants);
     if (is_file($skeletonTemplate)) {
         $filesystem->copy($skeletonTemplate, $templateDir . '/' . $templateFile);
         $finder = sfFinder::type('file')->name($templateFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
     }
     if (is_file($skeletonError)) {
         $filesystem->copy($skeletonError, $templateDir . '/' . $errorFile);
         $finder = sfFinder::type('file')->name($errorFile);
         $filesystem->replaceTokens($finder->in($templateDir), '##', '##', $constants);
     }
     $this->logSection('psdf:generate-activity', sprintf("Fin generacion actividad", $arguments['activity']));
 }
开发者ID:psdf,项目名称:psdfCorePlugin,代码行数:61,代码来源:psdfGenerateActivityTask.class.php


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