WPDKView::addSubview PHP Method

addSubview() public method

Add a view in queue views
public addSubview ( WPDKView $view ) : WPDKView
$view WPDKView
return WPDKView
    public function addSubview($view)
    {
        /**
         * Filter the potential adding of a subview.
         *
         * @param bool $continue Default TRUE. Set to FALSE to avoid adding of a subview.
         *
         */
        $continue = apply_filters('wpdk_view_should_add_subview', true, $view);
        if ($continue) {
            $view->superview = $this;
            $this->subviews[$view->id] = $view;
            /**
             * Fires when a subview is added
             *
             * @param WPDKView $view The added subview
             */
            do_action('wpdk_view_did_add_subview', $view);
        }
        return $view;
    }

Usage Example

Example #1
0
 /**
  * Create an instance of WPDKViewController class
  *
  * @brief Construct
  *
  * @param string $id         The unique id for this view controller
  * @param string $title      The title of this view controller. This is displayed on top header
  *
  * @return WPDKViewController
  */
 public function __construct($id, $title)
 {
     $this->id = sanitize_title($id);
     $this->title = $title;
     $this->view = new WPDKView($id . '-view-root', array('wrap'));
     $this->viewHead = new WPDKHeaderView($id . '-header-view', $this->title);
     $this->view->addSubview($this->viewHead);
 }