Allow for inheritance of Controller::$_render property within subclasses #884

Merged
merged 1 commit into from Apr 12, 2013

Conversation

Projects
None yet
2 participants
Contributor

mikegreiling commented Apr 12, 2013

I'd like the be able to do the following in a few controllers of mine which utilize an alternative layout:

class DashboardController extends \lithium\action\Controller {

    /**
     * Specify dashboard layout by default
     *
     */
    protected $_render = array('layout' => 'dashboard');

    [...]
}

However, when doing this, all of the other default attributes of the $_render property become undefined unless I lift the entire array from the \lithium\action\Controller class.

So I'm left with doing this instead:

class DashboardController extends \lithium\action\Controller {

    /**
     * Specify dashboard layout by default
     *
     */
    public function __construct(array $config = array()) {
        $defaults = array('render' => array('layout' => 'dashboard'));
        parent::__construct($config + $defaults);
    }

    [...]
}

This PR aims to make inheritance within the $_render property simpler by inheriting and merging defaults from all parent classes similar to how \lithium\data\Model handles inheritance in the $_meta property.

@nateabele nateabele added a commit that referenced this pull request Apr 12, 2013

@nateabele nateabele Merge pull request #884 from pixelcog/controller-render-inherit
Allow for inheritance of Controller::$_render property within subclasses
4ce4c7c

@nateabele nateabele merged commit 4ce4c7c into UnionOfRAD:dev Apr 12, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment