|
@@ -3,21 +3,67 @@
|
|
|
namespace Drupal\edlp_productions\Controller;
|
|
|
|
|
|
use Drupal\Core\Controller\ControllerBase;
|
|
|
-// use Drupal\Core\Datetime\DrupalDateTime;
|
|
|
+use Drupal\menu_link_content\Entity\MenuLinkContent;
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
|
|
|
|
|
|
class ProductionsController extends ControllerBase {
|
|
|
|
|
|
+// TODO: generate the menu, how ?
|
|
|
+
|
|
|
+ private function query() {
|
|
|
+ // TODO: get the production menu
|
|
|
+ // @see https://api.drupal.org/api/drupal/core%21modules%21menu_ui%21menu_ui.module/8.6.x
|
|
|
+ // @see https://drupal.stackexchange.com/questions/200893/get-menu-link-page-settings-from-view-configuration
|
|
|
+ $menu_name = 'productions';
|
|
|
+
|
|
|
+ $query = \Drupal::entityQuery('menu_link_content')
|
|
|
+ ->condition('menu_name', $menu_name)
|
|
|
+ ->condition('enabled', 1)
|
|
|
+ ->sort('weight', 'ASC');
|
|
|
+
|
|
|
+ $result = $query->execute();
|
|
|
+ // dpm($result);
|
|
|
+
|
|
|
+ foreach ($result as $id) {
|
|
|
+ $menu_link = MenuLinkContent::load($id);
|
|
|
+ // dpm($menu_link->getParentId());
|
|
|
+ if($menu_link->getParentId() === ""){
|
|
|
+ dpm($menu_link->getTitle());
|
|
|
+ $path = $menu_link->getUrlObject()->getInternalPath();
|
|
|
+ preg_match('/^node\/(\d+)$/', $path, $m);
|
|
|
+ dpm($m[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: loop through first level
|
|
|
+ // TODO: load nodes
|
|
|
+ // TODO: create items
|
|
|
+ // TODO: apply right display
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private function toRenderable(){
|
|
|
+ $this->query();
|
|
|
+ // dpm($this->future_nodes);
|
|
|
+
|
|
|
+ // TODO: add localtasks to each nodes : https://api.drupal.org/api/drupal/core%21includes%21menu.inc/function/menu_primary_local_tasks/8.2.x
|
|
|
+
|
|
|
+ return array(
|
|
|
+ "#theme"=>'edlp_productions',
|
|
|
+ "#hello"=>'Hello',
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Display productions as a page.
|
|
|
*
|
|
|
* @return renderable array
|
|
|
*/
|
|
|
public function productions() {
|
|
|
- return array(
|
|
|
- "#markup"=>"Edlp Productions"
|
|
|
- );
|
|
|
+ return $this->toRenderable();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -28,9 +74,7 @@ class ProductionsController extends ControllerBase {
|
|
|
public function productionsjson() {
|
|
|
|
|
|
$response = new JsonResponse();
|
|
|
- $renderable = array(
|
|
|
- "#markup"=>"Edlp Productions"
|
|
|
- );
|
|
|
+ $renderable = $this->toRenderable();
|
|
|
$rendered = render($renderable);
|
|
|
|
|
|
$response->setData([
|