repository,typo3,extbase,fal , How to get all FAL File Objects which are referenced?


How to get all FAL File Objects which are referenced?

Question:

Tag: repository,typo3,extbase,fal

I'm trying to make a extbase extension for TYPO3 to get alle file objects with mimetype image/... which referenced by any content, plugin or fluid in typo3.

But i don't know which is the best way to get these data. How should i create a model in my extension and how should i create the correct repository?

If i create a custom query i'm not sure how to return a complete FAL Object which contains any data (like metadata) etc.

hope someone could help me to find the right way, and maybe has a example or something.

thanks a lot


Answer:

You could do it like this, details are at the bottom:

  1. Get all file references.
  2. Go through them, retrieve the referenced file for each of them and retain only the ones where the field mime_type starts with image/.

There are two things you probably need to watch out for:

  1. The field mime_type needs to be up to date. Check the FAL scheduler indexing task for that.
  2. Performance. Depending on the number of files you have, it could be much faster to do this with a custom SQL statement which makes use of a JOIN. But you should only do that if performance is a problem.

How to get all file references:

First, build your own empty file reference class:

namespace Vendor/Extkey/Domain/Model;

class FileReference extends \TYPO3\CMS\Extbase\Domain\Model\FileReference {}

Make sure to configure it in your TypoScript to be serialized to the table sys_file_reference:

config.tx_extbase.persistence {
    classes {
        Vendor\Extkey\Domain\Model\FileReference {
            mapping {
                tableName = sys_file_reference
            }
        }
    }
}

Add a repository for the references:

namespace Vendor/Extkey/Domain/Repository;

class FileReferenceRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
    public function initializeObject() {
        /** @var \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
        $defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');

        $defaultQuerySettings->setRespectStoragePage(FALSE);
        $this->setDefaultQuerySettings($defaultQuerySettings);
    }
}

The reference class can be empty, but the repository needs it to be there in order to work correctly. Make sure you add the default query settings to ignore the page id, so you get all non-hidden and non-deleted file references by calling $fileReferenceRepository->findAll().

How to check the MIME-type of each referenced file:

You can get the MIME-type of each reference by calling

$fileReference->getOriginalResource()->getMimeType()

This should automatically fetch the original file from storage and read its MIME-type.


Related:


Typo3 6.2 fluid pagination not working as expected


typo3,fluid,extbase,typo3-6.2.x,typo3-4.5
My typo3 6.2(Upgraded from Typo3 4.5) fluid paginate displays all the items instead of 5 items. My Repository Method : public function getRandomLocation($iLimit) { $query = $this->createQuery(); $result = $query->statement("Select * FROM tx_sfel_domain_model_ttblocationsproduktegruppen WHERE hidden = 0 AND deleted = 0 AND logo != '' ORDER BY uid LIMIT 0,...

System.StackOverflowException was unhandled error


c#,asp.net,asp.net-mvc,repository
I am fairly new to repositories and mock repositories, so I would like help understanding what this error means exactly and how to avoid it. I have looked at other posts and done my research but they are too specific to their errors. The code that is breaking is public...

Typo3 extbase database query


typo3,extbase,typo3-6.2.x,queryinterface
I have an extbase database query like below. $query = $this->createQuery(); $result = $query->statement("Select * FROM table1 WHERE hidden = 0 AND deleted = 0 AND (".$PublicationYears.") AND logo != '' ORDER BY uid ASC LIMIT 0, ".$iLimit." ")->execute(); return $result; $PublicationYears = "ttra = '12' or ttra = '13'...

need more understanding on gitblit groovy push script


java,git,groovy,repository,gitblit
I have below groovy script PushCommand push=git.push(); push.setRemote("my remote"); push.setPushAll(); //Push all branches under refs/heads/*. push.setForce(true); //Sets the force preference for push operation. push.call(); My requirement: want to push only changes from one gitinstance to other setPushAll : Is this going to push all repository data all time script executed...

Typo3 6.2: “Could not find a suitable type converter for ”String“ ” exeption after update


php,typo3,typo3-6.2.x
Typo3 was from a very old version updated to Typo3 6.2. The most things are working now, but I have one own written extension that give me the following error: Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1297759968: Exception while property mapping at property path "":Could not find a suitable...

How can I render preview of FE plugin diplayed in Page module


typo3,backend,extbase,typo3-6.2.x,typo3-extensions
I have developed TYPO3 (6.2) extensions with some FE plugins. I need to change informations about plugin, which is displayed in the backend on page view. Now only Title and name of plugin is displayed ... I have used flexforms for configure the plugin and I would like to show...

Git: Remove directory with quotes and backslashes from repo


git,directory,repository,special-characters
I have a directory in my git repository (but not on my local system) named "my\\directory-name" It contains two quotation marks and two backslashes. The problem is that with this directory in my repo it is not possible to checkout the contents completely because (error message:) git doesn't find a...

TYPO3 Extbase build own Sitemap


typo3,sitemap,extbase
There are a lot of sitemap Generators for TYPO3 in the TER available. But none of them can handle Sites created by Extbase, which are not shown in the TYPO3 page tree. Edit Thanks to biesior, detailed informations: Unconventional I switch in TypoScript the GET Parameter for my Extbase extension[globalVar...

How to get Query object to felogin repository?


typo3,typo3-6.1.x
i need Query object of TYPO3\CMS\Felogin\Controller\FrontendLoginController in my extention repository so i can create my own query conditions.

How to get filename in Typo3 solr extension with FAL and own Extbase extension


solr,typo3,extbase,typo3-6.2.x,fal
Before FAL, I can get the filename of an image from my own Extbase extension in the solr config file "typo3/ext/solr/Configuration/TypoScript/Solr/setup.txt" via index { queue { tx_myextension = 1 tx_myextension { fields { ... myimage_stringS = articleimage ... } } } } Where "articleimage" was a database field with the...

Getting code from my forked repository


git,laravel,repository,laravel-5,composer-php
I made a fork from a repository called "chrisbjr/api-guard". the repository latest version is v2.2.2, and I made a release v2.2.3 from my fork. I have my own branch which is dev-fulluth, to get the code from my fork not from the main repo, composer has to contain the below...

How to use Hook “processDatamap_postProcFieldArray” in TYPO3 6.x


php,typo3,extbase,typo3-6.2.x
Use case: When saving an object (in backend, maybe in frontend too later) I want to manipulate values before saving to database. Problem: The file seems to get included (shows an error on save if I choose a wrong file path) but the function does not seem to be executed...

What urpmi source can I use with Mandriva Entreprise Server 5.2?


linux,repository,server
I have to install several packages for a customer on an old server using Mandriva Entreprise Server 5.2 (MES5). I have asked my customer for the DVD-ROM but he didn't find it, so I would like to know if there is an online compatible repository. I have found several repositories...

Maven failure to find codehaus artifact org.codehaus:codehaus-parent


java,maven,groovy,repository
So codehaus shut down (over the weekend, apparently): https://www.codehaus.org/ Now it says here that "Maven: All repositories are mirrored into Central, and our Nexus is hosted by Sonatype". If I am reading this correctly, this means that it should continue to work (and because Central is the default repository, I...

Backup github repository, branches and commits?


github,repository,backup
I want to backup everything including master & other branches & commits on my local & create new repository using different account. Which steps should i follow ? (bundle, mirror or clone)...

Show Typo3 FlexForm checkbox items inline


typo3
Would it be possible to show the checkboxes inline, so behind each other with a FlexForm? I'm now using the following code, but this shows every setting in a vertical list. <settings.ownchoice_for_sale> <TCEforms> <label>For sale</label> <config> <type>check</type> </config> </TCEforms> </settings.ownchoice_for_sale> <settings.ownchoice_reserved> <TCEforms> <label>Reserved</label> <config> <type>check</type> </config>...

PHP Frameworks and Project Repositories


php,git,github,zend-framework2,repository
I'm starting a new in PHP and for the first time I'm going to use a framework as the basis of the project. I've decided to use Zend Framework 2 for it. I'm going to be version controlling the project via Github. Is it normal to include all the framework...

Can I return DTO from my repository in some cases?


c#,entity-framework,design-patterns,repository,dto
I have two entities in my "domain assembly". Message - Id - Title - Content - IsMandatoryReading MessageUser - MessageId - UserId // The user who already read the message In my "Infrastructure assembly" I have the MessageRepository with the methods Save, Delete, GetAll, GetMany, FindById etc, all refer the...

How to change git repository using android studio


git,github,android-studio,version-control,repository
I'm using git with android studio and I already sync other repository. But I hope to change a git repository like github. I think I need to disconnect already connected to the repository but I don't found this option. To do that, How can I do?...

How does my frontend usergroup list get lost between Extbase action controller and Fluid template partial in TYPO3 6.2?


typo3,fluid,extbase,typo3-6.2.x,typo3-extensions
I'm using TYPO3 CMS 6.2.12 and Extension Builder 6.2.0 to model a Report class and build an extension to manage it. One of the domain driven design requirements is that a report author be a logged-in front end user. A second requirement is that the author choose a single group...

How to get typo3 settings in the utility files?


php,typo3,fluid,extbase
plugin.tx_xxx { setting { storagePid = 23 } } I want this typo3 settings in utility file. Please help me....

See git commands generated by TortoiseGit


c#,.net,git,repository,tortoisegit
I use TortoiseGit as my git client. I can cooperate with repository by clicking. I would like to know more about git and its command. Is there any oportunity to see what git commands are generate for git? For example I click Switch command and select target, how can I...

How to turn local source code directory into remote git repo?


git,repository
I have a directory on my Windows machine with some source code that I want to share with a couple of other people to develop it further together. I am thinking of using git, but since I want this repo to be (1) private and (2) free, this seems to...

google sitemap for tx_news records with dd_googlesitemap_dmf (or alternative)


typo3,sitemap,typo3-6.2.x
I try to let typo3 generate a sitemap for all the news records. For that I tried the dd_googlesitemap_dmf extention. The dd_googlesitemap works (it creates a sitemap for all the typo3 pages - but not for extensions). I filled in the basic infos into the configuration and called the url...

Routes for TYPO3 Neos plugin


typo3,typo3-flow,typo3-neos
I'm trying to define routes for my plugin. Everything is working as it should, because I got pretty URL on output, but unfortunately while I'm trying to access it I get an 404 error with message: #1303209195: No controller could be resolved which would match your request. Package key: "",...

Replace URLs in Typo3 DB


mysql,database,typo3
So I have a Site created with Typo3. I also have a domain which is linked to the folder of the Typo3 Installation. www.example.org I created a Subdomain and linked it to the same folder and used the Main Domain for something else. But now everything on the Subdomain still...

How to disable cache for a image carousel in TYPO3


caching,typo3,typoscript,extbase,typo3-6.2.x
My TYPO3 extension has a lib that generates random 5 images from the total stock, for example out of the 100 images. This is done randomly every time the page is loaded. Only default the TYPO3 cache is enabled so every time the same 5 images are showed. As the...

Mock service that takes unitOfWork in constructor


c#,unit-testing,repository,moq,business-logic
I try to write unit tests on my business logic. What i have now : private Mock<IRepository<Theme>> _mockRepository; private IBaseService<Theme> _service; private Mock<IAdminDataContext> _mockDataContext; private List<Theme> _listTheme; [TestInitialize] public void Initialize() { _mockRepository = new Mock<IRepository<Theme>>(); _mockDataContext = new Mock<IAdminDataContext>(); _service = new ThemeService(_mockDataContext.Object); _listTheme = new List<Theme> { new...

typo3 flow persist updated relation


php,doctrine2,typo3,typo3-flow
I have an issue TYPO3 Flow updating my relations. Am I wrong, that Flow should update changed relations automatically, so I don't have to update the related entities with the respective repository? Example 1: I have a model "Project" with multiple "Job" childs on attribute "jobs". If I do: $project->setJobs($collectionOfJobs);...

typo3 templavoila check current language


typo3,typoscript,templavoila
Hi i have 4 languages in my typo. Here is my main configuration for them: #LANGS config.linkVars=L config.defaultGetVars.L = 0 config.sys_language_overlay = hideNonTranslated [globalVar = GP:L = 3] config.sys_language_uid = 3 config.language = en config.locale_all = en_EN config.htmlTag_langKey = en plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 3 [globalVar = GP:L = 2] config.sys_language_uid =...

Hide typo3 content elements for specific user(groups)


typo3,typoscript
I want to "hide/deactivate" the table element for specific users/usergroups in the typo3 BE. Or to be more clear: I want to ONLY allow it to ONE specific user (admin). How can i do that? NOTE: At the moment the table element is deactivated in the global TS-config via tt_content...

How to add a LIST item with Java API Repository in Oracle ATG?


java,oracle,repository,atg
I create this repository: <gsa-template> <item-descriptor name="indirizzo" > <table name="INDIRIZZO" type="primary" id-column-name="ID_INDIRIZZO"> <property name="via" data-type="string" column-name="VIA" /> <property name="civico" data-type="int" column-name="CIVICO" /> </table> </item-descriptor> <item-descriptor name="utente" > <table name="UTENTE" type="primary" id-column-name="ID_UTENTE"> <property name="nome" data-type="string" column-name="NOME" /> <property...

htaccess and authentication for multiple domains


.htaccess,typo3
I am running a mutlisite TYPO3-Site. For the pre-live process, I want to add a htaccess with a htpasswd for 3 / 4 sites. How can I configure the htaccess-file to trigger the authentication only for specific urls? For example: http://example.org shouldn't get a password-protection, while http://example2.org should. Both sites...

Github App for Mac crashes upon opening


osx,github,crash,repository
Downloaded the Github for Mac app and it crashes instantly upon opening. Here is the error report: Application Specific Information: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Received error from name: in binding for key path "currentActionViewModel" on : NSError { domain: GTGitErrorDomain, code: -12, description: "Failed to...

Where are TYPO3 constants from constant editor stored?


typo3,constants
In Typo3 Backend -> Template -> Constants there is a constant editor. Where does TYPO3 saving the constants? Tried an fgrep -ri for an existing pattern, in case of saving to filesystem - no matches. Tried an MySQL search for an existing pattern, in case of saving to DB -...

Android Studio Best way import module from other repository


android,git,gradle,repository
I have to import a project from a Github repository as a module inside an Android Studio project that it committed into another repository. The project I have to import from Github will be updated constantly so it means that I'll have to refresh every now and again for having...

TYPO3 Solr extension and facets


solr,typo3,typoscript,typo3-6.2.x
I have a small question about TYPO3 solr facets.At present in my website I have 6 different indexing configuration available. Two of them are custom extension table's and one is tt_news and rest of the 3 are pages table with some custom condition. I managed to add this using additionalWhereClause...

File url [tmp_name] after upload via Typo3 backend


typo3,fluid
I'm building a typo3 extension and in a backend plugin I want to build a image upload form. I seem not to get the correct $_Files url. The following fluid form is used: <f:form action="customerSliderImages" id="customerSliderImages"> <f:form.upload name="custSlider[sliderimage]" /> <f:form.submit value="Upload" /> </f:form> I want to have the [name] and...

Using FAL in Extbase correctly


typo3,extbase,fal
Domain model class Image extends AbstractContent { /** * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference */ protected $file; /** * Gets the image file * * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference */ public function getFile() { return $this->file; } /** * Sets the image file * * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file * @return void */ public function setFile($file)...

userfunc condition for detecting mobile device


typo3,typoscript,typo3-7.x
Since TYPO3 7 the condition 'device' and 'useragent' are deprecated. No I'm looking for a userFunc to use as a condition for detecting mobile devices. My aim is to hide or to show some special pages on mobile devices. I used the extension 'contexts_wurfl' for a while but I guess...

Typoscript add class to the first element using stdWrap


typo3,typoscript,typo3-6.2.x
I have a custom requirement to display an image slider using TypoScript. The images are taken from default tt_content image content element. I've added the following TypoScript code to implement this; lib.homeslider = COA lib.homeslider { 10 = CONTENT 10 { table = tt_content select { where = colPos =...

TYPO3-Upgrade 4.5 to 6.2: namespaces


namespaces,typo3,typo3-6.2.x
I'm updating an old TYPO3 to latest verison 6.2.12. As I do so I replace deprecated classes with the proper namespaces. E.g. t3lib_div to \TYPO3\CMS\Core\Utility\GeneralUtility or t3lib_extmgm to \TYPO3\CMS\Core\Utility\ExtensionManagementUtility. But I cant find the proper namespaced class for t3lib_svbase. Any suggestions? . And I absolutely have no clue what I...

Entity Framework relationships between different DbContext and different schemas


c#,entity-framework,foreign-keys,repository,dbcontext
So, I have two main objects, Member and Guild. One Member can own a Guild and one Guild can have multiple Members. I have the Members class in a separate DbContext and separate class library. I plan to reuse this class library in multiple projects and to help differentiate, I...

How to assign variable in fluid?


typo3,fluid,view-helpers
I want viewhelper that can be helpful to assign variable in fluid, I dont want variable to be passed from controller.

findAll on non object in extbase


repository,extbase,findall,typo3-4.5
I just created an extension in typo3 4.5 with one model (product). I created the "productRepository" then injected it in the ProductController but I still get the Call to a member function findAll() on a non-object here is how the ProductController looks like : /** * @var Tx_PiProductDetail_Domain_Repository_ProductRepository */ protected...

Language detection not working in Typo3 6.2.12


typo3,typoscript,typo3-6.2.x,language-detection
I've a website which has 2 languages: German (de) as default and English (en) as translated. I am trying to implement language detection functionality in the website using the extension "rlmp_language_detection" version 7.0.0. What I want to achieve is, for the countries Austria (at), Switzerland (ch) and Germany (de), the...

tt_news single view with static news_id


typo3,tt-news
I am using Typo3 Version 6.2 with the plugin tt_news. All I want to do is: Have a simple page on my website On that page I want to have a tt_news single view the news_id of this view should be static (set by me) and NOT by GET variables...

How to rename a remote git branch name


git,repository,rename,git-branch
I have 4 braches like master -> origin/regacy, FeatureA -> origin/FeatureA. As you can see above, I typed a wrong name. So I want to rename a remote branch name ( origin/regacy => origin/legacy or origin/master) I try to command below. git remote rename regacy legacy But git console retured...

Trying to access Oracle's Maven repository


oracle,maven,repository
I'm attempting to access Oracle's repository. Oracle doesn't make it easy. However, I'm attempting to follow the documentation that Oracle provided. I've: Approved the licensing agreement on my system (in case there's some sort of cookie that needs to be set). Set both M2_HOME and MAVEN_HOME to /usr/share/apache-maven. Created an...

getting a repository for projects


repository
When I was on an army programming course me and my friends used SVN with a repository we had. I wanna set up a repository so that I can work on my projects without having to worry about moving my files from pc to pc and working with the right...