Mercurial > hg > isophonics-drupal-site
comparison core/core.api.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 1fec387a4317 |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
411 * | 411 * |
412 * Note: If not specified, all of the methods mentioned here belong to | 412 * Note: If not specified, all of the methods mentioned here belong to |
413 * \Drupal\Core\Cache\CacheBackendInterface. | 413 * \Drupal\Core\Cache\CacheBackendInterface. |
414 * | 414 * |
415 * The Cache API is used to store data that takes a long time to compute. | 415 * The Cache API is used to store data that takes a long time to compute. |
416 * Caching can either be permanent or valid only for a certain timespan, and | 416 * Caching can either be permanent or valid only for a certain time span, and |
417 * the cache can contain any type of data. | 417 * the cache can contain any type of data. |
418 * | 418 * |
419 * To use the Cache API: | 419 * To use the Cache API: |
420 * - Request a cache object through \Drupal::cache() or by injecting a cache | 420 * - Request a cache object through \Drupal::cache() or by injecting a cache |
421 * service. | 421 * service. |
556 * you save an entity, you can be sure that the cache items that have the | 556 * you save an entity, you can be sure that the cache items that have the |
557 * corresponding cache tags will be invalidated. | 557 * corresponding cache tags will be invalidated. |
558 * This also is the case when you define your own entity types: you'll get the | 558 * This also is the case when you define your own entity types: you'll get the |
559 * exact same cache tag invalidation as any of the built-in entity types, with | 559 * exact same cache tag invalidation as any of the built-in entity types, with |
560 * the ability to override any of the default behavior if needed. | 560 * the ability to override any of the default behavior if needed. |
561 * See \Drupal\Core\Cache\CacheableDepenencyInterface::getCacheTags(), | 561 * See \Drupal\Core\Cache\CacheableDependencyInterface::getCacheTags(), |
562 * \Drupal\Core\Entity\EntityTypeInterface::getListCacheTags(), | 562 * \Drupal\Core\Entity\EntityTypeInterface::getListCacheTags(), |
563 * \Drupal\Core\Entity\Entity::invalidateTagsOnSave() and | 563 * \Drupal\Core\Entity\Entity::invalidateTagsOnSave() and |
564 * \Drupal\Core\Entity\Entity::invalidateTagsOnDelete(). | 564 * \Drupal\Core\Entity\Entity::invalidateTagsOnDelete(). |
565 * | 565 * |
566 * @section context Cache contexts | 566 * @section context Cache contexts |
567 * | 567 * |
568 * Some computed data depends on contextual data, such as the user roles of the | 568 * Some computed data depends on contextual data, such as the user roles of the |
569 * logged-in user who is viewing a page, the language the page is being rendered | 569 * logged-in user who is viewing a page, the language the page is being rendered |
570 * in, the theme being used, etc. When caching the output of such a calculation, | 570 * in, the theme being used, etc. When caching the output of such a calculation, |
571 * you must cache each variation separately, along with information about which | 571 * you must cache each variation separately, along with information about which |
572 * variation of the contextual data was used in the calculatation. The next time | 572 * variation of the contextual data was used in the calculation. The next time |
573 * the computed data is needed, if the context matches that for an existing | 573 * the computed data is needed, if the context matches that for an existing |
574 * cached data set, the cached data can be reused; if no context matches, a new | 574 * cached data set, the cached data can be reused; if no context matches, a new |
575 * data set can be calculated and cached for later use. | 575 * data set can be calculated and cached for later use. |
576 * | 576 * |
577 * Cache contexts are services tagged with 'cache.context', whose classes | 577 * Cache contexts are services tagged with 'cache.context', whose classes |
1224 * The Drupal project primarily uses runtime assertions to enforce the | 1224 * The Drupal project primarily uses runtime assertions to enforce the |
1225 * expectations of the API by failing when incorrect calls are made by code | 1225 * expectations of the API by failing when incorrect calls are made by code |
1226 * under development. While PHP type hinting does this for objects and arrays, | 1226 * under development. While PHP type hinting does this for objects and arrays, |
1227 * runtime assertions do this for scalars (strings, integers, floats, etc.) and | 1227 * runtime assertions do this for scalars (strings, integers, floats, etc.) and |
1228 * complex data structures such as cache and render arrays. They ensure that | 1228 * complex data structures such as cache and render arrays. They ensure that |
1229 * methods' return values are the documented datatypes. They also verify that | 1229 * methods' return values are the documented data types. They also verify that |
1230 * objects have been properly configured and set up by the service container. | 1230 * objects have been properly configured and set up by the service container. |
1231 * They supplement unit tests by checking scenarios that do not have unit tests | 1231 * They supplement unit tests by checking scenarios that do not have unit tests |
1232 * written for them. | 1232 * written for them. |
1233 * | 1233 * |
1234 * There are two php settings which affect runtime assertions. The first, | 1234 * There are two php settings which affect runtime assertions. The first, |
1250 * - Content: Information meant to be displayed on your site: articles, basic | 1250 * - Content: Information meant to be displayed on your site: articles, basic |
1251 * pages, images, files, custom blocks, etc. Content is stored and accessed | 1251 * pages, images, files, custom blocks, etc. Content is stored and accessed |
1252 * using @link entity_api Entities @endlink. | 1252 * using @link entity_api Entities @endlink. |
1253 * - Session: Information about individual users' interactions with the site, | 1253 * - Session: Information about individual users' interactions with the site, |
1254 * such as whether they are logged in. This is really "state" information, but | 1254 * such as whether they are logged in. This is really "state" information, but |
1255 * it is not stored the same way so it's a separate type here. Session | 1255 * it is not stored the same way so it's a separate type here. Session data is |
1256 * information is available from the Request object. The session implements | 1256 * accessed via \Symfony\Component\HttpFoundation\Request::getSession(), which |
1257 * returns an instance of | |
1257 * \Symfony\Component\HttpFoundation\Session\SessionInterface. | 1258 * \Symfony\Component\HttpFoundation\Session\SessionInterface. |
1259 * See the @link session Sessions topic @endlink for more information. | |
1258 * - State: Information of a temporary nature, generally machine-generated and | 1260 * - State: Information of a temporary nature, generally machine-generated and |
1259 * not human-edited, about the current state of your site. Examples: the time | 1261 * not human-edited, about the current state of your site. Examples: the time |
1260 * when Cron was last run, whether node access permissions need rebuilding, | 1262 * when Cron was last run, whether node access permissions need rebuilding, |
1261 * etc. See @link state_api the State API topic @endlink for more information. | 1263 * etc. See @link state_api the State API topic @endlink for more information. |
1262 * - Configuration: Information about your site that is generally (or at least | 1264 * - Configuration: Information about your site that is generally (or at least |
1999 | 2001 |
2000 /** | 2002 /** |
2001 * Alter cron queue information before cron runs. | 2003 * Alter cron queue information before cron runs. |
2002 * | 2004 * |
2003 * Called by \Drupal\Core\Cron to allow modules to alter cron queue settings | 2005 * Called by \Drupal\Core\Cron to allow modules to alter cron queue settings |
2004 * before any jobs are processesed. | 2006 * before any jobs are processed. |
2005 * | 2007 * |
2006 * @param array $queues | 2008 * @param array $queues |
2007 * An array of cron queue information. | 2009 * An array of cron queue information. |
2008 * | 2010 * |
2009 * @see \Drupal\Core\QueueWorker\QueueWorkerInterface | 2011 * @see \Drupal\Core\Queue\QueueWorkerInterface |
2010 * @see \Drupal\Core\Annotation\QueueWorker | 2012 * @see \Drupal\Core\Annotation\QueueWorker |
2011 * @see \Drupal\Core\Cron | 2013 * @see \Drupal\Core\Cron |
2012 */ | 2014 */ |
2013 function hook_queue_info_alter(&$queues) { | 2015 function hook_queue_info_alter(&$queues) { |
2014 // This site has many feeds so let's spend 90 seconds on each cron run | 2016 // This site has many feeds so let's spend 90 seconds on each cron run |
2255 * A one-dimensional array of \Drupal\Core\Config\ConfigImporter method names | 2257 * A one-dimensional array of \Drupal\Core\Config\ConfigImporter method names |
2256 * or callables that are invoked to complete the import, in the order that | 2258 * or callables that are invoked to complete the import, in the order that |
2257 * they will be processed. Each callable item defined in $sync_steps should | 2259 * they will be processed. Each callable item defined in $sync_steps should |
2258 * either be a global function or a public static method. The callable should | 2260 * either be a global function or a public static method. The callable should |
2259 * accept a $context array by reference. For example: | 2261 * accept a $context array by reference. For example: |
2260 * <code> | 2262 * @code |
2261 * function _additional_configuration_step(&$context) { | 2263 * function _additional_configuration_step(&$context) { |
2262 * // Do stuff. | 2264 * // Do stuff. |
2263 * // If finished set $context['finished'] = 1. | 2265 * // If finished set $context['finished'] = 1. |
2264 * } | 2266 * } |
2265 * </code> | 2267 * @endcode |
2266 * For more information on creating batches, see the | 2268 * For more information on creating batches, see the |
2267 * @link batch Batch operations @endlink documentation. | 2269 * @link batch Batch operations @endlink documentation. |
2268 * | 2270 * |
2269 * @see callback_batch_operation() | 2271 * @see callback_batch_operation() |
2270 * @see \Drupal\Core\Config\ConfigImporter::initialize() | 2272 * @see \Drupal\Core\Config\ConfigImporter::initialize() |
2583 * definition order. If order matters defining a priority is strongly advised | 2585 * definition order. If order matters defining a priority is strongly advised |
2584 * instead of relying on these two tie breaker rules as they might change in a | 2586 * instead of relying on these two tie breaker rules as they might change in a |
2585 * minor release. | 2587 * minor release. |
2586 * @} | 2588 * @} |
2587 */ | 2589 */ |
2590 | |
2591 /** | |
2592 * @defgroup session Sessions | |
2593 * @{ | |
2594 * Store and retrieve data associated with a user's browsing session. | |
2595 * | |
2596 * @section sec_intro Overview | |
2597 * The Drupal session management subsystem is built on top of the Symfony | |
2598 * session component. It is optimized in order to minimize the impact of | |
2599 * anonymous sessions on caching proxies. A session is only started if necessary | |
2600 * and the session cookie is removed from the browser as soon as the session | |
2601 * has no data. For this reason it is important for contributed and custom | |
2602 * code to remove session data if it is not used anymore. | |
2603 * | |
2604 * @section sec_usage Usage | |
2605 * Session data is accessed via the | |
2606 * \Symfony\Component\HttpFoundation\Request::getSession() | |
2607 * method, which returns an instance of | |
2608 * \Symfony\Component\HttpFoundation\Session\SessionInterface. The most | |
2609 * important methods on SessionInterface are set(), get(), and remove(). | |
2610 * | |
2611 * The following code fragment shows the implementation of a counter controller | |
2612 * relying on the session: | |
2613 * @code | |
2614 * public function counter(Request $request) { | |
2615 * $session = $request->getSession(); | |
2616 * $count = $session->get('mymodule.counter', 0) + 1; | |
2617 * $session->set('mymodule.counter', $count); | |
2618 * | |
2619 * return [ | |
2620 * '#markup' => $this->t('Page Views: @count', ['@count' => $count]), | |
2621 * '#cache' => [ | |
2622 * 'max-age' => 0, | |
2623 * ], | |
2624 * ]; | |
2625 * } | |
2626 * | |
2627 * public function reset(Request $request) { | |
2628 * $session = $request->getSession(); | |
2629 * $session->remove('mymodule.counter'); | |
2630 * } | |
2631 * @endcode | |
2632 * | |
2633 * It is important to keep the amount of data stored inside the session to a | |
2634 * minimum, as the complete session is loaded on every request. Also third | |
2635 * party session storage backends do not necessarily allow objects of unlimited | |
2636 * size. If it is necessary to collect a non-trivial amount of data specific to | |
2637 * a user's session, use the Key/Value store to save the serialized data and | |
2638 * only store the key to the entry in the session. | |
2639 * | |
2640 * @section sec_reserved Reserved attributes and namespacing | |
2641 * Contributed modules relying on the session are encouraged to namespace | |
2642 * session attributes by prefixing them with their project name or an | |
2643 * abbreviation thereof. | |
2644 * | |
2645 * Some attributes are reserved for Drupal core and must not be accessed from | |
2646 * within contributed and custom code. Reserved attributes include: | |
2647 * - uid: The user ID for an authenticated user. The value of this attribute | |
2648 * cannot be modified. | |
2649 * @} | |
2650 */ |