You are here

interface InjectedApiInterface in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/ClassFinder/InjectedApi/InjectedApiInterface.php \Drupal\xautoload\ClassFinder\InjectedApi\InjectedApiInterface

To help testability, we use an injected API instead of just a return value. The injected API can be mocked to provide a mocked file_exists(), and to monitor all suggested candidates, not just the correct return value.

Hierarchy

Expanded class hierarchy of InjectedApiInterface

All classes that implement InjectedApiInterface

3 files declare their use of InjectedApiInterface
FinderPluginInterface.php in lib/ClassFinder/Plugin/FinderPluginInterface.php
GenericPrefixMap.php in lib/ClassFinder/GenericPrefixMap.php
Interface.php in legacy/lib/FinderPlugin/Interface.php

File

lib/ClassFinder/InjectedApi/InjectedApiInterface.php, line 11

Namespace

Drupal\xautoload\ClassFinder\InjectedApi
View source
interface InjectedApiInterface {

  /**
   * This is done in the injected api object, so we can easily provide a mock
   * implementation.
   */
  function is_dir($dir);

  /**
   * Get the name of the class we are looking for.
   *
   * @return string
   *   The class we are looking for.
   */
  function getClass();

  /**
   * Suggest a file that, if the file exists,
   * has to declare the class we are looking for.
   * Only keep the class on success.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return bool
   *   TRUE, if the file exists.
   *   FALSE, otherwise.
   */
  function suggestFile($file);

  /**
   * Same as suggestFile(), but skip the file_exists(),
   * assuming that we already know the file exists.
   *
   * This could make sense if a plugin already did the file_exists() check.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return bool
   *   TRUE, if the file was found - which is always.
   */
  function suggestFile_skipFileExists($file);

  /**
   * Same as suggestFile(), but assume that file_exists() returns TRUE.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return bool
   *   TRUE, if the file was found - which is always.
   */
  function suggestFile_checkNothing($file);

  /**
   * Same as suggestFile(), but check the full PHP include path.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return bool
   *   TRUE, if the file exists.
   *   FALSE, otherwise.
   */
  function suggestFile_checkIncludePath($file);

  /**
   * Suggest a file that MUST exists, and that MAY declare the class we are
   * looking for.
   *
   * This is useful if a plugin already did the is_file() check by itself.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return boolean|NULL
   *   TRUE, if we are not interested in further candidates.
   *   FALSE|NULL, if we are interested in further candidates.
   */
  function guessFile($file);

  /**
   * Suggest a file that MAY exist, and that MAY declare the class we are
   * looking for.
   *
   * This is useful if a plugin already did the is_file() check by itself.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return boolean|NULL
   *   TRUE, if we are not interested in further candidates.
   *   FALSE|NULL, if we are interested in further candidates.
   */
  function guessPath($file);

  /**
   * Suggest a file that MUST exist, and if so, MUST declare the class we are
   * looking for.
   *
   * This is useful if a plugin already did the is_file() check by itself.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return boolean|NULL
   *   TRUE, if we are not interested in further candidates.
   *   FALSE|NULL, if we are interested in further candidates.
   */
  function claimFile($file);

  /**
   * Suggest a file that MAY exist, and if so, MUST declare the class we are
   * looking for.
   *
   * This is useful if a plugin already did the is_file() check by itself.
   *
   * @param string $file
   *   The file that is supposed to declare the class.
   *
   * @return boolean|NULL
   *   TRUE, if we are not interested in further candidates.
   *   FALSE|NULL, if we are interested in further candidates.
   */
  function claimPath($file);

}

Members

Namesort descending Modifiers Type Description Overrides
InjectedApiInterface::claimFile function Suggest a file that MUST exist, and if so, MUST declare the class we are looking for. 3
InjectedApiInterface::claimPath function Suggest a file that MAY exist, and if so, MUST declare the class we are looking for. 3
InjectedApiInterface::getClass function Get the name of the class we are looking for. 1
InjectedApiInterface::guessFile function Suggest a file that MUST exists, and that MAY declare the class we are looking for. 3
InjectedApiInterface::guessPath function Suggest a file that MAY exist, and that MAY declare the class we are looking for. 3
InjectedApiInterface::is_dir function This is done in the injected api object, so we can easily provide a mock implementation. 1
InjectedApiInterface::suggestFile function Suggest a file that, if the file exists, has to declare the class we are looking for. Only keep the class on success. 3
InjectedApiInterface::suggestFile_checkIncludePath function Same as suggestFile(), but check the full PHP include path. 3
InjectedApiInterface::suggestFile_checkNothing function Same as suggestFile(), but assume that file_exists() returns TRUE. 3
InjectedApiInterface::suggestFile_skipFileExists function Same as suggestFile(), but skip the file_exists(), assuming that we already know the file exists. 3