Zum Inhalt

Standard-Feldtypen

Folgende Typen werden automatisch aus den dargestellten Annotations gemappt und im Contentfly CMS UI entsprechend dargestellt. Im Backend sind die im Standard mitgelieferten Eigenschaften-Typen unter appcms/areanet/PIM/Classes/Types definiert, die korrespondierende AngularJS-Directive im Contentfly CMS UI unter appcms/areanet/PIM-UI/default/assets/types

Boolean

1
2
3
4
5
<?php
/**
 * @ORM\Column(type="boolean")
 */
protected $booleanProperty;

Checkbox

Pflegbare Checkboxen. Die Checkboxen/Werte können unter Administration->Optionen verwaltet werden. Dazu wird automatisch eine Gruppe angelegt. Ist das Attribut group in der Checkbox-Annotation nicht gesetzt, wird als Gruppe "Entität/Property" gesetzt, ansonsten der entsprechende Name aus dem group-Attribut. columns (optional) gibt die Anzahl der Spalten an, horizontalAlignment die Anordnung der Checkboxen.

1
2
3
4
5
6
7
8
<?php
/**
  * @ORM\ManyToMany(targetEntity="Areanet\PIM\Entity\Option")
  * @ORM\JoinTable(name="checkbox_properties", joinColumns={@ORM\JoinColumn(onDelete="CASCADE", nullable=true)})
  * @PIM\Checkbox(horizontalAlignment=false/true, group="Gruppenname", columns=4)
  * @PIM\Config(label="Pflegbare Checkboxen")
*/
protected $checkboxProperty;

Hinweis

Pflegbare Checkboxen funktionieren in der aktuellen Version nur mit einer ManyToMany-Verbindung zur Entität Areanet\PIM\Entity\Option.

Dateiupload 1:n (einfach)

1
2
3
4
5
6
<?php
/**
 * @ORM\ManyToOne(targetEntity="Areanet\PIM\Entity\File")
 * @ORM\JoinColumn(onDelete="SET NULL")
 */
protected $images;

Dateiupload n:m (mehrfach)

1
2
3
4
5
6
<?php
/**
 * @ORM\ManyToMany(targetEntity="Areanet\PIM\Entity\File")
 * @ORM\JoinTable(name="join_table_name", joinColumns={@ORM\JoinColumn(onDelete="CASCADE")})
 */
protected $images;

Dateiupload n:m (mehrfach sortierbar)

1
2
3
4
5
6
<?php
/**
 * @ORM\OneToMany(targetEntity="Custom\Entity\ProductImages", mappedBy="product")
 * @PIM\ManyToMany(targetEntity="Areanet\PIM\Entity\File", mappedBy="image")
 */
protected $images;

Für sortierbare, verknüpfte Entitäten muss eine "Zwischen-Entität" (vgl. n-m-Join bei einer Datenbank angelegt werden) vom Typ BaseSortable angelegt werden. Die Doctrine Annotatin @ORM\OneToMany ist die eigentlich relevante Konfiguration für die Datenbank. Die Annotation @PIM\ManyToMany dient dem Contentfly CMS UI dazu, um die Oberfläche korrekt darstellen zu können.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
/**
 * @ORM\Entity
 * @ORM\Table(name="product_images")
 * @PIM\Config(hide=true)
 */
class ProductImages extends Areanet\PIM\Entity\BaseSortable
{

    /**
     * @ORM\ManyToOne(targetEntity="Custom\Entity\Product", inversedBy="images")
     * @ORM\JoinColumn(onDelete="CASCADE")
     */
    protected $product;

    /**
     * @ORM\ManyToOne(targetEntity="Areanet\PIM\Entity\File")
     * @ORM\JoinColumn(onDelete="CASCADE")
     * @PIM\Config(label="Detailbilder", accept="image/*")
     */
    protected $image;

    ...;
}    

Datum

Standardformat Tag.Monat.Jahr

1
2
3
4
5
<?php
/**
 * @ORM\Column(type="datetime")
*/
protected $datetimeProperty;

Benutzerdefiniertes Format, siehe http://php.net/manual/de/function.date.php

1
2
3
4
5
6
<?php
/**
 * @ORM\Column(type="datetime")
 * @PIM\Datetime(format='MM-DD-YYYY')
*/
protected $datetimeProperty;

Dezimalzahl

1
2
3
4
5
<?php
/**
 * @ORM\Column(type="decimal", precision=10, scale=2)
*/
protected $decimalProperty;

Entity-Auswahlliste

Listet alle konfiguierten Entitäten in einer Select-Auswahlliste auf:

1
2
3
4
5
6
<?php
/**
 * @ORM\Column(type="string")
 * @PIM\EntitySelector()
*/
protected $entitySelectorProperty;

Ganzzahl

1
2
3
4
5
<?php
/**
 * @ORM\Column(type="integer")
 */
protected $integerProperty;

Join 1:1

1
2
3
4
5
6
<?php
/**
 * @ORM\OneToOne(targetEntity="Custom\Entity\TARGET_ENTITY")
 * @ORM\JoinColumn(onDelete="SET NULL")
*/
protected $targetObject;

Join 1:n

Custom\Entity\SOURCE_ENTITY

1
2
3
4
5
6
<?php
/**
 * @ORM\ManyToOne(targetEntity="Custom\Entity\TARGET_ENTITY")
 * @ORM\JoinColumn(onDelete="SET NULL")
*/
protected $targetObject;

Bidirektional in Custom\Entity\TARGET_ENTITY

Bei einer bidirektionalen Verbindung wird in der Datenbank-Tabelle der TARGET_ENTITY kein Feld angelegt, die Verbindung ist lediglich "virtuell" in Doctrine vorhanden.

1
2
3
4
5
<?php
/**
 * @ORM\OneToMany(targetEntity="Custom\Entity\SOURCE_ENTITY", mappedBy="targetObject")
 */
protected $sourceObjects;

Join n:m

Custom\Entity\SOURCE_ENTITY

1
2
3
4
5
6
<?php
/**
 * @ORM\ManyToMany(targetEntity="Custom\Entity\TARGET_ENTITY")
 * @ORM\JoinTable(name="join_table_name", joinColumns={@ORM\JoinColumn(onDelete="CASCADE")})
*/
protected $targetObjects;

Bidirektional in Custom\Entity\TARGET_ENTITY

1
2
3
4
5
<?php
/**
 * @ORM\ManyToMany(targetEntity="Custom\Entity\SOURCE_ENTITY", mappedBy="targetObjects")
*/
protected $sourceObjects;

Join n:m (Selbstreferenzierend)

1
2
3
4
5
6
<?php
/**
 * @ORM\ManyToMany(targetEntity="Custom\Entity\TARGET_ENTITY")
 * @ORM\JoinTable(name="join_table_name", joinColumns={@ORM\JoinColumn(onDelete="CASCADE")}, inverseJoinColumns={@ORM\JoinColumn(onDelete="CASCADE", name="REFERENZ_ID", referencedColumnName="id")})
*/
protected $sourceObjects;

Beispiel

Es sollen zu Produkten jeweilige Alternativprodukte zugewiesen werden können. Beide Objekte sind jeweils eine Entität von Custom\Entity\Product, die intern in der Datenbank in der Tabelle product abgelegt sind. Bei einem n:m-Join würde Doctrine im Standard eine Tabelle product_alt mit den beiden Feldern product_id (Original-Produkt) und noch einmal produkt_id (Alternaiv-Produkt) anlegen, was zwangsläufig zu einem Datenbankfehler führt.

In diesem Fall muss also in der Doctrine Annotation @ORM\JoinTable der Datenbank-Feldname des Alternativ-Produktes name="REFERENZ_ID" entsprechend angepasst werden.

<?php @ORM\JoinTable(name="join_table_name", joinColumns={@ORM\JoinColumn(onDelete="CASCADE")}, inverseJoinColumns={@ORM\JoinColumn(onDelete="CASCADE", name="alternativprodukt_id", referencedColumnName="id")})

Join n:m (sortierbar)

1
2
3
4
5
6
<?php
/**
 * @ORM\OneToMany(targetEntity="Custom\Entity\ProductNotes", mappedBy="product")
 * @PIM\ManyToMany(targetEntity="Custom\Entity\Note", mappedBy="note")
*/
protected $notes;

Für sortierbare, verknüpfte Entitäten muss eine "Zwischen-Entität" (vgl. n-m-Join bei einer Datenbank angelegt werden) vom Typ BaseSortable angelegt werden. Die Doctrine Annotatin @ORM\OneToMany ist die eigentlich relevante Konfiguration für die Datenbank. Die Annotation @PIM\ManyToMany dient dem Contentfly CMS UI dazu, um die Oberfläche korrekt darstellen zu können.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
/**
 * @ORM\Entity
 * @ORM\Table(name="product_notes")
 * @PIM\Config(hide=true)
 */
class ProductNotes extends Areanet\PIM\Entity\BaseSortable
{

    /**
     * @ORM\ManyToOne(targetEntity="Custom\Entity\Product", inversedBy="notes")
     * @ORM\JoinColumn(onDelete="CASCADE")
     */
    protected $product;

    /**
     * @ORM\ManyToOne(targetEntity="Custom\Entity\Note")
     * @ORM\JoinColumn(onDelete="CASCADE")
     * @PIM\Config(label="Detailbilder")
     */
    protected $note;

    ...;
}    

Radio

Pflegbare Radio-Buttons. Die Buttons/Werte können unter Administration->Optionen verwaltet werden. Dazu wird automatisch eine Gruppe angelegt. Ist das Attribut group in der Radio-Annotation nicht gesetzt, wird als Gruppe "Entität/Property" gesetzt, ansonsten der entsprechende Name aus dem group-Attribut. columns (optional) gibt die Anzahl der Spalten an, horizontalAlignment die Anordnung der Radio-Buttons.

1
2
3
4
5
6
7
8
<?php
/**
  * @ORM\ManyToMany(targetEntity="Areanet\PIM\Entity\Option")
  * @ORM\JoinTable(name="radio_properties", joinColumns={@ORM\JoinColumn(onDelete="CASCADE", nullable=true)})
  * @PIM\Radio(horizontalAlignment=false/true, group="Gruppenname", columns=4)
  * @PIM\Config(label="Pflegbare Radiobuttons")
*/
protected $radioProperty;

Hinweis

Pflegbare Radio-Buttons funktionieren in der aktuellen Version nur mit einer ManyToMany-Verbindung zur Entität Areanet\PIM\Entity\Option.

Textfeld einzeilig

1
2
3
4
5
<?php
/**
 * @ORM\Column(type="string")
*/
protected $stringProperty;

Textfeld mehrzeilig

1
2
3
4
5
6
<?php
/**
 * @ORM\Column(type="text")
 * @PIM\Textarea(lines=10)
*/
protected $textProperty;

Hinweis

Die Annoation @PIM\Textarea ist optional, die Erkennung eines mehrzeiligen Textfeldes erfolgt bereits durch type="text"

Textfeld mit RTE

1
2
3
4
5
6
<?php
/**
 * @ORM\Column(type="text")
 * @PIM\Rte()
*/
protected $rteProperty;

Anpassung der Toolbar

1
2
3
4
5
6
<?php
/**
 * @ORM\Column(type="text")
 * @PIM\Rte(toolbar="formatselect | bold italic strikethrough subscript superscript | ...")
*/
protected $rteProperty;

Hinweis

Der Editor basiert auf TinyMCE. Mögliche Toolbar-Buttons unter tiny.cloud/docs/advanced/editor-control-identifiers

Select-Feld

1
2
3
4
5
6
<?php
/**
 * @ORM\Column(type="string")
 * @PIM\Select(options="VALUE=LABEL, VALUE=LABEL, VALUE=LABEL")
*/
protected $selectProperty;

Uhrzeit

Standardformat Stunden:Minute

1
2
3
4
5
<?php
/**
 * @ORM\Column(type="time")
*/
protected $timeProperty;

Benutzerdefiniertes Format, siehe http://php.net/manual/de/function.date.php

1
2
3
4
5
6
<?php
/**
 * @ORM\Column(type="time")
 * @PIM\Time(format='H:i:s')
*/
protected $timeProperty;

  1. http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html