Beispiel #1
1
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $forum_config = $this->config('forum.settings');
     $vid = $forum_config->get('vocabulary');
     $vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid);
     if (!$vocabulary) {
         throw new NotFoundHttpException();
     }
     // Build base taxonomy term overview.
     $form = parent::buildForm($form, $form_state, $vocabulary);
     foreach (Element::children($form['terms']) as $key) {
         if (isset($form['terms'][$key]['#term'])) {
             $term = $form['terms'][$key]['#term'];
             $form['terms'][$key]['term']['#url'] = Url::fromRoute('forum.page', ['taxonomy_term' => $term->id()]);
             unset($form['terms'][$key]['operations']['#links']['delete']);
             $route_parameters = $form['terms'][$key]['operations']['#links']['edit']['url']->getRouteParameters();
             if (!empty($term->forum_container->value)) {
                 $form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit container');
                 $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', $route_parameters);
             } else {
                 $form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit forum');
                 $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_form', $route_parameters);
             }
             // We don't want the redirect from the link so we can redirect the
             // delete action.
             unset($form['terms'][$key]['operations']['#links']['edit']['query']['destination']);
         }
     }
     // Remove the alphabetical reset.
     unset($form['actions']['reset_alphabetical']);
     // Use the existing taxonomy overview submit handler.
     $form['terms']['#empty'] = $this->t('No containers or forums available. <a href="@container">Add container</a> or <a href="@forum">Add forum</a>.', array('@container' => $this->url('forum.add_container'), '@forum' => $this->url('forum.add_forum')));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $url = Url::fromRoute('autofloat.settings');
     $config_link = \Drupal::l(t('AutoFloat Filter Settings'), $url);
     $form['notice'] = array('#markup' => t('!config_link are shared by all the text formats where it is enabled.', array('!config_link' => $config_link)));
     return $form;
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $block = array('#theme' => 'fblikebutton', '#layout' => $this->configuration['layout'], '#show_faces' => $this->configuration['show_faces'], '#action' => $this->configuration['action'], '#font' => $this->configuration['font'], '#color_scheme' => $this->configuration['color_scheme'], '#width' => $this->configuration['iframe_width'], '#height' => $this->configuration['iframe_height'], '#other_css' => $this->configuration['iframe_css'], '#language' => $this->configuration['language']);
     // If it's not for the current page
     if ($this->configuration['block_url'] != '<current>') {
         $block['#url'] = $this->configuration['block_url'];
     } else {
         // Avoid this block to be cached
         $block['#cache'] = array('max-age' => 0);
         /**
          * Drupal uses the /node path to refers to the frontpage. That's why facebook
          * could point to www.example.com/node instead of wwww.example.com.
          * 
          * To avoid this, we check if the current path is the frontpage
          */
         // Check if the path is pointing home
         if (\Drupal::routeMatch()->getRouteName() == 'view.frontpage.page_1') {
             global $base_url;
             $block['#url'] = $base_url;
         } else {
             $block['#url'] = Url::fromRoute('<current>', array(), array('absolute' => true))->toString();
         }
     }
     return $block;
 }
 /**
  * Tests rendering form elements without passing through
  * \Drupal::formBuilder()->doBuildForm().
  */
 function testDrupalRenderFormElements()
 {
     // Define a series of form elements.
     $element = array('#type' => 'button', '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'submit'));
     $element = array('#type' => 'textfield', '#title' => $this->randomMachineName(), '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'text'));
     $element = array('#type' => 'password', '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'password'));
     $element = array('#type' => 'textarea', '#title' => $this->randomMachineName(), '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//textarea');
     $element = array('#type' => 'radio', '#title' => $this->randomMachineName(), '#value' => FALSE);
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'radio'));
     $element = array('#type' => 'checkbox', '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'checkbox'));
     $element = array('#type' => 'select', '#title' => $this->randomMachineName(), '#options' => array(0 => $this->randomMachineName(), 1 => $this->randomMachineName()));
     $this->assertRenderedElement($element, '//select');
     $element = array('#type' => 'file', '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'file'));
     $element = array('#type' => 'item', '#title' => $this->randomMachineName(), '#markup' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//div[contains(@class, :class) and contains(., :markup)]/label[contains(., :label)]', array(':class' => 'form-type-item', ':markup' => $element['#markup'], ':label' => $element['#title']));
     $element = array('#type' => 'hidden', '#title' => $this->randomMachineName(), '#value' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'hidden'));
     $element = array('#type' => 'link', '#title' => $this->randomMachineName(), '#url' => Url::fromRoute('common_test.destination'), '#options' => array('absolute' => TRUE));
     $this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array(':href' => \Drupal::urlGenerator()->generateFromPath('common-test/destination', ['absolute' => TRUE]), ':title' => $element['#title']));
     $element = array('#type' => 'details', '#open' => TRUE, '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//details/summary[contains(., :title)]', array(':title' => $element['#title']));
     $element = array('#type' => 'details', '#open' => TRUE, '#title' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//details');
     $element['item'] = array('#type' => 'item', '#title' => $this->randomMachineName(), '#markup' => $this->randomMachineName());
     $this->assertRenderedElement($element, '//details/div/div[contains(@class, :class) and contains(., :markup)]', array(':class' => 'form-type-item', ':markup' => $element['item']['#markup']));
 }
 /**
  * {@inheritdoc}
  */
 public function getDefaultOperations(EntityInterface $entity)
 {
     /** @var \Drupal\commerce_tax\Entity\TaxRateInterface $entity */
     $operations = parent::getDefaultOperations($entity);
     $operations['rate_amounts'] = ['title' => $this->t('View rate amounts'), 'url' => Url::fromRoute('entity.commerce_tax_rate_amount.collection', ['commerce_tax_rate' => $entity->id()])];
     return $operations;
 }
/**
 * Add items to the toolbar menu.
 *
 * The toolbar is a container for administrative and site-global interactive
 * components.
 *
 * The toolbar provides a common styling for items denoted by the
 * .toolbar-tab class.
 *
 * The toolbar provides a construct called a 'tray'. The tray is a container
 * for content. The tray may be associated with a toggle in the administration
 * bar. The toggle shows or hides the tray and is optimized for small and
 * large screens. To create this association, hook_toolbar() returns one or
 * more render elements of type 'toolbar_item', containing the toggle and tray
 * elements in its 'tab' and 'tray' properties.
 *
 * The following properties are available:
 *   - 'tab': A renderable array.
 *   - 'tray': Optional. A renderable array.
 *   - '#weight': Optional. Integer weight used for sorting toolbar items in
 *     administration bar area.
 *
 * This hook is invoked in toolbar_pre_render().
 *
 * @return
 *   An array of toolbar items, keyed by unique identifiers such as 'home' or
 *   'administration', or the short name of the module implementing the hook.
 *   The corresponding value is a render element of type 'toolbar_item'.
 *
 * @see toolbar_pre_render()
 * @ingroup toolbar_tabs
 */
function hook_toolbar()
{
    $items = array();
    // Add a search field to the toolbar. The search field employs no toolbar
    // module theming functions.
    $items['global_search'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'search', '#attributes' => array('placeholder' => t('Search the site'), 'class' => array('search-global'))), '#weight' => 200, '#attached' => array('css' => array(drupal_get_path('module', 'search') . '/css/search.base.css')));
    // The 'Home' tab is a simple link, which is wrapped in markup associated
    // with a visual tab styling.
    $items['home'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'link', '#title' => t('Home'), '#url' => Url::fromRoute('<front>'), '#options' => array('attributes' => array('title' => t('Home page'), 'class' => array('toolbar-icon', 'toolbar-icon-home')))), '#weight' => -20);
    // A tray may be associated with a tab.
    //
    // When the tab is activated, the tray will become visible, either in a
    // horizontal or vertical orientation on the screen.
    //
    // The tray should contain a renderable array. An optional #heading property
    // can be passed. This text is written to a heading tag in the tray as a
    // landmark for accessibility.
    $items['commerce'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'link', '#title' => t('Shopping cart'), '#url' => Url::fromRoute('cart'), '#options' => array('html' => FALSE, 'attributes' => array('title' => t('Shopping cart')))), 'tray' => array('#heading' => t('Shopping cart actions'), 'shopping_cart' => array('#theme' => 'item_list', '#items' => array())), '#weight' => 150);
    // The tray can be used to render arbritrary content.
    //
    // A renderable array passed to the 'tray' property will be rendered outside
    // the administration bar but within the containing toolbar element.
    //
    // If the default behavior and styling of a toolbar tray is not desired, one
    // can render content to the toolbar element and apply custom theming and
    // behaviors.
    $items['user_messages'] = array('#type' => 'toolbar_item', 'tab' => array('#type' => 'link', '#theme' => 'user_message_toolbar_tab', '#theme_wrappers' => array(), '#title' => t('Messages'), '#url' => Url::fromRoute('user.message'), '#options' => array('attributes' => array('title' => t('Messages')))), 'tray' => array('#heading' => t('User messages'), 'messages' => array()), '#weight' => 125);
    return $items;
}
 /**
  * Assert that a trail exists in the internal browser.
  *
  * @param array $trail
  *   An associative array whose keys are expected breadcrumb link paths and
  *   whose values are expected breadcrumb link texts (not sanitized).
  */
 protected function assertBreadcrumbParts($trail)
 {
     // Compare paths with actual breadcrumb.
     $parts = $this->getBreadcrumbParts();
     $pass = TRUE;
     // There may be more than one breadcrumb on the page. If $trail is empty
     // this test would go into an infinite loop, so we need to check that too.
     while ($trail && !empty($parts)) {
         foreach ($trail as $path => $title) {
             // If the path is empty, generate the path from the <front> route.  If
             // the path does not start with a leading slash, then run it through
             // Url::fromUri('base:')->toString() to get the correct base
             // prepended.
             if ($path == '') {
                 $url = Url::fromRoute('<front>')->toString();
             } elseif ($path[0] != '/') {
                 $url = Url::fromUri('base:' . $path)->toString();
             } else {
                 $url = $path;
             }
             $part = array_shift($parts);
             $pass = $pass && $part['href'] === $url && $part['text'] === SafeMarkup::checkPlain($title);
         }
     }
     // No parts must be left, or an expected "Home" will always pass.
     $pass = $pass && empty($parts);
     $this->assertTrue($pass, format_string('Breadcrumb %parts found on @path.', array('%parts' => implode(' » ', $trail), '@path' => $this->getUrl())));
 }
 /**
  * Writes a log messages and retrieves it via the REST API.
  */
 public function testWatchdog()
 {
     // Write a log message to the DB.
     $this->container->get('logger.channel.rest')->notice('Test message');
     // Get the ID of the written message.
     $id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, array(':type' => 'rest'))->fetchField();
     // Create a user account that has the required permissions to read
     // the watchdog resource via the REST API.
     $account = $this->drupalCreateUser(array('restful get dblog'));
     $this->drupalLogin($account);
     $response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => $id, '_format' => $this->defaultFormat]), 'GET');
     $this->assertResponse(200);
     $this->assertHeader('content-type', $this->defaultMimeType);
     $log = Json::decode($response);
     $this->assertEqual($log['wid'], $id, 'Log ID is correct.');
     $this->assertEqual($log['type'], 'rest', 'Type of log message is correct.');
     $this->assertEqual($log['message'], 'Test message', 'Log message text is correct.');
     // Request an unknown log entry.
     $response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => 9999, '_format' => $this->defaultFormat]), 'GET');
     $this->assertResponse(404);
     $decoded = Json::decode($response);
     $this->assertEqual($decoded['message'], 'Log entry with ID 9999 was not found', 'Response message is correct.');
     // Make a bad request (a true malformed request would never be a route match).
     $response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => 0, '_format' => $this->defaultFormat]), 'GET');
     $this->assertResponse(400);
     $decoded = Json::decode($response);
     $this->assertEqual($decoded['message'], 'No log entry ID was provided', 'Response message is correct.');
 }
Beispiel #9
0
 /**
  * Loops through and displays all form errors.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 protected function displayErrorMessages(array $form, FormStateInterface $form_state)
 {
     $error_links = [];
     $errors = $form_state->getErrors();
     // Loop through all form errors and check if we need to display a link.
     foreach ($errors as $name => $error) {
         $form_element = FormElementHelper::getElementByName($name, $form);
         $title = FormElementHelper::getElementTitle($form_element);
         // Only show links to erroneous elements that are visible.
         $is_visible_element = Element::isVisibleElement($form_element);
         // Only show links for elements that have a title themselves or have
         // children with a title.
         $has_title = !empty($title);
         // Only show links for elements with an ID.
         $has_id = !empty($form_element['#id']);
         // Do not show links to elements with suppressed messages. Most often
         // their parent element is used for inline errors.
         if (!empty($form_element['#error_no_message'])) {
             unset($errors[$name]);
         } elseif ($is_visible_element && $has_title && $has_id) {
             $error_links[] = $this->l($title, Url::fromRoute('<none>', [], ['fragment' => $form_element['#id'], 'external' => TRUE]));
             unset($errors[$name]);
         }
     }
     // Set normal error messages for all remaining errors.
     foreach ($errors as $error) {
         $this->drupalSetMessage($error, 'error');
     }
     if (!empty($error_links)) {
         $render_array = [['#markup' => $this->formatPlural(count($error_links), '1 error has been found: ', '@count errors have been found: ')], ['#theme' => 'item_list', '#items' => $error_links, '#context' => ['list_style' => 'comma-list']]];
         $message = $this->renderer->renderPlain($render_array);
         $this->drupalSetMessage($message, 'error');
     }
 }
 /**
  * Tests edit form destinations.
  */
 public function testFormSaveDestination()
 {
     // Create new moderated content in draft.
     $this->drupalPostForm('node/add/moderated_content', ['title[0][value]' => 'Some moderated content', 'body[0][value]' => 'First version of the content.'], t('Save as Draft'));
     $node = $this->drupalGetNodeByTitle('Some moderated content');
     $edit_path = sprintf('node/%d/edit', $node->id());
     // After saving, we should be at the canonical URL and viewing the first
     // revision.
     $this->assertUrl(Url::fromRoute('entity.node.canonical', ['node' => $node->id()]));
     $this->assertText('First version of the content.');
     // Make a new forward revision; after saving, we should be on the "Latest
     // version" tab.
     $this->drupalPostForm($edit_path, ['body[0][value]' => 'Second version of the content.'], t('Save and transition to Needs Review'));
     $this->assertUrl(Url::fromRoute('entity.node.latest_version', ['node' => $node->id()]));
     $this->assertText('Second version of the content.');
     // Make a new published revision; after saving, we should be at the
     // canonical URL.
     $this->drupalPostForm($edit_path, ['body[0][value]' => 'Third version of the content.'], t('Save and transition to Published'));
     $this->assertUrl(Url::fromRoute('entity.node.canonical', ['node' => $node->id()]));
     $this->assertText('Third version of the content.');
     // Make a new forward revision; after saving, we should once again be on the
     // "Latest version" tab.
     $this->drupalPostForm($edit_path, ['body[0][value]' => 'Fourth version of the content.'], t('Save and create new revision in Draft'));
     $this->assertUrl(Url::fromRoute('entity.node.latest_version', ['node' => $node->id()]));
     $this->assertText('Fourth version of the content.');
 }
Beispiel #11
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, ProfileInterface $linkit_profile = NULL, $plugin_instance_id = NULL) {
    $this->linkitProfile = $linkit_profile;
    $this->linkitMatcher = $this->linkitProfile->getMatcher($plugin_instance_id);

    $form += $this->linkitMatcher->buildConfigurationForm($form, $form_state);

    $form['actions'] = array('#type' => 'actions');
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Save changes'),
      '#submit' => array('::submitForm'),
      '#button_type' => 'primary',
    );
    $form['actions']['delete'] = array(
      '#type' => 'link',
      '#title' => $this->t('Delete'),
      '#url' => Url::fromRoute('linkit.matcher.delete', [
        'linkit_profile' => $this->linkitProfile->id(),
        'plugin_instance_id' => $this->linkitMatcher->getUuid(),
      ]),
      '#attributes' => [
        'class' => ['button', 'button--danger'],
      ],
    );

    return $form;
  }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['help'] = array('#markup' => t('By default, only the "Free order" payment method is listed here. To see additional payment methods you must <a href="@install">install additional modules</a>. The "Payment Method Pack" module that comes with Ubercart provides "Check" and "COD" payment methods. The "Credit Card" module that comes with Ubercart provides a credit card payment method, although you will need an additional module to provide a payment gateway for your credit card. For more information about payment methods and settings please read the <a href="@doc">Ubercart Documentation</a>.', ['@install' => Url::fromRoute('system.modules_list')->toString(), '@doc' => Url::fromUri('http://www.drupal.org/documentation/modules/ubercart')->toString()]));
     $form['methods'] = array('#type' => 'table', '#header' => array(t('Payment method'), t('List position'), t('Operations')), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'uc-payment-method-weight')));
     foreach ($this->paymentMethodManager->getDefinitions() as $id => $method) {
         $form['methods'][$id]['#attributes']['class'][] = 'draggable';
         $form['methods'][$id]['status'] = array('#type' => 'checkbox', '#title' => SafeMarkup::checkPlain($method['name']), '#default_value' => $method['checkout']);
         $form['methods'][$id]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $method['name'])), '#title_display' => 'invisible', '#default_value' => $method['weight'], '#attributes' => array('class' => array('uc-payment-method-weight')));
         if (empty($method['no_gateway'])) {
             $gateways = _uc_payment_gateway_list($id, TRUE);
             $options = array();
             foreach ($gateways as $gateway_id => $gateway) {
                 $options[$gateway_id] = $gateway['title'];
             }
             if ($options) {
                 $form['methods'][$id]['status']['#title'] .= ' (' . t('includes %gateways', array('%gateways' => implode(', ', $options))) . ')';
             }
         }
         $links = array();
         if (!empty($method['settings_form'])) {
             $links['settings'] = array('title' => t('Settings'), 'url' => Url::fromRoute('uc_payment.method_settings', ['method' => $id]));
         }
         // $links['conditions'] = array(
         //   'title' => t('Conditions'),
         //   'url' => Url::fromRoute('admin/store/config/payment/manage/uc_payment_method_', ['method' => $id]),
         // );
         $form['methods'][$id]['settings'] = array('#type' => 'operations', '#links' => $links);
     }
     return parent::buildForm($form, $form_state);
 }
Beispiel #13
0
 /**
  * Test translated breadcrumbs.
  */
 public function testTranslatedBreadcrumbs()
 {
     // Ensure non-translated breadcrumb is correct.
     $breadcrumb = array(Url::fromRoute('<front>')->toString() => 'Home');
     foreach ($this->terms as $term) {
         $breadcrumb[$term->url()] = $term->label();
     }
     // The last item will not be in the breadcrumb.
     array_pop($breadcrumb);
     // Check the breadcrumb on the leaf term page.
     $term = $this->getLeafTerm();
     $this->assertBreadcrumb($term->urlInfo(), $breadcrumb, $term->label());
     $languages = \Drupal::languageManager()->getLanguages();
     // Construct the expected translated breadcrumb.
     $breadcrumb = array(Url::fromRoute('<front>', [], ['language' => $languages[$this->translateToLangcode]])->toString() => 'Home');
     foreach ($this->terms as $term) {
         $translated = $term->getTranslation($this->translateToLangcode);
         $url = $translated->url('canonical', ['language' => $languages[$this->translateToLangcode]]);
         $breadcrumb[$url] = $translated->label();
     }
     array_pop($breadcrumb);
     // Check for the translated breadcrumb on the translated leaf term page.
     $term = $this->getLeafTerm();
     $translated = $term->getTranslation($this->translateToLangcode);
     $this->assertBreadcrumb($translated->urlInfo('canonical', ['language' => $languages[$this->translateToLangcode]]), $breadcrumb, $translated->label());
 }
 /**
  * Tests \Drupal\Core\Cache\Context\SessionExistsCacheContext::getContext().
  */
 public function testCacheContext()
 {
     $this->dumpHeaders = TRUE;
     // 1. No session (anonymous).
     $this->assertSessionCookieOnClient(FALSE);
     $this->drupalGet(Url::fromRoute('<front>'));
     $this->assertSessionCookieOnClient(FALSE);
     $this->assertRaw('Session does not exist!');
     $this->assertRaw('[session.exists]=0');
     // 2. Session (authenticated).
     $this->assertSessionCookieOnClient(FALSE);
     $this->drupalLogin($this->rootUser);
     $this->assertSessionCookieOnClient(TRUE);
     $this->assertRaw('Session exists!');
     $this->assertRaw('[session.exists]=1');
     $this->drupalLogout();
     $this->assertSessionCookieOnClient(FALSE);
     $this->assertRaw('Session does not exist!');
     $this->assertRaw('[session.exists]=0');
     // 3. Session (anonymous).
     $this->assertSessionCookieOnClient(FALSE);
     $this->drupalGet(Url::fromRoute('<front>', [], ['query' => ['trigger_session' => 1]]));
     $this->assertSessionCookieOnClient(TRUE);
     $this->assertRaw('Session does not exist!');
     $this->assertRaw('[session.exists]=0');
     $this->drupalGet(Url::fromRoute('<front>'));
     $this->assertSessionCookieOnClient(TRUE);
     $this->assertRaw('Session exists!');
     $this->assertRaw('[session.exists]=1');
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $fblikebutton_node_options = node_type_get_names();
     $config = $this->config('fblikebutton.settings');
     $form['fblikebutton_dynamic_visibility'] = array('#type' => 'details', '#title' => $this->t('Visibility settings'), '#open' => TRUE);
     $form['fblikebutton_dynamic_visibility']['fblikebutton_node_types'] = array('#type' => 'checkboxes', '#title' => $this->t('Display the Like button on these content types:'), '#options' => $fblikebutton_node_options, '#default_value' => $config->get('node_types'), '#description' => $this->t('Each of these content types will have the "like" button automatically added to them.'));
     /** 
      * @TODO: Uncomment this when the module is also able to add the button to 
      * the links area
      * 
     $form['fblikebutton_dynamic_visibility']['fblikebutton_full_node_display'] = array(
       '#type' => 'radios',
       '#title' => $this->t('Where do you want to show the Like button (full node view)?'),
       '#options' => array(
         $this->t('Content area'),
         $this->t('Links area')
       ),
       '#default_value' => $config->get('full_node_display'),
       '#description' => $this->t('If <em>Content area</em> is selected, the button will appear in the same area as the node content. When you select <em>Links area</em> the Like button will be visible in the links area, usually at the bottom of the node (When you select this last option you may want to adjust the Appearance settings). You can also configure Static Like Button Blocks in'. \Drupal::l($this->t('block page'), Url::fromRoute('block.admin_display')) . '.'),
     );
     */
     $form['fblikebutton_dynamic_visibility']['fblikebutton_teaser_display'] = array('#type' => 'radios', '#title' => $this->t('Where do you want to show the Like button on teasers?'), '#options' => array($this->t('Don\'t show on teasers'), $this->t('Content area')), '#default_value' => $config->get('teaser_display'), '#description' => $this->t('If you want to show the like button on teasers you can select the display area.'));
     $form['fblikebutton_dynamic_appearance'] = array('#type' => 'details', '#title' => $this->t('Appearance settings'), '#open' => TRUE);
     $form['fblikebutton_dynamic_appearance']['fblikebutton_layout'] = array('#type' => 'select', '#title' => $this->t('Layout style'), '#options' => array('standard' => $this->t('Standard'), 'box_count' => $this->t('Box Count'), 'button_count' => $this->t('Button Count'), 'button' => $this->t('Button')), '#default_value' => $config->get('layout'), '#description' => $this->t('Determines the size and amount of social context next to the button.'));
     // The actial values passed in from the options will be converted to a boolean
     // in the validation function, so it doesn't really matter what we use.
     $form['fblikebutton_dynamic_appearance']['fblikebutton_show_faces'] = array('#type' => 'select', '#title' => $this->t('Show faces in the box?'), '#options' => array(t('Do not show faces'), $this->t('Show faces')), '#default_value' => $config->get('show_faces', TRUE), '#description' => $this->t('Show profile pictures below the button. Only works if <em>Layout style</em> (found above) is set to <em>Standard</em> (otherwise, value is ignored).'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_action'] = array('#type' => 'select', '#title' => $this->t('Verb to display'), '#options' => array('like' => $this->t('Like'), 'recommend' => $this->t('Recommend')), '#default_value' => $config->get('action'), '#description' => $this->t('The verbiage to display inside the button itself.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_font'] = array('#type' => 'select', '#title' => $this->t('Font'), '#options' => array('arial' => 'Arial', 'lucida+grande' => 'Lucida Grande', 'segoe+ui' => 'Segoe UI', 'tahoma' => 'Tahoma', 'trebuchet+ms' => 'Trebuchet MS', 'verdana' => 'Verdana'), '#default_value' => $config->get('font', 'arial'), '#description' => $this->t('The font with which to display the text of the button.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_color_scheme'] = array('#type' => 'select', '#title' => $this->t('Color scheme'), '#options' => array('light' => $this->t('Light'), 'dark' => $this->t('Dark')), '#default_value' => $config->get('color_scheme'), '#description' => $this->t('The color scheme of the box environtment.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_weight'] = array('#type' => 'number', '#title' => $this->t('Weight'), '#default_value' => $config->get('weight'), '#description' => $this->t('The weight determines where, at the content block, the like button will appear. The larger the weight, the lower it will appear on the node. For example, if you want the button to appear more toward the top of the node, choose <em>-40</em> as opposed to <em>-39, -38, 0, 1,</em> or <em>50,</em> etc. To position the Like button in its own block, go to the ' . \Drupal::l($this->t('block page'), Url::fromRoute('block.admin_display')) . '.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_language'] = array('#type' => 'textfield', '#title' => $this->t('Language'), '#default_value' => $config->get('language'), '#description' => $this->t('Specific language to use. Default is English. Examples:<br />French (France): <em>fr_FR</em><br />French (Canada): <em>fr_CA</em><br />More information can be found at http://developers.facebook.com/docs/internationalization/ and a full XML list can be found at http://www.facebook.com/translations/FacebookLocales.xml'));
     return parent::buildForm($form, $form_state);
 }
Beispiel #16
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $current_path = $request->attributes->get('_system_path');
     $current_url = Url::createFromRequest($request);
     $devel_config = $this->config('devel.settings');
     $form['queries'] = array('#type' => 'fieldset', '#title' => t('Query log'));
     $description = t('Display a log of the database queries needed to generate the current page, and the execution time for each. Also, queries which are repeated during a single page view are summed in the # column, and printed in red since they are candidates for caching.');
     $form['queries']['query_display'] = array('#type' => 'checkbox', '#title' => t('Display query log'), '#default_value' => $devel_config->get('query_display'), '#description' => $description);
     $form['queries']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="query_display"]' => array('checked' => FALSE))));
     $form['queries']['settings']['query_sort'] = array('#type' => 'radios', '#title' => t('Sort query log'), '#default_value' => $devel_config->get('query_sort'), '#options' => array(t('by source'), t('by duration')), '#description' => t('The query table can be sorted in the order that the queries were executed or by descending duration.'));
     $form['queries']['settings']['execution'] = array('#type' => 'textfield', '#title' => t('Slow query highlighting'), '#default_value' => $devel_config->get('execution'), '#size' => 4, '#maxlength' => 4, '#description' => t('Enter an integer in milliseconds. Any query which takes longer than this many milliseconds will be highlighted in the query log. This indicates a possibly inefficient query, or a candidate for caching.'));
     $form['api_url'] = array('#type' => 'textfield', '#title' => t('API Site'), '#default_value' => $devel_config->get('api_url'), '#description' => t('The base URL for your developer documentation links. You might change this if you run <a href="!url">api.module</a> locally.', array('!url' => Url::fromUri('http://drupal.org/project/api')->toString())));
     $form['timer'] = array('#type' => 'checkbox', '#title' => t('Display page timer'), '#default_value' => $devel_config->get('timer'), '#description' => t('Display page execution time in the query log box.'));
     $form['memory'] = array('#type' => 'checkbox', '#title' => t('Display memory usage'), '#default_value' => $devel_config->get('memory'), '#description' => t('Display how much memory is used to generate the current page. This will show memory usage when devel_init() is called and when devel_exit() is called.'));
     $form['redirect_page'] = array('#type' => 'checkbox', '#title' => t('Display redirection page'), '#default_value' => $devel_config->get('redirect_page'), '#description' => t('When a module executes drupal_goto(), the query log and other developer information is lost. Enabling this setting presents an intermediate page to developers so that the log can be examined before continuing to the destination page.'));
     $form['page_alter'] = array('#type' => 'checkbox', '#title' => t('Display $page array'), '#default_value' => $devel_config->get('page_alter'), '#description' => t('Display $page array from <a href="http://api.drupal.org/api/function/hook_page_alter/7">hook_page_alter()</a> in the messages area of each page.'));
     $form['raw_names'] = array('#type' => 'checkbox', '#title' => t('Display machine names of permissions and modules'), '#default_value' => $devel_config->get('raw_names'), '#description' => t('Display the language-independent machine names of the permissions in mouse-over hints on the !Permissions page and the module base file names on the @Permissions and !Modules pages.', array('!Permissions' => $this->l(t('Permissions'), Url::fromRoute('user.admin_permissions')), '@Permissions' => t('Permissions'), '!Modules' => $this->l(t('Modules'), Url::fromRoute('system.modules_list')))));
     $error_handlers = devel_get_handlers();
     $form['error_handlers'] = array('#type' => 'select', '#title' => t('Error handlers'), '#options' => array(DEVEL_ERROR_HANDLER_NONE => t('None'), DEVEL_ERROR_HANDLER_STANDARD => t('Standard Drupal'), DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Krumo backtrace in the message area'), DEVEL_ERROR_HANDLER_BACKTRACE_KRUMO => t('Krumo backtrace above the rendered page')), '#multiple' => TRUE, '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_NONE : $error_handlers, '#description' => SafeMarkup::set(t('Select the error handler(s) to use, in case you <a href="@choose">choose to show errors on screen</a>.', array('@choose' => $this->url('system.logging_settings'))) . '<ul>' . '<li>' . t('<em>None</em> is a good option when stepping through the site in your debugger.') . '</li>' . '<li>' . t('<em>Standard Drupal</em> does not display all the information that is often needed to resolve an issue.') . '</li>' . '<li>' . t('<em>Krumo backtrace</em> displays nice debug information when any type of error is noticed, but only to users with the %perm permission.', array('%perm' => t('Access developer information'))) . '</li></ul>' . t('Depending on the situation, the theme, the size of the call stack and the arguments, etc., some handlers may not display their messages, or display them on the subsequent page. Select <em>Standard Drupal</em> <strong>and</strong> <em>Krumo backtrace above the rendered page</em> to maximize your chances of not missing any messages.') . '<br />' . t('Demonstrate the current error handler(s):') . ' ' . $this->l('notice', $current_url, array('query' => array('demo' => 'notice'))) . ', ' . $this->l('notice+warning', $current_url, array('query' => array('demo' => 'warning'))) . ', ' . $this->l('notice+warning+error', $current_url, array('query' => array('demo' => 'error'))) . ' ' . t('(The presentation of the @error is determined by PHP.)', array('@error' => 'error'))));
     $form['error_handlers']['#size'] = count($form['error_handlers']['#options']);
     if ($request->query->has('demo')) {
         if ($request->getMethod() == 'GET') {
             $this->demonstrateErrorHandlers($request->query->get('demo'));
         }
         $request->query->remove('demo');
     }
     $options = array('default', 'blue', 'green', 'orange', 'white', 'disabled');
     $form['krumo_skin'] = array('#type' => 'radios', '#title' => t('Krumo display'), '#description' => t('Select a skin for your debug messages or select <em>disabled</em> to display object and array output in standard PHP format.'), '#options' => array_combine($options, $options), '#default_value' => $devel_config->get('krumo_skin'));
     $form['rebuild_theme'] = array('#type' => 'checkbox', '#title' => t('Rebuild the theme information like the registry'), '#description' => t('While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.'), '#default_value' => $devel_config->get('rebuild_theme'));
     $form['use_uncompressed_jquery'] = array('#type' => 'checkbox', '#title' => t('Use uncompressed jQuery'), '#default_value' => $devel_config->get('use_uncompressed_jquery'), '#description' => t("Use a human-readable version of jQuery instead of the minified version that ships with Drupal, to make JavaScript debugging easier."));
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, $view_mode)
 {
     if ($view_mode == 'customer' && $order->access('invoice')) {
         $build = array('#type' => 'link', '#title' => $this->t('Click to open a window with a printable invoice.'), '#url' => Url::fromRoute('uc_order.user_invoice_print', ['user' => $order->getOwnerId(), 'uc_order' => $order->id()], array('attributes' => array('onclick' => "window.open(this.href, '" . $this->t('Invoice') . "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=480,left=50,top=50'); return false;"))));
         return $build;
     }
 }
 /**
  * Tests changing the published status on a node without fields.
  */
 public function testPublishedStatusNoFields()
 {
     // Test changing the published status of an article without fields.
     $this->drupalLogin($this->administrator);
     // Delete all fields.
     $this->drupalGet('admin/structure/types/manage/article/fields');
     $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $this->fieldName . '/delete', array(), t('Delete'));
     $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags/delete', array(), t('Delete'));
     $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image/delete', array(), t('Delete'));
     // Add a node.
     $default_langcode = $this->langcodes[0];
     $values[$default_langcode] = array('title' => array(array('value' => $this->randomMachineName())));
     $entity_id = $this->createEntity($values[$default_langcode], $default_langcode);
     $entity = entity_load($this->entityTypeId, $entity_id, TRUE);
     // Add a content translation.
     $langcode = 'fr';
     $language = ConfigurableLanguage::load($langcode);
     $values[$langcode] = array('title' => array(array('value' => $this->randomMachineName())));
     $entity_type_id = $entity->getEntityTypeId();
     $add_url = Url::fromRoute("entity.{$entity_type_id}.content_translation_add", [$entity->getEntityTypeId() => $entity->id(), 'source' => $default_langcode, 'target' => $langcode], array('language' => $language));
     $this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), t('Save and unpublish (this translation)'));
     $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
     $translation = $entity->getTranslation($langcode);
     // Make sure we unpublished the node correctly.
     $this->assertFalse($this->manager->getTranslationMetadata($translation)->isPublished(), 'The translation has been correctly unpublished.');
 }
 /**
  * Displays links to all products that have not been categorized.
  *
  * @return
  *   Renderable form array.
  */
 public function orphans()
 {
     $build = array();
     if ($this->config('taxonomy.settings')->get('maintain_index_table')) {
         $vid = $this->config('uc_catalog.settings')->get('vocabulary');
         $product_types = uc_product_types();
         $field = FieldStorageConfig::loadByName('node', 'taxonomy_catalog');
         //@todo - figure this out
         // $field is a config object, not an array, so this doesn't work.
         //$types = array_intersect($product_types, $field['bundles']['node']);
         $types = $product_types;
         //temporary to get this to work at all
         $result = db_query('SELECT DISTINCT n.nid, n.title FROM {node_field_data} n LEFT JOIN (SELECT ti.nid, td.vid FROM {taxonomy_index} ti LEFT JOIN {taxonomy_term_data} td ON ti.tid = td.tid WHERE td.vid = :vid) txnome ON n.nid = txnome.nid WHERE n.type IN (:types[]) AND txnome.vid IS NULL', [':vid' => $vid, ':types[]' => $types]);
         $rows = array();
         while ($node = $result->fetchObject()) {
             $rows[] = $this->l($node->title, Url::fromRoute('entity.node.edit_form', ['node' => $node->nid], ['query' => ['destination' => 'admin/store/products/orphans']]));
         }
         if (count($rows) > 0) {
             $build['orphans'] = array('#theme' => 'item_list', '#items' => $rows);
         } else {
             $build['orphans'] = array('#markup' => $this->t('All products are currently listed in the catalog.'), '#prefix' => '<p>', '#suffix' => '</p>');
         }
     } else {
         $build['orphans'] = array('#markup' => $this->t('The node terms index is not being maintained, so Ubercart can not determine which products are not entered into the catalog.'), '#prefix' => '<p>', '#suffix' => '</p>');
     }
     return $build;
 }
 /**
  * Test access to the editor image dialog.
  */
 public function testEditorImageDialogAccess()
 {
     $url = Url::fromRoute('editor.image_dialog', ['editor' => 'plain_text']);
     $session = $this->assertSession();
     // With no text editor, expect a 404.
     $this->drupalGet($url);
     $session->statusCodeEquals(404);
     // With a text editor but without image upload settings, expect a 200, but
     // there should not be an input[type=file].
     $editor = Editor::create(['editor' => 'ckeditor', 'format' => 'plain_text', 'settings' => ['toolbar' => ['rows' => [[['name' => 'Media', 'items' => ['DrupalImage']]]]], 'plugins' => []], 'image_upload' => ['status' => FALSE, 'scheme' => 'public', 'directory' => 'inline-images', 'max_size' => '', 'max_dimensions' => ['width' => 0, 'height' => 0]]]);
     $editor->save();
     $this->resetAll();
     $this->drupalGet($url);
     $this->assertTrue($this->cssSelect('input[type=text][name="attributes[src]"]'), 'Image uploads disabled: input[type=text][name="attributes[src]"] is present.');
     $this->assertFalse($this->cssSelect('input[type=file]'), 'Image uploads disabled: input[type=file] is absent.');
     $session->statusCodeEquals(200);
     // With image upload settings, expect a 200, and now there should be an
     // input[type=file].
     $editor->setImageUploadSettings(['status' => TRUE] + $editor->getImageUploadSettings())->save();
     $this->resetAll();
     $this->drupalGet($url);
     $this->assertFalse($this->cssSelect('input[type=text][name="attributes[src]"]'), 'Image uploads enabled: input[type=text][name="attributes[src]"] is absent.');
     $this->assertTrue($this->cssSelect('input[type=file]'), 'Image uploads enabled: input[type=file] is present.');
     $session->statusCodeEquals(200);
 }
Beispiel #21
0
 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\eck\Entity\EckEntity */
     $row['id'] = $entity->id();
     $row['title'] = \Drupal::l($this->getLabel($entity), Url::fromRoute('entity.' . $this->entityTypeId . '.canonical', array($this->entityTypeId => $entity->id())));
     return array_merge($row, parent::buildRow($entity));
 }
  /**
   * {@inheritdoc}
   */
  public function getDefaultOperations(EntityInterface $entity) {
    $operations = parent::getDefaultOperations($entity);

    if (isset($operations['edit'])) {
      $operations['edit']['title'] = t('Edit profile');
    }

    $operations['matchers'] = [
      'title' => t('Manage matchers'),
      'weight' => 10,
      'url' => Url::fromRoute('linkit.matchers', [
        'linkit_profile' => $entity->id()
      ]),
    ];

    $operations['attributes'] = [
      'title' => t('Manage attributes'),
      'weight' => 20,
      'url' => Url::fromRoute('linkit.attributes', [
        'linkit_profile' => $entity->id()
      ]),
    ];

    return $operations;
  }
 /**
  * {@inheritdoc}
  */
 public function getCancelUrl()
 {
     $entity_layout = $this->getEntityLayoutFromRouteMatch();
     $target_entity_type = $entity_layout->getTargetEntityType();
     $bundle_entity_type = $this->entityLayoutService->getTargetBundleEntityType($entity_layout);
     return Url::fromRoute("entity_layout.{$target_entity_type}.layout", [$bundle_entity_type => $this->entityLayout->getTargetBundle()]);
 }
Beispiel #24
0
  /**
   * Adds linkit custom autocomplete functionality to elements.
   *
   * Instead of using the core autocomplete, we use our own.
   *
   * {@inheritdoc}
   *
   * @see \Drupal\Core\Render\Element\FormElement::processAutocomplete
   */
  public static function processLinkitAutocomplete(&$element, FormStateInterface $form_state, &$complete_form) {
    $url = NULL;
    $access = FALSE;

    if (!empty($element['#autocomplete_route_name'])) {
      $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : array();
      $url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->toString(TRUE);
      /** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */
      $access_manager = \Drupal::service('access_manager');
      $access = $access_manager->checkNamedRoute($element['#autocomplete_route_name'], $parameters, \Drupal::currentUser(), TRUE);
    }

    if ($access) {
      $metadata = BubbleableMetadata::createFromRenderArray($element);
      if ($access->isAllowed()) {
        $element['#attributes']['class'][] = 'form-linkit-autocomplete';
        $metadata->addAttachments(['library' => ['linkit/linkit.autocomplete']]);
        // Provide a data attribute for the JavaScript behavior to bind to.
        $element['#attributes']['data-autocomplete-path'] = $url->getGeneratedUrl();
        $metadata = $metadata->merge($url);
      }
      $metadata
        ->merge(BubbleableMetadata::createFromObject($access))
        ->applyTo($element);
    }

    return $element;
  }
Beispiel #25
0
 /**
  * Tests menu link for route with access check.
  *
  * @see \Drupal\menu_test\Access\AccessCheck::access()
  */
 public function testMenuBlockLinksAccessCheck()
 {
     $this->drupalPlaceBlock('system_menu_block:account');
     // Test that there's link rendered on the route.
     $this->drupalGet('menu_test_access_check_session');
     $this->assertLink('Test custom route access check');
     // Page still accessible but thre should not be menu link.
     $this->drupalGet('menu_test_access_check_session');
     $this->assertResponse(200);
     $this->assertNoLink('Test custom route access check');
     // Test that page is no more accessible.
     $this->drupalGet('menu_test_access_check_session');
     $this->assertResponse(403);
     // Check for access to a restricted local task from a default local task.
     $this->drupalGet('foo/asdf');
     $this->assertResponse(200);
     $this->assertLinkByHref('foo/asdf');
     $this->assertLinkByHref('foo/asdf/b');
     $this->assertNoLinkByHref('foo/asdf/c');
     // Attempt to access a restricted local task.
     $this->drupalGet('foo/asdf/c');
     $this->assertResponse(403);
     $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', array(':class' => 'tabs primary', ':href' => Url::fromRoute('menu_test.router_test1', ['bar' => 'asdf'])->toString()));
     $this->assertTrue(empty($elements), 'No tab linking to foo/asdf found');
     $this->assertNoLinkByHref('foo/asdf/b');
     $this->assertNoLinkByHref('foo/asdf/c');
 }
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $user = \Drupal::currentUser();
     $cart_config = \Drupal::config('uc_cart.settings');
     if ($user->isAuthenticated()) {
         $email = $user->getEmail();
         $contents['#description'] = $this->t('Order information will be sent to your account e-mail listed below.');
         $contents['primary_email'] = array('#type' => 'hidden', '#value' => $email);
         $contents['email_text'] = array('#markup' => '<div>' . $this->t('<b>E-mail address:</b> @email (<a href=":url">edit</a>)', ['@email' => $email, ':url' => Url::fromRoute('entity.user.edit_form', ['user' => $user->id()], ['query' => drupal_get_destination()])->toString()]) . '</div>');
     } else {
         $email = $order->getEmail();
         $contents['#description'] = $this->t('Enter a valid email address for this order or <a href=":url">click here</a> to login with an existing account and return to checkout.', [':url' => Url::fromRoute('user.login', [], ['query' => drupal_get_destination()])->toString()]);
         $contents['primary_email'] = array('#type' => 'email', '#title' => $this->t('E-mail address'), '#default_value' => $email, '#required' => TRUE);
         if ($cart_config->get('email_validation')) {
             $contents['primary_email_confirm'] = array('#type' => 'email', '#title' => $this->t('Confirm e-mail address'), '#default_value' => $email, '#required' => TRUE);
         }
         $contents['new_account'] = array();
         if ($cart_config->get('new_account_name')) {
             $contents['new_account']['name'] = array('#type' => 'textfield', '#title' => $this->t('Username'), '#default_value' => isset($order->data->new_user_name) ? $order->data->new_user_name : '', '#maxlength' => 60, '#size' => 32);
         }
         if ($cart_config->get('new_account_password')) {
             $contents['new_account']['pass'] = array('#type' => 'password', '#title' => $this->t('Password'), '#maxlength' => 32, '#size' => 32);
             $contents['new_account']['pass_confirm'] = array('#type' => 'password', '#title' => $this->t('Confirm password'), '#description' => $this->t('Passwords must match to proceed.'), '#maxlength' => 32, '#size' => 32);
         }
         if (!empty($contents['new_account'])) {
             $contents['new_account'] += array('#type' => 'details', '#title' => $this->t('New account details'), '#description' => $this->t('<b>Optional.</b> New customers may supply custom account details.<br />We will create these for you if no values are entered.'), '#open' => TRUE);
         }
     }
     return $contents;
 }
 protected function setUp()
 {
     parent::setUp();
     $this->updateUrl = Url::fromRoute('system.db_update');
     $this->updateUser = $this->drupalCreateUser(array('administer software updates', 'access site in maintenance mode'));
     \Drupal::service('entity.definition_update_manager')->applyUpdates();
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $current_url = Url::createFromRequest($request);
     $devel_config = $this->config('devel.settings');
     $form['page_alter'] = array('#type' => 'checkbox', '#title' => t('Display $page array'), '#default_value' => $devel_config->get('page_alter'), '#description' => t('Display $page array from <a href="http://api.drupal.org/api/function/hook_page_alter/7">hook_page_alter()</a> in the messages area of each page.'));
     $form['raw_names'] = array('#type' => 'checkbox', '#title' => t('Display machine names of permissions and modules'), '#default_value' => $devel_config->get('raw_names'), '#description' => t('Display the language-independent machine names of the permissions in mouse-over hints on the <a href=":permissions_url">Permissions</a> page and the module base file names on the Permissions and <a href=":modules_url">Modules</a> pages.', array(':permissions_url' => Url::fromRoute('user.admin_permissions')->toString(), ':modules_url' => Url::fromRoute('system.modules_list')->toString())));
     $error_handlers = devel_get_handlers();
     $form['error_handlers'] = array('#type' => 'select', '#title' => t('Error handlers'), '#options' => array(DEVEL_ERROR_HANDLER_NONE => t('None'), DEVEL_ERROR_HANDLER_STANDARD => t('Standard Drupal'), DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Kint backtrace in the message area'), DEVEL_ERROR_HANDLER_BACKTRACE_KINT => t('Kint backtrace above the rendered page')), '#multiple' => TRUE, '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_NONE : $error_handlers, '#description' => [['#markup' => $this->t('Select the error handler(s) to use, in case you <a href=":choose">choose to show errors on screen</a>.', [':choose' => $this->url('system.logging_settings')])], ['#theme' => 'item_list', '#items' => [$this->t('<em>None</em> is a good option when stepping through the site in your debugger.'), $this->t('<em>Standard Drupal</em> does not display all the information that is often needed to resolve an issue.'), $this->t('<em>Kint backtrace</em> displays nice debug information when any type of error is noticed, but only to users with the %perm permission.', ['%perm' => t('Access developer information')])]], ['#markup' => $this->t('Depending on the situation, the theme, the size of the call stack and the arguments, etc., some handlers may not display their messages, or display them on the subsequent page. Select <em>Standard Drupal</em> <strong>and</strong> <em>Kint backtrace above the rendered page</em> to maximize your chances of not missing any messages.') . '<br />' . $this->t('Demonstrate the current error handler(s):') . ' ' . $this->l('notice', $current_url->setOption('query', ['demo' => 'notice'])) . ', ' . $this->l('notice+warning', $current_url->setOption('query', ['demo' => 'warning'])) . ', ' . $this->l('notice+warning+error', $current_url->setOption('query', ['demo' => 'error'])) . ' (' . $this->t('The presentation of the @error is determined by PHP.', ['@error' => 'error']) . ')']]);
     $form['error_handlers']['#size'] = count($form['error_handlers']['#options']);
     if ($request->query->has('demo')) {
         if ($request->getMethod() == 'GET') {
             $this->demonstrateErrorHandlers($request->query->get('demo'));
         }
         $request->query->remove('demo');
     }
     $form['rebuild_theme'] = array('#type' => 'checkbox', '#title' => t('Rebuild the theme information like the registry'), '#description' => t('While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.'), '#default_value' => $devel_config->get('rebuild_theme'));
     $dumper = $devel_config->get('devel_dumper');
     $default = $this->dumperManager->isPluginSupported($dumper) ? $dumper : $this->dumperManager->getFallbackPluginId(NULL);
     $form['dumper'] = array('#type' => 'radios', '#title' => $this->t('Variables Dumper'), '#options' => [], '#default_value' => $default, '#description' => $this->t('Select the debugging tool used for formatting and displaying the variables inspected through the debug functions of Devel. You can enable the <a href=":kint_install">Kint module</a> (shipped with Devel) and select the Kint debugging tool for an improved debugging experience. <strong>NOTE</strong>: Some of these plugins require external libraries for to be enabled. Learn how install external libraries with <a href=":url">Composer</a>.', [':url' => 'https://www.drupal.org/node/2404989', ':kint_install' => Url::fromRoute('system.modules_list')->toString()]));
     foreach ($this->dumperManager->getDefinitions() as $id => $definition) {
         $form['dumper']['#options'][$id] = $definition['label'];
         $supported = $this->dumperManager->isPluginSupported($id);
         $form['dumper'][$id]['#disabled'] = !$supported;
         $form['dumper'][$id]['#description'] = ['#type' => 'inline_template', '#template' => '{{ description }}{% if not supported %}<div><small>{% trans %}<strong>Not available</strong>. You may need to install external dependencies for use this plugin.{% endtrans %}</small></div>{% endif %}', '#context' => ['description' => $definition['description'], 'supported' => $supported]];
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * Checks if a node's type requires a redirect.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The event to process.
  */
 public function purlCheckNodeContext(GetResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher_interface)
 {
     $route_options = $this->routeMatch->getRouteObject()->getOptions();
     $isAdminRoute = array_key_exists('_admin_route', $route_options) && $route_options['_admin_route'];
     if (!$isAdminRoute && ($matched = $this->matchedModifiers->getMatched() && ($entity = $this->routeMatch->getParameter('node')))) {
         $node_type = $this->entityStorage->load($entity->bundle());
         $purl_settings = $node_type->getThirdPartySettings('purl');
         if (!isset($purl_settings['keep_context']) || !$purl_settings['keep_context']) {
             $url = \Drupal\Core\Url::fromRoute($this->routeMatch->getRouteName(), $this->routeMatch->getRawParameters()->all(), ['host' => Settings::get('purl_base_domain'), 'absolute' => TRUE]);
             try {
                 $redirect_response = new TrustedRedirectResponse($url->toString());
                 $redirect_response->getCacheableMetadata()->setCacheMaxAge(0);
                 $modifiers = $event->getRequest()->attributes->get('purl.matched_modifiers', []);
                 $new_event = new ExitedContextEvent($event->getRequest(), $redirect_response, $this->routeMatch, $modifiers);
                 $dispatcher_interface->dispatch(PurlEvents::EXITED_CONTEXT, $new_event);
                 $event->setResponse($new_event->getResponse());
                 return;
             } catch (RedirectLoopException $e) {
                 \Drupal::logger('redirect')->warning($e->getMessage());
                 $response = new Response();
                 $response->setStatusCode(503);
                 $response->setContent('Service unavailable');
                 $event->setResponse($response);
                 return;
             }
         }
     }
 }
  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $this->getLabel($entity);
    $row['id'] = $entity->id();
    // You probably want a few more properties here...
    $row += parent::buildRow($entity);
    $url = Url::fromRoute(
      'block.admin_display',
      array(),
      ['query' => ['block_visibility_group' => $row['id']]]
    );
    /*$row['manage_blocks'] = array(
    '#type' => 'link',
    '#title' => 'Manage Blocks',
    // @todo Why does this crash?
    '#url' => $url,

    ); */
    $row['operations']['data']['#links']['manage_blocks'] = [
      'title' => $this->t('Manage Blocks'),
      'weight' => 80,
      'url' => $url,
    ];
    uasort($row['operations']['data']['#links'], '\Drupal\Component\Utility\SortArray::sortByWeightElement');
    return $row;
  }