Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

so that PdfConfig['options'] is merged rather then replaced #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

asmt3
Copy link

@asmt3 asmt3 commented May 9, 2014

If my controller has:

$this->pdfConfig = array(
        'options' => array(
                'footer-html' => '/pdfparts/foot/' . $id,
            ),
        );

This change means that my existing configuration options:

Configure::write('CakePdf', array(
    'engine' => 'CakePdf.WkHtmlToPdf',
    'options' => array(
        'print-media-type' => false,
        'outline' => true,
        'dpi' => 96,
        'header-spacing' => 30,
    ),
    'margin' => array(
        'bottom' => 10,
        'left' => 10,
        'right' => 10,
        'top' => 45
    ),
    'orientation' => 'portrait',
    'download' => true,
));

won't be overwritten. They'll be merged instead.

@@ -49,7 +49,7 @@ class PdfView extends View {
public function __construct(Controller $Controller = null) {
$this->_passedVars[] = 'pdfConfig';
parent::__construct($Controller);
$this->pdfConfig = array_merge(
$this->pdfConfig = array_merge_recursive(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or Hash::merge() better

@dereuromark
Copy link
Member

We should add a test case to avoid regression.

@dereuromark
Copy link
Member

Maybe the class should get a InstanceConfigTrait, then people can use config() or configShallow() as they like.

@ADmad ADmad force-pushed the master branch 2 times, most recently from a255973 to 341d8ec Compare February 23, 2017 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants