예제 #1
0
파일: Task.php 프로젝트: ergonlogic/ran
 function __construct(EntityInterface $entity)
 {
     $this->queue = new \Celery('localhost', 'guest', 'guest', '/');
     $this->id = $entity->getRevisionId();
     $this->ref_id = $entity->nid->value;
     $this->name = $entity->getTitle();
     $this->type = $entity->bundle();
     // Host Definition
     $this->host_def_vars = $this->getHostDefinition($entity);
     $this->host_def_vars['ran_name'] = $this->name;
     $this->host_def_type = $this->host_def_vars['_system_type'];
     unset($this->host_def_vars['_system_type']);
     // Host Configuration
     $this->host_conf_vars = $this->getHostConfiguration($entity);
     $this->host_conf_types = $this->host_conf_vars['_roles'];
     unset($this->host_conf_vars['_roles']);
     // Host Description
     $this->description = 'Generated by Rán.';
     $desc = $entity->getFields()['field_ran__description']->getString();
     if (isset($this->vars['_description'])) {
         $this->description = $this->vars['_description'];
         unset($this->vars['_description']);
     }
     $this->org = 'root';
     $this->project = 'default';
     $this->extra_vars = json_encode(array('ran_name' => $this->name, 'ran_desc' => $this->description, 'ran_type' => $this->type, 'ran_def_type' => $this->host_def_type, 'ran_def_vars' => $this->host_def_vars, 'ran_conf_types' => $this->host_conf_types, 'ran_conf_vars' => $this->host_conf_vars), JSON_UNESCAPED_UNICODE);
 }
 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $links = array('edit' => array('title' => t('Edit'), 'url' => Url::fromRoute('entity.empty_page.edit_form', ['empty_page' => $entity->getName()])), 'delete' => array('title' => t('Delete'), 'url' => Url::fromRoute('entity.empty_page.delete_form', ['empty_page' => $entity->getName()])));
     $row = array('title' => array('data' => $entity->getTitle()), 'name' => array('data' => $entity->getName()), 'path' => array('data' => array('#type' => 'link', '#title' => $entity->getPath(), '#url' => Url::fromUri('base://' . $entity->getPath()), '#options' => array('html' => TRUE))), 'operations' => array('data' => array('#type' => 'operations', '#links' => $links)));
     return $row + parent::buildRow($entity);
 }