예제 #1
0
파일: Div.php 프로젝트: khanhdeux/typo3test
 /**
  * Store user values in any database table
  *
  * @param User $user User properties
  * @param array $config TypoScript Settings
  * @param ContentObjectRenderer $contentObject
  * @param ObjectManagerInterface $objectManager
  * @return void
  */
 public static function storeInDatabasePreflight($user, $config, $contentObject, $objectManager)
 {
     $uid = 0;
     if (empty($config['new.']['storeInDatabase.'])) {
         return;
     }
     // one loop for every table to store
     foreach ((array) $config['new.']['storeInDatabase.'] as $table => $storeSettings) {
         $storeSettings = NULL;
         // if turned off
         if (!$contentObject->cObjGetSingle($config['new.']['storeInDatabase.'][$table]['_enable'], $config['new.']['storeInDatabase.'][$table]['_enable.'])) {
             continue;
         }
         // push user values to TypoScript to use with ".field=username"
         $contentObject->start(array_merge($user->_getProperties(), array('lastGeneratedUid' => $uid)));
         /**
          * @var $storeInDatabase \In2\Femanager\Utility\StoreInDatabase
          */
         $storeInDatabase = $objectManager->get('In2\\Femanager\\Utility\\StoreInDatabase');
         $storeInDatabase->setTable($table);
         foreach ($config['new.']['storeInDatabase.'][$table] as $field => $value) {
             if ($field[0] === '_' || stristr($field, '.')) {
                 continue;
             }
             $value = $contentObject->cObjGetSingle($config['new.']['storeInDatabase.'][$table][$field], $config['new.']['storeInDatabase.'][$table][$field . '.']);
             $storeInDatabase->addProperty($field, $value);
         }
         $uid = $storeInDatabase->execute();
     }
 }