Prepare the current mpdf object.

@return Mpdf
972833
public function prepare(): Mpdf
    {
        $this->pdf = $this->getPdf();

        // set the custom pdf template
        if (null !== $this->getTemplate() && file_exists($this->getTemplate())) {
            $this->pdf->SetImportUse();

            $pageCount = $this->pdf->SetSourceFile($this->getTemplate());
            $tplIdx = $this->pdf->ImportPage($pageCount);
            $this->pdf->UseTemplate($tplIdx);
            $this->pdf->UseTemplate($tplIdx);
        }

        $this->pdf->WriteHTML($this->html);

        $this->isPrepared = true;

        return $this->pdf;
    }
149809
public function prepare()
    {
        $files = $this->getFilesStack();
        if (!empty($files)) {
            foreach ($files as $_file) {
                $this->addContent(
                    file_get_contents($_file->getRealPath()),
                    $_file->getPathname()
                );
            }
        }
    }
1313160
private function prepareLocateDataObject()
    {
        $fragment = new CNabuPHPMethodBuilder(
            $this, 'locateDataObject', CNabuPHPMethodBuilder::METHOD_PROTECTED,
            false, false, false, true, 'bool'
        );
        $fragment->addComment("Locate a Data Object.");
        $fragment->addComment("@return bool Returns true if the Data Object found or false if not.");

        $fragment->addParam(
            'element', 'SimpleXMLElement', false, null, 'SimpleXMLElement', 'Element to locate the Data Object.'
        );
        $fragment->addParam(
            'data_parent', 'CNabuDataObject', true, null, 'CNabuDataObject', 'Data Parent object.'
        );

        $fragment->addFragment(array(
            '$retval = false;',
            '',
            "if (isset(\$element['GUID'])) {",
            "    \$guid = (string)\$element['GUID'];",
            "    if (!(\$this->nb_data_object instanceof $this->class_data_name)) {",
            "        \$this->nb_data_object = $this->class_data_name::findByHash(\$guid);",
            '    } else {',
            '        $this->nb_data_object = null;',
            '    }',
            '',
            "    if (!(\$this->nb_data_object instanceof $this->class_data_name)) {",
            "        \$this->nb_data_object = new $this->class_data_name();",
            "        \$this->nb_data_object->setHash(\$guid);",
            '    }',
            '    $retval = true;',
            '}',
            '',
            'return $retval;'
        ));

        $this->getDocument()->addUse('\nabu\data\CNabuDataObject');
        $this->getDocument()->addUse("\\$this->class_data_namespace\\$this->class_data_name");
        $this->getDocument()->addUse('\SimpleXMLElement');

        $this->addFragment($fragment);
    }
76217
public function prepare($content = null)
    {
        is_null($content) || $this->setContent($content);

        $content = $this->getContent();

        $content = $this->arrayToJson($content);

        $content = $this->objectToJson($content);

        $content = $this->printRecursiveNonAlphaNum($content);

        if (! $this->jsonErrors($content)) {
            $this->header('Content-Type: application/json');
        }

        $this->setContent($content);

        return $this;
    }
593902
public function create(): self
    {
        $this->payload = null;
        $this->aad = null;
        $this->recipients = [];
        $this->sharedProtectedHeader = [];
        $this->sharedHeader = [];
        $this->compressionMethod = null;
        $this->contentEncryptionAlgorithm = null;
        $this->keyManagementMode = null;

        return $this;
    }
1333425
public function prepare_package() {
        global $DB;

        $format = $this->exporter->get('format');
        $content = self::entry_content($this->course, $this->cm, $this->glossary, $this->entry, $this->aliases, $format);

        if ($this->exporter->get('formatclass') === PORTFOLIO_FORMAT_PLAINHTML) {
            $filename = clean_filename($this->entry->concept) . '.html';
            $this->exporter->write_new_file($content, $filename);

        } else if ($this->exporter->get('formatclass') === PORTFOLIO_FORMAT_RICHHTML) {
            if ($this->multifiles) {
                foreach ($this->multifiles as $file) {
                    $this->exporter->copy_existing_file($file);
                }
            }
            $filename = clean_filename($this->entry->concept) . '.html';
            $this->exporter->write_new_file($content, $filename);

        } else if ($this->exporter->get('formatclass') === PORTFOLIO_FORMAT_LEAP2A) {
            $writer = $this->get('exporter')->get('format')->leap2a_writer();
            $entry = new portfolio_format_leap2a_entry('glossaryentry' . $this->entry->id, $this->entry->concept, 'entry', $content);
            $entry->author = $DB->get_record('user', array('id' => $this->entry->userid), 'id,firstname,lastname,email');
            $entry->published = $this->entry->timecreated;
            $entry->updated = $this->entry->timemodified;
            if ($this->multifiles) {
                $writer->link_files($entry, $this->multifiles);
                foreach ($this->multifiles as $file) {
                    $this->exporter->copy_existing_file($file);
                }
            }
            if ($this->categories) {
                foreach ($this->categories as $cat) {
                    // this essentially treats them as plain tags
                    // leap has the idea of category schemes
                    // but I think this is overkill here
                    $entry->add_category($cat->name);
                }
            }
            $writer->add_entry($entry);
            $content = $writer->to_xml();
            $filename = $this->get('exporter')->get('format')->manifest_name();
            $this->exporter->write_new_file($content, $filename);

        } else {
            throw new portfolio_caller_exception('unexpected_format_class', 'glossary');
        }
    }
235459
public function prepare()
    {
        $request = parent::prepare();

        $url = $request->getUrl(true);

        $query = $url->getQuery();
        $query->merge($this->templateVariables);
        $request->setUrl($url);

        return $request;
    }
378885
public function prepare_package() {

        if ($this->plugin && $this->editor) {
            $options = portfolio_format_text_options();
            $context = context_module::instance($this->cmid);
            $options->context = $context;

            $plugin = $this->get_submission_plugin();

            $text = $plugin->get_editor_text($this->editor, $this->sid);
            $format = $plugin->get_editor_format($this->editor, $this->sid);

            $html = format_text($text, $format, $options);
            $html = portfolio_rewrite_pluginfile_urls($html,
                                                      $context->id,
                                                      'mod_assign',
                                                      $this->area,
                                                      $this->sid,
                                                      $this->exporter->get('format'));

            $exporterclass = $this->exporter->get('formatclass');
            if (in_array($exporterclass, array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_RICHHTML))) {
                if ($files = $this->exporter->get('caller')->get('multifiles')) {
                    foreach ($files as $file) {
                        $this->exporter->copy_existing_file($file);
                    }
                }
                return $this->exporter->write_new_file($html, 'assignment.html', !empty($files));
            } else if ($this->exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
                $leapwriter = $this->exporter->get('format')->leap2a_writer();
                $entry = new portfolio_format_leap2a_entry($this->area . $this->cmid,
                                                           $context->get_context_name(),
                                                           'resource',
                                                           $html);

                $entry->add_category('web', 'resource_type');
                $entry->author = $this->user;
                $leapwriter->add_entry($entry);
                if ($files = $this->exporter->get('caller')->get('multifiles')) {
                    $leapwriter->link_files($entry, $files, $this->area . $this->cmid . 'file');
                    foreach ($files as $file) {
                        $this->exporter->copy_existing_file($file);
                    }
                }
                return $this->exporter->write_new_file($leapwriter->to_xml(),
                                                       $this->exporter->get('format')->manifest_name(),
                                                       true);
            } else {
                debugging('invalid format class: ' . $this->exporter->get('formatclass'));
            }

        }

        if ($this->exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
            $leapwriter = $this->exporter->get('format')->leap2a_writer();
            $files = array();
            if ($this->singlefile) {
                $files[] = $this->singlefile;
            } else if ($this->multifiles) {
                $files = $this->multifiles;
            } else {
                throw new portfolio_caller_exception('invalidpreparepackagefile',
                                                     'portfolio',
                                                     $this->get_return_url());
            }

            $entryids = array();
            foreach ($files as $file) {
                $entry = new portfolio_format_leap2a_file($file->get_filename(), $file);
                $entry->author = $this->user;
                $leapwriter->add_entry($entry);
                $this->exporter->copy_existing_file($file);
                $entryids[] = $entry->id;
            }
            if (count($files) > 1) {
                $baseid = 'assign' . $this->cmid . $this->area;
                $context = context_module::instance($this->cmid);

                // If we have multiple files, they should be grouped together into a folder.
                $entry = new portfolio_format_leap2a_entry($baseid . 'group',
                                                           $context->get_context_name(),
                                                           'selection');
                $leapwriter->add_entry($entry);
                $leapwriter->make_selection($entry, $entryids, 'Folder');
            }
            return $this->exporter->write_new_file($leapwriter->to_xml(),
                                                   $this->exporter->get('format')->manifest_name(),
                                                   true);
        }
        return $this->prepare_package_file();
    }
205514
public function prepare()
    {

        $options = $this->options->prepareOptions;

        if( $options & Options::BACKUP or true ) {

            $root = $this->options->pathRoot;
            $pathsToBackup = $this->options->getPathsToBackup();

            // make a fully qualified path relative to $root
            $anchorToRoot = function( $path ) use ($root) {
                return escapeshellarg( "." . substr( $path, strlen($root) ) );
            };

            $pathsToBackup = array_map( $anchorToRoot, $pathsToBackup );
            $pathsToBackup = implode( ' ', $pathsToBackup );

            $backupDir = $this->options->getPath('backup');
            $filename = "{$backupDir}/" . self::fileSystemFriendly(
                date( DateTime::POSTGRES_TIMESTAMP_WITHOUT_TIME_ZONE_NO_MICROSECONDS )
            ) . '.tar.gz';

            $command = sprintf(
                'cd %s; tar cszf %s --exclude=%s -C %s %s; cd -',
                escapeshellarg( $root ),
                escapeshellarg( $filename ),
                $anchorToRoot( $backupDir ),
                escapeshellarg( $root ),
                $pathsToBackup
            );

            exec( $command );

        }

        // trash _all_ previously generated entitys
        /* BROKEN - Too agressive. Doesn't consider $options['match']
        $rebuild = in_array( $option, array( self::REBUILD_AND_BACKUP, self::REBUILD_NO_BACKUP ) );
        if( $rebuild ) {
            foreach( new \DirectoryIterator( $this->paths['entity'] ) as $item ) {
                if( $item->isFile() ) {
                    // unlink( $item->getPathname() );
                }
            }
        }
         */

    }
792725
protected function _prepareForm()
    {
        $form = new Varien_Data_Form(array(
            'id' => 'edit_form',
            'action' => $this->getData('action'),
            'method' => 'post'
        ));
        $form->setUseContainer(true);
        $this->setForm($form);
        return parent::_prepareForm();
    }
581169
public function createFormatter()
    {
        $num = array_push($this->formatters, new PHPCPDFormatterElement($this));

        return $this->formatters[$num - 1];
    }
862401
public function prepareCrudeSetup()
    {
        if (method_exists($this, 'prepareModelCrudeSetup'))
            return $this->prepareModelCrudeSetup();

        $this->crudeSetup = new CrudeSetup($this->getCalledClassName(), []);

        return $this->crudeSetup;
    }
130119
private function prepareCreateXMLTranslationsObject()
    {
        $fragment = new CNabuPHPMethodBuilder(
            $this, 'createXMLTranslationsObject', CNabuPHPMethodBuilder::METHOD_PROTECTED, false, false, false,
            true, 'CNabuXMLTranslationsList'
        );
        $fragment->addComment("Creates the XML instance to manage the translations list of this Element.");
        $fragment->addComment('@return CNabuXMLTranslationsList Returns the created instance.');

        $class_list = nb_strEndsWith($this->class_name, 'Base')
                    ? preg_replace('/Base$/', 'LanguageList', $this->class_name)
                    : $this->class_name . 'LanguageList'
        ;

        $class_list_ns = nb_strEndsWith($this->class_namespace, '\base')
                       ? preg_replace('/\\\\base$/', '', $this->class_namespace)
                       : $this->class_namespace
        ;
        $fragment->addFragment("return new $class_list(\$this->nb_data_object->getTranslations());");

        $this->getDocument()->addUse("\\$class_list_ns\\$class_list");
        $this->getDocument()->addUse('\nabu\xml\lang\CNabuXMLTranslationsList');

        $this->addFragment($fragment);
    }
1075454
public function build(): GetFileInfoRequest
	{
		$instance = new GetFileInfoRequest();
		if ($this->objectId === null) {
			throw new BuilderException('Property [objectId] is required.');
		}
		$instance->objectId = $this->objectId;
		return $instance;
	}
782325
protected function prepareExecute()
    {
        $packageName = $this->getOption('package');

        /** @var AbstractPackage $package */
        $package = $this->console->getPackage($packageName);

        $class = null;

        if ($package) {
            $class = MvcHelper::getPackageNamespace(get_class($package), 1) . '\\Seed\\DatabaseSeeder';
        }

        if (!class_exists($class)) {
            $class = $this->getOption('class');
        }

        $class = StringNormalise::toClassNamespace($class);

        if (!class_exists($class)) {
            $file = $package ? $package->getDir() . '/Seed/' . $class . '.php' : null;

            if (!$file || !is_file($file)) {
                $file = $this->getOption(
                    'd',
                    Ioc::getConfig()->get('path.seeders')
                ) . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';

                if ($file[0] !== '/' && substr($file, 1, 2) !== ':\\') {
                    $file = $this->console->get('path.root') . '/' . $file;
                }
            }

            if (is_file($file)) {
                include_once $file;
            }
        }

        if (!class_exists($class)) {
            throw new \RuntimeException('Class: ' . $class . ' not exists.');
        }

        if (!is_subclass_of($class, 'Windwalker\Core\Seeder\AbstractSeeder')) {
            throw new \RuntimeException('Class: ' . $class . ' should be sub class of Windwalker\Core\Seeder\AbstractSeeder.');
        }

        // Auto include classes
        $path = dirname(ReflectionHelper::getPath($class));

        $files  = Filesystem::files($path);
        $loader = new ClassLoader();
        $loader->register();

        /** @var \SplFileInfo $file */
        foreach ($files as $file) {
            $loader->addMap($file->getBasename('.php'), $file->getPathname());
        }

        $this->console->set('seed.class', $class);
    }
1313882
protected function prepareData()
    {
        $dataProvider = $this->attributes['dataProvider'];
        $urlPattern   = $this->attributes['urlPattern'];
        $return       = new Collection();
        foreach ($dataProvider as $item) {
            $name = isset($item->title) ? $item->title : $item->name;
            $url  = str_replace('{id}', $item->id, $urlPattern);
            $return->push(['url' => handles($url), 'name' => ucfirst($name), 'id' => $item->id]);
        }
        return $return->sortBy('name');
    }
116359
protected function prepare () {
		$request = & $this->request;

		// store original path value for later use
		$request->SetOriginalPath($request->GetPath(TRUE));

		// switching media site version and targeting localized version 
		// will be only by GET method, other methods are not very useful 
		// to localize or target for media site version. It adds only another
		// not much useful route records to route processing:
		$this->isGet = $request->GetMethod() == \MvcCore\IRequest::METHOD_GET;
		
		// look into request params if there is any switching 
		// parameter for session strict mode
		$this->requestGlobalGet = array_merge([], $request->GetGlobalCollection('get')); // clone `$_GET`
		
		// Set up session object to look inside for something from previous requests. 
		// This command starts the session if not started yet.
		$this->setUpSession();

		// Try to recognize administration request by `admin` param in query string
		// and by any authenticated user. The boolean flag `$this->adminRequest`
		// is used only to not process strict session mode redirections and to serve
		// requested documents directly, so there is not necessary to check if user
		// has any privileges or not, because this is only router.
		if (isset($this->requestGlobalGet[static::$adminRequestQueryParamName])) {
			$authClass = static::$baseAuthClass;
			if (class_exists($authClass)) {
				$user = $authClass::GetInstance()->GetUser();
				if ($user !== NULL) 
					$this->adminRequest = TRUE;
			}
		}
	}