master

laravel/framework

Last updated at: 29/12/2023 09:21

BindingRegistrar.php

TLDR

This file is an interface that defines the methods for adding route parameter binders and retrieving the binding callback for a given binding.

Methods

bind

This method is used to add a new route parameter binder. It takes two parameters: $key (string) which represents the binding key, and $binder (string or callable) which represents the binder callback. The method does not return anything.

getBindingCallback

This method is used to get the binding callback for a given binding. It takes one parameter: $key (string) which represents the binding key. The method returns a closure.

<?php

namespace Illuminate\Contracts\Routing;

interface BindingRegistrar
{
    /**
     * Add a new route parameter binder.
     *
     * @param  string  $key
     * @param  string|callable  $binder
     * @return void
     */
    public function bind($key, $binder);

    /**
     * Get the binding callback for a given binding.
     *
     * @param  string  $key
     * @return \Closure
     */
    public function getBindingCallback($key);
}