EmberBlock.php in Decoupled Blocks 8
File
modules/pdb_ember/src/Plugin/Block/EmberBlock.php
View source
<?php
namespace Drupal\pdb_ember\Plugin\Block;
use Drupal\pdb\Plugin\Block\PdbBlock;
class EmberBlock extends PdbBlock {
public function build() {
$info = $this
->getComponentInfo();
$machine_name = $info['machine_name'];
$build = parent::build();
$build['#allowed_tags'] = [
$machine_name,
];
$build['#markup'] = '<' . $machine_name . ' id="instance-id-' . $machine_name . '">Test</' . $machine_name . '>';
return $build;
}
public function attachFramework(array $component) {
$attached = [];
$attached['drupalSettings']['ember']['global_injectables'] = [];
return $attached;
}
public function attachSettings(array $component) {
$machine_name = $component['machine_name'];
$uuid = $this->configuration['uuid'];
$attached = [];
$attached['drupalSettings']['ember']['components']['instance-id-' . $uuid] = [
'uri' => '/' . $component['path'],
'element' => $machine_name,
];
$attached['drupalSettings']['apps'][$machine_name]['uri'] = '/' . $component['path'];
return $attached;
}
public function attachLibraries(array $component) {
return [
'library' => [
'pdb_ember/ember',
'pdb_ember/app',
],
];
}
}