[TYPO3-english] TYPO3 extension thought experiment: Editing a news entry and comment entries in one go
I have a class called news. This class of course has an edit and update Action in its specific controller. Next to this it has objects of the class comments attached to it (the relation to these comments objects is stored in an Object Storage). Normally, as you can imagine, you can edit the news and the comments seperately as they have seperate controllers and their Actions. BUT: Is there a way to edit the news object/record and the comments of it in one go hypothetically? So basically the editAction of the news class assigns the news object with its corresponding Object Storage property "comments" to the view and in the view i can easily access each comment through their relation in the Object Storage and implement them into a form to also change their values... The simplyfied updateAction would look like this (keep in mind the property "comments" of the news is the Object Storage for the comments): public function updateAction(\...\...\Domain\Model\news $news) { $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); $commentRepository = $objectManager->get(\...\...\Domain\Repository\commentRepository::class); foreach($news->getComments() as $comment){ $commentRepository->update($comment); } $this->newsRepository->update($news); $this->redirect('list'); } The (simplified) Edit template would look like this: Do you see the problem in this hypothetical example? Only the news object is passed to the updateAction and of course the Object Storage property ("comments") where the relations to the corresponding comment objects are stored are passed to the updateAction, not the changed comments themselves. So only the changed newsentry is persisted not the changed commnetentries, even though i have the necessary code in the updateAction to do so. So, guys... Is there any solution to this problem or is it not possible at all and i should look for other means to find a solution and don' waste time on this. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: TYPO3 extension: attaching an object to an objectstorage throws a MySQL database error
BTW: In my ext_tables.sql the datatype for the 'checklist' is: checklist smallint(5) unsigned DEFAULT '0' NOT NULL, So i guess this smallint throws the error!? But what datatype should i specify for an objectstorage? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] TYPO3 extension: attaching an object to an objectstorage throws a MySQL database error
One of my TYPO3 extension classes uses a property (checklist) that is an object storage. class Kaufmnnisch extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { public function __construct(){ $this->checklist = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); } /** * checklist * * @var Tx_Extbase_Persistence_ObjectStorage * @lazy */ protected $checklist; /** * Returns the checklist * * @return Tx_Extbase_Persistence_ObjectStorage $checklist */ public function getChecklist() { return $this->checklist; } /** * Sets the checklist * * @param Tx_Extbase_Persistence_ObjectStorage $checklist * @return void */ public function setChecklist($checklist) { $this->checklist = $checklist; } /** * Returns the boolean state of checklist * * @return bool */ public function isChecklist() { return $this->checklist; } To that object storage i want to be able to add objects of the class 'Checkobject' which has just two propeties: 'name' and 'checked'... Within the controller of the class i have following code in the createAction: $Kundenauftragliegtvor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('...\Kundentermine\Domain\Model\Checkobject'); $Kundenauftragliegtvor->setName('Kundenauftrag liegt vor'); $Kaufmnnisch->getChecklist()->attach($Kundenauftragliegtvor); So basically when creating an object of that class i want to initially create the object $Kundenauftragliegtvor (of course later i want to add additional objects of that class, but thats another story)... BUT: When creating an object of the class Kaufmnnisch I get the following error: Incorrect integer value: '' for column 'checklist' at row 1 It seems that attaching the object to the objectstorage 'checklist' seems to create the error in my MySQL database. I suspect that my TCA (specifically the part for the objectstorage) isn't correct: 'checklist' => [ 'exclude' => true, 'label' => 'LLL:EXT:kundentermine/Resources/Private/Language/locallang_db.xlf:tx_kundentermine_domain_model_kaufmnnisch.checklist', 'config' => [ 'type' => 'passthrough', 'items' => [ '1' => [ '0' => 'LLL:EXT:lang/locallang_core.xlf:labels.enabled' ] ], 'default' => 0, ] ], ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Preventing a record to be saved if the BE user input value was undesired?
I want to prevent a BE user from inputting undesired property values for records, let's say for the property IPv4. I wrote an evaluation class for this: class IPv4Evaluation { /** * @param string $value * @param string $is_in * @param bool $set * @return string */ public function evaluateFieldValue($value, $is_in, &$set) { if (!filter_var($value, FILTER_VALIDATE_IP)){ $value = 'Fehlerhafte Eingabe (IPv4): .conf wird nicht angelegt'; /** @var FlashMessage $message */ $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '.conf wird nicht angelegt', 'Fehlerhafte Eingabe (IPv4):', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE ); /** @var $flashMessageService FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $flashMessageService->getMessageQueueByIdentifier()->enqueue($message); } return $value; } } But the only thing that it does while adding it to the field of the specific classe's TCA is to change the value to another value. I also use a flash message to warn the user that the inserted value is false. But i really need the record not to be saved in this situation. So in short: If the BE user does insert an undesired value and he wants to save it, the record will either not be created or not be saved, if he was just editing an existing record. How do i do this? Maybe i should use a Datamapper Hook for this instead of an eval class? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Typo3 Extension: 'Unknown column in field list' error
I have a huge problem adding new classes/models to my extension. Basically: Every time i add a new class/model with the extension_builder and then want to create a record of that class i get the following error message: 2: SQL error: 'Unknown column 'edited' in 'field list'' (tx_icingaconfgen_domain_model_checkperiod:NEW5a27f9da8a41d636846075) The interesting thing is: "edited" is NOT a property of that class, but the property of other classes in that extension. I've searched through the TCA of the class that throws the error and also the MySql table itself, but the field "edited" is indeed not part of that class. What's going on here? Edit: What i find interesting is the fact that when i add a column "edited" to MySql table manually, the record can be created. But in no way i'm using this property in my Model. Why does it require a MySql column of that name then? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: I changed my extension folder name and now Typo3 throws an error message
Topic can be closed... I renamed the folder again and how the extension is name in the PackageStates.php. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] I changed my extension folder name and now Typo3 throws an error message
So today my extension_builder overwrote my entire TCAs while saving, so i did something stupid: i changed the folder name of my extension via winscp and uploaded the backupfolder of my extension i made yesterday. Now i get the error message Oops, an error occurred! TYPO3 Fatal Error: Extension key "icingaconfgen" is NOT loaded! I know the error could be fixed with changing the state of the extension in the PackageStates.php to inactive, but the problem is: The extension doesn't appear in this file. Interesting enough the foldername i changed my old old extension folder to ("x") appears in the file as inactive though. What should i do now? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] displayCond: How can i specify additional optional conditions of the same field?
Basically: In the Backend i want to make specific fields only visible when the BE user chooses a specific value from a drop down menue of another field. I know i have to do this via displayCond in the TCAs, but i'm only able to define ONE condition or rather one value of the specific field to be the condition, like in this line: 'displayCond' => 'FIELD:checktype:=:4', Checktype is a field that uses records from a foreign table in a select drop down menu. The spicific condition is the Uid of my specified record. BUT: how can i add other Uids from the same field as optional conditions? For instance, i experimented with this: 'displayCond' => 'FIELD:checktype:=:4||11||10', Of cause it doesn't work... ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Extension: Automatically delete also the referenced records in BE?
I think (hope) this is a very basic, easy to answer question: In my extension i enable the backend user to create and delete records. Some of these classes define one or more of their properties through the uid of the record/object of another class (with 'type' => 'select' and access to a foreign table in the TCA files). Deleting one of such records gives me the warning message: "Are you sure you want to delete this record? "Test" [tx_icingaconfgen_domain_model_kunde:17] (There are 2 reference(s) to this record!)" Is it possible delete the referenced records as well automatically? And if so: Could i specifiy this only for certain classes? Example: I have a class called "host" and a class called "service"... The class service defines a property called host via the uid of a specific "host" object. If i delete the specific "host" object/record i want all the service objects/records that reference this "host" object automatically. BUT: If i delete a certain "service" object i don't want the "host" record to be deleted, just the "service" record. I guess i could do this via the frontend, but i want this to be specifically possible via the backend. Is there a way to achive this? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Prevent the task from accessing a class repository if there are no records of that class?
I solved the problem myself: Instead of using... if($appliances != null){...} I simply checked if a record in the repository is empty: foreach($appliances as $appliance) { \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(!empty($appliance)); if(!empty($appliance)){ if($appliance->getKundeuid() == $kunde->getUid()) { $name = $appliance->getIpv4intern(); $address = $appliance->getIpv4extern(); $file = '/etc/icinga2/conf.d/hosts/'.$kunde->getName().'/Appliance_'. $appliance->getIpv4intern().'_'.$kunde->getKundennummer() . '.conf'; $code_a = 'object Host "'; $code_b = '" { import "generic-host" address = "'; $code_c = '" vars.notification["mail"] = { groups = [ "icingaadmins" ] } }'; $fp = fopen("{$file}", 'wb'); fwrite($fp, $code_a . $name . $code_b . $address . $code_c); fclose($fp); } } } ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Prevent the task from accessing a class repository if there are no records of that class?
So basically i'm using a Scheduler task in which i first create an object of each class repository and use the function findAll() on each: /** @var CustomerRepository $apprep2 */ $apprep2 = $objectManager->get(\Cjk\Icingaconfgen\Domain\Repository\ApplianceRepository::class); /** @var Typo3QuerySettings $querySettings */ $querySettings = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings'); $querySettings->setRespectStoragePage(FALSE); $apprep2->setDefaultQuerySettings($querySettings); $appliances = $apprep2->findAll(); Then i use each repository object in a foreach loop to access specific properties of each record in the repository (to write them into a file - but that's another story) like this: foreach($appliances as $appliance) { if($appliance->getKundeuid() == $kunde->getUid()) { $name = $appliance->getIpv4intern(); $address = $appliance->getIpv4extern(); $file = '/etc/icinga2/conf.d/hosts/'.$kunde->getName().'/Appliance_'. $appliance->getIpv4intern().'_'.$kunde->getKundennummer() . '.conf'; $code_a = 'object Host "'; $code_b = '" { import "generic-host" address = "'; $code_c = '" vars.notification["mail"] = { groups = [ "icingaadmins" ] } }'; $fp = fopen("{$file}", 'wb'); fwrite($fp, $code_a . $name . $code_b . $address . $code_c); fclose($fp); } } My problem is: The moment i don't have any record of let's say the class "appliance" Typo 3 throws me an error becauuse there is no "appliance" record it wants to access. "Oops, an error occurred! Call to a member function getIpv4intern() on null" Using an if condition like: "if($appliances != null){...}" ..Still makes the task trying to call "getIpv4intern()"... What can i do to prevent the task using the foreach loop (or any other part of my code that tries to access the record, if the record is empty? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 Extension: Controllers can't be found by Backend Module
Can be closed ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Typo3 Extension: Controllers can't be found by Backend Module
Recently I've been trying to create a Backend Module for my extension. More or less for self study reasons, since I technically don't need it, but still, it'd be nice to know what i'm doing wrong. Basically: I have an extension, that works perfectly fine. I can create records in the Backend and the Frontend Actions also work as the should, but for some reason my Backend Module can't find the assigned controllers, even though they work in the Frontend. "Could not analyse class: `Vendor\Icingaconfgen\Controller\ApplianceController` maybe not loaded or no autoloader? Class `Vendor\Icingaconfgen\Controller\ApplianceController` does not exist" That's how i registered my Backend Module in the **ext_tables.php**: if (TYPO3_MODE === 'BE') { \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( 'Vendor.'.$_EXTKEY, 'web', // Main area 'mod1', // Name of the module '', // Position of the module array( // Allowed controller action combinations 'Appliance' => 'list, show, new, create, edit, update, delete', 'Host' => 'list, show, new, create, edit, update, delete' ), array( // Additional configuration 'access'=> 'user,group', 'labels'=> 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xml', ) ); } Maybe there is a missunderstanding on my side. So these controllers are the same as those i use in the Frontend!? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] A refresh in the Backend creates a new record everytime
I have, what i think is a minor problem, so hopefully this won't casue to much troble for anyone helping me: In the Backend i want the user to create records of a specific Model. The form should change depending on a select list which is filled with record of another model. It technically works, i set it up with displayCond conditions and to make it refresh i use the line "$GLOBALS['TCA']['tx_icingaconfgen_domain_model_services']['ctrl']['requestUpdate'] = 'checktype';" in my ext_tables.php, but whenever i choose a option in the select list and i get the referesh notification ("This change will affect which fields are available in the form. Would you like to save now in order to refresh the display?") it creates a record upon clicking on OK. But that's obviously not what i want. Is there maybe another way to refresh? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Thank you very much, it seems to have worked flawlessly. But i had to change the line where i create the Typo3QuerySettings object to "'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings'". I had not time to test it yet in its full extent, because i just got to work, but you saved me a lot of trouble and wasted time. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Quote: christian ewigfrost (ewigfrost) wrote on Tue, 07 November 2017 16:14 Quote: christian ewigfrost (ewigfrost) wrote on Tue, 07 November 2017 16:08 > Quote: Mikel wrote on Tue, 07 November 2017 16:02 > > > The execute method needs a return statement. > > Add return TRUE; add the end of your method. > > > Thanks... It works. > > But the var dump returns NULL. Sry, i realized that the first host object has the uid 128... With that i get the object returned in var dump. So it works flawlessly. But really thanks... So far at least i can access the repository but my biggest concern is actually how to get from here to be able to use findAll(), to auto generate my files as described in the initial post. Any idea why it works with findByUid() and not with findAll? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Quote: christian ewigfrost (ewigfrost) wrote on Tue, 07 November 2017 16:08 Quote: Mikel wrote on Tue, 07 November 2017 16:02 > The execute method needs a return statement. > Add return TRUE; add the end of your method. Thanks... It works. But the var dump returns NULL. Sry, i realized that the first host object has the uid 128... With that i get the object returned in var dump. So it works flawlessly. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Quote: Mikel wrote on Tue, 07 November 2017 16:02 The execute method needs a return statement. Add return TRUE; add the end of your method. Thanks... It works. But the var dump returns NULL. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Quote: christian ewigfrost (ewigfrost) wrote on Tue, 07 November 2017 15:37 Here my TestTask.php: get(\Cjk\Icingaconfgen\Domain\Repository\HostRepository::class); \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($apprep->findByUid(1)); } } But above the error i get a var dump window with NULL. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
It works now, it was my fault... But: I get an error when executing the saved task: Execution of task "Foobar Test ()" failed with the following message: Task failed to execute successfully. Class: Cjk\Icingaconfgen\Tasks\TestTask, UID: 5 ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Here my TestTask.php: get(\Cjk\Icingaconfgen\Domain\Repository\HostRepository::class); \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($apprep->findByUid(1)); } } ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Sry, i'm an idiot... I forgot a semicolon in the line before.^^ It works now. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Quote: Mikel wrote on Tue, 07 November 2017 15:18 > > Oops, an error occurred! > syntax error, unexpected 'DebuggerUtility' (T_STRING) Take the full namespace (or take a use statement at the beggining of your class): \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($apprep->findByUid(1)); Another error: Oops, an error occurred! syntax error, unexpected '\' (T_NS_SEPARATOR) ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
OK, i tried to do what you told me: I registered the task in the ext_localconf.php: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\Cjk\Icingaconfgen\Tasks\TestTask::class] = array( 'extension' => $_EXTKEY, 'title' => 'Foobar Test' ); I created a TestTask.php file in Classes/Command/ directory: get(\Cjk\Icingaconfgen\Domain\Repository\HostRepository::class) DebuggerUtility::var_dump($apprep->findByUid(1)); } } But when i want to save the task Foobar Test i get an error: Oops, an error occurred! syntax error, unexpected 'DebuggerUtility' (T_STRING) ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
One thing i'm confused about: I already registered the CommandController in the ext_localconf.php like this: if (TYPO3_MODE === 'BE') { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'Cjk\\Icingaconfgen\\Command\\SimpleCommandController'; } So i need to additionally add the task? Is this for the execute function? Sry for these stupid questions, this is my 3rd day working with the scheduler and i'm very very new to Typo3, so pls don't hold it against me.^^ ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
..Also the part about: "The TypoScript needs to be present in the root page of your website for backend modules/CommandControllers to use them. I suggest you add the stuff to myext/Configuration/TypoScript/setup.txt and add the static template of your ext to the root page." ..Is something that i can't warp my head around. How do i do this and why should i do this? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
BTW: I used that Stackoverflow post as a reference: https://stackoverflow.com/questions/23068053/in-an-extbase-extension-how-to-access-the-persistence-layer-from-a-scheduler-ta/23077743#23077743 The problem is: I don't understand where to put the line "module.tx_yourext.persistence < plugin.tx_yourext.persistence" since i don't have this setup.txt in the specific directory, but rather a setup.ts. Adding the line to the setup.ts doesn't change anything. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
Quote: Mikel wrote on Tue, 07 November 2017 13:18 Try to fetch a single record with findByUid instead of getting all with findAll. If you get a result, your repository has no records storage uid. You can set it global in TypoScript or you can change your repository settings. Just to go for sure: Rename your method to execute and let your class extend the AbstractTask of TYPO3. Does that solve the problem? Mikel Same as before. I even tried to inject the repositories in the class of the CommandController: /** * hostRepository * * @var \Cjk\Icingaconfgen\Domain\Repository\HostRepository * @inject */ protected $hostRepository; /** * servicesRepository * * @var \Cjk\Icingaconfgen\Domain\Repository\ServicesRepository * @inject */ protected $servicesRepository; And then i just tried to access the repository in the function: $hosts = $this->hostRepository->findAll(); $services = $this->servicesRepository->findAll(); To be clear: The task seems to be run in the Scheduler without problems, but the code doesn't generate the files i want, whereas as a frontend Action it produces them without flaw. I didn't try your execute() suggestion yet. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Command Controller: I can't execute a command that uses class repositories of my extension
The task runs well enough, i tried this with creating a dummy file with some summy text in it with trying to access the repositories. It worked (even without execute()). But it seems i cannot access the repositories from the Command Controller. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Command Controller: I can't execute a command that uses class repositories of my extension
Yesterday i finally got my Typo3 Scheduler working the way i want. Mostly it was the implementation of the CommandController into my extension that was a little bit "problematic". Now i have another question regarding the Scheduler and the CommandController specifically. I have an Action i have implemented in the controller of a class of my extension. This Action i'd like to use automated in the scheduler. Now, what the function does is simply generating a specific file i need to use in another application. The function gets the repsitory of the class "Host" and then finds all objects of it. Then it just uses the properties of each object to generate the beforementioned files. It does the same with the class "services". In the frontend through the Action the code works perfectly and generates the files, but in the CommandController, executed automatically through the Scheduler it simply doesn't work. Is there a missunderstanding on my side? Can't i access each class repository via a command or rather: "Are the repositories only accessable via an Action?" Or is there another error in my thought? Here is the code, it's the way it is implemented in the Action of the class controller AND in the COmmandController: public function simpleCommand() { $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $apprep = $objectManager->get(\Cjk\Icingaconfgen\Domain\Repository\HostRepository::class); $hosts = $apprep->findAll(); $objectManager2 = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $apprep2 = $objectManager2->get(\Cjk\Icingaconfgen\Domain\Repository\ServicesRepository::class); $services = $apprep2->findAll(); foreach($hosts as $host) { $name = $host->getUid(); $address = $host->getIpv4(); $file = '/etc/icinga2/conf.d/hosts/' . $name . '.conf'; $code_a = 'object Host "'; $code_b = '" { import "generic-host" address = "'; $code_c = '" vars.notification["mail"] = { groups = [ "icingaadmins" ] } }'; $fp = fopen("{$file}", 'wb'); fwrite($fp, $code_a . $name . $code_b . $address . $code_c); fclose($fp); mkdir('/etc/icinga2/conf.d/hosts/' . $name); foreach($services as $service) { if($service->getHost() == $name) { $name = $host->getUid(); $chkcmd = 'http'; $file = '/etc/icinga2/conf.d/hosts/'.$name.'/' . $name . '-service.conf'; $code_a = 'object Service "'; $code_b = '" { import "generic-service" host_name = "'; $code_c = '" check_command = "http" }'; $fp = fopen("{$file}", 'wb'); fwrite($fp, $code_a . $name.'-service'. $code_b . $name . $code_c); fclose($fp); } } exec('sudo /etc/init.d/icinga2 restart'); } } ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 scheduler: Can i somehow execute Action of controllers of my extension with it or my code?
Thanks. I'm working with a CommandController now btw. Is still need to figure out how to use it properly but it seems i learn how to properly use the scheduler the way it's supposed to be used. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 scheduler: Can i somehow execute Action of controllers of my extension with it or my code?
I've tried this step by step guide, but the Command simply doesn't pop up in the Scheduler: http://blog.scwebs.in/typo3/typo3-commandcontroller-in-scheduler-task ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 scheduler: Can i somehow execute Action of controllers of my extension with it or my code?
Yeah, i checked that out already. My problem is that i don't know where to put that code. The documentation states: "A task is represented by a PHP class that extends the base task class..." So is the task basically an additional class in my extension and do i therefore create a seperate php file where the other extension class php files are or how should i understand this. It may be because i'm pretty new to Typo3 and especially extension developement (or because i had not enough sleep last night), but i just can't wrap my head around this. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Typo3 scheduler: Can i somehow execute Action of controllers of my extension with it or my code?
A while ago i was tasked to write a Typo3 extension to write so called .conf files for the icinga2 montoring tool (has nothing to do with Typo3). Still let me explain some parts of it: Basically the backend user needs to create records of records of specific classes and set values for each records properties. Then i need to process the records to create these .conf files with the specific values with a php script. I was tasked to use the scheduler in Typo3 for this. And here come the problems: How do i use this? I checked the documentation (https://docs.typo3.org/typo3cms/extensions/scheduler/Introduction/Index.html), but i still can't wrap my head around how to use it for my task. I can easily write an Action in a controller of a class to be executed in the frontend and in turn generate the con files... basically manually without the scheduler. But where do i put my php code to be run by the scheduler? I somehow seem not to understand the basical principle of the scheduler. Can i just run an Action of a specific controller of a class of my extension like i would in the Frontend via the scheduler? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 foreign_table: How to specify a specific column to a select drop down menu?
Quote: Mikel wrote on Wed, 25 October 2017 16:38 OK. Yes, that is possible. Like I said --> itemsProcFunc. Go into your tca, to the select field. 'renderType' => 'selectSingle', 'foreign_table' => 'tx_cvfoobar_domain_model_kunde', 'itemsProcFunc' => ‚Foobar\CvFoobar\Tca\SelectProcFunc->prepareItems', class SelectProcFunc { public function prepareItems($param) { $newItems = []; foreach ($param['items'] as $item) { $newItem = [ 0 => 'Enter your label', 1 => 'enter_your_value' ]; $newItems[] = $newItem; } $param['items'] = $newItems; return $param; } } Just as a quick example. That inserts only static values and labels. To get more information from related Kunde record, you need to make an instance of the repository and load the record by uid. You need to allow string inserts, if kundeuid is just a string. BUT: This is not a very safe solution. You write the values into the database. What happens, if a user changes the kundeuid in one of the records? The relation is broken, as the value has been written into the database. Also, for db queries, you need to compare strings. You also need to evaluate, that kundeuid is unique (if needed). What is your target? Do you want to group records by that attribute „kundeuid"? If so, you should better add another model „Kundengruppe" with m:n relations to Appliance and Kunde. This also would make db queries more easy, as you can build queries from both sides and get your Appliance by Kundengruppe and also your Kunden by Kundengruppe. Mikel Actually assigning the auto generated uid property was the right thing to do, there was just a missunderstanding between my boss and me. My aim is to generate .conf files for the Icinga2 monitoring system and using the tables generated by the extension. A user should be able to create Hosts, Appliances and also create Services that are directly assigned to a Host (and also specified in the .conf files of Icinga, but that has nothing to do with TYPO3, so i won't go into detail). Then an admin should be able to check the entries the user made in the TYPO3 backend and then run a php script that creates those .conf files from the tables that the extension generated. I'm not quite sure yet how to do this yet, but as this has nothing to do with TYPO3 i'll ask at Stackoverflow.^^ But there is one thing i don't know yet: I just can't find the tables in phpmyadmin. I don't know why. ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 foreign_table: How to specify a specific column to a select drop down menu?
Quote: Mikel wrote on Wed, 25 October 2017 15:45 I think, I now understand. You just want to have a different label in your select box, right? If so, you can change that in the TCA of Kunde. 'ctrl' => [ 'label' => 'name', Change the value of label to ‚kundeuid' Or add the „label_alt" option. But that would change the label of your records Kunde global. So your customers will also be shown with that label in the backend listing. If you can't change it global, you need to prepare your items by itemsProcFunc. You can pass the records to your own method and prepare them, before they are assigned to the dropdown. BTW: In my opinion, this relation is more complicated than it should be. Do you want to group customers in that way? Or what is your target of ‚kundeuid'? Thanks for the label tip... But actually what i want to do is soemthing else. I just find it hard to describe because it's the first time i work with TYPO3. I think the following describes it best: I do not want to change the label field of the select items but rather change their values to a value other than the "uid" of the foreign records. That's exactly what i want to do, i want to assign the values of kundeuid to a value other than the "uid" of the foreign records. Is that possible? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 foreign_table: How to specify a specific column to a select drop down menu?
Quote: Mikel wrote on Tue, 24 October 2017 16:40 Do you need something like that? 'foreign_table_where' => 'AND tx_icingaconfgen_domain_model_kunde.your_property = ###REC_FIELD_[tx_icingaconfgen_your_model_to_compare.your_property]###', Sorry, but I'm not sure if I understand your use case. It is a bit hard to read :-) You can also have a look on https://docs.typo3.org/typo3cms/TCAReference/ColumnsConfig/Type/Select.html#itemsprocfunc <https://docs.typo3.org/typo3cms/TCAReference/ColumnsConfig/Type/Select.html#itemsprocfunc> You can prepare the items for the select in your own method. Mikel > Am 24.10.2017 um 15:04 schrieb christian ewigfrost : > > Hmmm... But that's not waht i want to do: What this does is just filtering the assignable records by their properties and then lets me choose the record in the select. But it assigns the entire record or the uid of the record to the property of the creatable record as understand. > What i want to do is: > > Say i'd set 'kundeuid' with the value 'customer01' or something while creating a record of the class Kunde. Then i create a record of the class 'Appliance'. It also has a property named 'kundeuid' and i want to set it through a select that is filled with the 'kundeuid' s from all the records of the class Kunde. One option of this select would be 'customer01' from the record of Kunde i created. I'd choose it and the property 'kundeuid' of the created Appliance record should be also 'customer01'... ___ > TYPO3-english mailing list > TYPO3-english (at) lists.typo3.org > http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english OK, let me try to explain again. Maybe my thought process comes across better this time: In the backend of TYPO3 i have the folder where my records are stored of cause. There are records of the class "Kunde" stored (these are the customers - just the german word for it). Each record of this class has the property 'kundeuid' which isn't the same as the automatically generated property 'uid', but a property that was set manually. Then there are records of the class Appliance. This Appliance record has a property that is also named 'kundeuid' and acts as a way to determine which 'Kunde' record this 'Appliance' record belongs to. (technically it's a 1:n relation between Kunde and Appliance). Now what i want to do is: The user should be able to create a record of Appliance in the backend. The property 'kundeuid' of Appliance should be a select drop down menu that has all the 'kundeuid' values of all existing Kunde records in it. The user should choose one of those values to determine visually which Kunde record the Appliance record "belongs" to. The property 'kundeuid' of the class Appliance should get exactly this value! Let me get to the problem now... My problem currently: 'type' => 'select', 'renderType' => 'selectSingle', 'foreign_table' => 'tx_icingaconfgen_domain_model_kunde', The code above fills the select drop down menu with records of the class Kunde by using it as a foreign_table. That's clear to me... BUT: The property 'kundeuid' of class Appliance doesn't get the value assigned to it that i want. In the drop down menue i don't see the 'kundeuid' property values of all te Kunde records but other values of another property (i think it's the first column of that table). If i choose it in the drop down and then create the Appliance record the Appliance record gets the value of the automatically generated property 'uid' of the specific Kunde record assigned... But i want to assign my own property value 'kundeuid' to it... Is this possible at all or do i missunderstand the entire concept of it? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Re: Typo3 foreign_table: How to specify a specific column to a select drop down menu?
Hmmm... But that's not waht i want to do: What this does is just filtering the assignable records by their properties and then lets me choose the record in the select. But it assigns the entire record or the uid of the record to the property of the creatable record as understand. What i want to do is: Say i'd set 'kundeuid' with the value 'customer01' or something while creating a record of the class Kunde. Then i create a record of the class 'Appliance'. It also has a property named 'kundeuid' and i want to set it through a select that is filled with the 'kundeuid' s from all the records of the class Kunde. One option of this select would be 'customer01' from the record of Kunde i created. I'd choose it and the property 'kundeuid' of the created Appliance record should be also 'customer01'... ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Typo3 foreign_table: How to specify a specific column to a select drop down menu?
Basically a simple question (i guess): I want to add records in the Typo3 backend. Thatfor i made an extension containing 4 different classes. While adding a record of one specific class to a folder via the backend i want to have a select that lets me chose from items of a column from another class. I know i have to use a foreign_table for this like in this code: 'kundeuid' => array( 'exclude' => 1, 'label' => 'LLL:EXT:icingaconfgen/Resources/Private/Language/locallang_db.xlf:tx_icingaconfgen_domain_model_appliance.kundeuid', 'config' => array( 'type' => 'select', 'renderType' => 'selectSingle', 'foreign_table' => 'tx_icingaconfgen_domain_model_kunde', 'foreign_table_where' => 'ORDER BY tx_icingaconfgen_domain_model_kunde.kundeuid asc', 'items' => array( array('-- Select Kunde --', 0), ), 'size' => 1, 'maxitems' => 1 ), ), But the problem is i can't specify that the selection should only include properties of a determined column. Instead the select drop down menu seems to use properties of the very first column. How can i specify the column of the 'kundeuid' property? ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
[TYPO3-english] Using object properties of a list of existing objects options in a form.select viewhelper
Before i start describing the Problem: I'm pretty new to Typo3 and Extension developement for it (it's basically my first Extension and the first time i'm working with Typo3), so don't be to hard on me. Currently im developing an extension that lets the user create objects of the class "Appliance" with the help of a form. Defining the properties through textfields isn't the big problem here, BUT: I want to also implement a drop down box via select in the form. The user should be able to choose from objects (or rather a specific property of These objects - "Kundeuid") of another class ("Kunde") that is of cause also part of the extension. Creating the "Kunde" objects isn't part of the extension. They are created in the backend and stored in a folder (of cause). I want to use these objects in the form.select in the FormFields.html partial as options. But i cant wrap my head around the functionality here. I think my problem is that i don't seem to understand the connection between the controller(s) and the specific templates and partials. The functionality seems to resemble the binding between XAML and C# in WPF (which were my previous projects) but i still can't figure it out. Here the specific partial: Here the specific part of the controller: public function createAction(\Cjk\Icingaconfgen\Domain\Model\Appliance $newAppliance) { $appliancex = $this->objectManager->get('Cjk\\Icingaconfgen\\Domain\\Model\\Appliance'); $appliancex->setKundeuid($newAppliance->getKundeuid()); $appliancex->setIpv4extern($newAppliance->getIpv4extern()); $appliancex->setIpv4intern($newAppliance->getIpv4intern()); $appliancex->setSshport($newAppliance->getSshport()); $appliancex->setPasswordnsclient($newAppliance->getPasswordnsclient()); $appliancex->setPasswordappliance($newAppliance->getPasswordappliance()); $this->applianceRepository->add($appliancex); $this->redirect('list'); } ___ TYPO3-english mailing list TYPO3-english@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english