/** * {@inheritdoc} */ public function log($level, $message, array $context = array()) { $map = array(LogLevel::EMERGENCY => WATCHDOG_EMERGENCY, LogLevel::DEBUG => WATCHDOG_DEBUG, LogLevel::INFO => WATCHDOG_INFO, LogLevel::ALERT => WATCHDOG_ALERT, LogLevel::CRITICAL => WATCHDOG_CRITICAL, LogLevel::ERROR => WATCHDOG_ERROR, LogLevel::NOTICE => WATCHDOG_NOTICE); $watchdog_level = $map[$level]; // Map the logger channel to the watchdog type. $type = isset($context['channel']) ? $context['channel'] : 'default'; unset($context['channel']); $this->drupal7->watchdog($type, $message, $context, $watchdog_level); }
/** * {@inheritdoc} */ public function getTimeZone() { return $this->drupal7->drupal_get_user_timezone(); }
/** * {@inheritdoc} */ public function deleteMessagesByType($type) { $this->drupal7->drupal_get_messages($type, TRUE); return $this; }
/** * Implements Drupal\Core\Flood\FloodInterface::isAllowed(). * * Checks whether a user is allowed to proceed with the specified event. * * Events can have thresholds saying that each user can only do that event * a certain number of times in a time window. This function verifies that the * current user has not exceeded this threshold. * * @param $name * The unique name of the event. * @param $threshold * The maximum number of times each user can do this event per time window. * @param $window * Number of seconds in the time window for this event (default is 3600 * seconds, or 1 hour). * @param $identifier * Unique identifier of the current user. Defaults to their IP address. * * @return bool * TRUE if the user is allowed to proceed. FALSE if they have exceeded the * threshold and should not be allowed to proceed. */ public function isAllowed($name, $threshold, $window = 3600, $identifier = NULL) { return $this->drupal7->flood_is_allowed($name, $threshold, $window, $identifier); }
/** * @covers ::deleteMessagesByType() */ public function test_deleteMessagesByType() { $this->drupal7->shouldReceive('drupal_get_messages')->once()->with('warning', TRUE); $this->assertSame($this->messenger_service, $this->messenger_service->deleteMessagesByType('warning')); }
/** * @covers ::__call() */ public function test_call() { $random_string = 'is_a_lovely_cat!'; $this->assertEquals('izumi_is_a_lovely_cat!', $this->drupal7_service->drupal7_legacy_test_function($random_string), 'Calling function via legacy service works.'); }
/** * {@inheritdoc} */ public function getName($module) { $module_data = $this->drupal7->system_rebuild_module_data(); return $module_data[$module]->info['name']; }
/** * {@inheritdoc} */ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { $this->drupal7->module_disable($module_list, $uninstall_dependents); $this->drupal7->drupal_uninstall_modules($module_list); }
/** * {@inheritdoc} */ public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) { return $this->drupal7->format_plural($count, $singular, $plural, $args, $options); }
/** * Generates an internal or external URL. * * When creating links in modules, consider whether l() could be a better * alternative than url(). * * @param $path * (optional) The internal path or external URL being linked to, such as * "node/34" or "http://example.com/foo". The default value is equivalent to * passing in '<front>'. A few notes: * - If you provide a full URL, it will be considered an external URL. * - If you provide only the path (e.g. "node/34"), it will be * considered an internal link. In this case, it should be a system URL, * and it will be replaced with the alias, if one exists. Additional query * arguments for internal paths must be supplied in $options['query'], not * included in $path. * - If you provide an internal path and $options['alias'] is set to TRUE, the * path is assumed already to be the correct path alias, and the alias is * not looked up. * - The special string '<front>' generates a link to the site's base URL. * - If your external URL contains a query (e.g. http://example.com/foo?a=b), * then you can either URL encode the query keys and values yourself and * include them in $path, or use $options['query'] to let this function * URL encode them. * @param $options * (optional) An associative array of additional options, with the following * elements: * - 'query': An array of query key/value-pairs (without any URL-encoding) to * append to the URL. * - 'fragment': A fragment identifier (named anchor) to append to the URL. * Do not include the leading '#' character. * - 'absolute': Defaults to FALSE. Whether to force the output to be an * absolute link (beginning with http:). Useful for links that will be * displayed outside the site, such as in an RSS feed. * - 'alias': Defaults to FALSE. Whether the given path is a URL alias * already. * - 'external': Whether the given path is an external URL. * - 'language': An optional language object. If the path being linked to is * internal to the site, $options['language'] is used to look up the alias * for the URL. If $options['language'] is omitted, the global $language_url * will be used. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can * only be enforced when the variable 'https' is set to TRUE. * - 'base_url': Only used internally, to modify the base URL when a language * dependent URL requires so. * - 'prefix': Only used internally, to modify the path when a language * dependent URL requires so. * - 'script': The script filename in Drupal's root directory to use when * clean URLs are disabled, such as 'index.php'. Defaults to an empty * string, as most modern web servers automatically find 'index.php'. If * clean URLs are disabled, the value of $path is appended as query * parameter 'q' to $options['script'] in the returned URL. When deploying * Drupal on a web server that cannot be configured to automatically find * index.php, then hook_url_outbound_alter() can be implemented to force * this value to 'index.php'. * - 'entity_type': The entity type of the object that called url(). Only * set if url() is invoked by entity_uri(). * - 'entity': The entity object (such as a node) for which the URL is being * generated. Only set if url() is invoked by entity_uri(). * * @return string * A string containing a URL to the given path. */ public function url($path = NULL, array $options = array()) { return $this->drupal7->url($path, $options); }
/** * Formats an internal or external URL link as an HTML anchor tag. * * This function correctly handles aliased paths and adds an 'active' class * attribute to links that point to the current page (for theming), so all * internal links output by modules should be generated by this function if * possible. * * However, for links enclosed in translatable text you should use t() and * embed the HTML anchor tag directly in the translated string. For example: * @code * t('Visit the <a href="@url">settings</a> page', array('@url' => url('admin'))); * @endcode * This keeps the context of the link title ('settings' in the example) for * translators. * * @param string $text * The translated link text for the anchor tag. * @param string $path * The internal path or external URL being linked to, such as "node/34" or * "http://example.com/foo". After the url() function is called to construct * the URL from $path and $options, the resulting URL is passed through * check_plain() before it is inserted into the HTML anchor tag, to ensure * well-formed HTML. See url() for more information and notes. * @param array $options * An associative array of additional options. Defaults to an empty array. It * may contain the following elements. * - 'attributes': An associative array of HTML attributes to apply to the * anchor tag. If element 'class' is included, it must be an array; 'title' * must be a string; other elements are more flexible, as they just need * to work in a call to drupal_attributes($options['attributes']). * - 'html' (default FALSE): Whether $text is HTML or just plain-text. For * example, to make an image tag into a link, this must be set to TRUE, or * you will see the escaped HTML image tag. $text is not sanitized if * 'html' is TRUE. The calling function must ensure that $text is already * safe. * - 'language': An optional language object. If the path being linked to is * internal to the site, $options['language'] is used to determine whether * the link is "active", or pointing to the current page (the language as * well as the path must match). This element is also used by url(). * - Additional $options elements used by the url() function. * * @return string * An HTML string containing a link to the given path. * * @see url() */ public function l($text, $path, array $options = array()) { return $this->drupal7->l($text, $path, $options); }
public function set($name, $value) { $this->drupal7->variable_set($name, $value); }