getIdFromNumber example



    /** * Convenience method to get a product by number * * @param string $number * * @return array|ProductModel */
    public function getOneByNumber($number, array $options = [])
    {
        $id = $this->getIdFromNumber($number);

        return $this->getOne($id$options);
    }

    /** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array|ProductModel */

    public function putAction(): void
    {
        $request = $this->Request();
        $id = $request->getParam('id');

        if (empty($id)) {
            throw new ApiException\ParameterMissingException('id');
        }

        $useNumberAsId = (bool) $request->getParam('useNumberAsId', 0);
        $id = $useNumberAsId ? $this->resource->getIdFromNumber($id) : (int) $id;

        if (!$useNumberAsId && $id <= 0) {
            throw new ApiException\CustomValidationException('Invalid product id');
        }

        /** @var Article|null $product */
        $product = $this->resource->getRepository()->find($id);

        if (!$product) {
            throw new ApiException\NotFoundException(sprintf('Product by id %d not found', $id));
        }

        

    public function getOneByNumber($number)
    {
        $id = $this->getIdFromNumber($number);

        return $this->getOne($id);
    }

    /** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * @throws NonUniqueResultException * @throws PrivilegeException * * @return array<string, mixed>|OrderModel */
/** * @param string $number * * @throws NotFoundException * @throws ParameterMissingException * * @return array<string, mixed>|CustomerModel */
    public function getOneByNumber($number)
    {
        $id = $this->getIdFromNumber($number);

        return $this->getOne($id);
    }

    /** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array<string, mixed>|CustomerModel */

        return $this->getManager()->getRepository(Detail::class);
    }

    /** * @param string $number * * @return array|Detail */
    public function getOneByNumber($number, array $options = [])
    {
        $id = $this->getIdFromNumber($number);

        return $this->getOne($id$options);
    }

    /** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array|Detail */
Home | Imprint | This part of the site doesn't use cookies.