/**
  * Returns all instances that implement the requested interface or all of them in not supplied
  * @param string $interface
  * @return array<KalturaPlugin>
  */
 public static function getPluginInstances($interface = null)
 {
     if (!count(self::$pluginInstances)) {
         self::$pluginInstances = array();
         $plugins = self::getPlugins();
         foreach ($plugins as $pluginName => $pluginClass) {
             if (!$pluginClass || !class_exists($pluginClass)) {
                 continue;
             }
             if (!self::isValid($pluginClass, array_keys(self::$pluginInstances))) {
                 continue;
             }
             self::$pluginInstances[$pluginName] = new $pluginClass();
         }
     }
     if (is_null($interface)) {
         return self::$pluginInstances;
     }
     $instances = array();
     foreach (self::$pluginInstances as $pluginInstance) {
         if ($pluginInstance instanceof IKalturaPlugin) {
             $instance = $pluginInstance->getInstance($interface);
             if ($instance) {
                 $instances[strtolower($pluginInstance->getPluginName())] = $instance;
             }
         }
     }
     return $instances;
 }