/** * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $comment * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $post * @param $signalInformation string */ public function handleCommentInsertion(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $comment, \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $post, $signalInformation) { $content = 'Comment: ' . $comment->getComment(); $content .= ' (Post: ' . $post->getTitle() . ')'; $content .= " / " . $signalInformation . chr(10); $this->writeLogFile($content); }
/** * Authenticates a frontend user * * @param DomainObjectInterface $user * @return void */ public function authenticateUser(DomainObjectInterface $user) { $frontendController = $this->getFrontendController(); $frontendController->fe_user->createUserSession($user->_getCleanProperties()); $frontendController->fe_user->loginSessionStarted = TRUE; $frontendController->fe_user->user = $frontendController->fe_user->fetchUserSession(); $frontendController->loginUser = TRUE; }
/** * Populate this proxy by asking the $population closure. * * @return object The instance (hopefully) returned */ public function _loadRealInstance() { // this check safeguards against a proxy being activated multiple times // usually that does not happen, but if the proxy is held from outside // its parent ... the result would be weird. if ($this->parentObject->_getProperty($this->propertyName) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy) { $objects = $this->dataMapper->fetchRelated($this->parentObject, $this->propertyName, $this->fieldValue, false, false); $propertyValue = $this->dataMapper->mapResultToPropertyValue($this->parentObject, $this->propertyName, $objects); $this->parentObject->_setProperty($this->propertyName, $propertyValue); $this->parentObject->_memorizeCleanState($this->propertyName); return $propertyValue; } else { return $this->parentObject->_getProperty($this->propertyName); } }
/** * Adds or updates the given model in the repository for the * given API path * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $model * @param string $path The API path * @return void */ public function saveModelForPath($model, $path) { $repository = $this->getRepositoryForPath($path); if ($repository) { if ($model->_isNew()) { $repository->add($model); } else { $repository->update($model); } $this->persistAllChanges(); } }
/** * Since ExtBase isn't forcing the one to one relationships * for FileReferences, we're doing it here. * * ASSUMPTION: FileReference to File is one to one as well. * Meaning, deleting a FileReference will delete the File. * * NOTE: At this point, the FileReference object has not been saved * in the database. * * @param FileReference $fileReference * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object * @param string $fieldname * @param string $propertyPath */ public function saveOneToOne(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object, $fieldname, FileReference $fileReference, $propertyPath = 'file') { // This is a new $object, unlikely to have any existing FileReferences for this field. if (!$object->getUid() || $fileReference->getUid()) { return $this->save($fileReference, $propertyPath); } // Remove all FileReferences for this field $datamap = $this->dataMapper->getDataMap(get_class($object)); $this->removeFileReferences($object->getUid(), $datamap->getTableName(), $fieldname); return $this->save($fileReference, $propertyPath); }
/** * Returns the property data from the given model * * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $model * @param string $propertyKey * @return mixed */ public function getModelProperty($model, $propertyKey) { /** @var VirtualObject $model */ $modelData = $model->getData(); if (isset($modelData[$propertyKey])) { return $modelData[$propertyKey]; } return NULL; }
/** * Delete an mm-relation from a relation table * * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $relatedObject The related object * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject The parent object * @param string $parentPropertyName The name of the parent object's property where the related objects are stored in * @return bool */ protected function deleteRelationFromRelationtable(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $relatedObject, \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $parentPropertyName) { $dataMap = $this->dataMapper->getDataMap(get_class($parentObject)); $columnMap = $dataMap->getColumnMap($parentPropertyName); $relationTableName = $columnMap->getRelationTableName(); $relationMatchFields = array($columnMap->getParentKeyFieldName() => (int) $parentObject->getUid(), $columnMap->getChildKeyFieldName() => (int) $relatedObject->getUid()); $relationTableMatchFields = $columnMap->getRelationTableMatchFields(); if (is_array($relationTableMatchFields)) { $relationMatchFields = array_merge($relationTableMatchFields, $relationMatchFields); } $res = $this->storageBackend->removeRow($relationTableName, $relationMatchFields, false); return $res; }
/** * @return boolean */ protected function isStorageAlreadyMemorizedInParentCleanState() { return $this->parentObject->_getCleanProperty($this->propertyName) === $this; }
/** * Get element uid * * @param array|DomainObjectInterface $element * * @return int|NULL */ protected function getElementUid($element) { if ($element instanceof DomainObjectInterface) { if ($element instanceof AbstractLocalizedEntity) { return (int) $element->getLocalizedUid(); } return (int) $element->getUid(); } if (is_array($element) && isset($element['uid'])) { return (int) $element['uid']; } return NULL; }