本文整理汇总了PHP中Finder类的典型用法代码示例。如果您正苦于以下问题:PHP Finder类的具体用法?PHP Finder怎么用?PHP Finder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Finder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testFilenameListIsGenerated
/**
* @requires PHP 5.6
*/
public function testFilenameListIsGenerated()
{
$sfFinder = $this->getMockBuilder('\\Symfony\\Component\\Finder\\Finder')->disableOriginalConstructor()->getMock();
$filesystem = $this->getMockBuilder('\\Helmich\\TypoScriptLint\\Util\\Filesystem')->disableOriginalConstructor()->getMock();
$fib = $this->getMockBuilder('SplFileInfo')->disableOriginalConstructor();
$fi1 = $fib->getMock();
$fi1->expects($this->any())->method('isFile')->willReturn(FALSE);
$fi2 = $fib->getMock();
$fi2->expects($this->any())->method('isFile')->willReturn(TRUE);
$fi3 = $fib->getMock();
$fi3->expects($this->any())->method('isFile')->willReturn(TRUE);
$fi4 = $fib->getMock();
$fi4->expects($this->any())->method('getPathname')->willReturn('directory/file3');
$fi5 = $fib->getMock();
$fi5->expects($this->any())->method('getPathname')->willReturn('directory/file4');
$sfFinder->expects($this->once())->method('files')->willReturnSelf();
$sfFinder->expects($this->once())->method('in')->with('directory');
$sfFinder->expects($this->once())->method('getIterator')->willReturn(new \ArrayObject([$fi4, $fi5]));
$finder = new Finder($sfFinder, $filesystem);
$filesystem->expects($this->at(0))->method('openFile')->with('directory')->willReturn($fi1);
$filesystem->expects($this->at(1))->method('openFile')->with('file1')->willReturn($fi2);
$filesystem->expects($this->at(2))->method('openFile')->with('file2')->willReturn($fi3);
$filenames = $finder->getFilenames(['directory', 'file1', 'file2']);
$this->assertEquals(['directory/file3', 'directory/file4', 'file1', 'file2'], $filenames);
}
开发者ID:hexa2k9,项目名称:typo3-typoscript-lint,代码行数:28,代码来源:FinderTest.php
示例2: testClearCache
public function testClearCache()
{
$dir = Renderer::getCacheDir();
Renderer::clearCache();
$finder = new Finder();
$finder->files()->name('*.php')->in($dir);
$this->assertEquals(0, $finder->count());
}
开发者ID:a11enwong,项目名称:pochika,代码行数:8,代码来源:RendererTest.php
示例3: addFinder
public function addFinder(Finder $finder)
{
if (!empty($this->finders[$finder->getName()])) {
throw new ServiceBuilderException("Duplicate finder name '{$finder->getName()}' for entity '{$this->name}'");
}
foreach ($finder->getColumns() as $finderColumn) {
if (empty($this->properties[$finderColumn->getName()])) {
//throw new ServiceBuilderException("Finder column '{$finderColumn->getName()}' is not a property for entity '$this->name'");
}
}
$this->finders[$finder->getName()] = $finder;
}
开发者ID:aeberh,项目名称:php-movico,代码行数:12,代码来源:Entity.php
示例4: delete
/**
* Deletes a directory
*
* @param boolean $recursive
*
* @return boolean
*/
public function delete($recursive = false)
{
if (!$recursive) {
return parent::delete();
}
$finder = new Finder();
$contents = $finder->listContents($this->path);
foreach ($contents as $item) {
$item->delete(true);
}
return parent::delete();
}
开发者ID:fuelphp,项目名称:filesystem,代码行数:19,代码来源:Directory.php
示例5: main
function main()
{
$fridge_csv_path = isset($argv[1]) ? $argv[1] : 'fridge.csv';
$recipe_json_path = isset($argv[2]) ? $argv[2] : 'recipes.js';
$ingredients = array_map('str_getcsv', file($fridge_csv_path));
$recipes = json_decode(file_get_contents($recipe_json_path), 1);
$fridge = new Fridge();
$fridge->fillFromArray($ingredients);
$finder = new Finder($fridge);
$recipeToday = $finder->findRecipe($recipes);
echo $recipeToday . "\n";
}
开发者ID:y2khjh,项目名称:test1,代码行数:12,代码来源:Main.php
示例6: getThemes
protected function getThemes()
{
$themes = array();
$dir = $this->container->getParameter('kernel.root_dir') . '/../web/themes';
$finder = new Finder();
foreach ($finder->directories()->in($dir)->depth('== 0') as $directory) {
$theme = $this->getTheme($directory->getBasename());
if ($theme) {
$themes[] = $theme;
}
}
return $themes;
}
开发者ID:robert-li-2015,项目名称:EduSoho,代码行数:13,代码来源:ThemeServiceTest.php
示例7: collectGarbage
/**
* Randomly runs garbage collection on the image directory
*
* @return bool
*/
public function collectGarbage()
{
if (!mt_rand(1, $this->gcFreq) == 1) {
return false;
}
$this->createFolderIfMissing();
$finder = new Finder();
$criteria = sprintf('<= now - %s minutes', $this->expiration);
$finder->in($this->webPath . '/' . $this->imageFolder)->date($criteria);
foreach ($finder->files() as $file) {
unlink($file->getPathname());
}
return true;
}
开发者ID:ivytin,项目名称:re_web,代码行数:19,代码来源:ImageFileHandler.php
示例8: testFindRecipeFunction
public function testFindRecipeFunction()
{
$fridge = $this->getFridge();
$idealRecipes = $this->getRecipesData();
$finder = new Finder($fridge);
$result1 = $finder->findRecipe($idealRecipes);
$this->assertEquals($result1, 'grilled cheese on toast');
$newRecipe2 = array('name' => 'extra cheese and peanut butter on bread', 'ingredients' => array(0 => array('item' => 'bread', 'amount' => '2', 'unit' => 'slices'), 1 => array('item' => 'cheese', 'amount' => '10', 'unit' => 'slices'), 2 => array('item' => 'peanut butter', 'amount' => '250', 'unit' => 'grams')));
$result2 = $finder->findRecipe(array_merge($idealRecipes, array($newRecipe2)));
$this->assertEquals($result2, 'extra cheese and peanut butter on bread');
$newRecipe3 = array('name' => 'expired salad', 'ingredients' => array(0 => array('item' => 'mixed salad', 'amount' => '200', 'unit' => 'grams')));
$result3 = $finder->findRecipe(array($newRecipe3));
$this->assertEquals($result3, 'Order Takeout');
}
开发者ID:y2khjh,项目名称:test1,代码行数:14,代码来源:FinderTest.php
示例9: zipFiles
/**
* Zip files
*
* @param string $targetDir Target dir path
* @param array $files Files to zip
*
* @throws \Exception
*/
private function zipFiles($targetDir, $files)
{
$zip = new \ZipArchive();
$zipName = pathinfo($files[0], PATHINFO_FILENAME);
$zipPath = FileSystem::getUniquePath($targetDir . DIRECTORY_SEPARATOR . $zipName . ".zip");
if ($zip->open($zipPath, \ZipArchive::CREATE)) {
foreach ($files as $file) {
$path = $targetDir . DIRECTORY_SEPARATOR . $file;
if (is_dir($path)) {
$zip->addEmptyDir($file);
foreach (Finder::find("*")->from($path) as $item) {
$name = $file . DIRECTORY_SEPARATOR . substr_replace($item->getPathname(), "", 0, strlen($path) + 1);
if ($item->isDir()) {
$zip->addEmptyDir($name);
} else {
$zip->addFile($item->getRealPath(), $name);
}
}
} else {
$zip->addFile($path, $file);
}
}
$zip->close();
} else {
throw new \Exception("Can not create ZIP archive '{$zipPath}' from '{$targetDir}'.");
}
}
开发者ID:ixtrum,项目名称:file-manager-plugins,代码行数:35,代码来源:Zip.php
示例10: getWriteDisplay
/**
* show the data in an input element for editing
*
* @return string
*/
protected function getWriteDisplay()
{
$selectedOptionNames = explode(', ', $this->value);
$output = Html::startTag('div', ['class' => $this->class]);
$connectedClassName = $this->fieldinfo->getConnectedClass();
/** @var BaseConnectionObject $connObj */
$connObj = new $connectedClassName();
$class = $connObj->getOtherClass($this->fieldinfo->getClass());
$obj = Factory::createObject($class);
$connectedFieldName = $this->fieldinfo->getFieldsOfConnectedClass();
$table = DB::table($obj->getTable());
$result = Finder::create($class)->find([$table->getColumn($connectedFieldName), $table->getColumn('LK')]);
foreach ($result as $row) {
$params = [];
$params['value'] = $row['LK'];
$params['type'] = 'checkbox';
$params['class'] = 'checkbox';
$params['name'] = $this->name . '[]';
if (in_array($row[$connectedFieldName], $selectedOptionNames)) {
$params['checked'] = 'checked';
}
$output .= Html::startTag('p') . Html::singleTag('input', $params) . " " . $row[$connectedFieldName] . Html::endTag('p');
}
$output .= Html::endTag('div');
return $output;
}
开发者ID:kafruhs,项目名称:fws,代码行数:31,代码来源:MnConnection.php
示例11: testJoinNtoN
public function testJoinNtoN()
{
$finder = Finder::like()->like_user->user;
$schema = new Schemas\Infered();
$query = $schema->generateQuery($finder);
$this->assertEquals('SELECT like.*, like_user.*, user.* FROM like INNER JOIN like_user ON like_user.like_id = like.id INNER JOIN user ON like_user.user_id = user.id', (string) $query);
}
开发者ID:rogeriopradoj,项目名称:Relational,代码行数:7,代码来源:FinderTest.php
示例12: save
/**
* Formats the output and saved it to disc.
*
* @param string $identifier filename
* @param $contents $contents language array to save
* @return bool \File::update result
*/
public function save($identifier, $contents)
{
// store the current filename
$file = $this->file;
// save it
$return = parent::save($identifier, $contents);
// existing file? saved? and do we need to flush the opcode cache?
if ($file == $this->file and $return and static::$flush_needed) {
if ($this->file[0] !== '/' and (!isset($this->file[1]) or $this->file[1] !== ':')) {
// locate the file
if ($pos = strripos($identifier, '::')) {
// get the namespace path
if ($file = \Autoloader::namespace_path('\\' . ucfirst(substr($identifier, 0, $pos)))) {
// strip the namespace from the filename
$identifier = substr($identifier, $pos + 2);
// strip the classes directory as we need the module root
$file = substr($file, 0, -8) . 'lang' . DS . $identifier;
} else {
// invalid namespace requested
return false;
}
} else {
$file = \Finder::search('lang', $identifier);
}
}
// make sure we have a fallback
$file or $file = APPPATH . 'lang' . DS . $identifier;
// flush the opcode caches that are active
static::$uses_opcache and opcache_invalidate($file, true);
static::$uses_apc and apc_compile_file($file);
}
return $return;
}
开发者ID:takawasitobi,项目名称:pembit,代码行数:40,代码来源:php.php
示例13: config
public static function config($args, $build = true)
{
$args = self::_clear_args($args);
$file = strtolower(array_shift($args));
$config = array();
// load the config
if ($paths = \Finder::search('config', $file, '.php', true)) {
// Reverse the file list so that we load the core configs first and
// the app can override anything.
$paths = array_reverse($paths);
foreach ($paths as $path) {
$config = \Fuel::load($path) + $config;
}
}
unset($path);
// We always pass in fields to a config, so lets sort them out here.
foreach ($args as $conf) {
// Each paramater for a config is seperated by the : character
$parts = explode(":", $conf);
// We must have the 'name:value' if nothing else!
if (count($parts) >= 2) {
$config[$parts[0]] = $parts[1];
}
}
$overwrite = \Cli::option('o') or \Cli::option('overwrite');
$content = <<<CONF
<?php
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
*
* @package\t\tFuel
* @version\t\t1.0
* @author\t\tFuel Development Team
* @license\t\tMIT License
* @copyright\t2011 Fuel Development Team
* @link\t\thttp://fuelphp.com
*/
CONF;
$content .= 'return ' . str_replace(' ', "\t", var_export($config, true)) . ';';
$content .= <<<CONF
/* End of file {$file}.php */
CONF;
$path = APPPATH . 'config' . DS . $file . '.php';
if (!$overwrite and is_file($path)) {
throw new Exception("APPPATH/config/{$file}.php already exist, please use -overwrite option to force update");
}
$path = pathinfo($path);
try {
\File::update($path['dirname'], $path['basename'], $content);
\Cli::write("Created config: APPPATH/config/{$file}.php", 'green');
} catch (\InvalidPathException $e) {
throw new Exception("Invalid basepath, cannot update at " . APPPATH . "config" . DS . "{$file}.php");
} catch (\FileAccessException $e) {
throw new Exception(APPPATH . "config" . DS . $file . ".php could not be written.");
}
}
开发者ID:reganhimself,项目名称:KeeleProgrammers,代码行数:60,代码来源:generate.php
示例14: process_form
private function process_form()
{
$domain = Request::getPost('domain');
if (strlen($domain) < 1) {
return;
}
$this->set_body('form_success', true);
$url = CrawlerURL::instance($domain);
$domain = $url->getDomain();
$link = "{$domain}/";
$domainObject = Finder::instance('Domain')->setNameFilter($domain)->getDomain();
if (!$domainObject) {
$domainObject = Mutator::instance('Domain', 'Create')->setData($domain)->execute();
}
$linkObject = Finder::instance('Link')->setNameFilter($link)->getLink();
if (!$linkObject) {
$linkObject = Mutator::instance('Link', 'Create')->setData($link)->execute();
}
$crawlSiteQueueObject = Finder::instance('CrawlSiteQueue')->setDomainFilter($domainObject->getID())->setStatusFilter(CrawlSiteQueue::$IS_UNCRAWLED)->getCrawlSiteQueue();
if (!$crawlSiteQueueObject) {
Mutator::instance('CrawlSiteQueue', 'Create')->setData($domainObject, CrawlSiteQueue::$IS_UNCRAWLED)->execute();
}
$crawlPageQueueObject = Finder::instance('CrawlPageQueue')->setDomainFilter($domainObject->getID())->setLinkFilter($linkObject->getID())->setStatusFilter(CrawlPageQueue::$IS_UNCRAWLED)->getCrawlPageQueue();
if (!$crawlPageQueueObject) {
Mutator::instance('CrawlPageQueue', 'Create')->setData($domainObject, $linkObject, CrawlPageQueue::$IS_UNCRAWLED)->execute();
}
}
开发者ID:jacobemerick,项目名称:crawler,代码行数:27,代码来源:HomeController.class.inc.php
示例15: load
public function load($resource, $type = null)
{
if (true === $this->loaded) {
throw new \RuntimeException('Do not add this loader twice');
}
//$modules = $this->doctrine->getRepository('MaximCMSBundle:Module')->findBy(array("activated" => 1));
$collection = new RouteCollection();
/* FIND ROUTING FILES IN BUNDLES AND LOAD THOSE */
$exclude = array("CMSBundle", "InstallBundle", "AdminBundle");
$names = array("routing.yml", "routing_admin.yml");
for ($i = 0; $i < count($names); $i++) {
$finder = new Finder();
$finder->name($names[$i]);
foreach ($finder->in(__DIR__ . "/../../")->exclude($exclude) as $file) {
$locator = new FileLocator(array(substr($file, 0, count($file) - (strlen($names[$i]) + 1))));
$loader = new YamlFileLoader($locator);
$collection->addCollection($loader->load($names[$i]));
}
}
return $collection;
/*if (true === $this->loaded) {
throw new \RuntimeException('Do not add this loader twice');
}
$collection = new RouteCollection();
echo "hi";
// get all Bundles
$bundles = $this->container->getParameter('kernel.bundles');
foreach($bundles as $bundle) {
if(isset($bundle)) {
echo $bundle;
}
}
/*$resource = '@AcmeDemoBundle/Resources/config/import_routing.yml';
$type = 'yaml';
$importedRoutes = $this->import($resource, $type);
$collection->addCollection($importedRoutes);
return $collection; */
}
开发者ID:c4d3r,项目名称:mcsuite-application-eyeofender,代码行数:46,代码来源:RoutingLoader.php
示例16: getInstalledPhps
/**
* @return array
*/
public static function getInstalledPhps()
{
static $phps;
if (!isset($phps)) {
$phps = [];
$finder = new Finder();
$finder->directories()->in('/opt/phpbrew/php')->depth('== 0');
foreach ($finder as $file) {
$phpbin = $file->getPathname() . '/bin/php';
if (!file_exists($phpbin)) {
continue;
}
$phps[] = $file->getFilename();
}
}
return $phps;
}
开发者ID:maxdmyers,项目名称:dashbrew,代码行数:20,代码来源:Util.php
示例17: load
/**
* Loads a view as a string
* Used by Base_Controller->render() method to load a view
*
* @param string View name to load
* @param sring Directory where is the view
*
* @return string The load view
*
*/
public static function load($name, $directory = 'views')
{
$file = Finder::find_file($name, $directory, true);
if (empty($file)) {
show_error('Theme error : <b>The file "' . $directory . '/' . $name . '" cannot be found.</b>');
}
$string = file_get_contents(array_shift($file));
return $string;
}
开发者ID:pompalini,项目名称:emngo,代码行数:19,代码来源:Theme.php
示例18: all
/**
* {@inheritdoc}
*/
public function all() : MapInterface
{
$files = Finder::create()->in($this->path);
$map = new Map('string', FileInterface::class);
foreach ($files as $file) {
$map = $map->put($file->getRelativePathname(), $this->get($file->getRelativePathname()));
}
return $map;
}
开发者ID:innmind,项目名称:filesystem,代码行数:12,代码来源:FilesystemAdapter.php
示例19: setData
/**
* set data
*/
public function setData()
{
$obj = Factory::createObject('News');
$table = DB::table($obj->getTable());
$limit = new base_database_Limit(10);
$order = DB::order($table->getColumn('firstEditTime'));
$finder = Finder::create('news')->setOrder($order)->setlimit($limit);
$this->data = $finder->find();
}
开发者ID:kafruhs,项目名称:fws,代码行数:12,代码来源:Model.php
示例20: find_file
/**
* Finds the given config files
*
* @param bool $multiple Whether to load multiple files or not
* @return array
*/
protected function find_file()
{
$paths = \Finder::search('config', $this->file, $this->ext, true);
$paths = array_merge(\Finder::search('config/' . \Fuel::$env, $this->file, $this->ext, true), $paths);
if (count($paths) > 0) {
return array_reverse($paths);
}
throw new \ConfigException(sprintf('File "%s" does not exist.', $this->file));
}
开发者ID:reganhimself,项目名称:KeeleProgrammers,代码行数:15,代码来源:file.php
注:本文中的Finder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论