trigger example

                while ($this->db->transDepth !== 0) {
                    $transDepth = $this->db->transDepth;
                    $this->db->transComplete();

                    if ($transDepth === $this->db->transDepth) {
                        log_message('error', 'Database: Failure during an automated transaction commit/rollback!');
                        break;
                    }
                }

                // Let others do something with this query.                 Events::trigger('DBQuery', $query);

                if ($exception !== null) {
                    throw new DatabaseException($exception->getMessage()$exception->getCode()$exception);
                }

                return false;
            }

            // Let others do something with this query.             Events::trigger('DBQuery', $query);

            

  public function modifyState() {
    \Drupal::state()->set('basic_auth_test.state.controller_executed', TRUE);
    return ['#markup' => 'Done'];
  }

  /** * @see \Drupal\basic_auth\Tests\Authentication\BasicAuthTest::testControllerNotCalledBeforeAuth() */
  public function readState() {
    // Mark this page as being uncacheable.     \Drupal::service('page_cache_kill_switch')->trigger();

    return [
      '#markup' => \Drupal::state()->get('basic_auth_test.state.controller_executed') ? 'yep' : 'nope',
      '#cache' => [
        'max-age' => 0,
      ],
    ];
  }

}

    protected function handleRequest(?RouteCollectionInterface $routes, Cache $cacheConfig, bool $returnResponse = false)
    {
        $this->forceSecureAccess();

        if ($this->request instanceof IncomingRequest && strtolower($this->request->getMethod()) === 'cli') {
            return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
        }

        Events::trigger('pre_system');

        // Check for a cached page. Execution will stop         // if the page has been cached.         if (($response = $this->displayCache($cacheConfig)) instanceof ResponseInterface) {
            return $response;
        }

        $routeFilter = $this->tryToRouteIt($routes);

        $uri = $this->determinePath();

        
if ($this->languageManager && $request && $request->server->get('HTTP_ACCEPT_LANGUAGE')) {
      $http_accept_language = $request->server->get('HTTP_ACCEPT_LANGUAGE');
      $langcodes = array_keys($this->languageManager->getLanguages());
      $mappings = $this->config->get('language.mappings')->get('map');
      $langcode = UserAgent::getBestMatchingLangcode($http_accept_language$langcodes$mappings);
    }

    // Internal page cache with multiple languages and browser negotiation     // could lead to wrong cached sites. Therefore disabling the internal page     // cache.     // @todo Solve more elegantly in https://www.drupal.org/node/2430335.     $this->pageCacheKillSwitch->trigger();

    return $langcode;
  }

}
$this->cliMessages[] = "\t" . CLI::color($message, 'red');

                    return false;
                }

                throw new RuntimeException($message);
            }
        }

        $data           = get_object_vars($this);
        $data['method'] = 'latest';
        Events::trigger('migrate', $data);

        return true;
    }

    /** * Migrate down to a previous batch * * Calls each migration step required to get to the provided batch * * @param int $targetBatch Target batch number, or negative for a relative batch, 0 for all * * @return mixed Current batch number on success, FALSE on failure or no migrations are found * * @throws ConfigException * @throws RuntimeException */
                while ($this->transDepth !== 0) {
                    $transDepth = $this->transDepth;
                    $this->transComplete();

                    if ($transDepth === $this->transDepth) {
                        log_message('error', 'Database: Failure during an automated transaction commit/rollback!');
                        break;
                    }
                }

                // Let others do something with this query.                 Events::trigger('DBQuery', $query);

                if ($exception !== null) {
                    throw new DatabaseException(
                        $exception->getMessage(),
                        $exception->getCode(),
                        $exception
                    );
                }

                return false;
            }

            
$this->buildMessage();
        $result = $this->spoolEmail();

        if ($result) {
            $this->setArchiveValues();

            if ($autoClear) {
                $this->clear();
            }

            Events::trigger('email', $this->archive);
        }

        return $result;
    }

    /** * Batch Bcc Send. Sends groups of BCCs in batches * * @return void */
    public function batchBCCSend()
    {
public function delete(array $entities) {
    if (!$entities) {
      // If no IDs or invalid IDs were passed, do nothing.       return;
    }

    try {
      $transaction = $this->database->startTransaction();
      parent::delete($entities);

      // Ignore replica server temporarily.       \Drupal::service('database.replica_kill_switch')->trigger();
    }
    catch (\Exception $e) {
      if (isset($transaction)) {
        $transaction->rollBack();
      }
      Error::logException(\Drupal::logger($this->entityTypeId)$e);
      throw new EntityStorageException($e->getMessage()$e->getCode()$e);
    }
  }

  /** * {@inheritdoc} */
new EntitySearchResult(
                'app_flow_event',
                1,
                new EntityCollection([]),
                null,
                new Criteria(),
                Context::createDefaultContext(),
            ),
        ]);

        $triggerFlowController = new TriggerFlowController(new EventDispatcher()$appFlowEventRepository);
        $triggerFlowController->trigger('custom.checkout.event', $request$context);
    }

    public function testTriggerWithInvalidAware(): void
    {
        $request = new Request();
        $request->setMethod('POST');
        $context = Context::createDefaultContext();

        $response = $this->triggerFlowController->trigger('custom.checkout.event', $request$context);
        static::assertEquals(Response::HTTP_OK, $response->getStatusCode());
        static::assertIsString($response->getContent());
        
/** * Returns the site maintenance page if the site is offline. * * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event * The event to process. */
  public function onKernelRequestMaintenance(RequestEvent $event) {
    $request = $event->getRequest();
    $route_match = RouteMatch::createFromRequest($request);
    if ($this->maintenanceMode->applies($route_match)) {
      // Don't cache maintenance mode pages.       \Drupal::service('page_cache_kill_switch')->trigger();

      if (!$this->maintenanceMode->exempt($this->account)) {
        // When the account is not exempt, other subscribers handle request.         $this->eventDispatcher->dispatch($event, MaintenanceModeEvents::MAINTENANCE_MODE_REQUEST);
      }
      else {
        // Display a message if the logged-in user has access to the site in         // maintenance mode. Don't show maintenance message:         // - on AJAX requests.         // - on Iframe uploads.         // - on the maintenance mode settings page.
if (!($message instanceof Markup) && $message instanceof MarkupInterface) {
      $message = Markup::create((string) $message);
    }

    // Do not use strict type checking so that equivalent string and     // MarkupInterface objects are detected.     if ($repeat || !in_array($message$this->flashBag->peek($type))) {
      $this->flashBag->add($type$message);
    }

    // Mark this page as being uncacheable.     $this->killSwitch->trigger();

    return $this;
  }

  /** * {@inheritdoc} */
  public function addStatus($message$repeat = FALSE) {
    return $this->addMessage($messagestatic::TYPE_STATUS, $repeat);
  }

  
public $returnValue = true;

    public function send($autoClear = true)
    {
        if ($this->returnValue) {
            $this->setArchiveValues();

            if ($autoClear) {
                $this->clear();
            }

            Events::trigger('email', $this->archive);
        }

        return $this->returnValue;
    }
}
$first, '22:13:00', '22:14:00', '22:15:00'],
                [$second, '22:13:00', '22:14:00', '22:15:00'],
            ],
        ];

        yield 'past' => [
            'startTime' => '22:12:00',
            'runs' => [
                '22:12:01' => [],
            ],
            'schedule' => [
                RecurringMessage::trigger(new class() implements TriggerInterface {
                    public function __toString(): string
                    {
                        return 'foo';
                    }

                    public function getNextRunDate(\DateTimeImmutable $run): ?\DateTimeImmutable
                    {
                        return null;
                    }
                }(object) []),
            ],
        ];
/** * Gets the FROM and optionally JOIN conditions to lock the entity managed by this persister. * * @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. * @psalm-param LockMode::*|null $lockMode * * @return string */
    protected function getLockTablesSql($lockMode)
    {
        if ($lockMode === null) {
            Deprecation::trigger(
                'doctrine/orm',
                'https://github.com/doctrine/orm/pull/9466',
                'Passing null as argument to %s is deprecated, pass LockMode::NONE instead.',
                __METHOD__
            );

            $lockMode = LockMode::NONE;
        }

        return $this->platform->appendLockHint(
            'FROM '
            .
use Symfony\Component\Scheduler\Trigger\TriggerInterface;
use Symfony\Contracts\Service\ServiceLocatorTrait;

class SchedulerTransportFactoryTest extends TestCase
{
    public function testCreateTransport()
    {
        $trigger = $this->createMock(TriggerInterface::class);
        $serializer = $this->createMock(SerializerInterface::class);
        $clock = $this->createMock(ClockInterface::class);

        $defaultRecurringMessage = RecurringMessage::trigger($trigger(object) ['id' => 'default']);
        $customRecurringMessage = RecurringMessage::trigger($trigger(object) ['id' => 'custom']);

        $default = new SchedulerTransport(new MessageGenerator(new SomeScheduleProvider([$defaultRecurringMessage]), 'default', $clock));
        $custom = new SchedulerTransport(new MessageGenerator(new SomeScheduleProvider([$customRecurringMessage]), 'custom', $clock));

        $factory = new SchedulerTransportFactory(
            new Container([
                'default' => fn () => new SomeScheduleProvider([$defaultRecurringMessage]),
                'custom' => fn () => new SomeScheduleProvider([$customRecurringMessage]),
            ]),
            $clock,
        );
Home | Imprint | This part of the site doesn't use cookies.