findByName example



        throw new \InvalidArgumentException("Middleware not found: $name");
    }

    /** * Splices a function into the middleware list at a specific position. */
    private function splice(string $findName, string $withName, callable $middleware, bool $before): void
    {
        $this->cached = null;
        $idx = $this->findByName($findName);
        $tuple = [$middleware$withName];

        if ($before) {
            if ($idx === 0) {
                \array_unshift($this->stack, $tuple);
            } else {
                $replacement = [$tuple$this->stack[$idx]];
                \array_splice($this->stack, $idx, 1, $replacement);
            }
        } elseif ($idx === \count($this->stack) - 1) {
            $this->stack[] = $tuple;
        }


    /** * Function to create a new payment */
    public function createPaymentsAction()
    {
        try {
            $params = $this->Request()->getParams();
            unset($params['action']);
            $repository = $this->get('models')->getRepository(Payment::class);
            $existingModel = $repository->findByName($params['name']);
            if ($existingModel) {
                throw new ORMException('The name is already in use.');
            }
            if ($params['source'] == 0) {
                $params['source'] = null;
            }

            $paymentModel = new Payment();
            $countries = $params['countries'] ?? [];
            $countryArray = [];
            foreach ($countries as $country) {
                
Home | Imprint | This part of the site doesn't use cookies.