info:concrete5:58:crud

CRUD

FIXME!!!

https://gitlab.com/zpartakov/concrete5_crud

Ancien

essai non fonctionnel sur une singlepage “expressement.php”, l'erreur renvoyée semble un bug connu
la 2e méthode fonctionne mais est un peu tricky
<?php
//source: https://documentation.concrete5.org/developers/express/programmatically-creating-express-objects
$student = Express::buildObject('student', 'students', 'Student', $pkg);
$student->addAttribute('text', 'First Name', 'first_name');
$student->addAttribute('text', 'Last Name', 'last_name');
$student->addAttribute('email', 'courriel', 'courriel');
$studentEntity = $student->save();
 
//create form
    $form = $student->buildForm('Form');
    $form->addFieldset('Basics')
        ->addAttributeKeyControl('first_name')
        ->addAttributeKeyControl('last_name')
        ->addAttributeKeyControl('courriel');
 
    $form = $form->save();
 
    $entityManager = $student->getEntityManager();
    $studentEntity->setDefaultViewForm($form);
    $studentEntity->setDefaultEditForm($form);
    $entityManager->persist($studentEntity);
    $entityManager->flush();
 
//$this->app->clearCaches();
//    $this->$student->app->clear();
//        parent::clearCaches();
 
//use Express; exit;
//add datas
$entry = Express::buildEntry('student')
    ->setStudentFirstName('Fred')
    ->setStudentLastName('Radeff')
    ->setStudentCourriel('fradeff@akademia.ch')
    ->save();
 
exit;
 
//following requires     composer require bitter/concrete5-express-batch-importer, which requires to change in /composer.json
//"minimum-stability": "stable" -> "minimum-stability": "dev"
 
// Import Test Data to the Express Object
$entries = [];
 
for ($i = 1; $i <= 100; $i++) {
    $entries[] = [
        "first_name" => "Lorem ipsum",
        "last_name" => "Lorem ipsum",
        "bio" => "Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem"
    ];
}
 
$startTime = microtime(true) * 1000;
 
\Bitter\Concrete\Express\BatchImporter::batchImport("student", $entries);
 
$endTime = microtime(true) * 1000;
 
\Log::addEntry(t("Avg. Time: %sms / Entry", round(($endTime - $startTime) / count($entries), 2)));
 
 
//bug!
#\Bitter\Concrete\Express\BatchImporter::batchImportCSV("student", "/home/radeff/web/c5.old/test.csv");
#exit;
</php>
  • info/concrete5/58/crud.txt
  • Dernière modification: 2020/11/03 11:27
  • de radeff