Contao\Backend::handleRunOnce PHP Метод

handleRunOnce() публичный статический Метод

Handle "runonce" files
public static handleRunOnce ( )
    public static function handleRunOnce()
    {
        try {
            $files = \System::getContainer()->get('contao.resource_locator')->locate('config/runonce.php', null, false);
        } catch (\InvalidArgumentException $e) {
            return;
        }
        foreach ($files as $file) {
            try {
                include $file;
            } catch (\Exception $e) {
            }
            $strRelpath = str_replace(TL_ROOT . DIRECTORY_SEPARATOR, '', $file);
            if (!unlink($file)) {
                throw new \Exception("The file {$strRelpath} cannot be deleted. Please remove the file manually and correct the file permission settings on your server.");
            }
            \System::log("File {$strRelpath} ran once and has then been removed successfully", __METHOD__, TL_GENERAL);
        }
    }

Usage Example

Пример #1
0
 /**
  * Handles executing the runonce files.
  */
 public function handleRunOnce()
 {
     // Wait for the tables to be created (see #5061)
     if (!$this->hasTable('tl_log')) {
         return;
     }
     Backend::handleRunOnce();
 }