Trait for managers that support parent managers.
Description
Source
File: src/db-objects/manager-with-parents-trait.php
trait Manager_With_Parents_Trait { /** * Parent managers. * * @since 1.0.0 * @var array */ protected $parent_managers = array(); /** * Adds a parent manager. * * @since 1.0.0 * * @param string $slug Parent manager identifier. * @param Manager $manager Parent manager instance. * @return bool True on success, false on failure. */ public function add_parent_manager( $slug, $manager ) { if ( ! is_a( $manager, Manager::class ) ) { return false; } $this->parent_managers[ $slug ] = $manager; return true; } /** * Retrieves a parent manager. * * @since 1.0.0 * * @param string $slug Parent manager identifier. * @return Manager Parent manager instance. */ public function get_parent_manager( $slug ) { if ( ! isset( $this->parent_managers[ $slug ] ) ) { return null; } return $this->parent_managers[ $slug ]; } }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
Methods
- __construct — Constructor.
- delete_from_db — Internal method to delete a form from the database.
- fetch_from_db — Internal method to fetch a form from the database.
- insert_into_db — Internal method to insert a new form into the database.
- map_args — Maps form arguments to regular post arguments.
- setup_hooks — Sets up all action and filter hooks for the service.
- update_in_db — Internal method to update an existing form in the database.