Kategorien
Agavi Frameworks Javascript PHP

agavi output type overwrite in action

um den output type einer agavi action auch nach dem routing zu ändern, kann man innerhalb der action den output type überschreiben.


/**
 * assume that 'html' is the standard GET output for this action
 * when this action is called via POST you want to change the output type to 'json'
 * because on error or success you want to show small messages per json instead full html
 */
    public function executeRead(AgaviRequestDataHolder $rd)
    {
        return 'Input';
    }

    public function executeWrite(AgaviRequestDataHolder $rd)
    {
        $this->getContainer()->setOutputType($this->getContext()->getController()->getOutputType('json'));
        try
        {
            // do POST stuff
        }
        catch(Exception $e)
        {
            $this->setAttribute('message', $e->getMessage());
            return 'Error';
        }
        return 'Success';
    }
Kategorien
Deployment Linux Server Shell

mit find und xargs alte dateien löschen

Der Konsolen Befehl im Detail:

find . -type f -ctime +3 -maxdepth 1 | xargs rm

find . findet im aktuellen Ordner Dateien (-type f – files) deren Dateistatus vor mehr als 3*24h (-ctime +3) geändert wurde. Mit -maxdepth 1 verhindern wir Rekursion in die Tiefe des aktuellen Ordners.

Die Pipe (|) übergibt das find-Ergebnis nach xargs und führt rm auf jedem einzelnen Ergebnis aus.