I have shown the interface of RA forms. Another interface is the processor for adding subscribers to the newsletter. This interface inherits the main processor interface, but adds a method. The press release processor needs the default processor method and subscription method. The
Interface inheritance allows you to merge multiple interfaces without copying code. In some cases. In PHP 5.3.9 or later, classes can also implement multiple interfaces. Syntax use commas between interface names. The following is an example of a controller class declaration that will be used with the recently used symfny router. Class user implements serviceprovider interface and bootableprovider interface. {my class users must follow all the rules of these two interfaces. Creating an interface that extends both interfaces is messy and has no practical benefits. So I used comma syntax to implement both interfaces.
So far, we have only discussed the interface method. The interface can also define class constants. Remember that you cannot change the constant value of an interface when you implement or inherit it. Interface constants are not a common function. One use of interface constants is to define loops for plug-ins. Word press developers, including me, often use class inheritance to define plug-in slug properties once, and use them as JavaScript or CSS handles and menu page slugs. Reducing duplicate code and having only one place to change is a great thing. But this is not the main reason to extend base classes. Otherwise, the interface can solve the same problem without following an unnecessary class inheritance hierarchy. For example:
Interface manager{
Const slug= \
}Need to use object interface? One of the main advantages of the interface is to add rules to the program that can be executed by convention. I think the interface is like a database abstraction. Neither is required, but the faster you add projects, the easier it is to manage them and change the way they work. WordPress plug-ins usually think that additional plug-ins are required. These additional functions need to perform actions and use hook rules too often, but they are only rules. The core plug-in doesn’t actually know how the add-on works. If using class_implments() to use a specific interface requires additional functionality, the core plug-in will understand how the additional functionality works. The
For some plug-in types, calling additional feature classes instead of using hooks may be a better solution, but it is not possible without knowing how it works. The interface makes this possible. Another reason to use the interface is to illustrate the workflow that everyone in the project must follow. Unlike writing rules that must be checked for application through careful code, a series of rules defined in the interface must be followed, or fatal errors will occur. So, should I use an object interface? The answer is: But don’t use \