logo
down
shadow

Typo3 MM Relation


Typo3 MM Relation

By : user2949151
Date : November 16 2020, 06:23 AM
will help you De facto you need to use methods addMatrikelnr(...) and removeMatrikelnr(...) for adding and remving relations, they are generated by Builder in Fach model.
Take a look at a setMatrikelnr method in the model it takes a collection not single object as a param.
code :
<?php
namespace ReRe\Rere\Domain\Model;

class Fach extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {

    /**
     * matrikelnr
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\ReRe\Rere\Domain\Model\Pruefling>
     */
    protected $matrikelnr = NULL;

    /**
     * __construct
     */
    public function __construct() {
        //Do not remove the next line: It would break the functionality
        $this->initStorageObjects();
    }

    /**
     * Initializes all ObjectStorage properties
     * Do not modify this method!
     * It will be rewritten on each save in the extension builder
     * You may modify the constructor of this class instead
     *
     * @return void
     */
    protected function initStorageObjects() {
        $this->matrikelnr = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
    }

    /**
     * Adds a Pruefling
     *
     * @param \ReRe\Rere\Domain\Model\Pruefling $matrikelnr
     * @return void
     */
    public function addMatrikelnr(\ReRe\Rere\Domain\Model\Pruefling $matrikelnr) {
        $this->matrikelnr->attach($matrikelnr);
    }

    /**
     * Removes a Pruefling
     *
     * @param \ReRe\Rere\Domain\Model\Pruefling $matrikelnrToRemove The Pruefling to be removed
     * @return void
     */
    public function removeMatrikelnr(\ReRe\Rere\Domain\Model\Pruefling $matrikelnrToRemove) {
        $this->matrikelnr->detach($matrikelnrToRemove);
    }

    /**
     * Returns the matrikelnr
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\ReRe\Rere\Domain\Model\Pruefling> $matrikelnr
     */
    public function getMatrikelnr() {
        return $this->matrikelnr;
    }

    /**
     * Sets the matrikelnr
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\ReRe\Rere\Domain\Model\Pruefling> $matrikelnr
     * @return void
     */
    public function setMatrikelnr(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $matrikelnr) {
        $this->matrikelnr = $matrikelnr;
    }

}


Share : facebook icon twitter icon
TYPO3 Extbase bidirectional 1:n relation

TYPO3 Extbase bidirectional 1:n relation


By : Ramkumar Karsh
Date : March 29 2020, 07:55 AM
I wish this helpful for you I assume you have created the following domain model with the Extension Builder.
code :
/**
 * Returns the author
 *
 * @var \TYPO3\YourExtension\Domain\Model\Author
 */
protected $author;

/**
 * @return \TYPO3\YourExtension\Domain\Model\Author
 */
public function getAuthor() {
    return $this->author;
}
TYPO3 extbase - ObjectStorage and 1:n relation

TYPO3 extbase - ObjectStorage and 1:n relation


By : kuroi
Date : March 29 2020, 07:55 AM
seems to work fine Well i made a fatal error when using the SAME category-object. In fact i just changed its CatName value. In ORM we need one object for each "value". Means we can't use the same object for multiple "object-allocations" like i did above. So the correct way of achieving my purpose is:
code :
$categories = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\ObjectStorage');

$category1 = $this->objectManager->get('VENDX\Items\Domain\Model\Category'); //1st catobj
$category1->setCatName('Cat1');  //First category
$categories->attach($category1);

$category2 = $this->objectManager->get('VENDX\Items\Domain\Model\Category'); //2nd catobj
$category2->setCatName('Cat2');  //Second category
$categories->attach($category2);

$item->setCategories($categories);
$categories = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage;

$category1 = new \VENDX\Items\Domain\Model\Category; //1st catobj
$category1->setCatName('Cat1');  //First category
$categories->attach($category1);

$category2 = new \VENDX\Items\Domain\Model\Category; //2nd catobj
$category2->setCatName('Cat2');  //Second category
$categories->attach($category2);

$item->setCategories($categories);
TYPO3 Extbase: Filtering a 1:N relation

TYPO3 Extbase: Filtering a 1:N relation


By : Saad Bhatti
Date : March 29 2020, 07:55 AM
seems to work fine You can use the Extbase Query Object for getting just the events with certain dates.
I assume you have a field 'date' in your event model, that keeps track of the added events.
code :
// assuming your repository is "eventRepository"
$startDate = 1497960246;
$query = $this->eventRepository->createQuery();
$query->matching($query->greaterThan('date.start', $startDate));
$events = $query->execute();
TYPO3 Parent relation reciprocity

TYPO3 Parent relation reciprocity


By : user3507476
Date : March 29 2020, 07:55 AM
I wish did fix the issue.
Do I really need to create a 'parent_r' propriety in my entity, since it is already stored?
Get TYPO3 Extbase mm relation count

Get TYPO3 Extbase mm relation count


By : stand1921
Date : March 29 2020, 07:55 AM
Any of those help Extbase Repositories got countAll() / countByProperty() by default. You can also add your own functions to the repository for just returning the object count of any query.
You may try something like this in your controller:
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org