Completed
Push — master ( 4ab803...4a4860 )
by Vladimir
02:28
created

Compiler::setRedirectTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx;
9
10
use allejo\stakx\Command\BuildableCommand;
11
use allejo\stakx\Document\ContentItem;
12
use allejo\stakx\Document\DynamicPageView;
13
use allejo\stakx\Document\PageView;
14
use allejo\stakx\Document\PermalinkDocument;
15
use allejo\stakx\Document\RepeaterPageView;
16
use allejo\stakx\Document\TwigDocument;
17
use allejo\stakx\Exception\FileAwareException;
18
use allejo\stakx\FrontMatter\ExpandedValue;
19
use allejo\stakx\Manager\BaseManager;
20
use allejo\stakx\Manager\ThemeManager;
21
use allejo\stakx\Manager\TwigManager;
22
use allejo\stakx\System\Folder;
23
use allejo\stakx\System\FilePath;
24
use Twig_Environment;
25
use Twig_Error_Runtime;
26
use Twig_Error_Syntax;
27
use Twig_Source;
28
use Twig_Template;
29
30
/**
31
 * This class takes care of rendering the Twig body of PageViews with the respective information and it also takes care
32
 * of writing the rendered Twig to the filesystem.
33
 *
34
 * @internal
35
 *
36
 * @since 0.1.1
37
 */
38
class Compiler extends BaseManager
39
{
40
    /** @var string|false */
41
    private $redirectTemplate;
42
43
    /** @var PageView[][] */
44
    private $importDependencies;
45
46
    /** @var Twig_Template[] */
47
    private $templateDependencies;
48
49
    /** @var PageView[] */
50
    private $pageViewsFlattened;
51
52
    /** @var string[] */
53
    private $templateMapping;
54
55
    /** @var PageView[][] */
56
    private $pageViews;
57
58
    /** @var Folder */
59
    private $folder;
60
61
    /** @var string */
62
    private $theme;
63
64
    /** @var Twig_Environment */
65
    private $twig;
66
67 14
    public function __construct()
68
    {
69 14
        parent::__construct();
70
71 14
        $this->twig = TwigManager::getInstance();
72 14
        $this->theme = '';
73 14
    }
74
75
    /**
76
     * @param string|false $template
77
     */
78
    public function setRedirectTemplate($template)
79
    {
80
        $this->redirectTemplate = $template;
81
    }
82
83
    /**
84
     * @param Folder $folder
85
     */
86 14
    public function setTargetFolder(Folder $folder)
87
    {
88 14
        $this->folder = $folder;
89 14
    }
90
91
    /**
92
     * @param PageView[][] $pageViews
93
     * @param PageView[]   $pageViewsFlattened
94
     */
95 14
    public function setPageViews(array &$pageViews, array &$pageViewsFlattened)
96
    {
97 14
        $this->pageViews = &$pageViews;
98 14
        $this->pageViewsFlattened = &$pageViewsFlattened;
99 14
    }
100
101
    /**
102
     * @param string $themeName
103
     */
104
    public function setThemeName($themeName)
105
    {
106
        $this->theme = $themeName;
107
    }
108
109
    ///
110
    // Twig parent templates
111
    ///
112
113
    public function isImportDependency($filePath)
114
    {
115
        return isset($this->importDependencies[$filePath]);
116
    }
117
118
    /**
119
     * Check whether a given file path is used as a parent template by a PageView
120
     *
121
     * @param  string $filePath
122
     *
123
     * @return bool
124
     */
125
    public function isParentTemplate($filePath)
126
    {
127
        return isset($this->templateDependencies[$filePath]);
128
    }
129
130
    /**
131
     * Rebuild all of the PageViews that used a given template as a parent
132
     *
133
     * @param string $filePath The file path to the parent Twig template
134
     */
135
    public function refreshParent($filePath)
136
    {
137
        foreach ($this->templateDependencies[$filePath] as &$parentTemplate)
0 ignored issues
show
Bug introduced by
The expression $this->templateDependencies[$filePath] of type object<Twig_Template> is not traversable.
Loading history...
138
        {
139
            $this->compilePageView($parentTemplate);
140
        }
141
    }
142
143
    public function getTemplateMappings()
144
    {
145
        return $this->templateMapping;
146
    }
147
148
    ///
149
    // IO Functionality
150
    ///
151
152
    /**
153
     * Compile all of the PageViews registered with the compiler.
154
     *
155
     * @since 0.1.0
156
     */
157 14
    public function compileAll()
158
    {
159 14
        foreach ($this->pageViewsFlattened as &$pageView)
160
        {
161 14
            $this->compilePageView($pageView);
162
        }
163 14
    }
164
165
    public function compileImportDependencies($filePath)
166
    {
167
        foreach ($this->importDependencies[$filePath] as &$dependent)
168
        {
169
            $this->compilePageView($dependent);
170
        }
171
    }
172
173
    public function compileSome(array $filter = array())
174
    {
175
        /** @var PageView $pageView */
176
        foreach ($this->pageViewsFlattened as &$pageView)
177
        {
178
            $ns = $filter['namespace'];
179
180
            if ($pageView->hasTwigDependency($ns, $filter['dependency']) ||
181
                $pageView->hasTwigDependency($ns, null)
182
            ) {
183
                $this->compilePageView($pageView);
184
            }
185
        }
186
    }
187
188
    /**
189
     * Compile an individual PageView item.
190
     *
191
     * This function will take care of determining *how* to treat the PageView and write the compiled output to a the
192
     * respective target file.
193
     *
194
     * @param DynamicPageView|RepeaterPageView|PageView $pageView The PageView that needs to be compiled
195
     *
196
     * @since 0.1.1
197
     */
198 14
    public function compilePageView(PageView &$pageView)
199
    {
200 14
        $this->twig->addGlobal('__currentTemplate', $pageView->getFilePath());
201 14
        $this->output->debug('Compiling {type} PageView: {pageview}', array(
202 14
            'pageview' => $pageView->getRelativeFilePath(),
203 14
            'type' => $pageView->getType()
204
        ));
205
206
        try
207
        {
208 14
            switch ($pageView->getType())
209
            {
210 14
                case PageView::STATIC_TYPE:
211 10
                    $this->compileStaticPageView($pageView);
212 10
                    $this->compileStandardRedirects($pageView);
213 10
                    break;
214
215 4
                case PageView::DYNAMIC_TYPE:
216 2
                    $this->compileDynamicPageViews($pageView);
217 2
                    $this->compileStandardRedirects($pageView);
218 2
                    break;
219
220 2
                case PageView::REPEATER_TYPE:
221 2
                    $this->compileRepeaterPageViews($pageView);
222 2
                    $this->compileExpandedRedirects($pageView);
223 14
                    break;
224
            }
225
        }
226
        catch (Twig_Error_Runtime $e)
227
        {
228
            throw new FileAwareException(
229
                $e->getRawMessage(),
230
                $e->getCode(),
231
                $e,
232
                $pageView->getRelativeFilePath(),
233
                $e->getTemplateLine() + $pageView->getLineOffset()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class allejo\stakx\Document\PermalinkDocument as the method getLineOffset() does only exist in the following sub-classes of allejo\stakx\Document\PermalinkDocument: allejo\stakx\Document\ContentItem, allejo\stakx\Document\DynamicPageView, allejo\stakx\Document\PageView, allejo\stakx\Document\RepeaterPageView, allejo\stakx\FrontMatter\FrontMatterDocument. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
234
            );
235
        }
236 14
    }
237
238
    /**
239
     * Write the compiled output for a static PageView.
240
     *
241
     * @param PageView $pageView
242
     *
243
     * @since 0.1.1
244
     */
245 10
    private function compileStaticPageView(PageView &$pageView)
246
    {
247 10
        $targetFile = $pageView->getTargetFile();
248 10
        $output = $this->renderStaticPageView($pageView);
249
250 10
        $this->output->notice('Writing file: {file}', array('file' => $targetFile));
251 10
        $this->folder->writeFile($targetFile, $output);
252 10
    }
253
254
    /**
255
     * Write the compiled output for a dynamic PageView.
256
     *
257
     * @param DynamicPageView $pageView
258
     *
259
     * @since 0.1.1
260
     */
261 2
    private function compileDynamicPageViews(DynamicPageView &$pageView)
262
    {
263 2
        $contentItems = $pageView->getRepeatableItems();
264 2
        $template = $this->createTwigTemplate($pageView);
265
266 2
        foreach ($contentItems as &$contentItem)
267
        {
268 2
            if ($contentItem->isDraft() && !Service::getParameter(BuildableCommand::USE_DRAFTS))
269
            {
270 1
                $this->output->debug('{file}: marked as a draft', array(
271 1
                    'file' => $contentItem->getRelativeFilePath()
272
                ));
273
274 1
                continue;
275
            }
276
277 2
            $targetFile = $contentItem->getTargetFile();
278 2
            $output = $this->renderDynamicPageView($template, $contentItem);
0 ignored issues
show
Documentation introduced by
$contentItem is of type object<allejo\stakx\Document\RepeatableItem>, but the function expects a object<allejo\stakx\Document\TwigDocument>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
279
280 2
            $this->output->notice('Writing file: {file}', array('file' => $targetFile));
281 2
            $this->folder->writeFile($targetFile, $output);
282
283 2
            $this->compileStandardRedirects($contentItem);
0 ignored issues
show
Documentation introduced by
$contentItem is of type object<allejo\stakx\Document\TwigDocument>, but the function expects a object<allejo\stakx\Document\PermalinkDocument>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
284
        }
285 2
    }
286
287
    /**
288
     * Write the compiled output for a repeater PageView.
289
     *
290
     * @param RepeaterPageView $pageView
291
     *
292
     * @since 0.1.1
293
     */
294 2
    private function compileRepeaterPageViews(RepeaterPageView &$pageView)
295
    {
296 2
        $pageView->rewindPermalink();
297
298 2
        $template = $this->createTwigTemplate($pageView);
299 2
        $permalinks = $pageView->getRepeaterPermalinks();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class allejo\stakx\Document\PageView as the method getRepeaterPermalinks() does only exist in the following sub-classes of allejo\stakx\Document\PageView: allejo\stakx\Document\RepeaterPageView. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
300
301 2
        foreach ($permalinks as $permalink)
302
        {
303 2
            $pageView->bumpPermalink();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class allejo\stakx\Document\PageView as the method bumpPermalink() does only exist in the following sub-classes of allejo\stakx\Document\PageView: allejo\stakx\Document\RepeaterPageView. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
304 2
            $targetFile = $pageView->getTargetFile();
305 2
            $output = $this->renderRepeaterPageView($template, $pageView, $permalink);
0 ignored issues
show
Compatibility introduced by
$pageView of type object<allejo\stakx\Document\PageView> is not a sub-type of object<allejo\stakx\Document\RepeaterPageView>. It seems like you assume a child class of the class allejo\stakx\Document\PageView to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
306
307 2
            $this->output->notice('Writing repeater file: {file}', array('file' => $targetFile));
308 2
            $this->folder->writeFile($targetFile, $output);
309
        }
310 2
    }
311
312
    /**
313
     * @deprecated
314
     *
315
     * @todo This function needs to be rewritten or removed. Something
316
     *
317
     * @param ContentItem $contentItem
318
     */
319
    public function compileContentItem(ContentItem &$contentItem)
320
    {
321
        $pageView = &$contentItem->getPageView();
322
        $template = $this->createTwigTemplate($pageView);
323
324
        $this->twig->addGlobal('__currentTemplate', $pageView->getFilePath());
325
        $contentItem->evaluateFrontMatter($pageView->getFrontMatter(false));
326
327
        $targetFile = $contentItem->getTargetFile();
328
        $output = $this->renderDynamicPageView($template, $contentItem);
329
330
        $this->output->notice('Writing file: {file}', array('file' => $targetFile));
331
        $this->folder->writeFile($targetFile, $output);
332
    }
333
334
    ///
335
    // Redirect handling
336
    ///
337
338
    /**
339
     * Write redirects for standard redirects.
340
     *
341
     * @param PermalinkDocument $pageView
342
     *
343
     * @since 0.1.1
344
     */
345 12
    private function compileStandardRedirects(PermalinkDocument &$pageView)
346
    {
347 12
        $redirects = $pageView->getRedirects();
348
349 12
        foreach ($redirects as $redirect)
0 ignored issues
show
Bug introduced by
The expression $redirects of type null|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
350
        {
351 4
            $redirectPageView = PageView::createRedirect(
352 4
                $redirect,
353 4
                $pageView->getPermalink(),
354 4
                $this->redirectTemplate
355
            );
356
357 4
            $this->compileStaticPageView($redirectPageView);
358
        }
359 12
    }
360
361
    /**
362
     * Write redirects for expanded redirects.
363
     *
364
     * @param RepeaterPageView $pageView
365
     *
366
     * @since 0.1.1
367
     */
368 2
    private function compileExpandedRedirects(RepeaterPageView &$pageView)
369
    {
370 2
        $permalinks = $pageView->getRepeaterPermalinks();
371
372
        /** @var ExpandedValue[] $repeaterRedirect */
373 2
        foreach ($pageView->getRepeaterRedirects() as $repeaterRedirect)
374
        {
375
            /**
376
             * @var int           $index
377
             * @var ExpandedValue $redirect
378
             */
379
            foreach ($repeaterRedirect as $index => $redirect)
380
            {
381
                $redirectPageView = PageView::createRedirect(
382
                    $redirect->getEvaluated(),
383
                    $permalinks[$index]->getEvaluated(),
384
                    $this->redirectTemplate
385
                );
386
                $this->compilePageView($redirectPageView);
387
            }
388
        }
389 2
    }
390
391
    ///
392
    // Twig Functionality
393
    ///
394
395
    /**
396
     * Get the compiled HTML for a specific iteration of a repeater PageView.
397
     *
398
     * @param Twig_Template $template
399
     * @param PageView      $pageView
400
     * @param ExpandedValue $expandedValue
401
     *
402
     * @since  0.1.1
403
     *
404
     * @return string
405
     */
406 2
    private function renderRepeaterPageView(Twig_Template &$template, RepeaterPageView &$pageView, ExpandedValue &$expandedValue)
407
    {
408 2
        $pageView->setFrontMatter(array(
409 2
            'permalink' => $expandedValue->getEvaluated(),
410 2
            'iterators' => $expandedValue->getIterators(),
411
        ));
412
413
        return $template
414 2
            ->render(array(
415 2
                'this' => $pageView->createJail(),
416
            ));
417
    }
418
419
    /**
420
     * Get the compiled HTML for a specific ContentItem.
421
     *
422
     * @param Twig_Template $template
423
     * @param TwigDocument  $twigItem
424
     *
425
     * @return string
426
     * @since  0.1.1
427
     *
428
     */
429 2
    private function renderDynamicPageView(Twig_Template &$template, TwigDocument &$twigItem)
430
    {
431
        return $template
432 2
            ->render(array(
433 2
                'this' => $twigItem->createJail(),
434
            ));
435
    }
436
437
    /**
438
     * Get the compiled HTML for a static PageView.
439
     *
440
     * @param PageView $pageView
441
     *
442
     * @since  0.1.1
443
     *
444
     * @throws \Exception
445
     * @throws \Throwable
446
     * @throws Twig_Error_Syntax
447
     *
448
     * @return string
449
     */
450 10
    private function renderStaticPageView(PageView &$pageView)
451
    {
452
        return $this
453 10
            ->createTwigTemplate($pageView)
454 10
            ->render(array(
455 10
                'this' => $pageView->createJail(),
456
            ));
457
    }
458
459
    /**
460
     * Create a Twig template that just needs an array to render.
461
     *
462
     * @param PageView $pageView The PageView whose body will be used for Twig compilation
463
     *
464
     * @since  0.1.1
465
     *
466
     * @throws \Exception
467
     * @throws \Throwable
468
     * @throws Twig_Error_Syntax
469
     *
470
     * @return Twig_Template
471
     */
472 14
    private function createTwigTemplate(PageView &$pageView)
473
    {
474
        try
475
        {
476 14
            $template = $this->twig->createTemplate($pageView->getContent());
477
478 14
            $this->templateMapping[$template->getTemplateName()] = $pageView->getRelativeFilePath();
479
480 14
            if (Service::getParameter(BuildableCommand::WATCHING))
481
            {
482
                // Keep track of import dependencies
483
                foreach ($pageView->getImportDependencies() as $dependency)
484
                {
485
                    $this->importDependencies[$dependency][$pageView->getName()] = &$pageView;
0 ignored issues
show
Deprecated Code introduced by
The method allejo\stakx\FrontMatter...tterDocument::getName() has been deprecated with message: use getObjectName() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
486
                }
487
488
                // Keep track of Twig extends'
489
                $parent = $template->getParent(array());
490
491
                while ($parent !== false)
492
                {
493
                    // Replace the '@theme' namespace in Twig with the path to the theme folder and create a UnixFilePath object from the given path
494
                    $path = str_replace('@theme', $this->fs->appendPath(ThemeManager::THEME_FOLDER, $this->theme), $parent->getTemplateName());
495
                    $path = new FilePath($path);
496
497
                    $this->templateDependencies[(string)$path][$pageView->getName()] = &$pageView;
0 ignored issues
show
Deprecated Code introduced by
The method allejo\stakx\FrontMatter...tterDocument::getName() has been deprecated with message: use getObjectName() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
498
499
                    $parent = $parent->getParent(array());
500
                }
501
            }
502
503 14
            return $template;
504
        }
505
        catch (Twig_Error_Syntax $e)
506
        {
507
            $e->setTemplateLine($e->getTemplateLine() + $pageView->getLineOffset());
508
            $e->setSourceContext(new Twig_Source(
509
                $pageView->getContent(),
510
                $pageView->getName(),
0 ignored issues
show
Deprecated Code introduced by
The method allejo\stakx\FrontMatter...tterDocument::getName() has been deprecated with message: use getObjectName() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
511
                $pageView->getRelativeFilePath()
512
            ));
513
514
            throw $e;
515
        }
516
    }
517
}
518