mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-22 01:56:13 +01:00
[FEATURE] Add an Addition model an a relation to it.
This commit is contained in:
parent
c74c26029a
commit
e8d19e41c8
15 changed files with 513 additions and 12 deletions
57
Classes/Domain/Model/Addition.php
Normal file
57
Classes/Domain/Model/Addition.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace OliverKlee\Tea\Domain\Model;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Oliver Klee <typo3-coding@oliverklee.de>, oliverklee.de
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
/**
|
||||
* This model represents an addition for tea like sugar or milk.
|
||||
*
|
||||
* @author Oliver Klee <typo3-coding@oliverklee.de>
|
||||
*/
|
||||
class Addition extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject {
|
||||
/**
|
||||
* @var \string
|
||||
* @validate NotEmpty
|
||||
*/
|
||||
protected $title = '';
|
||||
|
||||
/**
|
||||
* @return \string $title
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \string $title
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTitle($title) {
|
||||
$this->title = $title;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -32,7 +32,7 @@ namespace OliverKlee\Tea\Domain\Model;
|
|||
*/
|
||||
class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
|
||||
/**
|
||||
* @var \float
|
||||
* @var float
|
||||
*/
|
||||
protected $size = 0.0;
|
||||
|
||||
|
@ -43,14 +43,38 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
|
|||
protected $type = NULL;
|
||||
|
||||
/**
|
||||
* @return \float $size
|
||||
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition>
|
||||
* @lazy
|
||||
*/
|
||||
protected $additions = NULL;
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*
|
||||
* @return TeaBeverage
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->initializeStorageObjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all ObjectStorage properties.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initializeStorageObjects() {
|
||||
$this->additions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float $size
|
||||
*/
|
||||
public function getSize() {
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \float $size
|
||||
* @param float $size
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -73,5 +97,47 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
|
|||
public function setType(\OliverKlee\Tea\Domain\Model\TeaType $type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an Addition.
|
||||
*
|
||||
* @param \OliverKlee\Tea\Domain\Model\Addition $addition
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addAddition(\OliverKlee\Tea\Domain\Model\Addition $addition) {
|
||||
$this->additions->attach($addition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an Addition.
|
||||
*
|
||||
* @param \OliverKlee\Tea\Domain\Model\Addition $additionToRemove The Addition to be removed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeAddition(\OliverKlee\Tea\Domain\Model\Addition $additionToRemove) {
|
||||
$this->additions->detach($additionToRemove);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the additions.
|
||||
*
|
||||
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions
|
||||
*/
|
||||
public function getAdditions() {
|
||||
return $this->additions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the additions.
|
||||
*
|
||||
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAdditions(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additions) {
|
||||
$this->additions = $additions;
|
||||
}
|
||||
}
|
||||
?>
|
107
Configuration/TCA/Addition.php
Normal file
107
Configuration/TCA/Addition.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
if (!defined ('TYPO3_MODE')) {
|
||||
die ('Access denied.');
|
||||
}
|
||||
|
||||
$TCA['tx_tea_domain_model_addition'] = array(
|
||||
'ctrl' => $TCA['tx_tea_domain_model_addition']['ctrl'],
|
||||
'interface' => array(
|
||||
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title',
|
||||
),
|
||||
'types' => array(
|
||||
'1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, title,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access,starttime, endtime'),
|
||||
),
|
||||
'palettes' => array(
|
||||
'1' => array('showitem' => ''),
|
||||
),
|
||||
'columns' => array(
|
||||
'sys_language_uid' => array(
|
||||
'exclude' => 1,
|
||||
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
|
||||
'config' => array(
|
||||
'type' => 'select',
|
||||
'foreign_table' => 'sys_language',
|
||||
'foreign_table_where' => 'ORDER BY sys_language.title',
|
||||
'items' => array(
|
||||
array('LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1),
|
||||
array('LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
'l10n_parent' => array(
|
||||
'displayCond' => 'FIELD:sys_language_uid:>:0',
|
||||
'exclude' => 1,
|
||||
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
|
||||
'config' => array(
|
||||
'type' => 'select',
|
||||
'items' => array(
|
||||
array('', 0),
|
||||
),
|
||||
'foreign_table' => 'tx_tea_domain_model_addition',
|
||||
'foreign_table_where' => 'AND tx_tea_domain_model_addition.pid=###CURRENT_PID### AND tx_tea_domain_model_addition.sys_language_uid IN (-1,0)',
|
||||
),
|
||||
),
|
||||
'l10n_diffsource' => array(
|
||||
'config' => array(
|
||||
'type' => 'passthrough',
|
||||
),
|
||||
),
|
||||
't3ver_label' => array(
|
||||
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel',
|
||||
'config' => array(
|
||||
'type' => 'input',
|
||||
'size' => 30,
|
||||
'max' => 255,
|
||||
)
|
||||
),
|
||||
'hidden' => array(
|
||||
'exclude' => 1,
|
||||
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden',
|
||||
'config' => array(
|
||||
'type' => 'check',
|
||||
),
|
||||
),
|
||||
'starttime' => array(
|
||||
'exclude' => 1,
|
||||
'l10n_mode' => 'mergeIfNotBlank',
|
||||
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime',
|
||||
'config' => array(
|
||||
'type' => 'input',
|
||||
'size' => 13,
|
||||
'max' => 20,
|
||||
'eval' => 'datetime',
|
||||
'checkbox' => 0,
|
||||
'default' => 0,
|
||||
'range' => array(
|
||||
'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')),
|
||||
),
|
||||
),
|
||||
),
|
||||
'endtime' => array(
|
||||
'exclude' => 1,
|
||||
'l10n_mode' => 'mergeIfNotBlank',
|
||||
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime',
|
||||
'config' => array(
|
||||
'type' => 'input',
|
||||
'size' => 13,
|
||||
'max' => 20,
|
||||
'eval' => 'datetime',
|
||||
'checkbox' => 0,
|
||||
'default' => 0,
|
||||
'range' => array(
|
||||
'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')),
|
||||
),
|
||||
),
|
||||
),
|
||||
'title' => array(
|
||||
'exclude' => 0,
|
||||
'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_addition.title',
|
||||
'config' => array(
|
||||
'type' => 'input',
|
||||
'size' => 30,
|
||||
'eval' => 'trim,required',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
|
@ -6,10 +6,10 @@ if (!defined ('TYPO3_MODE')) {
|
|||
$TCA['tx_tea_domain_model_teabeverage'] = array(
|
||||
'ctrl' => $TCA['tx_tea_domain_model_teabeverage']['ctrl'],
|
||||
'interface' => array(
|
||||
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, size, type',
|
||||
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, size, type, additions',
|
||||
),
|
||||
'types' => array(
|
||||
'1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, size, type,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access,starttime, endtime'),
|
||||
'1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, size, type, additions,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access,starttime, endtime'),
|
||||
),
|
||||
'palettes' => array(
|
||||
'1' => array('showitem' => ''),
|
||||
|
@ -112,6 +112,42 @@ $TCA['tx_tea_domain_model_teabeverage'] = array(
|
|||
'maxitems' => 1,
|
||||
),
|
||||
),
|
||||
'additions' => array(
|
||||
'exclude' => 0,
|
||||
'label' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_teabeverage.additions',
|
||||
'config' => array(
|
||||
'type' => 'select',
|
||||
'foreign_table' => 'tx_tea_domain_model_addition',
|
||||
'MM' => 'tx_tea_teabeverage_addition_mm',
|
||||
'size' => 10,
|
||||
'autoSizeMax' => 30,
|
||||
'maxitems' => 9999,
|
||||
'multiple' => 0,
|
||||
'wizards' => array(
|
||||
'_PADDING' => 1,
|
||||
'_VERTICAL' => 1,
|
||||
'edit' => array(
|
||||
'type' => 'popup',
|
||||
'title' => 'Edit',
|
||||
'script' => 'wizard_edit.php',
|
||||
'icon' => 'edit2.gif',
|
||||
'popup_onlyOpenIfSelected' => 1,
|
||||
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
|
||||
),
|
||||
'add' => Array(
|
||||
'type' => 'script',
|
||||
'title' => 'Create new',
|
||||
'icon' => 'add.gif',
|
||||
'params' => array(
|
||||
'table' => 'tx_tea_domain_model_addition',
|
||||
'pid' => '###CURRENT_PID###',
|
||||
'setValue' => 'prepend'
|
||||
),
|
||||
'script' => 'wizard_add.php',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
|
@ -1 +1 @@
|
|||
{"modules":[{"config":{"position":[40,138]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaBeverage","objectsettings":{"aggregateRoot":true,"description":"Tea beverage","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"264022070620"},"propertyGroup":{"properties":[{"propertyDescription":"size","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"size","propertyType":"Float","uid":"686745089204"}]},"relationGroup":{"relations":[{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"type","relationName":"type","relationType":"manyToOne","relationWire":"[wired]","uid":"381688624164"}]}}},{"config":{"position":[756,159]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaType","objectsettings":{"aggregateRoot":false,"description":"Tea type","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"1351448414985"},"propertyGroup":{"properties":[{"propertyDescription":"title","propertyIsExcludeField":false,"propertyIsRequired":true,"propertyName":"title","propertyType":"String","uid":"514346914201"},{"propertyDescription":"caffeinated","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"caffeinated","propertyType":"Boolean","uid":"314036724989"}]},"relationGroup":{"relations":[]}}}],"properties":{"backendModules":[],"description":"This extension serves as an example on how to unit-test different data types and relation types in TYPO3 extensions.","emConf":{"category":"plugin","custom_category":"","dependsOn":"extbase => 6.0\nfluid => 6.0\ntypo3 => 6.0\n","disableLocalization":false,"disableVersioning":false,"priority":"","shy":false,"state":"alpha","targetVersion":"6.0","version":""},"extensionKey":"tea","name":"Tea example","originalExtensionKey":"tea","persons":[{"company":"oliverklee.de","email":"typo3-coding@oliverklee.de","name":"Oliver Klee","role":"Developer"}],"plugins":[],"vendorName":"OliverKlee"},"wires":[{"src":{"moduleId":0,"terminal":"relationWire_0","uid":"381688624164"},"tgt":{"moduleId":1,"terminal":"SOURCES","uid":"1351448414985"}}],"log":{"last_modified":"2013-11-01 08:34","extension_builder_version":"2.5.2","be_user":"Oliver Klee (1)"}}
|
||||
{"modules":[{"config":{"position":[658,132]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaBeverage","objectsettings":{"aggregateRoot":true,"description":"Tea beverage","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"264022070620"},"propertyGroup":{"properties":[{"propertyDescription":"size","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"size","propertyType":"Float","uid":"686745089204"}]},"relationGroup":{"relations":[{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"type","relationName":"type","relationType":"manyToOne","relationWire":"[wired]","uid":"381688624164"},{"foreignRelationClass":"","lazyLoading":true,"propertyIsExcludeField":false,"relationDescription":"additions","relationName":"additions","relationType":"manyToMany","relationWire":"[wired]","uid":"1077905653897"}]}}},{"config":{"position":[71,142]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"TeaType","objectsettings":{"aggregateRoot":false,"description":"Tea type","mapToTable":"","parentClass":"","sorting":false,"type":"Entity","uid":"1351448414985"},"propertyGroup":{"properties":[{"propertyDescription":"title","propertyIsExcludeField":false,"propertyIsRequired":true,"propertyName":"title","propertyType":"String","uid":"514346914201"},{"propertyDescription":"caffeinated","propertyIsExcludeField":false,"propertyIsRequired":false,"propertyName":"caffeinated","propertyType":"Boolean","uid":"314036724989"}]},"relationGroup":{"relations":[]}}},{"config":{"position":[35,391]},"name":"New Model Object","value":{"actionGroup":{"_default0_list":false,"_default1_show":false,"_default2_new_create":false,"_default3_edit_update":false,"_default4_delete":false,"customActions":[]},"name":"Addition","objectsettings":{"aggregateRoot":false,"description":"addition","mapToTable":"","parentClass":"","sorting":false,"type":"ValueObject","uid":"1270408953807"},"propertyGroup":{"properties":[{"propertyDescription":"title","propertyIsExcludeField":false,"propertyIsRequired":true,"propertyName":"title","propertyType":"String","uid":"846205806952"}]},"relationGroup":{"relations":[]}}}],"properties":{"backendModules":[],"description":"This extension serves as an example on how to unit-test different data types and relation types in TYPO3 extensions.","emConf":{"category":"plugin","custom_category":"","dependsOn":"extbase => 6.0\nfluid => 6.0\ntypo3 => 6.0\n","disableLocalization":false,"disableVersioning":false,"priority":"","shy":false,"state":"alpha","targetVersion":"6.0","version":""},"extensionKey":"tea","name":"Tea example","originalExtensionKey":"tea","persons":[{"company":"oliverklee.de","email":"typo3-coding@oliverklee.de","name":"Oliver Klee","role":"Developer"}],"plugins":[],"vendorName":"OliverKlee"},"wires":[{"src":{"moduleId":0,"terminal":"relationWire_0","uid":"381688624164"},"tgt":{"moduleId":1,"terminal":"SOURCES","uid":"1351448414985"}},{"src":{"moduleId":0,"terminal":"relationWire_1","uid":"1077905653897"},"tgt":{"moduleId":2,"terminal":"SOURCES","uid":"1270408953807"}}],"log":{"last_modified":"2013-11-01 08:56","extension_builder_version":"2.5.2","be_user":"Oliver Klee (1)"}}
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<xliff version="1.0">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T20:34:29Z" product-name="tea">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T20:56:40Z" product-name="tea">
|
||||
<header/>
|
||||
<body>
|
||||
<trans-unit id="tx_tea_domain_model_teabeverage">
|
||||
|
@ -12,6 +12,9 @@
|
|||
<trans-unit id="tx_tea_domain_model_teabeverage.type">
|
||||
<source>type</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_teabeverage.additions">
|
||||
<source>additions</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_teatype">
|
||||
<source>Tea type</source>
|
||||
</trans-unit>
|
||||
|
@ -21,6 +24,12 @@
|
|||
<trans-unit id="tx_tea_domain_model_teatype.caffeinated">
|
||||
<source>caffeinated</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_addition">
|
||||
<source>addition</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_addition.title">
|
||||
<source>title</source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<xliff version="1.0">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T20:56:40Z" product-name="tea">
|
||||
<header/>
|
||||
<body>
|
||||
<trans-unit id="title.description">
|
||||
<source>title</source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<xliff version="1.0">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T20:34:29Z" product-name="tea">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T20:56:40Z" product-name="tea">
|
||||
<header/>
|
||||
<body>
|
||||
<trans-unit id="title.description">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<xliff version="1.0">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T20:34:29Z" product-name="tea">
|
||||
<file source-language="en" datatype="plaintext" original="messages" date="2013-11-01T20:56:40Z" product-name="tea">
|
||||
<header/>
|
||||
<body>
|
||||
<trans-unit id="tx_tea_domain_model_teabeverage">
|
||||
|
@ -12,6 +12,9 @@
|
|||
<trans-unit id="tx_tea_domain_model_teabeverage.type">
|
||||
<source>Type</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_teabeverage.additions">
|
||||
<source>Additions</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_teatype">
|
||||
<source>Tea Type</source>
|
||||
</trans-unit>
|
||||
|
@ -21,6 +24,12 @@
|
|||
<trans-unit id="tx_tea_domain_model_teatype.caffeinated">
|
||||
<source>Caffeinated</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_addition">
|
||||
<source>Addition</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="tx_tea_domain_model_addition.title">
|
||||
<source>Title</source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
BIN
Resources/Public/Icons/tx_tea_domain_model_addition.gif
Normal file
BIN
Resources/Public/Icons/tx_tea_domain_model_addition.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 243 B |
70
Tests/Unit/Domain/Model/AdditionTest.php
Normal file
70
Tests/Unit/Domain/Model/AdditionTest.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace OliverKlee\Tea\Tests;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2013 Oliver Klee <typo3-coding@oliverklee.de>, oliverklee.de
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
/**
|
||||
* Test case.
|
||||
*
|
||||
* @author Oliver Klee <typo3-coding@oliverklee.de>
|
||||
*/
|
||||
class AdditionTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
|
||||
/**
|
||||
* @var \OliverKlee\Tea\Domain\Model\Addition
|
||||
*/
|
||||
protected $fixture = NULL;
|
||||
|
||||
public function setUp() {
|
||||
$this->fixture = new \OliverKlee\Tea\Domain\Model\Addition();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
unset($this->fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getTitleInitiallyReturnsEmptyString() {
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->fixture->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setTitleSetsTitle() {
|
||||
$this->fixture->setTitle('foo bar');
|
||||
|
||||
$this->assertSame(
|
||||
'foo bar',
|
||||
$this->fixture->getTitle()
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -35,7 +35,7 @@ class TeaBeverageTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
|
|||
/**
|
||||
* @var \OliverKlee\Tea\Domain\Model\TeaBeverage
|
||||
*/
|
||||
protected $fixture;
|
||||
protected $fixture = NULL;
|
||||
|
||||
public function setUp() {
|
||||
$this->fixture = new \OliverKlee\Tea\Domain\Model\TeaBeverage();
|
||||
|
@ -88,5 +88,59 @@ class TeaBeverageTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
|
|||
$this->fixture->getType()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getAdditionsInitiallyReturnsEmptyStorage() {
|
||||
$this->assertEquals(
|
||||
new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(),
|
||||
$this->fixture->getAdditions()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setAdditionsSetsAdditions() {
|
||||
$items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
|
||||
$this->fixture->setAdditions($items);
|
||||
|
||||
$this->assertSame(
|
||||
$items,
|
||||
$this->fixture->getAdditions()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function addAdditionAddsAddition() {
|
||||
$items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
|
||||
$this->fixture->setAdditions($items);
|
||||
|
||||
$newItem = new \OliverKlee\Tea\Domain\Model\Addition();
|
||||
$this->fixture->addAddition($newItem);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->fixture->getAdditions()->contains($newItem)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function removeAdditionRemovesAddition() {
|
||||
$items = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
|
||||
$this->fixture->setAdditions($items);
|
||||
|
||||
$newItem = new \OliverKlee\Tea\Domain\Model\Addition();
|
||||
$this->fixture->addAddition($newItem);
|
||||
$this->fixture->removeAddition($newItem);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->fixture->getAdditions()->contains($newItem)
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -35,7 +35,7 @@ class TeaTypeTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
|
|||
/**
|
||||
* @var \OliverKlee\Tea\Domain\Model\TeaType
|
||||
*/
|
||||
protected $fixture;
|
||||
protected $fixture = NULL;
|
||||
|
||||
public function setUp() {
|
||||
$this->fixture = new \OliverKlee\Tea\Domain\Model\TeaType();
|
||||
|
|
|
@ -30,7 +30,7 @@ $TCA['tx_tea_domain_model_teabeverage'] = array(
|
|||
'starttime' => 'starttime',
|
||||
'endtime' => 'endtime',
|
||||
),
|
||||
'searchFields' => 'size,type,',
|
||||
'searchFields' => 'size,type,additions,',
|
||||
'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/TeaBeverage.php',
|
||||
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_tea_domain_model_teabeverage.gif'
|
||||
),
|
||||
|
@ -67,4 +67,34 @@ $TCA['tx_tea_domain_model_teatype'] = array(
|
|||
),
|
||||
);
|
||||
|
||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_tea_domain_model_addition', 'EXT:tea/Resources/Private/Language/locallang_csh_tx_tea_domain_model_addition.xlf');
|
||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_tea_domain_model_addition');
|
||||
$TCA['tx_tea_domain_model_addition'] = array(
|
||||
'ctrl' => array(
|
||||
'title' => 'LLL:EXT:tea/Resources/Private/Language/locallang_db.xlf:tx_tea_domain_model_addition',
|
||||
'label' => 'title',
|
||||
'tstamp' => 'tstamp',
|
||||
'crdate' => 'crdate',
|
||||
'cruser_id' => 'cruser_id',
|
||||
'dividers2tabs' => TRUE,
|
||||
|
||||
'versioningWS' => 2,
|
||||
'versioning_followPages' => TRUE,
|
||||
|
||||
'origUid' => 't3_origuid',
|
||||
'languageField' => 'sys_language_uid',
|
||||
'transOrigPointerField' => 'l10n_parent',
|
||||
'transOrigDiffSourceField' => 'l10n_diffsource',
|
||||
|
||||
'delete' => 'deleted',
|
||||
'enablecolumns' => array(
|
||||
'disabled' => 'hidden',
|
||||
'starttime' => 'starttime',
|
||||
'endtime' => 'endtime',
|
||||
),
|
||||
'searchFields' => 'title,',
|
||||
'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Addition.php',
|
||||
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_tea_domain_model_addition.gif'
|
||||
),
|
||||
);
|
||||
?>
|
|
@ -7,6 +7,7 @@ CREATE TABLE tx_tea_domain_model_teabeverage (
|
|||
|
||||
size double(11,2) DEFAULT '0.00' NOT NULL,
|
||||
type int(11) unsigned DEFAULT '0',
|
||||
additions int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
|
||||
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
|
@ -74,4 +75,55 @@ CREATE TABLE tx_tea_domain_model_teatype (
|
|||
KEY parent (pid),
|
||||
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
|
||||
KEY language (l10n_parent,sys_language_uid)
|
||||
);
|
||||
|
||||
#
|
||||
# Table structure for table 'tx_tea_domain_model_addition'
|
||||
#
|
||||
CREATE TABLE tx_tea_domain_model_addition (
|
||||
uid int(11) NOT NULL auto_increment,
|
||||
pid int(11) DEFAULT '0' NOT NULL,
|
||||
|
||||
title varchar(255) DEFAULT '' NOT NULL,
|
||||
|
||||
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
|
||||
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
|
||||
starttime int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
endtime int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
|
||||
t3ver_oid int(11) DEFAULT '0' NOT NULL,
|
||||
t3ver_id int(11) DEFAULT '0' NOT NULL,
|
||||
t3ver_wsid int(11) DEFAULT '0' NOT NULL,
|
||||
t3ver_label varchar(255) DEFAULT '' NOT NULL,
|
||||
t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
|
||||
t3ver_stage int(11) DEFAULT '0' NOT NULL,
|
||||
t3ver_count int(11) DEFAULT '0' NOT NULL,
|
||||
t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
|
||||
t3ver_move_id int(11) DEFAULT '0' NOT NULL,
|
||||
|
||||
t3_origuid int(11) DEFAULT '0' NOT NULL,
|
||||
sys_language_uid int(11) DEFAULT '0' NOT NULL,
|
||||
l10n_parent int(11) DEFAULT '0' NOT NULL,
|
||||
l10n_diffsource mediumblob,
|
||||
|
||||
PRIMARY KEY (uid),
|
||||
KEY parent (pid),
|
||||
KEY t3ver_oid (t3ver_oid,t3ver_wsid),
|
||||
KEY language (l10n_parent,sys_language_uid)
|
||||
);
|
||||
|
||||
#
|
||||
# Table structure for table 'tx_tea_teabeverage_addition_mm'
|
||||
#
|
||||
CREATE TABLE tx_tea_teabeverage_addition_mm (
|
||||
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
sorting int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
|
||||
|
||||
KEY uid_local (uid_local),
|
||||
KEY uid_foreign (uid_foreign)
|
||||
);
|
Loading…
Reference in a new issue