関数
Store::populate()
GenericError objects戻り値 戻り値
ファイル: src/Error/Store.php
    public function populate() {
        $defaultError = $this->getErrorCodeMap()[parent::INTERNAL_SERVER_ERROR];
        $defaultMessage = $defaultError->message;
        $this->addError(new GenericError(
            self::WPDB_INTERNAL_ERROR,
            $this->getConstantNameByValue(self::WPDB_INTERNAL_ERROR),
            500,
            __('A wpdb method failed during execution. Wpdb most likely had a problem connecting to the database.', 'wcexwl'),
            $defaultMessage
        ));
        $this->addError(new GenericError(
            self::NOT_LOGGED_IN,
            $this->getConstantNameByValue(self::NOT_LOGGED_IN),
            401,
            __('You are logged out. Please login and try again.', 'wcexwl'),
            __('You are logged out. Please login and try again.', 'wcexwl')
        ));
        $this->addError(new GenericError(
            self::WISHLIST_ITEM_NOT_FOUND,
            $this->getConstantNameByValue(self::WISHLIST_ITEM_NOT_FOUND),
            404,
            function ($id) {
                // translators: ID of the wishlist item
                return sprintf(__('A wishlist item with ID 「%d」 does not exist.', 'wcexwl'), $id);
            },
            __('Wishlist item not found. Did you delete it in a different tab?', 'wcexwl')
        ));
        $isom = function ($sku) {
            // translators: SKU of the wishlist item
            return sprintf(__('%s is sold out.', 'wcexwl'), $sku);
        };
        $this->addError(new GenericError(
            self::ITEM_SOLD_OUT,
            $this->getConstantNameByValue(self::ITEM_SOLD_OUT),
            400,
            $isom,
            $isom
        ));
        $perpm = function ($itemRestriction, $sku) {
            return sprintf(
                // translators: 1. per purchase limit 2. SKU of the wishlist item
                __('This article is limited by %1$d at a time for %2$s.', 'wcexwl'),
                (int)$itemRestriction,
                $sku
            );
        };
        $this->addError(new GenericError(
            self::PER_PURCHASE_LIMIT_EXCEEDED,
            $this->getConstantNameByValue(self::PER_PURCHASE_LIMIT_EXCEEDED),
            400,
            $perpm,
            $perpm
        ));
        $qeslm = function ($sku, $checkstock) {
            // translators: 1. SKU of wishlist item 2. number of stock remaining
            return sprintf(__('%1$s only has %2$d stock remaining.', 'wcexwl'), $sku, (int)$checkstock);
        };
        $this->addError(new GenericError(
            self::QUANT_EXCEEDS_STOCK_LIMIT,
            $this->getConstantNameByValue(self::QUANT_EXCEEDS_STOCK_LIMIT),
            400,
            $qeslm,
            $qeslm
        ));
        $this->addError(new GenericError(
            self::POST_IN_TRASH,
            $this->getConstantNameByValue(self::POST_IN_TRASH),
            404,
            function ($id) {
                // translators: post ID of the item
                return sprintf(__('The item with post ID 「%d」 has been trashed.', 'wcexwl'), $id);
            },
            function ($sku = '') {
                // translators: SKU of the item
                return sprintf(__('%s is no longer for sale.', 'wcexwl'), $sku);
            }
        ));
        $this->addError(new GenericError(
            self::ITEM_DELETED,
            $this->getConstantNameByValue(self::ITEM_DELETED),
            404,
            function ($id) {
                // translators: post ID of the item
                return sprintf(__('The item with post ID 「%d」 has been deleted.', 'wcexwl'), $id);
            },
            function ($sku = '') {
                // translators: SKU of the item
                return sprintf(__('%s is no longer for sale.', 'wcexwl'), $sku);
            }
        ));
        $this->addError(new GenericError(
            self::REQUIRED_FIELDS_MISSING,
            $this->getConstantNameByValue(self::REQUIRED_FIELDS_MISSING),
            400,
            function ($field) {
                return 'The field "' . $field . '" is required.';
            },
            function ($message) {
                return $message;
            }
        ));
        $this->addError(new GenericError(
            self::REQUIRED_OPTIONS_MISSING,
            $this->getConstantNameByValue(self::REQUIRED_OPTIONS_MISSING),
            400,
            function ($message) {
                return $message;
            },
            function ($message) {
                return $message;
            }
        ));
        $this->addError(new GenericError(
            self::UNSERIALIZATION_ERROR,
            $this->getConstantNameByValue(self::UNSERIALIZATION_ERROR),
            400,
            function ($serial) {
                // translators: the string that could not be unserialized
                return sprintf(__('The following string could not be unserialized: %s', 'wcexwl'), (string)$serial);
            },
            $defaultMessage
        ));
        $this->addError(new GenericError(
            self::SERIALIZED_ITEM_IS_MALFORMED,
            $this->getConstantNameByValue(self::SERIALIZED_ITEM_IS_MALFORMED),
            400,
            __('The serialized item is missing required fields', 'wcexwl'),
            $defaultMessage
        ));
        $mcallback = function ($sku) {
            // translators: SKU of the item
            return sprintf(__('Options have changed for %s. Please add to cart from the item page.', 'wcexwl'), $sku);
        };
        $this->addError(new GenericError(
            self::ITEM_OPTIONS_INVALID,
            $this->getConstantNameByValue(self::ITEM_OPTIONS_INVALID),
            400,
            $mcallback,
            $mcallback
        ));
        $this->addError(new GenericError(
            self::CONTINUE_CHARGE_REQUIRES_EMPTY_CART,
            $this->getConstantNameByValue(self::CONTINUE_CHARGE_REQUIRES_EMPTY_CART),
            409,
            function ($message) {
                return $message;
            },
            function ($message) {
                return $message;
            }
        ));
        $this->addError(new GenericError(
            self::CART_CONTAINS_CONTINUE_CHARGE,
            $this->getConstantNameByValue(self::CART_CONTAINS_CONTINUE_CHARGE),
            409,
            function ($message) {
                return $message;
            },
            function ($message) {
                return $message;
            }
        ));
        $mcallback = function ($itemname) {
            // translators: name of the item
            return sprintf(__('%s cannot be processed in a batch operation.', 'wcexwl'), $itemname);
        };
        $this->addError(new GenericError(
            self::CANNOT_PROCESS_IN_BATCH_OP,
            $this->getConstantNameByValue(self::CANNOT_PROCESS_IN_BATCH_OP),
            422,
            $mcallback,
            $mcallback
        ));
    }