Simple Factory Pattern Demo (ok)
Last updated
Was this helpful?
Last updated
Was this helpful?
Hoặc viết dưới dạng plugin
This project was written as a demo application for an Envato Tuts+ Series on using Design Patterns in WordPress.
This project is not an official WordPress plugin, theme, or application and is not meant to be run within the context of the WordPress application.
It's meant to provide a working example of the Simple Factory design pattern.
demo.php
is the driver that is meant to be the entry-point of the application. It sets everything into motion.
images
contains a sketch of the Simple Factory Pattern diagram for this demo
lib
contains the core files for the application
lib/plugin.php
represents the core plugin file or, more specifically, how you would incorporate the Simple Factory into a WordPress plugin.
lib/simple-factory.php
is the Simple Factory class itself that relies on a base class, its subclasses, and input to return the proper element
lib/users/user.php
the abstract base class representing all users
lib/users/admin.php
the subclass representing an Adminstrator with read-write
privileges
lib/users/reader.php
the subclass representing a Reader with read
privileges
lib/users/volunteer.php
the subclass representing a Volunteer with help
privileges*
Download a copy of the latest tag from GitHub
Extract the contents to a directory of your choice
Run the demo.php
script from the command-line to see the script in action