setOptions example

$temp['mx'] = array_shift($options);
            }

            if (!empty($options)) {
                $temp['hostname'] = array_shift($options);
            }

            $options = $temp;
        }

        $options += $this->_options;
        $this->setOptions($options);
    }

    /** * Returns all set Options * * @return array */
    public function getOptions()
    {
        return $this->_options;
    }

    
public function getContentType(): string
    {
        return self::FILE_CONTENT_TYPE;
    }

    public function render(RenderedDocument $document): string
    {
        $dompdf = new Dompdf();

        $options = new Options($this->dompdfOptions);

        $dompdf->setOptions($options);
        $dompdf->setPaper($document->getPageSize()$document->getPageOrientation());
        $dompdf->loadHtml($document->getHtml());

        /* * Dompdf creates and destroys a lot of objects. The garbage collector slows the process down by ~50% for * PHP <7.3 and still some ms for 7.4 */
        $gcEnabledAtStart = gc_enabled();
        if ($gcEnabledAtStart) {
            gc_collect_cycles();
            gc_disable();
        }
public function __construct(AbstractProxy|\SessionHandlerInterface $handler = null, MetadataBag $metaBag = null, bool $secure = false)
    {
        $this->handler = $handler;
        $this->metaBag = $metaBag;
        $this->secure = $secure;
    }

    public function createStorage(?Request $request): SessionStorageInterface
    {
        $storage = new PhpBridgeSessionStorage($this->handler, $this->metaBag);
        if ($this->secure && $request?->isSecure()) {
            $storage->setOptions(['cookie_secure' => true]);
        }

        return $storage;
    }
}
$entity_type3->id()->willReturn('the_entity_type_id');
    $entity_type3->getLinkTemplate('canonical')->willReturn('/the/canonical/link/template');
    $entity_type3->entityClassImplements(FieldableEntityInterface::class)->willReturn(FALSE);
    $route = (new Route('/the/canonical/link/template'))
      ->setDefaults([
        '_entity_view' => 'the_entity_type_id.full',
        '_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::title',
      ])
      ->setRequirements([
        '_entity_access' => 'the_entity_type_id.view',
      ])
      ->setOptions([
        'parameters' => [
          'the_entity_type_id' => [
            'type' => 'entity:the_entity_type_id',
          ],
        ],
      ]);
    $data['id_key_type_null'] = [clone $route$entity_type3->reveal()];

    $entity_type4 = static::getEntityType($entity_type3);
    $entity_type4->entityClassImplements(FieldableEntityInterface::class)->willReturn(TRUE);
    $entity_type4->getKey('id')->willReturn('id');
    
// Remove the leading slash.       $uri_parts['path'] = substr($uri_parts['path'], 1);

      if (UrlHelper::isExternal($uri_parts['path'])) {
        throw new \InvalidArgumentException("The internal path component '{$uri_parts['path']}' is external. You are not allowed to specify an external URL together with internal:/.");
      }
    }

    $url = \Drupal::pathValidator()
      ->getUrlIfValidWithoutAccessCheck($uri_parts['path']) ?: static::fromUri('base:' . $uri_parts['path']$options);
    // Allow specifying additional options.     $url->setOptions($options + $url->getOptions());

    return $url;
  }

  /** * Creates a new Url object for 'route:' URIs. * * @param array $uri_parts * Parts from a URI of the form route:{route_name};{route_parameters} as * from parse_url(), where the path is the route name optionally followed by * a ";" followed by route parameters in key=value format with & separators. * @param array $options * An array of options, see \Drupal\Core\Url::fromUri() for details. * @param string $uri * The original passed in URI. * * @return static * A new Url object for a 'route:' URI. * * @throws \InvalidArgumentException * Thrown when the route URI does not have a route name. */
    // current request.     if (isset($destination) && $redirect !== FALSE) {
      // Create a valid redirect if one does not exist already.       if (!($redirect instanceof Url)) {
        $redirect = Url::createFromRequest($request);
      }

      // Add the current destination to the redirect unless one exists already.       $options = $redirect->getOptions();
      if (!isset($options['query']['destination'])) {
        $options['query']['destination'] = $destination;
        $redirect->setOptions($options);
      }

      $form_state->setRedirectUrl($redirect);
      $request->query->remove('destination');
    }
  }

  /** * Submit handler to duplicate a display for a view. */
  public function submitDisplayDuplicate($form, FormStateInterface $form_state) {
    

  }

  /** * Tests the setOptions() method. * * @covers ::setOptions */
  public function testSetOptions() {
    $url = Url::fromRoute('test_route', []);
    $this->assertEquals([]$url->getOptions());
    $url->setOptions(['foo' => 'bar']);
    $this->assertEquals(['foo' => 'bar']$url->getOptions());
    $url->setOptions([]);
    $this->assertEquals([]$url->getOptions());
  }

  /** * Tests the mergeOptions() method. * * @covers ::mergeOptions */
  public function testMergeOptions() {
    
// If no HTML ID was found above, automatically create one.       if (!isset($element['#id'])) {
        $element['#id'] = $element['#options']['attributes']['id'] = HtmlUtility::getUniqueId('ajax-link');
      }
      $element = static::preRenderAjaxForm($element);
    }

    if (!empty($element['#url']) && $element['#url'] instanceof CoreUrl) {
      $options = NestedArray::mergeDeep($element['#url']->getOptions()$element['#options']);
      /** @var \Drupal\Core\Utility\LinkGenerator $link_generator */
      $link_generator = \Drupal::service('link_generator');
      $generated_link = $link_generator->generate($element['#title']$element['#url']->setOptions($options));
      $element['#markup'] = $generated_link;
      $generated_link->merge(BubbleableMetadata::createFromRenderArray($element))
        ->applyTo($element);
    }
    return $element;
  }

  /** * Pre-render callback: Collects child links into a single array. * * This method can be added as a pre_render callback for a renderable array, * usually one which will be themed by links.html.twig. It iterates through * all unrendered children of the element, collects any #links properties it * finds, merges them into the parent element's #links array, and prevents * those children from being rendered separately. * * The purpose of this is to allow links to be logically grouped into related * categories, so that each child group can be rendered as its own list of * links if RendererInterface::render() is called on it, but * calling RendererInterface::render() on the parent element will * still produce a single list containing all the remaining links, regardless * of what group they were in. * * A typical example comes from node links, which are stored in a renderable * array similar to this: * @code * $build['links'] = array( * '#theme' => 'links__node', * '#pre_render' => array(Link::class, 'preRenderLinks'), * 'comment' => array( * '#theme' => 'links__node__comment', * '#links' => array( * // An array of links associated with node comments, suitable for * // passing in to links.html.twig. * ), * ), * 'statistics' => array( * '#theme' => 'links__node__statistics', * '#links' => array( * // An array of links associated with node statistics, suitable for * // passing in to links.html.twig. * ), * ), * 'translation' => array( * '#theme' => 'links__node__translation', * '#links' => array( * // An array of links associated with node translation, suitable for * // passing in to links.html.twig. * ), * ), * ); * @endcode * * In this example, the links are grouped by functionality, which can be * helpful to themers who want to display certain kinds of links * independently. For example, adding this code to node.html.twig will result * in the comment links being rendered as a single list: * @code * {{ content.links.comment }} * @endcode * * (where a node's content has been transformed into $content before handing * control to the node.html.twig template). * * The preRenderLinks method defined here allows the above flexibility, but * also allows the following code to be used to render all remaining links * into a single list, regardless of their group: * @code * {{ content.links }} * @endcode * * In the above example, this will result in the statistics and translation * links being rendered together in a single list (but not the comment links, * which were rendered previously on their own). * * Because of the way this method works, the individual properties of each * group (for example, a group-specific #theme property such as * 'links__node__comment' in the example above, or any other property such as * #attributes or #pre_render that is attached to it) are only used when that * group is rendered on its own. When the group is rendered together with * other children, these child-specific properties are ignored, and only the * overall properties of the parent are used. * * @param array $element * Render array containing child links to group. * * @return array * Render array containing child links grouped into a single array. */
// @todo Views should expect and store a leading /. See         // https://www.drupal.org/node/2423913.         $alter['url'] = CoreUrl::fromUserInput('/' . ltrim($path, '/'));
      }
      else {
        $alter['url'] = CoreUrl::fromUri($path);
      }
    }

    $options = $alter['url']->getOptions() + $options;

    $path = $alter['url']->setOptions($options)->toUriString();

    if (!empty($alter['path_case']) && $alter['path_case'] != 'none' && !$alter['url']->isRouted()) {
      $path = str_replace($alter['path']$this->caseTransform($alter['path']$this->options['alter']['path_case'])$path);
    }

    if (!empty($alter['replace_spaces'])) {
      $path = str_replace(' ', '-', $path);
    }

    // Parse the URL and move any query and fragment parameters out of the path.     $url = UrlHelper::parse($path);

    
$options = $item->options;
    $options += $url->getOptions();

    // Add optional 'rel' attribute to link options.     if (!empty($settings['rel'])) {
      $options['attributes']['rel'] = $settings['rel'];
    }
    // Add optional 'target' attribute to link options.     if (!empty($settings['target'])) {
      $options['attributes']['target'] = $settings['target'];
    }
    $url->setOptions($options);

    return $url;
  }

}

  protected $usesRowPlugin = TRUE;

  public function attachTo(array &$build$display_id, Url $feed_url$title) {
    $url_options = [];
    $input = $this->view->getExposedInput();
    if ($input) {
      $url_options['query'] = $input;
    }
    $url_options['absolute'] = TRUE;

    $url = $feed_url->setOptions($url_options)->toString();

    // Add the RSS icon to the view.     $this->view->feedIcons[] = [
      '#theme' => 'feed_icon',
      '#url' => $url,
      '#title' => $title,
    ];

    // Attach a link to the RSS feed, which is an alternate representation.     $build['#attached']['html_head_link'][][] = [
      'rel' => 'alternate',
      
protected $_storage;

    /** * Constructor * * @param null|array|Zend_Config|ArrayAccess $options * @return void */
    public function __construct($options = null)
    {
        if (null !== $options) {
            $this->setOptions($options);
        }
    }

    /** * Serialized representation of the object * * @return string */
    public function serialize()
    {
        $device = $this->getDevice();
        
$groupId = $group->getId();

            if (isset($groups[$groupId])) {
                $group = $groups[$groupId];
            }

            $groups[$groupId] = $group;

            $options = $group->getOptions();
            if ($options === null) {
                $options = new PropertyGroupOptionCollection();
                $group->setOptions($options);
            }
            $options->add($option);

            $options->add($option);

            $option->setConfiguratorSetting($setting);
        }

        return $groups;
    }

    
$route->setPath('/path/{bar<\w++>}');
        $this->assertEquals('/path/{bar}', $route->getPath(), '->setPath() removes inline requirements');
        $route->setPath('/path/{foo?value}');
        $this->assertEquals('/path/{foo}', $route->getPath(), '->setPath() removes inline defaults');
        $route->setPath('/path/{!bar<\d+>?value}');
        $this->assertEquals('/path/{!bar}', $route->getPath(), '->setPath() removes all inline settings');
    }

    public function testOptions()
    {
        $route = new Route('/{foo}');
        $route->setOptions(['foo' => 'bar']);
        $this->assertEquals(array_merge([
        'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler',
        ]['foo' => 'bar'])$route->getOptions(), '->setOptions() sets the options');
        $this->assertEquals($route$route->setOptions([]), '->setOptions() implements a fluent interface');

        $route->setOptions(['foo' => 'foo']);
        $route->addOptions(['bar' => 'bar']);
        $this->assertEquals($route$route->addOptions([]), '->addOptions() implements a fluent interface');
        $this->assertEquals(['foo' => 'foo', 'bar' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler']$route->getOptions(), '->addDefaults() keep previous defaults');
    }

    
// Display links by default based on the current language.     // Link relations that do not require an existing entity should not be     // affected by this entity's language, however.     if (!in_array($rel['collection', 'add-page', 'add-form'], TRUE)) {
      $options += ['language' => $this->language()];
    }

    $uri_options = $uri->getOptions();
    $uri_options += $options;

    return $uri->setOptions($uri_options);
  }

  /** * {@inheritdoc} */
  public function hasLinkTemplate($rel) {
    $link_templates = $this->linkTemplates();
    return isset($link_templates[$rel]);
  }

  /** * Gets an array link templates. * * @return array * An array of link templates containing paths. */
Home | Imprint | This part of the site doesn't use cookies.