Example #1
0
 /**
  * Create a new object to handle an image
  *
  * @param File $file A file instance of the original image
  *
  * @throws \InvalidArgumentException If the file does not exists or cannot be processed
  *
  * @deprecated Deprecated since Contao 4.3, to be removed in Contao 5.0.
  *             Use the contao.image.image_factory service instead.
  */
 public function __construct(File $file)
 {
     @trigger_error('Using new Contao\\Image() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_factory service instead.', E_USER_DEPRECATED);
     // Check whether the file exists
     if (!$file->exists()) {
         // Handle public bundle resources
         if (file_exists(TL_ROOT . '/web/' . $file->path)) {
             $file = new \File('web/' . $file->path);
         } else {
             throw new \InvalidArgumentException('Image "' . $file->path . '" could not be found');
         }
     }
     $this->fileObj = $file;
     $arrAllowedTypes = \StringUtil::trimsplit(',', strtolower(\Config::get('validImageTypes')));
     // Check the file type
     if (!in_array($this->fileObj->extension, $arrAllowedTypes)) {
         throw new \InvalidArgumentException('Image type "' . $this->fileObj->extension . '" was not allowed to be processed');
     }
 }
Example #2
0
 /**
  * Rotate the log files
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use the logger service instead, which rotates its log files automatically.
  */
 public function rotateLogs()
 {
     @trigger_error('Using Automator::rotateLogs() has been deprecated and will no longer work in Contao 5.0. Use the logger service instead, which rotates its log files automatically.', E_USER_DEPRECATED);
     $arrFiles = preg_grep('/\\.log$/', scan(TL_ROOT . '/system/logs'));
     foreach ($arrFiles as $strFile) {
         $objFile = new \File('system/logs/' . $strFile . '.9');
         // Delete the oldest file
         if ($objFile->exists()) {
             $objFile->delete();
         }
         // Rotate the files (e.g. error.log.4 becomes error.log.5)
         for ($i = 8; $i > 0; $i--) {
             $strGzName = 'system/logs/' . $strFile . '.' . $i;
             if (file_exists(TL_ROOT . '/' . $strGzName)) {
                 $objFile = new \File($strGzName);
                 $objFile->renameTo('system/logs/' . $strFile . '.' . ($i + 1));
             }
         }
         // Add .1 to the latest file
         $objFile = new \File('system/logs/' . $strFile);
         $objFile->renameTo('system/logs/' . $strFile . '.1');
     }
 }
Example #3
0
 /**
  * Rotate the log files
  */
 public function rotateLogs()
 {
     $arrFiles = preg_grep('/\\.log$/', scan(TL_ROOT . '/system/logs'));
     foreach ($arrFiles as $strFile) {
         $objFile = new \File('system/logs/' . $strFile . '.9');
         // Delete the oldest file
         if ($objFile->exists()) {
             $objFile->delete();
         }
         // Rotate the files (e.g. error.log.4 becomes error.log.5)
         for ($i = 8; $i > 0; $i--) {
             $strGzName = 'system/logs/' . $strFile . '.' . $i;
             if (file_exists(TL_ROOT . '/' . $strGzName)) {
                 $objFile = new \File($strGzName);
                 $objFile->renameTo('system/logs/' . $strFile . '.' . ($i + 1));
             }
         }
         // Add .1 to the latest file
         $objFile = new \File('system/logs/' . $strFile);
         $objFile->renameTo('system/logs/' . $strFile . '.1');
     }
 }