【问题标题】:i extend class want exten contructor laravel. php我扩展类想要扩展构造器 laravel。 php
【发布时间】:2021-12-13 09:51:37
【问题描述】:

我扩展类想要扩展构造器 laravel。 php 我扩展类想要扩展构造函数 laravel。 我扩展类想要扩展构造器 laravel。 构造器类的孩子

function __construct($documentTemplate) {
        parent::__construct();
    }

构造器类父...我扩展类想要扩展构造器laravel.....我扩展类想要扩展构造器laravel....我扩展类想要扩展构造器laravel。

 public function __construct($documentTemplate)
    {
        // Temporary document filename initialization
        $this->tempDocumentFilename = tempnam(Settings::getTempDir(), 'PhpWord');
        if (false === $this->tempDocumentFilename) {
            throw new CreateTemporaryFileException(); // @codeCoverageIgnore
        }

        // Template file cloning
        if (false === copy($documentTemplate, $this->tempDocumentFilename)) {
            throw new CopyFileException($documentTemplate, $this->tempDocumentFilename); // @codeCoverageIgnore
        }

        // Temporary document content extraction
        $this->zipClass = new ZipArchive();
        $this->zipClass->open($this->tempDocumentFilename);
        $index = 1;
        while (false !== $this->zipClass->locateName($this->getHeaderName($index))) {
            $this->tempDocumentHeaders[$index] = $this->readPartWithRels($this->getHeaderName($index));
            $index++;
        }
        $index = 1;
        while (false !== $this->zipClass->locateName($this->getFooterName($index))) {
            $this->tempDocumentFooters[$index] = $this->readPartWithRels($this->getFooterName($index));
            $index++;
        }

        $this->tempDocumentMainPart = $this->readPartWithRels($this->getMainPartName());
        $this->tempDocumentSettingsPart = $this->readPartWithRels($this->getSettingsPartName());
        $this->tempDocumentContentTypes = $this->zipClass->getFromName($this->getDocumentContentTypesName());
    }

See screenshot for error message

【问题讨论】:

  • 如果问题编辑器要求你写更多的文字,这意味着提供更多信息,而不是多次复制和粘贴相同(不清楚)的东西!请阅读How to Ask

标签: php laravel error-handling


【解决方案1】:

您必须在扩展类中将参数传递给parent::__construct();

这样:

function __construct($documentTemplate) {
    parent::__construct($documentTemplate);
}

【讨论】:

    猜你喜欢
    • 2016-12-28
    • 2022-11-24
    • 2017-05-11
    • 2011-07-28
    • 1970-01-01
    相关资源
    最近更新 更多