Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Template for a components.
==========================
### Document structure:

### Example:
51 changes: 51 additions & 0 deletions docs/functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Template for functions.
=======================
### Document structure:
1. Signature
2. Short description
3. Long description(if exists)
4. Arguments description(if exists)
5. Return statement description(if returns something)
6. Code

### Example:

function **my_function(array $arg1, $arg2 = NULL)**

> This function allow users(short description)....

> Additional info for this function(long description).

* **$arg1**:

        type: _array_

        description: _Argument 1 description._

* **$arg2**:

        type: _string_

        default: _NULL_

        description: _Argument 2 description._

* **return**:

        type: _object_

        description: _Return some object._

**Code:**
```php
function my_function(array $arg1, $arg2 = NULL) {
$object = new stdClass();
foreach($arg1 as $name => $value) {
$object->{$name} = $value;
}
if (!empty($arg2)) {
$object->arg = $arg2;
}
return $object;
}
```
18 changes: 18 additions & 0 deletions docs/functions/src/8.1.x/action_entity_type_build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function **action_entity_type_build(array &$entity_types)**

> Implements hook_entity_type_build().

**Code:**
```php
function action_entity_type_build(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['action']
->setFormClass('add', 'Drupal\action\ActionAddForm')
->setFormClass('edit', 'Drupal\action\ActionEditForm')
->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
->setListBuilderClass('Drupal\action\ActionListBuilder')
->setLinkTemplate('delete-form', '/admin/config/system/actions/configure/{action}/delete')
->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}')
->setLinkTemplate('collection', '/admin/config/system/actions');
}
```
30 changes: 30 additions & 0 deletions docs/functions/src/8.1.x/action_help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function **action_help($route_name, RouteMatchInterface $route_match)**

> Implements hook_help().

**Code:**
```php
function action_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.action':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Actions module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the <a href=":documentation">online documentation for the Actions module</a>.', array(':documentation' => 'https://www.drupal.org/documentation/modules/action')) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Using simple actions') . '</dt>';
$output .= '<dd>' . t('<em>Simple actions</em> do not require configuration and are listed automatically as available on the <a href=":actions">Actions page</a>.', array(':actions' => \Drupal::url('entity.action.collection'))) . '</dd>';
$output .= '<dt>' . t('Creating and configuring advanced actions') . '</dt>';
$output .= '<dd>' . t('<em>Advanced actions</em> are user-created and have to be configured individually. Create an advanced action on the <a href=":actions">Actions page</a> by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', array(':actions' => \Drupal::url('entity.action.collection'))) . '</dd>';
$output .= '</dl>';
return $output;

case 'entity.action.collection':
$output = '<p>' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration and are listed here automatically. Advanced actions need to be created and configured before they can be used because they have options that need to be specified; for example, sending an email to a specified address or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>';
return $output;

case 'entity.action.edit_form':
return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended in order to better identify the precise action taking place.');
}
}
```
17 changes: 17 additions & 0 deletions docs/functions/src/8.1.x/action_views_form_substitutions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function **action_views_form_substitutions()**

> Implements hook_views_form_substitutions().

**Code:**
```php
function action_views_form_substitutions() {
$select_all = array(
'#type' => 'checkbox',
'#default_value' => FALSE,
'#attributes' => array('class' => array('action-table-select-all')),
);
return array(
'<!--action-bulk-form-select-all-->' => drupal_render($select_all),
);
}
```
34 changes: 34 additions & 0 deletions docs/functions/src/8.1.x/aggregator_cron.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function **aggregator_cron()**

> Implements hook_cron().

> Queues news feeds for updates once their refresh interval has elapsed.

**Code:**
```php
function aggregator_cron() {
$queue = \Drupal::queue('aggregator_feeds');

$ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh();
foreach (Feed::loadMultiple($ids) as $feed) {
if ($queue->createItem($feed)) {
// Add timestamp to avoid queueing item more than once.
$feed->setQueuedTime(REQUEST_TIME);
$feed->save();
}
}

// Delete queued timestamp after 6 hours assuming the update has failed.
$ids = \Drupal::entityQuery('aggregator_feed')
->condition('queued', REQUEST_TIME - (3600 * 6), '<')
->execute();

if ($ids) {
$feeds = Feed::loadMultiple($ids);
foreach ($feeds as $feed) {
$feed->setQueuedTime(0);
$feed->save();
}
}
}
```
55 changes: 55 additions & 0 deletions docs/functions/src/8.1.x/aggregator_entity_extra_field_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function **aggregator_entity_extra_field_info()**

> Implements hook_entity_extra_field_info().

**Code:**
```php
function aggregator_entity_extra_field_info() {
$extra = array();

$extra['aggregator_feed']['aggregator_feed'] = array(
'display' => array(
'items' => array(
'label' => t('Items'),
'description' => t('Items associated with this feed'),
'weight' => 0,
),
// @todo Move to a formatter at https://www.drupal.org/node/2339917.
'image' => array(
'label' => t('Image'),
'description' => t('The feed image'),
'weight' => 2,
),
// @todo Move to a formatter at https://www.drupal.org/node/2149845.
'description' => array(
'label' => t('Description'),
'description' => t('The description of this feed'),
'weight' => 3,
),
'more_link' => array(
'label' => t('More link'),
'description' => t('A more link to the feed detail page'),
'weight' => 5,
),
'feed_icon' => array(
'label' => t('Feed icon'),
'description' => t('An icon that links to the feed URL'),
'weight' => 6,
),
),
);

$extra['aggregator_item']['aggregator_item'] = array(
'display' => array(
// @todo Move to a formatter at https://www.drupal.org/node/2149845.
'description' => array(
'label' => t('Description'),
'description' => t('The description of this feed item'),
'weight' => 2,
),
),
);

return $extra;
}
```
51 changes: 51 additions & 0 deletions docs/functions/src/8.1.x/aggregator_help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function **aggregator_help($route_name, RouteMatchInterface $route_match)**

> Implements hook_help().

**Code:**
```php
function aggregator_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.aggregator':
$path_validator = \Drupal::pathValidator();
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the <a href=":aggregator-module">online documentation for the Aggregator module</a>.', array(':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator')) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
// Check if the aggregator sources View is enabled.
if ($url = $path_validator->getUrlIfValid('aggregator/sources')) {
$output .= '<dt>' . t('Viewing feeds') . '</dt>';
$output .= '<dd>' . t('Users view feed content in the <a href=":aggregator">main aggregator display</a>, or by <a href=":aggregator-sources">their source</a> (usually via an RSS feed reader). The most recent content in a feed can be displayed as a block through the <a href=":admin-block">Blocks administration page</a>.', array(':aggregator' => \Drupal::url('aggregator.page_last'), ':aggregator-sources' => $url->toString(), ':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
}
$output .= '<dt>' . t('Adding, editing, and deleting feeds') . '</dt>';
$output .= '<dd>' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the <a href=":feededit">Feed aggregator page</a>.', array(':feededit' => \Drupal::url('aggregator.admin_overview'))) . '</dd>';
$output .= '<dt>' . t('Configuring the display of feed items') . '</dt>';
$output .= '<dd>' . t('Administrators can choose how many items are displayed in the listing pages, which HTML tags are allowed in the content of feed items, and whether they should be trimmed to a maximum number of characters on the <a href=":settings">Feed aggregator settings page</a>.', array(':settings' => \Drupal::url('aggregator.admin_settings'))) . '</dd>';
$output .= '<dt>' . t('Discarding old feed items') . '</dt>';
$output .= '<dd>' . t('Administrators can choose whether to discard feed items that are older than a specified period of time on the <a href=":settings">Feed aggregator settings page</a>. This requires a correctly configured cron maintenance task (see below).', array(':settings' => \Drupal::url('aggregator.admin_settings'))) . '<dd>';

$output .= '<dt>' . t('<abbr title="Outline Processor Markup Language">OPML</abbr> integration') . '</dt>';
// Check if the aggregator opml View is enabled.
if ($url = $path_validator->getUrlIfValid('aggregator/opml')) {
$output .= '<dd>' . t('A <a href=":aggregator-opml">machine-readable OPML file</a> of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be <a href=":import-opml">imported via an OPML file</a>.', array(':aggregator-opml' => $url->toString(), ':import-opml' => \Drupal::url('aggregator.opml_add'))) . '</dd>';
}
$output .= '<dt>' . t('Configuring cron') . '</dt>';
$output .= '<dd>' . t('A working <a href=":cron">cron maintenance task</a> is required to update feeds automatically.', array(':cron' => \Drupal::url('system.cron_settings'))) . '</dd>';
$output .= '</dl>';
return $output;

case 'aggregator.admin_overview':
// Don't use placeholders for possibility to change URLs for translators.
$output = '<p>' . t('Many sites publish their headlines and posts in feeds, using a number of standardized XML-based formats. The aggregator supports <a href="http://en.wikipedia.org/wiki/Rss">RSS</a>, <a href="http://en.wikipedia.org/wiki/Resource_Description_Framework">RDF</a>, and <a href="http://en.wikipedia.org/wiki/Atom_%28standard%29">Atom</a>.') . '</p>';
$output .= '<p>' . t('Current feeds are listed below, and <a href=":addfeed">new feeds may be added</a>. For each feed, the <em>latest items</em> block may be enabled at the <a href=":block">blocks administration page</a>.', array(':addfeed' => \Drupal::url('aggregator.feed_add'), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</p>';
return $output;

case 'aggregator.feed_add':
return '<p>' . t('Add a feed in RSS, RDF or Atom format. A feed may only have one entry.') . '</p>';

case 'aggregator.opml_add':
return '<p>' . t('<abbr title="Outline Processor Markup Language">OPML</abbr> is an XML format for exchanging feeds between aggregators. A single OPML document may contain many feeds. Aggregator uses this file to import all feeds at once. Upload a file from your computer or enter a URL where the OPML file can be downloaded.') . '</p>';
}
}
```
12 changes: 12 additions & 0 deletions docs/functions/src/8.1.x/aggregator_preprocess_block.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function **aggregator_preprocess_block(&$variables)**

> Implements hook_preprocess_HOOK() for block templates.

**Code:**
```php
function aggregator_preprocess_block(&$variables) {
if ($variables['configuration']['provider'] == 'aggregator') {
$variables['attributes']['role'] = 'complementary';
}
}
```
20 changes: 20 additions & 0 deletions docs/functions/src/8.1.x/aggregator_requirements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function **aggregator_requirements($phase)**

> Implements hook_requirements().

**Code:**
```php
function aggregator_requirements($phase) {
$has_curl = function_exists('curl_init');
$requirements = array();
$requirements['curl'] = array(
'title' => t('cURL'),
'value' => $has_curl ? t('Enabled') : t('Not found'),
);
if (!$has_curl) {
$requirements['curl']['severity'] = REQUIREMENT_ERROR;
$requirements['curl']['description'] = t('The Aggregator module could not be installed because the PHP <a href="http://php.net/manual/curl.setup.php">cURL</a> library is not available.');
}
return $requirements;
}
```
19 changes: 19 additions & 0 deletions docs/functions/src/8.1.x/aggregator_theme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function **aggregator_theme()**

> Implements hook_theme().

**Code:**
```php
function aggregator_theme() {
return array(
'aggregator_feed' => array(
'render element' => 'elements',
'file' => 'aggregator.theme.inc',
),
'aggregator_item' => array(
'render element' => 'elements',
'file' => 'aggregator.theme.inc',
),
);
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function **ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInterface $form_state)**

> Ajax callback for 'add_css'.

**Code:**
```php
function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new AddCssCommand('my/file.css'));
return $response;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function **ajax_forms_test_advanced_commands_after_callback($form, FormStateInterface $form_state)**

> Ajax form callback: Selects 'after'.

**Code:**
```php
function ajax_forms_test_advanced_commands_after_callback($form, FormStateInterface $form_state) {
$selector = '#after_div';

$response = new AjaxResponse();
$response->addCommand(new AfterCommand($selector, "This will be placed after"));
return $response;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function **ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterface $form_state)**

> Ajax form callback: Selects 'alert'.

**Code:**
```php
function ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new AlertCommand('Alert'));
return $response;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function **ajax_forms_test_advanced_commands_append_callback($form, FormStateInterface $form_state)**

> Ajax form callback: Selects 'append'.

**Code:**
```php
function ajax_forms_test_advanced_commands_append_callback($form, FormStateInterface $form_state) {
$selector = '#append_div';
$response = new AjaxResponse();
$response->addCommand(new AppendCommand($selector, "Appended text"));
return $response;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function **ajax_forms_test_advanced_commands_before_callback($form, FormStateInterface $form_state)**

> Ajax form callback: Selects 'before'.

**Code:**
```php
function ajax_forms_test_advanced_commands_before_callback($form, FormStateInterface $form_state) {
$selector = '#before_div';
$response = new AjaxResponse();
$response->addCommand(new BeforeCommand($selector, "Before text"));
return $response;
}
```
Loading