Skip to content

Instantly share code, notes, and snippets.

View mysiar's full-sized avatar
🌐
Working remotely

Piotr Synowiec mysiar

🌐
Working remotely
View GitHub Profile
@mysiar
mysiar / amount_embeddable.php
Created September 12, 2020 15:07
Amount Embeddable
/**
* @ORM\Embeddable()
*/
class Amount
{
/**
* @ORM\Column(type="integer")
* @var int
*/
private $value;
...
- { property: 'area', type: 'number', label: label.area, type_options: { required: true, html5: false, input: 'number', scale: 1 } }
...
/**
* @ORM\Column(type="decimal", precision=7, scale=1)
* @var float
*/
private $area;
public function setArea(float $area)
{
$this->area = $area;
}
@mysiar
mysiar / paginator.html.twig
Last active November 19, 2020 07:36
Pagination for EasyAdmin
{# tested with 2.3.5 #}
{% trans_default_domain 'EasyAdminBundle' %}
{% set _paginator_request_parameters = _request_parameters|merge({'referer': null}) %}
{% if paginator.haveToPaginate %}
<div class="list-pagination">
<div class="list-pagination-counter">
{{ 'paginator.counter'|trans({ '%start%': paginator.currentPageOffsetStart, '%end%': paginator.currentPageOffsetEnd, '%results%': paginator.nbResults})|raw }} {{ 'easy_admin.results'|trans }}
</div>
<div style="border: 1px solid black; height: 20px; width: 60px; background-color: {{ value }}"></div>
<?php
declare(strict_types=1);
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ColorPickerType extends AbstractType
{% extends '@!EasyAdmin/default/edit.html.twig' %}
{% block main %}
{{ parent() }}
{% endblock %}
{% block body_javascript %}
{{ parent() }}
<script src="{{ asset('js/jqColorPicker.min.js') }}" type="text/javascript"></script>
@mysiar
mysiar / RamseyUuid.md
Created March 18, 2020 12:32
RamseyUuid
/**
     * @ORM\Column(type="uuid")
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
     * @ORM\Id()
     *
     * @var \Ramsey\Uuid\Uuid
     */
 protected $id;
@mysiar
mysiar / DoctrineFixtures.md
Last active October 8, 2019 08:36
Doctrine Fixtures

Doctrine fixtures in different place than src/DataFixtures

  1. fixtures directory tree (example)

    tests/Fixtures/Data
    tests/Fixtures/Test
    
  2. all fixtures implements FixtureGroupInterface, Data fixtures return data, Test fixtures return test

  3. loading fixtures

@mysiar
mysiar / CsvIterator.php
Created April 2, 2019 09:34
CsvIterator
<?php
declare(strict_types=1);
namespace mysiar;
use Exception;
use Iterator;
class CsvIterator implements Iterator
{