this breaking change affects the fe_user table. the TYPO3 upgrade wizard reworks the table to the new FileReferences from FAL. so before all that we had the image name stored in the database, after the wizard runs we have an integer in the table.
why does this integer get stored now? how are we supposed to get the image off the ResourceFactory without any identifier? or am i getting it wrong? i cant work off the row's uid and also cant use the value stored in the image column.
how can i recieve the image from the ResourceFactory after the upgrade wizard updated all the columns?
its possible to get the actual file object by the reference to the row, like this:
$fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
/** #var FileReference $fileObjects */
$fileObjects = $fileRepository->findByRelation('fe_users', 'image', $row['uid']);
foreach($fileObjects as $file){
/** #var FileReference $file */
print_r($file->getIdentifier());
}
Related
I would like create a index of ".h" files in my doxygen-ed project in addition of the default index.
Is there a way to do this automatically ?
I have do this by adding a \addtogroup in every headers like this :
/** \addtogroup Headers
* - oge-mutex.h
* \copybrief oge-mutex.h
*/
This will create a page with a list of all marked headers and her brief description.
I have an image file in the page properties and I can't find a way to use the properties of the file reference because they are all protected.
Not every attribute must be in the debug. If you look into the FileReference class you can see that there are several getters for different fields.
In PHP you do:
$title = $myFileReference->getTitle();
$description = $myFileReference->getDescription();
In Fluid you do:
{fileReference.title}
{fileReference.description}
You can access all properties through {fileReference.originalResource.properties}
/**
* New post form
* #param \Vendor\My\Domain\Model\Post|null $newPost New post
* #return void
* #dontvalidate $newPost
*/
public function newAction(\Vendor\My\Domain\Model\Post $newPost = NULL) {
$this->view->assign('test', 'hello');
$this->view->assign('categoryList', $this->categoryRepository->findAllByBlog(0));
$this->view->assign('postObject', $newPost);
}
public function editAction() {
$this->view->assign('categoryList', $this->categoryRepository->findAllByBlog(0));
$postObject = $this->postRepository->findOneByUid($this->request->getArgument('id'));
$this->view->assign('postObject', $postObject);
}
this is my script and my problem is that I have a categoryList array, its is only getting in edit view. I want to use that category list on newaction. When I tried to foreach that array in new action view file it is getting empty. and i can get it after saving the postObject. Any idea about this particular problem? and variable test from newaction also not visible in the newAction Template file.
Am using Typo3 7.6.11
Declare arguments you want to receive, as arguments for your controller action. Reference this argument name correctly in Fluid templates when you build links to your controller action. Do not access arguments from the Request directly. Add correct PDPdoc comments for it, too.
Basically: do the correct thing with your arguments instead of bypassing the framework. This advise applies to anything you do in Extbase.
NB: New and Edit actions should never, ever share the same template (this further indicates you bypass the framework's expected behavior). Create and New, yes. But not New and Edit. If necessary, put the form fields in a partial and the form itself in separate templates so you can control the action building and object/object-name setup correctly.
If a $this->***Repository method returns NULL, it may be that the repository had no StoragePid defined.
Make sure both newAction and editAction have the same storagePid defined in TypoScript or your Backend Plugin Settings (Flexform).
The TypoScript for this would look something like this:
plugin.tx_extension.persistence.storagePid = 100
I have a m:n relation in my domain model:
inquiry is the aggregate root in my domain model
several investigators can be assigned to each inquiry.
In the inquiry model this is defined:
/**
* #var Tx_Extbase_Persistence_ObjectStorage<Tx_MyExt_Domain_Model_Investigator>
*/
protected $investigator;
The investigator domain model is mapped to the fe_user table of TYPO3, which is noted properly in the configuration (ext_typoscript_setup.txt):
config.tx_extbase{
persistence{
classes{
Tx_MyExt_Domain_Model_Investigator {
mapping {
recordType = Tx_Extbase_Domain_Model_FrontendUser
tableName = fe_users
}
}
}
This works fine, I can display and edit inquiry records in the backend and frontend. However, when I want to change the investigators assigned to one inquiry (from edit action), I get an exception after submitting my form:
#1297759968: Exception while property mapping at property path "investigator":
No converter found which can be used to convert from "array" to
"Tx_Extbase_Persistence_ObjectStorage"
The multiselect-box that I use for this is created like that:
<f:form.select multiple="true" size="10" property="investigator"
value="{inquiry.investigator}" options="{allInvestigators}"
optionLabelField="name" />
Which is rendered like this:
<select name="tx_myext_inquiry[inquiry][investigator][]" size="10" multiple="true">
<option value="362">John Doe</option>
<option value="590">Jane Doe</option>
<option selected="selected" value="361">Steve Miller</option>
<option value="720">James Brown</option>
<option value="726">Janis Joplin</option>
</select>
{allInvestigators} is an array with all users from the group "investigators".
The values already stored are marked with "selected", which proves that some of my code is correct ;).
I tried fiddling around with the type converter (Tx_Extbase_Property_TypeConverter_PersistentObjectConverter Dok) in the InquiryController to cast my array to an object, but it to no avail. The field investigator is passed as an array to the update action, which triggers the exception.
I spend five hours on this now, need to move on.
How can I get rid of this error message?
Is converting the array to an object the right approach at all?
(Any questions for more details will be answered ASAP)
Edit:
Environment: TYPO3 version 6.1.1, Fluid 6.1.0, Extbase 6.1.0
I found the culprit in the model definition in Classes/Domain/Model/Inquiry.php
/**
* #var Tx_Extbase_Persistence_ObjectStorage<Tx_MyExt_Domain_Model_Investigator>
*/
protected $investigator;
I changed (part of) the #var annotation to name space style:
/**
* #var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<Tx_MyExt_Domain_Model_Investigator>
*/
protected $investigator;
Now the update process works. I guess in our project we need to standardize the model to name spaces.
If this is a bug, I will file it at forge.typo3.org.
This is currently a known problem in the 6.* branches of TYPO3.
See http://forge.typo3.org/issues/54289 there is currently a patch pending to get this fixed.
I have tested it with TYPO3 6.1 and TYPO3 6.2-dev from GIT and can't reproduce this problem. So it would be nice if you can give up some environment informations. Please start with your current TYPO3-Version.
I got a Doctrine entity having one field:
/**
* #PHPCRODM\String()
* #Assert\MaxLength(255)
*/
protected $title;
Is it possible to force a maxlength attribute for the input generated from this field, without having to specify it manually?
Apparently, PHPCRODM does not accept such an option. Sad... :(
[Creation Error] The annotation #PHPCRODM\String declared on property [...]\Article::$title does not have a property named "length". Available properties: type, translated, name, property, multivalue, assoc, nullable
Should create a PR when I'll get some free time. :)