Skip to content

Instantly share code, notes, and snippets.

@alfredbez
Last active August 29, 2015 14:23
Show Gist options
  • Save alfredbez/227dddf1cdc8809c4ea7 to your computer and use it in GitHub Desktop.
Save alfredbez/227dddf1cdc8809c4ea7 to your computer and use it in GitHub Desktop.

I'm currently developing an Extbase Extension which should have a scheduler task. This scheduler task should store a domain model. A new row in the database is generated, but it's always empty (except uid and pid = 1).

Output DB-Table:

uid pid titel
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1

A very basic mail is sent after the Model is stored.

What Am I Doing Wrong?

##filepaths

  • ext_tables.sql
  • Classes/Domain/Model/Simple.php
  • Classes/Domain/Repository/SimpleRepository.php
  • Classes/Task/LoadXml.php
CREATE TABLE tx_myext_domain_model_simple (
uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
titel varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid),
);
<?php
namespace Vendor\Myext\Task;
use TYPO3\CMS\Scheduler\Task\AbstractTask;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use Vendor\Myext\Domain\Model\Simple;
use Vendor\Myext\Domain\Repository\SimpleRepository;
class LoadXml extends AbstractTask {
public function execute() {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$persistenceManager = $objectManager->get(PersistenceManager::class);
$simpleRepository= $objectManager->get(SimpleRepository::class);
$simple = new Simple;
$simple->setTitel('Titel');
$simpleRepository->add($simple);
$persistenceManager->persistAll();
// send notification mail
return true;
}
}
<?php
namespace Vendor\Myext\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class Simple extends AbstractEntity {
/**
* Titel
* @var string
*/
protected $titel = '';
public function __construct() {
}
public function setTitel($titel) {
$this->titel = $titel;
}
public function getTitel() {
return $this->titel;
}
}
<?php
namespace Vendor\Myext\Domain\Repository;
use \TYPO3\CMS\Extbase\Persistence\Repository;
class SimpleRepository extends Repository {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment