Skip to content

Overloading

Lubomir Andrisek edited this page Jul 11, 2019 · 1 revision

Overload state handler in php

final class MySqlComponent extends \Masala\SqlBuilder implements IMySqlComponentFactory {
    public function handleState(): void {
        $this->state();
        $this->state->rows = \stdClass;
        foreach($this->database->query($this->query, ...$this->arguments)->fetchAll() as $key => $row) {
            ...application logic...
             $this->state->rows->$key = $row;
        }
final class MyMongoComponentGrid extends MongoBuilder implements IMyMongoComponentFactory {
    public function handleState(): void {
        $this->state();
        $this->state->rows = \stdClass;
        foreach($this->client->selectCollection($this->database, $this->collection)->find($this->arguments, $this->options) as $key => $row) {
            ...application logic...
             $this->state->rows->$key = $row;
        }

Overload props method in php

    public function props(): array {
        $props = parent::props();
        $props['edit'] = ['label' => $this->translatorRepository->translate('save changes'), 'link' => $this->link('edit')];
        $props['remove'] = ['link' => $this->link('remove')];
        $props['new'] = ['label' => $this->translatorRepository->translate('save changes'), 'link' => $this->link('new')];
        return $props;
    }

Clone this wiki locally