Skip to content

Commit

Permalink
Merge 20d7953 into ac8ebb1
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Mar 28, 2020
2 parents ac8ebb1 + 20d7953 commit 6701ee6
Show file tree
Hide file tree
Showing 54 changed files with 259 additions and 1,317 deletions.
85 changes: 0 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,91 +279,6 @@ Visite [Twig Documentaion](http://twig.sensiolabs.org/documentation) for more ti
* [jasny/twig-extensions](https://github.com/jasny/twig-extensions)
* [twig/markdown-extra](https://github.com/twigphp/markdown-extra)

## Events ##

This plugin emits several events.

### Loaders ###

The default loader can be replace by listening to the `Cake\TwigView\Event\LoaderEvent::EVENT`, for example with [twital](https://github.com/goetas/twital):

```php
<?php

use Cake\Event\EventListenerInterface;
use Goetas\Twital\TwitalLoader;
use Cake\TwigView\Event\ConstructEvent;
use Cake\TwigView\Event\LoaderEvent;

class LoaderListener implements EventListenerInterface
{
public function implementedEvents(): array
{
return [
LoaderEvent::EVENT => 'loader',
ConstructEvent::EVENT => 'construct',
];
}

public function loader(LoaderEvent $event): void
{
$event->result = new TwitalLoader($event->getLoader());
}

/**
* We've also listening in on this event so we can add the needed extensions to check for to the view
*/
public function construct(ConstructEvent $event): void
{
$event->getTwigView()->unshiftExtension('.twital.html');
$event->getTwigView()->unshiftExtension('.twital.xml');
$event->getTwigView()->unshiftExtension('.twital.xhtml');
}
}


```

### Extensions ###

Extensions can be added to the twig environment by listening to the `Cake\TwigView\Event\ConstructEvent::EVENT`, for example:

```php
<?php

use Cake\Event\EventListenerInterface;
use Cake\TwigView\Event\ConstructEvent;

class LoaderListener implements EventListenerInterface
{
public function implementedEvents(): array
{
return [
ConstructEvent::EVENT => 'construct',
];
}

public function construct(ConstructEvent $event): void
{
$event->getTwig()->addExtension(new YourTwigExtension);
}
}

```

## Bake

You can use Bake to generate your basic CRUD views using the `theme` option.
Let's say you have a `TasksController` for which you want to generate twig templates.
You can use the following command to generate your index, add, edit and view file formatted
using Twig :

```bash
bin/cake bake twig_template Tasks all -t Cake/TwigView
```

## Screenshots ##

### Profiler ###

![Profiler](/docs/images/profiler.png)
Expand Down
3 changes: 0 additions & 3 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
'markdown' => [
'engine' => 'engine', // See https://twig.symfony.com/doc/3.x/filters/markdown_to_html.html and then set to `new DefaultMarkdown()`
],
'flags' => [
'potentialDangerous' => false,
],
],
];
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ parameters:
-
message: "#^Parameter \\#2 \\$callable of class Twig\\\\TwigFilter constructor expects \\(callable\\(\\)\\: mixed\\)\\|null, 'debug' given\\.$#"
count: 1
path: src/Twig/Extension/Basic.php
path: src/Twig/Extension/BasicExtension.php

-
message: "#^Constant ROOT not found\\.$#"
count: 2
path: src/Twig/Extension/Profiler.php
path: src/Twig/Extension/ProfilerExtension.php

-
message: "#^Constant CACHE not found\\.$#"
Expand Down
11 changes: 2 additions & 9 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.9.4@352bd3f5c5789db04e4010856c2f4e01ed354f4e">
<file src="src/Shell/CompileShell.php">
<DeprecatedClass occurrences="3">
<code>Shell</code>
<code>parent::__construct($io, $locator)</code>
<code>parent::getOptionParser()</code>
</DeprecatedClass>
</file>
<file src="src/Twig/TokenParser/Cell.php">
<file src="src/Twig/TokenParser/CellParser.php">
<InternalMethod occurrences="3">
<code>parseExpression</code>
<code>parseExpression</code>
<code>parseExpression</code>
</InternalMethod>
</file>
<file src="src/Twig/TokenParser/Element.php">
<file src="src/Twig/TokenParser/ElementParser.php">
<InternalMethod occurrences="3">
<code>parseExpression</code>
<code>parseExpression</code>
Expand Down
57 changes: 0 additions & 57 deletions src/Event/ConstructEvent.php

This file was deleted.

63 changes: 0 additions & 63 deletions src/Event/EnvironmentConfigEvent.php

This file was deleted.

132 changes: 0 additions & 132 deletions src/Event/ExtensionsListener.php

This file was deleted.

Loading

0 comments on commit 6701ee6

Please sign in to comment.