Esempio n. 1
0
 /**
  * Get column header.
  *
  * @return string
  */
 public function getHeader()
 {
     if ($header = $this->get('header')) {
         return Helpers::tryTranslate($header);
     }
     return $this->translate('columns') ?: $this->generateLabel();
 }
Esempio n. 2
0
 /**
  * Get field label.
  *
  * @return string
  */
 public function getLabel()
 {
     if ($label = $this->get('label')) {
         return Helpers::tryTranslate($label);
     }
     return $this->generateLabel();
 }
Esempio n. 3
0
 /**
  * @param Action $action
  * @param mixed $model
  *
  * @return array
  */
 protected function exportAction(Action $action, $model)
 {
     $id = $action->getId();
     $title = Helpers::tryTranslate($action->getTitle($model));
     $disabled = $action->isDisabled($model);
     $state = $action->getState($model);
     return compact('id', 'title', 'disabled', 'state');
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['prompt' => Helpers::tryTranslate($this->get('prompt')), 'items' => $this->translateItems($this->getItems()), 'multiple' => $this->get('multiple', false)] + parent::toArray();
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['input_type' => $this->inputType(), 'placeholder' => Helpers::tryTranslate($this->get('placeholder'))] + parent::toArray();
 }
Esempio n. 6
0
 /**
  * Generate a label from the id.
  *
  * @return string
  */
 protected function generateLabel()
 {
     return Helpers::labelFromId($this->id);
 }
Esempio n. 7
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['append' => Helpers::tryTranslate($this->get('append')), 'prepend' => Helpers::tryTranslate($this->get('prepend'))] + parent::toArray();
 }
Esempio n. 8
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['contents' => Helpers::tryTranslate($this->contents)] + parent::toArray();
 }
Esempio n. 9
0
 /**
  * @param mixed $model
  *
  * @return string
  */
 public function getTitle($model)
 {
     return $this->evaluate('title', $model) ?: Helpers::labelFromId($this->get('id'));
 }
Esempio n. 10
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['title' => Helpers::tryTranslate($this->title)] + parent::toArray();
 }
Esempio n. 11
0
 /**
  * Make title for specified plurality.
  *
  * @param string $plurality
  *
  * @return string
  */
 protected function makeTitle($plurality)
 {
     $result = $this->translate("::{$this->id}.title.{$plurality}");
     if ($result !== null) {
         return $result;
     }
     $result = $this->translate("::entities.titles.{$this->id}.{$plurality}");
     if ($result !== null) {
         return $result;
     }
     $func = "str_{$plurality}";
     return Helpers::labelFromId($func($this->id));
 }