1. Go to this page and download the library: Download wieni/wmcontroller library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wieni / wmcontroller example snippets
// src/Controller/Node/ArticleController.php
namespace Drupal\mymodule\Controller\Node;
use Drupal\Core\Controller\ControllerBase;
use Drupal\node\NodeInterface;
class ArticleController extends ControllerBase
{
public function show(NodeInterface $node)
{
return [
'#theme' => 'article_node',
'#node' => $node,
];
}
}
// src/Controller/Node/ArticleController.php
namespace Drupal\mymodule\Controller\Node;
use Drupal\Core\Controller\ControllerBase;
use Drupal\mymodule\Entity\Node\Article; # See wieni/wmmodel
class ArticleController extends ControllerBase
{
public function show(Article $article)
{
// Loads mytheme/templates/article/detail.html.twig
return $this->view(
'article.detail',
[
'article' => $article,
]
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.