コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function createDatagrid($configurator, string $name = null, array $options = []) : DatagridInterface
 {
     if (!$configurator instanceof DatagridConfiguratorInterface) {
         $configurator = $this->datagridRegistry->getConfigurator($configurator);
     }
     if (null === $name) {
         $name = StringUtil::fqcnToBlockPrefix(get_class($configurator));
     }
     $builder = $this->createDatagridBuilder();
     $configurator->buildDatagrid($builder, $options);
     return $builder->getDatagrid($name);
 }
コード例 #2
0
ファイル: MockTestCase.php プロジェクト: rollerworks/datagrid
 protected function createColumn(string $name = 'foo', string $type = TextType::class) : ColumnInterface
 {
     $resolvedType = $this->createMock(ResolvedColumnTypeInterface::class);
     $resolvedType->expects(self::any())->method('getInnerType')->willReturn(new $type());
     $resolvedType->expects(self::any())->method('getBlockPrefix')->willReturn(StringUtil::fqcnToBlockPrefix($type));
     $column = $this->createMock(ColumnInterface::class);
     $column->expects(self::any())->method('getName')->willReturn($name);
     $column->expects(self::any())->method('getType')->willReturn($resolvedType);
     $column->expects(self::any())->method('createHeaderView')->withAnyParameters()->willReturnCallback(function (DatagridView $datagrid) use($column, $name) {
         return new HeaderView($column, $datagrid, $name);
     });
     $column->expects(self::any())->method('createCellView')->withAnyParameters()->willReturnCallback(function (HeaderView $header, $source, $index) {
         $view = new CellView($header, $header->datagrid);
         $view->vars['row'] = $index;
         $view->value = $source;
         $view->source = $source;
         return $view;
     });
     return $column;
 }
コード例 #3
0
ファイル: ColumnType.php プロジェクト: rollerworks/datagrid
 /**
  * Returns the prefix of the template block name for this type.
  *
  * @return string The prefix of the template block name
  */
 public function getBlockPrefix() : string
 {
     return StringUtil::fqcnToBlockPrefix(get_class($this));
 }