1<?php 2/** 3 * Copyright since 2007 PrestaShop SA and Contributors 4 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA 5 * 6 * NOTICE OF LICENSE 7 * 8 * This source file is subject to the Open Software License (OSL 3.0) 9 * that is bundled with this package in the file LICENSE.md. 10 * It is also available through the world-wide-web at this URL: 11 * https://opensource.org/licenses/OSL-3.0 12 * If you did not receive a copy of the license and are unable to 13 * obtain it through the world-wide-web, please send an email 14 * to license@prestashop.com so we can send you a copy immediately. 15 * 16 * DISCLAIMER 17 * 18 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 19 * versions in the future. If you wish to customize PrestaShop for your 20 * needs please refer to https://devdocs.prestashop.com/ for more information. 21 * 22 * @author PrestaShop SA and Contributors <contact@prestashop.com> 23 * @copyright Since 2007 PrestaShop SA and Contributors 24 * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) 25 */ 26 27namespace PrestaShopBundle\Entity; 28 29use Doctrine\Common\Collections\ArrayCollection; 30use Doctrine\ORM\Mapping as ORM; 31 32/** 33 * Attribute. 34 * 35 * @ORM\Table( 36 * indexes={@ORM\Index(name="attribute_group", columns={"id_attribute_group"})} 37 * ) 38 * @ORM\Entity(repositoryClass="PrestaShopBundle\Entity\Repository\AttributeRepository") 39 */ 40class Attribute 41{ 42 /** 43 * @var int 44 * 45 * @ORM\Id 46 * @ORM\Column(name="id_attribute", type="integer") 47 * @ORM\GeneratedValue(strategy="AUTO") 48 */ 49 private $id; 50 51 /** 52 * @ORM\ManyToOne(targetEntity="PrestaShopBundle\Entity\AttributeGroup") 53 * @ORM\JoinColumn(name="id_attribute_group", referencedColumnName="id_attribute_group", nullable=false) 54 */ 55 private $attributeGroup; 56 57 /** 58 * @var string 59 * 60 * @ORM\Column(name="color", type="string", length=32) 61 */ 62 private $color; 63 64 /** 65 * @var int 66 * 67 * @ORM\Column(name="position", type="integer") 68 */ 69 private $position; 70 71 /** 72 * @ORM\ManyToMany(targetEntity="PrestaShopBundle\Entity\Shop", cascade={"persist"}) 73 * @ORM\JoinTable( 74 * joinColumns={@ORM\JoinColumn(name="id_attribute", referencedColumnName="id_attribute")}, 75 * inverseJoinColumns={@ORM\JoinColumn(name="id_shop", referencedColumnName="id_shop", onDelete="CASCADE")} 76 * ) 77 */ 78 private $shops; 79 80 /** 81 * @ORM\OneToMany(targetEntity="PrestaShopBundle\Entity\AttributeLang", mappedBy="attribute") 82 */ 83 private $attributeLangs; 84 85 /** 86 * Constructor. 87 */ 88 public function __construct() 89 { 90 $this->shops = new ArrayCollection(); 91 $this->attributeLangs = new ArrayCollection(); 92 } 93 94 /** 95 * Get id. 96 * 97 * @return int 98 */ 99 public function getId() 100 { 101 return $this->id; 102 } 103 104 /** 105 * Set color. 106 * 107 * @param string $color 108 * 109 * @return Attribute 110 */ 111 public function setColor($color) 112 { 113 $this->color = $color; 114 115 return $this; 116 } 117 118 /** 119 * Get color. 120 * 121 * @return string 122 */ 123 public function getColor() 124 { 125 return $this->color; 126 } 127 128 /** 129 * Set position. 130 * 131 * @param int $position 132 * 133 * @return Attribute 134 */ 135 public function setPosition($position) 136 { 137 $this->position = $position; 138 139 return $this; 140 } 141 142 /** 143 * Get position. 144 * 145 * @return int 146 */ 147 public function getPosition() 148 { 149 return $this->position; 150 } 151 152 /** 153 * Set attributeGroup. 154 * 155 * @param \PrestaShopBundle\Entity\AttributeGroup $attributeGroup 156 * 157 * @return Attribute 158 */ 159 public function setAttributeGroup(AttributeGroup $attributeGroup) 160 { 161 $this->attributeGroup = $attributeGroup; 162 163 return $this; 164 } 165 166 /** 167 * Get attributeGroup. 168 * 169 * @return \PrestaShopBundle\Entity\AttributeGroup 170 */ 171 public function getAttributeGroup() 172 { 173 return $this->attributeGroup; 174 } 175 176 /** 177 * Add shop. 178 * 179 * @param \PrestaShopBundle\Entity\Shop $shop 180 * 181 * @return Attribute 182 */ 183 public function addShop(Shop $shop) 184 { 185 $this->shops[] = $shop; 186 187 return $this; 188 } 189 190 /** 191 * Remove shop. 192 * 193 * @param \PrestaShopBundle\Entity\Shop $shop 194 */ 195 public function removeShop(Shop $shop) 196 { 197 $this->shops->removeElement($shop); 198 } 199 200 /** 201 * Get shops. 202 * 203 * @return \Doctrine\Common\Collections\Collection 204 */ 205 public function getShops() 206 { 207 return $this->shops; 208 } 209 210 public function addAttributeLang(AttributeLang $attributeLang) 211 { 212 $this->attributeLangs[] = $attributeLang; 213 214 $attributeLang->setAttribute($this); 215 216 return $this; 217 } 218 219 public function removeAttributeLang(AttributeLang $attributeLang) 220 { 221 $this->attributeLangs->removeElement($attributeLang); 222 } 223 224 public function getAttributeLangs() 225 { 226 return $this->attributeLangs; 227 } 228} 229