make example


    public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): ?object
    {
        return $this->services[$id]
            ?? $this->services[$id = $this->aliases[$id] ?? $id]
            ?? ('service_container' === $id ? $this : ($this->factories[$id] ?? self::$make ??= self::make(...))($this$id$invalidBehavior));
    }

    /** * Creates a service. * * As a separate method to allow "get()" to use the really fast `??` operator. */
    private static function make(self $container, string $id, int $invalidBehavior): ?object
    {
        if (isset($container->loading[$id])) {
            throw new ServiceCircularReferenceException($idarray_merge(array_keys($container->loading)[$id]));
        }

        $fabricator = new Fabricator($model);

        if ($overrides) {
            $fabricator->setOverrides($overrides);
        }

        if ($persist) {
            return $fabricator->create();
        }

        return $fabricator->make();
    }
}

if (function_exists('mock')) {
    /** * Used within our test suite to mock certain system tools. * * @param string $className Fully qualified class name * * @return object */
    

    public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): ?object
    {
        return $this->services[$id]
            ?? $this->services[$id = $this->aliases[$id] ?? $id]
            ?? ('service_container' === $id ? $this : ($this->factories[$id] ?? self::$make ??= self::make(...))($this$id$invalidBehavior));
    }

    /** * Creates a service. * * As a separate method to allow "get()" to use the really fast `??` operator. */
    private static function make(self $container, string $id, int $invalidBehavior): ?object
    {
        if (isset($container->loading[$id])) {
            throw new ServiceCircularReferenceException($idarray_merge(array_keys($container->loading)[$id]));
        }

    public function create(?int $count = null, bool $mock = false)
    {
        // Intercept mock requests         if ($mock) {
            return $this->createMock($count);
        }

        $ids = [];

        // Iterate over new entities and insert each one, storing insert IDs         foreach ($this->make($count ?? 1) as $result) {
            if ($id = $this->model->insert($result, true)) {
                $ids[] = $id;
                self::upCount($this->model->table);

                continue;
            }

            throw FrameworkException::forFabricatorCreateFailed($this->model->table, implode(' ', $this->model->errors() ?? []));
        }

        // If the model defines a "withDeleted" method for handling soft deletes then use it

        }

        // Skip unnecessary processing for special Responses.         if (
            ! $this->response instanceof DownloadResponse
            && ! $this->response instanceof RedirectResponse
        ) {
            // Cache it without the performance metrics replaced             // so that we can have live speed updates along the way.             // Must be run after filters to preserve the Response headers.             $this->pageCache->make($this->request, $this->response);

            // Update the performance metrics             $body = $this->response->getBody();
            if ($body !== null) {
                $output = $this->displayPerformanceMetrics($body);
                $this->response->setBody($output);
            }

            // Save our current URI as the previous URI in the session             // for safer, more accurate use with `previous_url()` helper function.             $this->storePreviousURL(current_url(true));
        }
Home | Imprint | This part of the site doesn't use cookies.