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


PHP Folder::find方法代码示例

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


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

示例1: initialize

 /**
  * Initialize method
  */
 public function initialize()
 {
     $paths = App::path('Shell/Task', 'CodeBlastrQueue');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.+\\.php'));
         foreach ($res as &$r) {
             $r = 'CodeBlastrQueue.' . basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     parent::initialize();
 }
开发者ID:codeblastr,项目名称:queue,代码行数:16,代码来源:QueueShell.php

示例2: initialize

 /**
  * Overwrite shell initialize to dynamically load all Queue Related Tasks.
  *
  * @return void
  */
 public function initialize()
 {
     $plugins = Plugin::loaded();
     foreach ($plugins as $plugin) {
         $pluginPaths = App::path('Shell/Task', $plugin);
         foreach ($pluginPaths as $pluginPath) {
             $Folder = new Folder($pluginPath);
             $res = $Folder->find('Queue.+Task\\.php');
             foreach ($res as &$r) {
                 $r = $plugin . '.' . basename($r, 'Task.php');
             }
             $this->tasks = array_merge($this->tasks, $res);
         }
     }
     $paths = App::path('Shell/Task');
     foreach ($paths as $path) {
         $Folder = new Folder($path);
         $res = array_merge($this->tasks, $Folder->find('Queue.+\\.php'));
         foreach ($res as &$r) {
             $r = basename($r, 'Task.php');
         }
         $this->tasks = $res;
     }
     parent::initialize();
     $this->QueuedTasks->initConfig();
 }
开发者ID:repher,项目名称:cakephp-queue,代码行数:31,代码来源:QueueShell.php

示例3: fixturize

 /**
  * Loads all fixtures from disk if none defined.
  *
  * @param \Cake\TestSuite\TestCase $test The test case to inspect.
  * @return void
  */
 public function fixturize($test)
 {
     if (!isset($test->fixtures)) {
         $folder = new Folder($this->_fixturePath);
         $fixtureFiles = $folder->find('.*Fixture\\.php');
         foreach ($fixtureFiles as $fixtureFile) {
             $fixtureName = str_replace('Fixture.php', '', $fixtureFile);
             $fixtureName = Inflector::underscore($fixtureName);
             $test->fixtures[] = 'app.' . $fixtureName;
         }
     }
     parent::fixturize($test);
 }
开发者ID:gourmet,项目名称:platform,代码行数:19,代码来源:FixtureManager.php

示例4: _initializeModule

 /**
  * Initialize a single module instance.
  *
  * @param string $modulePath
  */
 protected static function _initializeModule($modulePath)
 {
     $moduleFolder = new Folder($modulePath);
     $moduleName = basename($moduleFolder->path);
     $moduleClassFilename = $moduleName . 'Module.php';
     $moduleClassFile = $moduleFolder->find($moduleClassFilename);
     if (empty($moduleClassFile)) {
         user_error(__d('wasabi_cms', 'Module {0} has no associated class file {1} in {3}.', $moduleName, $moduleClassFilename, $modulePath));
     }
     $moduleClassFile = $moduleClassFile[0];
     $moduleNamespace = self::_extractNamespace($modulePath . DS . $moduleClassFile);
     if (!$moduleNamespace) {
         user_error(__d('wasabi_cms', 'Module {3} has no namespace.'));
     }
     $class = $moduleNamespace . '\\' . $moduleName . 'Module';
     self::$_modules[$class] = new $class();
 }
开发者ID:wasabi-cms,项目名称:cms,代码行数:22,代码来源:ModuleManager.php

示例5: import

 public function import()
 {
     $settingsFile = 'settings';
     if (!empty($this->plugin)) {
         $settingsFile = $this->plugin . '.' . $settingsFile;
         $settingsFileDir = Plugin::path($this->plugin) . 'config';
     } else {
         $settingsFileDir = ROOT . DS . 'config';
     }
     $settingsDir = new Folder($settingsFileDir, false);
     if (!$settingsDir->find('settings.*')) {
         return false;
     }
     $config = new PhpConfig();
     $data = $config->read($settingsFile);
     if (!$data) {
         return false;
     }
     if (!empty($this->plugin)) {
         $this->out(__d('platform', '- <success>Processing settings pool for {0} plugin</success>', $this->plugin));
     } else {
         $this->out(__d('platform', '- <success>Processing settings pool for {0}</success>', 'App'));
     }
     $settingsTable = TableRegistry::get('Platform.Settings');
     foreach ($data as $row) {
         if (!isset($row['plugin']) || empty($row['plugin'])) {
             $row['plugin'] = $this->plugin;
         }
         $data = ['plugin' => $row['plugin'], 'path' => $row['path']];
         $setting = $settingsTable->find('all', ['conditions' => $data])->first();
         if (!$setting) {
             $setting = $settingsTable->newEntity();
             $data = array_merge($data, ['value' => isset($row['default']) ? $row['default'] : '']);
         }
         $setting = $settingsTable->patchEntity($setting, $data);
         $settingsTable->save($setting);
     }
     //TODO: Maybe chared method for settings save
     $settings = $settingsTable->find()->combine('path', 'value')->toArray();
     ksort($settings);
     $settings = Hash::expand($settings);
     Settings::dump('config', 'default', $settings);
 }
开发者ID:mindforce,项目名称:cakephp-platform,代码行数:43,代码来源:SettingsTask.php

示例6: getApiControllers

 /**
  * Returns a list of Controller names found in /src/Controller/Api.
  *
  * @return array List holding sorted Controller names
  */
 public static function getApiControllers()
 {
     $cached = Cache::read('api_controllers');
     if ($cached) {
         return $cached;
     }
     $dir = new Folder(APP . 'Controller' . DS . Inflector::camelize(Configure::read('App++.Api.prefix')));
     $controllerFiles = $dir->find('.*Controller\\.php');
     if (!$controllerFiles) {
         return false;
     }
     $result = [];
     foreach ($controllerFiles as $controllerFile) {
         $result[] = substr($controllerFile, 0, strlen($controllerFile) - 14);
     }
     sort($result);
     Cache::write('api_controllers', $result);
     return $result;
 }
开发者ID:alt3,项目名称:cakephp-app-configurator,代码行数:24,代码来源:PlusPlus.php

示例7: deleteFile

 private function deleteFile(Attachment $attachment, $recursive = false)
 {
     $return = true;
     $dir = new Folder(Configure::read('Upload.path') . $attachment->get('file_path'));
     if ($recursive) {
         $files = $dir->findRecursive($attachment->get('file_name') . '.*', true);
     } else {
         $files = $dir->find($attachment->get('file_name') . '.*');
     }
     foreach ($files as $file) {
         $fileTmp = new File($file);
         if ($fileTmp->exists()) {
             if (!$fileTmp->delete()) {
                 $return = false;
             }
         } else {
             $return = false;
         }
     }
     return $return;
 }
开发者ID:grandfelix,项目名称:woodyattachments,代码行数:21,代码来源:AttachmentsTable.php

示例8: ajaxDeleteImage

 public function ajaxDeleteImage($id = null)
 {
     $this->autoRender = false;
     $ImagesTable = TableRegistry::get('Images');
     $image = $ImagesTable->get($id);
     $shared = $ImagesTable->find()->where(['id !=' => $image->id, 'field_index !=' => $image->field_index, 'model' => $image->model, 'filename' => $image->filename]);
     if (!$shared->count()) {
         $basePath = WWW_ROOT . 'uploads/images/' . $image->model;
         $dir = new Folder($basePath);
         $files = $dir->find('.*_.*\\..*');
         (new File($basePath . DS . $image->filename))->delete();
         foreach ($files as $file) {
             if (preg_match("/.*_{$image->filename}/", $file)) {
                 (new File($basePath . DS . $file))->delete();
             }
         }
     }
     if (!$ImagesTable->delete($image)) {
         throw new InternalErrorException();
     }
     if (!$this->request->is('ajax')) {
         $this->redirect($this->referer());
     }
 }
开发者ID:aiphee,项目名称:image,代码行数:24,代码来源:ImagesController.php

示例9: getPermittedFilename

 /**
  * This function provides the correct filename for the creation of file systems. 
  * 
  * @param type $directory
  * @param type $filename
  * @return string
  */
 public function getPermittedFilename($directory, $filename)
 {
     $pathInfo = pathinfo($filename);
     $pathInfo['filename'] = substr(Inflector::slug($pathInfo['filename']), 0, 100);
     if (strlen($pathInfo['filename']) < 3) {
         $pathInfo['filename'] = $this->_randomString();
     }
     $dir = new Folder($directory);
     $iter = 0;
     do {
         if ($iter == 0) {
             $slugFileName = $pathInfo['filename'] . '.' . $pathInfo['extension'];
         } else {
             $slugFileName = $pathInfo['filename'] . '-' . $iter . '.' . $pathInfo['extension'];
         }
         $data = $dir->find($slugFileName, true);
         $iter++;
     } while (count($data) > 0);
     return $slugFileName;
 }
开发者ID:aoliverio,项目名称:content,代码行数:27,代码来源:File.php

示例10: testFind

 /**
  * testFind method
  *
  * @return void
  */
 public function testFind()
 {
     $Folder = new Folder();
     $Folder->cd(CORE_PATH . 'config');
     $result = $Folder->find();
     $expected = ['config.php'];
     $this->assertSame(array_diff($expected, $result), []);
     $this->assertSame(array_diff($expected, $result), []);
     $result = $Folder->find('.*', true);
     $expected = ['bootstrap.php', 'cacert.pem', 'config.php'];
     $this->assertSame($expected, $result);
     $result = $Folder->find('.*\\.php');
     $expected = ['bootstrap.php', 'config.php'];
     $this->assertSame(array_diff($expected, $result), []);
     $this->assertSame(array_diff($expected, $result), []);
     $result = $Folder->find('.*\\.php', true);
     $expected = ['bootstrap.php', 'config.php'];
     $this->assertSame($expected, $result);
     $result = $Folder->find('.*ig\\.php');
     $expected = ['config.php'];
     $this->assertSame($expected, $result);
     $result = $Folder->find('config\\.php');
     $expected = ['config.php'];
     $this->assertSame($expected, $result);
     $Folder = new Folder(TMP . 'tests/', true);
     $File = new File($Folder->pwd() . DS . 'paths.php', true);
     $Folder->create($Folder->pwd() . DS . 'testme');
     $Folder->cd('testme');
     $result = $Folder->find('paths\\.php');
     $expected = [];
     $this->assertSame($expected, $result);
     $Folder->cd($Folder->pwd() . '/..');
     $result = $Folder->find('paths\\.php');
     $expected = ['paths.php'];
     $this->assertSame($expected, $result);
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:41,代码来源:FolderTest.php

示例11: migrationData

 /**
  * Path to migration folder.
  *
  * @param $path
  * @return array
  */
 public static function migrationData($path)
 {
     $data = [];
     $dir = new Folder($path);
     $files = $dir->find('.*\\.php');
     if (!empty($files)) {
         foreach ($files as $file) {
             $_fileName = str_replace('.php', '', $file);
             $segments = explode('_', $_fileName);
             $version = $segments[0];
             unset($segments[0]);
             $class = Inflector::camelize(implode('_', $segments));
             $data[$version] = ['class' => $class, 'path' => $path . DS . $file];
         }
     }
     return $data;
 }
开发者ID:Cheren,项目名称:union,代码行数:23,代码来源:Plugin.php

示例12: loadConfig

 /**
  * Loads the configuration files and populates the array
  *
  * @return void
  */
 public function loadConfig()
 {
     // Load Yaml lib
     if (empty($this->_Spyc)) {
         $this->_Spyc = new Spyc();
     }
     $template = Configure::read('Sb.template');
     // Fetch the correct template
     $this->log("\"{$template}\" template is being used.", 'info', 1);
     $this->_template = $template;
     // Search for config files
     $configDir = $this->getConfigPath($template);
     $this->log("Template dir is '{$configDir}'.", 'info');
     $dir = new Folder($configDir);
     $configFiles = $dir->find('(?!_).*\\.yml');
     // Load config files
     foreach ($configFiles as $file) {
         // Opening file and converting YAML content to PHP array
         $this->log("Loading file: \"{$file}\"...", 'info', 1);
         $this->_config = array_merge_recursive($this->_config, $this->_Spyc->YAMLLoad($configDir . $file));
     }
     $this->populate();
 }
开发者ID:el-cms,项目名称:Sb,代码行数:28,代码来源:Sbc.php

示例13: getNginxFiles

 /**
  * Return an simple array with all Nginx site files found in /etc/nginx/sites-available.
  *
  * @return array Simple array with found filenames
  */
 public function getNginxFiles()
 {
     $dir = new Folder($this->webserverMeta['nginx']['sites-available']);
     return $dir->find('.*', 'sort');
 }
开发者ID:alt3,项目名称:cakebox-console,代码行数:10,代码来源:CakeboxInfo.php

示例14: getControllersForApp

 /**
  * Retrieve all controller names + paths for the app src.
  *
  * @return array
  */
 public function getControllersForApp()
 {
     $controllers = [];
     $ctrlFolder = new Folder();
     /** @var Folder $ctrlFolder */
     $ctrlFolder->cd(ROOT . DS . 'src' . DS . 'Controller');
     if (!empty($ctrlFolder)) {
         $files = $ctrlFolder->find('.*Controller\\.php$');
         $subLength = strlen('Controller.php');
         foreach ($files as $f) {
             $filename = basename($f);
             if ($filename === 'AppController.php') {
                 continue;
             }
             $ctrlName = substr($filename, 0, strlen($filename) - $subLength);
             $controllers[] = ['name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f];
         }
         $subFolders = $ctrlFolder->read(true, false, true)[0];
         foreach ($subFolders as $subFolder) {
             $ctrlFolder->cd($subFolder);
             $files = $ctrlFolder->find('.*Controller\\.php$');
             $subLength = strlen('Controller.php');
             foreach ($files as $f) {
                 $filename = basename($f);
                 if ($filename === 'AppController.php') {
                     continue;
                 }
                 $ctrlName = substr($filename, 0, strlen($filename) - $subLength);
                 $controllers[] = ['name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f];
             }
         }
     }
     return $controllers;
 }
开发者ID:wasabi-cms,项目名称:core,代码行数:39,代码来源:GuardianComponent.php

示例15: _includeComponents

 /**
  * Includes the needed components
  *
  * @return void
  */
 protected function _includeComponents()
 {
     // for now, we just include all components
     $appComponentFolder = WWW_ROOT . 'js/app/components/';
     $folder = new Folder($appComponentFolder);
     $files = $folder->find('.*\\.js');
     if (!empty($files)) {
         foreach ($files as $file) {
             $this->_dependencies[] = 'app/components/' . $file;
         }
     }
     // Add Plugin Components
     foreach (Plugin::loaded() as $pluginName) {
         $pluginJsComponentsFolder = Plugin::path($pluginName) . '/webroot/js/app/components/';
         if (is_dir($pluginJsComponentsFolder)) {
             $folder = new Folder($pluginJsComponentsFolder);
             $files = $folder->find('.*\\.js');
             foreach ($files as $file) {
                 $this->_dependencies[] = '/' . Inflector::underscore($pluginName) . '/js/app/components/' . $file;
             }
         }
     }
 }
开发者ID:codekanzlei,项目名称:cake-frontend-bridge,代码行数:28,代码来源:FrontendBridgeHelper.php


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