Reverse-finds all files and directories with a given name/subpath

@param string  $name
@param boolean $reload
@param string  $type
1926
public function findAllReversed($name, $reload = false, $type = 'all')
	{
		return $this->findAll($name, $reload, true, $type);
	}
707226
public function delete($name, $type = '')
    {
        $legacyKernel = Eresus_Kernel::app()->getLegacyKernel();
        $filename = $legacyKernel->froot . 'templates/';
        if ($type)
        {
            $filename .= "$type/";
        }
        $filename .= "$name.html";
        $result = filedelete($filename);
        return $result;
    }
755456
public function removeMigrationFile($name, $type)
    {
        $class_name = $this->getMigrationName($type, $name);

        $removed = false;
        $migration_file = $this->getMigrationPath().$class_name.'.php';
        if (file_exists($migration_file)) {
            if (unlink($migration_file)) {
                $removed = true;
                $migration = $this->modx->getObject($this->blend_class_object, ['name' => $class_name]);
                if (is_object($migration) && $migration->remove()) {
                    $this->out($class_name.' migration has been removed from the blend_migrations table', Blender::VERBOSITY_VERY_VERBOSE);

                }
            } else {
                $this->outError($class_name.' migration has not been removed from the blend_migrations table');
            }

        } else {
            $this->outError($this->getMigrationPath().$class_name.'.php migration could not be found to remove');
        }

        return $removed;
    }
920013
public function deleteRole(string $type, string $name): WebAclRule {
        self::checkRoleType($type);
        unset($this->roles[$type][$name]);
        return $this;
    }
530929
public static function find($name)
    {
        if (!is_dir(DOCROOT.PLUGIN_DIR.DIRECTORY_SEPARATOR.$name)) return false;
        if (!file_exists(DOCROOT.PLUGIN_DIR.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.PLUGIN_INFO)) return false;
        return new self($name);
    }
246959
public function exportFileAction($type, $name)
    {
        $server = $this->ldap->get($name);
        $server['userPassword'] = 'userpassword';
        $user = isset($server['user']) ? $server['user'] : null;
        $password = isset($server['password']) ? $server['password'] : null;

        if ($this->ldap->userMapping($server) && $this->ldap->connect($server, $user, $password)) {
            $users = $this->ldap->getUsers($server);
            $this->ldap->close();
            $response = new response(
                $this->templating->render(
                    'ClarolineAuthenticationBundle:export:'.$type.'.html.twig',
                    ['users' => $users, 'server' => $server]
                )
            );
        } else {
            $response = new Response('Error');
        }

        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename='.$name.'.'.$type);
        $response->headers->set('Connection', 'close');

        return $response;
    }
726884
private function loadHelper(string $name): void
    {
        $class = static::class;

        // Somebody forgot to call `addHelperPath`
        if (!isset(static::$helpersPath[$class])) {
            throw new CommonException("Helper path not found for class `$class`");
        }

        // Try to find helper file
        foreach (static::$helpersPath[$class] as $path) {
            if ($helperPath = realpath($path . '/' . ucfirst($name) . '.php')) {
                $this->addHelper($name, $helperPath);
                return;
            }
        }

        throw new CommonException("Helper `$name` not found for class `$class`");
    }
1092527
protected function loadDefaultValues($name, $type = 'metadata')
    {
        $defaultValue = $this->getFileManager()->getContents(array($this->pathToDefaults, $type, $name.'.json') );
        if ($defaultValue !== false) {
            if ($this->useObjects) {
                return Utils\Json::decode($defaultValue);
            } else {
                return Utils\Json::decode($defaultValue, true);
            }
        }
        if ($this->useObjects) {
            return (object) [];
        } else {
            return array();
        }
    }
192417
protected static function _run($name, $type)
	{
		// -v or --version
		$version = \Cli::option('v', \Cli::option('version', ''));

		// version is used as a flag, so show it
		if ($version === true)
		{
			\Cli::write('Currently installed migrations for '.$type.':'.$name.':', 'green');

			foreach (\Config::get('migrations.version.'.$type.'.'.$name, array()) as $version)
			{
				\Cli::write('- '.$version);
			}
			return;
		}

		// version contains a timestamp of sorts
		elseif ($version !== '')
		{
			// if version has a value, make sure only 1 item was passed
			if (static::$default + static::$module_count + static::$package_count > 1)
			{
				\Cli::write('Migration: version only accepts 1 item.');
				return;
			}
			$migrations = \Migrate::version($version, $name, $type, \Cli::option('catchup', false));
		}

		// migrate to the latest version
		else
		{
			$migrations = \Migrate::latest($name, $type, \Cli::option('catchup', false));
		}

		// any migrations executed?
		if ($migrations)
		{
			\Cli::write('Performed migrations for '.$type.':'.$name.':', 'green');

			foreach ($migrations as $migration)
			{
				\Cli::write($migration);
			}
		}
		else
		{
			if ($migrations === false)
			{
				\Cli::write('Some migrations where skipped for '.$type.':'.$name.'. Please re-run the migrations.', 'cyan');
			}
			elseif ($version !== '')
			{
				\Cli::write('No migrations were found for '.$type.':'.$name.'.');
			}
			else
			{
				\Cli::write('Already on the latest migration for '.$type.':'.$name.'.');
			}
		}
	}
962408
private function findPartialFile($name)
    {
        foreach ($this->partialDirs as $dir) {
            $file = $this->createPartialPath($dir, $name);

            if (is_file($file)) {
                return $file;
            }
        }

        return false;
    }
1344368
function preload(gpath, type) {
  glob.sync(gpath).forEach(function(file) {
    walk(file, type, null, require);
  });
}
1080052
private function doLoadMetadata($type)
    {
        if (null !== $meta = $this->getFromMemory($type)) {
            // Found in memory.
            return $meta;
        }

        if (null !== $meta = $this->getFromCache($type)) {
            // Found in cache.
            $this->setToMemory($meta);
            return $meta;
        }
        return null;
    }
150626
public static function getInstallPath($type, $name)
    {
        $locator = Grav::instance()['locator'];

        if ($type === 'theme') {
            $install_path = $locator->findResource('themes://', false) . DS . $name;
        } else {
            $install_path = $locator->findResource('plugins://', false) . DS . $name;
        }
        return $install_path;
    }
1062731
public function hasRoute(string $type, string $name): bool{
        return (isset($this->routes[$name]) && isset($this->routes[$name][$type]));
    }
626939
def reload_extensions_dir path
    loaded = Set.new(typenames.select { |x| @namespace.const_defined? x })
    Dir.open(path) do |dir|
      dir.each do |file|
        next unless file =~ /\.rb$/
        next unless loaded.member? $`
        file_path = File.join(dir, file)
        load file_path
      end
    end
  end
780518
private function findFile($name, $ext)
	{
		if (null === $ext)
			$ext = $this->default_ext;
		$basename = basename($name);
		$type = $this->getTypeForExt($ext);

		if (isset(self::$files[$this->prefix][$type][$name])
		 && file_exists($file = self::$files[$this->prefix][$type][$name]))
			return $file;

		foreach ($this->paths as $path)
		{
			$prefixes = isset($path['prefixes']) ? $path['prefixes'] : array();
			$prefix = isset($prefixes[$type]) ? $prefixes[$type] . '/' : '';

			foreach ($path['directories'] as $directory)
			{
				$files = glob(rtrim($directory, '/') . '/' . $prefix . $name . '.*');
				if (!$files) // no file found
					continue;

				foreach ($files as $file)
				{
					list($found_name, $found_ext) = $this->getNameAndExtension($file);
					
					if ($basename != basename($found_name) || $ext != $found_ext)
						continue;

					self::$files[$this->prefix][$ext][$name] = $file;
					self::$file_added = true;

					return self::$files[$this->prefix][$ext][$name];
				}
			}
		}

		return null;
	}
457910
public function delete(String $name, String $type = 'controller', String $app = NULL) : Bool
    {
        if( ! empty($app) )
        {
            $this->settings['application'] = $app;
        }

        $file = $this->path($name, $type);

        if( is_file($file) )
        {
            return unlink($file);
        }

        return false;
    }