本文整理汇总了PHP中sfToolkit类的典型用法代码示例。如果您正苦于以下问题:PHP sfToolkit类的具体用法?PHP sfToolkit怎么用?PHP sfToolkit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfToolkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$config = $this->getCliConfig();
$args = array(
'data_fixtures_path' => $config['data_fixtures_path'][0],
);
if (!is_dir($args['data_fixtures_path']))
{
$this->getFilesystem()->mkdirs($args['data_fixtures_path']);
}
if ($arguments['target'])
{
$filename = $arguments['target'];
if (!sfToolkit::isPathAbsolute($filename))
{
$filename = $args['data_fixtures_path'].'/'.$filename;
}
$this->getFilesystem()->mkdirs(dirname($filename));
$args['data_fixtures_path'] = $filename;
}
$this->logSection('doctrine', sprintf('dumping data to fixtures to "%s"', $args['data_fixtures_path']));
$this->callDoctrineCli('dump-data', $args);
}
示例2: customize
public function customize($params)
{
$params['moduleName'] = 'search';
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
$generatorManager = new sfGeneratorManager(sfProjectConfiguration::getActive());
sfGeneratorConfigHandler::getContent($generatorManager, 'xfGeneratorInterface', $params);
}
示例3: addClassBody
protected function addClassBody(&$script)
{
parent::addClassBody($script);
// remove comments and fix coding standards
$script = str_replace(array("\t", "{\n \n"), array(' ', "{\n"), sfToolkit::stripComments($script));
}
示例4: execute
protected function execute($arguments = array(), $options = array())
{
$this->standardBootstrap($arguments['application'], $options['env']);
$remove = sfLuceneToolkit::getDirtyIndexRemains();
if (count($remove) == 0) {
$this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->format('Nothing to do!', 'INFO'))));
} elseif ($arguments['confirmation'] == 'delete') {
$this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->format('Delete confirmation provided. Deleting directories now...', array('fg' => 'red', 'bold' => true)))));
foreach ($remove as $dir) {
sfToolkit::clearDirectory($dir);
rmdir($dir);
$this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('dir-', $dir))));
}
} else {
$messages = array($this->formatter->format('The following directories are alien and not referenced by your configuration:', 'INFO'));
for ($c = count($remove), $x = 0; $x < $c; $x++) {
$messages[] = ' ' . ($x + 1) . ') ' . $remove[$x];
}
$messages[] = '';
$messages[] = 'These directories were ' . $this->formatter->format('not', array('fg' => 'red', 'bold' => true)) . ' deleted. To delete these directories, please run:';
$messages[] = '';
$messages[] = ' ' . $this->formatter->format('symfony lucene:clean ' . $arguments['application'] . ' delete', 'INFO');
$messages[] = '';
$this->dispatcher->notify(new sfEvent($this, 'command.log', $messages));
}
}
示例5: initialize
/**
* @see sfPluginConfiguration
*/
public function initialize()
{
sfConfig::set('sf_orm', 'propel');
if (!sfConfig::get('sf_admin_module_web_dir')) {
sfConfig::set('sf_admin_module_web_dir', '/sfPropelPlugin');
}
sfToolkit::addIncludePath(array(sfConfig::get('sf_root_dir'), sfConfig::get('sf_propel_runtime_path', realpath(dirname(__FILE__) . '/../lib/vendor'))));
require_once 'propel/Propel.php';
if (!Propel::isInit()) {
if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
Propel::setLogger(new sfPropelLogger($this->dispatcher));
}
$propelConfiguration = new PropelConfiguration();
Propel::setConfiguration($propelConfiguration);
$this->dispatcher->notify(new sfEvent($propelConfiguration, 'propel.configure'));
Propel::initialize();
}
$this->dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent'));
if (sfConfig::get('sf_web_debug')) {
$this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelPropel', 'listenToAddPanelEvent'));
}
if (sfConfig::get('sf_test')) {
$this->dispatcher->connect('context.load_factories', array($this, 'clearAllInstancePools'));
}
}
示例6: sf_unit_test_shutdown
function sf_unit_test_shutdown()
{
$sf_root_dir = sys_get_temp_dir().'/sf_test_project';
if(is_dir($sf_root_dir))
{
sfToolkit::clearDirectory($sf_root_dir);
@rmdir($sf_root_dir);
}
$sessions = glob(sys_get_temp_dir().'/sessions*');
$tmp_files = glob(sys_get_temp_dir().'/sf*');
$files = array_merge((empty($sessions) ? array() : $sessions), (empty($tmp_files) ? array() : $tmp_files));
foreach ($files as $file)
{
if(is_dir($file))
{
sfToolkit::clearDirectory($file);
@rmdir($file);
}
else
{
@unlink($file);
}
}
}
示例7: cleanup
function cleanup()
{
//sfToolkit::clearDirectory(dirname(__FILE__).'/../fixtures/project/cache');
sfToolkit::clearDirectory(dirname(__FILE__) . '/../fixtures/project/log');
@unlink(sfConfig::get('sf_data_dir') . '/test.sqlite');
@unlink(sfConfig::get('sf_config_dir') . '/app.yml');
}
示例8: execute
/**
* Executes this configuration handler.
*
* @param array $configFiles An array of absolute filesystem path to a configuration file
*
* @return string Data to be written to a cache file
*
* @throws sfConfigurationException If a requested configuration file does not exist or is not readable
* @throws sfParseException If a requested configuration file is improperly formatted
*/
public function execute($configFiles)
{
// parse the yaml
$config = self::getConfiguration($configFiles);
// init our data
$data = '';
// let's do our fancy work
foreach ($config as $file) {
if (!is_readable($file)) {
// file doesn't exist
throw new sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file));
}
$contents = file_get_contents($file);
// strip comments (not in debug mode)
if (!sfConfig::get('sf_debug')) {
$contents = sfToolkit::stripComments($contents);
}
// insert configuration files
/* $contents = preg_replace_callback(array('#(require|include)(_once)?\((sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->checkConfig\(\'config/([^\']+)\'\)\);#m',
'#()()(sfContext::getInstance\(\)\->getConfigCache\(\)|\$configCache)->import\(\'config/([^\']+)\'(, false)?\);#m'),
array($this, 'insertConfigFileCallback'), $contents);
*/
// strip php tags
$contents = sfToolkit::pregtr($contents, array('/^\\s*<\\?(php)?/m' => '', '/^\\s*\\?>/m' => ''));
// replace windows and mac format with unix format
$contents = str_replace("\r", "\n", $contents);
// replace multiple new lines with a single newline
$contents = preg_replace(array('/\\s+$/Sm', '/\\n+/S'), "\n", $contents);
// append file data
$data .= "\n" . $contents;
}
// compile data
$retval = sprintf("<?php\n" . "// auto-generated by sfCompileConfigHandler\n" . "// date: %s\n%s\n", date('Y/m/d H:i:s'), $data);
return $retval;
}
示例9: execute
/**
* Executes this configuration handler.
*
* @param array An array of absolute filesystem path to a configuration file
*
* @return string Data to be written to a cache file
*
* @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable
* @throws <b>sfParseException</b> If a requested configuration file is improperly formatted
* @throws <b>sfInitializationException</b> If a cache.yml key check fails
*/
public function execute($configFiles)
{
// set our required categories list and initialize our handler
$categories = array('required_categories' => array());
$this->initialize($categories);
// parse the yaml
$myConfig = $this->parseYamls($configFiles);
$myConfig['all'] = sfToolkit::arrayDeepMerge(isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(), isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array());
unset($myConfig['default']);
$this->yamlConfig = $myConfig;
// iterate through all action names
$data = array();
$first = true;
foreach ($this->yamlConfig as $actionName => $values) {
if ($actionName == 'all') {
continue;
}
$data[] = $this->addCache($actionName);
$first = false;
}
// general cache configuration
$data[] = $this->addCache('DEFAULT');
// compile data
$retval = sprintf("<?php\n" . "// auto-generated by sfCacheConfigHandler\n" . "// date: %s\n%s\n", date('Y/m/d H:i:s'), implode('', $data));
return $retval;
}
示例10: underscore
/**
* Returns an underscore-syntaxed version or the CamelCased string.
*
* @param string $camel_cased_word String to underscore.
*
* @return string Underscored string.
*/
public static function underscore($camel_cased_word)
{
$tmp = $camel_cased_word;
$tmp = str_replace('::', '/', $tmp);
$tmp = sfToolkit::pregtr($tmp, array('/([A-Z]+)([A-Z][a-z])/' => '\\1_\\2', '/([a-z\\d])([A-Z])/' => '\\1_\\2'));
return strtolower($tmp);
}
示例11: clearDirectory
protected function clearDirectory($dir)
{
sfToolkit::clearDirectory($dir);
if (is_dir($dir)) {
rmdir($dir);
}
}
示例12: findPhpBinary
protected function findPhpBinary()
{
if (defined('PHP_BINARY') && PHP_BINARY)
{
return PHP_BINARY;
}
if (false !== strpos(basename($php = $_SERVER['_']), 'php'))
{
return $php;
}
// from https://github.com/symfony/Process/blob/379b35a41a2749cf7361dda0f03e04410daaca4c/PhpExecutableFinder.php
$suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array('');
foreach ($suffixes as $suffix)
{
if (is_executable($php = PHP_BINDIR.DIRECTORY_SEPARATOR.'php'.$suffix))
{
return $php;
}
}
if ($php = getenv('PHP_PEAR_PHP_BIN'))
{
if (is_executable($php))
{
return $php;
}
}
return sfToolkit::getPhpCli();
}
示例13: executeCommand
public function executeCommand(sfWebRequest $request)
{
$command = trim($request->getParameter("dm_command"));
if (substr($command, 0, 2) == "sf") {
$command = substr($command, 3);
$exec = sprintf('%s "%s" %s --color', sfToolkit::getPhpCli(), dmProject::getRootDir() . '/symfony', $command);
} else {
$options = substr(trim($command), 0, 2) == 'll' || substr(trim($command), 0, 2) == 'ls' ? '--color' : '';
$parts = explode(" ", $command);
$parts[0] = dmArray::get($this->getAliases(), $parts[0], $parts[0]);
$command = implode(" ", $parts);
$parts = explode(" ", $command);
$command = dmArray::get($this->getAliases(), $command, $command);
if (!in_array($parts[0], $this->getCommands())) {
return $this->renderText(sprintf("%s<li>This command is not available. You can do: <strong>%s</strong></li>", $this->renderCommand($command), implode(' ', $this->getCommands())));
}
$exec = sprintf("%s {$options}", $command);
}
ob_start();
passthru($exec . ' 2>&1', $return);
$raw = dmAnsiColorFormatHtmlRenderer::render(ob_get_clean());
$arr = explode("\n", $raw);
$res = $this->renderCommand($command);
foreach ($arr as $a) {
$res .= "<li class='dm_result_command'><pre>" . $a . "</pre></li>";
}
return $this->renderText($res);
}
示例14: initialize
protected function initialize(array $options)
{
$this->options = sfToolkit::arrayDeepMerge($this->options, $options);
if (!$this->page instanceof DmPage) {
throw new dmException(sprintf('%s require a source instance of DmPage, %s given', get_class($this), get_class($this->page)));
}
}
示例15: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$filename = $arguments['target'];
if (null !== $filename && !sfToolkit::isPathAbsolute($filename))
{
$dir = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures';
$this->getFilesystem()->mkdirs($dir);
$filename = $dir.DIRECTORY_SEPARATOR.$filename;
$this->logSection('propel', sprintf('dumping data to "%s"', $filename));
}
$data = new sfPropelData();
$classes = null === $options['classes'] ? 'all' : explode(',', $options['classes']);
if (null !== $filename)
{
$data->dumpData($filename, $classes, $options['connection']);
}
else
{
fwrite(STDOUT, sfYaml::dump($data->getData($classes, $options['connection']), 3));
}
}