[TYPO3-english] Re: Prevent the task from accessing a class repository if there are no records of that class?

christian ewigfrost christian-kulozik at gmx.net
Fri Nov 17 12:46:57 CET 2017


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);
    }
}
}


More information about the TYPO3-english mailing list