partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit bceb72532bacbb628e1ef925545081b7cbacfb32
parent 4838dab7e6e3c5d94b1eab9bc787845bdfdc2d05
Author: Felicitus <felicitus@felicitus.org>
Date:   Fri, 19 Jun 2015 16:46:19 +0200

Reverted JMSSerializer, removed DoctrineExtensions tree

Diffstat:
Mapp/AppKernel.php | 2++
Mapp/config/config.yml | 9+++++++++
Msrc/PartKeepr/AuthBundle/Controller/DefaultController.php | 2+-
Msrc/PartKeepr/DoctrineReflectionBundle/Resources/views/model.js.twig | 3++-
Msrc/PartKeepr/DoctrineReflectionBundle/Services/ReflectionService.php | 5+++++
Msrc/PartKeepr/FootprintBundle/Entity/Footprint.php | 2--
Msrc/PartKeepr/FootprintBundle/Entity/FootprintCategory.php | 1-
Dsrc/PartKeepr/FootprintBundle/Entity/Repository/FootprintCategoryRepository.php | 9---------
Msrc/PartKeepr/PartBundle/Entity/PartCategory.php | 2--
Dsrc/PartKeepr/PartBundle/Entity/Repository/PartCategoryRepository.php | 10----------
Msrc/PartKeepr/UnitBundle/Entity/Unit.php | 2+-
Msrc/backend/PartKeepr/Category/AbstractCategory.php | 29+++++++++++------------------
12 files changed, 31 insertions(+), 45 deletions(-)

diff --git a/app/AppKernel.php b/app/AppKernel.php @@ -60,6 +60,7 @@ class AppKernel extends Kernel new PartKeepr\RESTBundle\PartKeeprRESTBundle(), new PartKeepr\ApiDocBundle\PartKeeprApiDocBundle(), new PartKeepr\UnitBundle\PartKeeprUnitBundle(), + new PartKeepr\PartBundle\PartKeeprPartBundle(), new Dunglas\ApiBundle\DunglasApiBundle(), ); @@ -75,6 +76,7 @@ class AppKernel extends Kernel $bundles[] = new PartKeepr\FrontendBundle\PartKeeprFrontendBundle(); $bundles[] = new PartKeepr\SiPrefixBundle\PartKeeprSiPrefixBundle(); $bundles[] = new PartKeepr\AuthBundle\PartKeeprAuthBundle(); + $bundles[] = new PartKeepr\FootprintBundle\PartKeeprFootprintBundle(); return $bundles; } diff --git a/app/config/config.yml b/app/config/config.yml @@ -25,6 +25,7 @@ sensio_framework_extra: framework: #esi: ~ #translator: { fallback: %locale% } + serializer: { enable_annotations: true } secret: %secret% router: resource: "%kernel.root_dir%/config/routing.yml" @@ -85,6 +86,10 @@ twig: dunglas_api: title: "Your API name" # The title of the API. description: "The full description of your API" # The description of the API. + collection: + pagination: + items_per_page: + enable_client_request: true nelmio_api_doc: sandbox: @@ -106,3 +111,6 @@ services: parent: "api.resource" arguments: [ "PartKeepr\SiPrefixBundle\Entity\SiPrefix" ] tags: [ { name: "api.resource" } ] + + api.name_converter: + class: Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter+ \ No newline at end of file diff --git a/src/PartKeepr/AuthBundle/Controller/DefaultController.php b/src/PartKeepr/AuthBundle/Controller/DefaultController.php @@ -56,7 +56,7 @@ class DefaultController extends FOSRestController $loginResponse->sessionId = $session->getSessionID(); $loginResponse->username = $paramFetcher->get("username"); $loginResponse->isAdmin = $session->getUser()->isAdmin(); - $loginResponse->userPreferences = $session->getUser()->getPreferences(); + //$loginResponse->userPreferences = $session->getUser()->getPreferences(); return $loginResponse; } diff --git a/src/PartKeepr/DoctrineReflectionBundle/Resources/views/model.js.twig b/src/PartKeepr/DoctrineReflectionBundle/Resources/views/model.js.twig @@ -2,9 +2,10 @@ Ext.define('{{ className }}', { extend: 'Ext.data.Model', alias: 'schema.{{ className }}', + idProperty: "@id", fields: [ {% for field in fields %} - { name: '{{ field.name }}'{% if field.type%}, type: '{{ field.type }}'{% endif %}}{% if not loop.last %},{% endif %} + { name: '{{ field.name|raw }}'{% if field.type%}, type: '{{ field.type }}'{% endif %}}{% if not loop.last %},{% endif %} {% endfor %} ], diff --git a/src/PartKeepr/DoctrineReflectionBundle/Services/ReflectionService.php b/src/PartKeepr/DoctrineReflectionBundle/Services/ReflectionService.php @@ -54,6 +54,11 @@ class ReflectionService { foreach ($fields as $field) { $currentMapping = $cm->getFieldMapping($field); + if ($currentMapping["fieldName"] == "id") { + $currentMapping["fieldName"] = "@id"; + $currentMapping["type"] = "string"; + } + $fieldMappings[] = array( "name" => $currentMapping["fieldName"], "type" => $this->getExtJSFieldMapping($currentMapping["type"]), diff --git a/src/PartKeepr/FootprintBundle/Entity/Footprint.php b/src/PartKeepr/FootprintBundle/Entity/Footprint.php @@ -1,6 +1,5 @@ <?php namespace PartKeepr\FootprintBundle\Entity; -use JMS\Serializer\Annotation\ExclusionPolicy; use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; use PartKeepr\Util\Deserializable; @@ -12,7 +11,6 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @TargetService(uri="/footprint") - * @ExclusionPolicy("none") */ class Footprint extends BaseEntity implements Serializable, Deserializable { diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintCategory.php b/src/PartKeepr/FootprintBundle/Entity/FootprintCategory.php @@ -18,7 +18,6 @@ class FootprintCategory extends AbstractCategory { * @ORM\ManyToOne(targetEntity="FootprintCategory", inversedBy="children") * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE") * - * @Gedmo\TreeParent * @var int */ private $parent; diff --git a/src/PartKeepr/FootprintBundle/Entity/Repository/FootprintCategoryRepository.php b/src/PartKeepr/FootprintBundle/Entity/Repository/FootprintCategoryRepository.php @@ -1,8 +0,0 @@ -<?php -namespace PartKeepr\FootprintBundle\Entity\Repository; - -use Gedmo\Tree\Entity\Repository\NestedTreeRepository; - -class FootprintCategoryRepository extends NestedTreeRepository -{ -}- \ No newline at end of file diff --git a/src/PartKeepr/PartBundle/Entity/PartCategory.php b/src/PartKeepr/PartBundle/Entity/PartCategory.php @@ -3,7 +3,6 @@ namespace PartKeepr\PartBundle\Entity; use PartKeepr\Category\AbstractCategory, Doctrine\ORM\Mapping as ORM; -use Gedmo\Mapping\Annotation as Gedmo; /** * @ORM\Entity(repositoryClass="PartKeepr\PartBundle\Entity\Repository\PartCategoryRepository") @@ -16,7 +15,6 @@ class PartCategory extends AbstractCategory { * @ORM\ManyToOne(targetEntity="PartCategory", inversedBy="children") * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE") * - * @Gedmo\TreeParent * @var int */ private $parent; diff --git a/src/PartKeepr/PartBundle/Entity/Repository/PartCategoryRepository.php b/src/PartKeepr/PartBundle/Entity/Repository/PartCategoryRepository.php @@ -1,9 +0,0 @@ -<?php -namespace PartKeepr\PartBundle\Entity\Repository; - -use Gedmo\Tree\Entity\Repository\NestedTreeRepository; - -class PartCategoryRepository extends NestedTreeRepository -{ - -}- \ No newline at end of file diff --git a/src/PartKeepr/UnitBundle/Entity/Unit.php b/src/PartKeepr/UnitBundle/Entity/Unit.php @@ -11,7 +11,7 @@ use PartKeepr\Util\BaseEntity, * This object represents an unit. Units can be: Volt, Hertz etc. * * @ORM\Entity - * @TargetService(uri="/unit") + * @TargetService(uri="/api/units") **/ class Unit { /** diff --git a/src/backend/PartKeepr/Category/AbstractCategory.php b/src/backend/PartKeepr/Category/AbstractCategory.php @@ -1,14 +1,13 @@ <?php namespace PartKeepr\Category; +use Doctrine\ORM\Mapping as ORM; use PartKeepr\Util\BaseEntity; use PartKeepr\Util\Serializable; -use Gedmo\Mapping\Annotation as Gedmo; -use Doctrine\ORM\Mapping as ORM; +use DoctrineExtensions\NestedSet\Node; /** - * @Gedmo\Tree(type="nested") - * @ORM\MappedSuperclass + * @ORM\MappedSuperclass() * @ORM\Table(indexes={@ORM\Index(columns={"lft"}),@ORM\Index(columns={"rgt"})}) * * Represents an abstract category. This class isn't directly usable; you need to inherit it to take advantage of @@ -16,11 +15,10 @@ use Doctrine\ORM\Mapping as ORM; * * If you are interested on how NestedSets work, please read http://en.wikipedia.org/wiki/Nested_set_model */ -class AbstractCategory extends BaseEntity { +class AbstractCategory extends BaseEntity implements Node, Serializable { /** * The "left" property of the nested set * @ORM\Column(type="integer") - * @Gedmo\TreeLeft * @var integer */ private $lft; @@ -28,7 +26,6 @@ class AbstractCategory extends BaseEntity { /** * The "right" property of the nested set * @ORM\Column(type="integer") - * @Gedmo\TreeRight * @var integer */ private $rgt; @@ -47,17 +44,13 @@ class AbstractCategory extends BaseEntity { */ private $description; - /** - * @Gedmo\TreeRoot - * @ORM\Column(type="integer", nullable=true) - */ - private $root; - - /** - * @Gedmo\TreeLevel - * @ORM\Column(name="lvl", type="integer") - */ - private $level; + /** + * Holds the parent node ID. Note that this + * is not a persistant value, but rather calculated + * or set on the fly. + * @var int + */ + private $parent; /** * Holds the category path.