for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Psi\Component\Grid\Cell;
use Psi\Component\Grid\CellInterface;
use Psi\Component\Grid\CellViewInterface;
use Psi\Component\Grid\RowData;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
class PropertyCell implements CellInterface
{
private $accessor;
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
$this->accessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function createView(RowData $data, array $options): CellViewInterface
$property = $options['property'];
$value = $this->accessor->getValue($data->getObject(), $property);
return new View\ScalarView($value);
public function configureOptions(OptionsResolver $options)
$options->setDefault('property', null);
$options->setAllowedTypes('property', ['string', 'null']);
$options->setNormalizer('property', function (OptionsResolver $options, $value) {
if (null !== $value) {
return $value;
return $options['column_name'];
});