public function postClearCacheAction($all) { # delete the cache for all sites or just the current site # depending on the flag in the url $cacheDir = $all == 'all' ? $this->app['cache_dir'] . '/..' : $this->app['cache_dir']; $files = Symfony\Component\Finder\Finder::create()->files()->name('*')->in($cacheDir); foreach ($files as $file) { try { unlink($file->getRealPath()); } catch (\Exception $e) { # @TODO error logging, more response info return $this->app->json(array('success' => false)); } } return $this->app->json(array('success' => true)); }
<?php // Prevent e.g. 'Notice: Constant MATH_BIGINTEGER_MONTGOMERY already defined'. class MyArrayStore extends Sami\Store\ArrayStore { public function removeClass(Sami\Project $project, $name) { unset($this->classes[$name]); } } $iterator = Symfony\Component\Finder\Finder::create()->files()->name('*.php')->in(__DIR__ . '/../phpseclib/'); $versions = Sami\Version\GitVersionCollection::create(__DIR__ . '/../')->add('1.0')->add('2.0')->add('master'); return new Sami\Sami($iterator, array('theme' => 'enhanced', 'versions' => $versions, 'title' => 'phpseclib API Documentation', 'build_dir' => __DIR__ . '/api/output/%version%', 'cache_dir' => __DIR__ . '/api/cache/%version%', 'default_opened_level' => 2, 'store' => new MyArrayStore()));
<?php $dir = __DIR__ . '/../src'; $iterator = Symfony\Component\Finder\Finder::create()->files()->name('*.php')->in($dir); $options = ['theme' => 'default', 'title' => 'Laravel Tactician API Documentation', 'build_dir' => __DIR__ . '/../build/laravelTactician', 'cache_dir' => __DIR__ . '/../cache/laravelTactician']; $sami = new Sami\Sami($iterator, $options); return $sami;
/** * Internal routine for deleting thumbnails. * * @param string $source Directory to cleanup/clear * @param bool $pattern Filename patter * @param bool $force Set to true to delete all thumbnails * * @return SystemPlugin_Imagine_Manager */ private function removeFiles($source, $pattern = false, $force = false) { if (file_exists($source)) { $files = Symfony\Component\Finder\Finder::create()->files(); if ($pattern) { $files = $files->name($pattern); } $files = $files->in($source); foreach ($files as $file) { $unlink = true; if (!$force) { $sourceImage = base64_decode(basename($file->getPath()), true); $unlink = !file_exists($sourceImage); } if ($unlink) { unlink($file); } } // try to remove empty dirs $directories = Symfony\Component\Finder\Finder::create()->directories()->in($source); $dirs = array(); foreach ($directories as $dir) { $dirs[] = $dir; } foreach (array_reverse($dirs) as $dir) { @rmdir($dir); } // try to remove also source dir but not if it's base thumb dir if ($source != $this->getThumbDir()) { @rmdir($source); } } return $this; }
<?php /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ /* * Include module factory definitions */ $finder = Symfony\Component\Finder\Finder::create()->files()->path('/\\/Database\\//')->name('ModelFactory.php')->contains('$factory->define(')->in(base_path('app/Modules')); foreach ($finder as $factoryFile) { /** @noinspection PhpIncludeInspection */ include $factoryFile->getRealPath(); }
<?php /** * * This file is part of the phpBB Forum Software package. * * @copyright (c) phpBB Limited <https://www.phpbb.com> * @license GNU General Public License, version 2 (GPL-2.0) * * For full copyright and license information, please see * the docs/CREDITS.txt file. * */ // Prevent 'Class "acm" does not exist.' exception on removeClass(). class PhpbbArrayStore extends Sami\Store\ArrayStore { public function removeClass(Sami\Project $project, $name) { unset($this->classes[$name]); } } $iterator = Symfony\Component\Finder\Finder::create()->files()->name('*.php')->in(__DIR__ . '/../phpBB/')->notPath('#^cache/#')->notPath('#^develop/#')->notPath('#^ext/#')->notPath('#^vendor/#')->notPath('data'); $config = array('theme' => 'enhanced', 'title' => 'phpBB API Documentation', 'build_dir' => __DIR__ . '/api/output/%version%', 'cache_dir' => __DIR__ . '/api/cache/%version%', 'default_opened_level' => 2, 'store' => new PhpbbArrayStore()); return new Sami\Sami($iterator, $config);
<?php $dir = __DIR__ . '/src'; $iterator = Symfony\Component\Finder\Finder::create()->files()->name('*.php')->exclude('DataFixtures')->exclude('Resources')->exclude('Tests')->in($dir); $options = ['theme' => 'default', 'title' => 'Elcodi API Documentation', 'build_dir' => __DIR__ . '/../gh-pages', 'cache_dir' => __DIR__ . '/../gh-pages_cache']; $sami = new Sami\Sami($iterator, $options); return $sami;