Skip to content

Instantly share code, notes, and snippets.

@opdavies
Last active November 18, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opdavies/f902b7f4bb2e92dce1be to your computer and use it in GitHub Desktop.
Save opdavies/f902b7f4bb2e92dce1be to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\Finder\Finder;
/**
* Implements hook_views_default_views().
*/
function MYMODULE_views_default_views() {
// Find all .view.inc files in a the views/ directory, and include them.
$finder = new Finder();
$finder->files()->name('*.view.inc')->in(__DIR__ . '/views');
$views = array();
foreach ($finder as $file) {
require $file->getRealPath();
if (isset($view)) {
$views[$view->name] = $view;
}
}
return $views;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment