Loading chessboard_filter/src/ChessboardBulletinBoardCodeTagContentFilter.php +13 −3 Changes for chessboard_filter/src/ChessboardBulletinBoardCodeTagContentFilter.php: 13 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ namespace Drupal\chessboard_filter; use Drupal\chessboard\ChessboardFilterInterface as FilterInterface; use Drupal\chessboard_images\Diagram; use Drupal\chessboard_images\PiecePlacement; /** Loading Loading @@ -43,8 +42,19 @@ class ChessboardBulletinBoardCodeTagContentFilter implements FilterInterface{ */ public function filter($value) { $item = $this->parse($value); $diagram = new Diagram(); $element = $diagram->setPiecePlacement(new PiecePlacement($item['board_value'], $item['file_max']))->toRenderable(); $element = array( '#attached' => array( 'library' => array('chessboard_images/drupal.chessboard_images'), ), '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('chessboard')), 'chessboard' => array( '#type' => 'chessboard_images_diagram', '#piece_placement' => new PiecePlacement($item['board_value'], $item['file_max']), '#border' => $item['border'], '#square_color_first' => $item['square_color_first'], ), ); return $element; } Loading chessboard_images/src/Diagram.phpdeleted 100644 → 0 +0 −52 Changes for chessboard_images/src/Diagram.php: 0 added lines, 52 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\chessboard_images\Diagram. */ namespace Drupal\chessboard_images; use Drupal\Core\Render\RenderableInterface; use Drupal\chessboard\PiecePlacementInterface; /** * @internal * * Defines a Chessboard Images Diagram. * */ class Diagram implements RenderableInterface { /** * The piece placement object. * * @var Drupal\chessboard\PiecePlacementInterface */ protected $piecePlacement; public function setPiecePlacement(PiecePlacementInterface $piece_placement) { $this->piecePlacement = $piece_placement; return $this; } /** * {@inheritdoc} */ public function toRenderable() { $elements = array( '#attached' => array( 'library' => array('chessboard_images/drupal.chessboard_images'), ), '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('chessboard')), 'chessboard' => array( '#type' => 'chessboard_images_diagram', '#piece_placement' => $this->piecePlacement, ), ); return $elements; } } chessboard_images_formatter/src/Plugin/Field/FieldFormatter/ChessboardImagesFormatter.php +11 −3 Changes for chessboard_images_formatter/src/Plugin/Field/FieldFormatter/ChessboardImagesFormatter.php: 11 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ namespace Drupal\chessboard_images_formatter\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; use Drupal\chessboard_images_formatter\PiecePlacementBuilder; use Drupal\chessboard_images\Diagram; /** * Plugin implementation of the 'chessboard_images_formatter_diagram' formatter. Loading @@ -33,9 +32,18 @@ class ChessboardImagesFormatter extends FormatterBase { $builder = new PiecePlacementBuilder(); $builder->setFileMax(8); $diagram = new Diagram(); foreach ($items as $delta => $item) { $elements[$delta] = $diagram->setPiecePlacement($builder->setTypedData($item->get('piece_placement'))->build())->toRenderable(); $elements[$delta] = array( '#attached' => array( 'library' => array('chessboard_images/drupal.chessboard_images'), ), '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('chessboard')), 'chessboard' => array( '#type' => 'chessboard_images_diagram', '#piece_placement' => $builder->setTypedData($item->get('piece_placement'))->build(), ), ); } return $elements; Loading Loading
chessboard_filter/src/ChessboardBulletinBoardCodeTagContentFilter.php +13 −3 Changes for chessboard_filter/src/ChessboardBulletinBoardCodeTagContentFilter.php: 13 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ namespace Drupal\chessboard_filter; use Drupal\chessboard\ChessboardFilterInterface as FilterInterface; use Drupal\chessboard_images\Diagram; use Drupal\chessboard_images\PiecePlacement; /** Loading Loading @@ -43,8 +42,19 @@ class ChessboardBulletinBoardCodeTagContentFilter implements FilterInterface{ */ public function filter($value) { $item = $this->parse($value); $diagram = new Diagram(); $element = $diagram->setPiecePlacement(new PiecePlacement($item['board_value'], $item['file_max']))->toRenderable(); $element = array( '#attached' => array( 'library' => array('chessboard_images/drupal.chessboard_images'), ), '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('chessboard')), 'chessboard' => array( '#type' => 'chessboard_images_diagram', '#piece_placement' => new PiecePlacement($item['board_value'], $item['file_max']), '#border' => $item['border'], '#square_color_first' => $item['square_color_first'], ), ); return $element; } Loading
chessboard_images/src/Diagram.phpdeleted 100644 → 0 +0 −52 Changes for chessboard_images/src/Diagram.php: 0 added lines, 52 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\chessboard_images\Diagram. */ namespace Drupal\chessboard_images; use Drupal\Core\Render\RenderableInterface; use Drupal\chessboard\PiecePlacementInterface; /** * @internal * * Defines a Chessboard Images Diagram. * */ class Diagram implements RenderableInterface { /** * The piece placement object. * * @var Drupal\chessboard\PiecePlacementInterface */ protected $piecePlacement; public function setPiecePlacement(PiecePlacementInterface $piece_placement) { $this->piecePlacement = $piece_placement; return $this; } /** * {@inheritdoc} */ public function toRenderable() { $elements = array( '#attached' => array( 'library' => array('chessboard_images/drupal.chessboard_images'), ), '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('chessboard')), 'chessboard' => array( '#type' => 'chessboard_images_diagram', '#piece_placement' => $this->piecePlacement, ), ); return $elements; } }
chessboard_images_formatter/src/Plugin/Field/FieldFormatter/ChessboardImagesFormatter.php +11 −3 Changes for chessboard_images_formatter/src/Plugin/Field/FieldFormatter/ChessboardImagesFormatter.php: 11 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ namespace Drupal\chessboard_images_formatter\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; use Drupal\chessboard_images_formatter\PiecePlacementBuilder; use Drupal\chessboard_images\Diagram; /** * Plugin implementation of the 'chessboard_images_formatter_diagram' formatter. Loading @@ -33,9 +32,18 @@ class ChessboardImagesFormatter extends FormatterBase { $builder = new PiecePlacementBuilder(); $builder->setFileMax(8); $diagram = new Diagram(); foreach ($items as $delta => $item) { $elements[$delta] = $diagram->setPiecePlacement($builder->setTypedData($item->get('piece_placement'))->build())->toRenderable(); $elements[$delta] = array( '#attached' => array( 'library' => array('chessboard_images/drupal.chessboard_images'), ), '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('chessboard')), 'chessboard' => array( '#type' => 'chessboard_images_diagram', '#piece_placement' => $builder->setTypedData($item->get('piece_placement'))->build(), ), ); } return $elements; Loading