예제 #1
0
 /**
  * Costructor
  *
  * @param string $sourceEntity valid source entity class
  * @param string $targetEntity valid target entity class
  * @param bool $mapped is this association mapped/inversed
  * @param string $name
  * @param string $joinTable join table name
  * @param string $joinTargetColumn valid join table target column name
  * @param string $joinSourceColumn valid join table source column name
  * @throws InvalidArgumentException
  */
 public function __construct($sourceEntity, $targetEntity, $mapped = TRUE, $name = NULL, $joinTable = NULL, $joinTargetColumn = NULL, $joinSourceColumn = NULL)
 {
     parent::__construct($sourceEntity, $targetEntity);
     $targetMetadata = Metadata::getMetadata($targetEntity);
     $sourceMetadata = Metadata::getMetadata($sourceEntity);
     $this->mapped = $mapped;
     if (empty($name)) {
         $this->name = lcfirst(Tools::pluralize($targetMetadata->name));
     } else {
         $this->name = $name;
     }
     if (empty($joinSourceColumn)) {
         $this->joinSourceColumn = Tools::underscore($sourceMetadata->name . ucfirst($this->sourceColumn));
     } else {
         $this->joinSourceColumn = $joinSourceColumn;
     }
     if (empty($joinTargetColumn)) {
         $this->joinTargetColumn = Tools::underscore($targetMetadata->name . ucfirst($this->targetColumn));
     } else {
         $this->joinTargetColumn = $joinTargetColumn;
     }
     if (!empty($joinTable)) {
         $this->joinTable = $joinTable;
     } elseif ($this->mapped) {
         $this->joinTable = Tools::underscore(Tools::pluralize($sourceMetadata->name) . ucfirst(Tools::pluralize($targetMetadata->name)));
     } else {
         $this->joinTable = Tools::underscore(Tools::pluralize($targetMetadata->name) . ucfirst(Tools::pluralize($sourceMetadata->name)));
     }
 }
예제 #2
0
 /**
  * Costructor
  *
  * @param string $sourceEntity valid source entity class
  * @param string $targetEntity valid target entity class
  * @param string $name
  * @param string $column targer/source column name
  * @throws InvalidArgumentException
  */
 public function __construct($sourceEntity, $targetEntity, $name = NULL, $column = NULL)
 {
     parent::__construct($sourceEntity, $targetEntity);
     $metadata = Metadata::getMetadata($targetEntity);
     if (empty($name)) {
         $this->name = lcfirst($metadata->name);
     } else {
         $this->name = $name;
     }
     if (empty($column)) {
         $this->column = Tools::underscore($metadata->name . ucfirst($metadata->primaryKey));
     } else {
         $this->column = $column;
     }
 }