composer is almost finished, ramins to record compos order through ajax
This commit is contained in:
@@ -61,6 +61,13 @@ class CompositionController extends ControllerBase {
|
||||
$this->error_message = t("Composition creation needs a name as query paramater!");
|
||||
}
|
||||
break;
|
||||
case 'open':
|
||||
if($cid){
|
||||
$this->openComposition($cid);
|
||||
}else{
|
||||
$this->error_message = t("Composition opening needs a cid as url paramater!");
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if($cid){
|
||||
$this->deleteComposition($cid);
|
||||
@@ -109,6 +116,12 @@ class CompositionController extends ControllerBase {
|
||||
'new_link' => render($new_link_build),
|
||||
);
|
||||
break;
|
||||
case 'open':
|
||||
$this->getRendredComposition();
|
||||
$data += array(
|
||||
'compo' => $this->rendered_compo,
|
||||
);
|
||||
break;
|
||||
// case 'delete':
|
||||
// # code...
|
||||
// break;
|
||||
@@ -135,6 +148,16 @@ class CompositionController extends ControllerBase {
|
||||
$this->compo->save();
|
||||
}
|
||||
|
||||
private function getRendredComposition(){
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('composition');
|
||||
$compobuild = $view_builder->view($this->compo, 'default');
|
||||
$this->rendered_compo = render($compobuild);
|
||||
}
|
||||
|
||||
private function openComposition($cid){
|
||||
$this->compo = entity_load('composition', $cid);
|
||||
}
|
||||
|
||||
private function deleteComposition($cid){
|
||||
$this->compo = entity_load('composition', $cid);
|
||||
$this->compo->delete();
|
||||
|
||||
@@ -114,7 +114,14 @@ class StudioUIController extends ControllerBase {
|
||||
"#theme"=>'edlp_composition_ui',
|
||||
"#title" => t('Composition'),
|
||||
"#compositions" => $this->buildCompostionsList(),
|
||||
"#composer" => $this->buildComposer(),
|
||||
"#composer_header" => t("Drag and drop documents on the time line from your chutier above."),
|
||||
"#lastcomposition" => $this->getLastCompo(),
|
||||
'#composer_actions' => array(
|
||||
'play_composition'=>array(
|
||||
"#type"=>'container',
|
||||
"#markup"=>t('Play my composition'),
|
||||
),// TODO: add social media links (what about composition visibility uotside studio_ui ?)
|
||||
),
|
||||
);
|
||||
|
||||
return $composition_ui;
|
||||
@@ -125,8 +132,8 @@ class StudioUIController extends ControllerBase {
|
||||
$query = \Drupal::entityQuery('composition')
|
||||
->condition('user_id', $this->user->id());
|
||||
|
||||
$compos_nids = $query->execute();
|
||||
$compos = entity_load_multiple('composition', $compos_nids);
|
||||
$compos_ids = $query->execute();
|
||||
$compos = entity_load_multiple('composition', $compos_ids);
|
||||
|
||||
$createurl = Url::fromRoute('edlp_studio.composition_controller_action_ajax', ['action' => 'create'], ['absolute' => TRUE]);
|
||||
|
||||
@@ -137,7 +144,16 @@ class StudioUIController extends ControllerBase {
|
||||
);
|
||||
}
|
||||
|
||||
private function buildComposer(){
|
||||
return array('#markup'=>'TODO : composer UI');
|
||||
private function getLastCompo(){
|
||||
// just get the last compositions
|
||||
$query = \Drupal::entityQuery('composition')
|
||||
->condition('user_id', $this->user->id())
|
||||
->range(0,1)
|
||||
->sort('created');
|
||||
|
||||
$compos_id = $query->execute();
|
||||
$lastcompo = entity_load('composition', array_pop($compos_id));
|
||||
|
||||
return $lastcompo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user