Final Class Yiisoft\Yii\DataView\GridView\Column\Base\RendererContainer
| Inheritance | Yiisoft\ |
|---|
RendererContainer manages the creation and configuration of column renderers.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| addConfigs() | Add configuration settings for column renderers. | Yiisoft\ |
| get() | Get a configured instance of a column renderer. | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $container | \ |
The dependency injection container for creating renderers. |
public function __construct(ContainerInterface $container)
{
$this->injector = new Injector($container);
}
Add configuration settings for column renderers.
This method allows configuring multiple renderer classes at once. For each class, you can provide constructor arguments either by name or position.
| public self addConfigs ( array $configs ) | ||
| $configs | array |
Configuration settings for renderers. Keys are renderer class names, values are arrays of constructor arguments. |
| return | self |
New instance with updated configurations. |
|---|---|---|
public function addConfigs(array $configs): self
{
$new = clone $this;
foreach ($configs as $class => $config) {
$new->configs[$class] = isset($new->configs[$class])
? array_merge($new->configs[$class], $config)
: $config;
unset($new->cache[$class]);
}
return $new;
}
Get a configured instance of a column renderer.
If the renderer instance is not in cache, it will be created using the dependency injector
and configured with settings provided via {@see \
| public Yiisoft\ | ||
| $class | string |
The class name of the renderer to instantiate. |
| return | Yiisoft\ |
The configured renderer instance. |
|---|---|---|
public function get(string $class): ColumnRendererInterface
{
if (!isset($this->cache[$class])) {
$this->cache[$class] = $this->injector->make($class, $this->configs[$class] ?? []);
}
return $this->cache[$class];
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.