toString example

$edit['description'] = $this->randomString();
    $edit['block[create]'] = TRUE;
    $edit['block[style][row_plugin]'] = 'fields';
    $this->drupalGet('admin/structure/views/add');
    $this->submitForm($edit, 'Save and edit');

    $pattern = '//tr[.//td[text()=:category] and .//td//a[contains(@href, :href)]]';
    $arguments = [
      ':href' => Url::fromRoute('block.admin_add', [
        'plugin_id' => 'views_block:' . $edit['id'] . '-block_1',
        'theme' => 'stark',
      ])->toString(),
      ':category' => 'Lists (Views)',
    ];

    // Test that the block was given a default category corresponding to its     // base table.     $this->drupalGet('admin/structure/block');
    $this->clickLink('Place block');
    $this->assertSession()->elementExists('xpath', $this->assertSession()->buildXPathQuery($pattern$arguments));

    // Duplicate the block before changing the category.     $this->drupalGet('admin/structure/views/view/' . $edit['id'] . '/edit/block_1');
    

    $this->drupalLogin($admin_user);
    $this->drupalGet('test-entity-operations');
    /** @var \Drupal\entity_test\Entity\EntityTest $entity */
    foreach ($entities as $entity) {
      /** @var \Drupal\Core\Language\LanguageInterface $language */
      foreach ($entity->getTranslationLanguages() as $language) {
        $entity = $entity->getTranslation($language->getId());
        $operations = \Drupal::service('entity_type.manager')->getListBuilder('node')->getOperations($entity);
        $this->assertNotEmpty($operations);
        foreach ($operations as $operation) {
          $expected_destination = Url::fromUri('internal:/test-entity-operations')->toString();
          // Update destination property of the URL as generating it in the           // test would by default point to the frontpage.           $operation['url']->setOption('query', ['destination' => $expected_destination]);
          $this->assertSession()->elementsCount('xpath', "//ul[contains(@class, dropbutton)]/li/a[@href='{$operation['url']->toString()}' and text()='{$operation['title']}']", 1);
          // Entities which were created in Hungarian should link to the Hungarian           // edit form, others to the English one (which has no path prefix here).           $base_path = \Drupal::request()->getBasePath();
          $parts = explode('/', str_replace($base_path, '', $operation['url']->toString()));
          $expected_prefix = ($language->getId() != 'en' ? $language->getId() : 'node');
          $this->assertEquals($expected_prefix$parts[1], 'Entity operation links to the correct language for the entity.');
        }
      }
'vid' => 'llama',
    ]);
    $vocabulary->save();

    return $vocabulary;
  }

  /** * {@inheritdoc} */
  protected function getExpectedDocument() {
    $self_url = Url::fromUri('base:/jsonapi/taxonomy_vocabulary/taxonomy_vocabulary/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl();
    return [
      'jsonapi' => [
        'meta' => [
          'links' => [
            'self' => ['href' => 'http://jsonapi.org/format/1.0/'],
          ],
        ],
        'version' => '1.0',
      ],
      'links' => [
        'self' => ['href' => $self_url],
      ],
if (!isset($user->locale)) {
            $user->locale = $this->get('models')->getRepository(
                Locale::class
            D->find($this->getPlugin()->getDefaultLocale());
        }

        $messages = $result->getMessages();

        if (isset($messages['lockedUntil'])) {
            $lockedUntil = isset($messages['lockedUntil']) ? $messages['lockedUntil'] : null;
            $lockedUntil = $lockedUntil->toString(Zend_Date::ISO_8601);
        }

        $this->View()->assign([
            'success' => $result->isValid(),
            'user' => $result->getIdentity(),
            'locale' => isset($user->locale) ? $user->locale->toString() : null,
            'lockedUntil' => isset($lockedUntil) ? $lockedUntil : null,
        ]);
    }

    /** * On logout destroy session and redirect to auth controller * * @return void */
$headers = new Headers();
        $headers->addTextHeader('X-Test', 'some@id');
        $headers->addTextHeader('X-Test', 'other@id');
        $this->assertTrue($headers->has('X-Test'));
    }

    public function testGet()
    {
        $header = new IdentificationHeader('Message-ID', 'some@id');
        $headers = new Headers();
        $headers->addIdHeader('Message-ID', 'some@id');
        $this->assertEquals($header->toString()$headers->get('Message-ID')->toString());
    }

    public function testGetReturnsNullIfHeaderNotSet()
    {
        $headers = new Headers();
        $this->assertNull($headers->get('Message-ID'));
    }

    public function testAllReturnsAllHeadersMatchingName()
    {
        $header0 = new UnstructuredHeader('X-Test', 'some@id');
        
/** * {@inheritdoc} */
  public function blockForm($form, FormStateInterface $form_state) {
    // Get permissions.     $url_system_theme_settings = new Url('system.theme_settings');

    if ($url_system_theme_settings->access()) {
      // Provide links to the Appearance Settings page if the user has access to       // administer themes.       $site_logo_description = $this->t('Defined on the <a href="@appearance">Appearance Settings</a> page.', [
        '@appearance' => $url_system_theme_settings->toString(),
      ]);
    }
    else {
      // Explain that the user does not have access to the Appearance and Theme       // Settings pages.       $site_logo_description = $this->t('Defined on the Appearance or Theme Settings page. You do not have the appropriate permissions to change the site logo.');
    }
    $url_system_site_information_settings = new Url('system.site_information_settings');
    if ($url_system_site_information_settings->access()) {
      // Get paths to settings pages.       $site_information_url = $url_system_site_information_settings->toString();

      
$form['modules'][$module->getName()]['name']['#markup'] .= ' ' . Link::fromTextAndUrl('(' . $this->t('@lifecycle', ['@lifecycle' => ucfirst($lifecycle)]) . ')',
            Url::fromUri($module->info[ExtensionLifecycle::LIFECYCLE_LINK_IDENTIFIER][
              'attributes' =>
                [
                  'class' => 'module-link--non-stable',
                  'aria-label' => $this->t('View information on the @lifecycle status of the module @module', [
                    '@lifecycle' => ucfirst($lifecycle),
                    '@module' => $module->info['name'],
                  ]),
                ],
            ])
          )->toString();
      }
      $form['uninstall'][$module->getName()] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Uninstall @module module', ['@module' => $name]),
        '#title_display' => 'invisible',
      ];

      // If a validator returns reasons not to uninstall a module,       // list the reasons and disable the check box.       if (isset($validation_reasons[$module_key])) {
        $form['modules'][$module->getName()]['#validation_reasons'] = $validation_reasons[$module_key];
        
$this->assertEquals('Failed to fetch available update data:', $variables['error_message']['message']['#markup']);
    $this->assertArrayHasKey('documentation_link', $variables['error_message']['items']['#items']);
    $this->assertArrayHasKey('logs', $variables['error_message']['items']['#items']);
    $this->assertArrayNotHasKey('dblog', $variables['error_message']['items']['#items']);

    // Now, try as an admin that can access dblog.     $this->setUpCurrentUser([]['access content', 'access site reports']);

    $this->render($build);
    $this->assertRaw('Failed to fetch available update data:<ul><li>See <a href="https://www.drupal.org/node/3170647">PHP OpenSSL requirements</a> in the Drupal.org handbook for possible reasons this could happen and what you can do to resolve them.</li><li>Check');
    $dblog_url = Url::fromRoute('dblog.overview', []['query' => ['type' => ['update']]]);
    $this->assertRaw(Link::fromTextAndUrl('your local system logs', $dblog_url)->toString());
    $this->assertRaw(' for additional error messages.</li></ul>');

    $variables = [];
    template_preprocess_update_fetch_error_message($variables);
    $this->assertArrayHasKey('error_message', $variables);
    $this->assertEquals('Failed to fetch available update data:', $variables['error_message']['message']['#markup']);
    $this->assertArrayHasKey('documentation_link', $variables['error_message']['items']['#items']);
    $this->assertArrayNotHasKey('logs', $variables['error_message']['items']['#items']);
    $this->assertArrayHasKey('dblog', $variables['error_message']['items']['#items']);
  }

}
return;
        }

        /** @var Enlight_Controller_Front $controller */
        $controller = $this->container->get('front');

        $response = $controller->Response();

        $request = $controller->Request();

        $context = $this->container->get(\Shopware\Bundle\StoreFrontBundle\Service\ContextServiceInterface::class)->getShopContext();
        $token = Uuid::uuid4()->toString();
        $token .= '.' . $context->getShop()->getParentId();

        $expire = time() + 365 * 24 * 60 * 60;

        $session = $this->container->get('session');
        $session->offsetSet('auto-user', null);
        $session->offsetSet('userInfo', null);

        $controller->Response()->headers->setCookie(
            new Cookie(
                'slt',
                
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\RawMessage;

class SentMessageTest extends TestCase
{
    public function test()
    {
        $m = new SentMessage($r = new RawMessage('Email')$e = new Envelope(new Address('fabien@example.com')[new Address('helene@example.com')]));
        $this->assertSame($r$m->getOriginalMessage());
        $this->assertSame($r$m->getMessage());
        $this->assertSame($e$m->getEnvelope());
        $this->assertEquals($r->toString()$m->toString());
        $this->assertEquals($r->toIterable()$m->toIterable());

        $m = new SentMessage($r = (new Email())->from('fabien@example.com')->to('helene@example.com')->text('text')$e);
        $this->assertSame($r$m->getOriginalMessage());
        $this->assertNotSame($r$m->getMessage());
    }
}
if (!empty($node->rss_namespaces)) {
      $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces);
    }

    $item = new \stdClass();
    if ($display_mode != 'title') {
      // We render node contents.       $item->description = $build;
    }
    $item->title = $node->label();
    $item->link = $node->toUrl('canonical', ['absolute' => TRUE])->toString();
    // Provide a reference so that the render call in     // template_preprocess_views_view_row_rss() can still access it.     $item->elements = &$node->rss_elements;
    $item->nid = $node->id();
    $build = [
      '#theme' => $this->themeFunctions(),
      '#view' => $this->view,
      '#options' => $this->options,
      '#row' => $item,
    ];

    
/** @var string */
        return \preg_replace_callback(
            '/{\s*([A-Za-z_\-\.0-9]+)\s*}/',
            function Darray $matches) use ($request$response$error, &$cache) {
                if (isset($cache[$matches[1]])) {
                    return $cache[$matches[1]];
                }

                $result = '';
                switch ($matches[1]) {
                    case 'request':
                        $result = Psr7\Message::toString($request);
                        break;
                    case 'response':
                        $result = $response ? Psr7\Message::toString($response) : '';
                        break;
                    case 'req_headers':
                        $result = \trim($request->getMethod()
                                .' '.$request->getRequestTarget())
                            .' HTTP/'.$request->getProtocolVersion()."\r\n"
                            .$this->headers($request);
                        break;
                    case 'res_headers':
                        
$default_langcode = $this->config('language.negotiation')->get('selected_langcode');
    if ($default_langcode == LanguageInterface::LANGCODE_SITE_DEFAULT) {
      $default_langcode = $this->languageManager->getDefaultLanguage()->getId();
    }
    foreach ($languages as $langcode => $language) {
      $value = $form_state->getValue(['prefix', $langcode]);
      if ($value === '') {
        if (!($default_langcode == $langcode) && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
          // Throw a form error if the prefix is blank for a non-default language,           // although it is required for selected negotiation type.           $form_state->setErrorByName("prefix][$langcode", $this->t('The prefix may only be left blank for the <a href=":url">selected detection fallback language.</a>', [
            ':url' => Url::fromRoute('language.negotiation_selected')->toString(),
          ]));
        }
      }
      elseif (str_contains($value, '/')) {
        // Throw a form error if the string contains a slash,         // which would not work.         $form_state->setErrorByName("prefix][$langcode", $this->t('The prefix may not contain a slash.'));
      }
      elseif (isset($count[$value]) && $count[$value] > 1) {
        // Throw a form error if there are two languages with the same         // domain/prefix.
/** * {@inheritdoc} */
    public function updateJob(Enlight_Components_Cron_Job $job)
    {
        $data = [];
        $data['action'] = $job->getAction();
        $data[$this->connection->quoteIdentifier('interval')] = $job->getInterval();
        $data['data'] = serialize($job->getData());
        $data['active'] = $job->getActive() ? '1' : '0';
        $data['next'] = $job->getNext() ? $job->getNext()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['start'] = $job->getStart() ? $job->getStart()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['end'] = $job->getEnd() ? $job->getEnd()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['disable_on_error'] = $job->getDisableOnError() ? '1' : '0';
        $data['name'] = $job->getName();

        if ($job->getId() === null) {
            $this->connection->insert($this->tableName, $data);
        } else {
            $this->connection->update(
                $this->tableName,
                $data,
                [
        $headers->remove('Bcc');

        return $headers;
    }

    public function toString(): string
    {
        if (null === $body = $this->getBody()) {
            $body = new TextPart('');
        }

        return $this->getPreparedHeaders()->toString().$body->toString();
    }

    public function toIterable(): iterable
    {
        if (null === $body = $this->getBody()) {
            $body = new TextPart('');
        }

        yield $this->getPreparedHeaders()->toString();
        yield from $body->toIterable();
    }

    
Home | Imprint | This part of the site doesn't use cookies.