本文整理汇总了PHP中sfFinder::type方法的典型用法代码示例。如果您正苦于以下问题:PHP sfFinder::type方法的具体用法?PHP sfFinder::type怎么用?PHP sfFinder::type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfFinder
的用法示例。
在下文中一共展示了sfFinder::type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUpgrades
/**
* Returns an array of all possible upgrade files as an array with
* the upgrade's key and version
*
* This first looks for all .php files in the versions directory.
* The files should have the format of VERSION_NUMBER (e.g. 1.0.0__1).
* The project is then checked to see if
*/
public function getUpgrades()
{
if (!$this->_upgrades) {
$this->_upgrades = array();
$versions = array();
$dir = dirname(__FILE__) . '/versions';
$files = sfFinder::type('file')->name('*.php')->in($dir);
foreach ($files as $file) {
$info = pathinfo($file);
if (strpos($info['filename'], '__') === false) {
throw new sfException(sprintf('Invalid upgrade filename format for file "%s" - must contain a double underscore - VERSION__NUMBER (e.g. 1.0.0__1) ', $info['filename']));
}
$e = explode('__', $info['filename']);
$version = $e[0];
$number = $e[1];
if ($this->_isVersionNew($info['filename'])) {
$versions[] = array('version' => $version, 'number' => $number);
$this->_upgrades[] = $version . '__' . $number;
}
}
natcasesort($this->_upgrades);
foreach ($this->_upgrades as $key => $version) {
$this->_upgrades[$key] = $versions[$key];
}
}
return $this->_upgrades;
}
示例2: generate
/**
* @see sfGenerator
*/
public function generate($params = array())
{
$this->params = $params;
foreach (array('index_class', 'moduleName') as $required) {
if (!isset($this->params[$required])) {
throw new xfGeneratorException('You must specify "' . $required . '".');
}
}
if (!class_exists($this->params['index_class'])) {
throw new xfGeneratorException('Unable to build interface for nonexistant index "' . $this->params['index_class'] . '"');
}
if (null !== ($form = $this->get('simple.form.class', null))) {
$reflection = new ReflectionClass($form);
if (!$reflection->isSubClassOf(new ReflectionClass('xfForm'))) {
throw new xfGeneratorException('Form class must extend xfForm');
}
}
// check to see if theme exists
if (!isset($this->params['theme'])) {
$this->params['theme'] = 'default';
}
$themeDir = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $this->params['theme'], '');
$this->setGeneratedModuleName('auto' . ucfirst($this->params['moduleName']));
$this->setModuleName($this->params['moduleName']);
$this->setTheme($this->params['theme']);
$themeFiles = sfFinder::type('file')->relative()->discard('.*')->in($themeDir);
$this->generatePhpFiles($this->generatedModuleName, $themeFiles);
$data = "require_once(sfConfig::get('sf_module_cache_dir') . '/" . $this->generatedModuleName . "/actions/actions.class.php');";
$data .= "require_once(sfConfig::get('sf_module_cache_dir') . '/" . $this->generatedModuleName . "/actions/components.class.php');";
return $data;
}
示例3: generate
/**
* Generates classes and templates in cache.
*
* @param array $params The parameters
*
* @return string The data to put in configuration cache
*/
public function generate($params = array())
{
$this->validateParameters($params);
$this->modelClass = $this->params['model_class'];
// generated module name
$this->setModuleName($this->params['moduleName']);
$this->setGeneratedModuleName('auto' . ucfirst($this->params['moduleName']));
// theme exists?
$theme = isset($this->params['theme']) ? $this->params['theme'] : 'default';
$this->setTheme($theme);
$themeDir = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $theme, '');
if (!is_dir($themeDir)) {
throw new sfConfigurationException(sprintf('The theme "%s" does not exist.', $theme));
}
// configure the model
$this->configure();
$this->configuration = $this->loadConfiguration();
// generate files
$this->generatePhpFiles($this->generatedModuleName, sfFinder::type('file')->relative()->in($themeDir));
// move helper file
if (file_exists($file = $this->generatorManager->getBasePath() . '/' . $this->getGeneratedModuleName() . '/lib/helper.php')) {
@rename($file, $this->generatorManager->getBasePath() . '/' . $this->getGeneratedModuleName() . '/lib/Base' . ucfirst($this->moduleName) . 'GeneratorHelper.class.php');
}
return "require_once(sfConfig::get('sf_module_cache_dir').'/" . $this->generatedModuleName . "/actions/actions.class.php');";
}
示例4: clearCache
/**
* Clears the super cache by listening to the task.cache.clear event.
*
* @param sfEvent An sfEvent instance
*/
public static function clearCache(sfEvent $event)
{
$config = sfFilterConfigHandler::getConfiguration($event['app']->getConfigPaths('config/filters.yml'));
$event->getSubject()->logSection('cache', 'Clearing super cache');
// find super cache configuration
$found = false;
$cacheDir = 'cache';
foreach ($config as $value) {
if ('sfSuperCacheFilter' == $value['class']) {
$found = true;
if (isset($value['param']['cache_dir'])) {
$cacheDir = $value['param']['cache_dir'];
}
break;
}
}
if ($found) {
// clear the cache
$cacheDir = sfConfig::get('sf_web_dir') . '/' . $cacheDir;
if (is_dir($cacheDir)) {
// remove cache files
$event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
}
}
}
示例5: extract
/**
* @see sfI18nExtract
*/
public function extract()
{
foreach (sfFinder::type('dir')->maxdepth(0)->relative()->in($this->parameters['path'] . '/modules') as $moduleName) {
$this->extractFromPhpFiles(array($this->parameters['path'] . '/modules/' . $moduleName . '/actions', $this->parameters['path'] . '/modules/' . $moduleName . '/lib', $this->parameters['path'] . '/modules/' . $moduleName . '/templates'));
}
$this->extractFromPhpFiles($this->parameters['path'] . '/lib');
}
示例6: execute
/**
*
*
* @param unknown_type $arguments
* @param unknown_type $options
* @todo run in build task
* @todo add lock file
*/
protected function execute($arguments = array(), $options = array())
{
// run only in staging or dev mode
if ($options['env'] == "dev") {
throw new sfException(sprintf("Don't run the s3sync in the '%s' environment.", $options['env']));
}
$lReleaseName = sfConfig::get('app_release_name');
$lBucket = sfConfig::get('app_amazons3_bucket');
$lNewPath = CdnSingleton::getInstance()->getNextHost() . '/' . $lReleaseName;
$lCssDirectory = sfConfig::get('sf_web_dir') . "/css";
$lS3Directory = sfConfig::get('sf_web_dir') . "/s3sync";
$this->getFilesystem()->execute("rm -rf " . $lS3Directory . "/css");
$this->getFilesystem()->execute("rsync -aC --exclude .svn " . $lCssDirectory . " " . $lS3Directory);
$lFiles = sfFinder::type('file')->follow_link()->relative()->in($lS3Directory . "/css");
foreach ($lFiles as $lFile) {
// absolute path
$lFile = $lS3Directory . "/css/" . $lFile;
$lContent = file_get_contents($lFile);
$lContent = str_replace('url("/img/', 'url("' . $lNewPath . "/img/", $lContent);
$fp = fopen($lFile, 'w');
fwrite($fp, $lContent);
fclose($fp);
}
$this->getFilesystem()->execute("s3cmd --bucket-location=EU -P -r --exclude='*.svn*' --add-header 'Expires: Sat, 08 May 2015 15:22:28 GMT' sync web/s3sync/css/ s3://{$lBucket}/{$lReleaseName}/css/");
$this->getFilesystem()->execute("s3cmd --bucket-location=EU -P -r --exclude='*.svn*' --add-header 'Expires: Sat, 08 May 2015 15:22:28 GMT' sync web/img/ s3://{$lBucket}/{$lReleaseName}/img/");
$this->getFilesystem()->execute("s3cmd --bucket-location=EU -P -r --exclude='*.svn*' --add-header 'Expires: Sat, 08 May 2015 15:22:28 GMT' sync web/js/100_main/include/ s3://{$lBucket}/{$lReleaseName}/js/100_main/include/");
$this->getFilesystem()->execute("find ./web/js/100_main/include -type f -exec 7z a -tgzip -x\\!\\*.svn -x\\!\\*.gz {}.gz {} \\;");
$this->getFilesystem()->execute("s3cmd --bucket-location=EU -P -r --exclude='*.*' --include '*.gz' --mime-type 'application/javascript' --add-header 'Content-Encoding: gzip' sync web/js/100_main/include/ s3://{$lBucket}/{$lReleaseName}/js/100_main/include/");
$this->getFilesystem()->execute("find ./web/js/100_main/include -name '*.gz' -exec rm {} \\;");
$this->getFilesystem()->execute("find ./web/s3sync/css -type f -exec 7z a -tgzip -x\\!\\*.svn -x\\!\\*.gz {}.gz {} \\;");
$this->getFilesystem()->execute("s3cmd --bucket-location=EU -P -r --exclude='*.*' --include '*.gz' --mime-type 'text/css' --add-header 'Content-Encoding: gzip' sync web/s3sync/css/ s3://{$lBucket}/{$lReleaseName}/css/");
$this->getFilesystem()->execute("find ./web/s3sync/css -name '*.gz' -exec rm {} \\;");
}
示例7: loadTasks
/**
* Loads all available tasks.
*
* Looks for tasks in the symfony core, the current project and all project plugins.
*
* @param sfProjectConfiguration $configuration The project configuration
*/
protected function loadTasks(sfProjectConfiguration $configuration)
{
// Symfony core tasks
$dirs = array(sfConfig::get('sf_symfony_lib_dir') . '/task');
// Plugin tasks
foreach ($configuration->getPluginPaths() as $path) {
if (is_dir($taskPath = $path . '/lib/task')) {
$dirs[] = $taskPath;
}
}
// project tasks
$dirs[] = sfConfig::get('sf_lib_dir') . '/task';
$finder = sfFinder::type('file')->name('*Task.class.php');
foreach ($finder->in($dirs) as $file) {
$this->taskFiles[basename($file, '.class.php')] = $file;
}
// register local autoloader for tasks
spl_autoload_register(array($this, 'autoloadTask'));
// require tasks
foreach ($this->taskFiles as $task => $file) {
// forces autoloading of each task class
class_exists($task, true);
}
// unregister local autoloader
spl_autoload_unregister(array($this, 'autoloadTask'));
}
示例8: execute
protected function execute($arguments = array(), $options = array())
{
$plugin = $arguments['plugin'];
$app = $arguments['application'];
$module = $arguments['module'];
$pluginsDir = sfConfig::get('sf_plugins_dir') . '/' . $plugin;
// Validate the module name
if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $module)) {
throw new sfCommandException(sprintf('The module name "%s" is invalid.', $module));
}
$moduleDir = $pluginsDir . '/apps/' . $app . '/modules/' . $module;
if (is_dir($moduleDir)) {
throw new sfCommandException(sprintf('The module "%s" already exists in the "%s" application.in the "%s" plugin', $moduleDir, $app, $plugin));
}
$properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
if (is_readable($pluginsDir . '/config/properties.ini')) {
$pluginProperties = parse_ini_file($pluginsDir . '/config/properties.ini', true);
$properties = array_merge($properties, $pluginProperties);
}
$constants = array('PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'APP_NAME' => $app, 'MODULE_NAME' => $module, 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here');
$skeletonDir = dirname(__FILE__) . '/skeleton/module';
// create basic application structure
$finder = sfFinder::type('any')->discard('.sf');
$this->getFilesystem()->mirror($skeletonDir . '/module', $moduleDir, $finder);
// customize php and yml files
$finder = sfFinder::type('file')->name('*.php', '*.yml');
$this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $constants);
}
示例9: upgrade
public function upgrade()
{
if (!file_exists($file = sfConfig::get('sf_lib_dir') . '/form/BaseForm.class.php')) {
$properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
$tokens = array('PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here');
$this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir') . '/task/generator/skeleton/project/lib/form/BaseForm.class.php', $file);
$this->getFilesystem()->replaceTokens(array($file), '##', '##', $tokens);
}
$finder = sfFinder::type('file')->name('*.php');
foreach ($finder->in($this->getProjectLibDirectories('/form')) as $file) {
$contents = file_get_contents($file);
$changed = false;
// forms that extend sfForm should now extend BaseForm
$contents = preg_replace('/(\\bextends\\s+)sfForm\\b/i', '\\1BaseForm', $contents, -1, $count);
$changed = $count || $changed;
// change instances of sfWidgetFormInput to sfWidgetFormInputText
$contents = preg_replace('/\\bnew\\s+sfWidgetFormInput\\b/i', '\\0Text', $contents, -1, $count);
$changed = $count || $changed;
// change signature of sfFormDoctrine::processValues()
$contents = preg_replace('/public\\s+function\\s+processValues\\s*\\(\\s*\\$\\w+(\\s*=\\s*null\\s*)\\)/ie', "str_replace('\$1', '', '\$0')", $contents, -1, $count);
$changed = $count || $changed;
if ($changed) {
$this->logSection('form', 'Migrating ' . $file);
file_put_contents($file, $contents);
}
}
}
示例10: loadAllFilesInDir
public function loadAllFilesInDir($dir)
{
$files = sfFinder::type('file')->name('*.schema.sql')->follow_link()->in($dir);
foreach ($files as $file) {
$this->loadFromFile($file);
}
}
示例11: execute
protected function execute($arguments = array(), $options = array())
{
$app = $arguments['application'];
$override = $options['override'];
$testAppDir = sfConfig::get('sf_test_dir').'/features/'.$app;
if (is_readable(sfConfig::get('sf_data_dir').'/skeleton/features'))
{
$skeletonDir = sfConfig::get('sf_data_dir').'/skeleton/features';
}
else
{
$skeletonDir = dirname(__FILE__).'/skeleton/features';
}
if (file_exists(sfConfig::get('sf_root_dir') . '/behat.yml')) {
$this->getFilesystem()->remove(sfConfig::get('sf_root_dir') . '/behat.yml');
}
// create basic application features
$finder = sfFinder::type('any')->discard('.sf');
$this->getFilesystem()->mirror($skeletonDir.'/app', $testAppDir, $finder, array(
'override' => $override
));
$this->getFilesystem()->mirror($skeletonDir.'/root', sfConfig::get('sf_root_dir'), $finder, array(
'override' => $override
));
}
示例12: execute
protected function execute($arguments = array(), $options = array())
{
$plugins = explode(',', $options['plugins']);
foreach (glob(sfConfig::get('sf_plugins_dir') . '/*', GLOB_ONLYDIR) as $plugin_path) {
$plugin = basename($plugin_path);
if ($options['plugins'] != 'all' && !in_array($plugin, $plugins)) {
continue;
}
if (is_dir(sfConfig::get('sf_plugins_dir') . '/' . $plugin . '/.git')) {
$this->logSection($plugin, 'plugin folder already under git management');
continue;
}
$file = sfConfig::get('sf_plugins_dir') . '/' . $plugin . '/.sw_git_migration';
if (!is_file($file) && $options['plugins'] != 'all') {
$this->logSection($plugin, 'no .sw_git_migration file');
continue;
}
$git_repository = trim(file_get_contents($file));
$this->logSection($plugin, 'starting restore ...');
// remove current directory content
$this->getFileSystem()->remove(sfFinder::type('any')->ignore_version_control(false)->in(sprintf('%s/.sw_git_migration_plugin', sfConfig::get('sf_plugins_dir'))));
// run the task to deploy a git repository over a svn repo
$this->logSection($plugin, 'clone the repository');
$cmd = sprintf('%s clone %s %s/.sw_git_migration_plugin', $options['git'], $git_repository, sfConfig::get('sf_plugins_dir'));
$this->exec($cmd);
$this->logSection($plugin, 'copy the content into the');
$this->getFileSystem()->mirror(sprintf('%s/.sw_git_migration_plugin', sfConfig::get('sf_plugins_dir')), sfConfig::get('sf_plugins_dir') . '/' . $plugin, sfFinder::type('any')->ignore_version_control(false), array('overwrite' => true));
$this->getFileSystem()->remove(sfFinder::type('any')->ignore_version_control(false)->in(sprintf('%s/.sw_git_migration_plugin', sfConfig::get('sf_plugins_dir'))));
}
}
示例13: loadMapBuilderClasses
/**
* Loads map builder classes.
*
* This method is ORM dependant.
*
* @throws sfException
*/
protected function loadMapBuilderClasses()
{
// we must load all map builder classes to be able to deal with foreign keys (cf. editSuccess.php template)
$classes = sfFinder::type('file')->ignore_version_control()->name('*MapBuilder.php')->in(sfLoader::getModelDirs());
foreach ($classes as $class)
{
$class_map_builder = basename($class, '.php');
$maps[$class_map_builder] = new $class_map_builder();
if (!$maps[$class_map_builder]->isBuilt())
{
$maps[$class_map_builder]->doBuild();
}
if ($this->className == str_replace('MapBuilder', '', $class_map_builder))
{
$this->map = $maps[$class_map_builder];
}
}
if (!$this->map)
{
throw new sfException('The model class "'.$this->className.'" does not exist.');
}
$this->tableMap = $this->map->getDatabaseMap()->getTable(constant($this->className.'Peer::TABLE_NAME'));
}
示例14: combineModuleFiles
/**
*
* Combine files defined in module's view.yml files
*/
public function combineModuleFiles()
{
// get the all modules
$modules = sfConfig::get('sf_enabled_modules', array());
$app_modules = sfFinder::type('directory')->maxdepth(0)->in(sfConfig::get('sf_app_module_dir'));
foreach ($app_modules as $module) {
$modules[] = str_replace(sfConfig::get('sf_app_module_dir') . '/', '', $module);
}
foreach ($modules as $module) {
$this->logSection('combine', 'module : ' . $module);
$configPath = sprintf('modules/%s/config/view.yml', $module);
$files = $this->configuration->getConfigPaths($configPath);
$config = swCombineViewConfigHandler::getConfiguration($files);
$this->view_handler->setYamlConfig($config);
foreach ($config as $view => $params) {
$this->logSection('combine', ' > view : ' . $module . '::' . $view);
// Generate css module files
$stylesheets = $this->view_handler->exposeMergeConfigValue('stylesheets', $view);
if (count($stylesheets) > 0) {
$assets = $this->view_handler->exposeAddAssets('stylesheet', $stylesheets, false);
$this->combineAndOptimize('stylesheet', $assets);
}
// Generate js module files
$javascripts = $this->view_handler->exposeMergeConfigValue('javascripts', $view);
if (count($javascripts) > 0) {
$assets = $this->view_handler->exposeAddAssets('javascript', $javascripts, false);
$this->combineAndOptimize('javascript', $assets);
}
}
}
}
示例15: generate
/**
* Generates classes and templates in cache.
*
* @param array The parameters
*
* @return string The data to put in configuration cache
*/
public function generate($params = array())
{
$logger = sfContext::getInstance()->getLogger();
$logger->err("WOW generate enter");
$logger->err(print_r($params, true));
$this->params = $params;
// check if all required parameters are present
$required_parameters = array('moduleName');
foreach ($required_parameters as $entry) {
if (!isset($this->params[$entry])) {
throw new sfParseException(sprintf('You must specify a "%s".', $entry));
}
}
// generated module name
$this->setGeneratedModuleName('auto' . ucfirst($this->params['moduleName']));
$this->setModuleName($this->params['moduleName']);
// check if the theme exists?
$theme = isset($this->params['theme']) ? $this->params['theme'] : 'default';
$themeDir = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $theme, '');
if (!is_dir($themeDir)) {
throw new sfConfigurationException(sprintf('The theme "%s" does not exist.', $theme));
}
$this->setTheme($theme);
$files = sfFinder::type('file')->relative()->in($themeDir);
$this->generatePhpFiles($this->generatedModuleName, $files);
// require generated action class
$data = "require_once(sfConfig::get('sf_module_cache_dir').'/" . $this->generatedModuleName . "/actions/actions.class.php');\n";
$logger->err("WOW generate leave");
return $data;
}