Skip to content

Instantly share code, notes, and snippets.

@adampiotrowski
Created May 30, 2016 08:10
Show Gist options
  • Select an option

  • Save adampiotrowski/19ee71d1777e665c00b983866e6397be to your computer and use it in GitHub Desktop.

Select an option

Save adampiotrowski/19ee71d1777e665c00b983866e6397be to your computer and use it in GitHub Desktop.
<?php
/*
* WellCommerce Open-Source E-Commerce Platform
*
* This file is part of the WellCommerce package.
*
* (c) Adam Piotrowski <adam@wellcommerce.org>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code.
*/
namespace Rewolucja\Bundle\AppBundle\Enhancer;
use Rewolucja\Bundle\AppBundle\Entity\CoverType;
use WellCommerce\Bundle\DoctrineBundle\Definition\FieldDefinition;
use WellCommerce\Bundle\DoctrineBundle\Definition\ManyToOneDefinition;
use WellCommerce\Bundle\DoctrineBundle\Definition\MappingDefinitionCollection;
use WellCommerce\Bundle\DoctrineBundle\Enhancer\AbstractMappingEnhancer;
use WellCommerce\Bundle\ProductBundle\Entity\Extra\ProductExtraTrait;
use WellCommerce\Bundle\ProductBundle\Entity\Product;
/**
* Class ProductMappingEnhancer
*
* @author Adam Piotrowski <adam@wellcommerce.org>
*/
final class ProductMappingEnhancer extends AbstractMappingEnhancer
{
protected function configureMappingDefinition(MappingDefinitionCollection $collection)
{
$collection->add(new FieldDefinition([
'fieldName' => 'publisher',
'type' => 'string',
'length' => 64,
'unique' => false,
'nullable' => true,
'columnName' => 'publisher',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'author',
'type' => 'string',
'length' => 255,
'unique' => false,
'nullable' => true,
'columnName' => 'author',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'publicationYear',
'type' => 'string',
'length' => 12,
'unique' => false,
'nullable' => true,
'columnName' => 'publication_year',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'premiereDate',
'type' => 'string',
'length' => 18,
'unique' => false,
'nullable' => true,
'columnName' => 'premiere_date',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'seriesName',
'type' => 'string',
'length' => 64,
'unique' => false,
'nullable' => true,
'columnName' => 'series_name',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'schoolSubject',
'type' => 'string',
'length' => 64,
'unique' => false,
'nullable' => true,
'columnName' => 'school_subject',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'schoolClass',
'type' => 'string',
'length' => 12,
'unique' => false,
'nullable' => true,
'columnName' => 'school_class',
]));
$collection->add(new ManyToOneDefinition([
'fieldName' => 'coverType',
'joinColumns' => [
[
'name' => 'cover_type_id',
'referencedColumnName' => 'id',
'onDelete' => 'SET NULL'
]
],
'targetEntity' => CoverType::class
]));
$collection->add(new FieldDefinition([
'fieldName' => 'format',
'type' => 'string',
'length' => 64,
'unique' => false,
'nullable' => true,
'columnName' => 'format',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'pagesCount',
'type' => 'string',
'length' => 12,
'unique' => false,
'nullable' => true,
'columnName' => 'pages_count',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'ageGroup',
'type' => 'string',
'length' => 32,
'unique' => false,
'nullable' => true,
'columnName' => 'age_group',
]));
$collection->add(new FieldDefinition([
'fieldName' => 'isbn',
'type' => 'string',
'length' => 32,
'unique' => false,
'nullable' => true,
'columnName' => 'isbn',
]));
}
public function getSupportedEntityClass() : string
{
return Product::class;
}
public function getSupportedEntityExtraTraitClass() : string
{
return ProductExtraTrait::class;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment