Check if resource exists

@param string                $resource
@param \Laranix\Themer\Theme $theme
@return bool
177765
protected function exists(string $resource, Theme $theme = null) : bool
    {
        return is_file($this->getResourcePath($resource, $theme));
    }
169760
public function resource($name, $resource = null)
    {
        if ($resource) {
            $this->addResource($name, $resource);
        } else {
            return $this->getResource($name);
        }
    }
302134
public function watch($resource)
    {
        if (!$this->files->exists($resource)) {
            throw new RuntimeException('Resource must exist before you can watch it.');
        } elseif ($this->files->isDirectory($resource)) {
            $resource = new DirectoryResource(new SplFileInfo($resource), $this->files);

            $resource->setupDirectory();
        } else {
            $resource = new FileResource(new SplFileInfo($resource), $this->files);
        }

        // The listener gives users the ability to bind listeners on the events
        // created when watching a file or directory. We'll give the listener
        // to the tracker so the tracker can fire any bound listeners.
        $listener = new Listener();

        $this->tracker->register($resource, $listener);

        return $listener;
    }
227201
public static function isEmpty($resource)
    {
        if (!self::isValid($resource) &&
            null !== $resource) {
            return false;
        }

        return String::isEmpty($resource);
    }
1340961
@Override
	public boolean exists() {
		// Return false if any of the resources in this aggregated resource
		// does not exist
		boolean result = true;
		for (IResource resource : resources) {
			if (!resource.exists()) {
				result = false;
				break;
			}
		}
		return result;
	}
256603
protected function _loadResource($resource) {
        return $this->cache([__METHOD__, $resource], function() use ($resource) {
            $data = $this->getLocaleBundle()->loadResource(null, $resource);

            if ($parent = $this->getParentLocale()) {
                $data = array_merge(
                    $parent->getLocaleBundle()->loadResource(null, $resource),
                    $data
                );
            }

            return $data;
        });
    }
366440
protected function hasError($resource)
    {
        // No error if no resource
        if (empty($resource)) {
            return false;
        }

        // If the error code is empty the statement / connection has not been run yet
        $code = $resource->errorCode();
        if (empty($code)) {
            return false;
        }

        // Skip 'ok' and undefined 'warning' types.
        // @see http://docstore.mik.ua/orelly/java-ent/jenut/ch08_06.htm
        return $code !== '00000' && $code !== '01000';
    }
115762
public function exists($id)
    {
        try {
            return !!$this->resource->hExists(static::CACHE_KEY, $id);
        } catch (ConnectionException $e) {
            return false;
        }
    }
1211851
public function addTheme(ThemeInterface $theme, $key, $default = false)
    {
        $this->themes[$key] = $theme;

        if ($default) {
            $this->default = $key;
        }

        return true;
    }
803880
public static function getThemeUrl($theme, $resource, $absolute = false) {
		if ($absolute) {
			return self::$siteURL . self::ASSETS_FOLDER . $theme . '/' . $resource;
		}
		return ltrim ( self::ASSETS_FOLDER, '/' ) . $theme . '/' . $resource;
	}
231011
private function checkResources(array $resources): bool
    {
        $isValid = true;
        foreach ($resources as $key => $valueAndLocale) {
            $isValid = $isValid === true && $this->checkPair((string)$key, $valueAndLocale);
        }

        return $isValid;
    }
338728
function remove($resource)
    {
        $rid = spl_object_hash($resource);
        if (!isset($this->resourcePool[$rid]))
        {
            return false;
        }
        //从resourcePool中删除
        unset($this->resourcePool[$rid]);
        $this->resourceNum--;
        return true;
    }
551349
public function has(?string $key) : bool
    {
        return $key === null ? false : isset($this->themes[$key]);
    }
1230075
protected function resourceExists($resource)
    {
        if (!$resource) {
            return false;
        }
        if ($resource instanceof ModuleResource) {
            return $resource->exists();
        }
        $base = rtrim(Director::baseFolder(), '/');
        return file_exists($base . '/' . $resource);
    }
1319432
protected boolean resourceIsValid(CmsResource resource) {

        if (!resource.getRootPath().startsWith(m_basePath)) {
            return false;
        }
        if (m_requireFile & resource.isFolder()) {
            return false;
        }
        if (m_requireFolder & resource.isFile()) {
            return false;
        }
        return true;
    }
1329086
public function exists($template)
    {
        foreach ($this->engines as $engine) {
            if ($engine->supports($template)) {
                return $engine->exists($template);
            }
        }

        return false;
    }
327669
public static boolean doesResourceExist(final String resource, final ResourceLoader resourceLoader) {
        try {
            if (StringUtils.isNotBlank(resource)) {
                val res = resourceLoader.getResource(resource);
                return doesResourceExist(res);
            }
        } catch (final Exception e) {
            LOGGER.warn(e.getMessage(), e);
        }
        return false;
    }