Grido@master
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Grido
    • Components
      • Actions
      • Columns
      • Filters
    • DataSources
    • PropertyAccessors
    • Translations

Classes

  • Grido\Translations\FileTranslator
  1 <?php
  2 
  3 /**
  4  * This file is part of the Grido (https://github.com/o5/grido)
  5  *
  6  * Copyright (c) 2011 Petr Bugyík (http://petr.bugyik.cz)
  7  *
  8  * For the full copyright and license information, please view
  9  * the file LICENSE.md that was distributed with this source code.
 10  */
 11 
 12 namespace Grido\Components;
 13 
 14 /**
 15  * Base of grid components.
 16  *
 17  * @package     Grido
 18  * @subpackage  Components
 19  * @author      Petr Bugyík
 20  *
 21  * @property-read string $label
 22  * @property-read string $type
 23  * @property-read \Grido\Grid $grid
 24  * @property-read \Nette\Application\UI\Form $form
 25  */
 26 abstract class Component extends \Nette\Application\UI\PresenterComponent
 27 {
 28     /** @var string */
 29     protected $label;
 30 
 31     /** @var string */
 32     protected $type;
 33 
 34     /** @var \Grido\Grid */
 35     protected $grid;
 36 
 37     /** @var \Nette\Application\UI\Form */
 38     protected $form;
 39 
 40     /** @var \Grido\PropertyAccessors\IPropertyAccessor */
 41     protected $propertyAccessor;
 42 
 43     /**
 44      * @return \Grido\Grid
 45      */
 46     public function getGrid()
 47     {
 48         return $this->grid;
 49     }
 50 
 51     /**
 52      * @return \Nette\Application\UI\Form
 53      */
 54     public function getForm()
 55     {
 56         if ($this->form === NULL) {
 57             $this->form = $this->grid->getComponent('form');
 58         }
 59 
 60         return $this->form;
 61     }
 62 
 63     /**
 64      * @return \Grido\PropertyAccessors\IPropertyAccessor
 65      */
 66     public function getPropertyAccessor()
 67     {
 68         if ($this->propertyAccessor === NULL) {
 69             $this->propertyAccessor = $this->grid->getPropertyAccessor();
 70         }
 71 
 72         return $this->propertyAccessor;
 73     }
 74 
 75     /**
 76      * @return string
 77      * @internal
 78      */
 79     public function getLabel()
 80     {
 81         return $this->label;
 82     }
 83 
 84     /**
 85      * @return string
 86      * @internal
 87      */
 88     public function getType()
 89     {
 90         return $this->type;
 91     }
 92 
 93     /**
 94      * @param \Grido\Grid $grid
 95      * @param string $name
 96      * @return \Nette\ComponentModel\Container
 97      */
 98     protected function addComponentToGrid($grid, $name)
 99     {
100         $this->grid = $grid;
101         $this->propertyAccessor = $grid->getPropertyAccessor();
102 
103         //check container exist
104         $container = $this->grid->getComponent($this::ID, FALSE);
105         if (!$container) {
106             $this->grid->addComponent(new \Nette\ComponentModel\Container, $this::ID);
107             $container = $this->grid->getComponent($this::ID);
108         }
109 
110         return $container->addComponent($this, $name);
111     }
112 
113     /**
114      * @param  string $message
115      * @return string
116      */
117     protected function translate($message)
118     {
119         return call_user_func_array(array($this->grid->getTranslator(), "translate"), func_get_args());
120     }
121 }
122 
Grido@master API documentation generated by ApiGen