Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Component / Utility / OpCodeCache.php
1 <?php
2
3 namespace Drupal\Component\Utility;
4
5 /**
6  * Provides helpers to handle PHP opcode caches.
7  *
8  * @ingroup utility
9  */
10 class OpCodeCache {
11
12   /**
13    * Checks if OpCodeCache is enabled.
14    *
15    * @return bool
16    *   TRUE if opcache is enabled, FALSE otherwise.
17    */
18   public static function isEnabled() {
19     return extension_loaded('Zend OPcache') && ini_get('opcache.enable');
20   }
21
22   /**
23    * Invalidates a PHP file from a possibly active opcode cache.
24    *
25    * In case the opcode cache does not support to invalidate an individual file,
26    * the entire cache will be flushed.
27    *
28    * @param string $pathname
29    *   The absolute pathname of the PHP file to invalidate.
30    */
31   public static function invalidate($pathname) {
32     clearstatcache(TRUE, $pathname);
33
34     // Check if the Zend OPcache is enabled and if so invalidate the file.
35     if (function_exists('opcache_invalidate')) {
36       opcache_invalidate($pathname, TRUE);
37     }
38   }
39
40 }