Admin Page Framework Documentation

Packages

  • AdminPageFramework
    • Common
      • Factory
      • Form
        • FieldType
      • Utility
    • Factory
      • AdminPage
      • MetaBox
      • NetworkAdmin
      • PageMetaBox
      • PostType
      • TaxonomyField
      • TermMeta
      • UserMeta
      • Widget
    • Utility

Classes

  • AdminPageFramework_AdminNotice
  • AdminPageFramework_ArrayHandler
  • AdminPageFramework_Debug
  • AdminPageFramework_Debug_Base
  • AdminPageFramework_Debug_Log
  • AdminPageFramework_Debug_Utility
  • AdminPageFramework_RegisterClasses

Resources

  • Tutorials
  • Support
  • Reporting Issues

Class AdminPageFramework_RegisterClasses

Registers classes in the given directory to be auto-loaded.

Usage

Pass the scanning directory path or a list of class files to the class constructor and it will register the classes to be auto-loaded. To set a class file path array, the structure must be consist of elements of a key-value pair of a file path and the key of the class name.
new RegisterClasses( array( $sMyDirPath, $sAnotherDirPath ), $aOptions=array(), $aFlassFilePaths=array() );

Example

$aClassFiles = array(
    "AdminPageFramework"        => $sDirPath . "/factory/admin_page/AdminPageFramework.php",
    "AdminPageFramework_Controller" => $sDirPath . "/factory/admin_page/AdminPageFramework_Controller.php",
    "AdminPageFramework_Controller_Form"        => $sDirPath . "/factory/admin_page/AdminPageFramework_Controller_Form.php",
    "AdminPageFramework_Controller_Menu"        => $sDirPath . "/factory/admin_page/AdminPageFramework_Controller_Menu.php",
    "AdminPageFramework_Controller_Page"        => $sDirPath . "/factory/admin_page/AdminPageFramework_Controller_Page.php",
 );
new AdminPageFramework_RegisterClasses(
    '', // the scanning directory - do not scan anything
    array(
        'exclude_class_names'   => array(
            'AdminPageFramework_MinifiedVersionHeader',
            'AdminPageFramework_BeautifiedVersionHeader',
        ),
    ),
    $aClassFiles    // a class list array
);
// Then the registered classes can be instantiated without including them as they are all handled by the auto-loader.
$_oAdminPage = new AdminPageFramework( ... );

See the __construct() method below for the details of arguments.

Package: AdminPageFramework\Common\Utility
Version: 1.0.0
Since: 3.0.0
Located at factory/_common/utility/AdminPageFramework_RegisterClasses.php

Methods summary

public
# __construct( array|string $asScanDirPaths, array $aOptions = array(), array $aClasses = array() )

Sets up properties and performs registering classes.

Parameters

$asScanDirPaths
array|string
$asScanDirPath the target directory path to scan
$aOptions
array
$aOptions The recursive settings.
  • is_recursive - (boolean) determines whether the scan should be performed recursively.
  • exclude_dir_paths - (array) An array holding excluding directory paths without an ending slash.
  • exclude_dir_names - (array) An array holding excluding directory names.
  • allowed_extensions - (array) An array holding allowed file extensions without a starting dot. e.g. array( 'php', 'inc' )
array( 'is_recursive' => true, 'exclude_dir_paths' => array(), 'exclude_dir_names' => array(), 'allowed_extensions' => array(), )
$aClasses
array
$aClasses the link to the array storing registered classes outside this object. The structure of $aClasses must be consist of elements of a key-value pair of a file path and the key of the class name. array( 'MyClassName' => 'MyClassName.php', 'MyClassName2' => 'MyClassName2.php', )

Remark

The directory paths set for the 'exclude_dir_paths' option should use the system directory separator.

Magic methods summary

Properties summary

public array $_aClasses
#

Stores the registered classes with the key of the class name and the value of the file path.

protected static array $_aStructure_Options
#

Represents the structure of the recursive option array.

Related

If you find undocumented functionality, please report it here.

Admin Page Framework