Compare commits

...

1 Commits

  1. 3
      assets/js/app.js
  2. 2
      composer.json
  3. 251
      composer.lock
  4. 2
      config/bundles.php
  5. 2
      config/packages/pix_sortable_behavior.yaml
  6. 4
      config/packages/sonata_admin.yaml
  7. 8
      config/packages/stof_doctrine_extensions.yaml
  8. 12
      config/services.yaml
  9. 35
      src/Admin/ProjectAdmin.php
  10. 23
      src/Entity/Project.php
  11. 18
      symfony.lock

3
assets/js/app.js

@ -2,6 +2,9 @@ require('bootstrap/dist/js/bootstrap.bundle.min');
require('owl.carousel/dist/owl.carousel.min');
require('../js/vendor/jquery.particleground');
require('../../public/bundles/pixsortablebehavior/js/jquery-ui.min.js');
require('../../public/bundles/pixsortablebehavior/js/init.js');
$(function () {
/**
* @link https://github.com/jnicol/particleground

2
composer.json

@ -5,11 +5,13 @@
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"pixassociates/sortable-behavior-bundle": "^1.5",
"sonata-project/admin-bundle": "^3.38",
"sonata-project/core-bundle": "^3.11",
"sonata-project/doctrine-orm-admin-bundle": "^3.6",
"sonata-project/media-bundle": "^3.10",
"sonata-project/user-bundle": "^4.2",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/console": "^4.1",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.1",

251
composer.lock

@ -4,9 +4,53 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "050760222e99b03b656e432a69eaad71",
"content-hash": "259ec1871ab3c97d7b66eee06a3889d6",
"hash": "8a75b3993ae6ef856a6a4b1a66495468",
"content-hash": "631790dba16ab46454b6a4a16c8d875b",
"packages": [
{
"name": "behat/transliterator",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/Behat/Transliterator.git",
"reference": "826ce7e9c2a6664c0d1f381cbb38b1fb80a7ee2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Behat/Transliterator/zipball/826ce7e9c2a6664c0d1f381cbb38b1fb80a7ee2c",
"reference": "826ce7e9c2a6664c0d1f381cbb38b1fb80a7ee2c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"chuyskywalker/rolling-curl": "^3.1",
"php-yaoi/php-yaoi": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"psr-0": {
"Behat\\Transliterator": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Artistic-1.0"
],
"description": "String transliterator",
"keywords": [
"i18n",
"slug",
"transliterator"
],
"time": "2017-04-04 11:38:05"
},
{
"name": "cocur/slugify",
"version": "v3.1",
@ -1369,6 +1413,87 @@
],
"time": "2018-03-08 08:59:27"
},
{
"name": "gedmo/doctrine-extensions",
"version": "v2.4.36",
"source": {
"type": "git",
"url": "https://github.com/Atlantic18/DoctrineExtensions.git",
"reference": "87c78ff9fd4b90460386f753d95622f6fbbfcb27"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Atlantic18/DoctrineExtensions/zipball/87c78ff9fd4b90460386f753d95622f6fbbfcb27",
"reference": "87c78ff9fd4b90460386f753d95622f6fbbfcb27",
"shasum": ""
},
"require": {
"behat/transliterator": "~1.2",
"doctrine/common": "~2.4",
"php": ">=5.3.2"
},
"conflict": {
"doctrine/annotations": "<1.2"
},
"require-dev": {
"doctrine/common": ">=2.5.0",
"doctrine/mongodb-odm": ">=1.0.2",
"doctrine/orm": ">=2.5.0",
"phpunit/phpunit": "^4.8.35|^5.7|^6.5",
"symfony/yaml": "~2.6|~3.0|~4.0"
},
"suggest": {
"doctrine/mongodb-odm": "to use the extensions with the MongoDB ODM",
"doctrine/orm": "to use the extensions with the ORM"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
}
},
"autoload": {
"psr-4": {
"Gedmo\\": "lib/Gedmo"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "David Buchmann",
"email": "david@liip.ch"
},
{
"name": "Gediminas Morkevicius",
"email": "gediminas.morkevicius@gmail.com"
},
{
"name": "Gustavo Falco",
"email": "comfortablynumb84@gmail.com"
}
],
"description": "Doctrine2 behavioral extensions",
"homepage": "http://gediminasm.org/",
"keywords": [
"Blameable",
"behaviors",
"doctrine2",
"extensions",
"gedmo",
"loggable",
"nestedset",
"sluggable",
"sortable",
"timestampable",
"translatable",
"tree",
"uploadable"
],
"time": "2018-07-26 12:16:35"
},
{
"name": "guzzlehttp/psr7",
"version": "1.4.2",
@ -2365,6 +2490,63 @@
],
"time": "2015-07-25 16:39:46"
},
{
"name": "pixassociates/sortable-behavior-bundle",
"version": "v1.5",
"target-dir": "Pix/SortableBehaviorBundle",
"source": {
"type": "git",
"url": "https://github.com/pix-digital/pixSortableBehaviorBundle.git",
"reference": "bcb223f26b235647dc57bb5a56c64d331c9a4e5f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pix-digital/pixSortableBehaviorBundle/zipball/bcb223f26b235647dc57bb5a56c64d331c9a4e5f",
"reference": "bcb223f26b235647dc57bb5a56c64d331c9a4e5f",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/form": ">=2.1",
"symfony/framework-bundle": ">=2.1"
},
"require-dev": {
"gedmo/doctrine-extensions": ">=2.2"
},
"suggest": {
"sonata-project/admin-bundle": "Can be easily integrated with Sonata Admin bundle",
"stof/doctrine-extensions-bundle": "1.1.*@dev"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
}
},
"autoload": {
"psr-0": {
"Pix\\SortableBehaviorBundle": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Ricci",
"email": "nr@pix-digital.com"
}
],
"description": "Provides a way to sort your admin listing",
"homepage": "https://github.com/pix-digital/pixSortableBehaviorBundle",
"keywords": [
"admin",
"sonata",
"sortable"
],
"time": "2018-03-26 15:56:52"
},
{
"name": "psr/cache",
"version": "1.0.1",
@ -3485,6 +3667,71 @@
],
"time": "2018-07-08 19:32:37"
},
{
"name": "stof/doctrine-extensions-bundle",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/stof/StofDoctrineExtensionsBundle.git",
"reference": "46db71ec7ffee9122eca3cdddd4ef8d84bae269c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stof/StofDoctrineExtensionsBundle/zipball/46db71ec7ffee9122eca3cdddd4ef8d84bae269c",
"reference": "46db71ec7ffee9122eca3cdddd4ef8d84bae269c",
"shasum": ""
},
"require": {
"gedmo/doctrine-extensions": "^2.3.4",
"php": ">=5.3.2",
"symfony/framework-bundle": "~2.7|~3.2|~4.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.0",
"symfony/security-bundle": "^2.7 || ^3.2 || ^4.0"
},
"suggest": {
"doctrine/doctrine-bundle": "to use the ORM extensions",
"doctrine/mongodb-odm-bundle": "to use the MongoDB ODM extensions"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"psr-4": {
"Stof\\DoctrineExtensionsBundle\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"description": "Integration of the gedmo/doctrine-extensions with Symfony2",
"homepage": "https://github.com/stof/StofDoctrineExtensionsBundle",
"keywords": [
"behaviors",
"doctrine2",
"extensions",
"gedmo",
"loggable",
"nestedset",
"sluggable",
"sortable",
"timestampable",
"translatable",
"tree"
],
"time": "2017-12-24 16:06:50"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v6.1.2",

2
config/bundles.php

@ -23,4 +23,6 @@ return [
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
Sonata\MediaBundle\SonataMediaBundle::class => ['all' => true],
App\Application\Sonata\MediaBundle\ApplicationSonataMediaBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
Pix\SortableBehaviorBundle\PixSortableBehaviorBundle::class => ['all' => true],
];

2
config/packages/pix_sortable_behavior.yaml

@ -0,0 +1,2 @@
pix_sortable_behavior:
db_driver: orm # default value : mongodb

4
config/packages/sonata_admin.yaml

@ -33,6 +33,10 @@ sonata_admin:
layout: admin/layout.html.twig
options:
use_select2: true
# assets:
# javascripts:
# - bundles/pixsortablebehavior/js/jquery-ui.min.js
# - bundles/pixsortablebehavior/js/init.js
sonata_block:
blocks:

8
config/packages/stof_doctrine_extensions.yaml

@ -0,0 +1,8 @@
# Read the documentation: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html
# See the official DoctrineExtensions documentation for more details: https://github.com/Atlantic18/DoctrineExtensions/tree/master/doc/
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
sortable: true
translatable: true

12
config/services.yaml

@ -19,7 +19,7 @@ services:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
# makes classes in src/ available to be used as services
@ -37,6 +37,14 @@ services:
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
# Gedmo sortable listener
gedmo.listener.sortable:
class: Gedmo\Sortable\SortableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ "@annotation_reader" ] ]
###
# Sonata Admin Services
###
@ -44,6 +52,6 @@ services:
admin.project:
public: true
class: App\Admin\ProjectAdmin
arguments: [~, App\Entity\Project, ~]
arguments: [~, App\Entity\Project, 'PixSortableBehaviorBundle:SortableAdmin']
tags:
- { name: sonata.admin, manager_type: orm, label: Project }

35
src/Admin/ProjectAdmin.php

@ -3,11 +3,15 @@
namespace App\Admin;
use App\Entity\Project;
use Pix\SortableBehaviorBundle\Services\PositionHandler;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelListType;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
/**
* Class ProjectAdmin
@ -23,6 +27,12 @@ class ProjectAdmin extends AbstractAdmin
/** {@inheritdoc} */
protected $baseRoutePattern = 'project';
protected $datagridValues = array(
'_page' => 1,
'_sort_order' => 'ASC',
'_sort_by' => 'position',
);
/**
* {@inheritdoc}
*/
@ -44,6 +54,13 @@ class ProjectAdmin extends AbstractAdmin
'required' => true,
)
)
->add('position',
HiddenType::class,
array(
'attr' => array(
'hidden' => true,
),
))
->add(
'media',
ModelListType::class,
@ -86,11 +103,27 @@ class ProjectAdmin extends AbstractAdmin
array(
'actions' => array(
'edit' => array(),
)
'move' => array(
'template' => '@PixSortableBehavior/Default/_sort.html.twig'
),
// 'move' => array(
// 'template' => '@PixSortableBehavior/Default/_sort_drag_drop.html.twig',
// 'enable_top_bottom_buttons' => true,
// ),
),
)
);
}
/**
* {@inheritdoc}
*/
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('move', $this->getRouterIdParameter() . '/move/{position}');
parent::configureRoutes($collection);
}
/**
* @param Project $object
*

23
src/Entity/Project.php

@ -4,6 +4,7 @@ namespace App\Entity;
use App\Application\Sonata\MediaBundle\Entity\Media;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Sonata\MediaBundle\Model\MediaInterface;
/**
@ -44,6 +45,12 @@ class Project
*/
protected $media;
/**
* @Gedmo\SortablePosition
* @ORM\Column(name="position", type="integer")
*/
private $position;
/**
* @return int|null
@ -108,4 +115,20 @@ class Project
{
return $this->media;
}
/**
* @return mixed
*/
public function getPosition()
{
return $this->position;
}
/**
* @param mixed $position
*/
public function setPosition($position): void
{
$this->position = $position;
}
}

18
symfony.lock

@ -1,4 +1,7 @@
{
"behat/transliterator": {
"version": "v1.2.0"
},
"cocur/slugify": {
"version": "v3.1"
},
@ -74,6 +77,9 @@
"friendsofsymfony/user-bundle": {
"version": "v2.1.2"
},
"gedmo/doctrine-extensions": {
"version": "v2.4.36"
},
"guzzlehttp/psr7": {
"version": "1.4.2"
},
@ -131,6 +137,9 @@
"phpoption/phpoption": {
"version": "1.5.0"
},
"pixassociates/sortable-behavior-bundle": {
"version": "v1.5"
},
"psr/cache": {
"version": "1.0.1"
},
@ -197,6 +206,15 @@
"sonata-project/user-bundle": {
"version": "4.2.3"
},
"stof/doctrine-extensions-bundle": {
"version": "1.2",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "master",
"version": "1.2",
"ref": "6c1ceb662f8997085f739cd089bfbef67f245983"
}
},
"swiftmailer/swiftmailer": {
"version": "v6.1.2"
},

Loading…
Cancel
Save