204 lines
3.2 KiB
PHP
204 lines
3.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Sylius package.
|
|
*
|
|
* (c) Paweł Jędrzejewski
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Sylius\Component\Attribute\Model;
|
|
|
|
use Sylius\Component\Translation\Model\AbstractTranslatable;
|
|
|
|
/**
|
|
* Model for object attributes.
|
|
*
|
|
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
|
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
|
|
*/
|
|
class Attribute extends AbstractTranslatable implements AttributeInterface
|
|
{
|
|
/**
|
|
* Attribute id.
|
|
*
|
|
* @var mixed
|
|
*/
|
|
protected $id;
|
|
|
|
/**
|
|
* Type.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $type = AttributeTypes::TEXT;
|
|
|
|
/**
|
|
* Internal name.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $name;
|
|
|
|
/**
|
|
* Attribute configuration.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $configuration = array();
|
|
|
|
/**
|
|
* Creation time.
|
|
*
|
|
* @var \DateTime
|
|
*/
|
|
protected $createdAt;
|
|
|
|
/**
|
|
* Last update time.
|
|
*
|
|
* @var \DateTime
|
|
*/
|
|
protected $updatedAt;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->createdAt = new \DateTime();
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function __toString()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getPresentation()
|
|
{
|
|
return $this->translate()->getPresentation();
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setPresentation($presentation)
|
|
{
|
|
$this->translate()->setPresentation($presentation);
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getType()
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setType($type)
|
|
{
|
|
$this->type = $type;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getConfiguration()
|
|
{
|
|
return $this->configuration;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setConfiguration(array $configuration)
|
|
{
|
|
$this->configuration = $configuration;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getCreatedAt()
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setCreatedAt(\DateTime $createdAt)
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getUpdatedAt()
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function setUpdatedAt(\DateTime $updatedAt)
|
|
{
|
|
$this->updatedAt = $updatedAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function getTranslationEntityClass()
|
|
{
|
|
return get_class().'Translation';
|
|
}
|
|
}
|