Skip to content
Snippets Groups Projects
Commit 45270eaf authored by Sean Madsen's avatar Sean Madsen Committed by GitHub
Browse files

Merge pull request #206 from seanmadsen/symfony-tools

Autogenerate hooks summary (with Symfony CLI tool)
parents b4e2eacc 7a9fd62e
No related branches found
No related tags found
No related merge requests found
Showing
with 79 additions and 317 deletions
../tools/bin/tools
\ No newline at end of file
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
$wiki_url = 'https://wiki.civicrm.org/confluence/display/CRMDOC';
$cache_dir = __DIR__ . '/wiki_cache';
chdir($cache_dir);
foreach ($hooks_by_category as $category => $hooks) {
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
if ( file_exists($hook_name) ) {
echo "SKIPPING: $hook_name (already cached)";
}
else {
echo "DOWNLOADING: $hook_name" . PHP_EOL;
system("curl '$wiki_url/$hook_name' > '$hook_name'");
}
echo PHP_EOL;
}
}
echo "DONE" . PHP_EOL;
<?php
$hooks_by_category = [
"Database" => [
['name' => "hook_civicrm_copy", 'is_deprecated' => false],
['name' => "hook_civicrm_custom", 'is_deprecated' => false],
['name' => "hook_civicrm_managed", 'is_deprecated' => false],
['name' => "hook_civicrm_merge", 'is_deprecated' => false],
['name' => "hook_civicrm_post", 'is_deprecated' => false],
['name' => "hook_civicrm_pre", 'is_deprecated' => false],
['name' => "hook_civicrm_trigger_info", 'is_deprecated' => false],
['name' => "hook_civicrm_referenceCounts", 'is_deprecated' => false],
['name' => "hook_civicrm_postSave_table_name", 'is_deprecated' => false],
],
"Extension lifecycle" => [
['name' => "hook_civicrm_disable", 'is_deprecated' => false],
['name' => "hook_civicrm_enable", 'is_deprecated' => false],
['name' => "hook_civicrm_install", 'is_deprecated' => false],
['name' => "hook_civicrm_uninstall", 'is_deprecated' => false],
['name' => "hook_civicrm_upgrade", 'is_deprecated' => false],
['name' => "hook_civicrm_postInstall", 'is_deprecated' => false],
],
"Form" => [
['name' => "hook_civicrm_alterContent", 'is_deprecated' => false],
['name' => "hook_civicrm_buildForm", 'is_deprecated' => false],
['name' => "hook_civicrm_postProcess", 'is_deprecated' => false],
['name' => "hook_civicrm_validateForm", 'is_deprecated' => false],
['name' => "hook_civicrm_alterTemplateFile", 'is_deprecated' => false],
['name' => "hook_civicrm_preProcess", 'is_deprecated' => false],
['name' => "hook_civicrm_idsException", 'is_deprecated' => false],
],
"GUI" => [
['name' => "hook_civicrm_buildAmount", 'is_deprecated' => false],
['name' => "hook_civicrm_caseSummary", 'is_deprecated' => false],
['name' => "hook_civicrm_customFieldOptions", 'is_deprecated' => true],
['name' => "hook_civicrm_dashboard", 'is_deprecated' => false],
['name' => "hook_civicrm_links", 'is_deprecated' => false],
['name' => "hook_civicrm_navigationMenu", 'is_deprecated' => false],
['name' => "hook_civicrm_pageRun", 'is_deprecated' => false],
['name' => "hook_civicrm_searchColumns", 'is_deprecated' => false],
['name' => "hook_civicrm_searchTasks", 'is_deprecated' => false],
['name' => "hook_civicrm_summary", 'is_deprecated' => false],
['name' => "hook_civicrm_summaryActions", 'is_deprecated' => false],
['name' => "hook_civicrm_tabs", 'is_deprecated' => true],
['name' => "hook_civicrm_xmlMenu", 'is_deprecated' => false],
['name' => "hook_civicrm_tabset", 'is_deprecated' => false],
['name' => "hook_civicrm_dashboard_defaults", 'is_deprecated' => false],
['name' => "hook_civicrm_contact_get_displayname", 'is_deprecated' => false],
['name' => "hook_civicrm_fieldOptions", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMenu", 'is_deprecated' => false],
],
"Mail" => [
['name' => "hook_civicrm_alterMailParams", 'is_deprecated' => false],
['name' => "hook_civicrm_emailProcessor", 'is_deprecated' => false],
['name' => "hook_civicrm_emailProcessorContact", 'is_deprecated' => false],
['name' => "hook_civicrm_mailingGroups", 'is_deprecated' => false],
['name' => "hook_civicrm_postEmailSend", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMailer", 'is_deprecated' => false],
['name' => "hook_civicrm_unsubscribeGroups", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMailContent", 'is_deprecated' => false],
['name' => "hook_civicrm_postMailing", 'is_deprecated' => false],
],
"Permission" => [
['name' => "hook_civicrm_aclGroup", 'is_deprecated' => false],
['name' => "hook_civicrm_aclWhereClause", 'is_deprecated' => false],
['name' => "hook_civicrm_alterAPIPermissions", 'is_deprecated' => false],
['name' => "hook_civicrm_permission_check", 'is_deprecated' => false],
['name' => "hook_civicrm_permission", 'is_deprecated' => false],
['name' => "hook_civicrm_selectWhereClause", 'is_deprecated' => false],
],
"Uncategorized" => [
['name' => "hook_civicrm_alterCalculatedMembershipStatus", 'is_deprecated' => false],
['name' => "hook_civicrm_alterBarcode", 'is_deprecated' => false],
['name' => "hook_civicrm_alterBadge", 'is_deprecated' => false],
['name' => "hook_civicrm_alterPaymentProcessorParams", 'is_deprecated' => false],
['name' => "hook_civicrm_alterSettingsFolders", 'is_deprecated' => false],
['name' => "hook_civicrm_alterSettingsMetaData", 'is_deprecated' => false],
['name' => "hook_civicrm_apiWrappers", 'is_deprecated' => false],
['name' => "hook_civicrm_buildStateProvinceForCountry", 'is_deprecated' => false],
['name' => "hook_civicrm_config", 'is_deprecated' => false],
['name' => "hook_civicrm_contactListQuery", 'is_deprecated' => true],
['name' => "hook_civicrm_cron", 'is_deprecated' => false],
['name' => "hook_civicrm_dupeQuery", 'is_deprecated' => false],
['name' => "hook_civicrm_export", 'is_deprecated' => false],
['name' => "hook_civicrm_import", 'is_deprecated' => false],
['name' => "hook_civicrm_membershipTypeValues", 'is_deprecated' => false],
['name' => "hook_civicrm_tokens", 'is_deprecated' => false],
['name' => "hook_civicrm_tokenValues", 'is_deprecated' => false],
['name' => "hook_civicrm_queryObjects", 'is_deprecated' => false],
['name' => "hook_civicrm_check", 'is_deprecated' => false],
['name' => "hook_civicrm_optionValues", 'is_deprecated' => true],
['name' => "hook_civicrm_coreResourceList", 'is_deprecated' => false],
['name' => "hook_civicrm_angularModules", 'is_deprecated' => false],
['name' => "hook_civicrm_container", 'is_deprecated' => false],
['name' => "hook_civicrm_crudLink", 'is_deprecated' => false],
['name' => "hook_civicrm_fileSearches", 'is_deprecated' => false],
['name' => "hook_civicrm_notePrivacy", 'is_deprecated' => false],
['name' => "hook_civicrm_eventDiscount", 'is_deprecated' => false],
['name' => "hook_civicrm_recent", 'is_deprecated' => false],
['name' => "hook_civicrm_unhandledException", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMailingLabelParams", 'is_deprecated' => false],
['name' => "hook_civicrm_geocoderFormat", 'is_deprecated' => false],
['name' => "hook_civicrm_alterLogTables", 'is_deprecated' => false],
],
"Case" => [
['name' => "hook_civicrm_caseChange", 'is_deprecated' => false],
['name' => "hook_civicrm_caseTypes", 'is_deprecated' => false],
['name' => "hook_civicrm_post_case_merge", 'is_deprecated' => false],
['name' => "hook_civicrm_pre_case_merge", 'is_deprecated' => false],
],
"Batch" => [
['name' => "hook_civicrm_batchItems", 'is_deprecated' => false],
['name' => "hook_civicrm_batchQuery", 'is_deprecated' => false],
],
"Entity" => [
['name' => "hook_civicrm_entityTypes", 'is_deprecated' => false],
],
"CiviRules" => [
['name' => "hook_civirules_alter_trigger_data", 'is_deprecated' => false],
['name' => "hook_civirules_logger", 'is_deprecated' => false],
],
"Profile" => [
['name' => "hook_civicrm_buildProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_buildUFGroupsForModule", 'is_deprecated' => false],
['name' => "hook_civicrm_processProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_searchProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_validateProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_viewProfile", 'is_deprecated' => false],
],
"Report" => [
['name' => "hook_civicrm_alterReportVar", 'is_deprecated' => false],
],
];
\ No newline at end of file
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
$cache_dir = __DIR__ . '/wiki_cache';
$root_dir = dirname(dirname(__DIR__));
$hooks_dir = "$root_dir/docs/hooks";
function clean_markdown($markdown) {
// add domain name to all hyperlinks that point to the wiki
$pattern = '@\]\((/confluence[^)]*)\)@';
$replace = '](https://wiki.civicrm.org$1)';
$markdown = preg_replace($pattern,$replace,$markdown);
// set all headings of level 3 and above to level 2
$pattern = '@^(##)(#+) (.*)$@m';
$replace = '## $3';
$markdown = preg_replace($pattern,$replace,$markdown);
return $markdown;
}
# create hooks directory if needed
if ( !is_dir($hooks_dir) ) {
mkdir($hooks_dir);
}
chdir($hooks_dir);
foreach ($hooks_by_category as $category => $hooks) {
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
$markdown_file = "$hook_name.md";
$html = "$cache_dir/$hook_name";
if ( file_exists($html) && !file_exists($markdown_file) ) {
echo "converting $hook_name ... ";
$conv_output_array = array();
$conv_status = 1;
exec("webpage2md $html", $conv_output_array, $conv_status);
if( $conv_status == 0 ) {
$conv_output = implode("\n",$conv_output_array);
$conv_output = clean_markdown($conv_output);
file_put_contents($markdown_file, $conv_output);
echo "done" . PHP_EOL;
}
else {
echo "ERROR CONVERTING $hook_name" . PHP_EOL;
echo "$conv_output";
}
}
else if ( !file_exists($html) ) {
echo "WARNING: $hook_name not yet fetched" . PHP_EOL;
}
else if ( file_exists($markdown_file) ) {
echo "ignoring $hook_name (markdown file already exists)" . PHP_EOL;
}
}
}
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
echo "- Hooks:" . PHP_EOL;
foreach ($hooks_by_category as $category => $hooks) {
echo " - $category hooks:" . PHP_EOL;
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
if ( $hook['is_deprecated'] ) {
$menu_name = "<del>$hook_name</del>";
}
else {
$menu_name = $hook_name;
}
echo " - $menu_name: hooks/$hook_name.md" . PHP_EOL;
}
}
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
foreach ($hooks_by_category as $category => $hooks) {
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
echo "$hook_name hooks/$hook_name" . PHP_EOL;
}
}
# Ignore everything in this directory
*
# Except this file
!.gitignore
\ No newline at end of file
......@@ -149,6 +149,21 @@ If you'd like to move a page, take the following steps:
!!! note
Page redirection *won't work locally* (when previewing with `mkdocs serve`), but it *will* work once the guide is published on docs.civicrm.org. The redirection is implemented as part of our [docs-publisher](https://lab.civicrm.org/documentation/docs-publisher) app.
## Auto-generated documentation {:#auto-gen}
Some guides may have auto-generated content, which is summarized here.
### In the Developer Guide {:#auto-gen-dev}
This Developer Guide has an automatically-generated [list of all hooks](/hooks/list.md). To re-create this list, run the following command from the root level of the repository:
```
./bin/tools generate:hooks-list
```
Our editing workflow currently requires someone to manually run this command after and commit its changes whenever hooks files are edited.
## Content attribution guidelines {:#attribution}
All CiviCRM documentation content is licensed [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/). This means that if you want to copy content out of our docs and use it elsewhere, you're welcome to do so as long as your give attribution to the author.
......
# hook_civicrm_aclGroup
## Description
## Summary
This hook is called when composing the ACL to restrict access to civicrm
entities (civicrm groups, profiles and events). NOTE: In order to use
this hook you must uncheck "View All Contacts" AND "Edit All Contacts"
entities (civicrm groups, profiles and events).
## Notes
In order to use this hook you must uncheck "View All Contacts" AND "Edit All Contacts"
in Drupal Permissions for the user role you want to limit. You can then
go into CiviCRM and grant permission to Edit or View "All Contacts" or
"Certain Groups". See the Forum Topic at:
......
# hook_civicrm_aclWhereClause
## Description
## Summary
This hook is called when composing the ACL where clause to restrict
visibility of contacts to the logged in user.
Note that this hook is called only when filling up the
civicrm_acl_contact_cache table, and not every time a contact SELECT
## Notes
This hook is called only when filling up the
`civicrm_acl_contact_cache` table, and not every time a contact `SELECT`
query is performed. Those will join onto the
civicrm_acl_contact_cache table.
`civicrm_acl_contact_cache` table.
*NB: This hook will not be called at all if the logged in user has
access to the "edit all contacts" permission.*
!!! caution "Caveat"
It will not be called at all if the logged in user has access to the "edit all contacts" permission.
## Definition
......
# hook_civicrm_alterAPIPermissions
## Description
## Summary
This hook is called when API 3 permissions are checked and can alter the
`$permissions` structure from `CRM/Core/DAO/permissions.php` (as well as
the API `$params` array) based on the `$entity` and `$action` (or
unconditionally).
This hook is called when API 3 permissions are checked.
## Notes
This hook can alter the `$permissions` structure from `CRM/Core/DAO/permissions.php` (as well as the API `$params` array) based on the `$entity` and `$action` (or unconditionally).
!!! Note
If a given entity/action permissions are unset, the default
......
# hook_civicrm_alterBadge
## Description
## Summary
This hook allows one to modify the content and format of the name
badges. Available in 4.5+.
This hook allows you to modify the content and format of name badges.
## Availability
Available in 4.5+.
## Definition
......
# hook_civicrm_alterBarcode
## Description
## Summary
This hook allows you to modify the content that is encoded in barcode.
## Availability
This hook allows one to modify the content that is encoded in barcode.
Available in 4.4+.
## Definition
......
# hook_civicrm_alterCalculatedMembershipStatus
## Description
## Summary
This hook is called when calculating the membership status - e.g on a
form or in the cron job that rolls over statuses
This hook is called when calculating the membership status.
## Notes
Examples of when this hook is called include:
* on a form
* in the cron job that rolls over statuses
## Definition
`hook_civicrm_alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {`{.java
.plain}
hook_civicrm_alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership)
## Parameters
* $membershipStatus the calculated membership status array
* $arguments arguments used in the calculation
* $membership the membership array from the calling function
* $membership the membership array from the calling function
## Added
......
# hook_civicrm_alterContent
## Description
## Summary
This hook is invoked after all the content of a CiviCRM form or page is
generated. It allows for direct manipulation of the generated content.
generated and allows for direct manipulation of the generated content.
## Definition
......
# hook_civicrm_alterLogTables
## Description
## Summary
This hook allows you to amend the specification of the log tables to be
created when logging is turned on. You can adjust the specified tables
and the engine and define indexes and exceptions.\
\
Note that CiviCRM creates log tables according to the specification at
the point of creation. It does not update them if you change the
specification, except with regards to adding additional tables. Tables
are never automatically dropped.
created when logging is turned on.
Turning logging on and off will cause any adjustments to the exceptions
to be enacted as that information is in the triggers not the log tables,
which are recreated.
## Notes
You can adjust the specified tables and the engine and define indexes and exceptions. Note that CiviCRM creates log tables according to the specification at the point of creation. It does not update them if you change the specification, except with regards to adding additional tables. Tables are never automatically dropped.
Turning logging on and off will cause any adjustments to the exceptions to be enacted as that information is in the triggers not the log tables, which are recreated.
There is, however, a function that will convert Archive tables to log
tables (one way) if the hook is in play. This has to be done
deliberately by calling the system.updatelogtables api and it can be a
slow process.
There is, however, a function that will convert Archive tables to log tables (one way) if the hook is in play. This has to be done deliberately by calling the `system.updatelogtables` api and it can be a slow process.
## Availability
......@@ -28,19 +19,11 @@ This hook was first available in CiviCRM 4.7.7.
## Definition
---------------------------------------------------------------
`hook_`{.java .plain}civicrm_alterLogTables(&$logTableSpec)
---------------------------------------------------------------
hook_civicrm_alterLogTables(&$logTableSpec)
## Parameters
- @param array $logTableSpec\
\
\
- @param array $logTableSpec
## Example
......
# hook_civicrm_alterMailContent
## Description
## Summary
This hook is called after getting the content of the mail and before
tokenizing it.
......
# hook_civicrm_alterMailParams
## Description
## Summary
This hook is called when an email is about to be sent by CiviCRM.
......
# hook_civicrm_alterMailer
## Description
## Summary
This hook is called when CiviCRM prepares an email driver class to
handle outbound message delivery.
## Availability
Introduced in CiviCRM v4.4.
## Definition
......
# hook_civicrm_alterMailingLabelParams
## Description
## Summary
This hook is called to alter the parameters used to generate mailing
labels. To be added in CiviCRM 4.1 or later.
labels.
## Availability
CiviCRM 4.1 or later
## Definition
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment