Commit d57bca58 authored by Marco Villegas's avatar Marco Villegas
Browse files

Issue #1291904: Update api documentation for entity CRUD hooks.

parent 1f2be1e8
Loading
Loading
Loading
Loading
+168 −49
Changes for versioncontrol.api.php: 168 added lines, 49 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,138 @@ function hook_versioncontrol_entity_commit_update(VersioncontrolOperation $opera
function hook_versioncontrol_entity_commit_delete(VersioncontrolOperation $operation) {
}

/**
 * Act just after a versioncontrol branch has been inserted.
 *
 * @param VersioncontrolBranch $operation
 *   The branch object.
 *
 * @ingroup Branches
 */
function hook_versioncontrol_entity_branch_insert(VersioncontrolBranch $branch) {
}

/**
 * Act just after a versioncontrol branch has been updated.
 *
 * @param VersioncontrolBranch $branch
 *   The branch object.
 *
 * @ingroup Branches
 */
function hook_versioncontrol_entity_branch_update(VersioncontrolBranch $branch) {
}

/**
 * Act just after a versioncontrol branch has been deleted.
 *
 * @param VersioncontrolBranch $branch
 *   The branch object.
 *
 * @ingroup Branches
 */
function hook_versioncontrol_entity_branch_delete(VersioncontrolBranch $branch) {
}

/**
 * Act just after a versioncontrol event has been inserted.
 *
 * @param VersioncontrolEvent $event
 *   The event object.
 *
 * @ingroup Events
 */
function hook_versioncontrol_entity_event_insert(VersioncontrolEvent $event) {
}

/**
 * Act just after a versioncontrol event has been updated.
 *
 * @param VersioncontrolEvent $event
 *   The event object.
 *
 * @ingroup Events
 */
function hook_versioncontrol_entity_event_update(VersioncontrolEvent $event) {
}

/**
 * Act just after a versioncontrol event has been deleted.
 *
 * @param VersioncontrolEvent $event
 *   The event object.
 *
 * @ingroup Events
 */
function hook_versioncontrol_entity_event_delete(VersioncontrolEvent $event) {
}

/**
 * Act just after a versioncontrol item has been inserted.
 *
 * @param VersioncontrolItem $item
 *   The item object.
 *
 * @ingroup Items
 */
function hook_versioncontrol_entity_item_insert(VersioncontrolItem $item) {
}

/**
 * Act just after a versioncontrol item has been updated.
 *
 * @param VersioncontrolItem $item
 *   The item object.
 *
 * @ingroup Items
 */
function hook_versioncontrol_entity_item_update(VersioncontrolItem $item) {
}

/**
 * Act just after a versioncontrol item has been deleted.
 *
 * @param VersioncontrolItem $item
 *   The item object.
 *
 * @ingroup Items
 */
function hook_versioncontrol_entity_item_delete(VersioncontrolItem $item) {
}

/**
 * Act just after a versioncontrol tag has been inserted.
 *
 * @param VersioncontrolTag $tag
 *   The tag object.
 *
 * @ingroup Tags
 */
function hook_versioncontrol_entity_tag_insert(VersioncontrolTag $tag) {
}

/**
 * Act just after a versioncontrol tag has been updated.
 *
 * @param VersioncontrolTag $tag
 *   The tag object.
 *
 * @ingroup Tags
 */
function hook_versioncontrol_entity_tag_update(VersioncontrolTag $tag) {
}

/**
 * Act just after a versioncontrol tag has been deleted.
 *
 * @param VersioncontrolTag $tag
 *   The tag object.
 *
 * @ingroup Tags
 */
function hook_versioncontrol_entity_tag_delete(VersioncontrolTag $tag) {
}

/**
 * Extract repository data from the repository edit/add form's submitted
 * values, and add it to the @p $repository array. Later, that array will be
@@ -82,67 +214,54 @@ function hook_versioncontrol_repository_submit(&$repository, $form, $form_state)
}

/**
 * Act on database changes when VCS repositories are inserted,
 * updated or deleted.
 *
 * @param $op
 *   Either 'insert' when the repository has just been created, or 'update'
 *   when repository name, root, URL backend or module specific data change,
 *   or 'delete' if it will be deleted after this function has been called.
 * Act just after a versioncontrol repository has been inserted.
 *
 * @param $repository
 *   The repository array containing the repository. It's a single
 *   repository array like the one returned by versioncontrol_get_repository(),
 *   so it consists of the following elements:
 *
 *   - 'repo_id': The unique repository id.
 *   - 'name': The user-visible name of the repository.
 *   - 'vcs': The unique string identifier of the version control system
 *        that powers this repository.
 *   - 'root': The root directory of the repository. In most cases,
 *        this will be a local directory (e.g. '/var/repos/drupal'),
 *        but it may also be some specialized string for remote repository
 *        access. How this string may look like depends on the backend.
 *   - 'authorization_method': The string identifier of the repository's
 *        authorization method, that is, how users may register accounts
 *        in this repository. Modules can provide their own methods
 *        by implementing hook_versioncontrol_authorization_methods().
 *   - 'data': An array where modules can store additional information about
 *        the repository, for settings or other data.
 *   - '[xxx]_specific': An array of VCS specific additional repository
 *        information. How this array looks like is defined by the
 *        corresponding backend module (versioncontrol_[xxx]).
 *        (Deprecated, to be replaced by the more general 'data' property.)
 *   - '???': Any other additions that modules added by implementing
 *        hook_versioncontrol_repository_submit().
 * @param VersioncontrolRepository $repository
 *   The repository object.
 *
 * @ingroup Repositories
 * @ingroup Database change notification
 * @ingroup Form handling
 * @ingroup Target audience: All modules with repository specific settings
 */
function hook_versioncontrol_repository($op, $repository) {
  $ponies = $repository['mymodule']['ponies'];

  switch ($op) {
    case 'update':
      db_query("DELETE FROM {mymodule_ponies}
                WHERE repo_id = %d", $repository['repo_id']);
      // fall through
    case 'insert':
function hook_versioncontrol_entity_repository_insert(VersioncontrolRepository $repository) {
  // TODO use here dbtng
  foreach ($ponies as $pony) {
        db_query("INSERT INTO {mymodule_ponies} (repo_id, pony)
                  VALUES (%d, %s)", $repository['repo_id'], $pony);
    db_query("INSERT INTO {mymodule_ponies} (repo_id, pony) VALUES (%d, %s)", $repository->repo_id, $pony);
  }
}
      break;

    case 'delete':
      db_query("DELETE FROM {mymodule_ponies}
                WHERE repo_id = %d", $repository['repo_id']);
      break;
/**
 * Act just after a versioncontrol repository has been updated.
 *
 * @param VersioncontrolRepository $repository
 *   The repository object.
 *
 * @ingroup Repositories
 * @ingroup Database change notification
 * @ingroup Target audience: All modules with repository specific settings
 */
function hook_versioncontrol_entity_repository_update(VersioncontrolRepository $repository) {
  $ponies = $repository->data['mymodule']['ponies'];
  db_query("DELETE FROM {mymodule_ponies} WHERE repo_id = %d", $repository->repo_id);
  // TODO use here dbtng
  foreach ($ponies as $pony) {
    db_query("INSERT INTO {mymodule_ponies} (repo_id, pony) VALUES (%d, %s)", $repository->repo_id, $pony);
  }
}

/**
 * Act just after a versioncontrol repository has been deleted.
 *
 * @param VersioncontrolRepository $repository
 *   The repository object.
 *
 * @ingroup Repositories
 * @ingroup Database change notification
 * @ingroup Target audience: All modules with repository specific settings
 */
function hook_versioncontrol_entity_repository_delete(VersioncontrolRepository $repository) {
  db_query("DELETE FROM {mymodule_ponies} WHERE repo_id = %d", $repository->repo_id);
}

/**
 * Register new authorization methods that can be selected for a repository.